Skip to content

Sweep cli/src/ui: inline wrappers, fix fake tests - #1961

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/sweep-cli-ui
Nov 2, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/sweep-cli-ui

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Architecture refactor sweep of crates/socket-patch-cli/src/ui/{mod,prompt,status,test_support}.rs, from the audit notes in coverage/files.tsv (ledger branch arch-audit/ledger, discussion #1830, living document Part 4 "structure"). ui/text.rs is held by #1884. The StatusLine::stderr(json, silent) → one-bool change is also held, because its callers (scan/mod.rs, lock_cli.rs) are in open PRs.

Changes

prompt.rs

  • Inlined ask() and confirm_waits() into confirm(), and folded read_answer() (single caller) into confirm_with() using early returns.
  • Removed Ask.non_interactive_answer: every caller set it to default_yes.
  • Made Ask, confirm_with and the three NON_INTERACTIVE_* consts private, since nothing outside the file uses them.
  • Tests:
    • deleted non_interactive_notes_share_one_wording (it asserted the consts equal their own literals);
    • deleted setup_style_default_no_but_proceed_when_non_interactive (it tested the removed field);
    • deleted read_answer_maps_empty_to_none_and_eof_to_decline (it repeated the confirm_with cases: empty, whitespace, yes, no, non-UTF-8, EOF);
    • deleted a_prompt_nobody_waits_on_never_reads_the_answer (a duplicate of non_interactive_silent_writes_nothing);
    • replaced confirm_waits_agrees_with_confirm_over_the_flag_cube with yes_or_json_answers_the_default. The old (yes=false, json=false) cell failed whenever stdin was a TTY;
    • renamed non_interactive_returns_the_non_interactive_answer_with_note → non_interactive_answers_the_default_with_note.
  • Red→green:
    • making EOF take the default fails eof_declines_even_when_default_is_yes;
    • flipping the --yes/--json early return fails yes_or_json_answers_the_default.

mod.rs

  • Replaced the four cfg'd stdout_vt/stderr_vt fns and vt_probe with one vt() -> (stdout, stderr) per platform.
  • Fixed the stale "see get.rs severity_rank" comment (T10); it now points to core ranking::severity_order.
  • Dropped the bare issue numbers and the "Shared by apply and rollback" note.
  • Trimmed the module-doc list, which went stale whenever text gained exports.

status.rs

  • Inlined term_is_dumb.
  • Removed the first half of shorter_after_longer_leaves_no_residue, which duplicated the finish_with regression test; both tests are renamed after what they check.

test_support.rs is clean. Its test stays in mod.rs: tests/common/pty_io.rs includes the file by path, so a #[cfg(test)] module inside it would run in every integration binary.

/code-review high

I fixed 3 findings:

  • restored select_one's quiet() guard, which protects callers that pass derived flags;
  • kept the env_var helper;
  • gave each platform its own vt(), so Windows clippy has no needless_return.

I left 3 findings unfixed:

  • The (bool, bool) tuple can be misread. Its only callers are two adjacent lines in mod.rs and one in status.rs, and the order is documented.
  • TERM=dumb is read in two places. This existed before this PR (the audit notes list it); unifying it would change the live-line policy under NO_COLOR.
  • The confirm non-TTY path has no end-to-end test. The old test only checked it when stdin was not a TTY, and tests/scan and tests/update cover the non-interactive note end to end.

Stats

git diff --stat: 3 files, +60 / −215. Production about +20 / −62; tests about +40 / −153.

Behavior

None.

Risk

Low. Platform-specific code changed: the Windows vt() in mod.rs. CI's windows compile check covers it; a maintainer may want a full-scope run.

Results:

  • local cargo clippy --workspace --all-features -D warnings: clean;
  • local cargo test -p socket-patch-cli --lib: 936 pass;
  • local --test update / --test scan: 247 + 68 pass;
  • CI: 82/82 green;
  • Bugbot: no issues.

https://claude.ai/code/session_011f9aeQr6f8dLWGHbq6xTvm


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
confirm() now builds its Ask inline: the ask() and confirm_waits()
wrappers are gone, and read_answer() is folded into confirm_with().
Ask loses non_interactive_answer, which every caller set to
default_yes, and Ask, confirm_with and the note consts become
private. select_one no longer re-checks the process quiet flag: its
only caller passes the same flags ui::init saw, and --json returns
earlier.

ui/mod.rs replaces the four stdout_vt/stderr_vt fns with one vt()
pair, drops the env_var wrapper, and fixes the severity comment that
pointed at a moved get.rs fn. status.rs inlines term_is_dumb.

Tests: drop the tautological wording test, the setup-style test of
the removed field, the read_answer test that repeated the
confirm_with cases, and the duplicate nobody-waits test. The
TTY-dependent confirm_waits test becomes yes_or_json_answers_the_
default. status.rs drops a duplicate finish_with case.

Assisted-by: Claude Code:claude-opus-5-5
Restores select_one's process-wide quiet check (a caller passing
derived flags would otherwise print the note under --silent), keeps
the env_var helper, and gives each platform its own vt() so the
Windows body needs no return (clippy needless_return).

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 1, 2026 23:09
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code arch-refactor PR opened by the scheduled architecture refactor routine labels Nov 1, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ee261ca. Configure here.

Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Nov 1, 2026
Records the sweep PR in the register and the coverage manifest, and
logs the run.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 2, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[burn-down agent] Labeled Ready for review at ee261ca.

  • CI: 82/82 green on ee261ca (31 success, 50 skipped, 1 neutral); mergeable, no conflicts.
  • Bugbot: reviewed ee261ca, no findings; no unresolved review threads.
  • Reviewer note: refactor of cli/src/ui/{mod,prompt,status}.rs only (−215/+60). Worth a look: the deleted/replaced prompt tests in prompt.rs and the per-platform vt() in mod.rs.
  • Slack announcement not sent this run (Slack send unavailable); the next run will retry.

Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Final review brief

What it does. This is a refactor sweep of cli/src/ui with no behavior change. In prompt.rs, ask, confirm_waits and read_answer are inlined into confirm/confirm_with, and the always-equal Ask.non_interactive_answer field is removed. In mod.rs, the four cfg'd *_vt helpers become one vt() -> (stdout, stderr) per platform. It also deletes tests that only restated literals or duplicated other cases. +60 / −215.

Risk: low. Each removed item had its only users inside these three files (checked with a grep of origin/main). The answer semantics are unchanged: EOF, I/O errors and non-UTF-8 input still decline even when the default is yes, and an empty line takes the default. The only Windows-only change is the vt() rename, and CI's Windows compile covers it.

Look here

  • prompt.rs:26: confirm now builds Ask inline (the --yes/--json early return is unchanged)
  • prompt.rs:102: read_answer folded in with let-else; EOF, errors and bad UTF-8 return false
  • prompt.rs:76: confirm_with non-interactive path now answers default_yes
  • mod.rs:126: the vt() tuple (Windows; the Unix variant is just below)
  • status.rs:50: live-line gate, with term_is_dumb inlined

Verified

  • Read the full diff and the PR description, which matches the code.
  • No external callers of confirm_waits, stderr_vt, Ask or the NON_INTERACTIVE_* consts remain.
  • The kept tests still cover EOF with a yes default, the empty line and silent non-interactive mode.
  • Ran cargo test -p socket-patch-cli --lib ui:: locally: 48/48 pass.
  • CI 82/82 green on ee261ca (ci-ok and clippy success); Bugbot found no issues; no unresolved threads; CHANGELOG.md untouched.

Changes I made. None.

Open questions. None. The three findings the author left unfixed are explained in the description, and I agree they are out of scope.

Auto-merge is armed, so approving sends this straight to the merge queue.


Generated by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[agent] Reviewed ee261caddf0d669ba61d6e4b41b59caeae1d261c. Checked prompt defaults/EOF/error behavior, terminal VT checks and status-line gating. No major correctness issues found. Validation: source and regression-test review plus the available exact-head CI checks; no local test pass is claimed.

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 3dcb53b Nov 2, 2026
82 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the arch-refactor/sweep-cli-ui branch November 2, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants