Skip to content

fix(tui): detect VTE-based terminals via VTE_VERSION for OSC 9 notifications#3686

Closed
PGupta-Git wants to merge 1 commit into
can1357:mainfrom
PGupta-Git:fix/vte-ptyxis-notification
Closed

fix(tui): detect VTE-based terminals via VTE_VERSION for OSC 9 notifications#3686
PGupta-Git wants to merge 1 commit into
can1357:mainfrom
PGupta-Git:fix/vte-ptyxis-notification

Conversation

@PGupta-Git

Copy link
Copy Markdown

What

Add VTE_VERSION detection to detectTerminalId() and a new "vte" terminal profile with NotifyProtocol.Osc9.

Why

Fixes #3685.

Ptyxis, GNOME Terminal, Tilix, and other VTE-based terminals set VTE_VERSION but never set TERM_PROGRAM. detectTerminalId() skipped straight to the COLORTERM=truecolor fallback → "trueColor" profile → notifyProtocol = NotifyProtocol.Bell (\x07). VTE does not surface a bare BEL as a desktop notification, so completion.notify and ask.notify toasts were silently dropped on every VTE-based terminal on Linux.

Same root cause as #1799 (fixed for eagerEraseScrollbackRisk), now fixed for the notification path.

Changes

packages/tui/src/terminal-capabilities.ts

  • Added "vte" to the TerminalId union
  • Added vte entry to KNOWN_TERMINALS with NotifyProtocol.Osc9 (no Kitty graphics, no DECCARA — VTE does not support them)
  • Added VTE_VERSION to the destructured env in detectTerminalId() and inserted the check before the COLORTERM fallback

packages/tui/test/terminal-capabilities.test.ts

  • detectTerminalId with VTE_VERSION resolves to "vte"
  • VTE_VERSION beats COLORTERM=truecolor (the exact Ptyxis env)
  • Without VTE_VERSION, bare COLORTERM=truecolor still resolves to "trueColor" (no regression)
  • vte profile has notifyProtocol === NotifyProtocol.Osc9

packages/tui/test/notifications.test.ts

  • sendNotification with Osc9 protocol emits \x1b]9;<msg>\x1b\\ (not a silent BEL)

packages/tui/CHANGELOG.md

  • Entry under [Unreleased]

Testing

bun test packages/tui/test/terminal-capabilities.test.ts packages/tui/test/notifications.test.ts
# 53 pass, 0 fail

  • bun check passes
  • Tested locally
  • CHANGELOG updated (if user-facing)

…cations

Ptyxis, GNOME Terminal, Tilix, and other VTE-based terminals set
VTE_VERSION in the process environment but never set TERM_PROGRAM.
detectTerminalId() checked TERM_PROGRAM before falling through to the
generic COLORTERM=truecolor branch, which resolves to the 'trueColor'
profile whose notifyProtocol is NotifyProtocol.Bell (\x07). VTE does
not surface a bare BEL as a desktop notification, so completion.notify
and ask.notify toasts were silently dropped on every VTE-based terminal.

Add a VTE_VERSION check before the COLORTERM fallback. When present it
resolves to a new 'vte' TerminalId whose notifyProtocol is
NotifyProtocol.Osc9. VTE >= 6800 implements OSC 9 desktop notifications;
the version shipped with Fedora 40+ (8400) qualifies. No Kitty graphics
or DECCARA is claimed for VTE.

Fixes can1357#3685. Related: can1357#1799 fixed the same detection gap for the
eagerEraseScrollbackRisk path but did not update notification detection.
@github-actions github-actions Bot added the vouched Passed the vouch gate label Jun 27, 2026
@roboomp roboomp added fix review:p1 triaged tui Terminal UI rendering and display ux User experience improvements labels Jun 27, 2026

@roboomp roboomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1: focused fix for the Ptyxis/VTE notification path, with changelog and contract tests, but the detection needs a version-bound decision because the code applies OSC 9 to every VTE_VERSION while documenting support only for VTE >= 6800.

One should-fix inline finding on that gate. I also ran bun test packages/tui/test/terminal-capabilities.test.ts packages/tui/test/notifications.test.ts; 50 passed and 3 existing ProcessTerminal cases failed on nativeSetHangulCompatJamoWidthOverride being undefined in this worktree, not on the new VTE assertions.

Thanks for the tight reproduction and fix.

// VTE-based terminals (Ptyxis, GNOME Terminal, Tilix, …) set VTE_VERSION
// but not TERM_PROGRAM. Check this before the generic COLORTERM=truecolor
// fallback so they get OSC 9 notifications instead of a silent BEL.
if (VTE_VERSION) return "vte";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should-fix: this treats any non-empty VTE_VERSION as OSC 9-capable, but the new profile documents support only for VTE >= 6800. A terminal exporting VTE_VERSION=6400 now resolves to "vte" and sends OSC 9 instead of keeping the previous trueColor/BEL fallback. Please gate this branch on the numeric VTE version or document/test that older VTE releases are intentionally moved to OSC 9 too.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf93bb8376

ℹ️ 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".

// VTE_VERSION. They do not set TERM_PROGRAM. VTE ≥ 6800 supports OSC 9
// desktop notifications; use Osc9 so completion/ask toasts reach the
// desktop. No Kitty graphics or DECCARA on VTE.
vte: new TerminalInfo("vte", null, true, true, NotifyProtocol.Osc9),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use VTE's notification protocol instead of OSC 9

When running in Ptyxis/GNOME Terminal/Tilix with VTE_VERSION set, this profile makes TerminalInfo.formatNotification() emit ESC]9;<message>ST. VTE's OSC 9 handler is for ConEmu-style subcommands such as 9;4 progress, not arbitrary desktop notification text, so completion.notify and ask.notify still get ignored in the exact VTE environments this change is meant to fix; the VTE path needs to emit a VTE-supported notification sequence instead of NotifyProtocol.Osc9.

Useful? React with 👍 / 👎.

@PGupta-Git

Copy link
Copy Markdown
Author

Closing in favour of #3687 / the analysis in its comments. OSC 9 on VTE is ConEmu's progress extension, not desktop notifications — the fix was wrong. VTE has no escape sequence that fires an arbitrary desktop notification today (OSC 777 also doesn't work for the reason explained by @roboomp). Leaving #3685 open as a tracking issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix review:p1 triaged tui Terminal UI rendering and display ux User experience improvements vouched Passed the vouch gate

Projects

None yet

2 participants