opencode-queue 0.11.0 → 0.11.2
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/README.md +2 -2
- package/index.ts +19 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ When the session is busy:
|
|
|
85
85
|
- Only one queued entry is sent per idle transition, so queued work runs one item at a time.
|
|
86
86
|
- Queued entries are kept in place after an error or abort.
|
|
87
87
|
- `/queue stop` pauses automatic replay without clearing queued entries, and `/queue start` resumes it.
|
|
88
|
-
- `/queue flush` sends all queued entries immediately, even before the session is idle.
|
|
88
|
+
- `/queue flush` sends all queued entries immediately in one batch, even before the session is idle.
|
|
89
89
|
|
|
90
90
|
When the session is idle:
|
|
91
91
|
|
|
@@ -97,7 +97,7 @@ When the session is idle:
|
|
|
97
97
|
- `/queue !ls` runs `ls` immediately as an OpenCode shell block.
|
|
98
98
|
- `/queue` and `/queue list` show the current queue.
|
|
99
99
|
- `/queue stop` pauses automatic replay, and `/queue start` resumes it.
|
|
100
|
-
- `/queue flush` sends all queued entries immediately.
|
|
100
|
+
- `/queue flush` sends all queued entries immediately in one batch.
|
|
101
101
|
- `/queue clear` clears the current queue, and `/queue clear 1` clears a specific queued item.
|
|
102
102
|
|
|
103
103
|
## Queue Management
|
package/index.ts
CHANGED
|
@@ -139,7 +139,7 @@ const plan = (event: unknown): event is Ask => {
|
|
|
139
139
|
return question?.header === "Build Agent" && question.question.includes("switch to the build agent")
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
export const QueuePlugin: Plugin = async ({ client }) => {
|
|
142
|
+
export const QueuePlugin: Plugin = async ({ client, directory }) => {
|
|
143
143
|
const sessions = new Map<string, State>()
|
|
144
144
|
const hidden = new Set<string>()
|
|
145
145
|
const post = (client as unknown as { _client?: { post?: Post } })._client?.post
|
|
@@ -154,7 +154,7 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const toast = (message: string, variant: "info" | "error", duration = 2500) =>
|
|
157
|
-
client.tui.showToast({ body: { message, variant, duration } }).catch(() => undefined)
|
|
157
|
+
client.tui.showToast({ body: { message, variant, duration }, query: { directory } }).catch(() => undefined)
|
|
158
158
|
|
|
159
159
|
const stop = async (message: string, variant: "info" | "error" = "info", duration = 5000): Promise<never> => {
|
|
160
160
|
await toast(message, variant, duration)
|
|
@@ -292,27 +292,30 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
292
292
|
const items = current.items.splice(0, count)
|
|
293
293
|
if (!items.length) return { sent: 0, failed: 0 }
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
current.activity = { kind: "sending", idle: false }
|
|
296
|
+
let retry: Item[] = []
|
|
297
297
|
try {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
298
|
+
const results = await Promise.all(
|
|
299
|
+
items.map(async (item) => {
|
|
300
|
+
try {
|
|
301
|
+
await replay(sid, item)
|
|
302
|
+
return { item, failed: false }
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error("QueuePlugin failed to flush queued input", error)
|
|
305
|
+
await toast(`Queue failed: ${error instanceof Error ? error.message : String(error)}`, "error")
|
|
306
|
+
return { item, failed: true }
|
|
307
|
+
}
|
|
308
|
+
}),
|
|
309
|
+
)
|
|
310
|
+
retry = results.flatMap((result) => (result.failed ? [result.item] : []))
|
|
309
311
|
} finally {
|
|
310
312
|
if (retry.length) current.items.unshift(...retry)
|
|
313
|
+
const failed = retry.length
|
|
311
314
|
const replayCompleted = current.activity.kind === "sending" && current.activity.idle
|
|
312
315
|
if (replayCompleted) settle(sid, count === 1 && failed === 0)
|
|
313
316
|
else current.activity = failed ? { kind: "idle" } : { kind: "busy" }
|
|
314
317
|
}
|
|
315
|
-
return { sent: items.length -
|
|
318
|
+
return { sent: items.length - retry.length, failed: retry.length }
|
|
316
319
|
}
|
|
317
320
|
|
|
318
321
|
const manage = async (sid: string, op: ControlOp) => {
|
package/package.json
CHANGED