Component evidence

Chat Recovery Action Gating (chat/recovery-gating.ts)

open-design · apps/web/src/runtime/chat/recovery-gating.ts · typescript · Apache-2.0
paymentsuichatlang:typescripttag:error-handling

Determines whether chat recovery actions like retry or resume are permitted and resolves error messages when blocked. Reuse in AI chat applications for state validation.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/nexu-io/open-design | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * 报错卡上那一排恢复动作(重试 / 续跑 / 切到 Cloud)**这一刻能不能动**,
 * 以及动不了的时候该说哪句话。
 *
 * ## 为什么要有这个函数
 *
 * 宿主(`ProjectView`)本来就有一个 `currentConversationActionDisabled` 布尔:
 * 六个条件或起来,为真就让 `handleRetry` / `handleResumeRun` /
 * `handleSwitchToAmrAndRetry` **静默 `return`**。而按钮那一侧从来没接过这个
 * 布尔 —— 于是屏幕上是一颗永远可点的〔重试〕,点下去什么都不发生,埋点却已经
 * 上报了一次「用户点了重试」(OPEND-2821)。
 *
 * 修法不是放宽那六个条件 —— 它们各有理由(只读项目、算不出付费主体、会话正忙)。
 * 修法是**把这个布尔换成一个能说出原因的值**,让按钮的可用态和卡面上的说明
 * 都从同一个判据出来。
 *
 * ## 不变量
 *
 * `resolveRecoveryActionBlockReason(...) !== null` 与原来那个布尔
 * **逐条等价**:原式是
 *
 *   busy(loading || streaming || hasActiveRun)


... (truncated -- full source via MCP)