Skip to content

fix(ui): LongBridge 超时/未知状态给出专属处置建议,横幅不再误报「需要安装」 - #313

Open
wxrbyte wants to merge 1 commit into
helsome:mainfrom
wxrbyte:codex/fix-longbridge-status-action
Open

wxrbyte wants to merge 1 commit into
helsome:mainfrom
wxrbyte:codex/fix-longbridge-status-action

Conversation

@wxrbyte

@wxrbyte wxrbyte commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

问题与修复

LongBridgeStatusValue 有 6 个取值(packages/longbridge-tools/src/status.ts:4-10),但 apps/electron/src/main/kernelHost.ts:2586-2597 的 getLongBridgeStatusAction() 只处理其中 3 个,'timeout' 与 'unknown' 落到 default: return undefined。UI(AppShell.tsx:67-73)又把 undefined 兜底成 Install LongBridge CLI and run longbridge auth login.,标题也只剩「限流 / 其它」两分支 —— 于是超时被描述成「需要安装」,而 CLI 其实已安装、也可能已登录。

本 PR:

  • getLongBridgeStatusAction() 补齐 'timeout' 与 'unknown' 两个分支(超时 → 检查网络/代理并重试;未归类错误 → 先 longbridge --version 自检再重试)。'available' 仍由调用方 status.available ? undefined : …(kernelHost.ts:645-647)短路,不需要动作,故不新增分支。
  • AppShell.tsx 的横幅标题把 'timeout' 并入「paused」分支:超时是暂时不可用,与限流同类;'unknown' 保留 setup needed(原因未知,确实可能是环境问题)。

不改动已支持状态的既有文案,不改 IPC 契约与状态码。

Closes #312

可复现测试报告

  • 环境:Windows 10、Bun 1.4.2(744846f84);基线 main 3a17eca6(2026-10-03T16:16:35Z)
  • 聚焦测试 cd apps/electron && bun test src/main/kernelHost.test.ts(新增 3 个用例:available 无动作 / timeout 走重试而非安装 / unknown 有自己的动作):
    • 修复前 → 12 pass / 2 fail(Expected: "string" / Received: "undefined")
    • 修复后 → 14 pass / 0 fail
  • 类型检查 bun run typecheck → @finagent/core / i18n / shared / ui / electron 全部 exit 0
  • 全量 cd apps/electron && bun test → 32 pass / 1 fail。唯一失败是 research-prompts.test.ts 的 synthesis prompt embeds SECURITY RULES before the data bundle,与本改动无关且属既有问题:它单独运行是 4 pass / 0 fail;把本 PR 的 3 个文件还原成 main 版本后全量仍是 29 pass / 1 fail(同一条失败);且 research-prompts.ts / research-prompts.test.ts 与上游 main 逐字节一致。判定为既有的跨文件测试隔离问题,未在本 PR 处理。
  • 未运行的测试:test:e2e / test:e2e:visible / test:package-smoke(Windows 上跑不起完整 e2e)。
  • 说明:上游 .github/workflows/pr.yml 当前为 disabled_manually,本 PR 不会产生 check run —— 以上全部为等价本地命令结果,非 CI。

UI 变化

LongBridge 横幅在超时场景下的文案:

项 修复前 修复后
标题前缀 LongBridge setup needed: LongBridge paused:
处置建议 Install LongBridge CLI and run longbridge auth login.(action 为 undefined 时的兜底) LongBridge CLI timed out; market data requests are paused. Check your network or proxy and retry.

'unknown' 场景标题前缀不变(仍为 setup needed),但处置建议由安装引导改为 run longbridge --version 自检 + 重试。已支持状态(not_installed / not_authed / rate_limited)与 available(不显示横幅)文案不变。本 PR 未附组件截图(§7.6 的截图流程在评审要求时启用),如需要我可在本 PR 补 Before/After 组件截图与直链。

查重与冲突

getLongBridgeStatusAction() covered only 3 of the 6 LongBridgeStatusValue
states, so 'timeout' and 'unknown' returned undefined. The renderer then fell
back to "Install LongBridge CLI and run longbridge auth login." and titled the
banner "setup needed" - wrong guidance when the CLI is installed and the call
merely did not return in time.

Add timeout/unknown branches to the action map, and treat a timeout as a pause
rather than a setup problem in the banner title.

Refs helsome#312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): LongBridge 超时/未知失败缺少处置建议,横幅却提示「需要安装」

1 participant