Skip to content

feat(minimal): tab complete session ID/names - #966

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/completions
Jul 25, 2026
Merged

feat(minimal): tab complete session ID/names#966
twitchyliquid64 merged 1 commit into
mainfrom
tom/completions

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added dynamic shell completion for session names and UUIDs across session-related commands.
    • Completion candidates now include contextual descriptions (e.g., terminal titles or project paths).
    • Shell completion now uses a registration “shim” and fetches session candidates on-demand (best-effort; returns no candidates if the backend can’t respond quickly).
  • Documentation
    • Updated CLI reference for min completions <SHELL> to explain the registration shim and the dynamic, best-effort completion behavior.
    • Added examples for the hidden completion inspection command (min complete-session-str).

Note

Add tab completion for session IDs and names in the min CLI

  • Adds dynamic shell completion for session arguments (attach, destroy, rename, session policy, ssh-forward) by querying live sessions via a bounded, non-autospawning RPC with a short timeout.
  • Introduces a new hidden complete-session-str subcommand that prints value<TAB>description lines for debugging and scripting.
  • Changes min completions <shell> to emit a dynamic-registration shim instead of a static completion table.
  • Completion candidates prefer session names; IDs are shown for unnamed sessions or when the prefix matches an ID.
  • Behavioral Change: min completions <shell> output changes from a static script to a dynamic shim — users must re-source or reinstall their completion setup.

Macroscope summarized 290d2f8.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now supports dynamic session completion through daemon-backed candidate retrieval, shell registration shims, a hidden candidate-printing command, and completion wiring for session-related arguments.

Changes

Dynamic session completion

Layer / File(s) Summary
Session candidate pipeline
crates/minimal/Cargo.toml, crates/minimal/src/completion.rs
Adds dynamic session candidate retrieval, prefix and UUID matching, descriptions, bounded daemon access, formatted output, and unit tests.
CLI completion contracts and wiring
crates/minimal/src/lib.rs
Adds the hidden completion command and connects session completion to policy, attach, destroy, rename, and SSH-forward arguments.
Shell registration and runtime handling
crates/minimal/src/lib.rs, crates/minimal/src/main.rs
Replaces static completion generation with registration shims and handles completion requests before normal runtime and logging setup.
Completion documentation
docs/reference/cli-min.md
Documents dynamic completion behavior, best-effort daemon access, and candidate inspection examples.

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

Sequence Diagram(s)

sequenceDiagram
  participant Shell
  participant min
  participant Daemon
  Shell->>min: request dynamic session completion
  min->>Daemon: ListSessions RPC with timeout
  Daemon-->>min: session candidates
  min-->>Shell: value and optional description
Loading

Suggested reviewers: 0chroma, norrietaylor

Poem

I’m a rabbit with completions to share,
Fetching session names through the air.
Tabs bloom bright,
UUIDs take flight,
And quiet logs leave stdout bare.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it does not follow the required template and is missing Summary, Testing, and Checklist sections. Rewrite it using the repo template: add Summary, Testing evidence, and Checklist items for docs updates and any BREAKING CHANGE footer.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise, conventional, and matches the main change: dynamic tab completion for session IDs and names.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/minimal/Cargo.toml`:
- Around line 29-36: Correct the explanatory comment above the clap_complete
dependency to accurately describe unstable-dynamic usage across completion.rs,
main.rs, and lib.rs, including ArgValueCompleter, CompletionCandidate,
CompleteEnv, and the env::Shells/write_registration APIs. Remove the claim that
usage is confined to two types in completion.rs, while preserving the
semver-stability warning.

In `@crates/minimal/src/completion.rs`:
- Around line 106-120: Move the is_daemon_running check from fetch_sessions into
the async operation wrapped by tokio::time::timeout(COMPLETION_TIMEOUT, rpc),
preserving the early None result when the daemon is not running. Ensure the
liveness check, connection, and RPC request all share the same completion
timeout budget.

In `@crates/minimal/src/main.rs`:
- Around line 43-52: Change the subscriber setup around Cli::parse so
CompleteSessionStr routes tracing output to stderr instead of skipping
subscriber installation. Preserve stdout parsing for other commands and ensure
the completion command’s daemon-connect and timeout tracing remains available
for debugging, following the existing git-remote-helper stderr-writer pattern.

In `@docs/reference/cli-min.md`:
- Line 194: Add a fenced code block language identifier, preferably text, to the
CLI example around the complete-session-str documentation in
docs/reference/cli-min.md, preserving the example content unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7a90102-9c03-4c02-b8d8-ff6d25ee1be3

📥 Commits

Reviewing files that changed from the base of the PR and between d899705 and 72ec521.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • crates/minimal/Cargo.toml
  • crates/minimal/src/completion.rs
  • crates/minimal/src/lib.rs
  • crates/minimal/src/main.rs
  • docs/reference/cli-min.md

Comment thread crates/minimal/Cargo.toml
Comment thread crates/minimal/src/completion.rs
Comment thread crates/minimal/src/main.rs Outdated
Comment thread docs/reference/cli-min.md
@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 25, 2026 05:55
@twitchyliquid64
twitchyliquid64 disabled auto-merge July 25, 2026 06:00
@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 25, 2026 06:03
@twitchyliquid64
twitchyliquid64 merged commit 9654970 into main Jul 25, 2026
29 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/completions branch July 25, 2026 06:11
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.

3 participants