Commit Graph

16303 Commits (main)

Author SHA1 Message Date
Jon Parise 13ada38ac4 os: RANDOM_BASENAME_LEN -> random_basename_len 2026-04-25 16:29:25 -04:00
Mitchell Hashimoto e9ca0f8c9a
core: Acquire renderer state mutex before calling processLinks (#12463)
Holding the renderer state mutex is a documented precondition of
`processLinks`, but `mouseButtonCallback` previously called the function
without the mutex.

This creates a race with the I/O thread's `processOutput`, which can
prune scrollback pages while `processLinks` is reading them, resulting
in a use-after-free segfault. See
https://github.com/ghostty-org/ghostty/discussions/12409 (Linux: crash
while selecting text).


57b5e1e250/src/Surface.zig (L4354-L4355)


57b5e1e250/src/Surface.zig (L3822-L3824)

995e4e375 (os: open) changed the body of `processLinks` to be
non-trivial and documented the precondition, but the lock was not held
at the call site.
2026-04-25 13:21:38 -07:00
Mitchell Hashimoto 0e0bcafed5
macOS: remove manual invalidateRestorableState() (#12464)
This should be safe to delete now after #12461.

I tested saving 27 tabs, 4 with 2 splits,
`TerminalRestorable.encode(with:` finished successfully.

And I check the breakpoints when the Sparkle sends
`-[NSRunningApplication treminate]`. The call stack at `-[NSResponder
invalidateRestorableState]` is pretty much the same as quitting via
`cmd+q`.
2026-04-25 13:16:08 -07:00
Mitchell Hashimoto aedf39f3bd
macOS: support migrations when restoring window state (#12461)
First two commits fix the issue when upgrading from 1.2.x to 1.3.x.
(#11304)

> To double check if this pr really fixes the issue, you can either
archive a release build, sign with the same profile, and override
manually.
> 
> Or you can find the `savedState` files (located in `~/Library/Daemon\
Containers/<uuid>`), can copy them the local build dir (which is what I
did), and run the debug build.

Following commits add tests for migrations and some logs.

**Currently the minimum version is set to 1.2.x**, since there's a lot
changes comparing to 1.1.x. It will be difficult to restore
`Ghostty.SplitNode` -> `SplitTree<Ghostty.SurfaceView>` without
introducing a lot of checks.
2026-04-25 13:15:50 -07:00
Mitchell Hashimoto 8e1dfbcf3e
os: add randomTmpPath for allocating temp paths (#12465)
Factor TempDir's name generation into a reusable `randomBasename` (16
random bytes, url-safe base64) and add `randomTmpPath` on top, which
composes `allocTmpDir` + `randomBasename` into a single allocated path
in the form `{TMPDIR}/{prefix}{random}` (`mktemp(1)`-ish).

This is convenient for callers who want a unique path under TMPDIR (for
a temporary file, socket, etc.) without having to think about basename
buffer sizing or path joining.

Also, use `std.base64.url_safe_no_pad.Encoder` instead of the custom
base64 alphabet, which is exactly equivalent.
2026-04-25 13:14:30 -07:00
Jon Parise c9d2285f63 os: add randomTmpPath for allocating temp paths
Factor TempDir's name generation into a reusable `randomBasename` (16
random bytes, url-safe base64) and add `randomTmpPath` on top, which
composes `allocTmpDir` + `randomBasename` into a single allocated path
in the form `{TMPDIR}/{prefix}{random}` (mktemp(1)-ish).

This is convenient for callers who want a unique path under TMPDIR (for
a temporary file, socket, etc.) without having to think about basename
buffer sizing or path joining.

Also, use `std.base64.url_safe_no_pad.Encoder` instead of the custom
base64 alphabet, which is exactly equivalent.
2026-04-25 15:52:40 -04:00
Lukas 385376185c
macOS: remove manual invalidateRestorableState() 2026-04-25 21:25:38 +02:00
Lukas 231f6f4c75
macOS: move the restoration logs 2026-04-25 21:06:20 +02:00
Lukas 72c03e7fb8
macOS: add window restoration tests 2026-04-25 21:06:20 +02:00
Lukas bfe07bb99e
macOS: add InternalState to cover migrations 2026-04-25 20:25:17 +02:00
Lukas 5b89671d51
macOS: make terminal restorable state compatible with 1.2.3(v5) 2026-04-25 20:22:59 +02:00
Lukas 8ebf4f70e5
macOS: make tab color optional 2026-04-25 20:09:55 +02:00
Mitchell Hashimoto b613ffcfd8
surface: respect semantic prompt boundaries for links (#12435)
Link detection currently expands the clicked location to a full line
before running the configured regexes. When semantic prompt markers are
present, this can cause prompt text and neighboring content to be
matched together even though they are distinct semantic regions.

Use semantic prompt boundaries when selecting the text to inspect for
link matching. This keeps prompt text separate from the content beside
it and avoids folding prompt text into double-click link/path selection.

Add a regression test that models a prompt and command on the same line
and verifies the prompt region and input region remain separate.

----

this is a fix for the issue users reported in
https://github.com/ghostty-org/ghostty/discussions/11415

**disclaimer**: I used codex addon within Cursor to research this
bug/regression and find a proper fix for it.
2026-04-25 10:32:15 -07:00
Vasyl Zuziak c4a671ba5a fix: remove test as has been suggested in comment 2026-04-25 19:26:22 +02:00
Mitchell Hashimoto c5c3cf16ba
feat: add GTK keybinds (matching the idiomatic Linux convention used by Firefox, GNOME Terminal, and VSCode) for move_tab (#12458)
> Re-submitting #11857, which was auto-closed pre-vouch. I'm now in the
vouched list.

## Summary

Adds default keybinds for `move_tab` on GTK/Linux, matching the
idiomatic Linux convention used by Firefox, GNOME Terminal, and VSCode:

- **`Ctrl+Shift+PageUp`** → `move_tab:-1` (move tab left)
- **`Ctrl+Shift+PageDown`** → `move_tab:1` (move tab right)

To free these keys, `jump_to_prompt` is reassigned to `Ctrl+Shift+Arrow
Up/Down`, which:
- Mirrors the macOS default (`Cmd+Shift+Arrow Up/Down`)
- Is currently unbound on GTK
- Maintains directional consistency (up = previous, down = next)

The new `move_tab` bindings use `putFlags` with `performable: true` to
match the pattern used by other tab actions (`previous_tab`,
`next_tab`).

Closes #4998

## Changes
- `src/config/Config.zig`: Reassign `jump_to_prompt` from
`Ctrl+Shift+PageUp/PageDown` to `Ctrl+Shift+Arrow Up/Down` (GTK only)
- `src/config/Config.zig`: Add `move_tab` default keybinds as
`Ctrl+Shift+PageUp/PageDown` (GTK only)

## Test plan
- [ ] Build on Linux/GTK: `zig build`
- [ ] Verify `Ctrl+Shift+PageUp` moves current tab left
- [ ] Verify `Ctrl+Shift+PageDown` moves current tab right
- [ ] Verify `Ctrl+Shift+Arrow Up` jumps to previous prompt
- [ ] Verify `Ctrl+Shift+Arrow Down` jumps to next prompt
- [ ] Verify `Ctrl+PageUp/PageDown` still switches tabs (unchanged)
- [ ] Verify macOS keybinds are unaffected
2026-04-25 10:10:33 -07:00
ghostty-vouch[bot] c9ba2b2afa
Update VOUCHED list (#12457)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11628#discussioncomment-16712930)
from @mitchellh.

Denounce: @4RH1T3CT0R7

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:54:04 +00:00
Enzo William 14c06312d5 feat: add default GTK keybinds for move_tab
Reassign jump_to_prompt from Ctrl+Shift+PageUp/PageDown to
Ctrl+Shift+Arrow Up/Down on GTK, freeing the idiomatic Linux
keybinds (Ctrl+Shift+PageUp/PageDown) for move_tab.

This matches the tab-moving keybinds used by Firefox, GNOME Terminal,
and VSCode. The new jump_to_prompt binding mirrors the macOS pattern
(Cmd+Shift+Arrow Up/Down).

Closes #4998

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 13:53:37 -03:00
ghostty-vouch[bot] 4d1bb9efe4
Update VOUCHED list (#12456)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11685#discussioncomment-16712917)
from @mitchellh.

Denounce: @enkr1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:52:41 +00:00
Mitchell Hashimoto df4f981592
Fix Korean IME committed text handling for arrow keys (#12447)
Fixes #11461

- Send Korean IME committed text as a separate text-only key event when
arrow-key handling commits preedit text.
- Replay arrow navigation after the committed text is sent. Do not
replay plain Left Arrow to match Terminal.app behavior.
- Manually tested Arrow keys and Opt/Cmd+Arrow during Korean preedit on
macOS.
2026-04-25 09:47:37 -07:00
ghostty-vouch[bot] 03e08f0c89
Update VOUCHED list (#12455)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11795#discussioncomment-16712869)
from @mitchellh.

Vouch: @bch

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:46:35 +00:00
ghostty-vouch[bot] 5a3b0c9c49
Update VOUCHED list (#12454)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11858#discussioncomment-16712861)
from @mitchellh.

Vouch: @enzowilliam

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:45:31 +00:00
ghostty-vouch[bot] e0c71dd41b
Update VOUCHED list (#12453)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11882#discussioncomment-16712859)
from @mitchellh.

Vouch: @mpatankar6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:45:08 +00:00
ghostty-vouch[bot] 0e707ba3f6
Update VOUCHED list (#12452)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11975#discussioncomment-16712831)
from @mitchellh.

Vouch: @rightaditya

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:43:11 +00:00
ghostty-vouch[bot] 51590ad7f1
Update VOUCHED list (#12451)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11993#discussioncomment-16712826)
from @mitchellh.

Vouch: @VoidNV

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:42:24 +00:00
Mitchell Hashimoto 69452b5c6f
Sync middle-click paste with copy-on-select (#12443)
Implements the behavior from #9788.

Today, middle-click paste always reads from the selection clipboard (or
the
system clipboard on platforms without a selection clipboard). With this
change
it follows `copy-on-select`:

- `true`: selection clipboard (unchanged)
- `clipboard`: system clipboard
- `false`: selection clipboard (also unchanged, preserves traditional
X11
  middle-click behavior)

The idea is symmetry: if `copy-on-select = clipboard` writes selections
to the
system clipboard, middle-click should come back from there too.

Also updated the config doc comment, which previously claimed
middle-click
"will always use the selection clipboard".

### Testing

`zig build test` passes locally (macOS, Zig 0.15.2).

Built and runtime-tested via the fork's CI:
https://github.com/007hacky007/ghostty/actions/runs/24707475544 - I'm
running the resulting binary daily and the three `copy-on-select` modes
behave as described above.
2026-04-25 09:39:12 -07:00
Mitchell Hashimoto 2dee1f1a3f
Update VOUCHED list (#12445)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12263#discussioncomment-16712767)
from @mitchellh.

Vouch: @thoutbeckers
2026-04-25 09:36:41 -07:00
ghostty-vouch[bot] ee81a6e1c6
Update VOUCHED list (#12450)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12108#discussioncomment-16712799)
from @mitchellh.

Vouch: @lebdron

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:36:12 +00:00
ghostty-vouch[bot] 4c046efbb1
Update VOUCHED list (#12449)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12141#discussioncomment-16712795)
from @mitchellh.

Vouch: @AkimioJR

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:35:39 +00:00
ghostty-vouch[bot] e0d0fbe0ad
Update VOUCHED list (#12448)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12169#discussioncomment-16712790)
from @mitchellh.

Vouch: @knu

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:34:38 +00:00
ghostty-vouch[bot] 8c3db43c86
Update VOUCHED list (#12446)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12272#discussioncomment-16712769)
from @mitchellh.

Vouch: @dkinzler

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:31:04 +00:00
github-actions[bot] e72774f2ab Update VOUCHED list
https://github.com/ghostty-org/ghostty/discussions/12263#discussioncomment-DC_kwDOHFhdAs4A_wQ_
2026-04-25 16:30:38 +00:00
ghostty-vouch[bot] fc7a064e80
Update VOUCHED list (#12444)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12305#discussioncomment-16712760)
from @mitchellh.

Vouch: @aaron-ang

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:29:37 +00:00
ghostty-vouch[bot] 119f3875d4
Update VOUCHED list (#12442)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12435#issuecomment-4320055303)
from @mitchellh.

Vouch: @ZuBB

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:26:24 +00:00
ghostty-vouch[bot] 667d467e24
Update VOUCHED list (#12441)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11987#discussioncomment-16712733)
from @mitchellh.

Vouch: @nouritsu

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:25:26 +00:00
ghostty-vouch[bot] c21ba8d826
Update VOUCHED list (#12440)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11632#discussioncomment-16712730)
from @mitchellh.

Vouch: @ajiblock

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:24:52 +00:00
Mitchell Hashimoto 8e2a13cb60
gtk/SurfaceScrolledWindow: wrap root child with another Adw.Bin (#12426)
Due to a known Gtk issue, the scrolled_window at the root of the
template is free-ed twice on dispose. This causes crashes when used with
GNOME 49 platform (Gtk 4.20, libadwaita 1.8.5).

Workaround this issue by wrapping the root child in another Adw.Bin,
similar to widgets like ResizeOverlay.

LLM was used to perform discovery against a manually recorded Valgrind
trace, and helped tracking down known fixes for this problem. The
comment in code was taken from another instance in the repository.

Fixes https://github.com/ghostty-org/ghostty/discussions/12306

Assisted-by: OpenAI GPT-5.4
2026-04-25 09:22:59 -07:00
ghostty-vouch[bot] b3d4f51ca7
Update VOUCHED list (#12439)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12347#discussioncomment-16712718)
from @mitchellh.

Vouch: @rjwittams

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:22:38 +00:00
ghostty-vouch[bot] 74045cc5d8
Update VOUCHED list (#12438)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12354#discussioncomment-16712711)
from @mitchellh.

Vouch: @007hacky007

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:21:57 +00:00
ghostty-vouch[bot] 98fb58b326
Update VOUCHED list (#12437)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12295#discussioncomment-16712704)
from @mitchellh.

Vouch: @dobbylee

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 16:20:20 +00:00
Leorize 560b7ba8e8 gtk/SurfaceScrolledWindow: wrap root child with another Adw.Bin
Due to a known Gtk issue, the scrolled_window at the root of the
template is free-ed twice on dispose. This causes crashes when used with
GNOME 49 platform (Gtk 4.20, libadwaita 1.8.5).

Workaround this issue by wrapping the root child in another Adw.Bin,
similar to widgets like ResizeOverlay.

LLM was used to perform discovery against a manually recorded Valgrind
trace, and helped tracking down known fixes for this problem.

Fixes https://github.com/ghostty-org/ghostty/discussions/12306

Assisted-by: OpenAI GPT-5.4
2026-04-25 09:18:21 -07:00
Mitchell Hashimoto 98d14aa66b
flatpak: update runtime to GNOME 50 (#12428)
Notable dependency changes:

- GTK: `4.20.4` -> `4.22.2`
- libadwaita: `1.8.5` -> `1.9.0`
2026-04-25 09:15:20 -07:00
dobbylee fa141a7262 Fix Korean IME committed text handling for arrow keys 2026-04-26 00:59:45 +09:00
ghostty-vouch[bot] c47a8091f1
Update VOUCHED list (#12436)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12409#discussioncomment-16712208)
from @00-kat.

Vouch: @jmr

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 14:51:36 +00:00
Jesse Rosenstock 28f4676b5d core: Acquire renderer state mutex before calling processLinks
Holding the renderer state mutex is a documented precondition of
`processLinks`, but `mouseButtonCallback` previously called
the function without the mutex.

This creates a race with the I/O thread's `processOutput`, which can
prune scrollback pages while `processLinks` is reading them, resulting
in a use-after-free segfault.  See
https://github.com/ghostty-org/ghostty/discussions/12409 (Linux: crash
while selecting text).

57b5e1e250/src/Surface.zig (L4354-L4355)

57b5e1e250/src/Surface.zig (L3822-L3824)

995e4e375 (os: open) changed the body of `processLinks` to be
non-trivial and documented the precondition, but the lock was not held
at the call site.
2026-04-25 16:36:45 +02:00
Vasyl Zuziak 85dc4b1842 surface: respect semantic prompt boundaries for links
Link detection currently expands the clicked location to a full line
before running the configured regexes. When semantic prompt markers
are present, this can cause prompt text and neighboring content to be
matched together even though they are distinct semantic regions.

Use semantic prompt boundaries when selecting the text to inspect for
link matching. This keeps prompt text separate from the content beside
it and avoids folding prompt text into double-click link/path
selection.

Add a regression test that models a prompt and command on the same
line and verifies the prompt region and input region remain separate.
2026-04-25 15:46:25 +02:00
Leorize 6fb86a819e
flatpak: update runtime to GNOME 50 2026-04-25 00:17:39 -07:00
ghostty-vouch[bot] 57b5e1e250
Update VOUCHED list (#12425)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12308#discussioncomment-16709130)
from @jcollie.

Vouch: @alaviss

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-25 05:45:32 +00:00
Mitchell Hashimoto 4ceeba4851
config: use Config to check key binding instead of App (#12415)
Previously `ghostty_app_key_is_binding` (unlike Surface) is just using
`config.keybind` to check whether a KeyEvent is in the set or not.

After this, I can add unit tests for keybinding more easily with dummy
configs.

I didn't find any usages of this in GTK, so it shouldn't affect
anything. ci will see if this is the case:)
2026-04-24 14:51:22 -07:00
Mitchell Hashimoto d35f02d83c
build: respect config.emit_xcframework for building libghostty-vt.xcframework on Darwin (#12267)
This fixes a hardcoded build issue on macOS where Zig unconditionally
forces xcodebuild -create-xcframework to run during compilation, even
when the caller explicitly specifies that they only want the raw
standard C objects/headers (-Demit-lib-vt).
2026-04-24 13:48:51 -07:00
Mitchell Hashimoto 5f892b691b
ci: fix 2026-04-24 13:39:45 -07:00