feat(code): Add "clear and continue from plan" option in plan mode#1249
feat(code): Add "clear and continue from plan" option in plan mode#1249littlekirkycode wants to merge 4 commits intoPostHog:mainfrom
Conversation
Adds /clear slash command that resets conversation history and starts a fresh session. Suppresses the SDK's built-in /clear (which doesn't work in our context) and replaces it with our own implementation. resetSession() now clears UI history by skipping log replay on reconnect.
Remove inline import in commands.ts. Rewrite resetSession() to create a new task run via createNewLocalSession() instead of clearing in-memory logs, ensuring old messages don't reappear on app restart.
Adds "Yes, clear history and continue from plan" option when exiting plan mode. Clears conversation history and re-injects the approved plan as the first prompt. Useful when context window is filling up during planning — lets the agent start fresh with just the plan.
ddb341b to
14b852f
Compare
| ) { | ||
| const planText = extractPlanText(updatedInput); | ||
|
|
||
| session.permissionMode = "default"; |
There was a problem hiding this comment.
Why would we approve a plan and then go to Default instead of Accept edits?
| }); | ||
| await context.updateConfigOption("mode", "default"); | ||
|
|
||
| // Signal the renderer to clear the session and re-inject the plan |
There was a problem hiding this comment.
Why is the renderer responsible for clearing the session and reinjecting the plan?
If we're going to be creating a new local session, do we need this notification at all?
jonathanlab
left a comment
There was a problem hiding this comment.
Thanks for the PR! It unfortunately does not seem to work for me:
10:21:30.815 (agent-service) › Failed to create session {
code: -32603,
message: 'Internal error',
data: { details: 'Query closed before response received' }
}
10:21:30.816 (session-service) › Failed to clear and continue from plan {
taskId: '98c4f413-d7d4-4903-8fcf-346256f3d420',
error: 'TRPCClientError: Internal error\n' +
' at TRPCClientError2.from (http://localhost:5173/node_modules/.vite/deps/chunk-3EEZN4XF.js?v=2a9e1145:2031:44)\n' +
' at Object.next (http://localhost:5173/@fs/Users/jonathan/dev/twig/packages/electron-trpc/src/renderer/ipcLink.ts:80:46)\n' +
' at #handleResponse (http://localhost:5173/@fs/Users/jonathan/dev/twig/packages/electron-trpc/src/renderer/ipcLink.ts:31:23)\n' +
' at http://localhost:5173/@fs/Users/jonathan/dev/twig/packages/electron-trpc/src/renderer/ipcLink.ts:23:27'
}
Above happened after creating a plan, then clicking clear and continue.
Also left some concerns w.r.t how we make the client responsible for this logic.
| }); | ||
| await context.updateConfigOption("mode", "default"); | ||
|
|
||
| // Signal the renderer to clear the session and re-inject the plan |
There was a problem hiding this comment.
Why is the renderer responsible for clearing the session and reinjecting the plan?
If we're going to be creating a new local session, do we need this notification at all?
Closes #704
Summary
Adds a third option when exiting plan mode: "Yes, clear history and
continue from plan". Clears the conversation and re-sends the approved
plan as the first prompt — useful when the context window filled up
during planning and you want the agent to start implementing with maximum
available context.
Flow
Agent-side
The permission handler extracts the plan text and signals the renderer
via
extNotification:Renderer-side
SessionServicedetects the notification, queues the plan, and executesafter the turn completes:
The plan is queued (not executed immediately) because the notification
arrives mid-turn — we wait for the current turn to finish before
clearing.
Changes
acp-extensions.tsCLEAR_AND_CONTINUEnotification constantpermission-options.tsclearAndContinueoption to plan exit dialogpermission-handlers.tsclearAndContinue— switch mode, send notificationpackage.json./acp-extensionssubpathtsup.config.tsacp-extensions.tsbuild entryservice.tspendingPlanContinuationsmap, notification detection,executeClearAndContinue()Test plan
as first prompt
unchanged