Skip to content

修复:协议类型/CLI类型/daemon lint清理 + tab卡死修复 - #1

Merged
zzhan111 merged 7 commits into
mainfrom
feat/phase-1-tray-app
Jun 11, 2026
Merged

修复:协议类型/CLI类型/daemon lint清理 + tab卡死修复#1
zzhan111 merged 7 commits into
mainfrom
feat/phase-1-tray-app

Conversation

@zzhan111

Copy link
Copy Markdown
Owner

Summary

  • 0fac4c0 — 修复 MCP/daemon 中被 JS dialog 卡死的 tab 导致 daemon 假死的问题(tab-wedge fix)
  • 800d5bb/0defaf7 — 修正 shared 协议类型:补全 bbTabId/progress、截图字段名 screenshotPathpath(对齐运行时契约)
  • 32b239c — 恢复 daemon 交互命令(click/fill/check/select)的 role/name + 状态返回值
  • bc227c1 — CLI typecheck 37→0 清零
  • bb0932e — daemon eslint 错误清零
  • 6de4380 — 更新 tray-app 构建 hash

验证

  • shared / daemon / mcp / cli 全部 tsc-clean
  • daemon lint green
  • daemon 146 + cli 24 测试通过
  • daemon / mcp 运行时无新增行为异常(向后兼容)

说明

本次 PR 集中清理 loop session 中发现的类型债务和协议层不一致问题。所有改动行为中性或纯增量,未改动 BB_* 环境变量、bbTabId 协议字段、x-bb-* 头等兼容层。

🤖 Generated with Claude Code

zzhan111 and others added 7 commits June 10, 2026 23:07
A wedged tab (open JS dialog blocking the renderer) made every CDP
command to it hang until COMMAND_TIMEOUT (30s). The MCP then reported
"Failed to start daemon. Run manually" on the abort, which is false —
the daemon is up — and drove a destructive taskkill/restart loop that
endangers the daemon shared by all agents.

MCP (sendCommand): distinguish our AbortController timeout (daemon up,
tab wedged → truthful hint to dismiss dialog / switch / close tab, and
"do NOT restart the daemon") from a real connection failure (clear the
cached daemon.json, re-read once, retry — also recovers from a daemon
restart that rotated the token/port).

Daemon (handleSessionEvent): always resolve Page.javascriptDialogOpening
— explicit tab.dialogHandler if set, else dismiss (accept:false), the
Playwright-like safe default — so a stray dialog never wedges the tab.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Generated panel.html from an earlier panel rebuild (Vite content-hash
bump for panel-*.js/css). Committed to keep the tracked entrypoint in
sync with the built assets and leave the working tree clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The 线C state-persistence commands tab_claim and task_update return
bbTabId (and task_update also progress) in their response data, but the
shared ResponseData interface never declared these fields. This produced
TS2561 excess-property errors in daemon command-dispatch.ts (lines 1133,
1151) and broke `tsc --noEmit` for the daemon package.

Add both as optional fields next to the existing lease/owner/released
group (the tab_claim/tab_release response family). Daemon typecheck now
passes; 146 daemon tests still green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ResponseData declared the screenshot path as `screenshotPath`, but the
daemon screenshot handler emits it under the key `path`
(command-dispatch.ts:869) and the CLI reads `response.data.path`
(screenshot.ts:68,80). `screenshotPath` had zero consumers anywhere —
the protocol type was the lone outlier, causing TS2339 "Property 'path'
does not exist" in the CLI.

Rename the field to `path` to match the actual daemon→CLI contract.
Behavior-neutral (no runtime change); fixes the two CLI screenshot
typecheck errors. daemon + mcp still typecheck clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The click/hover/fill/type/check/uncheck/select handlers returned only
{tab, seq}, but the CLI display code reads role, name, selectedValue,
selectedLabel, wasAlreadyChecked and wasAlreadyUnchecked from the
response. Since the CLI→daemon port these fields were never populated,
producing TS2339 errors (~18) and degraded CLI output (e.g. select
printed `选项: "undefined"`).

Populate them from data already on hand:
- role/name come from tab.refs[ref] (loaded by parseRef — zero extra CDP)
- check/uncheck fold a prior-state read into the existing callFunctionOn
  (returnByValue) to report wasAlready(Un)checked
- select returns the chosen option's visible text as selectedLabel and
  echoes selectedValue

Also declare these optional fields on the shared ResponseData type. All
additive — no existing field or control flow changed. daemon + mcp
typecheck clean; 146 daemon tests pass; CLI typecheck errors 33 → 15.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All behavior-neutral type-correctness fixes aligning the CLI to the
daemon-era contract:

- since parsing (console/errors/network): type the parsed value as
  `number | "last_action"` and drop the redundant `Request & {since}`
  intersection that collapsed it back to `number`.
- tabId (fetch/site): daemon tab ids are short hex strings, so widen the
  `number`-typed locals/returns to `string | number` to match TabInfo/
  ResponseData/Request.tabId, which are already `number | string`.
- open: assign `request.tabId` directly (Request.tabId exists) instead of
  an unsafe `as Record<string, unknown>` cast.
- reload: annotate the `/json/list` response shape; add @types/ws as a
  devDep so the `ws` import, message `data` and error `err` are typed.
- openclaw-bridge: throw when neither id nor targetId is returned so
  ocOpenTab honours its `string` return type.

No runtime behavior changed. cli typecheck 15 → 0; 24 cli tests pass;
daemon + mcp still clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`turbo run lint` failed on the daemon package with 7 pre-existing
no-unused-vars errors plus one stale eslint-disable. None affect runtime;
all are dead code:

- 3 test files imported `before` from node:test but never used it
- scratchpad-manager.test.ts had an unused `t` test-context arg
- ws.d.ts imported IncomingMessage/ClientRequest/Duplex but referenced none
- index.ts carried an eslint-disable for no-constant-condition that the
  active config no longer reports

daemon eslint now passes; tsc clean; 146 tests still green. (The web
package's vite.config.js no-undef lint errors are a separate eslint-env
config issue, left untouched.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@zzhan111
zzhan111 merged commit 70b0db7 into main Jun 11, 2026
1 check failed
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.

1 participant