返回 DeepSeek-Reasonix
deliveryContinue.ts
根目录 / desktop / frontend / src / lib / deliveryContinue.ts
1 // Delivery recovery ("continue checks") flow for final_readiness notices.
2 //
3 // Ordinary Delivery turns carry no Goal, so the recovery prompt is submitted
4 // directly. A tab with a Goal must resume it first so its delivery scope and
5 // persisted checkpoint survive the continuation; a Goal that refuses to resume
6 // (completed, or the tab vanished) is not poked further. The active tab is
7 // re-checked after the async resume so a mid-flight tab switch cannot deliver
8 // the continuation into the wrong session.
9 export interface DeliveryContinueOptions {
10 tabId: string | null | undefined;
11 ready: boolean;
12 goal: string | undefined;
13 activeTabId: () => string | null | undefined;
14 resumeGoal: (tabId: string) => Promise<boolean>;
15 send: (tabId: string) => Promise<void>;
16 }
17
18 export async function continueDelivery(opts: DeliveryContinueOptions): Promise<void> {
19 const { tabId, ready, goal } = opts;
20 if (!tabId || !ready) return;
21 if ((goal ?? "").trim()) {
22 const resumed = await opts.resumeGoal(tabId);
23 if (!resumed) return;
24 if (opts.activeTabId() !== tabId) return;
25 }
26 await opts.send(tabId);
27 }
28
28 lines TYPESCRIPT