Skip to content

test(notebook): trace escape before keymap dispatch - #135

Closed
BartvHelvert wants to merge 2 commits into
masterfrom
fix/notebook-escape-render
Closed

BartvHelvert wants to merge 2 commits into
masterfrom
fix/notebook-escape-render

Conversation

@BartvHelvert

@BartvHelvert BartvHelvert commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Diagnostics for #113. A new notebook markdown cell occasionally stays in edit mode after one Escape, with [# Top, one, mid, two] still visible. The assertion still requires that single Escape to render it; no key retry or notebook behavior change is added.

What the previous runs establish

The latest ten repeats at f95c92a0 had two notebook failures, both on Ubuntu. Both reported popup active=false, and cell/frame/input focus true before and after Escape. Neither IDE logged pressed ESCAPE in IdeKeyEventDispatcher's action trace. Earlier batches also reproduced on Windows.

That trace is downstream of queue processing and early consumers. Its absence does not establish that no event entered the JVM or reached the key dispatcher.

The tests set driver.robot.use.input.events=true: InputEventsRobot posts directly into IdeEventQueue. Moreover, hasInputFocus() injects a probe key and compares the queue's posted-key counter. It is not a passive OS-focus observation in this mode. These results do not establish an Xvfb/window-manager or pointer-routing problem. The input-focus probe and pointer diagnostics are removed; guarded passive cell/frame focus and popup reads remain.

The next trace

With -PtraceEscape=true, a test-only Java agent observes the pinned IDE using JDK instrumentation/class-file APIs:

  • Robot Escape calls and the created events immediately before posting.
  • JDK and IDE queue posting and dispatch entry/return.
  • Posting listeners, popup/custom dispatchers, and the key dispatcher: receiver class/identity and original return value.
  • Escape consumption, including its caller stack.

ESCAPE_TRACE lines include process/thread, event identity, event type/time, target component, current focus owner, and consumed state. Callbacks run once and their result/exception paths are preserved. The observer never posts, consumes, or redispatches an event. Hook installation is checked before the markdown cell is created, so a missing robot hook cannot look like an unposted Escape.

The agent and its small bootstrap-visible observer ship only as test tooling. No plugin code is changed.

Repeating the original sequence

The existing CI workflow has an opt-in notebook_escape dispatch input. It runs the whole SplitModeNotebookTest class ten times on each of Ubuntu and Windows, in fresh jobs. Each class keeps its existing scenario order and shared IDE sessions. It enables the agent, runs its observer checks, and retains IDE logs for successful runs too. Ordinary PR job names and sharding are preserved.

gh workflow run ci.yml --ref fix/notebook-escape-render -f notebook_escape=true

How it was tested

  • Agent checks cover actual bootstrap queue delivery, consuming/non-consuming callback results, ordinary-key behavior, and preservation of callback exceptions. Transformed robot/queue bytecode is also checked against the pinned IDE, including a plugin resource loader that hides JDK resources.
  • :ui-test:verifyEscapeTraceAgent passes, including checks against the pinned IDE and a plugin resource loader that hides JDK resources.
  • :ui-test:test --tests '*SplitModeNotebookTest' -PtraceEscape=true -PsearchableOptions=false passes locally: all 16 tests, including three strip-insertion rounds; all four hooks installed and no observer errors. Each markdown cell rendered after one Escape.
  • The single local freshTest run finished successfully: 1,512 passed, zero failures, two optional integration tests skipped. No further local runs were started after CI was requested.
  • actionlint passes for the workflow (ShellCheck unavailable locally).
  • Twenty-job CI batch: dispatched on 1b863518, ten complete notebook-class runs per OS. Results pending.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test. Diagnostics in the existing notebook UI test; agent behavior has dedicated checks.
  • No internal, override-only, obsolete or deprecated platform API is called by the diagnostics. Instrumentation observes pinned implementation bytecode through public JDK APIs; passive remote reads use public APIs.
  • docs/ is updated where behaviour changed, docs/status.md especially. No product behavior change.
  • Third-party material keeps its notice and is listed in NOTICE.md. None added.

Diagnostics for #113, not a fix. `SplitModeNotebookTest > the strip
between cells adds a code or markdown cell there` still fails on CI:
the new markdown cell's Escape leaves it unrendered, last observed
`[# Top, one, mid, two]`.

Ten runs of an earlier trace on each of two commits answered the first
question. In all five failures the key reached neither IDE: no
`pressed ESCAPE` in either process's dispatcher, no popup open, no
drag, and a thread dump taken during the stall with the client's EDT
parked in `getNextEvent`. The Escape is not taken by something in the
client; it never arrives.

The tests keep tracing `IdeKeyEventDispatcher`, which logs each key's
candidate actions and the one chosen, so a key that does arrive is
still told from one that is taken on the way. Around the Escape the
test now also records, on the client: whether the cell's editor is
still the focus owner, whether the frame is focused, whether the robot
has the input focus -- the window manager's, which Xvfb has none to
give, and which the frame's own `isFocused` does not tell -- and where
the pointer rests, since an X server with no focused window gives keys
to the window under it. They are printed and put in the failure
message, as the popup already is, and none of them can fail the test
they report on.

The next failure then separates a key the robot had nowhere to send
from one the X server dropped.

Refs #113
The input-events robot posts into the IDE queue, and its input-focus
probe injects another key. Observe posting, dispatch, callback results,
and consumption directly, with passive focus diagnostics and a single
Escape assertion. Check observer behavior and hook installation.

Add an opt-in CI batch that repeats the full notebook class ten times
on each OS and retains successful runs' logs for comparison.

Refs #113
@BartvHelvert BartvHelvert changed the title test(notebook): record where a lost Escape went test(notebook): trace escape before keymap dispatch Nov 10, 2026
@BartvHelvert

Copy link
Copy Markdown
Owner Author

Closing: the question this branch was built to answer is answered, and the agent is no longer the
cheapest way to confirm it.

Where it got to. The diagnostics here ruled out every candidate in turn — the key reached
neither IDE's dispatcher, no popup was open, no drag was running, the cell's editor was the focus
owner before and after, the frame was focused, and robot.hasInputFocus() was true. The pointer
reading, recorded at 960,540 and never moving, is what showed the robot to be fully synthetic,
which is what turned the question from where did the key go into was it posted at all.

The answer, derived from the platform's own bytecode and registry defaults and written up
here: while the
IDE waits on a lock it draws a freeze overlay, and SuvorovProgress installs an EventStealer
whose IdeEventQueue post listener takes key presses out of the queue and returns true, so
doPostEvent drops them before they are counted. It never puts them back. It passes KEY_TYPED
through and takes only KEY_PRESSED and KEY_RELEASED — which is why typing lands during a
freeze and Escape, carrying no character, does not.

Why not run the agent again. It instruments IdeEventQueue itself, so it perturbs the thing it
is meant to catch, and the ten runs on 1b86351 did not reproduce the failure at all. More to the
point, a second instance has since turned up on its own: #153, the snippet test's Tab, a different
test and a different key with the same asymmetry — typeText landing either side of a lost
key(...). That is corroboration from the suite rather than from a measuring device, and it
arrived without instrumentation.

The runs are better spent on whether the fix holds. #152 presses again until the key arrives, and
#156 turns that into one dispatch of twenty repeats of the class rather than twenty full matrices.
Twenty green runs puts the old ~23% rate at about 0.5% under the null; catching the steal once
would only confirm a diagnosis the fix already acts on.

The branch stays reachable if the agent is ever wanted again — as does f95c92a, whose
IdeKeyEventDispatcher trace is the one line worth re-adding if this recurs, since it tells a key
that arrived from one that never did.

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.

1 participant