Skip to content

feat: emit OSC terminal notifications on agent turn completion#1463

Open
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:fix/osc-terminal-notifications
Open

feat: emit OSC terminal notifications on agent turn completion#1463
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:fix/osc-terminal-notifications

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 17, 2026

Feature

Emit OSC 9 and OSC 777 escape sequences when the agent completes a turn, enabling desktop notifications in supported terminals.

Supported terminals:

  • OSC 9: iTerm2, Windows Terminal, ConEmu
  • OSC 777: rxvt-unicode, VTE-based (GNOME Terminal, Tilix, etc.)

Only emits when stdout is a TTY to avoid noise in piped/redirected output.

Fixes #1342


Open with Devin

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b872d4b9ce

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +450 to +451
if not sys.stdout.isatty():
return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate OSC notifications on the actual terminal stream

TurnEnd dispatch runs inside the Live(...) block in this module, and Rich redirects sys.stdout there by default; checking sys.stdout.isatty() in this helper can therefore evaluate the proxy stream instead of the real terminal and return early. In interactive shell sessions this suppresses both OSC writes, so the new completion notification path never fires even when the terminal supports OSC 9/777. Please gate on the console’s underlying output stream (or disable stdout redirection for Live) before deciding to skip notification emission.

Useful? React with 👍 / 👎.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@Br1an67 Br1an67 force-pushed the fix/osc-terminal-notifications branch from b872d4b to 66bfe9c Compare March 17, 2026 07:19
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 66bfe9cf6a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1046 to +1047
case TurnEnd():
pass
_emit_osc_notification("Kimi", "Task completed")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict completion notifications to final user turn

TurnEnd is emitted for internal flow steps as well as the top-level user request (see _flow_turn in src/kimi_cli/soul/kimisoul.py, which sends TurnEnd() on each node iteration), so emitting "Task completed" on every TurnEnd produces repeated and incorrect desktop notifications while a flow is still running. In multi-node or retrying flows this can spam notifications and tell users the task is done before the command actually finishes.

Useful? React with 👍 / 👎.

devin-ai-integration[bot]

This comment was marked as resolved.

Emit OSC 9 and OSC 777 escape sequences when the agent completes
a turn, enabling desktop notifications in supported terminals
(iTerm2, Windows Terminal, GNOME Terminal, rxvt-unicode, etc.).

Write directly to stderr fd using os.write() to bypass Rich's
stdout proxy in Live() mode. Check os.isatty(2) instead of
sys.stdout.isatty() for reliable TTY detection.

Fixes MoonshotAI#1342
@Br1an67 Br1an67 force-pushed the fix/osc-terminal-notifications branch from 66bfe9c to 94dd081 Compare March 17, 2026 07:59
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.

Add OSC 9/777 terminal notifications for task completion

1 participant