修复:协议类型/CLI类型/daemon lint清理 + tab卡死修复 - #1
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bbTabId/progress、截图字段名screenshotPath→path(对齐运行时契约)role/name+ 状态返回值验证
说明
本次 PR 集中清理 loop session 中发现的类型债务和协议层不一致问题。所有改动行为中性或纯增量,未改动
BB_*环境变量、bbTabId协议字段、x-bb-*头等兼容层。🤖 Generated with Claude Code