Skip to content

fix(dsh-plugin): show the connected browsers a selector miss reports - #404

Open
PerryLink wants to merge 1 commit into
Tencent:mainfrom
PerryLink:fix/dsh-plugin-selector-miss-candidates
Open

PerryLink wants to merge 1 commit into
Tencent:mainfrom
PerryLink:fix/dsh-plugin-selector-miss-candidates

Conversation

@PerryLink

Copy link
Copy Markdown
Contributor

#313 taught the CLI to list the connected browsers when a selector matches nothing, so a caller can pick a real instance or label instead of probing every browser in turn. The list reaches the JSON envelope; it does not reach a DSH user.

bsk --json reports the miss as NotFound with the candidates in data.browsers:

{ "code": "not_found", "message": "requested browser is not connected", "data": { "browsers": [ … ] } }

parseBskJson reads code, message and hint and drops data, and BskError has no field to carry it, so the candidates stop there. Putting them on the error object would not be enough either: the tool layer re-throws and the host shows error.message, so the list has to travel in the message.

Change

One helper, used in the place the CLI's own renderer puts the table — between the summary and the hint:

bsk session start failed: requested browser is not connected; connected browsers: alpha (chrome 131, label "Personal", 0 sessions); beta (edge 130, 1 session) (hint: run bsk browsers to list them)

It is deliberately one line. tools.ts keeps error.message.split("\n")[0] for the action card, so a multi-line list would be truncated in the UI while looking complete in the transcript.

Only data.browsers renders. Every other envelope is untouched, including the two that also use data — session_busy's reason, which drives the one-shot retry, and the ambiguous-label ids. An empty list renders nothing, matching the CLI, which leaves a miss against an empty registry unrendered too; an entry with no instance_id is skipped rather than printed as a blank row.

Verification

The two revisions were executed side by side over twelve envelopes. Two messages changed — the selector miss, and one case with a malformed candidate — and the other ten are byte-identical, covering session_busy, the fill_value_mismatch envelope, timeouts, killed-by-interrupt children, non-JSON stderr, and both success paths.

Three cases were added to tests/runner.test.ts: the candidate list (asserting the wording, the summary → candidates → hint order, and that the result is a single line), an empty list, and a data payload that is not a candidate list.

I have not run the package's own vitest here — the plugin's build step is what I could not reproduce locally — so the added cases are written to the file's existing conventions rather than reported green. The envelope comparison above runs the real runner.ts for both revisions.

Thanks again for #313; this is the follow-up you flagged in review.

Tencent#313 lists the connected browsers on a selector miss so the caller can pick a
real instance or label instead of probing every browser in turn. The list
reaches the `bsk --json` envelope as `data.browsers`, but `parseBskJson` reads
only `code`, `message` and `hint`, so it stops at the plugin boundary. Carrying
it on the error object would not help either: the tool layer re-throws and the
host shows `error.message`.

The list now renders into that message, between the summary and the hint, which
is the order the CLI's own renderer uses. It stays on one line because
`tools.ts` keeps only the first line of the message for the action card.

Only `data.browsers` renders. `data` also carries `reason` for the session-busy
retry and the ambiguous-label ids, and those envelopes are unchanged, as is every
other error, timeout, interrupt and success path - checked by running both
revisions over twelve envelopes, of which exactly two differ.
@PerryLink
PerryLink force-pushed the fix/dsh-plugin-selector-miss-candidates branch from a1906ff to 0f19398 Compare October 7, 2026 05:02

This branch has not been deployed

No deployments
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