Skip to content

fix(brain-orb): latch wheel routing per gesture and floor the inspector below the state card (#2538, #2539) - #2546

Merged
vybe merged 5 commits into
devfrom
vybe/issue-2538
Sep 7, 2026
Merged

vybe merged 5 commits into
devfrom
vybe/issue-2538

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Summary

Trackpad momentum that arrived after a Brain Orb panel had reached its scroll edge fell through to camera zoom, because the single wheel listener in public/brain-orb/orb.js decided panel-vs-zoom per event with no gesture memory. Now the first vertical event of a gesture (a run of wheel events with inter-event gaps ≤ 150 ms) picks the route from a computed-style walk over the scroll containers under the pointer, and every later event of that gesture keeps it — the inertia tail is swallowed at the edge, never zoomed, while a fresh gesture over an already-edged panel still zooms (deliberate edge-chaining preserved). The hardcoded panel allowlist is gone, so #scopePanel (a real overflow-y:auto scroller it never listed) scrolls under the wheel at last.

Separately, the node inspector (#inspector, centred at top:50%) rose into the state card (#stateBox, 26–200 px) and painted over "STATE / Idle". It is now floored at 224 px below the state card and height-capped so its bottom edge stays 26 px inside the viewport — CSS only, two values on one rule; a dragged or restored inspector keeps its user-chosen spot.

Both fixes live entirely in the vanilla first-party orb assets under src/frontend/public/brain-orb/ — no Vue, no backend, no schema, no MCP surface. index.html now loads orb.js and styles.css with a shared ?v=2026-09-06 token because prod nginx serves them 1y-immutable.

Closes

Fixes #2538
Fixes #2539

What changed

  • 5d695919 fix(brain-orb): latch wheel routing per gesture so momentum never zooms — serves Brain Orb: trackpad momentum after a panel hits its scroll edge leaks into camera zoom #2538. orb.js: WHEEL_GAP_MS = 150, wheelAt/wheelMode gesture state, panelCanScroll(node, dy) walks ancestors up to (excluding) <body>/<html> and reads overflowY from computed style (size check first, so the void costs zero style queries); the ctrlKey pinch branch and the Safari gesture* listeners are byte-identical; deltaY === 0 events refresh the clock but never start a latch. index.html: orb.js?v=2026-09-06 + the "bump BOTH" comment. New e2e/brain-orb-wheel-latch.spec.js (A1–A9, @smoke) + e2e/helpers/brain-orb.js (standalone /brain-orb/index.html FALLBACK graph — no agent, no auth; test.skip only when Chromium has no WebGL at all, hard fail when WebGL is present but the orb never boots).
  • 5d5fb715 fix(brain-orb): floor the inspector below the state card — serves Brain Orb: node inspector overlaps the state card — both right-anchored at the same z-index #2539. styles.css #inspector: transform:translateY(max(-50%, calc(224px - 50vh))) and max-height:min(82vh, calc(100vh - 224px - 26px)); nothing else on the rule changes, no fallback pairs (the sheet already relies on min() unguarded). index.html: styles.css?v=2026-09-06. New e2e/brain-orb-inspector-layout.spec.js (B1 at five viewports incl. the real 1280×756 iframe height and the ≤760 px media query, B2 short-inspector centring, B3 drag survives reload); helper gains a paragraphText option.
  • 33f57765 docs(brain-orb): state the ?v= cache-bust convention in the feature flow — both issues. One "Known limitations" bullet in docs/memory/feature-flows/brain-orb.md rewritten (the old text said the orb was frozen verbatim), plus the two specs and helper added to the file map.
  • 50e07bf1 docs(brain-orb): name the symmetric latch at the zoom branch — Brain Orb: trackpad momentum after a panel hits its scroll edge leaks into camera zoom #2538, review follow-up, comment only. The zoom branch now says the latch is symmetric by design and that spec A4 pins it, so nobody re-decides per event at that line.
  • 0002c61d docs(brain-orb): the ?v= bullet — first orb edits since v0.8.0, not since vendoring — both issues, review follow-up. Corrects a false "first edits since vendored" claim in the flow doc (Phases 2–4 edited orb.js in-repo before the v0.8.0 release merge).

Proof

Red at HEAD (a5ac3cf3, specs written first):

  • B1 ×5 viewports: inspector.top 72 vs stateBox.bottom 199.86 … Expected ≥ 215.86, Received 72 (81 / 97 / 68 / 81 at the other four)
  • A2+A3: Expected 330, Received 473.9 (camTargetDist across a 25-event tail)
  • A4: [true,false]
  • A5: #scopePanel wheel zoomed, defaultPrevented: true

Green after:

  • e2e/brain-orb-wheel-latch.spec.js + e2e/brain-orb-inspector-layout.spec.js: 16 passed, zero WebGL skips — re-run after the rebase onto origin/dev on a worktree Vite serving the branch's ?v=2026-09-06 assets: 16 passed (8.7s)
  • npm run test:e2e:smoke: 68 passed, 9 skipped, 0 failed (skips = the documented fixture-absent set)
  • vitest 84 / 1835 unchanged; raw-colour scan has 0 public/ entries (the ratchets only walk src/frontend/src/)
  • /verify-local PASS: unit 13899 passed, 32 skipped; integration 70 passed, 13 skipped, 2 deselected; build + import-smoke OK; boot + health OK; venv Python 3.13.5
  • /cso --diff PASS

Probe deltas (headless Chromium, window.orbState() seam):

  • inspector/state-card overlap at 1280×800 / 1440×900 / 1920×1080 / 1280×756 / 720×900: 128 / 119 / 103 / 132 / 119 px → 0 / 0 / 0 / 0 / 0
  • same-gesture tail after the panel edged: camTargetDist 330 → 363.6 before, 330 → 330 after; a fresh gesture (gap > 150 ms) over the edged panel still zooms

Mutation reds (the specs bite):

  • per-event routing restored in orb.js → spec A 2 failed / 7 passed
  • translateY(-50%) restored in styles.css → spec B 5 failed / 3 passed
  • per-commit green: 5d695919 alone → spec A 9 passed

Review: two comment-only follow-ups (50e07bf1, 0002c61d), no behaviour change; spec A re-run green after each.

Decisions for the reviewer

  1. T2 — form of the inspector floor. Shipped as transform:translateY(max(-50%, calc(224px - 50vh))), which keeps the original centring only while the inspector is ≤ 100vh − 448px tall. With ~340 px of fixed chrome that never happens on a 1280×800 iframe (centring band 308 px) and almost never at 1440×900 (452 px), so in practice it is a top:224px pin. The alternative is plain top:224px; transform:none — simpler CSS, stable title position. Taste, not correctness; both pass B1. Say the word and I swap it.
  2. Two honesty caveats, verbatim from the code comments. (a) Chromium coalesces wheel events queued behind a stalled frame into one, so a main-thread stall > 150 ms yields ONE bounded re-decided step, not immunity — the same step the per-event code took for that event. (b) The defaultPrevented assertion in spec A is scoped to synthetic events: once the first wheel of a native sequence goes uncancelled (which a panel gesture's does), Chrome dispatches the rest non-cancelable, so on trusted Chrome tails the edge preventDefault() is a no-op and Chrome's own scroll latching keeps the sequence on the origin scroller. camTargetDist is the primary observable either way.
  3. WHEEL_GAP_MS (150) is a tunable, not a test-pinned value. Only "a gap ≤ 300 ms is still the same gesture" is asserted (the specs use 300 ms for "> 150 ms"). 150 is the issue's upper bound, chosen for jank tolerance (≥ 9 frames at 60 Hz) while staying under a human lift-and-re-flick; there is no canonical value (Firefox's native transaction uses 1500 ms). Known consequences: a mouse user clicking the wheel faster than ~6.7 Hz at a panel edge waits for a ≤ 150 ms pause before edge-chaining zooms; fingers resting > 150 ms at the edge and then pushing on is a new gesture and zooms (same as before).
  4. Fix B's cost, stated so nobody raises the cap later: a full-height inspector is now capped at 100vh − 250px — on the real iframe (window minus browser chrome minus the 44 px header) that is ≈ 549 → 420 px at a 1280×800 window and ≈ 628 → 516 px at 1440×900. That is the price of not overlapping a 200 px card in a ~700 px viewport.
  5. Spec B1's elementFromPoint hit-test is tiered at 720×900 because #dock (755 px wide with 11 chips, top-centred) already covers the state value row at that width at HEAD, independent of the inspector — B1 still asserts the no-overlap geometry there; only the value-visible hit-test is relaxed, with the reason in the spec.

Not in this PR / follow-ups (not filed)

  1. type-bug — Brain Orb right-gutter collisions not covered by Brain Orb: node inspector overlaps the state card — both right-anchored at the same z-index #2539: a full-height #inspector covers the #controls legend (bottom-right; the inspector deterministically paints on top, later in DOM at equal z-index:10); #scopePanel (top:150px) overlaps #stateBox when shown (S) and shares the gutter with the inspector; plus the top-centred #dock covers #stateBox's value row at ≤ 760 px, and its chip-count-driven width brings it near the card at 1280. Needs a layout decision (collapse/move the legend while the inspector is open; give the scope panel its own floor; bound the dock), not a one-line fix.
  2. type-bug (P3) — orb.js never reads e.deltaX; horizontal <pre> scrollers (styles.css overflow-x:auto on code blocks) are unreachable by wheel. Deferred by Brain Orb: trackpad momentum after a panel hits its scroll edge leaks into camera zoom #2538 itself.
  3. type-docs — Architecture Map: src/frontend/public/brain-orb/** has no owning area file (frontend.md owns src/frontend/src/** only, so the PreToolUse hook is silent there); add it to integrations.md's Owns line + the core map row. Plus refresh the "verbatim" wording at docs/memory/architecture/integrations.md:123 and docs/memory/requirements/core-agent.md:1488 — after this PR the orb assets are first-party-maintained, not a verbatim vendored copy.
  4. type-bug (P3, paired small PR — can land before or after this one) — prod nginx: /brain-orb/index.html (and voice/orb.html) fall under location / with no Cache-Control, so a deploy's new ?v= tokens reach returning users only after heuristic freshness expires (hours–days; a hard reload is immediate). Add a location ~* \.html$ no-store twin of the = /index.html block (or scope immutable to Vite's hashed /assets/ only); verify with the prod image (/verify-local builds it).
  5. Follow-up-grade note, no issue unless asked — when the state tile is closed (TILES, orb.js), the floor still reserves 224 px of empty gutter; body:has(#stateBox.tile-hidden) #inspector{transform:translateY(-50%);max-height:82vh} would restore the previous geometry for that case.
  6. Test-runner catalog rows for the two new specs (the .claude submodule is out of scope for this run).

CI note

frontend-e2e.yml triggers on any src/frontend/ change, so it will run here. It must report the two orb specs PASSED, not SKIPPED — the helper skips (by design) only when the runner's Chromium exposes no WebGL context at all (SwiftShader absent), and neither the workflow nor playwright.config.js passes a GPU flag. Which of the two it is will be stated here once the first run lands; a SKIPPED verdict means the CI proof of these two fixes is the local run above, not the workflow.

🤖 Generated with Claude Code

vybe and others added 5 commits September 6, 2026 18:31
…ms (#2538)

The single window-level `wheel` listener in public/brain-orb/orb.js decided
zoom-vs-scroll PER EVENT via panelCanScroll(), with no gesture memory. On a
macOS trackpad one flick keeps emitting `wheel` at frame cadence long after
the fingers lift, so the inertia tail that arrived after a panel reached its
edge was routed to camTargetDist and the camera zoomed out.

- Gesture latch: a run of wheel events with inter-event gaps <= 150 ms
  (WHEEL_GAP_MS — the top of the issue's 120-150 ms range) is one gesture.
  Its first vertical event decides the route from the scroll container under
  the pointer; every later event keeps it. Panel-latched events that can
  scroll nothing are swallowed (preventDefault), never zoomed. A fresh
  gesture (gap > 150 ms) over an already-edged panel still zooms, so the
  deliberate "scroll to the end, then keep going to zoom out" chaining is
  preserved.
- Clock is e.timeStamp (input time) with a performance.now() fallback.
  Chromium coalesces events queued behind a stalled frame into one, so a
  stall > 150 ms still ends the gesture — bounded to one re-decided step.
- deltaY === 0 (pure-horizontal) events never start a latch; they refresh
  the clock and otherwise behave exactly as before. deltaX handling stays
  deferred, as the issue itself defers it.
- Allowlist gone: panelCanScroll() walks the target's ancestors up to <body>
  and asks computed style, so the CSS is the single source of truth.
  #scopePanel (overflow-y:auto all along) scrolls under the wheel at last.
- The ctrlKey pinch branch and the Safari gesture* listeners are untouched.
- index.html: orb.js is un-hashed under prod nginx's 1y-immutable cache, so
  the <script> tag now carries ?v=2026-09-06 (comment says: bump BOTH).

Proof: e2e/brain-orb-wheel-latch.spec.js (@smoke; standalone
/brain-orb/index.html FALLBACK graph — no agent, no auth; skips without
WebGL, fails loudly on a boot error). Red before the fix at A2+A3
(camTargetDist 330 -> 473.9 across a 25-event tail), A4 ([true,false]) and
A5 (#scopePanel wheel zoomed, defaultPrevented true); 9 passed after. A1
scrolls #inspContent into the inspector's visible box and asserts the aim
point before firing its one trusted wheel, so a mis-aim can never read as
a routing failure.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
#stateBox (top:26px, 174px tall) and #inspector (top:50%; translateY(-50%);
max-height:82vh) are both right-anchored .panels at z-index 10 with nothing
reserving vertical space, so a tall inspector rose into the state card and,
being later in DOM order, painted over "STATE / Idle" — measured overlap
128 / 119 / 103 px at 1280×800 / 1440×900 / 1920×1080 (132 px on the real
1280×756 iframe viewport).

CSS only — exactly two values on #inspector change:
- transform: translateY(max(-50%, calc(224px - 50vh))) keeps the centring
  while the box is short and floors its TOP edge at 224px (26 + 174 card +
  24 gap) once it is tall — continuous, no jump. The 174px premise holds
  for every STATES desc and the boot-time "reflecting last run" string
  (<=3 lines at 26ch); spec B1 asserts it rather than trusting it.
- max-height: min(82vh, calc(100vh - 224px - 26px)) keeps the BOTTOM edge
  26px inside the viewport.
No fallback pairs: the sheet already relies on min() unguarded. No JS:
makeDraggable/restorePanels set inline right:auto + transform:none, so a
dragged or restored inspector keeps its user-chosen spot (spec B3).

Cost, stated so nobody raises the cap later: on the real iframe a
full-height inspector shrinks from 82vh to 100vh-250px (~549 -> 420 px at a
1280×800 window). Out of scope, follow-ups: the #controls legend under a
full-height inspector, #scopePanel's own gutter collision, and — surfaced
by spec B1 — the top-centred #dock covering the state value at <=760px.

index.html: styles.css now carries the shared ?v=2026-09-06 token (the
orb.js tag got it in the previous commit; bump BOTH on every edit).

Proof: e2e/brain-orb-inspector-layout.spec.js (@smoke; standalone FALLBACK
page, no agent/auth). Red against the previous styles.css at all five
viewports — "inspector.top 72|81|97|68|81 vs stateBox.bottom 199.86,
Expected >= 215.86" — 8 passed after. The shared helper gains a
`paragraphText` option so B2's short note sits inside the centring band
(h <= 100vh - 448) instead of on its edge.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…low (#2538, #2539)

The "Known limitations" bullet said the orb was frozen (verbatim) and that a
future orb update "needs a cache-bust" — both false once #2538/#2539 edit
orb.js and styles.css and index.html carries the shared ?v=2026-09-06
token. Rewrite that one bullet to state the convention (bump BOTH tokens on
every edit) and its residual (/brain-orb/index.html itself is heuristically
cached by prod nginx — the \.html$ no-store rule is a paired follow-up),
and list the two Playwright HUD specs + helper in the file map. Nothing
else in the flow changes.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…y re-decides per event (#2538)

The block comment above panelCanScroll() states the gesture rule ("every
later event of the gesture keeps that route"), but the line a future reader
would actually edit — the zoom branch that runs while `can` is true for a
zoom-latched gesture — only said "zoom-latched". That is exactly where an
`if(wheelMode==='zoom' && can) return;` "improvement" would land and quietly
turn a zoom flick into an inspector scroll (the reported bug's mirror
image). Say it at that line: the latch is symmetric by design, the first
event decides, and spec A4 pins it. Comment only — no behaviour change;
spec A re-run green (9 passed).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ince vendoring (#2538, #2539)

"the first edits to the orb since it was vendored" is false: `git log --all
-- src/frontend/public/brain-orb/orb.js` shows the Phase 2–4 PRs (#1395,
#1407, #1494 and their hardening follow-ups) editing orb.js in-repo after
#1389 vendored it. What IS true, and what the cache-bust convention hinges
on, is that #2538/#2539 are the first orb edits to reach `dev` since the
v0.8.0 release merge (the only commit touching these files on origin/dev).
Say that instead.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@trinity-ability
trinity-ability marked this pull request as ready for review September 6, 2026 17:35

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr: Fixes #2538 + #2539 (both type-bug, status-in-progress), targets dev, 7 files, orb assets + e2e specs + brain-orb feature-flow update only. Security greps clean, no backend/schema/MCP surface. Gesture-latch logic and inspector floor CSS reviewed; the ?v= cache-bust is applied to both assets and documented. Regression specs name both issues with mutation controls. CI fully green, mergeable against current dev.

@vybe
vybe merged commit 1fd289c into dev Sep 7, 2026
26 checks passed
@vybe
vybe deleted the vybe/issue-2538 branch September 7, 2026 08:27
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.

2 participants