Skip to content

fix(linux): show context menu for split session rows - #26

Merged
melonamin merged 7 commits into
melonamin:linux-portfrom
Gnu-Gorets:fix/linux-split-session-context-menu
Aug 16, 2026
Merged

melonamin merged 7 commits into
melonamin:linux-portfrom
Gnu-Gorets:fix/linux-split-session-context-menu

Conversation

@Gnu-Gorets

Copy link
Copy Markdown

Problem

Right-clicking a split session row in the Linux sidebar does not open the session context menu. The same action works for a regular session.

The menu builder already adds Close Session for every single session, so split sessions should use the same menu.

Fix

  • attach the right-click gesture to each session row instead of the parent GtkListBox;
  • pass the exact row to the context-menu builder instead of resolving it from list-box coordinates;
  • extend the AT-SPI context-menu smoke scenario to cover a split session.

This avoids the list-box y-coordinate hit-test path that fails for the reported split-row case.

Validation

  • python3 -m py_compile agterm-linux/tests/atspi_smoke.py
  • git diff --check
  • Swift build/tests not run locally: Swift toolchain is unavailable in the environment. CI should run the Linux build and AT-SPI smoke suite.

@Gnu-Gorets
Gnu-Gorets requested a review from melonamin as a code owner August 12, 2026 18:42
@Gnu-Gorets
Gnu-Gorets force-pushed the fix/linux-split-session-context-menu branch from 8c741dc to 0ce8c96 Compare August 12, 2026 18:45
@melonamin
melonamin force-pushed the fix/linux-split-session-context-menu branch from 00fbf0c to c92f16e Compare August 16, 2026 14:30
@Gnu-Gorets

Copy link
Copy Markdown
Author

Fixed the CI failure in 3ea90c0: after enabling split, the AT-SPI test now waits for the rebuilt sidebar rows and retries the context click for transient accessibility races. Local checks: python3 -m py_compile agterm-linux/tests/atspi_smoke.py, git diff --check. The GTK smoke suite still needs CI dependencies.

@Gnu-Gorets

Copy link
Copy Markdown
Author

Fixed in 00fe74b: split reconciliation now preserves existing sidebar rows instead of rebuilding their GTK/AT-SPI objects. Removed the retry workaround from the smoke test; it now validates one real right-click. Local checks: python3 -m py_compile agterm-linux/tests/atspi_smoke.py, git diff --check.

@Gnu-Gorets

Copy link
Copy Markdown
Author

Follow-up in 2df39fb: the remaining rebuild came from surfaceDidFocus() after split focus, not reconcile(). It now updates the session label in place and keeps the live row/gesture intact; the context callback also resolves its controller from the event controller.

@Gnu-Gorets

Copy link
Copy Markdown
Author

The latest CI failure was a compile error in updateSessionName(): cast(widget) produced UnsafeMutablePointer<T>?, while GTK expects OpaquePointer?. Fixed in 2e8e756 by passing the existing widget handle directly. Local checks: git diff --check and py_compile passed.

@melonamin
melonamin merged commit cc540a3 into melonamin:linux-port Aug 16, 2026
5 checks passed
melonamin pushed a commit that referenced this pull request Sep 1, 2026
* fix(linux): keep the sidebar selection tint out of row popovers

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 (#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 #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.

* fix(linux): tint row icons with the selection foreground

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]>

---------

Co-authored-by: Claude Fable 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.

2 participants