[Graphite MQ] Draft PR GROUP:spec_aefa9c (PRs 41) - #45
Closed
graphite-app[bot] wants to merge 1 commit into
Closed
graphite-app[bot] wants to merge 1 commit into
graphite-app[bot] wants to merge 1 commit into
Conversation
## Summary
`--agent-mode` had no effect. `Execute` calls `InitAgentMode` before cobra parses flags, to keep the explorer TUI away from agents. That call can only see the environment, and its answer was final: `InitAgentMode` checked the flag only after a `CompareAndSwap` that every later call failed. So:
- `--agent-mode=false` under Claude Code still printed JSON envelopes.
- `--agent-mode` in a plain shell still printed human errors.
- The flag's help ("Use --agent-mode=false to disable") was untrue.
`InitAgentMode` now checks for an explicitly set `--agent-mode` before that early return, so the call from `PersistentPreRunE`, the first to see the parsed flags, applies it. The environment is still checked only once. The explorer check is unchanged: it only runs when vf has no arguments, so no flag can be present.
This PR and #38 can merge in either order. #38's stdin rule reads `output.IsAgentMode()` each time instead of keeping a copy (addressing Copilot's review there), so it follows this flag too. That is checked with both applied: `--agent-mode` turns the no-wait rule on outside an agent, and `--agent-mode=false` under `CLAUDECODE=1` turns it off.
## Before and after
| | master | this PR |
|---|---|---|
| `CLAUDECODE=1 vf workspace list --agent-mode=false` with no token | JSON envelope | human error |
| `vf workspace list --agent-mode` with no agent env and no token | human error | JSON envelope |
| `CLAUDECODE=1 vf agent update --llm gpt-4 --agent-mode=false` | envelope | human error |
## Test plan
- [x] `gofmt`, `go vet ./...` and `go test ./...` pass; `go.mod` is unchanged.
- [x] `internal/output/agentmode_test.go` replays Execute's early call and then PersistentPreRunE's call. It covers the flag in both directions and both no-flag cases; 2 cases fail on master.
- [x] `test/agent-mode-flag.test.ts`: 4 cases; 3 fail on master.
- [x] Full suite with #37 and #38 applied: 86/86. With the other three fixes from this batch as well: 101/101.
- [ ] CI: `CLI behaviour` shows master's 4 existing failures until #37 merges.
graphite-app
Bot
deleted the
gtmq_spec_aefa9c_1790955510920-cebf207b-7b2e-4300-8a4e-043dc76ac867
branch
October 2, 2026 15:39
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.
This draft PR was created by the Graphite merge queue.
Trunk will be fast forwarded to the HEAD of this PR when CI passes, and the original PRs will be closed.
The following PRs are included in this draft PR: