Skip to content

feat(cli): detach a running turn to background with Ctrl-B - #500

Merged
ajianaz merged 3 commits into
developfrom
feat/detach
Nov 3, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/detach

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Background detach for tole chat (#217): press Ctrl-B during a running turn to detach it into a background job.

  • The turn keeps running to completion in a detached worker; a jobs.rs job polls the detached pid (one polling thread per job) and appends the final answer into the session file, so tole resume (or another chat on the same session) shows the answer plus a background job <id> finished note.
  • /jobs lists running/finished background jobs; /jobs <id> shows a finished job's output; Ctrl-B prints the job id at detach time.
  • REPL-only (single chat turn); mission and run unchanged. The busy spinner is replaced by a plain "working (Ctrl-B to detach)" hint line so the keypress is discoverable.
  • Docs: README chat-keys table + CHANGELOG under [Unreleased].

Why (the problem you're solving)

Closes #217 — a slow turn blocked the whole REPL; there was no way to keep chatting while it finished.

Testing (how you verified this works)

  • RED first: detach_e2e failed to compile on the missing API (detach_current_turn). GREEN after implementation with a pty-based fixture (script drives a real tole chat with a slow echo server, sends Ctrl-B, asserts the prompt returns and the answer lands in the session file).
  • Detach-then-resume ordering verified: the finished answer is appended before the note line; concurrent chat on the same session during a detached turn is rejected with a clear error (session writer lock).
  • cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets -- -D warnings clean; cargo test --workspace --no-fail-fast 989 passed / 0 failed; cargo test -p tole-core --no-default-features 388/0; cargo build -p tole-cli --no-default-features ok.
  • UNVERIFIED: interactive feel (exact spinner/hint rendering) and real-model turns — tests use a scripted pty + mock provider. Ctrl-B in a raw terminal was exercised only through the pty fixture.

Detach stops waiting without aborting: the running tool settles, the turn ends Detached (durable entry, pc=Final, resumable). Serve and MCP faces added; job_start jobs nudge the session on exit. Refs #217
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 37e2517 into develop Nov 3, 2026
16 checks passed
@ajianaz
ajianaz deleted the feat/detach branch November 3, 2026 16:09
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.

background mid-flight: detach a running turn/job to background (Ctrl-B semantics)

1 participant