Skip to content

refactor: remove progress service dependency and optimize chat session forking#306207

Draft
DonJayamanne wants to merge 1 commit intomainfrom
don/helpful-raccoon
Draft

refactor: remove progress service dependency and optimize chat session forking#306207
DonJayamanne wants to merge 1 commit intomainfrom
don/helpful-raccoon

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 30, 2026 02:53
@DonJayamanne DonJayamanne self-assigned this Mar 30, 2026
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the chat “Fork Conversation” action to remove the progress service dependency and reduce duplicate contributed-session forks by deduplicating in-flight fork operations.

Changes:

  • Removed IProgressService dependency from chat fork action handling.
  • Added in-flight fork deduplication (pendingFork map) for contributed chat sessions.
  • Routed contributed-session forking through an action-instance helper to reuse/dedupe fork execution.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/actions/chatForkActions.ts:253

  • In forkContributedChatSession(...), the deferred navigation path uses setTimeout(async () => { await chatWidgetService.openSession(...) }) without any error handling; if openSession rejects this can surface as an unhandled promise rejection. Consider wrapping the callback in try/catch (and report/log the error), or returning/awaiting a promise that captures failures.
async function forkContributedChatSession(sourceSessionResource: URI, request: IChatSessionRequestHistoryItem | undefined, openForkedSessionImmediately: boolean, chatSessionsService: IChatSessionsService, chatWidgetService: IChatWidgetService) {
	const cts = new CancellationTokenSource();
	try {
		const forkedItem = await chatSessionsService.forkChatSession(sourceSessionResource, request, cts.token);

Comment on lines +232 to +246
private async forkContributedChatSession(sourceSessionResource: URI, request: IChatSessionRequestHistoryItem | undefined, openForkedSessionImmediately: boolean, chatSessionsService: IChatSessionsService, chatWidgetService: IChatWidgetService) {
const pendingKey = `${sourceSessionResource.toString()}@${request?.id ?? 'full'}`;
const pending = this.pendingFork.get(pendingKey);
if (pending) {
return pending;
}

const forkPromise = forkContributedChatSession(sourceSessionResource, request, openForkedSessionImmediately, chatSessionsService, chatWidgetService);
this.pendingFork.set(pendingKey, forkPromise);
try {
await forkPromise;
} finally {
this.pendingFork.delete(pendingKey);
}
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pendingFork is cleared once forkContributedChatSession(...) resolves, but when openForkedSessionImmediately is false the helper schedules openSession via setTimeout without awaiting it. This means the dedupe window ends before navigation happens, so a user can still trigger another /fork and create another session before the first forked session opens. Consider keeping the pending entry until the deferred openSession completes (e.g., have the helper return a promise that includes the deferred open, or delay deletion until after the scheduled open finishes).

This issue also appears on line 250 of the same file.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants