-
Notifications
You must be signed in to change notification settings - Fork 1.4k
improve worktree creation progress #1869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the worktree creation progress reporting in the Copilot CLI chat sessions to use a task-based progress indicator instead of separate progress and warning calls.
- Modernizes progress reporting to use
stream.progress()with a callback task - Changes warning reporting to use
progress.report()within the task callback - Provides a more integrated UX by showing progress status during the asynchronous operation
| await stream.progress(vscode.l10n.t('Creating isolated worktree for session...'), async (progress) => { | ||
| try { | ||
| const worktreePath = await vscode.commands.executeCommand('git.createWorktreeWithDefaults') as string | undefined; | ||
| if (worktreePath) { | ||
| return vscode.l10n.t('Created isolated worktree at {0}', worktreePath); | ||
| } else { | ||
| progress.report(new vscode.ChatResponseWarningPart(vscode.l10n.t('Failed to create worktree for isolation, using default workspace directory'))); | ||
| } | ||
| } catch (error) { | ||
| progress.report(new vscode.ChatResponseWarningPart(vscode.l10n.t('Error creating worktree for isolation: {0}', error instanceof Error ? error.message : String(error)))); | ||
| } | ||
| } catch (error) { | ||
| stream.warning(vscode.l10n.t('Error creating worktree for isolation: {0}', error instanceof Error ? error.message : String(error))); | ||
| } | ||
| }); | ||
|
|
||
| return undefined; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactored code breaks the function's return value. Previously, createWorktreeIfNeeded would return the worktreePath string on success, which was then used at line 350 to store the worktree path. Now the function always returns undefined at line 58, even when a worktree is successfully created at line 47.
The worktree path needs to be captured from the progress callback and returned:
let worktreePath: string | undefined = undefined;
await stream.progress(vscode.l10n.t('Creating isolated worktree for session...'), async (progress) => {
try {
worktreePath = await vscode.commands.executeCommand('git.createWorktreeWithDefaults') as string | undefined;
if (worktreePath) {
return vscode.l10n.t('Created isolated worktree at {0}', worktreePath);
} else {
progress.report(new vscode.ChatResponseWarningPart(vscode.l10n.t('Failed to create worktree for isolation, using default workspace directory')));
}
} catch (error) {
progress.report(new vscode.ChatResponseWarningPart(vscode.l10n.t('Error creating worktree for isolation: {0}', error instanceof Error ? error.message : String(error))));
}
});
return worktreePath;
No description provided.