Skip to content

feat: introduce interaction seam, decouple root menu, and guard non-TTY commands - #60

Open
Fahl-Design wants to merge 1 commit into
mainfrom
refactor/issue-53-interaction-seam
Open

Fahl-Design wants to merge 1 commit into
mainfrom
refactor/issue-53-interaction-seam

Conversation

@Fahl-Design

@Fahl-Design Fahl-Design commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Introduce 'src/interaction.rs' providing an 'Interaction' trait (with shared non-TTY and '--yes' policy in default 'confirm'/'select' methods), 'TtyInteraction' for production, and 'ScriptedInteraction' for deterministic in-process tests.
  • Decouple the root interactive menu in 'src/interactive.rs' from positional numeric indices by pairing each display label directly with its 'MenuAction' variant in 'ROOT_MENU_ITEMS', and guard bare 'pvm' when no terminal is attached.
  • Guard 'pvm uninstall' (without a version argument) when no terminal is attached, and route its interactive picker and confirmation through 'Interaction'.
  • Add '--yes' ('-y') to 'pvm self-update' and route 'self-update --apply' confirmation through 'Interaction' so non-TTY invocations follow the '--yes'/default policy instead of invoking raw 'dialoguer'.
  • Add in-process tests using 'ScriptedInteraction' for root menu dispatch, 'uninstall' interactive selection, and 'self-update --apply' confirmation flows, plus CLI integration tests in 'tests/cli.rs' for non-TTY behavior.

Verification

  • 'cargo fmt --all -- --check': passed
  • 'cargo clippy -- -D warnings': passed
  • 'cargo test': 54 unit tests + 45 integration tests passed (0 failed)

Closes #53


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75d8e536-cf74-4644-9403-d266423abf91
Commits

Reviewing files that changed from the base of the PR and between bb480f0 and d107ca0.

Files selected for processing: 8

  • src/commands/self_update.rs
  • src/commands/uninstall.rs
  • src/fs.rs
  • src/interaction.rs
  • src/interactive.rs
  • src/main.rs
  • src/prompt.rs
  • tests/cli.rs

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added a --yes option to approve self-updates without an interactive confirmation.
    • Interactive prompts now behave consistently across update, uninstall, and menu actions.
  • Bug Fixes
    • Self-updates no longer prompt or apply changes when no newer version is available or applying was not requested.
    • Non-interactive uninstall without a specified version now exits with a usage hint and leaves installed versions unchanged.
    • Running the menu without a terminal now exits with guidance instead of attempting to prompt.

The change adds a shared terminal interaction abstraction and updates the root menu, uninstall, and self-update flows to use it. Non-interactive sessions receive explicit handling in the menu and uninstall flows. Self-update adds a --yes option.

Changes: Terminal Interaction and Command Flows

Layer / File(s) Summary
Interaction contract and terminal adapters
src/interaction.rs, src/main.rs, src/prompt.rs, src/fs.rs
Adds the Interaction contract, TtyInteraction, and scripted test support. The existing confirmation helper delegates to TtyInteraction. The interaction module and test support are made available within the crate.
Root menu actions and interaction
src/interactive.rs, tests/cli.rs
Pairs root-menu labels with named actions and dispatches selections through the interaction abstraction. The menu rejects non-interactive sessions.
Uninstall selection and confirmation
src/commands/uninstall.rs, tests/cli.rs
Uses the interaction abstraction for version selection and confirmation. When a version must be selected in a non-interactive session, uninstall returns a usage error.
Self-update confirmation and application
src/commands/self_update.rs, tests/cli.rs
Adds --yes and separates update checking from applying the update. Confirmation uses the interaction abstraction, and tests cover approval, cancellation, and paths that do not prompt or apply.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SelfUpdate
  participant run_with
  participant FetchLatestTag
  participant Interaction
  participant ApplyUpdate
  SelfUpdate->>run_with: Provide interaction and update operations
  run_with->>FetchLatestTag: Fetch latest tag
  FetchLatestTag-->>run_with: Return release tag
  run_with->>Interaction: Confirm with default yes and --yes option
  Interaction-->>run_with: Return approval decision
  alt Update approved
    run_with->>ApplyUpdate: Apply fetched release tag
  end
Loading

Possibly related issues

  • Issue 57: The PR adds the shared interaction seam and routes self-update and uninstall through it, but does not migrate the remaining commands named in the issue.
Merge Risk: Minimal · previous review bb480

This change routes terminal prompts through a shared interaction layer and gives non-interactive sessions clear errors for the menu and uninstall. It also adds a --yes option to self-update. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the three main changes: an interaction seam, root-menu decoupling, and non-TTY guards. The changeset adds src/interaction.rs with an Interaction trait, moves the root menu to label/act…
Description check Passed The description lists the new Interaction trait, TtyInteraction, and ScriptedInteraction. It also covers the root-menu label/action pairing, the non-TTY guards for bare pvm, uninstall, and self-update…
Linked Issues check Passed Issue #53 has four coding acceptance criteria. Evidence comes from the whole-PR summary (merge base 9de82bc to head bb480f0). I did not open the source files, so this verdict rests on the summary.

1.…
Out of Scope Changes check Passed Every listed change maps to #53 or supports it:
- src/interaction.rs (new): the seam itself.
- src/interactive.rs: label/action pairing and the non-TTY guard for bare pvm.
- `src/commands/uninst…
Full details: Title check

Explanation

The title names the three main changes: an interaction seam, root-menu decoupling, and non-TTY guards. The changeset adds src/interaction.rs with an Interaction trait, moves the root menu to label/action pairs, and adds non-TTY guards for bare pvm, uninstall, and self-update --apply. The title is specific, though it is long at 80 characters and 11 words.

Full details: Description check

Explanation

The description lists the new Interaction trait, TtyInteraction, and ScriptedInteraction. It also covers the root-menu label/action pairing, the non-TTY guards for bare pvm, uninstall, and self-update --apply, the new --yes flag, and the added tests. It matches the changeset closely.

Full details: Linked Issues check

Explanation

Issue #53 has four coding acceptance criteria. Evidence comes from the whole-PR summary (merge base 9de82bc to head bb480f0). I did not open the source files, so this verdict rests on the summary.

  1. Interaction seam (#53): src/interaction.rs adds an Interaction trait with TtyInteraction for production and test-only ScriptedInteraction for in-process tests. Met.
  2. Non-TTY behavior (#53): Bare pvm returns a terminal error in src/interactive.rs before prompting. pvm uninstall without a version returns a usage error in non-interactive mode (src/commands/uninstall.rs). pvm self-update --apply uses Interaction::confirm, which applies --yes or the default when non-interactive. tests/cli.rs covers bare pvm and pvm uninstall. The issue allows either a clear usage/error or the --yes/default policy, so this is met.
  3. Label/action pairs (#53): ROOT_MENU_ITEMS pairs each label with its MenuAction variant. Met.
  4. In-process scripted tests (#53): Tests in src/interactive.rs, src/commands/uninstall.rs, and src/commands/self_update.rs use ScriptedInteraction for root-menu dispatch, uninstall selection, and self-update confirmation. Met.

Note: in non-interactive mode the self-update confirmation uses its default-yes policy, so --apply can replace the binary without an explicit --yes. The issue explicitly permits the default policy, so this does not fail the requirement.

Full details: Out of Scope Changes check

Explanation

Every listed change maps to #53 or supports it:

  • src/interaction.rs (new): the seam itself.
  • src/interactive.rs: label/action pairing and the non-TTY guard for bare pvm.
  • src/commands/uninstall.rs: non-TTY guard, and selection and confirmation routed through Interaction.
  • src/commands/self_update.rs: --yes/-y and --apply confirmation routed through Interaction. The --yes flag is part of the self-update non-TTY policy the PR describes.
  • src/prompt.rs: confirm delegates to TtyInteraction. This is a refactor that moves the shared confirmation logic behind the seam.
  • src/fs.rs: tests module and ENV_LOCK made pub(crate). This is test support for the new in-process tests.
  • src/main.rs: declares the interaction module.
  • tests/cli.rs: non-TTY regression tests and the --help check for --apply and --yes.

I found no change without a connection to #53.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the prompt with care,
Then hops through menus anywhere.
“Yes” can send the update on,
A cancelled choice leaves work undone.
The terminal answers, soft and clear,
And carrots celebrate the gear.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d7f596c-cf58-4f2c-8b48-e831e53969d8
Commits

Reviewing files that changed from the base of the PR and between 9de82bc and bb480f0.

Files selected for processing: 8

  • src/commands/self_update.rs
  • src/commands/uninstall.rs
  • src/fs.rs
  • src/interaction.rs
  • src/interactive.rs
  • src/main.rs
  • src/prompt.rs
  • tests/cli.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

…TY commands

Adds src/interaction.rs with an Interaction trait, TtyInteraction for production, and ScriptedInteraction for in-process tests. Pairs root menu labels directly with MenuAction variants instead of positional indices, adds non-TTY guards to bare pvm, pvm uninstall (no version), and pvm self-update --apply (with --yes), and adds unit and CLI tests covering all interactive and non-TTY flows.

Closes #53
@Fahl-Design
Fahl-Design force-pushed the refactor/issue-53-interaction-seam branch from bb480f0 to d107ca0 Compare November 30, 2026 20:03
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.

Introduce interaction seam, decouple root menu, and guard non-TTY commands

1 participant