Commit Graph

8131 Commits

Author SHA1 Message Date
Mitchell Hashimoto
cba82e976c macOS: Change Tab Title (#9879)
This adds the ability to change a _tab_ title. The previous
functionality was tied to a specific _surface_. A tab title will stick
to the current tab regardless of active splits and so on.

This follows the nomenclature that macOS terminal app does which is
"title vs terminal title" (although we explicitly use "tab" in various
places, I may remove that in the future).

**This is macOS only. GTK is tracked here: #9880**. I did macOS only
because thats the machine I'm on. It'll be trivial to add this to GTK,
too.

## Demo


https://github.com/user-attachments/assets/d9446785-d919-4212-8553-db50c56c8c2f

(The option is also in the main menu, the context menu, and the command
palette)

## AI Disclosure

This PR was done fully with Amp, I didn't write a single line of code at
the time of writing this PR description. I reviewed everything though
and fully understand it all. Its a mimic more or less of the prompt
surface title work (although we did unify some stuff like the apprt
action).
2025-12-11 16:53:50 -08:00
Mitchell Hashimoto
6105344c31 macos: add change tab title to right click menu 2025-12-11 16:30:06 -08:00
Mitchell Hashimoto
65cf124e2c core: change apprt action to enum value instead of a new one 2025-12-11 16:09:45 -08:00
Mitchell Hashimoto
32033c9e1a core: prompt_tab_title binding and apprt action 2025-12-11 16:03:19 -08:00
Jon Parise
c0deaaba4e bash: use a shell command for shell integration
Prior to #7044, on macOS, our shell-integrated command line would be
executed under exec -l, which causes bash to be started as a login
shell. This matches the macOS platform norms.

The change to direct command execution meant that we'd skip that path,
and bash would start as a normal interactive (non-login) shell on macOS.
We fixed this in #7253 by adding `--login` to the `bash` direct command
on macOS.

This avoided some of the overhead of starting an extra process just to
get a login shell, but it unfortunately doesn't quite match the bash
environment we get when shell integration isn't enabled (namely, $0
doesn't get the login-shell-identifying "-" prefix).

Instead, this change implements the approach proposed in #7254, which
switches the bash shell integration path to use a .shell command, giving
us the same execution environment as the non-shell-integrated command.
2025-12-11 17:02:14 -05:00
Devzeth
b224b69054 fix(terminal): increase grapheme_bytes instead of hyperlink_bytes during reflow
When reflowing content with many graphemes, the code incorrectly increased hyperlink_bytes capacity
instead of grapheme_bytes, causing GraphemeMapOutOfMemory errors.
2025-12-11 07:03:12 -08:00
Mitchell Hashimoto
86503045e9 fix: prevent integer overflow in hash_map layoutForCapacity (#9871)
Closes #9862
2025-12-11 06:57:23 -08:00
benodiwal
0d8c193bda fix(terminal): prevent integer overflow in hash_map layoutForCapacity
Co-Authored-By: Sachin <sachinbeniwal0101@gmail.com>
2025-12-11 16:43:16 +05:30
Mitchell Hashimoto
3352d5f081 Fix up close right description 2025-12-10 20:57:36 -08:00
Mitchell Hashimoto
cca10f3ca8 Revert GTK UI changes, apple-sdk build stuff 2025-12-10 20:20:37 -08:00
George Papadakis
625d7274bf Add close tabs on the right action 2025-12-10 20:14:27 -08:00
Mitchell Hashimoto
7642b8bec4 build: highway system integration should default to false 2025-12-10 13:13:38 -08:00
Mitchell Hashimoto
143748a8d3 Add system integration for highway (#9642) 2025-12-10 13:00:46 -08:00
Mitchell Hashimoto
af05397219 synthetic: make bytes generation more flexible (#9204) 2025-12-10 12:59:46 -08:00
Mitchell Hashimoto
581ed72efc gtk: support GTK 4.20 media queries in runtime & custom css (#9520) 2025-12-10 12:55:25 -08:00
Mitchell Hashimoto
b66e4dc2cb build: skip git version detection when used as dependency (#9850)
When ghostty is used as a Zig dependency, detect this by comparing the
build root with ghostty's source directory. Skip git detection entirely
and use the version from build.zig.zon.

This fixes build failures when downstream projects have git tags that
don't match ghostty's version format. Previously, ghostty would read the
downstream project's git tags and panic at Config.zig:246 with:

\`\`\`
tagged releases must be in vX.Y.Z format matching build.zig
\`\`\`

**Reproduction:**
1. Create a project that uses ghostty as a Zig dependency
2. Tag the project with a version like \`v0.2.0\`
3. Run \`zig build\` → panic

**Fix:**
Use \`@src().file\` to get ghostty's source directory and compare it
with \`b.build_root\`. When they differ, ghostty is a dependency and we
skip git detection.

Thread:
https://ampcode.com/threads/T-197e6c33-b8f8-4b23-8fc8-7f6b6edd9f35
2025-12-10 12:46:10 -08:00
Tim Culverhouse
05c704b247 build: skip git version detection when used as dependency
Detect if ghostty is being built as a dependency by comparing the build
root with ghostty's source directory. When used as a dependency, skip
git detection entirely and use the version from build.zig.zon.

This fixes build failures when downstream projects have git tags that
don't match ghostty's version format. Previously, ghostty would read
the downstream project's git tags and panic at Config.zig:246 with
"tagged releases must be in vX.Y.Z format matching build.zig".
2025-12-10 12:43:14 -08:00
Mitchell Hashimoto
3b31cef965 tmux: control mode core loop (no GUI connections yet) (#9860)
Related to #1935

This adds a new structure `terminal.tmux.Viewer` which continues
building on all the prior tmux control mode work to add a full
bidirectional reconciliation loop to discover and sync terminal states
from tmux to Ghostty and vice versa. **This is the core, cross-platform
business logic that will power the GUIs, later.**

Our prior work were protocol building blocks, and this PR is an actual
functional piece of work. You can now start Ghostty, run `tmux -CC
attach`, and we _will_ be creating full blown terminals internal that
capture the content and mirror the state exactly (barring inevitable
bugs in something this complex). But, we don't yet show them visually.
:) And we don't yet send inputs to it (it's a viewer only, for now).

**This sucked.** The control mode protocol is difficult, to put it
mildly, for a variety of reasons. Correctness of this is going to be
hard. Therefore, I focused really hard on this design to make it **fully
unit test friendly.** We're able to simulate full tmux sessions and runt
through our state machine and assert various states. I think this will
be critical to correctness as we eventually collect real world data.

> [!WARNING]
>
> This does actually have user-impacting changes! When you run `tmux -CC
attach` we will now run our full control mode client. This could result
in bugs or crashes or other problems. This only activates if you have a
real tmux session, though, so it should be avoidable by most users.
Since we don't actually take our state and send it to the GUI or
anything, this should be pretty safe.

**AI disclosure:** I used AI for a lot of the protocol reverse
engineering and documentation to figure out how it all works. I designed
the architecture myself and implemented most of it manually.
2025-12-10 12:40:58 -08:00
Mitchell Hashimoto
37f467c023 terminal/tmux: docs 2025-12-10 10:37:52 -08:00
Mitchell Hashimoto
b3e7c92263 fmt 2025-12-10 10:34:37 -08:00
Mitchell Hashimoto
29bb18d8cd terminal/tmux: grab tmux version on startup 2025-12-10 10:34:30 -08:00
Mitchell Hashimoto
58000f5821 terminal/tmux: build up pane states 2025-12-10 10:12:51 -08:00
Mitchell Hashimoto
bf46c4ebe7 terminal/tmux: many more output formats 2025-12-09 21:10:46 -08:00
Mitchell Hashimoto
4c30c5aa76 terminal/tmux: cleanup command queue logic 2025-12-09 20:31:51 -08:00
Mitchell Hashimoto
582ea5d84b terminal/tmux: window add 2025-12-09 20:07:08 -08:00
Mitchell Hashimoto
1a2b3c165a terminal/tmux: layoutChanged handling 2025-12-09 17:09:57 -08:00
Mitchell Hashimoto
071070faa3 terminal/tmux: handle session_changed inside command loop 2025-12-09 14:21:07 -08:00
Mitchell Hashimoto
64ef640127 terminal/tmux: exhaustive switch for command 2025-12-09 13:56:16 -08:00
Mitchell Hashimoto
938e419e04 terminal/tmux: handle output events 2025-12-09 13:13:52 -08:00
Mitchell Hashimoto
50ac848672 terminal/tmux: capture both primary/alt screen 2025-12-09 13:00:40 -08:00
Mitchell Hashimoto
a3e01581be terminal/tmux: history capture clears active area 2025-12-09 11:33:06 -08:00
Mitchell Hashimoto
b7fe9a926d terminal/tmux: capture visible area after history 2025-12-09 11:22:14 -08:00
Mitchell Hashimoto
41bf541005 terminal/tmux: test helper 2025-12-09 10:53:52 -08:00
Mitchell Hashimoto
e1e2791fb7 terminal/tmux: pane_history replays it into terminal 2025-12-09 10:00:43 -08:00
Mitchell Hashimoto
f02a2d5eed terminal/tmux: capture pane 2025-12-09 09:25:55 -08:00
Leah Amelia Chen
cf06417b7d gtk: fix xkb mapping not working in Linux (#9454) 2025-12-09 12:58:44 +08:00
Mitchell Hashimoto
766c306e04 terminal/tmux: pane history 2025-12-08 20:15:20 -08:00
Mitchell Hashimoto
ea09d257a1 terminal/tmux: initialize panes 2025-12-08 11:54:48 -08:00
Mitchell Hashimoto
86cd489701 terminal/tmux: introduce command queue for viewer 2025-12-08 09:00:38 -08:00
Mitchell Hashimoto
ec5a60a119 terminal/tmux: make sure we always have space for one action 2025-12-08 07:27:37 -08:00
Mitchell Hashimoto
b26c42f4a6 terminal/tmux: better formatting for notifications and actions 2025-12-08 07:00:44 -08:00
Mitchell Hashimoto
52dbca3d26 termio: hook up tmux viewer 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
3cbc232e31 terminal/tmux: return allocated list of actions 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
c1d686534e terminal/tmux: list windows 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
4c3ef8fa13 terminal/tmux: viewer list windows state 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
0d75a78747 terminal/tmux: start viewer state machine 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
af3a11b546 terminal/tmux: output has format/comptimeFormat 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
049b8826f6 macos: make QuickTerminalSize config C ABI compatible (#9837)
Hello! I did read `CONTRIBUTING.md`. I understand that the preference is
to receive pull requests for existing open issues and acknowledge that
I'm skipping a step wrt the preferred workflow since there aren't any
open issues yet for #8419. Living dangerously and hoping for the best
here. I hope you'll see that I'm acting in good faith 🤞.

In my attempts to debug why `quick-terminal-size` config wasn't working
reliably for me, I discovered that the
[`ghostty_config_quick_terminal_size_s`](08c9661683/include/ghostty.h (L460-L480))
struct used to initialize `QuickTerminalSize` in Swift-land, more often
than not, didn't match what I had in my config file (e.g.
`quick-terminal-size = 75%, 50%`)

<details>


08c9661683/include/ghostty.h (L460-L480)


08c9661683/macos/Sources/Ghostty/Ghostty.Config.swift (L507-L510)

</details>

Almost all mismatches seemed to be downstream of `tag` (for `primary`
and/or `secondary` `Size`) being an unexpected value for the
`ghostty_quick_terminal_size_tag_e` enum type, which led runtime
execution to fall into the `default` branch in this `switch` control
flow.


08c9661683/macos/Sources/Features/QuickTerminal/QuickTerminalSize.swift (L27-L38)

Looking at `src/config/CApi.zig`, `src/config/c_get.zig`,
`src/config/Config.zig`, and [Zig documentation for `extern
enum`](https://ziglang.org/documentation/master/#extern-enum), led me to
conclude that the crux of the issue is lack of guaranteed C ABI
compatibility for `Tag`


08c9661683/src/config/Config.zig (L7986-L7990)


08c9661683/include/ghostty.h (L461-L465)

Further research revealed that based on C language spec alone, one
cannot assume a fixed width for `enum` and that the behaviour is
compiler dependant. But given how the Zig documentation suggests using
`enum(c_int)` for C-ABI-compatible enums and extern enums + comments
elsewhere in `Config.zig` suggesting that `enum(c_int)` was chosen for
extern compatibility,


08c9661683/src/config/Config.zig (L4877)

I think that this fix (changing `enum(u8)` to `enum(c_int)`) is likely
the most straightforward and appropriate one.
2025-12-08 07:00:16 -08:00
Mitchell Hashimoto
9cd96e4b64 quirks: remove type signature for inlineAssert (#9843)
Functions with different calling conventions are not compatible with
each other

Fixes all release builds + CI
2025-12-07 21:57:48 -08:00
Leah Amelia Chen
2ac9e03c52 quirks: remove type signature for inlineAssert
Functions with different calling conventions are not compatible with
each other

Fixes all release builds + CI
2025-12-08 13:19:16 +08:00