feat: add mode authority markers, plan-decline tracking, and improved mode-switching UX#133
Merged
Merged
Conversation
… mode-switching UX - Add mode authority block to system prompt declaring current mode as authoritative and treating conflicting history/stale info as stale - Record hidden mode-changed markers when mode is switched via SetMode, including a note that mode changes do not retroactively approve plans - Record hidden plan-not-approved marker when user declines a plan, preventing the agent from acting on the declined plan from history - Update blocked-tool messages in ask/plan modes to suggest /agent,/plan commands and Shift+Tab shortcut instead of vague instructions - Simplify buildImplementPlanPrompt to drop redundant plan text (already in agent context) - Add comprehensive test coverage for all new behaviors
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.
Summary
This PR improves mode management by adding authoritative mode markers, plan-decline tracking, and clearer mode-switching instructions throughout the system.
Changes
Mode Authority & Markers
SetMode, a hidden message is recorded documenting the transition, including a note that mode changes do not retroactively approve plansIntentDeclinePlanintent andRecordPlanNotApprovedmethod record a hidden<plan_not_approved>marker, preventing the agent from acting on a declined plan that remains in historyMode-Switching UX
/agent,/plan,/ask) and theShift+Tabshortcut instead of vague instructionsMode switching commands are /agent, /ask, and /plan. Shift+Tab cycles modes in the TUI. Do not tell users to run /mode agent, /mode ask, or /mode plan; those commands do not exist.Cleanup
buildImplementPlanPromptto drop the redundant plan text (the plan is already in the agent's context window)Test Coverage
TestImmutableSystemBlocksDeclareCurrentModeAuthoritatively— verifies the mode authority block and mode-switching instructions appear in system promptsTestDeclinePlanPersistsHiddenMarkerAndStaysInPlanMode— tests the plan-decline flow via service dispatchTestEscDeclinePlan— tests the TUI popup escape key declines plan and clears stale plan stateFiles Changed
internal/agent/stream.go— updated mode-blocked messages with specific commandsinternal/agent/system_prompt.go— added mode authority block, mode-switching instructions, date/time instructioninternal/agent/system_prompt_test.go— new test for mode authority blockinternal/app/app.go— callsRecordModeChangedon mode switchinternal/app/plan_markers.go— new file withRecordPlanNotApprovedandRecordModeChangedinternal/app/service/dispatch.go— handlesIntentDeclinePlan, simplified prompt builderinternal/app/service/events_test.go— new test for plan-decline dispatchinternal/tui/chat_view.go— minor cleanupinternal/tui/model_keys.go— plan-decline key handling with state clearinginternal/tui/model_test.go— new test for esc decline in TUI