Skip to content

[dsh plugin 0.2.1] leafNodes() crashes on first paint under better-sidebar 0.19 — "Cannot read properties of undefined (reading 'kind')" #232

Description

@DCAMAR

Symptom

In the DSH (DeepSeek Harness) web client, the Browser Skill sidebar tab throws on first open, every time. Host (dsh-better-sidebar) catches it in its error boundary and shows a "Retry" button; clicking Retry renders fine.

TypeError: Cannot read properties of undefined (reading 'kind')
    at leafNodes  (@wxg-prc-cpg/browser-skill-dsh-plugin/lib/client.cjs)
    at observationTabOpen  (…)
    at evaluate  (…)
    at publish  (…)

Root cause (file + line)

lib/client.cjsleafNodes() (~L4462) and observationTabOpen() (~L4470):

function* leafNodes(node) {
  if (node.kind === "leaf") {          // <-- throws when node is undefined
    yield node; return;
  }
  for (const child of node.children) yield* leafNodes(child);
}

function observationTabOpen(state) {
  if (state === void 0) return false;                      // only `state` is guarded
  for (const root of [state.splits, state.bottomSplits])   // either can be undefined on the first frames
    for (const leaf of leafNodes(root)) 
}

On the first render the host workbench layout state is not populated yet, so state.splits / state.bottomSplits are undefinednode.kind throws. That is why the first open always fails and the manual retry always succeeds.

Suggested fix (one line)

function* leafNodes(node) {
  if (node === void 0) return;
  if (node.kind === "leaf") { yield node; return; }
  for (const child of node.children ?? []) yield* leafNodes(child);
}

(or skip undefined roots inside observationTabOpen).

Environment

  • @wxg-prc-cpg/browser-skill-dsh-plugin@0.2.1 (latest at the time of writing)
  • dsh-better-sidebar@0.19.1 (latest)
  • DSH 0.1.5-rc.1 · Windows 11 · Node 24

Related observation (same file, likely the same migration)

The tab is still opened with the legacy 0.18-era contract:

service.openTab({ type: OBSERVATION_TAB_TYPE, path: OBSERVATION_TAB_PATH })

Under better-sidebar 0.19 this path appears to be resolved as a file path, producing
cannot resolve target "…/browser-skill-observation": ENOENT on the auto-open path
(manually clicking the tab renders fine). May be worth migrating to the 0.19 tab contract.

Locally we patched leafNodes with an undefined-guard and verified the first-open crash is gone.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions