fix(coding-agent): add session_shutdown reasons closes #2863
This commit is contained in:
@@ -45,6 +45,7 @@ import type {
|
||||
SessionBeforeForkResult,
|
||||
SessionBeforeSwitchResult,
|
||||
SessionBeforeTreeResult,
|
||||
SessionShutdownEvent,
|
||||
ToolCallEvent,
|
||||
ToolCallEventResult,
|
||||
ToolResultEvent,
|
||||
@@ -168,11 +169,12 @@ export type ShutdownHandler = () => void;
|
||||
* Helper function to emit session_shutdown event to extensions.
|
||||
* Returns true if the event was emitted, false if there were no handlers.
|
||||
*/
|
||||
export async function emitSessionShutdownEvent(extensionRunner: ExtensionRunner): Promise<boolean> {
|
||||
export async function emitSessionShutdownEvent(
|
||||
extensionRunner: ExtensionRunner,
|
||||
event: SessionShutdownEvent,
|
||||
): Promise<boolean> {
|
||||
if (extensionRunner.hasHandlers("session_shutdown")) {
|
||||
await extensionRunner.emit({
|
||||
type: "session_shutdown",
|
||||
});
|
||||
await extensionRunner.emit(event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -512,9 +512,12 @@ export interface SessionCompactEvent {
|
||||
fromExtension: boolean;
|
||||
}
|
||||
|
||||
/** Fired on graceful process shutdown paths such as Ctrl+C, Ctrl+D, SIGHUP, and SIGTERM. */
|
||||
/** Fired before an extension runtime is torn down due to quit, reload, or session replacement. */
|
||||
export interface SessionShutdownEvent {
|
||||
type: "session_shutdown";
|
||||
reason: "quit" | "reload" | "new" | "resume" | "fork";
|
||||
/** Destination session file when shutting down due to session replacement. */
|
||||
targetSessionFile?: string;
|
||||
}
|
||||
|
||||
/** Preparation data for tree navigation */
|
||||
|
||||
Reference in New Issue
Block a user