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.
- package/dist/index.js +39 -13
- 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
|
-
|
|
198
|
+
const eventType = ev.type;
|
|
199
|
+
switch (eventType) {
|
|
193
200
|
case "session.created":
|
|
194
|
-
activeSessionId = ev.properties?.
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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.
|
|
220
|
-
|
|
221
|
-
|
|
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) => {
|