fix(server): show Implement button more reliably for Claude plan mode#2597
fix(server): show Implement button more reliably for Claude plan mode#2597imabdulazeez wants to merge 4 commits intopingdotgg:mainfrom
Conversation
Adds a heuristic to detect and capture plan-like text when Claude completes a plan-mode turn without calling ExitPlanMode. This makes the Implement button appear for structured text plans that don't explicitly use the SDK tool. The fallback gates on all of: - Turn ran in plan mode - No ExitPlanMode already captured - No pending user input request - Turn completed successfully The heuristic checks for: - Text length >= 200 chars (filters trivial responses) - Structural markers (headings, bullet/numbered lists) - Not starting with refusal stems - Either 3+ total list items OR a plan-related heading keyword Captures via the same emitProposedPlanCompleted path, with rawMethod "claude/text-fallback" for observability. Deduplication prevents double-firing when ExitPlanMode already captured the turn. No web/client changes required—the capture flows through existing turn.proposed.completed → activeProposedPlan → Implement button path.
- Store currentInteractionMode in context to properly reflect plan/default mode - Use tracked mode instead of input-based derivation for resolvedInteractionMode - Add null safety check for text block access - Support claude.sdk.text-fallback event source
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces new user-facing capabilities (promote/revert plan buttons) with new orchestration commands, events, persistence operations, and UI state management across multiple packages — constituting a new feature rather than a simple fix. You can customize Macroscope's approvability policy. Learn more. |
- Initialize interactionMode from context instead of hardcoding - Fix plan detection regex to support multiline matching with 'm' flag
- Introduce thread.proposed-plan.promote to allow users to promote assistant messages to proposed plans - Introduce thread.proposed-plan.revert to allow reverting promoted plans back to messages - Remove automatic text-fallback plan capture (looksLikePlan logic) - Update backend event handling, persistence layer, and frontend UI for plan mode interaction
|
Closing since not super happy with this implementation. Reverted to a "promote to plan" button for Claude plan mode messages that do not trigger a plan mode in my own fork for now. |
What Changed
Adds a fallback in
ClaudeAdapterthat captures plan-like assistant text at turn completion when Claude finishes a plan-mode turn without invoking theExitPlanModeSDK tool. The captured text is routed through the existingemitProposedPlanCompletedpath, so the Implement button surfaces unchanged on the client.looksLikePlanheuristic (≥200 chars, heading or list markers, no refusal stems, ≥3 list items or plan-keyword heading).ExitPlanModecapture and no pending user input, emitproposed.completedwith raw sourceclaude.sdk.text-fallback.claude.sdk.text-fallbacktoRuntimeEventRawSource.Server-only change. No web/client edits.
Why
Fixes #2519. With Opus 4.6/4.7, larger plan-mode responses could finish without ever calling
ExitPlanMode, so nothing emitsproposed.completedand the Implement button never appears. This change recognises the de facto plan output and reuses the existing capture path.The fallback is gated conservatively (plan mode, successful completion, no prior capture, no pending input) and dedup via
capturedProposedPlanKeysprevents double-capture whenExitPlanModedoes fire. New raw source keeps fallback captures distinguishable in event telemetry.Known concerns: heuristic is English-only (refusal stems / plan keywords), and thresholds are tuned by inspection — happy to extract to constants or adjust on review.
Checklist
Note
Add promote and revert controls for the Implement button in Claude plan mode
thread.proposed-plan.promoteandthread.proposed-plan.revertorchestration commands so users can promote the latest assistant message to a proposed plan or revert it back to a message.ChatComposerandCompactComposerControlsMenunow renders promote/revert controls when in plan mode and the appropriate state is met.deriveTimelineEntries; only the plan entry is shown.thread.proposed-plan-removedevent type through contracts, server projection pipeline, in-memory projector, and client store to propagate plan removal end-to-end.Macroscope summarized 30d31cf.