diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 2a97e33b..e316e96d 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -79,6 +79,7 @@ After runtime replacement, use `runtimeHost.session` as the new live session and ### Fixed +- Fixed startup resource loading to reuse the initial `ResourceLoader` for the first runtime, so extensions are not loaded twice before session startup and `session_start` handlers still fire for singleton-style extensions ([#2766](https://github.com/badlogic/pi-mono/issues/2766)) - Fixed theme `export` colors to resolve theme variables the same way as `colors`, so `/export` HTML backgrounds now honor entries like `pageBg: "base"` instead of requiring inline hex values ([#2707](https://github.com/badlogic/pi-mono/issues/2707)) ## [0.64.0] - 2026-03-29 diff --git a/packages/coding-agent/src/core/agent-session-runtime.ts b/packages/coding-agent/src/core/agent-session-runtime.ts index 4f2fd8ce..6b59335a 100644 --- a/packages/coding-agent/src/core/agent-session-runtime.ts +++ b/packages/coding-agent/src/core/agent-session-runtime.ts @@ -53,6 +53,8 @@ export interface CreateAgentSessionRuntimeOptions { cwd: string; /** Optional preselected session manager. If omitted, normal session resolution applies. */ sessionManager?: SessionManager; + /** Optional preloaded resource loader to reuse instead of creating and reloading one. */ + resourceLoader?: ResourceLoader; /** Optional session_start metadata to emit when the runtime binds extensions. */ sessionStartEvent?: SessionStartEvent; } @@ -86,15 +88,18 @@ export async function createAgentSessionRuntime( const settingsManager = SettingsManager.create(cwd, agentDir); const modelRegistry = ModelRegistry.create(authStorage, join(agentDir, "models.json")); const resourceLoader = - typeof bootstrap.resourceLoader === "function" + options.resourceLoader ?? + (typeof bootstrap.resourceLoader === "function" ? await bootstrap.resourceLoader(cwd, agentDir) : new DefaultResourceLoader({ ...(bootstrap.resourceLoader ?? {}), cwd, agentDir, settingsManager, - }); - await resourceLoader.reload(); + })); + if (!options.resourceLoader) { + await resourceLoader.reload(); + } const extensionsResult = resourceLoader.getExtensions(); for (const { name, config } of extensionsResult.runtime.pendingProviderRegistrations) { diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index d3fdb88b..64ab41c8 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -873,6 +873,7 @@ export async function main(args: string[]) { const runtime = await createAgentSessionRuntime(runtimeBootstrap, { cwd: sessionManager?.getCwd() ?? cwd, sessionManager, + resourceLoader, }); if (process.cwd() !== runtime.cwd) { process.chdir(runtime.cwd);