zjbar-opencode 1.1.8 → 1.1.10

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 +39 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -145,9 +145,15 @@ 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
+ const STOP_DEBOUNCE_MS = 2000;
156
+ let stopDebounceTimer = null;
151
157
  let zellijBin = "zellij";
152
158
  try {
153
159
  const { execFileSync } = __require("node:child_process");
@@ -189,22 +195,39 @@ var ZjbarPlugin = async ({ directory, client }) => {
189
195
  return {
190
196
  event: async ({ event }) => {
191
197
  const ev = event;
192
- switch (ev.type) {
198
+ const eventType = ev.type;
199
+ switch (eventType) {
193
200
  case "session.created":
194
- activeSessionId = ev.properties?.sessionID || null;
201
+ activeSessionId = ev.properties?.info?.id || null;
195
202
  sendToZjbar("SessionStart");
196
203
  break;
204
+ case "session.status": {
205
+ const status = ev.properties?.status?.type;
206
+ if (status === "busy") {
207
+ if (stopDebounceTimer) {
208
+ clearTimeout(stopDebounceTimer);
209
+ stopDebounceTimer = null;
210
+ }
211
+ sendToZjbar("UserPromptSubmit");
212
+ }
213
+ break;
214
+ }
197
215
  case "session.idle": {
198
216
  sendToZjbar("Stop", null, null, true);
217
+ if (stopDebounceTimer)
218
+ clearTimeout(stopDebounceTimer);
199
219
  const sid = ev.properties?.sessionID || activeSessionId;
200
- if (sid && client) {
201
- try {
202
- const summary = await getSessionSummary(client, sid);
203
- if (summary && shouldNotify("Stop", paneId, termProgram)) {
204
- sendNotification("Stop", paneId, zellijSession, termProgram, summary);
205
- }
206
- } catch {}
207
- }
220
+ stopDebounceTimer = setTimeout(async () => {
221
+ stopDebounceTimer = null;
222
+ if (sid && client) {
223
+ try {
224
+ const summary = await getSessionSummary(client, sid);
225
+ if (summary && shouldNotify("Stop", paneId, termProgram)) {
226
+ sendNotification("Stop", paneId, zellijSession, termProgram, summary);
227
+ }
228
+ } catch {}
229
+ }
230
+ }, STOP_DEBOUNCE_MS);
208
231
  break;
209
232
  }
210
233
  case "session.deleted":
@@ -216,10 +239,13 @@ var ZjbarPlugin = async ({ directory, client }) => {
216
239
  sendToZjbar("PermissionRequest", null, permTitle);
217
240
  break;
218
241
  }
219
- case "message.created":
220
- activeSessionId = ev.properties?.info?.sessionID || activeSessionId;
221
- sendToZjbar("UserPromptSubmit");
242
+ case "message.updated": {
243
+ const msgInfo = ev.properties?.info;
244
+ if (msgInfo?.role === "user" && msgInfo?.sessionID) {
245
+ activeSessionId = msgInfo.sessionID;
246
+ }
222
247
  break;
248
+ }
223
249
  }
224
250
  },
225
251
  "tool.execute.before": async (input) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zjbar-opencode",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
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",