LearnNewsExamplesServices
Frontmatter
id18723
titleThe grid View focus arm reads the pointer stamp before it is set
stateClosed
labels
bugaitestinggrid
assigneesneo-opus-grace
createdAtSep 15, 2026, 9:24 AM
updatedAtSep 15, 2026, 11:45 AM
githubUrlhttps://github.com/neomjs/neo/issues/18723
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 15, 2026, 11:45 AM

The grid View focus arm reads the pointer stamp before it is set

neo-opus-grace
neo-opus-grace commented on Sep 15, 2026, 9:24 AM

Context

grid/GridViewFocus.spec.mjs is red in every #17844 battery census — 32 reds at 3044d7f86b, 21 at 03219a75b7, this arm in both. The 2026-09-15 census diagnosed it: the spec is wrong, not the engine. It reads the pointer-modality stamp one worker round trip too early, and has done so since #18066 changed which event first focuses the View.

No visible defect is behind it. The grid focuses correctly, paints no accidental ring, and clears the class on blur; only the spec's read order is stale.

Live latest-open sweep: checked the latest 20 open issues at 2026-09-15T07:30Z; no equivalent found. A2A in-flight sweep (30 messages, all read-states): no overlapping claim. Own-assignment sweep: #17844 is the parent census ticket and stays open; no leaf owns this arm.

The Problem

The AC-1/AC-2 arm polls until the View owns focus, then reads the modality state synchronously in the next call:

await expect.poll(async () => (await readFocus()).active, {...}).toBe(viewId);

const f = await readFocus();
expect(f.pointer, 'pointer focus stamps neo-focus-pointer atomically').toBe(true);

src/main/DomAccess.mjs:379 adds neo-focus-pointer immediately before node.focus(), so for a programmatic focus the class and the focus do arrive together — which is what the arm was written against. #18066 ("a grid click keeps its mousedown default so focus reaches the View", PR #18065) stopped suppressing the click's default, so the browser now focuses the View natively on mousedown — one App-Worker round trip before the DomAccess.focus message that carries the stamp.

The poll therefore exits on the native focus, and the immediately following read lands inside the gap: activeElement is already the View, neo-focus-pointer is not there yet. The arm fails on a system behaving exactly as designed.

The ring assertion is unaffected in the gap — the native focus paints no ring here either — so the contract worth asserting is both sides of the gap, not one read at an arbitrary point in it.

The Architectural Reality

  • test/playwright/e2e/grid/GridViewFocus.spec.mjs — the AC-1/AC-2 arm, plus a @summary line still describing the pre-#18066 single-source focus as "the atomic pointer stamp".
  • src/main/DomAccess.mjs:379-396 — the modality contract: stamp before focus(), replace with neo-focus-keyboard on the first keydown, remove on blur. Unchanged by this ticket.
  • src/grid/View.mjs — the single focus anchor for the multi-body grid (tabIndex: -1). Unchanged by this ticket.
  • The arm is Neural-Link-gated, so it only executes with NEO_AGENTOS_RUNTIME_ROOT wired (#18246).

The Fix

In GridViewFocus.spec.mjs, replace the single post-focus read with the two-sided assertion the contract actually makes:

  1. Assert no ring as soon as the View holds focus — that is true throughout the gap and is the property a user would see break.
  2. expect.poll for neo-focus-pointer, instead of requiring it in the same read as the focus.
  3. Assert no ring again once the stamp has landed.

Correct the @summary and the arm comment so they describe the two-source focus path rather than the retired single-message one.

Engine behaviour is untouched; this is a test-only correction.

Acceptance Criteria

  • grid/GridViewFocus passes with the Brain runtime wired (NEO_AGENTOS_RUNTIME_ROOT=<brain checkout> npm run test-e2e -- grid/GridViewFocus --workers=1).
  • The arm still fails when the stamp is removed — verified against a mutant that never adds neo-focus-pointer, so the poll cannot pass vacuously.
  • No file under src/ changes.
  • #17844's failure table records this arm as fixed at the next census.

Out of Scope

  • The other 20 reds in the #17844 census — each is dispositioned there.
  • Any change to the DomAccess modality contract or to grid.View's focus ownership.
  • Making the native and programmatic focus paths converge on one message: the gap is legitimate, and closing it would be an engine change with no observed user-facing symptom.

Avoided Traps

  • Do not "fix" this by asserting the stamp before focus. The order is browser-owned; the only stable contract is the eventual state plus the ring's absence throughout.
  • Do not weaken the arm to a bare poll. A poll alone passes vacuously if the stamp is never removed from a previously-focused node — the ring assertions on both sides of the gap are what keep it discriminating.
  • Run the whole spec file, never a single --grep'd arm — #17844 trap 3.

Decision Record impact

none.

Related

#17844 (the census that found and diagnosed it) · #18066 / PR #18065 (the mousedown-default change that opened the gap) · #15195 (the focus-ownership contract the arm witnesses) · #18246 (the Neural-Link gating that decides whether it runs at all)

Origin Session ID: 148d12cc-9777-46e4-bfb9-a422479153a5

Retrieval Hint: query_raw_memories("GridViewFocus neo-focus-pointer stamp lands after native mousedown focus")

tobiu referenced in commit d0bb579 - "test(e2e): the grid View focus arm waits for the pointer stamp that native focus now precedes (#18723) (#18724) on Sep 15, 2026, 11:45 AM
tobiu closed this issue on Sep 15, 2026, 11:45 AM