Commit Graph

1022 Commits

Author SHA1 Message Date
Mitchell Hashimoto
09ff85b2ac macOS: fix find previous action when search is focused (#14131)
Typo found by @lrytz.
2026-09-03 08:38:09 -07:00
Lukas
e8936b8969 macOS: follow up cascading fix for #14118
Didn't respect the comment above before when reverting and testing hidden title 🫪
2026-09-03 09:22:36 +02:00
Lukas
e347482fba macOS: fix find previous action when search is focused 2026-09-03 08:13:21 +02:00
Mitchell Hashimoto
084316aa82 macOS: fix cascading without affecting other new-window behaviours (#14118)
Found another regression when investigating #14107 after the last fix.
This regression appears on macOS 15 and 26 as well: **New window by
Shortcuts.app or service menu while a window is visible would create a
tab**.

It appears that for `new-window` triggered by Shortcuts/Service, a small
delay is needed to avoid automatic tabbing. It's either removing
`NSWindow.userTabbingPreference == .always` completely or adding another
"delay" for cascading. The latter should be better.

Also fixes another cascading for `macos-titlebar-style = hidden`
previously missed.
2026-09-02 08:10:02 -07:00
Lukas
aafacb1cb9 macOS: fix flickering when creating new tab with glass style
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 16:18:30 +02:00
Lukas
a8b0855b63 macOS: fix cascading for HiddenTitlebarTerminalWindow 2026-09-02 11:16:41 +02:00
Lukas
310797df1d macOS: fix cascading without affecting other new-window behaviours 2026-09-02 11:05:48 +02:00
Lukas
451e224c64 macOS: clean up for #14106 2026-09-01 19:18:44 +02:00
Lukas
d4a5ff58b6 macOS: fix window cascading 2026-09-01 16:56:28 +02:00
Lukas
777929a8fe macOS: review windows when closing multiple tabs 2026-08-28 19:32:27 +02:00
Mitchell Hashimoto
2de1596115 macos: normalize action working directory paths
Discussion #14048

Directory URLs no longer export a trailing slash through PWD, which
keeps zsh's %1~ prompt expansion from resolving to an empty string.

A shared URL helper removes trailing separators while preserving the
filesystem root and percent-decoding behavior. Tests cover normal,
repeated, encoded, and root paths.
2026-08-27 14:35:01 -07:00
Mitchell Hashimoto
e9ad4b1d63 macOS: fix non control keys are not working for AppleScript (#13205)
`send key` only works for control keys like `enter` currently; this adds
(fixes) the support for other keys listed as available. Found by
@paaloeye in #13180

The core of this fix is relying on `UCKeyTranslate` to get the
corresponding character and code point from a key code using
`KeyboardLayout.character(for:modifiers:)`.

ScriptKeyEventCommand now respects `macos-option-as-alt`, and attach
`text`, `unshifted_codepoint` and `consumed_mods` under the same
condition as a manual input events like in `performKeyEquivalent` and
`localEventKeyDown`.

## AI Disclosure

Claude did the heavy lifting, I reviewed and rephrased some of the
comments it generated. And ofc reviewed and tested myself.
2026-08-27 09:33:24 -07:00
Lukas
0a9f47cae0 macOS: update note about tab accessory view 2026-08-26 22:45:56 +02:00
Lukas
b6ac6e1d47 Revert "macOS: use same ResetZoomAccessoryView (#14028)"
This reverts commit 15ff186f65, reversing
changes made to 1abd53ee53.
2026-08-26 22:44:12 +02:00
Mitchell Hashimoto
15ff186f65 macOS: use same ResetZoomAccessoryView (#14028) 2026-08-26 06:52:39 -07:00
Lukas
7a15898bc8 macOS: use same ResetZoomAccessoryView 2026-08-26 13:28:11 +02:00
Lukas
851751a116 macOS: clean up deprecated toolbar button 2026-08-26 10:21:40 +02:00
Lukas
6229d4eb62 macOS: fix AppleScript send key for non-control keys
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 17:49:02 +02:00
Mitchell Hashimoto
6d2b436529 macos: replace legacy aspectRatio with scaledToFit in clipboard preview (#14006)
Fixes the swiftlint legacy_swiftui_aspect_ratio violation.

### AI Disclosure

By Claude, but it's really simple.
2026-08-25 05:41:28 -07:00
Lukas
d7f5ba3b4f macOS: add test cases for ScriptKeyEventCommand
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 13:37:58 +02:00
Lukas
a2212a5b12 macos: replace legacy aspectRatio with scaledToFit in clipboard preview
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 10:22:27 +02:00
Mitchell Hashimoto
25c61e852f macos: implement Kitty clipboard protocol writes
Programs can now write the system clipboard through the Kitty
clipboard protocol in the macOS app. This also does all the hard work
plumbing through core termio/apprt so GTK should be an easy follow.

This functionality lets clients copy arbitrary representations (images, 
HTML, etc.) into the clipboard. Writes honor `clipboard-write`: allow 
applies silently, deny answers EPERM up front before any data is used, 
and ask shows the standard confirmation prompt.
2026-08-24 12:18:46 -07:00
Mitchell Hashimoto
df14efaf33 macos: preview images in the clipboard read confirmation dialog 2026-08-24 08:33:37 -07:00
Mitchell Hashimoto
af9470b19b macos: Kitty clipboard reads support pw/name session grants 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
0ce9054bf9 macos: implement Kitty clipboard protocol reads (OSC 5522) 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
7a9bca6a6e macOS: fix responsiveness for repeated new tab action (#13985)
Fixes #13725
2026-08-24 06:58:12 -07:00
Lukas
1d24eecb20 macOS: fix responsiveness for repeated new tab action 2026-08-24 11:37:34 +02:00
Lukas
6cf7e0cc54 macOS: fix swiftlint warnings
swiftlint 0.63.3 introduced a new rule called [`legacy_swiftui_aspect_ratio`](76363aa4d7/CHANGELOG.md (L314))
2026-08-24 11:34:38 +02:00
Lukas
10d7326889 macOS: clean up GlassViewModel 2026-08-21 11:17:54 +02:00
Lukas
fd17869d15 macOS: rework for #10943
Keep the background color as it is and apply glass effect on top of it
2026-08-20 13:30:33 +02:00
Jon Parise
5c952ac977 macos: simplify command palette sort keys
Store the Comparable ObjectIdentifier directly instead of wrapping the
only sort key type in AnySortKey.

The expected deterministic ordering of equal terminal command titles is
also now verified by a unit test.
2026-08-17 12:50:27 -04:00
Lukas
cb7eaa059d macOS: silent weak ownership difference warnings
UpdateViewModel doesn't own the Task, we don't actually need it here.
2026-08-12 15:34:55 +02:00
Lukas
daab08ec01 macOS: drop the cross-platform check and abstraction
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-12 14:00:03 +02:00
Mitchell Hashimoto
d1937d63e4 macOS: remove unused menu validations (#13726)
UpdateController isn't the target of any menu item, we don't need add
menu validation here.
2026-08-11 11:02:28 -07:00
Mitchell Hashimoto
d695ffff3b macos: defer OSC52 clipboard read confirmations until focused
Fixes #10077

Clipboard read confirmations would immediately show a sheet which
grabbed focus. This could be used for a bunch of dumb reasons, including 
DoS attacks. But, it also caused focus/sheet loops for programs that did
OSC52 on focus changes (which was seen via some Neovim configs!).

Now, if a surface is unfocused, we bell the surface and show the confirmation
request on next focus. If the surface is not focused or another request
comes in, we cancel the prior one.

This also fixes some memory management issues around clipboard requests
that were likely small leaks (didn't verify the old bug, but verified
the new code, and eyeballed the old).
2026-08-11 06:44:23 -07:00
Lukas
0c8ec225b5 macOS: remove unused menu validations 2026-08-10 12:12:25 +02:00
Mitchell Hashimoto
da745630be macos: only check for auto-tabbing when tabbing preference is always
windowDidLoad undoes macOS automatic window tabbing by inspecting
window.tabGroup. Accessing tabGroup on a fresh window materializes
AppKit's tab group machinery, which takes ~15-20ms and is on the
critical path of every window creation, including the first window at
app launch.

AppKit only auto-tabs a fresh window when the system tabbing
preference is "always": the tab bar "+" button goes through
newWindowForTab which we intercept and route through our own tab
logic, so it never auto-tabs. Guard the check on
NSWindow.userTabbingPreference == .always so everyone else skips the
tab group materialization entirely.

Measured on macOS (Apple Silicon) during app launch via the startup
timeline instrumentation:

  windowDidLoad tab group check: 17.8ms -> ~0ms
  main() -> window visible: median ~173ms -> ~165ms (n=7)
2026-08-09 19:54:28 -07:00
Mitchell Hashimoto
4b1e02c7c3 macos: do not load the config errors window when there are no errors
Measured on macOS (Apple Silicon) during app launch, via a startup
timeline instrumented across the Swift app and libghostty:

  config apply, errors step:      35.5ms -> 0.1ms
  main() -> first frame rendered: ~126ms -> ~93ms
  main() -> window visible:       ~193ms -> ~173ms
2026-08-09 19:54:28 -07:00
Mitchell Hashimoto
2602886144 macOS: fix quit alert missing when hidden (#13686)
Fixes https://github.com/ghostty-org/ghostty/discussions/13685.

Removed presumably deprecated check introduced in
8f1a014afd for update pill
> I checked for auto update as well, it works as before this, and for
manual updates we're not confirming anyway, so I think its safe to
remove it now.

Each BaseTerminalController already has quit check and confirming code
added in that review windows pr. It didn't cover QT before, overriding
it to animate in for showing alert.

[#5450](https://github.com/ghostty-org/ghostty/issues/5450) stays fixed.




https://github.com/user-attachments/assets/dbf36f16-e3ce-4f6a-bc25-367fe48739b9
2026-08-07 13:21:50 -07:00
Lukas
e83cf0b06f macOS: fix quit alert missing when hidden 2026-08-07 20:11:16 +02:00
Mitchell Hashimoto
4693e1b546 macos: sync appearance when new windows are created (#13675)
For new windows to get their appearance synced, we need to call
`syncAppearance` after `super.showWindow(sender)`. All previous calls to
`syncAppearance` on `TerminalWindow` will be ignored because the window
needs to have `isVisible` set to `true`.

This regression was introduced by:
5368adcd29

It added `.dropFirst()` to the `focusedSurface` appearance publishers in
`TerminalController.swift` which removes the initial call of the
subscription.

Fixes https://github.com/ghostty-org/ghostty/issues/13324

(landed on the same fix as @rasitakyol found here:
https://github.com/ghostty-org/ghostty/pull/13341)
2026-08-07 08:02:54 -07:00
Lukas
96826853bd macOS: fix window sizing after dragging a split into a window 2026-08-07 15:14:30 +02:00
Christoffer Winterkvist
e11bfb5139 macos: sync appearance when new windows are created (#13324)
call `syncAppearance` after `super.showWindow` has been called to
ensure that the window is visible.
2026-08-06 19:53:48 +02:00
Mitchell Hashimoto
e88601239d macOS: update command options match order (#13624)
Matches are sorted in the following order:
leadingColor > title > subtitle > description.

Ranking is lexicographic on (colorScore, textScore)

<img height="300" alt="image"
src="https://github.com/user-attachments/assets/1ec99e67-537e-4fc6-b595-d7eec8cbf31d"
/>


### AI Disclosure

Claude reviewed and added unit tests, also did some refactoring of my
original implementation.
2026-08-05 15:29:50 -07:00
Mitchell Hashimoto
57c1baf43a macos: defer overlapping clipboard completion
Fixes #/13074

Overlapping clipboard confirmations now defer denial until the next
main queue turn rather than completing inside the confirmation callback.

This prevents the native request state from being invalidated while its
callback is still active, avoiding the OSC 52 crash reported in #13074.

The deferred closure retains the originating surface view and completes
the ignored request with empty data, preserving the existing deny
behavior.
2026-08-05 14:24:37 -07:00
Mitchell Hashimoto
880eded158 macos: avoid IOSurface leak on automated surface creation (#13640)
Fixes #13444

A close while AppKit temporarily cleared/changed a surface's window
would leak the surface in the controller's pslit tree. This retained
surface kept a bunch of resources around, particularly large IOSurfaces.

This seems to only be reproducible under scripted load: rapid terminal
creation/destruction so that destruction happens just while there is a
nil window on a surface view.

Track surface ownership in a weak controller map updated alongside the
split tree, with validated fallbacks for existing attachment state.
Resolve scripted and App Intent operations through that ownership, and
route non-confirming root closes directly through the immediate tab or
window close path so teardown always reaches the renderer.
2026-08-05 14:18:22 -07:00
Mitchell Hashimoto
7a047553c7 macos: avoid IOSurface leak on automated surface creation
Fixes #13444

A close while AppKit temporarily cleared/changed a surface's window would
leak the surface in the controller's pslit tree. This retained surface kept
a bunch of resources around, particularly large IOSurfaces.

This seems to only be reproducible under scripted load: rapid terminal
creation/destruction so that destruction happens just while there is a nil
window on a surface view.

Track surface ownership in a weak controller map updated alongside the split
tree, with validated fallbacks for existing attachment state. Resolve
scripted and App Intent operations through that ownership, and route
non-confirming root closes directly through the immediate tab or window close
path so teardown always reaches the renderer.
2026-08-05 13:39:48 -07:00
Mitchell Hashimoto
8696bef644 macos: guard fullscreen tab presentation
#13611

Route new-tab window presentation through an Objective-C exception catcher.

AppKit can raise an NSInternalInconsistencyException while selecting a
new tab in native fullscreen.

Catch the presentation exception, report it through the existing error
logging path, and leave Ghostty running when AppKit’s fullscreen window
stack is inconsistent.

This was pretty hard to reproduce but I was able to reproduce it about
1/3rd of the time via AppleScript automation...
2026-08-05 11:25:18 -07:00
Claude Fable 5
d02ad967b6 macOS: update command options match order
Matches are sorted in the following order:
leadingColor > title > subtitle > description.

Ranking is lexicographic on (colorScore, textScore)
2026-08-05 16:15:01 +02:00
Lukas
c93752a008 macOS: suppress restart tips for auto update 2026-08-05 15:15:40 +02:00