Skip to content

fix(notify): cross-platform TTY write with CONOUT$/CON fallback for Windows (fixes #15)#16

Open
MoerAI wants to merge 1 commit intowarpdotdev:mainfrom
MoerAI:fix/cross-platform-tty-notify
Open

fix(notify): cross-platform TTY write with CONOUT$/CON fallback for Windows (fixes #15)#16
MoerAI wants to merge 1 commit intowarpdotdev:mainfrom
MoerAI:fix/cross-platform-tty-notify

Conversation

@MoerAI
Copy link
Copy Markdown

@MoerAI MoerAI commented Apr 20, 2026

Summary

  • Replace single /dev/tty write with a platform-aware cascade that works on Windows
  • Port WARP_CLIENT_VERSION validation from claude-code-warp to skip broken Warp builds

Problem

warpNotify() writes OSC 777 via writeFileSync("/dev/tty"), which is Unix-only. On Windows, this silently fails and no notifications ever reach Warp. PR #12's process.stdout.write() fallback also doesn't work because OpenCode's plugin loader pipes stdout for RPC — it never reaches the terminal.

Additionally, some Warp builds set WARP_CLI_AGENT_PROTOCOL_VERSION without actually supporting structured notifications, causing the plugin to send events that are silently dropped.

Fix

src/notify.ts — New writeTty() function with ordered fallback:

  1. /dev/tty — standard Unix controlling terminal (also works in WSL)
  2. CONOUT$ — Windows console output device (bypasses stdio redirection)
  3. CON — Windows console device (alternative path)
  4. process.stderr — last resort, only if stderr is still a TTY

Each target is opened with openSync/writeSync/closeSync for proper fd management.

Added WARP_CLIENT_VERSION gating (ported from claude-code-warp's should-use-structured.sh) to avoid sending notifications to known-broken Warp builds.

Changes

File Change
src/notify.ts Replace writeFileSync("/dev/tty") with cross-platform writeTty() cascade; add WARP_CLIENT_VERSION check
tests/index.test.ts Add writeTty smoke test

How to Test

  1. On Windows: Install plugin locally, run opencode in Warp, send a query — notifications should appear
  2. On macOS/Linux: Behavior unchanged (still uses /dev/tty first)

Fixes #15
Supersedes #12

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.

fix(notify): cross-platform TTY write — /dev/tty unavailable in OpenCode plugin context on Windows

1 participant