File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 */
814function 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
You can’t perform that action at this time.
0 commit comments