Skip to content

feat(plan-mode): Persist plans as markdown and fix approval UX#461

Merged
edenreich merged 1 commit intomainfrom
feat/persist-plans-as-markdown
Apr 27, 2026
Merged

feat(plan-mode): Persist plans as markdown and fix approval UX#461
edenreich merged 1 commit intomainfrom
feat/persist-plans-as-markdown

Conversation

@edenreich
Copy link
Copy Markdown
Contributor

@edenreich edenreich commented Apr 27, 2026

Summary

  • Closes [TASK] Plans should be written to disk as Markdowns #434RequestPlanApproval now writes the plan to <configDir>/plans/<timestamp>-<slug>.md (atomic write) and reads it back as canonical content; the default plan-mode prompt mandates an 8-section H2 template (Context, Files to Modify, Current Code, Changes, Performance Impact, Critical Files, Edge Cases, Verification).
  • Fixes several pre-existing plan-mode bugs surfaced during end-to-end testing: dropped reasoning_content on the post-approval turn (DeepSeek 400); race that marked the wrong assistant message as IsPlan; approval-button navigation didn't refresh the viewport; up/down arrow triggered history navigation while approval was pending; the plan body was rendered with an empty visible region above the buttons.
  • Adds docs/plan-mode.md, a RequestPlanApproval entry in docs/tools-reference.md, and a CLAUDE.md pointer; adds plans/ to .infer/.gitignore (project + cmd/init.go embedded copy).

Closes #434.

The RequestPlanApproval tool now writes the plan to
<configDir>/plans/<timestamp>-<slug>.md (atomic .tmp + rename) and reads
the file back as the canonical plan content. The default plan-mode
system prompt requires the plan body to use a fixed 8-section H2
template (Context, Files to Modify, Current Code, Changes, Performance
Impact, Critical Files, Edge Cases, Verification).

Several existing plan-mode bugs surfaced by end-to-end testing are also
fixed in this branch:

- Reasoning_content was dropped on the post-approval continuation,
  triggering a 400 from DeepSeek's thinking mode. The synthesized
  IsPlan assistant message duplicated the tool-call args without
  reasoning, so it's now filtered from the request via a new
  buildAgentMessagesFromEntries helper.
- A race between publishPlanApprovalRequest and MarkLastMessageAsPlan
  could mark the LLM's preamble turn as IsPlan, causing the wrong
  content to render under "Plan (Pending Approval):". Event
  publication now happens inside createPlanMessage, after the IsPlan
  entry is added; the redundant MarkLastMessageAsPlan call was
  removed.
- Plan-approval button navigation (left/right) updated state but
  didn't trigger a re-render, so the highlighted button never moved.
  A new PlanApprovalSelectionChangedEvent now drives the viewport
  refresh.
- Up/down arrows during plan approval triggered history navigation;
  they're now disabled while plan or tool approval is pending.
- renderPlanEntry put role + body on one line and produced an
  effectively-empty body. It now mirrors renderShortcutOutput so the
  full markdown plan is visible above the buttons.

Adds docs/plan-mode.md, a RequestPlanApproval entry in
docs/tools-reference.md, and a CLAUDE.md section pointing to them.
Adds plans/ to .infer/.gitignore (project + the embedded copy in
cmd/init.go) so persisted plans don't leak into commits.
@edenreich edenreich merged commit da9a47c into main Apr 27, 2026
5 checks passed
@edenreich edenreich deleted the feat/persist-plans-as-markdown branch April 27, 2026 22:43
ig-semantic-release-bot Bot pushed a commit that referenced this pull request Apr 27, 2026
## [0.105.0](v0.104.2...v0.105.0) (2026-04-27)

### 🚀 Features

* **plan-mode:** Persist plans as markdown and fix approval UX ([#461](#461)) ([da9a47c](da9a47c)), closes [#434](#434)

### 🧹 Maintenance

* **nix:** Update package to v0.104.2 ([#460](#460)) ([05fe627](05fe627))
@ig-semantic-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.105.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Plans should be written to disk as Markdowns

1 participant