返回 DeepSeek-Reasonix
transientInboxTarget.ts
根目录 / desktop / frontend / src / lib / transientInboxTarget.ts
1 // A transient inbox-target fence: the remote tab is switching, reconnecting or
2 // re-aiming its route. The bridge marks it with a code and RPCErrorData
3 // {"transient": true}; the composer holds the message and retries it briefly
4 // instead of surfacing a failure the user cannot act on.
5
6 export const TRANSIENT_INBOX_TARGET_CODE = "inbox_target_transient";
7
8 // Bounded retry schedule for a held message: four attempts inside ~1.5s, the
9 // span a session switch or reconnect needs to settle.
10 export const TRANSIENT_GUIDANCE_RETRY_DELAYS_MS = [150, 350, 500, 500] as const;
11
12 export function isTransientInboxTargetError(error: unknown): boolean {
13 if (error == null) return false;
14 const data = typeof error === "object" ? (error as { data?: unknown }).data : undefined;
15 if (data && typeof data === "object" && (data as { transient?: unknown }).transient === true) return true;
16 const message = typeof error === "string"
17 ? error
18 : error instanceof Error
19 ? error.message
20 : String((error as { message?: unknown }).message ?? "");
21 return message.includes(TRANSIENT_INBOX_TARGET_CODE);
22 }
23
23 lines TYPESCRIPT