41 Commits

Author SHA1 Message Date
Mitchell Hashimoto
f815f84594 macos: fix quick terminal restoring stale size after display reconnect (#13250)
"Why is my quick terminal not taking up the entire top of my docked Mac
screen after I reconnect?" Boy howdy are you in the right PR.

It turns out that the quick terminal caches its last-closed window frame
per display so it can restore the user's size when reopened. The cache
entry was considered valid whenever the current screen was the same size
*or larger* than when the frame was saved ("persist when screens grow").
This has led to a pattern that was simply maddening. To wit: that rule
breaks across display changes.

When an external display is disconnected and later reconnected at a
different resolution (common after traveling with a laptop, do not even
get me started on projectors) the same display can come back larger than
when the frame was cached. The stale frame is still treated as valid and
restored, so the quick terminal no longer fills the screen (it appears
at a partial width/height). Because the cache is persisted, restarting
Ghostty does not clear it, and the user is slowly driven mad. Welcome to
madness; we have snacks.

This PR addresses this by treating a cached frame as valid when the
screen geometry matches exactly (both backing scale factor and frame
size). On any mismatch we drop the entry and fall back to the configured
quick-terminal-size. Manual resizes are still remembered across toggles
within a stable display configuration.

Fixes the regression reported in #12348.

AI disclaimer: I used AI for this. Of course I used AI for this, my code
is terrible on a good day. Specifically, Claude Code, as well as a
custom harness that has the curious tendency to write commit messages
containing conspiracy theories about the code because I am history's
greatest monster.

Fight me!
2026-07-08 10:49:39 -07:00
Claude Fable 5
acd09c0a6c macos: add tests for NSPasteboard.getOpinionatedStringContents 2026-07-03 12:53:34 +02:00
Corey Quinn
0274e7ad84 macos: fix quick terminal restoring stale size after display reconnect
The quick terminal caches its last-closed window frame per display so it
can restore the user's size when reopened. The cache entry was considered
valid whenever the current screen was the same size *or larger* than when
the frame was saved ("persist when screens grow"). This has led to a pattern
that was simply maddening. To wit:

That rule breaks across display changes. When an external display is
disconnected and later reconnected at a different resolution (common
after traveling with a laptop) the same display can come back larger
than when the frame was cached. The stale frame is still treated as valid
and restored, so the quick terminal no longer fills the screen (it appears
at a partial width/height). Because the cache is persisted, restarting
Ghostty does not clear it, and the user is slowly driven mad.

Only treat a cached frame as valid when the screen geometry matches
exactly (both backing scale factor and frame size). On any mismatch we
drop the entry and fall back to the configured quick-terminal-size. Manual
resizes are still remembered across toggles within a stable display
configuration.

Fixes the regression reported in #12348.
2026-06-29 15:31:07 -07:00
Nolin McFarland
bf716a0c39 feat: add extension to normalize OSPasteboard string interface 2026-05-18 10:12:26 -04:00
Nolin McFarland
69cab3d808 feat: select needle when reading from pasteboard 2026-05-17 11:26:32 -04:00
Nolin McFarland
8fa42c6ec0 feat: add search state unit tests 2026-05-16 20:05:11 -04:00
Akinori Musha
a43cc02ebd macos: suppress control-char input while composing
When AppKit delivers a single C0 control character during
marked-text composition, Ghostty should treat it as input consumed by
the composing state instead of forwarding it to the terminal.

This prevents control-key IME actions, such as Japanese input
shortcuts like ctrl+h/j/m/n, from leaking into the terminal while
composition is still active. Printable text and non-composing control
input continue through the normal key path.

AI usage: OpenAI Codex helped investigate, implement, test, and refine
this change. I reviewed and tested the resulting code.
2026-04-29 22:50:35 +09:00
Lukas
72c03e7fb8 macOS: add window restoration tests 2026-04-25 21:06:20 +02:00
Lukas
fe8a6464b9 macOS: update MenuShortcutKey 2026-04-13 19:56:56 +02:00
Lukas
18f2702225 macOS: fix Find Next/Previous button in the menu bar is not working as expected 2026-04-02 20:31:31 +02:00
Lukas
702a2b43c3 macOS: fix upper cased letter is not correctly mapped to menu shortcut 2026-04-01 14:50:53 +02:00
Lukas
1845dd26b6 macOS: extract menu shortcut syncing into MenuShortcutManager 2026-03-30 16:09:21 +02:00
Lukas
65cd31dc79 macOS: add NormalizedMenuShortcutKeyTests 2026-03-30 15:47:07 +02:00
Lukas
5c5f645b61 macOS: support reloading temporary config for testing 2026-03-30 15:47:07 +02:00
Lukas
90dc4315e2 macos: add test cases for Ghostty.Config properties
Test boolean, string, enum, and numeric config properties using
TemporaryConfig to verify defaults and parsed values.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-10 20:03:17 +01:00
Lukas
32934445cf macos: add TemporaryConfig for AI to write test cases 2026-03-10 19:45:52 +01:00
Mitchell Hashimoto
71f81527ad macos: remove IntrinsicSizeTimingTests temporarily
These were too flaky.
2026-03-10 11:08:47 -07:00
Lukas
de0f2ab22d macos: add enum type for macos-titlebar-style 2026-03-10 17:15:14 +01:00
Lukas
a6cd1b08af macOS: fix intrinsicContentSize race in windowDidLoad (#11256)
Add initialContentSize fallback on TerminalViewContainer so
intrinsicContentSize returns the correct value immediately,
without waiting for @FocusedValue to propagate. This removes
the need for the DispatchQueue.main.asyncAfter 40ms delay.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:35:49 +01:00
Lukas
cfedda1a0e macOS: add regression tests for intrinsicContentSize race (#11256)
Tests that validate intrinsicContentSize returns a correct value when
TerminalController.windowDidLoad() reads it. Currently fail, proving
the race condition where @FocusedValue hasn't propagated
lastFocusedSurface before the 40ms timer fires.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:27:38 +01:00
Jon Parise
a716b9c4d4 macos: Ghostty.Shell.escape unit tests 2026-03-04 11:00:03 -05:00
Lukas
df53f75ad1 macOS: refine window tint for liquid glass (#11018)
Depends on #11030

- Update constraints of `TerminalGlassView`
- Use `TerminalViewContainer.DerivedConfig` to map styling properties
- Add TerminalViewContainerTests
- Instead of using delay, now the view updates are explicitly called by
window controllers
2026-02-27 10:49:12 -08:00
Mitchell Hashimoto
eaf7d8a012 macos: icon tests 2026-02-24 10:26:13 -08:00
Lukas
c72788894e ci: fix linting and delete non-useful tests 2026-02-24 10:13:24 +01:00
Lukas
45525a0a85 macOS: use NSDockTilePlugIn to update app icons 2026-02-24 08:58:14 +01:00
Jon Parise
b532cd55d6 macos: swiftlint 'trailing_whitespace' rule 2026-02-19 18:56:43 -05:00
Pieter Ouwerkerk
ce66bea581 Move MockView to SplitTreeTests itself 2026-02-17 09:37:02 -08:00
Pieter Ouwerkerk
8fdedbce45 Add MockView and SplitTreeTests 2026-02-16 20:23:48 -08:00
Jon Parise
df6feba417 macos: rename shellQuoted() to Ghostty.Shell.quote()
We already had an established Ghostty.Shell namespace (previously a
struct; now a more idiomatic enum), and locating these functions next to
each other makes it clearer how they relate to one another.
2026-02-16 15:27:57 -05:00
Jon Parise
1ff0dd821f macos: quote input strings used for shell commands
When we're building an input string that's explicitly meant to be used
as a shell command, quote (escape) it using the same logic as Python's
shlex.quote function.

This specifically addresses issues we've seen when open(1)'ing Ghostty
with filename arguments that contain spaces.
2026-02-05 09:21:37 -05:00
Mitchell Hashimoto
1b1ff3d76c macos: add some unit tests 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
791d8f8200 macos: add a "restart later" option to the installing state 2025-11-11 07:27:03 -08:00
Lukas
7e3aba7c99 macOS: remove readyToInstall state in update capsule
There is a sparkle-related 'issue' with the previous implementation. When you download/install in the `updateAvailable` state, if you don't install it, then check the updates again. Sparkle loses its downloaded stage in the delegate (it's normal when I use the sparkle source code). This time, when you click install in the `updateAvailable` state, it just uses the previous downloaded package and starts to install, without calling `showReady(toInstallAndRelaunch:)`.

I think removing `readyToInstall` in our customed ui, will reduce one step to install an update for most of the users out there, which makes sense, since the current package is pretty small, only takes a few seconds to download for a normal network, and they intended to install this update.
2025-11-09 20:24:24 +01:00
Mitchell Hashimoto
0f1c46e4a4 macos: support setting multiple clipboard content types 2025-10-30 14:01:58 -07:00
Mitchell Hashimoto
6eb26da3b7 macos: fix failing xcode tests 2025-10-14 06:55:10 -07:00
Mitchell Hashimoto
8f1a014afd macos: clean up the "installing" update state (#9170)
This includes multiple changes to clean up the "installing" state:

- Ghostty will not confirm quit, since the user has already confirmed
they want to restart to install the update.
- If termination fails for any reason, the popover has a button to retry
restarting.
- The copy and badge symbol have been updated to better match the
reality of the "installing" state.

<img width="1756" height="890" alt="CleanShot 2025-10-12 at 15 04 08@2x"
src="https://github.com/user-attachments/assets/1b769518-e15f-4758-be3b-c45163fa2603"
/>

AI written:
https://ampcode.com/threads/T-623d1030-419f-413f-a285-e79c86a4246b fully
understood.
2025-10-12 15:20:26 -07:00
Mitchell Hashimoto
bac2419343 macos: fix unit tests for notFound change 2025-10-10 09:45:34 -07:00
Mitchell Hashimoto
47f3c94640 macos: many more unit tests for update work 2025-10-10 08:34:45 -07:00
Mitchell Hashimoto
49eb65df77 macos: show release notes link 2025-10-08 22:05:03 -07:00
Mitchell Hashimoto
773990ada3 macos: window-position-x/y are from top-left corner
Fixes #8672

Almost fully written by AI: https://ampcode.com/threads/T-86df68a3-578c-4a1c-91f3-788f8b8f0aae

I reviewed all the code.
2025-09-18 12:18:13 -07:00
Mitchell Hashimoto
9fa26387ef build: zig build test runs Xcode tests on macOS
Related to #7879

This commit updates `zig build test` to run Xcode tests, too. These run
in parallel to the Zig tests, so they don't add any time to the test.

The Xcode tests will _not_ run when: (1) the target is not macOS, or (2)
the `-Dtest-filter` option is non-empty. This makes it so that this
change doesn't affect non-macOS and doesn't affect the general dev cycle
because you usually will run `-Dtest-filter` when developing a core
feature.

I didn't add a step to only run Xcode tests because I find that when I'm
working in Xcode I'm probably going to run the tests from there anyways.
The integration with `zig build test` is just a convenience, especially
around CI.

Speaking of CI, this change also makes it so this will run in CI.
2025-07-10 21:08:51 -07:00