fix(workflows): render gate show_file contents in the interactive prompt#2810
Open
doquanghuy wants to merge 1 commit into
Open
fix(workflows): render gate show_file contents in the interactive prompt#2810doquanghuy wants to merge 1 commit into
doquanghuy wants to merge 1 commit into
Conversation
The gate step read and recorded `show_file` but never displayed its contents at the interactive prompt, so the operator approved/rejected without seeing the referenced file. Render the file inside the prompt when stdin is a TTY, with a graceful notice for missing/unreadable files. Non-interactive PAUSED behaviour, exit codes, resume semantics, and no-`show_file` output are unchanged. Closes github#2809. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b43191b to
5412c47
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the built-in workflow gate step so that a configured show_file is actually rendered in the interactive prompt, allowing operators to review the referenced file contents before choosing approve/reject. It adds a bounded, non-throwing file-read helper and extends test coverage around the interactive/non-interactive behaviors.
Changes:
- Render
show_filecontents inside the interactive gate prompt (before the options). - Add
_read_show_file()helper that caps output length and degrades to a one-line notice on read/decode errors. - Add targeted tests covering interactive rendering, missing files, non-interactive pause behavior, empty files, and truncation.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/steps/gate/__init__.py |
Passes show_file into the gate prompt and safely renders file contents with truncation/error notices. |
tests/test_workflows.py |
Adds regression tests for interactive rendering and safe behavior across missing/empty/large files and non-interactive runs. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+85
to
+89
| if show_file and isinstance(show_file, str): | ||
| print(" │") | ||
| print(f" │ {show_file}:") | ||
| for line in GateStep._read_show_file(show_file): | ||
| print(f" │ {line}") |
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.
Description
Closes #2809.
The built-in
gatestep accepts ashow_fileconfig field. The value was read, template-expanded, and stored inoutput["show_file"], but its contents were never displayed at the interactive prompt — the operator was asked to approve/reject without seeing the referenced file.This renders
show_fileinside the interactive gate prompt, before the options. A missing or undecodable file degrades to a short one-line notice instead of raising, so a misconfigured path never breaks the prompt.What changed
GateStep._prompt(...)now acceptsshow_fileand prints its contents (each line within the gate box) before the options.GateStep._read_show_file(...)helper reads the file as UTF-8 and returns a(could not read file: …)/(file is empty)notice on error/empty instead of raising.Compatibility
PAUSED) path is unchanged — the file is not read when stdin is not a TTY.on_rejecthandling, and resume semantics are unchanged.show_fileproduce byte-identical output to before.Testing
uv run specify --helpuv sync --extra test && uv run pytest— 3310 passed, 40 skippedAdded three targeted tests in
tests/test_workflows.py::TestGateStep:show_filecontents and returns the chosen option;show_fileshows the notice and does not crash;output["show_file"]without reading the file.AI Disclosure
Used Claude to trace the bug in
gate/__init__.py, draft the fix and tests, and write this PR body. The behaviour was reproduced and the diff reviewed locally before submission.