fix(coding-agent): emit session name changes to extensions

This commit is contained in:
Alexey Zaytsev
2026-06-30 00:38:06 -05:00
parent 927e98068c
commit 726a9c526c
6 changed files with 49 additions and 1 deletions
@@ -2683,7 +2683,9 @@ export class AgentSession {
*/
setSessionName(name: string): void {
this.sessionManager.appendSessionInfo(name);
this._emit({ type: "session_info_changed", name: this.sessionManager.getSessionName() });
const event = { type: "session_info_changed", name: this.sessionManager.getSessionName() } as const;
this._emit(event);
void this._extensionRunner.emit(event);
}
// =========================================================================
@@ -128,6 +128,7 @@ export type {
SessionBeforeTreeResult,
SessionCompactEvent,
SessionEvent,
SessionInfoChangedEvent,
SessionShutdownEvent,
// Events - Session
SessionStartEvent,
@@ -551,6 +551,13 @@ export interface SessionStartEvent {
previousSessionFile?: string;
}
/** Fired when the current session metadata changes. */
export interface SessionInfoChangedEvent {
type: "session_info_changed";
/** Current normalized session name. Undefined when the name is cleared. */
name: string | undefined;
}
/** Fired before switching to another session (can be cancelled) */
export interface SessionBeforeSwitchEvent {
type: "session_before_switch";
@@ -630,6 +637,7 @@ export interface SessionTreeEvent {
export type SessionEvent =
| SessionStartEvent
| SessionInfoChangedEvent
| SessionBeforeSwitchEvent
| SessionBeforeForkEvent
| SessionBeforeCompactEvent
@@ -1133,6 +1141,7 @@ export interface ExtensionAPI {
on(event: "project_trust", handler: ProjectTrustHandler): void;
on(event: "resources_discover", handler: ExtensionHandler<ResourcesDiscoverEvent, ResourcesDiscoverResult>): void;
on(event: "session_start", handler: ExtensionHandler<SessionStartEvent>): void;
on(event: "session_info_changed", handler: ExtensionHandler<SessionInfoChangedEvent>): void;
on(
event: "session_before_switch",
handler: ExtensionHandler<SessionBeforeSwitchEvent, SessionBeforeSwitchResult>,
+1
View File
@@ -122,6 +122,7 @@ export type {
SessionBeforeSwitchEvent,
SessionBeforeTreeEvent,
SessionCompactEvent,
SessionInfoChangedEvent,
SessionShutdownEvent,
SessionStartEvent,
SessionTreeEvent,