Skip to content

Update ghostty fork to latest upstream - #2379

Merged
lawrencecchen merged 11 commits into
mainfrom
issue-1199-ghostty-upgrade
Apr 2, 2026
Merged

lawrencecchen merged 11 commits into
mainfrom
issue-1199-ghostty-upgrade

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Testing

  • DEVELOPER_DIR=/Applications/Xcode_26.3.app/Contents/Developer ./scripts/reload.sh --tag issue-1199-ghostty-upgrade

Issues


Summary by cubic

Updates the ghostty submodule to the latest upstream and switches the Swift bridge to @import GhosttyKit with a thin C shim that includes ghostty/include/ghostty.h. Restores smooth live resize by only treating divider-origin drags as interactive, tracking them per mouse-down across windows, forcing immediate geometry syncs, and refreshing visible terminal surfaces; also picks up the macOS focus-transfer mouse fix (closes #1199).

  • Dependencies

    • Bump ghostty submodule to latest upstream.
    • Import GhosttyKit in the bridging header; keep a thin wrapper that delegates to upstream’s canonical header.
    • Refresh fork notes and update pinned GhosttyKit checksums.
  • Bug Fixes

    • Require split fast-resize to start on a divider, track the drag to a single mouse gesture across windows, and ignore stale drag-pasteboard state so resizes aren’t suppressed.
    • Force immediate external geometry sync during interactive drags (with coalescing that preserves “immediate” when needed), and reconcile/refresh visible terminal surfaces after both external and anchor geometry syncs to avoid stale frames.
    • Make the clipboard read callback return a bool to correctly signal async handling; re-export selection C APIs to preserve keyboard copy mode.

Written for commit 08fd53e. Summary will update on new commits.

Summary by CodeRabbit

  • Documentation

    • Revised fork-change docs: macOS display/restart and resize handling, reintroduced kitty/OSC‑99 notification parsing, expanded theme picker behavior, color‑scheme reporting, keyboard copy‑mode notes, and clarified merge guidance.
  • New Features

    • Re-enabled OSC‑99 notifications, richer theme‑picker previews/startup matching, and a reported color‑scheme mode; selection APIs re-exported for compatibility.
  • Bug Fixes

    • Clipboard callback now returns reliable handled/unhandled signals and schedules UI work safely; drag/live‑resize no longer defers interactive geometry updates; geometry‑sync coalescing improved.
  • Chores

    • Updated Ghostty submodule and artifact checksum; public header now delegates to upstream and bridging import switched to module form.

@vercel

vercel Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Apr 1, 2026 11:45pm

@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaced the local Ghostty C header with an upstream include, advanced the Ghostty submodule and artifact checksum, adjusted Swift clipboard callback handling and hosted-view geometry refresh/coalescing (including split-divider interaction tracking), and rewrote ghostty-fork.md to reflect a March 30 rebase and reorganized fork notes.

Changes

Cohort / File(s) Summary
Fork Documentation
docs/ghostty-fork.md
Rebased and reorganized fork notes: updated upstream baseline commit and fork HEAD, renumbered/rewrote "Current fork changes", reintroduced OSC 99 kitty parser entries (new parser files listed), added macOS CVDisplayLink restart, expanded theme-picker commits, added color-scheme 2031 reporting, moved keyboard copy-mode C API notes, and revised merge-conflict guidance.
Submodule & Checksums
ghostty
ghostty, scripts/ghosttykit-checksums.txt
Bumped Ghostty submodule ref from bc9be90a2... to 0b231db94... and appended a new GhosttyKit.xcframework SHA256 checksum mapping.
Public C header re-export / bridging
ghostty.h, cmux-Bridging-Header.h
Replaced the local ghostty.h with a thin bridge that #includes ghostty/include/ghostty.h (removing the prior in-repo ABI declarations); changed Objective-C bridging import to @import GhosttyKit;.
Swift clipboard & drag-resize guards
Sources/GhosttyTerminalView.swift
Made runtimeConfig.read_clipboard_cb return explicit false when context/surface missing; capture requestSurface early and schedule main-queue work only when valid; adjusted drag-resize deferral to avoid suppressing interactive geometry updates during active interactive resize.
Hosted-view geometry sync & split-divider handling
Sources/TerminalWindowPortal.swift
Added split-divider hit-testing and tracking, extended isInteractiveGeometryResizeActive to include active split-divider drags, introduced immediate-vs-settled coalescing flag for external geometry syncs, extracted reconciliation helper reconcileVisibleHostedViewsAfterGeometrySync(reason:), and unified scheduling/reconciliation flows.

Sequence Diagram(s)

sequenceDiagram
participant HostView as WindowTerminalHostView
participant Registry as TerminalWindowPortalRegistry
participant Scheduler as GeometrySyncScheduler
participant Reconciler as Reconciler
participant Surface as HostedSurface

HostView->>HostView: hitTest(point) detects split-divider (mouseDown)
HostView->>Registry: noteSplitDividerInteraction(windowId, eventType)
Registry->>Scheduler: scheduleExternalGeometrySynchronize(forceImmediate? true/false)
Scheduler->>Scheduler: coalesceRequests(accumulate forceImmediate)
Scheduler->>Reconciler: run sync (reason)
Reconciler->>Surface: reconcileVisibleHostedViewsAfterGeometrySync(reason)
Surface->>Surface: refreshSurfaceNow(reason)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hopped through headers and bumped the head,
docs got tidy, old notes gently shed.
I nudged the clipboard, split dividers too,
reconciled views, and stitched checksums new.
A tiny rabbit cheers the code — hooray, skedaddle! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary change: updating the ghostty fork to latest upstream, which aligns with the main objective of advancing the submodule and rebasing on upstream main.
Description check ✅ Passed Pull request description includes a clear summary of changes and testing information, aligning with template requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-1199-ghostty-upgrade

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@greptile-apps

greptile-apps Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR advances the ghostty submodule from bc9be90a2 to 0b231db94, rebasing the cmux fork on Ghostty upstream main at 3509ccf78. It adds the corresponding pinned GhosttyKit checksum and refreshes docs/ghostty-fork.md to reflect the six current fork patches (display-link restart, resize stale-frame mitigation, OSC 99 parser, theme picker hooks, color-scheme mode-2031 reporting, and the re-exported keyboard copy-mode C APIs). The primary motivation is picking up upstream focus-transfer mouse fixes to close issue #1199.

Key changes:

  • ghostty: submodule pointer updated; SHA aligns exactly with the new checksums entry and the doc header.
  • scripts/ghosttykit-checksums.txt: one line added with the correct 40-char ghostty SHA key and 64-char SHA-256 value; format is consistent with all existing entries and with how download-prebuilt-ghosttykit.sh consumes the file.
  • docs/ghostty-fork.md: sections reorganized and updated; two zsh prompt-redraw sections (old §5/§6) are removed from "Current fork changes" without a corresponding entry in "Upstreamed fork changes", which may cause confusion during future rebases.

Confidence Score: 5/5

  • Safe to merge; all three changed artifacts are consistent and the only finding is a minor documentation omission.
  • The submodule SHA, the checksum file key, and the doc header all reference the same commit (0b231db94). The SHA-256 value is the correct 64-character length and follows the established format consumed by the download script. No code logic is changed. The sole finding is a P2 style suggestion about documenting the removed zsh sections under "Upstreamed fork changes", which does not affect correctness or build safety.
  • docs/ghostty-fork.md – the "Upstreamed fork changes" section does not record the two removed zsh prompt patches.

Important Files Changed

Filename Overview
docs/ghostty-fork.md Documentation updated to reflect the new fork base (3509ccf78), new fork head (0b231db94), six current patches, and refreshed merge-conflict notes; the removed zsh sections (old §5/§6) are not recorded in "Upstreamed fork changes".
ghostty Submodule pointer advanced from bc9be90a to 0b231db94; SHA is consistent with the new checksums entry and the fork head documented in ghostty-fork.md.
scripts/ghosttykit-checksums.txt New pinned SHA-256 entry added for 0b231db94; key is the full 40-char git SHA matching the updated submodule pointer, and the 64-char hex checksum follows the established file format correctly.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Submodule as ghostty submodule
    participant Checksums as ghosttykit-checksums.txt
    participant Script as download-prebuilt-ghosttykit.sh
    participant Release as manaflow-ai/ghostty releases

    Dev->>Submodule: advance pointer bc9be90a → 0b231db94
    Dev->>Checksums: add pinned SHA-256 for 0b231db94
    Dev->>Release: publish xcframework-0b231db94 asset

    Note over Script: CI / setup.sh invokes script
    Script->>Submodule: git rev-parse HEAD → 0b231db94
    Script->>Checksums: lookup expected SHA-256 for 0b231db94
    Checksums-->>Script: dfbea73081fd7cd3b63d2c9c92252a0761aca7ef9d59f0642dca0c0abee84461
    Script->>Release: curl GhosttyKit.xcframework.tar.gz
    Script->>Script: shasum -a 256 → verify checksum
    Script->>Script: extract GhosttyKit.xcframework
Loading

Comments Outside Diff (1)

  1. docs/ghostty-fork.md, line 103-109 (link)

    P2 Upstreamed sections missing from history

    The previous docs/ghostty-fork.md carried two fork-only patches (sections 5 and 6) covering zsh prompt redraw markers and Pure-style multiline prompt handling — commits 8ade43ce5, 0cf559581, 312c7b23a, and 404a3f175. Those sections are removed in this PR, but neither commit is listed under "Upstreamed fork changes."

    If those patches landed in upstream Ghostty (likely between v1.3.0 and v1.3.1-457), adding brief entries here follows the same pattern already used for cursor-click-to-move and makes it easier for future rebases to know those commits are safe to drop:

    ### zsh prompt redraw markers / Pure-style multiline prompt
    
    - Was local in the fork as `8ade43ce5`, `0cf559581`, `312c7b23a`, `404a3f175`.
    - Landed upstream, so they are no longer carried as fork-only patches.
    

    If they were intentionally removed for another reason, a one-line note explaining why would prevent confusion during the next rebase.

Reviews (1): Last reviewed commit: "Update ghostty fork to latest upstream" | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Sources/TerminalWindowPortal.swift (1)

1155-1165: Avoid unconditional second-pass reconcile across all visible terminals.

At Line 1161, every geometry sync now re-runs reconcileGeometryNow() for all visible hosted views, even though synchronizeHostedView(withId:) already does reconcile/refresh on geometry deltas. This can add noticeable resize overhead with many visible terminals.

♻️ Suggested guard to limit expensive second-pass work
 private func reconcileVisibleHostedViewsAfterGeometrySync(reason: String) {
+    // Keep this extra pass only for active geometry churn paths.
+    let duringGeometryChurn =
+        hostView.inLiveResize ||
+        window?.inLiveResize == true ||
+        TerminalWindowPortalRegistry.isInteractiveGeometryResizeActive
+    guard duringGeometryChurn else { return }
+
     // During live resize, AppKit can deliver frame churn where outer portal geometry
     // settles a tick before the terminal's own scroll/surface hierarchy. Only force an
     // in-place surface refresh when reconciliation actually changed terminal geometry.
     for entry in entriesByHostedId.values {
-        guard let hostedView = entry.hostedView, !hostedView.isHidden else { continue }
+        guard entry.visibleInUI,
+              let hostedView = entry.hostedView,
+              !hostedView.isHidden else { continue }
         if hostedView.reconcileGeometryNow() {
             hostedView.refreshSurfaceNow(reason: reason)
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/TerminalWindowPortal.swift` around lines 1155 - 1165,
reconcileVisibleHostedViewsAfterGeometrySync currently calls
hostedView.reconcileGeometryNow() for every visible entry, causing unnecessary
work; add a guard to skip the second-pass for entries that were already
reconciled by synchronizeHostedView(withId:). To implement: add a lightweight
flag/property on the entry (e.g., Entry.needsSecondPass or
Entry.geometryDirtyToken) that synchronizeHostedView(withId:) sets/clears when
it performs a reconcile/refresh, then in
reconcileVisibleHostedViewsAfterGeometrySync iterate entriesByHostedId but only
call hostedView.reconcileGeometryNow()/refreshSurfaceNow(reason:) when that flag
indicates a missed reconcile; clear the flag after running to avoid repeated
work.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Sources/TerminalWindowPortal.swift`:
- Around line 1155-1165: reconcileVisibleHostedViewsAfterGeometrySync currently
calls hostedView.reconcileGeometryNow() for every visible entry, causing
unnecessary work; add a guard to skip the second-pass for entries that were
already reconciled by synchronizeHostedView(withId:). To implement: add a
lightweight flag/property on the entry (e.g., Entry.needsSecondPass or
Entry.geometryDirtyToken) that synchronizeHostedView(withId:) sets/clears when
it performs a reconcile/refresh, then in
reconcileVisibleHostedViewsAfterGeometrySync iterate entriesByHostedId but only
call hostedView.reconcileGeometryNow()/refreshSurfaceNow(reason:) when that flag
indicates a missed reconcile; clear the flag after running to avoid repeated
work.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b0048e5-aee3-46c8-a25f-5f694b18805f

📥 Commits

Reviewing files that changed from the base of the PR and between 2464bc7 and c3fe5d4.

📒 Files selected for processing (2)
  • Sources/TerminalWindowPortal.swift
  • cmux-Bridging-Header.h
✅ Files skipped from review due to trivial changes (1)
  • cmux-Bridging-Header.h

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Sources/TerminalWindowPortal.swift">

<violation number="1" location="Sources/TerminalWindowPortal.swift:1749">
P3: This `if let activeSplitDividerDragWindowId` branch is unreachable because the same state is fully handled just above (return or clear), so the later check can never be true.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread Sources/TerminalWindowPortal.swift Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b78c00a9d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/TerminalWindowPortal.swift Outdated
…grade

# Conflicts:
#	docs/ghostty-fork.md
#	ghostty
#	scripts/ghosttykit-checksums.txt

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 401ffb169e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/TerminalWindowPortal.swift

This branch was successfully deployed

1 active deployment
Preview — 08fd53eb Deployed Apr 1, 2026 by vercel[bot]
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.

Clicking into a pane directly after tabbing into cmux reliably starts an upward infinite select scroll

1 participant