Skip to content

feat(#123): make the token inspector a click-only dialog - #129

Merged
Enniwhere merged 5 commits into
mainfrom
123-inspector-shell
Nov 28, 2026
Merged

Enniwhere merged 5 commits into
mainfrom
123-inspector-shell

Conversation

@Enniwhere

Copy link
Copy Markdown
Contributor

What grew

Hovering no longer inspects: it only outlines a token, cool blue where a click will open the inspector and light red where there is nothing to inspect, with a darker solid outline on the pinned token. Click, Enter or Space opens TokenDialog, a named, non-modal dialog; Escape, its × and a pointer-down outside close it, while jumping, flipping and wheeling leave it alone. The dialog caps itself to the viewport at 360 px, flips above a token in the bottom row, and opens with a 100 ms keyframe that switches off under reduced motion. Both e2e pin helpers now find it by role="dialog".

How to try

  1. npm run dev, open http://localhost:5173.
  2. Hover a prose token: a blue outline appears and nothing opens. Hover a gap or a frozen token: the outline is red.
  3. Click a token, or focus it and press Enter: the inspector opens. Close it with Escape, ×, an outside click, or by clicking another token.
  4. Narrow the window to ~360 px and click a token near the bottom; the dialog flips above it and stays inside all four edges.

Read first

src/lib/components/TokenDialog.svelte for the dialog contract and the clamp, then the inspectable guard and outside-pointerdown exemption list in src/routes/+page.svelte.

Noticed: slice 2 measured 310 changed lines against the plan's ~150 estimate, mostly because the outline rules, the outside-pointerdown exemption list and the dialog chrome each rewrote in place; slices 1 and 3 landed at 121 and 56 against ~140 and ~60.

Closes #123

Next: /review <pr>; after merge, /retrospective 123.

Rename `TokenTooltip.svelte` to `TokenDialog.svelte`, its class to
`.token-dialog`, and the page state `HoverState`/`hover`/`hoverQueryId`
to `InspectorState`/`inspector`/`queryId`. The two query locals become
`query` so the counter keeps its new name without shadowing.
No behaviour change; verified with check, lint, prettier and 680 tests.

Plan: 1
Slice: 1/3
Kind: mechanical
Hover and keyboard focus only outline a token now: cool blue when a click
can open the inspector, light red when the position does nothing, and the
darker solid outline marks the open position. TokenChips and InlineTokens
lose their hover props and the chip's native title. A click, Enter or Space
opens a non-modal role="dialog" named "Token inspector"; Escape, the close
button and a pointer-down outside close it, with token targets and Diffuse
exempt, so opening another token replaces it in one gesture. Both e2e pin
helpers now target the dialog, and the Advanced/About copy follows the click
path. Verified with check, lint, prettier, 680 tests and all 10 e2e tests.

Plan: 1
Slice: 2/3
Kind: behavioral
The clamp now learns the vertical flip: a token with less than 160 px of
room below anchors the dialog by `bottom`, capping its height to the room
above. `box-sizing: border-box` plus a width capped at `vw - 16` and
`left >= 8` keeps all four edges inside at 360 px. Opening is a 100 ms
keyframe, switched off under `prefers-reduced-motion: reduce`. The docs
that still said "hover inspector" now say click.

Verified with check, lint, prettier and 680 tests; a 360x480 Playwright run
opened a bottom-row token above it inside all four edges, and Escape, × and
an outside click each closed it with t-max unchanged.

Plan: 1
Slice: 3/3
Kind: behavioral
Park the plan's six Not doing lines, add the click-only inspector to the map,
add the session noticed line on the slice-2 churn, and bump to 1.21.0. The
issue carries no Compost field, so nothing is deleted.

Verified with check, lint, prettier and 680 tests; 15 changed lines. E2E passed
10/10 in slice 2, and a 360x480 Playwright check confirmed AC1 and AC4 in
slice 3.

Plan: 1
Slice: 3/3
Kind: mechanical
@Enniwhere

Copy link
Copy Markdown
Contributor Author

Reviewed commit: 29ff4cc

Verdict: approve

Blockers

  • None.

Stewardship notes

  • The doc sweep missed the behaviour description: AGENT_CONTEXT.md:8-10 still says a visitor inspects a token's neighbourhood "on hover", which the plan said would be corrected here.
  • A11y read, as the issue asked for: not moving focus on a pointer click is right, but Enter/Space also leaves focus on the token, and the dialog renders after the whole token list (src/routes/+page.svelte:759-777), so its ×, Flip and neighbour controls sit one Tab per remaining token away and the non-modal dialog may not be announced (src/lib/components/InlineTokens.svelte:65-69). Move focus only when opened from the keyboard.
  • AC1 asks for a short recorded run with t-max before and after each close; the PR body gives the try steps but no readings, and the commits only assert "unchanged". A three-line transcript would close it.
  • Noticed (PR): slice 2 measured 310 changed lines against the plan's ~150 estimate, while slices 1 and 3 landed at 121 and 56. Under the 400 cap, so a note; the soil commit also repeats Slice: 3/3, so two commits claim the last slice.

What could be deleted or simplified

  • Delete the impossible if (!target) return; guard in handleOutsidePointerDown (src/routes/+page.svelte:499-500): a pointerdown always has an Element target.
  • One data-inspect-target attribute on both token views would replace the .chip, [data-testid="prose-token"] pair (src/routes/+page.svelte:501-503) and stop the page depending on a component class and a test id.
  • Delete the stale "hover tooltip" and "mouse moved" comments (src/routes/+page.svelte:369, src/lib/stores/inspection.svelte.ts:2, src/lib/workers/trajectory.protocol.ts:23, src/lib/workers/trajectory.worker.ts:611, src/lib/strategies/neighbor-graph.ts:2, src/lib/engine/force-layout.ts:6) rather than re-wording all six.

Move focus into the dialog only on a keyboard open (Enter/Space), so a
pointer pin still leaves focus where it was. Token targets carry one
`data-inspect-target` attribute for the outside-pointerdown exemption,
the impossible null-target guard goes, and the stale "hover tooltip"
comments plus the AGENT_CONTEXT "on hover" line now say click/dialog.

AC1 now has a recorded e2e run: t-max 1 before and after Escape, × and
an outside click, plus the keyboard-open focus assertion. Verified with
check, lint, prettier, 680 tests and 11 e2e tests.

Plan: 1
Slice: review
Kind: behavioral
Fixes: review 1
@Enniwhere
Enniwhere merged commit 6fc767f into main Nov 28, 2026
3 checks passed
@Enniwhere
Enniwhere deleted the 123-inspector-shell branch November 28, 2026 21:25
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.

Inspector shell: hover outlines, pin opens a dialog

1 participant