opencode-queue 0.12.0 → 0.12.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 +1 -1
- package/index.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ When the session is idle:
|
|
|
113
113
|
/queue clear 2 3
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Queues are scoped to the current project and session. They are stored in OpenCode's user data directory and restored after OpenCode restarts or crashes. A send interrupted by a crash remains queued because the plugin cannot know whether OpenCode accepted it before exiting.
|
|
116
|
+
Queues are scoped to the current project and session. They are stored in OpenCode's user data directory and restored with their previous running or stopped state after OpenCode restarts or crashes. Restored queues do not replay just because the session starts idle; a running queue resumes after the session becomes busy and then finishes successfully. A send interrupted by a crash remains queued because the plugin cannot know whether OpenCode accepted it before exiting.
|
|
117
117
|
|
|
118
118
|
## Notes
|
|
119
119
|
|
package/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ type EntryOp =
|
|
|
33
33
|
| { kind: "compact"; source: string }
|
|
34
34
|
| { kind: "shell"; source: string; shell: string }
|
|
35
35
|
|
|
36
|
-
type Activity = { kind: "idle" } | { kind: "busy" } | { kind: "sending"; idle: boolean; items: Item[] }
|
|
36
|
+
type Activity = { kind: "idle" } | { kind: "restored" } | { kind: "busy" } | { kind: "sending"; idle: boolean; items: Item[] }
|
|
37
37
|
type State = { items: Item[]; activity: Activity; stopped: boolean; failed: boolean; hidden: Set<string> }
|
|
38
38
|
type Durable = Pick<State, "items" | "stopped" | "hidden">
|
|
39
39
|
type Store = { version: 1; projectID: string; sessions: Record<string, { items: Item[]; stopped: boolean; hidden: string[] }> }
|
|
@@ -215,7 +215,8 @@ export const QueuePlugin: Plugin = async ({ client, project, directory }) => {
|
|
|
215
215
|
const validHidden = Array.isArray(value.hidden) && value.hidden.every((id) => typeof id === "string")
|
|
216
216
|
if (!validHidden) console.warn("QueuePlugin skipped invalid stored hidden messages", sid)
|
|
217
217
|
const hidden = new Set(validHidden ? (value.hidden as string[]) : [])
|
|
218
|
-
|
|
218
|
+
const activity: Activity = { kind: items.length && !value.stopped ? "restored" : "idle" }
|
|
219
|
+
if (items.length || value.stopped || hidden.size) sessions.set(sid, { items, activity, stopped: value.stopped, failed: false, hidden })
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
} catch (error) {
|
|
@@ -706,7 +707,6 @@ export const QueuePlugin: Plugin = async ({ client, project, directory }) => {
|
|
|
706
707
|
},
|
|
707
708
|
}
|
|
708
709
|
|
|
709
|
-
for (const [sid, current] of sessions) if (current.items.length && !current.stopped) setTimeout(() => advance(sid), 0)
|
|
710
710
|
return hooks
|
|
711
711
|
}
|
|
712
712
|
|
package/package.json
CHANGED