Repository navigation
fix(brain-orb): latch wheel routing per gesture and floor the inspector below the state card (#2538, #2539) - #2546
Merged
Merged
Conversation
…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
marked this pull request as ready for review
September 6, 2026 17:35
vybe
approved these changes
Sep 7, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Trackpad momentum that arrived after a Brain Orb panel had reached its scroll edge fell through to camera zoom, because the single
wheellistener inpublic/brain-orb/orb.jsdecided 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 realoverflow-y:autoscroller it never listed) scrolls under the wheel at last.Separately, the node inspector (
#inspector, centred attop: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.htmlnow loadsorb.jsandstyles.csswith a shared?v=2026-09-06token because prod nginx serves them 1y-immutable.Closes
Fixes #2538
Fixes #2539
What changed
5d695919fix(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/wheelModegesture state,panelCanScroll(node, dy)walks ancestors up to (excluding)<body>/<html>and readsoverflowYfrom computed style (size check first, so the void costs zero style queries); thectrlKeypinch branch and the Safarigesture*listeners are byte-identical;deltaY === 0events refresh the clock but never start a latch.index.html:orb.js?v=2026-09-06+ the "bump BOTH" comment. Newe2e/brain-orb-wheel-latch.spec.js(A1–A9,@smoke) +e2e/helpers/brain-orb.js(standalone/brain-orb/index.htmlFALLBACK graph — no agent, no auth;test.skiponly when Chromium has no WebGL at all, hard fail when WebGL is present but the orb never boots).5d5fb715fix(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)))andmax-height:min(82vh, calc(100vh - 224px - 26px)); nothing else on the rule changes, no fallback pairs (the sheet already relies onmin()unguarded).index.html:styles.css?v=2026-09-06. Newe2e/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 aparagraphTextoption.33f57765docs(brain-orb): state the ?v= cache-bust convention in the feature flow — both issues. One "Known limitations" bullet indocs/memory/feature-flows/brain-orb.mdrewritten (the old text said the orb was frozen verbatim), plus the two specs and helper added to the file map.50e07bf1docs(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.0002c61ddocs(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 editedorb.jsin-repo before the v0.8.0 release merge).Proof
Red at HEAD (
a5ac3cf3, specs written first):inspector.top 72 vs stateBox.bottom 199.86 … Expected ≥ 215.86, Received 72(81 / 97 / 68 / 81 at the other four)Expected 330, Received 473.9(camTargetDistacross a 25-event tail)[true,false]#scopePanelwheel zoomed,defaultPrevented: trueGreen 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 ontoorigin/devon a worktree Vite serving the branch's?v=2026-09-06assets:16 passed (8.7s)npm run test:e2e:smoke: 68 passed, 9 skipped, 0 failed (skips = the documented fixture-absent set)84 / 1835unchanged; raw-colour scan has 0public/entries (the ratchets only walksrc/frontend/src/)/verify-localPASS: unit13899 passed, 32 skipped; integration70 passed, 13 skipped, 2 deselected; build + import-smoke OK; boot + health OK; venv Python 3.13.5/cso --diffPASSProbe deltas (headless Chromium,
window.orbState()seam):128 / 119 / 103 / 132 / 119 px → 0 / 0 / 0 / 0 / 0camTargetDist 330 → 363.6before,330 → 330after; a fresh gesture (gap > 150 ms) over the edged panel still zoomsMutation reds (the specs bite):
orb.js→ spec A2 failed / 7 passedtranslateY(-50%)restored instyles.css→ spec B5 failed / 3 passed5d695919alone → spec A9 passedReview: two comment-only follow-ups (
50e07bf1,0002c61d), no behaviour change; spec A re-run green after each.Decisions for the reviewer
transform:translateY(max(-50%, calc(224px - 50vh))), which keeps the original centring only while the inspector is ≤100vh − 448pxtall. 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 atop:224pxpin. The alternative is plaintop:224px; transform:none— simpler CSS, stable title position. Taste, not correctness; both pass B1. Say the word and I swap it.defaultPreventedassertion 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 edgepreventDefault()is a no-op and Chrome's own scroll latching keeps the sequence on the origin scroller.camTargetDistis the primary observable either way.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).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.elementFromPointhit-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)
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#inspectorcovers the#controlslegend (bottom-right; the inspector deterministically paints on top, later in DOM at equalz-index:10);#scopePanel(top:150px) overlaps#stateBoxwhen shown (S) and shares the gutter with the inspector; plus the top-centred#dockcovers#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.type-bug(P3) —orb.jsnever readse.deltaX; horizontal<pre>scrollers (styles.cssoverflow-x:autoon 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.type-docs— Architecture Map:src/frontend/public/brain-orb/**has no owning area file (frontend.mdownssrc/frontend/src/**only, so thePreToolUsehook is silent there); add it tointegrations.md's Owns line + the core map row. Plus refresh the "verbatim" wording atdocs/memory/architecture/integrations.md:123anddocs/memory/requirements/core-agent.md:1488— after this PR the orb assets are first-party-maintained, not a verbatim vendored copy.type-bug(P3, paired small PR — can land before or after this one) — prod nginx:/brain-orb/index.html(andvoice/orb.html) fall underlocation /with noCache-Control, so a deploy's new?v=tokens reach returning users only after heuristic freshness expires (hours–days; a hard reload is immediate). Add alocation ~* \.html$no-store twin of the= /index.htmlblock (or scopeimmutableto Vite's hashed/assets/only); verify with the prod image (/verify-localbuilds it).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..claudesubmodule is out of scope for this run).CI note
frontend-e2e.ymltriggers on anysrc/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 norplaywright.config.jspasses 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