fix(coding-agent): reuse initial resource loader on startup closes #2766
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user