Skip to content

[Graphite MQ] Draft PR GROUP:spec_aefa9c (PRs 41) - #45

Closed
graphite-app[bot] wants to merge 1 commit into
masterfrom
gtmq_spec_aefa9c_1790955510920-cebf207b-7b2e-4300-8a4e-043dc76ac867
Closed

graphite-app[bot] wants to merge 1 commit into
masterfrom
gtmq_spec_aefa9c_1790955510920-cebf207b-7b2e-4300-8a4e-043dc76ac867

Conversation

@graphite-app

@graphite-app graphite-app Bot commented Oct 2, 2026

Copy link
Copy Markdown

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:

## 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 graphite-app Bot closed this Oct 2, 2026
@graphite-app
graphite-app Bot deleted the gtmq_spec_aefa9c_1790955510920-cebf207b-7b2e-4300-8a4e-043dc76ac867 branch October 2, 2026 15:39
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.

1 participant