Skip to content

Notify on background terminal completion - #523

Merged
GraciousGazelles merged 10 commits into
mainfrom
feature/terminal-completion-notifications-20260725
Jul 26, 2026
Merged

GraciousGazelles merged 10 commits into
mainfrom
feature/terminal-completion-notifications-20260725

Conversation

@GraciousGazelles

@GraciousGazelles GraciousGazelles commented Jul 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add an opt-in notify_on_completion flag for unified exec commands
  • queue one typed, metadata-only terminal completion fragment through the owning session input queue
  • wake notification-aware blocked waits without starting an idle model turn
  • preserve existing terminal events and explicit write_stdin output retrieval
  • classify ordinary exit, failure/cancellation, explicit termination, session shutdown, and pruning

Safety

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

Both hosted runs passed on exact signed head 4bb5b1c6e1e7f1555321f1036f9f6f91fa16f632.

@gemini-code-assist gemini-code-assist 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.

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.

@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

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.

@GraciousGazelles
GraciousGazelles marked this pull request as ready for review July 26, 2026 01:30
@GraciousGazelles
GraciousGazelles merged commit 4ccc6af into main Jul 26, 2026
62 checks passed
@GraciousGazelles
GraciousGazelles deleted the feature/terminal-completion-notifications-20260725 branch July 26, 2026 01:30
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.

1 participant