Skip to content

[macos] restore addTabbedWindowSafely to fix tab crash#13

Merged
nicosuave merged 2 commits intosidequery:mainfrom
bvolpato-dd:bv/fix-addtabbedwindow-crash
Mar 1, 2026
Merged

[macos] restore addTabbedWindowSafely to fix tab crash#13
nicosuave merged 2 commits intosidequery:mainfrom
bvolpato-dd:bv/fix-addtabbedwindow-crash

Conversation

@bvolpato-dd
Copy link

Summary

  • Ports upstream Ghostty's ObjCExceptionCatcher that safely wraps addTabbedWindow:ordered: in an Objective-C @try/@catch block. AppKit can throw NSExceptions during tab operations on recent macOS versions (2025/2026), and Swift cannot catch those natively — causing hard crashes.
  • Restores all 11 callsites in TerminalController.swift and 3 in Fullscreen.swift from raw addTabbedWindow back to addTabbedWindowSafely.
  • This fix was already present upstream in ghostty-org/ghostty but was inadvertently dropped when Ghostree diverged.

Changes

  • New files: ObjCExceptionCatcher.h / .m — Objective-C wrapper that catches NSExceptions from addTabbedWindow:ordered: and converts them to NSError.
  • ghostty-bridging-header.h — Added #import "ObjCExceptionCatcher.h" so Swift can call the wrapper.
  • NSWindow+Extension.swift — Added addTabbedWindowSafely(_:ordered:) extension method that calls through the ObjC wrapper.
  • TerminalController.swift — Replaced all 11 raw addTabbedWindow calls with addTabbedWindowSafely.
  • Fullscreen.swift — Replaced all 3 raw addTabbedWindow calls with addTabbedWindowSafely.
  • project.pbxproj — Added ObjCExceptionCatcher.m to the Xcode file group.

Testing

  • zig build succeeds.
  • zig build test passes (2476 tests, 6 skipped).
  • Manual: open Ghostree, create/move/reorder tabs — no crashes.

Did this cause any problems?

Rollback/revert this commit and redeploy the service.

Made with Cursor

bvolpato-dd and others added 2 commits February 26, 2026 09:30
Port upstream Ghostty's ObjCExceptionCatcher that wraps
addTabbedWindow:ordered: in @try/@catch. AppKit can throw
NSExceptions during tab operations on recent macOS (2025/2026),
and Swift cannot catch those natively.

Made-with: Cursor
@nicosuave
Copy link
Member

I really appreciate you hunting this down @bvolpato-dd

@nicosuave nicosuave merged commit bab6de1 into sidequery:main Mar 1, 2026
37 of 38 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