Skip to content

Conversation

@ThomasK33
Copy link
Member

@ThomasK33 ThomasK33 commented Dec 8, 2025

Summary

  • Plan Mode workflow: Toggle between Plan/Exec modes (Cmd+Shift+M). In Plan mode, file edits restricted to ~/.mux/plans/<workspace-id>.md. Agent proposes plans via propose_plan tool for user review before implementation.
  • External file change detection: Timestamp-based polling detects external edits to plan files, computes unified diffs, injects as synthetic user messages to keep agent aware without breaking prompt cache.
  • ProposePlan UI: Markdown rendering, edit-in-editor button, "Start Here" context reset, fresh content on window focus.
  • File edit refactoring: Extracted shared execution pipeline, runtime-aware path validation, custom diff utility replacing external dependency.

Test plan

  • Toggle Plan/Exec mode with keyboard shortcut
  • Verify file edits blocked for non-plan files in Plan mode
  • Edit plan externally, confirm agent sees changes on next query
  • Run make test for unit test coverage
  • Run TEST_INTEGRATION=1 bun x jest tests/ipc/fileChangeNotification.test.ts for integration tests

Generated with mux

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ammario
Copy link
Member

ammario commented Dec 8, 2025

This seems like a lot of complexity... are you not able to get steering with the system prompt?

@ThomasK33
Copy link
Member Author

This seems like a lot of complexity... are you not able to get steering with the system prompt?

What steering are you referring to?

@ammario
Copy link
Member

ammario commented Dec 8, 2025

Seems like you're trying to fix the issue where the agent makes edits via bash when in plan mode, which is primarily the case with non-Anthropic models?

@ThomasK33
Copy link
Member Author

Seems like you're trying to fix the issue where the agent makes edits via bash when in plan mode, which is primarily the case with non-Anthropic models?

No, not at all. This approach is somewhat inspired by the planning system in Claude Code, which also writes to a Markdown file.

Essentially, it's a way to reduce output tokens and achieve a faster, more consistent iterative planning loop with the LLM, since the propose_plan tool call doesn’t need to reprint the entire plan each time, and more efficient file editing operations.

Additionally, the file will be useful in a follow-up PR, as we’ll be able to "attach" the plan to the workspace. After compaction, the plan can be included verbatim, supporting a more reliable and longer-running agentic loop.

@ThomasK33
Copy link
Member Author

Additionally, sharing the plan with others will become easier, enabling a future where a PR could include the plan file, making it accessible and helping developers achieve alignment more quickly.

@ammario
Copy link
Member

ammario commented Dec 8, 2025

Ah ok, understood. I misinterpreted the PR title.

Add Plan Mode - a deliberate workflow where agents propose plans before implementation.

## Core Features

**Plan Mode Workflow**
- Toggle between Plan and Exec modes with Cmd+Shift+M / Ctrl+Shift+M
- In Plan mode, file edits are restricted to ~/.mux/plans/<workspace-id>.md
- Agent writes plan via file_edit tools, then calls propose_plan to present for review
- Users can edit plans externally (in their preferred editor) before approval
- Start CLI sessions in plan mode with `mux run --mode plan`

**External File Change Detection**
- Timestamp-based polling detects when users edit plan files externally
- Computes unified diff of changes and injects as synthetic user message
- Agent automatically sees external modifications without manual notification
- Preserves prompt cache by injecting as user message, not system message mutation

**ProposePlan Tool UI**
- Renders proposed plans with markdown formatting
- Edit button opens plan in native terminal editor ($EDITOR)
- Fresh content refetches on window focus for external edit workflow
- "Start Here" button replaces chat context with plan (for long sessions)
- Show Text/Markdown toggle for raw vs rendered views

## Infrastructure

**File Edit Tool Refactoring**
- Extracted common execution pipeline (executeFileEditOperation)
- Shared validation utilities (isPlanFileAccess, validatePathInCwd)
- Custom diff utility (computeDiff) replaces external dependency
- Runtime-aware path resolution for SSH compatibility

**Test Coverage**
- Unit tests for change detection algorithm and diff computation
- Integration tests for file change notifications via IPC
- Plan mode enforcement tests for file_edit_* tools
- Tests for both local and SSH runtime scenarios

## Documentation
- New docs/plan-mode.mdx with comprehensive usage guide
- Updated docs/cli.mdx with --mode flag documentation
- Navigation updated in docs.json

fix: use local filesystem for plan files in SSH workspaces

Plan files are local artifacts that should always be stored on the
local machine, not on remote SSH hosts. Previously, plan mode would
use the workspace runtime for file operations, causing plan files
to be written to/read from the remote host when using SSH workspaces.

Add localRuntime option to tool config that bypasses SSH for plan
file I/O. The AI service now creates a LocalRuntime instance when
in plan mode, and file edit tools select the appropriate runtime
based on whether the operation targets a plan file.
@ThomasK33
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33 ThomasK33 added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit dc6e5b1 Dec 9, 2025
19 checks passed
@ThomasK33 ThomasK33 deleted the plan-mode branch December 9, 2025 10:59
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.

2 participants