-
Notifications
You must be signed in to change notification settings - Fork 8
feat(code): Add "clear and continue from plan" option in plan mode #1249
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
base: main
Are you sure you want to change the base?
Changes from all commits
a0c1945
7e6f3b0
14b852f
34f4e5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import type { | |
| RequestPermissionResponse, | ||
| } from "@agentclientprotocol/sdk"; | ||
| import type { PermissionUpdate } from "@anthropic-ai/claude-agent-sdk"; | ||
| import { POSTHOG_NOTIFICATIONS } from "../../../acp-extensions"; | ||
| import { text } from "../../../utils/acp-content"; | ||
| import type { Logger } from "../../../utils/logger"; | ||
| import { toolInfoFromToolUse } from "../conversion/tool-use-to-acp"; | ||
|
|
@@ -193,6 +194,44 @@ async function applyPlanApproval( | |
| }; | ||
| } | ||
|
|
||
| // Clear history and continue from plan — approve, switch mode, then signal renderer | ||
| if ( | ||
| response.outcome?.outcome === "selected" && | ||
| response.outcome.optionId === "clearAndContinue" | ||
| ) { | ||
| const planText = extractPlanText(updatedInput); | ||
|
|
||
| session.permissionMode = "default"; | ||
| await session.query.setPermissionMode("default"); | ||
| await context.client.sessionUpdate({ | ||
| sessionId: context.sessionId, | ||
| update: { | ||
| sessionUpdate: "current_mode_update", | ||
| currentModeId: "default", | ||
| }, | ||
| }); | ||
| await context.updateConfigOption("mode", "default"); | ||
|
|
||
| // Signal the renderer to clear the session and re-inject the plan | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the renderer responsible for clearing the session and reinjecting the plan? |
||
| if (planText) { | ||
| await context.client.extNotification( | ||
| POSTHOG_NOTIFICATIONS.CLEAR_AND_CONTINUE, | ||
| { | ||
| sessionId: context.sessionId, | ||
| plan: planText, | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| return { | ||
| behavior: "allow", | ||
| updatedInput, | ||
| updatedPermissions: context.suggestions ?? [ | ||
| { type: "setMode", mode: "default", destination: "localSettings" }, | ||
| ], | ||
| }; | ||
| } | ||
|
|
||
| const customInput = (response._meta as Record<string, unknown> | undefined) | ||
| ?.customInput as string | undefined; | ||
| const feedback = customInput?.trim(); | ||
|
|
||
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.
Why would we approve a plan and then go to
Defaultinstead ofAccept edits?