feat(tui): add interactive plan mode and fix compilation - #639
Conversation
WalkthroughAdds ChangesPlan mode and TUI plan editing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/tui/plan_command.go`:
- Around line 50-53: Update the bare `/plan` handling in the branch checking
`m.permissionMode == agent.PermissionModePlan` so it resets `m.permissionMode`
to `agent.PermissionModeAuto` before appending the current plan, preserving the
documented toggle behavior.
- Line 12: The TUI imports an unavailable planmode package, preventing
compilation. In internal/tui/plan_command.go, correct the import to the existing
package path or restore the internal/planmode package with PlanFilePath,
ReadPlan, and WritePlan implementations matching the command’s usage.
In `@internal/tui/run.go`:
- Line 60: Initialize the model’s program reference before constructing the
Bubble Tea program: update the setup around initialModel.program and
tea.NewProgram so the model receives a non-nil program when it starts, or remove
the under-test guard and rely on the returned tea.ExecProcess command.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 352feb84-b16b-454f-999a-7e857405bda9
📒 Files selected for processing (5)
internal/agent/loop.gointernal/agent/types.gointernal/tui/model.gointernal/tui/plan_command.gointernal/tui/run.go
| tea "charm.land/bubbletea/v2" | ||
|
|
||
| "github.com/Gitlawb/zero/internal/agent" | ||
| "github.com/Gitlawb/zero/internal/planmode" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | 🏗️ Heavy lift
Restore the missing planmode package or correct this import.
Current checks fail because github.com/Gitlawb/zero/internal/planmode is not provided by the module. This blocks compilation of the TUI; commit the package implementing PlanFilePath, ReadPlan, and WritePlan, or import the existing package path.
🧰 Tools
🪛 GitHub Check: Security & code health
[failure] 12-12:
could not import github.com/Gitlawb/zero/internal/planmode (invalid package name: "")
[failure] 12-12:
no required module provides package github.com/Gitlawb/zero/internal/planmode; to add it:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/tui/plan_command.go` at line 12, The TUI imports an unavailable
planmode package, preventing compilation. In internal/tui/plan_command.go,
correct the import to the existing package path or restore the internal/planmode
package with PlanFilePath, ReadPlan, and WritePlan implementations matching the
command’s usage.
Source: Linters/SAST tools
| // No subcommand: toggle plan mode, then surface the current plan. | ||
| if m.permissionMode == agent.PermissionModePlan { | ||
| m.transcript = reduceTranscript(m.transcript, transcriptAction{kind: actionAppendSystem, text: m.planText()}) | ||
| return m, nil |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make bare /plan actually toggle plan mode.
When plan mode is already active, this branch only displays the plan and never exits the mode. That conflicts with the documented /plan toggle behavior and the PR objective. Reset permissionMode to PermissionModeAuto here, or revise the command contract to make /plan view-only.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/tui/plan_command.go` around lines 50 - 53, Update the bare `/plan`
handling in the branch checking `m.permissionMode == agent.PermissionModePlan`
so it resets `m.permissionMode` to `agent.PermissionModeAuto` before appending
the current plan, preserving the documented toggle behavior.
| initialModel.mouseCapture = true | ||
| } | ||
| program = tea.NewProgram(initialModel, programOpts...) | ||
| initialModel.program = program |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
rg -n -C 3 'tea\.NewProgram\(|initialModel\.program|m\.program|tea\.ExecProcess' internal/tuiRepository: Gitlawb/zero
Length of output: 1613
Initialize program before calling tea.NewProgram
initialModel.program = program happens after tea.NewProgram(initialModel, ...), so the running model still sees m.program == nil. That forces /plan open down the “under test” path and skips launching the editor. Set the field before handing the model to Bubble Tea, or remove the guard and rely on the returned tea.ExecProcess command.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/tui/run.go` at line 60, Initialize the model’s program reference
before constructing the Bubble Tea program: update the setup around
initialModel.program and tea.NewProgram so the model receives a non-nil program
when it starts, or remove the under-test guard and rely on the returned
tea.ExecProcess command.
This PR adds interactive, read-only plan mode toggled via /plan in the TUI, allowing the user to view, open, and edit the plan file, and fixes plan command compilation issues (migrating editor spawning to tea.ExecProcess and correcting signature check of planmode.PlanFilePath).
Summary by CodeRabbit
New Features
/plansupport for opening the current plan in$VISUALor$EDITOR.Bug Fixes