Skip to content

mac: the completion popup's chrome follows the appearance - #300

Merged
GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/completion-popup-appearance
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/completion-popup-appearance

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Owner report: in light mode the documentation pane under the completion list is dark, so the highlighted entry's description is hard to read (screenshot in session).

Cause. CALayer takes CGColors, and a CGColor carries no appearance — it is resolved once, against whatever appearance is current when it is assigned. The panel is constructed before it is attached to a window, so windowBackgroundColor and separatorColor were resolved against the application's appearance in init and then never re-resolved. Text colours were always correct, because NSTextField holds the dynamic NSColor and resolves it at draw time — which is precisely why the result was a dark pane with light-mode text rather than a uniformly dark panel.

Fix. PopupChrome re-resolves both colours inside effectiveAppearance.performAsCurrentDrawingAppearance, and observes effectiveAppearance so a light/dark switch while the panel is alive is picked up too.

⚠️ Not built, not tested

Written on Linux, which cannot build Swift. The session's usage window is at 94% of its cap, so the Mac build and suite run were deferred rather than risk a lockout. Do not merge until:

  • swift build is clean;
  • swift test --skip NearbyInterfaceTests --skip NearbyLANInterfaceTests matches a control run of the same base (compare failing sets, not counts);
  • the pane is eyeballed in light and dark, including toggling the system appearance while the popup is open — that last case is what the observation exists for.

I would rather hand over an unverified fix with its reasoning than a verified guess.

Owner report: in light mode the documentation pane under the completion
list is dark, so its text is hard to read.

CALayer takes CGColors, which carry no appearance -- they are resolved once,
against whatever appearance is current when assigned. The panel is built
before it is attached to a window, so windowBackgroundColor and
separatorColor were resolved against the application's appearance at init and
then never changed. Text colours were always right, because NSTextField keeps
the dynamic NSColor and resolves it at draw time -- which is exactly why the
pane ended up dark-background with light-mode text.

PopupChrome re-resolves both colours inside
effectiveAppearance.performAsCurrentDrawingAppearance, and observes
effectiveAppearance so a light/dark switch while the panel exists is picked up
too.

NOT YET BUILT OR TESTED: written on Linux; the session's usage window is at
94% of its cap, so the Mac build and suite run are deferred. Do not merge
before  and  pass and the pane is eyeballed in both modes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar marked this pull request as ready for review September 14, 2026 04:09
@GoKubar
GoKubar merged commit 9bd4b02 into main Sep 14, 2026
17 of 20 checks passed
d-q222 added a commit that referenced this pull request Sep 14, 2026
…itch (GH#280, probe)

The regression tests #280 asks for. Each opens a document into a fresh editor
with no document switch, then asserts that
(a) the text carries syntax-colour temporary attributes,
(b) typing \se through keyDown requests the list once and a real completion
    session opens, and
(c) the typed command is coloured.

Three hostings:
- the bare SourceEditorView with the document present before mount;
- the bare SourceEditorView with the document opened after mount;
- the whole ContentView at the app's 1200x640 minimum size.

All three pass on main 9bd4b02, so the owner's report does NOT reproduce
under hosted conditions. Since the reported 8a5ac44 build, only 0f8ba91
(#300, popup appearance) has touched the editor sources. Ruled out by
reading the code: view identity (EditorPane has no .id), the empty
visible-window paint (window(for:) paints everything without a window), and
diagnostic marks clearing the colours (MarkPainter removes only
underline/tooltip keys). What remains differs between these tests and the
bundled app: a key/active window, an attached producer delivering compile
results, launch-time session/seed paths, and preferences such as Vim
keybindings. Findings and questions are on #280.

Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan)
Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback)
Co-authored-by: d-q222 <[email protected]>

Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
GoKubar pushed a commit that referenced this pull request Sep 14, 2026
…280) (#309)

* mac tests: first-focus colouring and completion without a document switch (GH#280, probe)

The regression tests #280 asks for. Each opens a document into a fresh editor
with no document switch, then asserts that
(a) the text carries syntax-colour temporary attributes,
(b) typing \se through keyDown requests the list once and a real completion
    session opens, and
(c) the typed command is coloured.

Three hostings:
- the bare SourceEditorView with the document present before mount;
- the bare SourceEditorView with the document opened after mount;
- the whole ContentView at the app's 1200x640 minimum size.

All three pass on main 9bd4b02, so the owner's report does NOT reproduce
under hosted conditions. Since the reported 8a5ac44 build, only 0f8ba91
(#300, popup appearance) has touched the editor sources. Ruled out by
reading the code: view identity (EditorPane has no .id), the empty
visible-window paint (window(for:) paints everything without a window), and
diagnostic marks clearing the colours (MarkPainter removes only
underline/tooltip keys). What remains differs between these tests and the
bundled app: a key/active window, an attached producer delivering compile
results, launch-time session/seed paths, and preferences such as Vim
keybindings. Findings and questions are on #280.

Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan)
Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback)
Co-authored-by: d-q222 <[email protected]>

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

* mac editor: text typed at the edge of the painted window is coloured (GH#280)

Measured cause. SyntaxPainter tracks `painted` ranges, the text whose
temporary colours match the highlighter, and an edit's flush repaints only
`painted ∩ dirty`. Its range arithmetic treated an edit that starts exactly at
a painted range's end, or ends exactly at its start, as outside the range.
Text typed at either edge was therefore never inside `painted` and never
coloured. It only turned colour when something else repainted: a scroll, or a
document switch, whose text reset repaints the window. That is the owner's
"eventually comes" and "click another file and back".

The startup document shows it directly. In the whole ContentView hosted like
the app, with the caret at the end of the fixture text, typing " \se" left
painted == [{0, 16}] over a 20-character text with 0 colour runs, while the
highlighter held 1 run for \se.

Fix: `shifted` joins edits that touch a range, using strict comparisons. The
existing union branch already yields the right range for touching insertions
and deletions; the new unit test pins eight cases.

Tests (EditorFirstFocusTests):
- testPaintedRangeAbsorbsEditsAtItsEdges and
  testStartupDocumentInContentViewIsColouredAndCompletes FAIL without this
  change and pass with it (verified by reverting only the source file);
- the three earlier first-focus probes still pass.
The completion half of the report did not reproduce: the list opens on first
focus in every hosting. The owner's non-activating launch (window never key)
is still to be checked in the real app.

Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan)
Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback)
Co-authored-by: d-q222 <[email protected]>

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

* mac tests: local focus probe for GH#280 (click + typing through window event dispatch)

Skipped unless FLASHTEX_FOCUS_PROBE=1 because it takes keyboard focus. It
hosts the whole ContentView in a window that was only ordered back, as in the
owner's non-activating launch, then sends a real mouse click and real keyDown
events through NSWindow.sendEvent.

With #309 on this branch, the click gives the editor first responder (the
window is still not key), the keys insert, typing \se opens a session, the
CompletionPopup child window is visible, and the command is coloured. So
completion on first focus does not reproduce through the real event path
either. Left to check: app activation from an open -g launch, which a test
process cannot emulate.

Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan)
Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback)
Co-authored-by: d-q222 <[email protected]>

Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
@GoKubar
GoKubar deleted the agent/kabir-claude/completion-popup-appearance branch September 16, 2026 04:17
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