feat(coding-agent): add ctx.reload and reload-runtime example closes #1371

This commit is contained in:
Mario Zechner 2026-02-08 15:08:16 +01:00
parent 0bd205ab87
commit e1b56c1d28
8 changed files with 114 additions and 0 deletions

View file

@ -147,6 +147,8 @@ export type NavigateTreeHandler = (
export type SwitchSessionHandler = (sessionPath: string) => Promise<{ cancelled: boolean }>;
export type ReloadHandler = () => Promise<void>;
export type ShutdownHandler = () => void;
/**
@ -210,6 +212,7 @@ export class ExtensionRunner {
private forkHandler: ForkHandler = async () => ({ cancelled: false });
private navigateTreeHandler: NavigateTreeHandler = async () => ({ cancelled: false });
private switchSessionHandler: SwitchSessionHandler = async () => ({ cancelled: false });
private reloadHandler: ReloadHandler = async () => {};
private shutdownHandler: ShutdownHandler = () => {};
private shortcutDiagnostics: ResourceDiagnostic[] = [];
private commandDiagnostics: ResourceDiagnostic[] = [];
@ -269,6 +272,7 @@ export class ExtensionRunner {
this.forkHandler = actions.fork;
this.navigateTreeHandler = actions.navigateTree;
this.switchSessionHandler = actions.switchSession;
this.reloadHandler = actions.reload;
return;
}
@ -277,6 +281,7 @@ export class ExtensionRunner {
this.forkHandler = async () => ({ cancelled: false });
this.navigateTreeHandler = async () => ({ cancelled: false });
this.switchSessionHandler = async () => ({ cancelled: false });
this.reloadHandler = async () => {};
}
setUIContext(uiContext?: ExtensionUIContext): void {
@ -501,6 +506,7 @@ export class ExtensionRunner {
fork: (entryId) => this.forkHandler(entryId),
navigateTree: (targetId, options) => this.navigateTreeHandler(targetId, options),
switchSession: (sessionPath) => this.switchSessionHandler(sessionPath),
reload: () => this.reloadHandler(),
};
}

View file

@ -306,6 +306,9 @@ export interface ExtensionCommandContext extends ExtensionContext {
/** Switch to a different session file. */
switchSession(sessionPath: string): Promise<{ cancelled: boolean }>;
/** Reload extensions, skills, prompts, and themes. */
reload(): Promise<void>;
}
// ============================================================================
@ -1234,6 +1237,7 @@ export interface ExtensionCommandContextActions {
options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },
) => Promise<{ cancelled: boolean }>;
switchSession: (sessionPath: string) => Promise<{ cancelled: boolean }>;
reload: () => Promise<void>;
}
/**