zjbar-opencode 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +32 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -145,9 +145,14 @@ var ZjbarPlugin = async ({ directory, client }) => {
145
145
  const paneId = process.env.ZELLIJ_PANE_ID;
146
146
  if (!zellijSession || !paneId)
147
147
  return {};
148
+ const GUARD_KEY = "ZJBAR_OPENCODE_ACTIVE";
149
+ if (process.env[GUARD_KEY])
150
+ return {};
151
+ process.env[GUARD_KEY] = "1";
148
152
  const sessionId = crypto.randomUUID();
149
153
  const termProgram = process.env.TERM_PROGRAM || null;
150
154
  let activeSessionId = null;
155
+ let stopNotified = false;
151
156
  let zellijBin = "zellij";
152
157
  try {
153
158
  const { execFileSync } = __require("node:child_process");
@@ -160,7 +165,7 @@ var ZjbarPlugin = async ({ directory, client }) => {
160
165
  }
161
166
  }
162
167
  }
163
- function sendToZjbar(hookEvent, toolName, summary) {
168
+ function sendToZjbar(hookEvent, toolName, summary, skipDesktop) {
164
169
  const payload = JSON.stringify({
165
170
  source: "opencode",
166
171
  pane_id: parseInt(paneId, 10),
@@ -181,7 +186,7 @@ var ZjbarPlugin = async ({ directory, client }) => {
181
186
  payload
182
187
  ], { detached: true, stdio: "ignore" });
183
188
  child.unref();
184
- if (shouldNotify(hookEvent, paneId, termProgram)) {
189
+ if (!skipDesktop && shouldNotify(hookEvent, paneId, termProgram)) {
185
190
  sendNotification(hookEvent, paneId, zellijSession, termProgram, summary);
186
191
  }
187
192
  }
@@ -189,20 +194,34 @@ var ZjbarPlugin = async ({ directory, client }) => {
189
194
  return {
190
195
  event: async ({ event }) => {
191
196
  const ev = event;
192
- switch (ev.type) {
197
+ const eventType = ev.type;
198
+ switch (eventType) {
193
199
  case "session.created":
194
- activeSessionId = ev.properties?.sessionID || null;
200
+ activeSessionId = ev.properties?.info?.id || null;
195
201
  sendToZjbar("SessionStart");
196
202
  break;
203
+ case "session.status": {
204
+ const status = ev.properties?.status?.type;
205
+ if (status === "busy") {
206
+ stopNotified = false;
207
+ sendToZjbar("UserPromptSubmit");
208
+ }
209
+ break;
210
+ }
197
211
  case "session.idle": {
212
+ sendToZjbar("Stop", null, null, true);
213
+ if (stopNotified)
214
+ break;
198
215
  const sid = ev.properties?.sessionID || activeSessionId;
199
- let summary = null;
200
216
  if (sid && client) {
201
217
  try {
202
- summary = await getSessionSummary(client, sid);
218
+ const summary = await getSessionSummary(client, sid);
219
+ if (summary && shouldNotify("Stop", paneId, termProgram)) {
220
+ stopNotified = true;
221
+ sendNotification("Stop", paneId, zellijSession, termProgram, summary);
222
+ }
203
223
  } catch {}
204
224
  }
205
- sendToZjbar("Stop", null, summary);
206
225
  break;
207
226
  }
208
227
  case "session.deleted":
@@ -214,10 +233,13 @@ var ZjbarPlugin = async ({ directory, client }) => {
214
233
  sendToZjbar("PermissionRequest", null, permTitle);
215
234
  break;
216
235
  }
217
- case "message.created":
218
- activeSessionId = ev.properties?.info?.sessionID || activeSessionId;
219
- sendToZjbar("UserPromptSubmit");
236
+ case "message.updated": {
237
+ const msgInfo = ev.properties?.info;
238
+ if (msgInfo?.role === "user" && msgInfo?.sessionID) {
239
+ activeSessionId = msgInfo.sessionID;
240
+ }
220
241
  break;
242
+ }
221
243
  }
222
244
  },
223
245
  "tool.execute.before": async (input) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zjbar-opencode",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "zjbar plugin for OpenCode — live AI activity indicators in Zellij status bar",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",