Skip to content

feat: add mode authority markers, plan-decline tracking, and improved mode-switching UX#133

Merged
shayne-snap merged 1 commit into
mainfrom
feat/mode-flow-plan-agent-ask
May 25, 2026
Merged

feat: add mode authority markers, plan-decline tracking, and improved mode-switching UX#133
shayne-snap merged 1 commit into
mainfrom
feat/mode-flow-plan-agent-ask

Conversation

@shayne-snap
Copy link
Copy Markdown
Contributor

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

  • Mode authority block — system prompt now explicitly declares the current mode and states to treat any conflicting conversation history, hidden markers, or assistant reasoning as stale
  • Mode-changed hidden markers — when mode is switched via SetMode, a hidden message is recorded documenting the transition, including a note that mode changes do not retroactively approve plans
  • Plan-decline tracking — a new IntentDeclinePlan intent and RecordPlanNotApproved method record a hidden <plan_not_approved> marker, preventing the agent from acting on a declined plan that remains in history

Mode-Switching UX

  • Updated blocked-tool messages in ask mode and plan mode to suggest specific commands (/agent, /plan, /ask) and the Shift+Tab shortcut instead of vague instructions
  • Added mode-switching command documentation in the system prompt: Mode 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

  • Simplified buildImplementPlanPrompt to 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 prompts
  • TestDeclinePlanPersistsHiddenMarkerAndStaysInPlanMode — tests the plan-decline flow via service dispatch
  • TestEscDeclinePlan — tests the TUI popup escape key declines plan and clears stale plan state
  • Updated existing test fixtures to match new mode-switching message text

Files Changed

  • internal/agent/stream.go — updated mode-blocked messages with specific commands
  • internal/agent/system_prompt.go — added mode authority block, mode-switching instructions, date/time instruction
  • internal/agent/system_prompt_test.go — new test for mode authority block
  • internal/app/app.go — calls RecordModeChanged on mode switch
  • internal/app/plan_markers.go — new file with RecordPlanNotApproved and RecordModeChanged
  • internal/app/service/dispatch.go — handles IntentDeclinePlan, simplified prompt builder
  • internal/app/service/events_test.go — new test for plan-decline dispatch
  • internal/tui/chat_view.go — minor cleanup
  • internal/tui/model_keys.go — plan-decline key handling with state clearing
  • internal/tui/model_test.go — new test for esc decline in TUI

… 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
@shayne-snap shayne-snap merged commit 959ee26 into main May 25, 2026
2 checks passed
@shayne-snap shayne-snap deleted the feat/mode-flow-plan-agent-ask branch May 25, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant