Open
Conversation
ce8bfa2 to
7311dff
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new /clearAndImplement slash command to the agent participant that allows users to start a fresh implementation session with the plan from session memory, avoiding context bloat from the planning conversation.
Changes:
- Adds
/clearAndImplementslash command that creates a new chat session and copies plan.md to the new session's memory - Updates the Plan agent's "Start Implementation" handoff button to use
/clearAndImplementinstead of a plain text prompt - Exports
MEMORY_BASE_DIRfrom memoryTool.tsx and addscommandsandwindowto vscodeTypes for accessing VS Code APIs - Includes test updates reflecting the handoff button changes
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscodeTypes.ts | Exports commands and window namespaces from VS Code API for accessing command execution and active chat panel session resource |
| src/util/common/test/shims/vscodeTypesShim.ts | Adds test shims for the new commands and window exports |
| src/extension/tools/node/memoryTool.tsx | Exports MEMORY_BASE_DIR constant for use in planAgentProvider |
| src/extension/intents/node/agentIntent.ts | Adds handler for clearAndImplement command that delegates to the IRunCommandExecutionService |
| src/extension/common/constants.ts | Maps clearAndImplement command to Agent intent |
| src/extension/agents/vscode-node/planAgentProvider.ts | Implements the core clearAndImplement logic including command registration, session memory copying, and new chat creation |
| src/extension/agents/vscode-node/test/planAgentProvider.spec.ts | Updates test expectations to reflect the new handoff button label and prompt changes |
| package.json | Adds clearAndImplement to the agent participant's command contributions |
| package.nls.json | Adds localized description for the clearAndImplement command |
Comments suppressed due to low confidence (3)
src/extension/agents/vscode-node/planAgentProvider.ts:355
- The command execution at line 307 (fallback path) and line 336 (error path) use
_sendChatQuery('Start implementation')which sends an in-session handoff. However, the successful path at lines 352-355 usesexecuteCommand('workbench.action.chat.open', ...)withmode: 'agent'andquery: 'Start implementation'. These two code paths may produce different user experiences. Consider whether the fallback and error paths should also use the same command and options as the success path, or document why they should differ.
await this._sendChatQuery('Start implementation');
return;
}
// Listen for the new session resource BEFORE creating the chat
let eventDisposable: vscode.Disposable | undefined;
const eventPromise = new Promise<vscode.Uri | undefined>(resolve => {
eventDisposable = vscode.window.onDidChangeActiveChatPanelSessionResource(newResource => {
resolve(newResource);
});
});
const newSessionPromise = raceTimeout(eventPromise, NEW_SESSION_RESOURCE_TIMEOUT_MS).finally(() => {
eventDisposable?.dispose();
});
// Create a new chat session
await this.runCommandService.executeCommand('workbench.action.chat.newChat');
// Wait for the new session resource
let newSessionResource = vscode.window.activeChatPanelSessionResource;
if (newSessionResource && newSessionResource.toString() !== currentSessionResource.toString()) {
// Fast path: resource already changed, dispose listener immediately
eventDisposable?.dispose();
} else {
newSessionResource = await newSessionPromise;
}
if (!newSessionResource) {
this.logService.warn('[PlanAgentProvider] Failed to get new session resource');
await this._sendChatQuery('Start implementation');
return;
}
// Copy plan.md to the new session's memory
const newSessionId = extractSessionId(newSessionResource.toString());
const newSessionDir = vscode.Uri.joinPath(
URI.from(storageUri), MEMORY_BASE_DIR, newSessionId
);
await createDirectoryIfNotExists(this.fileSystemService, newSessionDir);
const newPlanUri = vscode.Uri.joinPath(newSessionDir, 'plan.md');
await this.fileSystemService.writeFile(newPlanUri, planContent);
this.logService.trace(`[PlanAgentProvider] Copied plan.md from session ${currentSessionId} to ${newSessionId}`);
// Open in agent mode with "Start implementation"
await this.runCommandService.executeCommand('workbench.action.chat.open', {
mode: 'agent',
query: 'Start implementation',
});
src/extension/intents/node/agentIntent.ts:28
- Import order is inconsistent with the codebase convention. Imports from
../../../vscodeTypesshould be grouped together after all platform imports (from../../../platform/) and before extension-level imports (from../../). This import should be moved to line 33, after the blank line followingIWorkspaceServiceimport and before the blank line that precedes the util imports.
import { ChatResponseProgressPart2 } from '../../../vscodeTypes';
src/extension/agents/vscode-node/planAgentProvider.ts:332
- There's a potential race condition where the event listener may not be properly disposed if the promise resolves before reaching the fast path check. If
newSessionResourceis already set when accessed at line 326 but the event fires between line 326 and line 329, the event could resolve the promise, which would trigger thefinallycleanup at line 318-320, and then the code would also calldispose()again at line 329, resulting in a double-dispose. While this is generally safe for VS Code disposables, it would be cleaner to ensure the listener is only disposed once. Consider wrapping the fast path disposal in a check or using a flag to prevent double disposal.
let newSessionResource = vscode.window.activeChatPanelSessionResource;
if (newSessionResource && newSessionResource.toString() !== currentSessionResource.toString()) {
// Fast path: resource already changed, dispose listener immediately
eventDisposable?.dispose();
} else {
newSessionResource = await newSessionPromise;
}
7311dff to
a7cbbde
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.