Repository navigation
fix(linux): keep the sidebar selection tint out of row popovers - #38
Conversation
Right-clicking a session row opened a context menu whose items were
invisible under any theme whose selection-foreground equals the terminal
background (Kanagawa Dragon: both #181616). Only the hovered item stayed
faintly readable.
`showRowContextMenu` parents the popover to the right-clicked ROW, and the
right-click also selects that row, so the row carries `.agterm-selected`.
The tint rule `.agterm-selected label { color: <selFg>; }` is a DESCENDANT
match, so it reached `row > popover > contents > box > button > label` and
painted every menu label in the selection foreground, while
`@define-color popover_bg_color <themeBg>` painted the popover in the
matching background. `.agterm-sidebar label` has equal specificity and
loses on order. Present since the popover was reparented from the list box
to the row (melonamin#26); the recent `GTK_THEME=Adwaita-dark` removal fixed an
unrelated libadwaita fault and never touched this one.
The rule becomes `.agterm-selected > label`, scoping the tint to the row's
own labels. `setSidebarSelectionStyle` tags both the row and its content
box, and `makeRow` appends every label directly to that box, so the child
combinator still reaches all of them. The sibling `.agterm-sidebar
label`/`button` rules stay descendant matches deliberately: they keep
cascading into the popover, and `popover_fg_color` is the same value.
Rejected: a second class on the content box (one more thing to keep in
sync), resetting the color inside popovers (keeps the leaky rule and adds
another), and reverting the popover parent (undoes melonamin#26).
To make the rule testable, `applyWindowThemeColors` no longer builds the
display-wide chrome stylesheet as a 30-line inline interpolation: nothing
host-free could pin what the provider loads, because the method needs a
`GdkDisplay`. `ThemeColorResolver.windowThemeCSS(background:foreground:
selectionBackground:selectionForeground:sidebarBackground:)` now owns the
string, taking the five values the caller already resolves. The move is
byte-identical apart from the one rule, and `AppController.swift` drops
from 992 to 963 lines, below the 1000-line lint ceiling it was sitting
against. This follows `LinuxSidebarPolicy.sidebarCSS` and `App.swift`'s
`appCSS`: a pure builder in a Foundation-only type, string-pinned in
tests. The new `GhosttyConfigThemeTests` case asserts full string equality
against a hand-transcribed literal using five distinct sentinel colors, so
a transposed parameter cannot emit the expected string, plus a negative
assertion against reintroducing the descendant form.
`docs/sidebar.md` now owns the resulting contract: row labels must stay
direct children of the content box, or the tint drops silently.
Symbolic icons take their color from CSS `color`, but the selection tint rule matched only `label` — so the leading terminal icon and the flagged star kept the sidebar foreground on selected rows and vanished under any theme whose selection background equals its foreground (Kanagawa Dragon: both #c5c9c5). The rule gains `.agterm-selected > image`, same child combinator so row popovers stay untinted. The status glyph and unseen badge keep their pango markup colors by design. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The second commit (11d8028) extends the same fix to the row's symbolic icons. Symbolic icons take their color from CSS
Same view, Kanagawa Dragon, selected flagged session row. On the left the row shows only its label — the terminal icon and star are painted foreground-on-foreground; on the right both icons take the selection foreground with the label. The pinned CSS test literal, its selector assertion, and the |
Right-clicking a session row opened a context menu whose items were invisible under any theme whose
selection-foreground equals the terminal background. Kanagawa Dragon is the clearest case — both are
#181616— and only the hovered item stayed faintly readable.Same view, same window geometry, Kanagawa Dragon, first session row selected. On the left the popover is
a bare rectangle — all seven labels are painted
#181616on the#181616popover background.Root cause
showRowContextMenuparents the popover to the right-clicked row, and the right-click also selectsthat row, so the row carries
.agterm-selected. The tint ruleis a descendant match, so it reached
row > popover > contents > box > button > labeland paintedevery menu label in the selection foreground — while
@define-color popover_bg_color <themeBg>paintedthe popover in the matching background.
.agterm-sidebar labelhas equal specificity and loses on order.Present since the popover was reparented from the list box to the row (#26). The recent
GTK_THEME=Adwaita-darkremoval fixed an unrelated libadwaita fault and never touched this one.Fix
The rule becomes
.agterm-selected > label, .agterm-selected > image, scoping the tint to the row'sown content.
setSidebarSelectionStyletags both the row and its content box, andmakeRowappendsevery label and icon directly to that box, so the child combinator still reaches them all — name label,
breadcrumb, terminal icon, star. The status glyph and unseen badge keep their pango markup colors,
which CSS never touched.
The
imagehalf fixes a second symptom of the same collision: symbolic icons take their color fromCSS
color, and the old rule matched onlylabel, so the leading terminal icon and the flagged starkept the sidebar foreground on selected rows — invisible under the same themes, where the selection
background is the foreground.
The sibling
.agterm-sidebar label/buttonrules stay descendant matches deliberately: they keepcascading into the popover, and
popover_fg_colorresolves to the same value.Rejected alternatives: a second class on the content box (one more thing to keep in sync), resetting the
color inside popovers (keeps the leaky rule and adds another), and reverting the popover parent
(undoes #26).
Why the refactor rides along
The rule lived in a 30-line inline interpolation inside
applyWindowThemeColors, which needs aGdkDisplay— so nothing host-free could pin what the provider actually loads, and the CSS was only everexercised by eye.
ThemeColorResolver.windowThemeCSS(...)now owns the string, taking the five values thecaller already resolves. The move is byte-identical apart from the one rule, and
AppController.swiftdrops from 992 to 963 lines, off the 1000-line lint ceiling it was sitting against.
This follows the existing precedent of
LinuxSidebarPolicy.sidebarCSSandApp.swift'sappCSS: a purebuilder in a Foundation-only type, string-pinned in tests.
Tests
GhosttyConfigThemeTestsgains one case pinning the whole emitted string. It uses five distinctsentinel colors (
#111111…#555555) rather than a real palette on purpose: Kanagawa Dragon collapsesfive parameters into three values, so a transposed substitution would have emitted a byte-identical string
and passed. Plus a negative assertion against reintroducing the descendant form.
agterm-linux/docs/sidebar.mdnow owns the resulting contract — row labels must stay direct children ofthe content box, or the tint drops silently.
Verification
swift test— the new case and the rest of the suite pass.make lint— zero findings.Both builds were confirmed by
stringsbefore capture (descendant selector in the before binary,child combinator in the after).