Repository navigation
fix(refs): make ambiguity candidate refs paste-ready and carry device boot state - #4853
Conversation
… boot state Two same-domain ambiguity recoverability fixes: - A drag whose target selector refused used to print bare candidate refs the caller's frame never authorized: the drag's own resolution capture advanced past the tree that minted them, so pasting a printed ref was refused as superseded. The gesture route now runs the same ambiguity-issuance rule as the touch routes and the strict reads (the consumed-capture slot, then publishAmbiguousMatchCandidateRefs), so printed candidates are issued on the frame that lists them or not printed at all. The CLI render chain re-pins every printed line to the epoch the caller will face through one shared grammar (pinElementMatchCandidateLine beside the snapshot-line renderer). - A tied-device refusal listed id and name only. A tie can span booted and shut-down devices, and an id picked without the state can aim at a device that cannot answer, so both refusal sites (the kernel tie and the selection resolver) now print each candidate's boot state through one summary builder, and the Devices block renders booted=true/false. Unit acceptance: an ambiguous drag refusal's printed candidate ref, pinned as its refsGeneration directs, is admitted on the issued frame and taps the listed node. Co-Authored-By: Claude Code <noreply@anthropic.com>
…ror renderer CI caught the eager-closure budget: a static edge from the command-output error renderer into capture-kit's snapshot-line module pulled 12 new modules into the command-output entry closure. The pin grammar's only consumer is this renderer, so it folds back into the private helper — the render chain still re-pins born-stamped candidate lines, and capture-kit's renderer keeps emitting bare lines (the callstack#2870 wire shape). Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Thanks for the PR. It is ready at dc30a9d: CI is green (12 checks, none failing), and there are no conflicts. Not blocking, and fine to take or leave: the re-pin branch in pinCandidateLine (packages/command-output/src/output/error.ts#L241) cannot fire today because no producer emits stamped candidate lines, and re-pinning a stale stamp would point the ref at the wrong element, so the base regex and the re-pin test can go; the free-standing comment block in packages/capture-kit/src/snapshot/snapshot-lines.ts#L105 is orphaned, and MCP renders through the same formatHumanError, so it can be deleted; the drag test in interaction-gesture-drag.test.ts#L196 could use the default matcher over the existing two "Drag source" fixture so the real resolver produces the ambiguity; readDeviceList in packages/kernel/src/errors.ts#L219 should keep booted only when it is a boolean, since "false" as a string would render as booted=true; and commands.md#L107 could mention that device candidates show booted and that drag refusals now issue pinned candidates. Not verified here: tests were not run locally, a live device was not used to confirm that a real ambiguous drag reaches the pinned-candidate branch rather than the count-only one, and external consumers that parse details.devices strictly were not checked (the booted field is additive). |
The merge preview joins this branch with main, where dd7d81c (callstack#4853) grew device.ts by ten lines, so the branch's own zero-growth accounting does not hold on the tree CI actually checks: 994 head lines plus those ten crossed the 1000 limit and failed oxlint there. Compress the helper's one-line docblock, put its signature back on one line, and pass an empty value for a serial-less selector (an empty string matches no id, so that miss stays hint-free): 987 lines at head, 997 on the merge preview. Co-Authored-By: Claude Code <noreply@anthropic.com>
… in selector errors (#4861) * fix(kernel): name the other identity flag and the closest device name in selector errors A `--udid` that resolves nothing while the same value identifies an observed Android/HarmonyOS/Vega device answered "No Apple device with UDID emulator-5580" with no hint when the request carried no explicit --platform (the explicit case was already rejected by assertSelectorFlagMatchesPlatform). The failure now reads the flag the value belongs to through deviceIdentityFlag — no third inline pairing — and says "Did you mean --serial <value>?"; --serial answers the reverse the same way. Only an observed identity earns the hint, and a platform with no identity flag (web, linux) earns none, matching the #2065 precedent for --device. A --device name that survives the matcher but sits one punctuation character away from exactly one candidate (curly quotes on renamed simulators) is now answered with that candidate's name; more than one candidate under the quote fold earns no hint. The id-mistaken-for-name answer still wins when it applies. device.ts carried this work past the 1000-line lint cap, so the host-scoped id grammar (app devices, web sessions) moved verbatim into device-identity.ts, which every closure through device.ts already evaluates; @agent-device/kernel /device re-exports keep every import path stable. The moved web-session refusal now reads its wire reason from a declared table. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(kernel): point the id-grammar test imports at the owning module The barrel re-export of hostAppDeviceId and hostDeviceIdPrefix had no production consumer after the move, so the production-unused-exports gate refused it; both are used only by tests. The barrel keeps the symbols with production call sites, the tests import the two from @agent-device/kernel/device-identity (new exports-map entry), and the gate passes again. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(kernel): rebuild the ambiguous-close fixture and drop the unreachable spacing claim The two-candidate quote-fold case requested a quote-less name, which folds onto neither quoted candidate, so the close list stayed empty and the no-hint assertion passed without exercising the branch. The request now keeps its straight quotes while the two candidates spell theirs with U+2018 and U+2019, so both land under the fold and the answer names neither; flipping the single-candidate guard to >= 1 fails exactly this test. The closest-name hint said "punctuation or spacing", but the shared name matcher already folds whitespace, so a spacing-only difference resolves before any hint and the spacing claim was unreachable copy. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(kernel): keep the selector hints in device.ts and serve all three not-found sites with one helper The review asked for the smallest structural footprint: the ./device-identity package export made device-identity.ts a package entry whose eager closure grew from one module to three (errors.ts via the moved web-session refusal, plus redaction.ts), which the eager-closure budget gate refuses on no-growth, and the export had no production consumer. This drops the move and the export entirely: the host-scoped id grammar returns to device.ts, device-identity.ts returns to its merge-base content, and the three test files that had been pointed at the new entry go back to @agent-device/kernel/device. The two hints this branch added and the pre-existing mistaken-name answer now collapse into one helper: deviceNotFoundHint(candidates, value, flag?) reads the flag the request used, answers with the flag an observed device carries the value under, and for --device names the single candidate one quote fold away (quoteFoldDeviceName). device.ts absorbs the consolidation with no net line growth (989 at base, 989 here) against the 1000-line oxlint cap, so no module move and no new entry are needed. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(kernel): leave the merged device.ts under the 1000-line cap The merge preview joins this branch with main, where dd7d81c (#4853) grew device.ts by ten lines, so the branch's own zero-growth accounting does not hold on the tree CI actually checks: 994 head lines plus those ten crossed the 1000 limit and failed oxlint there. Compress the helper's one-line docblock, put its signature back on one line, and pass an empty value for a serial-less selector (an empty string matches no id, so that miss stays hint-free): 987 lines at head, 997 on the merge preview. Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: Claude Code <noreply@anthropic.com>
…ts replacement refs After `fill @e3 … --settle; press @e4` with @E4 taken from the earlier full snapshot, the plain-ref refusal offered nothing: the agent could not tell that a settled diff replaced the frame and paid a full `snapshot -i` every time (callstack#4571, the most common agent-blocking error in the dogfood data). The frame value now records which publication minted it. `RefFrameOrigin` (`complete` | `settle-diff` | `partial`) is set at issuance through the same factories; every partial publication flows through one choke point (`markSessionPartialRefsIssued`), and only the settle path (`issueSettleRefs`) passes `settle-diff`, so find, audit, replay divergence, and ambiguity issuances keep their refusal shape unchanged. Origin is diagnostic only: no admission decision and no ref lifetime changes — whether refs a diff left unchanged stay valid stays open for maintainers on callstack#4571. When the refusing frame is settle-diff and the refused plain ref is not one of its issued refs, the refusal: - names the settled diff as the replacement in the message (and says when the diff issued no refs), - carries `details.replacedBy: "settle-diff"` and `details.replacementRefs`, each issued ref pinned to the frame epoch in the ready-to-copy `@eN~s<epoch>` form (callstack#4853 paste-ready standard; the frame already authorized exactly these bodies, so printing them issues nothing new), - offers the same refs in the hint with the fresh-snapshot escape. The exact-emitted-ref suggestion keeps precedence when the refused body is itself in scope. ADR 0014 amended (dated subsection beside the refusal contract it extends). Co-Authored-By: Claude Code <noreply@anthropic.com>
…ts replacement refs (#5037) After `fill @e3 … --settle; press @e4` with @E4 taken from the earlier full snapshot, the plain-ref refusal offered nothing: the agent could not tell that a settled diff replaced the frame and paid a full `snapshot -i` every time (#4571, the most common agent-blocking error in the dogfood data). The frame value now records which publication minted it. `RefFrameOrigin` (`complete` | `settle-diff` | `partial`) is set at issuance through the same factories; every partial publication flows through one choke point (`markSessionPartialRefsIssued`), and only the settle path (`issueSettleRefs`) passes `settle-diff`, so find, audit, replay divergence, and ambiguity issuances keep their refusal shape unchanged. Origin is diagnostic only: no admission decision and no ref lifetime changes — whether refs a diff left unchanged stay valid stays open for maintainers on #4571. When the refusing frame is settle-diff and the refused plain ref is not one of its issued refs, the refusal: - names the settled diff as the replacement in the message (and says when the diff issued no refs), - carries `details.replacedBy: "settle-diff"` and `details.replacementRefs`, each issued ref pinned to the frame epoch in the ready-to-copy `@eN~s<epoch>` form (#4853 paste-ready standard; the frame already authorized exactly these bodies, so printing them issues nothing new), - offers the same refs in the hint with the fresh-snapshot escape. The exact-emitted-ref suggestion keeps precedence when the refused body is itself in scope. ADR 0014 amended (dated subsection beside the refusal contract it extends). Co-authored-by: Claude Code <noreply@anthropic.com>
Summary
Two same-domain fixes for
AMBIGUOUS_MATCHrecoverability, continuing #1597/#1602 (element candidates), #4506 (tied device id+name), and #2870's printing-implies-issuing rule. Scope declared on #4571 before opening: it takes that issue's ref-error half, not the swipe/gesture--settlegap.Before / after
An ambiguous drag on a session whose frame predates the drag's own capture:
Candidates: @e2 [view] "Drag source"with norefsGeneration; pasting@e2(or the earlier snapshot's@e2~s42) is refused (plain_ref_requires_complete_frame/ref_generation_mismatch).refsGenerationand the frame scope holds exactly the printed bodies; the pasted@e2~s<refsGeneration>taps the listed node.An ambiguous device request with a booted emulator and a shut-down simulator tied:
Devices:listsemulator-5554 Pixel/Pixel_9_Pro_XL Pixel 9 Pro XLwith no state.emulator-5554 Pixel booted=true/Pixel_9_Pro_XL Pixel 9 Pro XL booted=false.Changes
interaction-gesture.ts: the drag/swipe dispatch carries the consumed-capture slot and routes failures throughpublishAmbiguousMatchCandidateRefs.command-output/src/output/error.ts: the candidate-line pin helper re-pins born-stamped lines to the view's generation, so every printed line carries the epoch the caller will face (bare lines, the epoch additive once asrefsGeneration, stay the wire shape; the helper stays private to this module — the eager-closure budget forbids an edge from this entry into the capture-kit renderer).device.ts/device-selection-resolver.ts: onedeviceCandidateSummarybuilder feeds both device refusal sites, addingbootedto each entry;kernel/errorscarries the field through the device candidate view, and the CLIDevices:block rendersbooted=true|false.Validation
refsGenerationdirects, is admitted on the issued frame and taps the listed node.scripts/__tests__/eager-closure-budgets.test.ts, command-output entries) passes at dc30a9d.check:affectedat the pinned base: format, lint, and typecheck pass. The local layering stage fails on pre-existing baseline drift (untyped-reason/promise-race findings across files this PR does not touch;session-snapshot.tsis unchanged from the base and its finding is the pre-existingref_not_issuedliteral; the staged diff adds no reason literal). CI owns the full gate run.🤖 Generated with Claude Code