Repository navigation
Notify on background terminal completion - #523
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements an opt-in background terminal completion notification feature, allowing background processes to queue metadata-only completion fragments into the session's input queue upon exit. Key changes include the addition of TerminalCompletionNotification, updates to InputQueue to manage and coalesce these notifications, and the integration of a notify_on_completion flag across shell execution tools and the process manager. Feedback on these changes highlights two main areas for improvement: first, spawn_exit_watcher should use a Weak<Session> instead of a strong Arc<Session> to prevent background tasks from causing resource leaks; second, the terminal_completions queue should use a synchronous mutex rather than tokio::sync::Mutex since the lock is never held across asynchronous boundaries.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements an opt-in background terminal completion notification feature, allowing background processes to queue metadata-only completion fragments into the session's input queue. The changes span context definitions, input queue management, tool specifications, and the process manager's exit watcher. Feedback is provided regarding the queue overflow coalescing logic in InputQueue::enqueue_terminal_completion; instead of coalescing the oldest popped notification into the newest incoming one, it is recommended to coalesce it into the next oldest notification at the front of the queue to preserve chronological aggregation.
Summary
notify_on_completionflag for unified exec commandswrite_stdinoutput retrievalSafety
The injected fragment contains only the numeric process ID, an opaque process-instance UUID, terminal status, exit code, and bounded coalesced final-state counts. It never includes command output, command text, working directory, environment, approval details, or other subprocess-controlled text.
The queue deduplicates by opaque instance identity and remains bounded at 64 entries. Saturation retains explicit exited/failed aggregate counts rather than silently losing final-state accounting. Completion wakes notification-aware blocked waits but never starts an idle model turn.
Validation
cargo fmt --all -- --checkjq empty docs/divergences/index.yamlgit diff --checkBoth hosted runs passed on exact signed head
4bb5b1c6e1e7f1555321f1036f9f6f91fa16f632.