Skip to content

mac: hosted tests never activate the app, and a regression floor for soft line wrapping - #219

Merged
GoKubar merged 5 commits into
mainfrom
agent/qol/editor-wrap
Sep 13, 2026
Merged

GoKubar merged 5 commits into
mainfrom
agent/qol/editor-wrap

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Three editor quality-of-life fixes, verified together against a control checkout of the same base.

Hosted tests never activate the app

The hosted suites build real NSWindows so AppKit geometry is measured the way the shipping app measures it. They already avoid makeKey and some place the window off-screen, but an xctest process still starts life as a regular app, and a regular app that orders a window front is pulled in front of whoever is using the Mac. Running the suite flashed windows over the owner's work — reported twice.

HostedWindowSupport.prepare() puts the test process into a non-activating activation policy once, before any window exists: .prohibited first, falling back to .accessory if the OS refuses the stronger one. AppKit still builds, lays out and draws the windows, which is all these tests read. All 30 hosted-window sites across both test targets call it.

Proof. On this Mac .prohibited is accepted (logged by the guard test). The frontmost application was sampled 372 times across a full 130 s suite run that creates ~30 hosted windows: the test process never appeared. The only apps that came forward were the owner's own, as they used the machine undisturbed.

A guard test scans the test sources, so a new hosted test cannot quietly reintroduce the flash.

A regression floor for soft line wrapping

EditorPreferences.lineWrapping has been on by default since the preferences landed, but the only coverage asserted the container flags (widthTracksTextView, isHorizontallyResizable, hasHorizontalScroller). Nothing checked that text actually wraps, that the wrap follows the window, or that geometry read off the layout manager stays right when one logical line spans several visual rows.

Eight tests now host a real editor at an exact width and assert the behaviour: a long line becomes several stacked rows that stay inside the container; with wrapping off it is one row and a horizontal scroller appears; resizing re-wraps and restores exactly; caret rects descend through a wrapped line; the gutter still numbers logical lines, not visual rows; and the preference persists and resets.

The feature itself needed no change — it was already correct. The default stays on, which is right for a prose-heavy format like LaTeX.

The preferences panel has eight switches

Vim keybindings added a Settings toggle without updating the focus-order assertions, so both Settings tests have failed on main since it landed. The expected number now lives in one named constant with the switches listed beside it, so the next toggle is a one-line update in one place.

Tests

executed skipped failures
control, pristine main 1014 135 2 (both the stale switch count)
this branch + #216 1027 135 0

Failing set compared as a set, not a count: control {PanelAccessibilityTests.testConversionPreferencesSectionControlsTakeKeyboardFocus, PanelAccessibilityTests.testPreferencesPanelControlsTakeKeyboardFocusAndTheEditorKeepsIt} → this branch {}.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 5 commits September 13, 2026 18:48
The hosted suites build real NSWindows so AppKit geometry is measured the
way the shipping app measures it. They already avoid makeKey and some place
the window off-screen, but an xctest process still starts as a regular app,
and a regular app that orders a window front is pulled in front of whoever
is using the machine. Running the suite flashed windows over the owner's work.

HostedWindowSupport.prepare() puts the test process into a non-activating
activation policy (.prohibited, falling back to .accessory if the OS refuses
the stronger one) once, before any window exists. AppKit still builds, lays
out and draws the windows, which is all these tests read.

All 30 hosted-window sites across both test targets call it, and a guard test
scans the sources so a new hosted test cannot quietly reintroduce the flash.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
EditorPreferences.lineWrapping has been on by default since the preferences
landed, but the only coverage asserted the container flags (widthTracksTextView,
isHorizontallyResizable, hasHorizontalScroller). Nothing checked that text
actually wraps, that the wrap follows the window, or that geometry read off the
layout manager stays right when one logical line spans several visual rows.

These tests host a real editor at an exact width and assert the behaviour:
a long line becomes several stacked rows that stay inside the container; with
wrapping off it is one row and a horizontal scroller appears; resizing the
scroll view re-wraps and restores; caret rects descend through a wrapped line;
the gutter still numbers logical lines; and the preference persists and resets.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Vim keybindings added a Settings toggle without updating the focus-order
assertions, so both Settings tests have failed on main since it landed.

The expected number now lives in one named constant with the switches listed
beside it, so the next toggle is a one-line update in one place rather than a
count to rediscover from a failure in two tests.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar merged commit ad6d8fc into main Sep 13, 2026
20 checks passed
GoKubar added a commit that referenced this pull request Sep 14, 2026
…activating (#464)

The owner kept seeing editor windows flash over their work during test runs.
PR #219 made the xctest process non-activating, which stopped the focus theft
but not the drawing: a non-activating process still draws its windows.
`CGWindowListCopyWindowInfo` caught them at layer 0, on screen, near the
top-left corner. The old `HostedWindowSupport` doc comment asserted that
`.prohibited` "also keeps the windows off the screen"; it does not, and that
belief is what left the windows visible.

An AeroSpace rule cannot fix it either: across two full `swift test` runs
sampled every 0.4-0.5s, `aerospace list-windows --all` never listed an xctest
window at all, because the XCTest host is not a regular registered UI app.
CoreGraphics sees these windows; the window manager does not. So the fix has
to be in the harness.

Passing a far-offscreen origin to `NSWindow(contentRect:)` does not work,
because AppKit relocates the window inside the initializer. Measured on
macOS 26.6, a window asked for at (-10000,-10000) reports frame (80, 816)
immediately after `init` and lands at CGWindowList 600x432@(80,33) once
ordered front -- which is exactly the position the owner was seeing, and
exactly why the three sites that already passed `-10_000` origins never
helped. Overriding `constrainFrameRect` alone does not work either: it only
governs the second move, after the initializer has already done the first.

Both moves are needed, so `HostedWindowSupport.window(contentRect:...)` does
both: it sets the origin *after* init, where the initializer cannot undo it,
and returns an NSWindow subclass whose `constrainFrameRect` is the identity,
so ordering the window front does not drag its title bar back onto a display.
The requested origin is deliberately ignored -- only the size is used -- so a
newly written test is off-screen by default. All 37 construction sites now go
through it, and a guard test fails if any test constructs NSWindow directly.

Nothing is weakened to achieve this. The window still lays out and draws,
still accepts `makeFirstResponder`, still reports AXWindow/AXStandardWindow to
the accessibility suites, and keeps its content size; hosted tests measure in
window coordinates (`convert(_:to: nil)`), which do not depend on the global
origin. The completion popup follows its host off-screen: it positions itself
from the parent's caret rect in screen coordinates, so an off-screen parent
yields an off-screen popup, and a test now asserts that.

Also removes a duplicate copy of the helper that PR #219 left in
FlashTeXAccessibilityTests, which shadowed the shared one; the helper is now a
single small target both hosted test targets depend on.

Evidence, same machine, same sampler, nothing else running (measured by
attributing each window to its owning PID, because other lanes' xctest
processes share the owner name):

  before (ed796d9): 1155 tests, 0 failures; 98 distinct windows, 98 on display
  after:             1159 tests, 0 failures; 92 distinct windows,  1 on display

The single remaining entry is a 0x0 window at the origin -- zero pixels, and
present identically in the before run. `kCGWindowListOptionOnScreenOnly` means
"ordered in", not "intersects a display", so the measurement is by
intersection with display bounds rather than by absence from that list.

Implementation-Agent: mac-lane-agent (Claude Opus 5)
Commit-Executor: mac-lane-agent (direct git, Cursor usage limit fallback)


Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

Co-authored-by: mac-lane-agent <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
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