Skip to content

fix: stop notifying on every shell prompt redraw (ConEmu OSC 9 subcommands) - #127

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
AxelM-MSK:fix/osc9-notification-spam
Jul 29, 2026
Merged

fix: stop notifying on every shell prompt redraw (ConEmu OSC 9 subcommands)#127
amirlehmam merged 1 commit into
amirlehmam:masterfrom
AxelM-MSK:fix/osc9-notification-spam

Conversation

@AxelM-MSK

Copy link
Copy Markdown
Contributor

Problem

wmux fires a notification every time a command is run at a shell prompt — extremely noisy alongside the (desired) agent notifications.

Root cause

The OSC 9 handler in useTerminal.ts treats every OSC 9 payload as an iTerm2-style notification (OSC 9;<text>). But OSC 9 is overloaded: ConEmu/Windows Terminal use numeric subcommands — OSC 9;9;<cwd> (cwd report) and OSC 9;4;<state>;<n> (progress). wmux's own wmux-cmd-integration.cmd embeds 9;9;$P in the cmd prompt, and the standard Windows Terminal PowerShell profile snippet does the same — so every prompt redraw after every command raised a bogus notification with text like 9;C:\path.

Fix

One guard in the OSC 9 handler: payloads starting with a numeric subcommand (/^\d+;/) are swallowed instead of raised. Bare-text notifications, wmux notify, and the Claude Code Stop/Notification hook path are unaffected.

Testing

Verified in a dev instance:

  • ESC ]9;9;C:\fake BEL and ESC ]9;4;1;50 BEL → silent (previously each fired a notification)
  • ESC ]9;hello BEL → still notifies
  • cmd tab: pressing Enter repeatedly no longer fires notifications
  • wmux notify and agent Stop-hook notifications still work

🤖 Generated with Claude Code

OSC 9 is overloaded: iTerm2 uses it for notifications (OSC 9;<text>),
but ConEmu/Windows Terminal use numeric subcommands — 9;<cwd> (cwd
report, emitted by our cmd integration and the standard WT PowerShell
prompt snippet on every prompt redraw) and 4;<state>;<n> (progress).
The handler treated every payload as a notification, so each command
typed at a shell prompt fired a bogus one. Swallow numeric-subcommand
payloads; bare-text notifications still fire.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amirlehmam
amirlehmam merged commit 3c0cbef into amirlehmam:master Jul 29, 2026
amirlehmam added a commit that referenced this pull request Jul 29, 2026
#127 correctly identified that the OSC 9 handler treated ConEmu numeric
subcommands as iTerm2 notification text, so every cmd prompt redraw raised
a bogus notification. It guarded them with `return true`.

xterm runs OSC handlers newest-first and stops at the first returning true.
ProgressAddon registers on OSC 9 too, but is loaded before this handler, so
the notification handler always wins the sequence. Returning true therefore
still consumed 9;4 — the progress bar in the tab strip, sidebar and Windows
taskbar has been fed nothing since it shipped in 0.23.0.

Return false instead: the guard declines the sequence and xterm continues
down the chain to ProgressAddon. Notification spam stays fixed, and progress
starts working for the first time.

The predicate moves to hooks/osc9.ts so it is testable, with a regression
test driving real xterm + real ProgressAddon in wmux's registration order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HorCxLMH2pVuR16QyZCroL
@amirlehmam

Copy link
Copy Markdown
Owner

Merged, thank you — and the diagnosis turned out to uncover a second, older bug.

Your root-cause analysis was exactly right: wmux-cmd-integration.cmd:14 embeds $e]9;9;$P in the prompt, so every redraw was raising a notification with text like 9;C:\path.

While verifying the fix I checked what else registers on OSC 9, and found this: xterm dispatches OSC handlers newest-registered-first, stopping at the first one returning true. ProgressAddon also registers on OSC 9, but it's loaded at useTerminal.ts:431before the notification handler at :568. So the notification handler always wins the sequence, and return true still consumed 9;4.

I confirmed it with real xterm + real ProgressAddon in wmux's registration order:

handler returns notified ProgressAddon fired
master (no guard) 4;1;50, 9;C:\some\path, hello world
true (this PR) hello world
false hello world {state: 1, value: 50}

The OSC 9;4 progress bar — tab strip, sidebar, Windows taskbar — has been fed nothing since it shipped in 0.23.0, because this handler has been eating every OSC 9 the whole time.

So I merged your PR as-is and pushed a follow-up (2be9d41) flipping truefalse, which declines the sequence and lets xterm continue down the chain. Your notification fix is unchanged; progress now works for the first time. The predicate moved to hooks/osc9.ts with a regression test driving both consumers.

Shipping in v0.39.0.

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.

3 participants