feat: add auto-switch Claude Code mode before sending prompts - #5
Merged
Merged
Conversation
Greptile SummaryAdds automatic Claude Code mode switching before sending prompts. When Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant TUI as TUI (model.go)
participant Detector as Claude Detector
participant Tmux as Tmux Client
participant Claude as Claude Code Session
User->>TUI: Press Enter to send prompt
TUI->>TUI: Check config.UI.DefaultMode
alt DefaultMode is set (e.g., "plan")
TUI->>Detector: DetectMode(previewCache content)
Detector-->>TUI: currentMode (e.g., "code")
alt currentMode != targetMode
loop maxCycles (up to 3 times)
TUI->>Tmux: SendKeysToPaneRaw("BTab")
Tmux->>Claude: Send Shift+Tab keystroke
Claude-->>Claude: Cycle to next mode
TUI->>TUI: Sleep 50ms
TUI->>Tmux: CapturePaneDefault()
Tmux-->>TUI: newContent
TUI->>Detector: DetectMode(newContent)
Detector-->>TUI: detectedMode
alt detectedMode == targetMode
TUI->>TUI: Sleep 50ms (stabilize)
TUI->>TUI: addActivity("Switched to X mode")
Note over TUI: Exit loop, proceed to send
end
end
end
end
TUI->>Tmux: SendKeysToPane(promptText)
Tmux->>Claude: Send prompt with Enter(s)
TUI->>TUI: addActivity("Sent: X")
|
| return true | ||
| } | ||
| } | ||
| return true |
There was a problem hiding this comment.
logic: returns true even when mode switch fails after maxCycles
Suggested change
| return true | |
| return false |
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/tui/model.go
Line: 1145:1145
Comment:
**logic:** returns `true` even when mode switch fails after maxCycles
```suggestion
return false
```
How can I resolve this? If you propose a fix, please make it concise.Adds default_mode config option to automatically switch Claude Code to specified mode (plan/code/auto) before sending prompts via ccmanager.
MartianGreed
force-pushed
the
feat/auto-switch-mode
branch
from
January 22, 2026 19:46
15d28d8 to
093ffc2
Compare
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
default_modeconfig option toUIConfig(plan/code/auto/edit or empty to disable)Config Example
Test plan
make build)make test)make lint)default_mode: plan, send prompt from session in edit mode, verify mode switches