mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Update active session while it is in progress
This commit is contained in:
@@ -132,6 +132,11 @@ export class ActiveAgentSessionService extends Disposable implements IActiveAgen
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Update active session when the agent sessions model changes (e.g., metadata updates with worktree/repository info)
|
||||
this._register(this.agentSessionsService.model.onDidChangeSessions(() => {
|
||||
this.refreshActiveSessionFromModel();
|
||||
}));
|
||||
}
|
||||
|
||||
private registerChatBarWidgetTracking(): void {
|
||||
@@ -206,6 +211,29 @@ export class ActiveAgentSessionService extends Disposable implements IActiveAgen
|
||||
}
|
||||
}
|
||||
|
||||
private refreshActiveSessionFromModel(): void {
|
||||
const currentActive = this._activeSession.get();
|
||||
if (!currentActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
const agentSession = this.agentSessionsService.model.getSession(currentActive.resource);
|
||||
if (!agentSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [repository, worktree] = this.getRepositoryFromMetadata(agentSession.metadata);
|
||||
if (currentActive.repository?.toString() !== repository?.toString() || currentActive.worktree?.toString() !== worktree?.toString()) {
|
||||
const activeSessionItem: IActiveAgentSessionItem = {
|
||||
...agentSession,
|
||||
repository,
|
||||
worktree,
|
||||
};
|
||||
this.logService.info(`[ActiveAgentSessionService] Active session updated from model: ${currentActive.resource.toString()}, repository: ${repository?.toString() ?? 'none'}, worktree: ${worktree?.toString() ?? 'none'}`);
|
||||
this._activeSession.set(activeSessionItem, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private getRepositoryFromMetadata(metadata: { readonly [key: string]: unknown } | undefined): [URI | undefined, URI | undefined] {
|
||||
if (!metadata) {
|
||||
return [undefined, undefined];
|
||||
|
||||
Reference in New Issue
Block a user