Skip to content

test(prompt): read the prompt the LLM receives, not --show-prompt's stdout - #4207

Merged
max-sixty merged 4 commits into
mainfrom
release
Sep 21, 2026
Merged

max-sixty merged 4 commits into
mainfrom
release

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

test_show_prompt_ignores_diff_display_config was meant to pin that the LLM prompt ignores color.ui, diff.external, and diff.noprefix. It compared --show-prompt stdout, which .output() pipes, so anstream stripped ANSI and the color.ui = always case passed whatever the diff code did.

Now test_generation_prompt_ignores_diff_display_config, it points commit.generation.command at a script that saves its stdin, and compares the bytes the LLM command actually receives for wt step commit --dry-run and wt step squash --dry-run. It asserts no escape byte directly and checks the prompt matches the default-config prompt byte for byte. The branch-summary prompt had no such test; picker/summary.rs gets the same check. With PreparedDiff::capture reverted to porcelain, both tests fail on the escape-byte assertion.

An earlier version of this PR also moved has_staged_changes onto plumbing; #4192 makes that change with more coverage, so it's dropped here.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 20, 2026 18:02
`WorkingTree::has_staged_changes` ran porcelain `git diff --cached
--quiet`, which honors `submodule.<name>.ignore`. Under `= all`, a
staged submodule pointer bump read as nothing staged, so `wt step
commit` bailed "Nothing to commit" while its own `--dry-run` — which
already renders the staged diff through plumbing — showed the bump, and
`wt step squash` took the already-squashed exit and left it uncommitted.

It now runs `diff-index` through `PlumbingDiff::args`, which overrides
that setting, and branches on the exit code rather than reading any
failure as "has changes", so a git error surfaces instead of passing for
a staged change. `--ita-invisible-in-index` keeps an `add -N` path
unstaged, which is the answer porcelain gave and the one the staged diff
renders.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…tdout

`test_show_prompt_ignores_diff_display_config` compared `--show-prompt`
stdout across three diff-display settings. Two of them change the
prompt's content, so they were real; `color.ui = always` was not, because
`.output()` pipes stdout and anstream strips ANSI on a pipe. Both runs
produced identical bytes whether or not the diff was colored, so that
third of the test could not fail — it passes against the v0.78.0 binary,
which the setting did reach.

Now renamed to `test_generation_prompt_ignores_diff_display_config`, it
points `commit.generation.command` at a script that writes its stdin to a
file, so the comparison is over the bytes wt actually hands the command,
where the color survives. It asserts directly that those bytes carry no
escape byte. `--dry-run` stages into a temp index, so neither run mutates
what the other reads.

The branch summary had no coverage at all, and its prompt reaches a
command's stdin the same way, so `generate_summary` gets the same test
beside it.

Both fail when `PreparedDiff::capture` is put back on porcelain.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#4192 makes the same change to has_staged_changes — PlumbingDiff::Index plus the exit-code match — so one of the two should close as a duplicate. It also carries the error-path test noted inline below, which is worth keeping on whichever survives.

Comment thread src/git/repository/working_tree.rs Resolved
Comment thread tests/integration_tests/merge.rs Resolved
#4192 makes the same change with more coverage (git errors, nested
discovery under diff.relative, intent-to-add, ignored gitlinks), so this
PR keeps only the prompt-test repair. Also corrects the capture-path
comment in the generation-prompt test, which described a shared command
the loop doesn't use.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty max-sixty changed the title fix(commit): read staged changes with plumbing test(prompt): read the prompt the LLM receives, not --show-prompt's stdout Sep 21, 2026
@max-sixty
max-sixty merged commit 5d994f9 into main Sep 21, 2026
40 checks passed
@max-sixty
max-sixty deleted the release branch September 21, 2026 02:53
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.

2 participants