Skip to content

Commit e5e1a52

Browse files
authored
Fix: notifications broken on Windows (writeFileSync /dev/tty) (#12)
* fall back to process.stdout.write when writeFileSync fails * fix package-lock and untrack node_modules/package-lock * revert some changes
1 parent e60e068 commit e5e1a52

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/notify.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@ import { writeFileSync } from "fs"
44
* Send a Warp notification via OSC 777 escape sequence.
55
* Only emits when Warp declares cli-agent protocol support,
66
* avoiding garbled output in other terminals (and working over SSH).
7+
*
8+
* On Unix we write to /dev/tty so the sequence bypasses any
9+
* stdout redirection or terminal-multiplexer capture.
10+
* On Windows /dev/tty doesn't exist, so we fall back to
11+
* process.stdout which works because OpenCode plugins run
12+
* in-process (sharing the same ConPTY-connected stdout).
713
*/
814
function warpNotify(title: string, body: string): void {
915
if (!process.env.WARP_CLI_AGENT_PROTOCOL_VERSION) return
1016

17+
const sequence = `\x1b]777;notify;${title};${body}\x07`
18+
1119
try {
12-
// OSC 777 format: \033]777;notify;<title>;<body>\007
13-
const sequence = `\x1b]777;notify;${title};${body}\x07`
1420
writeFileSync("/dev/tty", sequence)
1521
} catch {
16-
// Silently ignore if /dev/tty is not available
22+
// /dev/tty unavailable (e.g. Windows) — write to stdout instead.
23+
try {
24+
process.stdout.write(sequence)
25+
} catch {
26+
// Silently ignore if stdout is also unavailable
27+
}
1728
}
1829
}
1930

0 commit comments

Comments
 (0)