Skip to content

feat(sessions): prompt user when shell process exits - #731

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-prompt
Jul 13, 2026
Merged

feat(sessions): prompt user when shell process exits#731
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-prompt

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 13, 2026

Copy link
Copy Markdown
Member
  • New crate async-dialog to implement ANSI terminal prompt, such as down an SSH connection.
  • WeakManagerHandle counterpart to ManagerHandle, used to avoid circular references
  • Prompt for when the shell process exits
  • Tests for teardown when the user selects deletion in the prompt

Summary by CodeRabbit

  • New Features
    • Added an async terminal dialog library with keyboard-driven selection menus (prompt support, default option, width truncation, and confirm/cancel controls).
    • Added a shell-exit prompt that lets users choose to detach or delete the session, with deletion performed through a manager-mediated control path.
  • Bug Fixes
    • Improved session teardown behavior when shell connections end, including reliable cleanup after choosing “delete”.
    • Restored terminal rendering state cleanly after interactive prompts complete.
  • Tests
    • Updated/extended session prompt interaction tests to validate delete/detach outcomes.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efc34176-b032-45d4-b9c4-fd2aab034273

📥 Commits

Reviewing files that changed from the base of the PR and between c04f8cf and 077974d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • crates/async-dialog/Cargo.toml
  • crates/async-dialog/src/error.rs
  • crates/async-dialog/src/key.rs
  • crates/async-dialog/src/lib.rs
  • crates/async-dialog/src/select.rs
  • crates/minimald/Cargo.toml
  • crates/minimald/src/session.rs
  • crates/minimald/src/session_host.rs
  • crates/minimald/src/sessions.rs
🚧 Files skipped from review as they are similar to previous changes (9)
  • Cargo.toml
  • crates/async-dialog/Cargo.toml
  • crates/async-dialog/src/error.rs
  • crates/minimald/Cargo.toml
  • crates/async-dialog/src/key.rs
  • crates/minimald/src/sessions.rs
  • crates/async-dialog/src/select.rs
  • crates/minimald/src/session.rs
  • crates/minimald/src/session_host.rs

📝 Walkthrough

Walkthrough

Adds the async-dialog crate for asynchronous terminal key decoding and single-choice prompts. Minimald passes session controls into hosts, presents shell-exit choices, and can delete sessions through a weak manager handle. Tests cover prompt interaction, channel closure, and record removal.

Changes

Async dialog crate

Layer / File(s) Summary
Workspace integration and input primitives
Cargo.toml, crates/async-dialog/...
Registers the new crate, defines dialog errors, decodes terminal bytes into Key events, buffers split reads with KeyStream, and re-exports the public API.
Interactive selection prompt
crates/async-dialog/src/select.rs
Adds the Select builder and Selection result, including navigation, cancellation, rendering, truncation, cleanup, and async tests.

Minimald session teardown

Layer / File(s) Summary
Manager control propagation
crates/minimald/Cargo.toml, crates/minimald/src/sessions.rs, crates/minimald/src/session.rs
Adds weak manager handles and SessionControl, then passes session-specific destruction capability through session and host creation.
Shell-exit prompt flow
crates/minimald/src/session_host.rs, crates/minimald/src/session.rs
Handles stdout-driven exits with a selection prompt, supports session deletion when control is available, and updates teardown tests and host call sites.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Binding
  participant Select
  participant SessionControl
  participant Manager
  Binding->>Select: display shell-exit options
  Select-->>Binding: return detach or delete selection
  Binding->>SessionControl: destroy session
  SessionControl->>Manager: request session destruction
  Manager-->>Binding: complete teardown
Loading

Possibly related issues

  • gominimal/inbox#151: Adds interactive session prompts supporting the tracked attach-detach and PTY supervision work.

Possibly related PRs

Suggested reviewers: evanspearman, norrietaylor

Poem

I’m a rabbit with keys in my paw,
A prompt now hops when shells withdraw.
Choose to detach, or delete with care,
The manager listens through weak-threaded air.
Hop, hop, shipped! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main user-facing change: prompting the user when the shell process exits.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ 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: 3

🤖 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/async-dialog/src/error.rs`:
- Around line 9-19: Update the #[error] format on DialogError::Io to interpolate
its wrapped std::io::Error source, preserving the existing variant and
conversion while ensuring Display and tracing logs include the underlying OS
error message.

In `@crates/async-dialog/src/key.rs`:
- Around line 86-95: Bound incomplete CSI sequences in decode_csi and the
surrounding buffer-draining logic near the caller at lines 138-151. When an ESC
[ sequence contains more than the permitted number of bytes without a final
byte, consume the bounded sequence as Key::Unknown and advance pos so the buffer
can drain; preserve None for incomplete sequences within the limit and normal
final-byte decoding.
- Around line 67-77: Update KeyStream::next so a buffered lone ESC is emitted as
Key::Escape after a short timeout instead of remaining incomplete indefinitely.
Also return Key::Escape when EOF occurs with the ESC byte still pending, while
preserving longer escape-sequence decoding when additional bytes arrive.
🪄 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: 6a2d5d12-e9c2-4b12-92cc-7880f16e993c

📥 Commits

Reviewing files that changed from the base of the PR and between 4054eda and 67f2525.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • crates/async-dialog/Cargo.toml
  • crates/async-dialog/src/error.rs
  • crates/async-dialog/src/key.rs
  • crates/async-dialog/src/lib.rs
  • crates/async-dialog/src/select.rs
  • crates/minimald/Cargo.toml
  • crates/minimald/src/session.rs
  • crates/minimald/src/session_host.rs
  • crates/minimald/src/sessions.rs

Comment thread crates/async-dialog/src/error.rs
Comment thread crates/async-dialog/src/key.rs
Comment thread crates/async-dialog/src/key.rs Outdated
@twitchyliquid64
twitchyliquid64 force-pushed the tom/session-prompt branch 2 times, most recently from 7bb2d5e to c04f8cf Compare July 13, 2026 19:17
Comment thread crates/minimald/src/session_host.rs Outdated
@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 13, 2026 19:31
@twitchyliquid64
twitchyliquid64 merged commit 1ea66f2 into main Jul 13, 2026
28 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/session-prompt branch July 13, 2026 20:12
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