Fix nx run completions: use nx graph --file=stdout - #335
Conversation
The workspace_targets generator that powers `nx run <TAB>` completions has been broken since Dec 2024 (PR #166) and was not actually fixed by the Apr 2026 attempt (PR #251, APP-3498): - PR #166 turned `nx graph --file $temp > /dev/null && cat $temp` into `... 2>/dev/null && cat $temp`, so nx's stdout banner from writing the file stopped being discarded and got prepended to the JSON, breaking parsing. - PR #251 tried `nx graph --print` first, but Nx 20.x/21.0 declare that flag without consuming it: nx ignores it and starts the interactive project-graph web server on 127.0.0.1:4211, which never exits. Because it never exits non-zero, the `||` fallback (which still carried the original stdout bug) never ran. `nx graph --file=stdout` is understood by every Nx version tested (20.x-23.x, see APP-5384) and writes only the graph JSON to stdout, with no confirmation banner and no interactive server. No fallback is needed since a single form covers the supported version range, and a fallback that's never reached correctly is worse than none. Verified against real Nx workspaces on nx@20.3.0 (the original reporter's version) and nx@23.1.1: both produce valid JSON and the expected `project:target` suggestions, with no process left listening on port 4211. Fixes warpdotdev/warp#4691. Co-Authored-By: Warp Agent <agent@warp.dev>
|
This PR was generated with Warp. |
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR changes Nx workspace target generation to use nx graph --file=stdout and adds regression coverage for command construction, target parsing, fail-closed behavior on banner-prefixed output, and empty graphs.
Concerns
- No blocking correctness, security, comment-quality, test-quality, or spec-drift concerns found in the provided diff.
spec_context.mdreports no approved or repository spec context.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
@oz-agent delete the comment as requested in my last review. make sure you cover the whole line range. |
|
Oz run started. |
|
I'm working on changes requested in this PR (responding to a PR conversation comment). You can view the conversation on Warp. I pushed changes to this PR based on the comment. Replied to and attempted to resolve 1 review comment that this run addressed. Next steps:
Powered by Oz |
Addresses review feedback on PR #335: delete the multi-paragraph rationale block above NX_WORKSPACE_TARGETS_COMMAND (the requested line range), keeping only the one-line summary. Co-Authored-By: Oz <oz-agent@warp.dev>
|
Deleted the whole comment block you flagged, covering the full requested line range (13–22 of Verified after the deletion: Pushed as commit |
Co-Authored-By: Andy <acarl005@users.noreply.github.com> Co-Authored-By: Oz <oz-agent@warp.dev>
Points at warpdotdev/command-signatures#335, which fixes `nx run <TAB>` completions (APP-5384 / #4691) by switching the workspace_targets generator from the broken `nx graph --print` / tmpfile fallback chain to `nx graph --file=stdout`. NOTE: this currently pins the fix branch's tip commit so CI can build and this diff can be reviewed ahead of time. command-signatures uses squash-merge only, so once #335 merges this rev must be bumped again to the resulting squash commit on main before this PR can land -- the branch (and this commit) will no longer be reachable once GitHub deletes it post-merge. Do not merge this PR until that follow-up bump is made. Co-Authored-By: Warp Agent <agent@warp.dev>
Points at warpdotdev/command-signatures#335 (merged), which fixes `nx run <TAB>` completions (APP-5384 / #4691) by switching the workspace_targets generator from the broken `nx graph --print` / tmpfile fallback chain to `nx graph --file=stdout`. Co-Authored-By: Warp Agent <agent@warp.dev>
Merged PRs: - Fix nx run completions: use nx graph --file=stdout (warpdotdev/command-signatures#335) - Add completion specs for yay and paru (AUR helpers) (warpdotdev/command-signatures#334) - Fix yay/paru completion specs: -Pc field separators and -B/--build option placement (warpdotdev/command-signatures#336) - Forward --context/--cluster/--user in kubectl generators (warpdotdev/command-signatures#331) The kubectl change forwards a --context, --cluster or --user written on the command line into the commands the completion generators run. Without it, completions after a --context enumerated from the shell's active context instead of the one on the line (#5186, #3929). It also adds --user value completions and wires --context/--cluster/--user up for kubecolor and oc. Co-Authored-By: Warp Agent <agent@warp.dev>
…--cluster/--user forwarding) (#15109) ## Description Updates `warp-command-signatures` to `15debaeb`, the squash commit on `command-signatures:main` for warpdotdev/command-signatures#331. That PR fixes the last remaining symptom of #5186: a `--context` (or `--cluster`, or `--user`) written on the command line was never forwarded into the commands the kubectl completion generators run, so later completions enumerated from the shell's active context instead of the one on the line. With `kubectl --context staging-cluster --namespace <TAB>`, the generator ran `kubectl … get namespace -o custom-columns=:.metadata.name` with no `--context`. It now forwards `--context`, `--cluster` and `--user`, mirroring the existing `--kubeconfig` and `--namespace` handling. It also adds value completion for `kubectl --user`, and wires `--context`/`--cluster`/`--user` up for `kubecolor` and `oc`, which declared those options with no generator. ### Merged PRs - Fix nx run completions: use nx graph --file=stdout (warpdotdev/command-signatures#335) - Add completion specs for yay and paru (AUR helpers) (warpdotdev/command-signatures#334) - Fix yay/paru completion specs: -Pc field separators and -B/--build option placement (warpdotdev/command-signatures#336) - Forward --context/--cluster/--user in kubectl generators (warpdotdev/command-signatures#331) ## Linked Issue Addresses #5186 (labeled `ready-to-implement`). Also addresses #3929, which asks for this same context-forwarding behavior. Deliberately no closing keyword — #5186 covers several symptoms and should be closed manually with a note that the earlier parts landed in the June 2026 stable builds. - [x] The linked issue is labeled `ready-to-spec` or `ready-to-implement`. - [ ] Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes). ## Testing The kubectl behavior is covered by unit tests in warpdotdev/command-signatures#331, which assert the generated command string rather than merely that completion happens — including an `assert_eq` on the entire command for the reported case, and a tightened `test_context_and_namespace_flags_before_subcommand` (it previously passed a `--context` but only checked namespace forwarding, which is why the earlier #247 fix missed this). That repo's `./script/presubmit` and CI were green on merge: 174 tests, 33 of them kubectl-specific. For this dependency bump: - `cargo fmt --all --check` passes. - `cargo clippy -p warp_completer --all-targets --tests -- -D warnings` passes against the new rev. - `cargo metadata --locked` accepts the lockfile, so `Cargo.lock` is in sync; the lockfile diff is limited to the two `command-signatures` source lines. - `cargo tree -p warp_completer -i warp-command-signatures` confirms `15debaeb` is what resolves. - `cargo test -p warp_completer` reports 138 passed / 25 failed, identical to `origin/master` with this change stashed. Those 25 failures are pre-existing in this environment and unrelated to the bump. There are no kubectl-specific tests in `warp_completer`. - [ ] I have manually tested my changes locally with `./script/run` ### Screenshots / Videos No capture taken. Exercising this path in a running client requires a full client build against the bumped rev, which is expensive relative to the value: warpdotdev/command-signatures#247 already carries screenshots of the `--context`/`--cluster` value completion working, #331 carries end-to-end evidence from real `kubectl` runs against a synthetic offline kubeconfig, and the generated command is asserted precisely by unit tests. ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode <!-- ## Changelog Entries for Stable --> CHANGELOG-IMPROVEMENT: Added completions for `yay` and `paru`, and `kubectl --user` value completions. CHANGELOG-BUG-FIX: Fixed `kubectl` completions ignoring a `--context`, `--cluster` or `--user` written on the command line, so namespaces, pods and other resources are now suggested from that cluster instead of the shell's active context. `kubecolor` and `oc` now complete those flags too, and `nx run` completions were fixed. <!-- warp:pr-description-artifacts start --> <!-- warp:pr-description-artifacts end --> Co-authored-by: Warp Agent <agent@warp.dev>


Summary
nx run <TAB>completions produce no suggestions on any currently-supported Nx version. Fixes warpdotdev/warp#4691 / APP-5384.Only
nx runis affected —nx build/serve/test/lintuse theapps_and_libsgenerator (nx show projects), which was verified working and is left untouched.Root cause
Two bugs in sequence in the
workspace_targetsgenerator (src/generators/nx.rs):CommandBuilderstruct #166).nx graph --file $temp > /dev/null && cat $tempbecame... 2>/dev/null && cat $temp.nx graph --fileprints a human-readable banner on stdout when writing the file, so it stopped being discarded and got prepended to the JSONcat $tempprinted, breakingserde_jsonparsing.nx graph --printfirst, falling back to the (still-broken) tmpfile form. Nx 20.x and 21.0 declare--printbut never consume it — nx ignores it and starts the interactive project-graph web server on127.0.0.1:4211, which never exits. Because it never exits non-zero, the||fallback never runs.Changes
--print-then-tmpfile chain with a singlenx graph --file=stdoutcommand. Nx has a special case for the literalstdouttarget that writes only the graph JSON to stdout — no confirmation banner, no interactive server — and it is understood by every Nx version tested (20.x-23.x). No fallback is needed since one form now covers the full supported range; keeping a fallback that's never reached correctly would just carry the latent bug forward.CommandBuilderrefactor can't silently reintroduce a bad redirect the way PR Fully migrate to theCommandBuilderstruct #166 did), one coveringprocess_workspace_targetsparsing real graph JSON intoproject:targetsuggestions, and one asserting parsing fails closed (no panic, empty results) if banner text ever precedes the JSON again.Verification
Built a real Nx workspace (3 projects:
admin-integrations,upsert-worker,utils, matching the original reporter's shape) and ran the actual generator command against bothnx@20.3.0(the reporter's exact version) and currentnx@23.1.1:Also reproduced the current bug for confirmation:
nx graph --printonnx@20.3.0hangs (exit=124under a 20s timeout) with the daemon printingProject graph started at http://127.0.0.1:4211/projects; confirmed no listener remains on port 4211 after the fixed--file=stdoutcommand runs.Checks run:
cargo fmt -p warp-command-signatures -p warp-completion-metadata --check— passcargo clippy -p warp-command-signatures -p warp-completion-metadata --all-targets --all-features -- -D warnings— passcargo test --verbose -p warp-command-signatures -p warp-completion-metadata— 145 + 10 tests pass (including the 4 new/updatednx::tests)Left alone (out of scope)
Triage (APP-5384) noted no timeout exists on generator execution (
GeneratorContext::execute_command_at_pwd→CommandExecutor::execute_commandinwarpdotdev/warp) and suspected a leakednx graphprocess per completion attempt on the old--printpath. This PR confirms that concern:timeout 20 nx graph --printhad to be force-killed, and without an external timeout the process (and its web server on port 4211) would keep running indefinitely for everynx run<TAB>attempt on old Nx. That's a separate, larger fix inwarpdotdev/warp's command execution path and is deliberately out of scope here per APP-5384.Shipping to users
warpdotdev/warppins this repo by commitrevinCargo.toml(currently32a7fd56, the exact commit this branch is based on), not by a published version, so merging this PR does not ship anything by itself. A follow-up PR bumping thatrev(andCargo.lock) inwarpdotdev/warpis required — opened separately, see below.