Skip to content

feat(linux): upgrade libghostty, add Kitty clipboard and fix GL teardown - #55

Merged
melonamin merged 28 commits into
melonamin:linux-portfrom
n2tr2:linux-libghostty-683d8db
Nov 8, 2026
Merged

melonamin merged 28 commits into
melonamin:linux-portfrom
n2tr2:linux-libghostty-683d8db

Conversation

@n2tr2

@n2tr2 n2tr2 commented Nov 1, 2026 •

Copy link
Copy Markdown

Moves Linux libghostty from 0ba6250 to 683d8db, adapts clipboard callbacks to its ABI, and fixes pane teardown freeing GL objects under another surface's context. The branch includes the current v0.40 Linux integration, #56 split restoration, #57 local links, and the startup initialization-order correction. There is no agtermCore delta from linux-port.

Changes

  • Retain each surface's creation GL context and make it current for engine teardown. If that fails, free with no context after clearing the current context; if clearing also fails, quarantine the engine, configuration storage, context, and wrapper until app exit.
  • Add Kitty clipboard protocol support: text reads and binary-safe, multi-representation writes. Permission refusals return protocol denial. Convert file URLs to paths only when the clipboard advertises text/uri-list, so literal file:// text round-trips.
  • Rebase the Linux engine patches onto 683d8db and remove the obsolete teardown compatibility patch. macOS engine configuration is unchanged.
  • Add clipboard policy/adapter coverage, retained-context and quarantine tests, and GL tracing across the pane-close paths. Preserve the input-layout and marker-content fixture corrections carried by this branch.

Validation

Current integration head a4a4766 passed CI run 42424893442:

  • Shared-core/CLI tests, strict SwiftLint, architecture/resource checks, and GTK debug/release builds passed.
  • All 631 Linux-package tests in 91 suites passed.
  • All 70 GTK scenarios passed, including remote-presentation, GL teardown under EGL and GLX, both quarantine scenarios, startup environment ordering, IBus lifecycle, layout-aware palette navigation, local links, and rendered cold split restoration.
  • This run rebuilt the runtime from a cold cache. The earlier branch also passed a warm-cache run.

The current remote-presentation harness separately passed once against baseline build e85e8a6 with the verified old 0ba6250 engine and pinned zmx runtime. This exercised SSH-255 loss, failed-probe reason/count reporting, stable pane identities, reattachment, leadership, overlay jobs, and ask handback. A passing baseline and current-head run do not explain the earlier intermittent failure.

Earlier branch validation traced GL deletes against their owning contexts across nine close paths and exercised deliberate mutations, headless Wayland, OSC 52/5522, font resizing, scrollback, IME commits, and busy/background teardown. Those runs are historical evidence; native desktop acceptance was not repeated for the current integration.

Remaining limits and release follow-ups

  • The historical remote-presentation failed-probe assertion remains unexplained. Do not classify it as fixed or as an established upgrade regression based on passing reruns.
  • Native NVIDIA, Hyprland, newer GTK, and a real input seat remain unverified in this integration. Real GL make-current failure was injected rather than reproduced on a live engine.
  • The no-context fallback can leak GPU resources. Quarantine deliberately keeps the engine and child process alive until app exit when safe teardown cannot proceed.
  • Kitty image-only reads remain unsupported; Kitty writes to PRIMARY are refused by the engine. Copy-on-select to PRIMARY remains available.
  • Previously observed wlroots OSC 52 ownership loss, IBus preedit after commit, and upstream-v0391 test instability also occurred with the old engine. The startup environment-ordering hazard is corrected by 1925919 in this integration, but that does not prove the cause of the earlier captured getenv crash.

n2tr2 added 23 commits October 31, 2026 19:51
GhosttySurface now holds its own ref on the pane's GdkGLContext and runs
ghostty_surface_free under it, restoring the prior context afterwards.
The last-chance free moves to the widget's destroy, and a skipped free
quarantines the engine so its callbacks stop reaching GTK or the model.

Adds the isolated retained-context check, the LD_PRELOAD shim, the log
analyzer and the gl-teardown AT-SPI scenarios that judge every teardown
path. The negative control on the unfixed code reported the expected
foreign, no-context and sibling deletes.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
gl-teardown-quarantine skips one overlay's free, then has its still
running child speak OSC 22, 2, 52 and 9 and exit after the widget is gone.
Each late callback must stop at the registry with the clipboard unchanged.
A command surface always waits, so its close arrives as SHOW_CHILD_EXITED
and is logged under the name the scenario asks for.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
Adds the container runner behind the headless Wayland and X11 proofs and
states the retained owner context, the display-open invariant, the
last-chance free, the degraded branches and the quarantine once in the
libghostty rules. The plan records the evidence and closes the GL
teardown gate; the startup-mutation and live-display gates stay open.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
The concurrent reader kept its exception on its own thread and recorded
a time only after a success, so a dead reader reported 0 ms and passed.
ControlProbe rethrows on the scenario thread, requires a completed read
and rejects a reader still alive after the join.

The same shape sat in stderr_slice, where an uncaptured stderr looked
like no degraded line; it now requires the sink's marker. The headless
runner gains a stage command that records the commit, because a linked
worktree's gitdir is not in the container, and a run refuses a stage
that names none.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
END proves only that the shim's destructor ran. exit(nonzero) runs
destructors too and a later library finalizer can still abort, so a
clean trace could sit beside a failing app while the runner discarded
wait's status and the scenarios never read returncode.

The runner and the gl-teardown scenarios now judge the exit apart from
the trace and accept only 0, because the GLib SIGTERM handler quits
cleanly. Stand-ins cover nonzero and signal exits beside a complete
trace with no display.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
The analyzer, path and exit suites check the judge behind the gl-teardown scenarios and ran under no gate. They need only the standard library and bash, so they sit beside the SVG check and stop the script on failure.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
A headless run took any stage naming a commit, so a stale stage could pass while the tests under it came from the live tree. run_host now compares the stage commit with Sources and linux/patches, on the host where a linked worktree's gitdir resolves. A commit git cannot resolve refuses, as do untracked sources, which git diff does not see. run_stage's own clean check gains linux/patches through the shared list.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
…-list

Every text read ran through the path decoder, so a Kitty client reading back its own text/plain file:// URL got a path. The callback has no request kind, so the clipboard's formats decide, taken as the read starts. Literal text round-trips and an offer with text/uri-list still reads and pastes as paths. A clipboard offering only text/plain with file:// lines no longer converts on paste, which is the intended trade.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
A blank context line in a unified diff is a single space, so the rebased patches fail CI's git diff --check. Same rule as scripts/zmx-patches; the patch bytes and their digest stay as built.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
@n2tr2
n2tr2 force-pushed the linux-libghostty-683d8db branch from 18cd6e4 to cba2f6f Compare November 1, 2026 15:51
n2tr2 added 4 commits November 1, 2026 19:15
A surface with no `command` closes through close_surface_cb, the one
RetainedGhosttySurface entry no scenario reached. gl-teardown-quarantine-close
quarantines a split, releases its exec'd child, and requires the callback's
drop with the primary pane's shell unchanged.

The callback drops under its own `close_surface` kind: SHOW_CHILD_EXITED logs
`close` first on a plain exit and each kind logs once, so the old label could
never appear. Removing the initializer's guard fails the scenario by name.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
`printf > file` creates the file before it writes, so waiting for it to
exist and then reading it can see it empty. The likely cause of the
`daemon-typed` assertion failing in CI on melonamin#55; that assertion recorded no
value, so this is not proven. A wrong value now times out by name.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
Under a Russian layout xdotool sends a named p through a temporary spare
keycode and unbinds it after the tap. Freezing the app across the press
lost the palette 0/3 opened at 50 ms and 0/6 until xdotool exited, while
the same freeze on a US layout and ctrl+shift+33 under Russian kept it.

Keycode 33 is what a real keyboard sends, and matches the Ctrl-J/K steps.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
Brings in melonamin#54's real commits, so this branch merges without a rebase once
melonamin#54 lands. Both sides added atspi_smoke.py scenario lines at the same
spots; the tree is unchanged by this merge.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
@n2tr2
n2tr2 marked this pull request as ready for review November 1, 2026 21:36
@n2tr2
n2tr2 requested a review from melonamin as a code owner November 1, 2026 21:36
n2tr2 added a commit to n2tr2/agterm-linux that referenced this pull request Nov 1, 2026
`printf > file` creates the file before it writes, so waiting for it to
exist and then reading it can see it empty. The likely cause of the
`daemon-typed` assertion failing in CI on melonamin#55; that assertion recorded no
value, so this is not proven. A wrong value now times out by name.

Claude-Session: https://claude.ai/code/session_01MeR3EkF5tniXNzBrRWmfYZ
@melonamin

melonamin commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Holding this upgrade for validation against the current linux-port/v0.40 integration before merge/release.

Two prerequisites in the description are already satisfied: #54 merged as 5d3f29b, and CI run 41352781624 used a warm runtime cache, passed all 64 GTK scenarios, and passed 623 Linux-package tests.

The remaining integration gate is current-branch validation of rendering, font/resize behavior, input/IME, clipboard, process lifecycle/GL teardown, and control-socket paths. The unexplained remote-presentation failed-probe assertion still needs a baseline or diagnosis; the previous passing reruns do not establish its cause. Native-display coverage and the deliberate quarantine behavior (engine and child remain live until app exit when safe teardown fails) remain explicit release decisions.

The November 1 checks are useful evidence, but they predate the current v0.40 integration. The current branch also contains 1925919, which moves resource-environment and locale initialization ahead of GTK workers and adds a startup-order regression; carry that correction through the integration. This addresses the startup-order hazard described in this PR, without proving the cause of the earlier captured crash. No new blocking code defect was established by the focused review.

@melonamin

melonamin commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Merged current linux-port (6db162b) into this branch as a4a4766, preserving the existing history. This includes the merged #57 local-link fix, #56 split-layout fix and rendered cold-restoration regression, and the startup initialization-order correction.

The merge was clean. Strict SwiftLint 0.65.0, core-boundary and CLI-drift checks pass; agtermCore remains identical to the Linux base. Fresh CI will validate the engine/clipboard/teardown changes against the current v0.40 application and complete GTK suite.

The current remote-presentation harness also passed once against the existing e85e8a6 baseline build using the verified old Ghostty pin 0ba6250 and its pinned zmx runtime. It exercised SSH-255 loss, failed-probe reason/count reporting, stable pane identities, reattachment, leadership, overlay jobs, and ask handback. The initial harness launch had an unstaged zmx path; after mounting the existing verified runtime at the harness's expected path, the scenario completed successfully.

One passing baseline run does not explain or clear the earlier intermittent failure. Current-head integration CI is still pending, and native-display acceptance remains unverified.

@melonamin melonamin changed the title feat(linux): move libghostty to 683d8db, add the Kitty clipboard and fix GL teardown (merge after #54) feat(linux): upgrade libghostty, add Kitty clipboard and fix GL teardown Nov 8, 2026
@melonamin
melonamin merged commit 7a22b4a into melonamin:linux-port Nov 8, 2026
5 checks passed
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