From bf0c3dcf832cc38f30ab736c800891e99d0aff0e Mon Sep 17 00:00:00 2001 From: Harry Date: Wed, 25 Mar 2026 17:59:29 -0700 Subject: [PATCH 1/2] rely on plugin version instead of terminal type for notifications --- src/index.ts | 12 ++++++++++++ src/notify.ts | 5 +++-- tests/notify.test.ts | 22 ++++++++-------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index 745211a..1186a11 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,6 +52,18 @@ function sendPermissionNotification(perm: Permission, cwd: string): void { } export const WarpPlugin: Plugin = async ({ client, directory }) => { + if (!process.env.WARP_CLI_AGENT_PROTOCOL_VERSION) { + await client.app.log({ + body: { + service: "opencode-warp", + level: "warn", + message: + "⚠️ Please update Warp to get agent notifications — your terminal does not declare cli-agent protocol support", + }, + }) + return {} + } + await client.app.log({ body: { service: "opencode-warp", diff --git a/src/notify.ts b/src/notify.ts index 4c8d4a3..e0086cd 100644 --- a/src/notify.ts +++ b/src/notify.ts @@ -2,10 +2,11 @@ import { writeFileSync } from "fs" /** * Send a Warp notification via OSC 777 escape sequence. - * Only emits when running inside Warp terminal to avoid garbled output in other terminals. + * Only emits when Warp declares cli-agent protocol support, + * avoiding garbled output in other terminals (and working over SSH). */ function warpNotify(title: string, body: string): void { - if (process.env.TERM_PROGRAM !== "WarpTerminal") return + if (!process.env.WARP_CLI_AGENT_PROTOCOL_VERSION) return try { // OSC 777 format: \033]777;notify;;<body>\007 diff --git a/tests/notify.test.ts b/tests/notify.test.ts index 358edbd..5f54001 100644 --- a/tests/notify.test.ts +++ b/tests/notify.test.ts @@ -11,31 +11,25 @@ mock.module("fs", () => ({ const { warpNotify } = await import("../src/notify") describe("warpNotify", () => { - const originalTermProgram = process.env.TERM_PROGRAM + const originalVersion = process.env.WARP_CLI_AGENT_PROTOCOL_VERSION afterEach(() => { writeSpy.mockClear() - if (originalTermProgram === undefined) { - delete process.env.TERM_PROGRAM + if (originalVersion === undefined) { + delete process.env.WARP_CLI_AGENT_PROTOCOL_VERSION } else { - process.env.TERM_PROGRAM = originalTermProgram + process.env.WARP_CLI_AGENT_PROTOCOL_VERSION = originalVersion } }) - it("skips when TERM_PROGRAM is not set", () => { - delete process.env.TERM_PROGRAM + it("skips when WARP_CLI_AGENT_PROTOCOL_VERSION is not set", () => { + delete process.env.WARP_CLI_AGENT_PROTOCOL_VERSION warpNotify("title", "body") expect(writeSpy).not.toHaveBeenCalled() }) - it("skips for other terminal programs", () => { - process.env.TERM_PROGRAM = "iTerm.app" - warpNotify("title", "body") - expect(writeSpy).not.toHaveBeenCalled() - }) - - it("writes OSC 777 sequence when inside Warp", () => { - process.env.TERM_PROGRAM = "WarpTerminal" + it("writes OSC 777 sequence when Warp declares protocol support", () => { + process.env.WARP_CLI_AGENT_PROTOCOL_VERSION = "1" warpNotify("warp://cli-agent", '{"event":"stop"}') expect(writeSpy).toHaveBeenCalledTimes(1) From 79c61b943f5e1f4d62ab20f34d08402ba110f2f5 Mon Sep 17 00:00:00 2001 From: Harry <harryalbert364@gmail.com> Date: Mon, 6 Apr 2026 15:25:38 -0400 Subject: [PATCH 2/2] update error --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1186a11..3564809 100644 --- a/src/index.ts +++ b/src/index.ts @@ -58,7 +58,7 @@ export const WarpPlugin: Plugin = async ({ client, directory }) => { service: "opencode-warp", level: "warn", message: - "⚠️ Please update Warp to get agent notifications — your terminal does not declare cli-agent protocol support", + "⚠️ Detected unsupported Warp version. Please update Warp to use this pluginDetected unsupported Warp version. Please update Warp to use this plugin", }, }) return {}