Commit Graph

1755 Commits

Author SHA1 Message Date
Akinori Musha
d60a16c146 macos: avoid replaying keys that commit preedit
Refs #10460
Related: #12518

When an input method commits all or part of marked text during keyDown,
AppKit returns the committed text through insertText. Treat that as
text committed by the input method instead of replaying the original key
event to the terminal.

Previously this path only handled arrow-key commits specially. A
control-key shortcut that commits preedit text could still be encoded as
the original control input after composition, such as ctrl+j becoming LF.

Send committed preedit text as a text-only event for any key that causes
the commit. Only replay arrow navigation keys that the existing Korean
IME handling expects, and keep plain left-arrow suppressed because AppKit
already leaves the caret in place.

AI usage: OpenAI Codex helped investigate, implement, test, and refine
this change. I reviewed and tested the resulting code.
2026-05-01 23:18:42 +09:00
Mitchell Hashimoto
4dcb09ada0 macos: suppress control-char input while composing (#12518)
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.

Refs #10460
Related: #2628, #4539
Vouched in #12169

Testing:
- xcodebuild test -scheme Ghostty -destination platform=macOS
-only-testing:GhosttyTests/SurfaceViewAppKitTests
- Manually tested Japanese IME control-key shortcuts on macOS

AI usage:
- OpenAI Codex helped investigate, implement, test, and refine this
change. I reviewed and tested the resulting code.
2026-04-30 06:48:58 -07:00
Mitchell Hashimoto
95b56eb525 macOS: fix focus state when toggling command palette from inline title editor (#12524)
A bug found while recording that menu fix.
> ~~Will link to an open issue if there is one.~~

When toggling the command palette from the inline title editor, the
first responder state of the surface is changed quickly from true to
false.

`makeFirstResponder:` is called by the title editor when finishing, but
it happens **after** the command palette is shown, so the `focused` is
set to `true` while the command palette is shown. (Could be an AppKit
issue as well, since the resign is not called after but the command
palette is receiving `keyDown`.)

Since `performKeyEquivalent(with:)` is called on all of the subviews
until one of the return `true` so the paste action is consumed by the
surface instead of the first responder (command palette).
2026-04-30 06:42:12 -07:00
Lukas
61595b5ec9 macOS: fix focus state when toggling command palette from inline title editor 2026-04-29 22:41:18 +02:00
Lukas
6fdca6bb53 macOS: enable copy only when there’s actual selected text 2026-04-29 19:33:09 +02: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
97c5a21aba macOS: fix ending search in menu bar does focus on surface 2026-04-27 19:03:06 +02:00
Lukas
1df7a5d3f3 macOS: update keybind for end_search 2026-04-27 18:55:31 +02: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
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
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
dobbylee
fa141a7262 Fix Korean IME committed text handling for arrow keys 2026-04-26 00:59:45 +09:00
Lukas
7c91cef28d config: use Config to check key binding instead of App
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.
2026-04-24 18:26:56 +02:00
Mitchell Hashimoto
7629c4ba84 macOS: fix command parsing in NewTerminalIntent (#12392)
Fixes #12391, regression from #10765
2026-04-23 06:34:54 -07:00
Lukas
b0b23f53a7 macOS: check abnormal-command-exit-runtime when process exits
Signed-off-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-04-23 11:35:51 +02:00
Lukas
a8ed37a791 macOS: fix command parsing in NewTerminalIntent
Fixes #12391, regression from #10765

Signed-off-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-04-23 11:35:34 +02:00
Mitchell Hashimoto
62fdd885e0 macOS: open preferred config if exists (#12321)
This helps developers like me to use a separate config for debugging
(which is already supported by the environment variable
`GHOSTTY_CONFIG_PATH`).

I can already use the local scheme to load a debugging config file, but
when opening the config file through Ghostty, it will still open the
default config.

This changes doesn't affect the release build, since `configPath` is
only set in the DEBUG build.
2026-04-21 09:23:29 -07:00
Mitchell Hashimoto
61363e80d1 macOS: fix App Icon update in Finder (#12344)
Looks like `NSWorkspace.shared.setIcon` can only be called from the main
App, DockTilePlugin is sandboxed and doesn't have the permission to
`file-write-finderinfo`.

<img width="1186" height="144" alt="image"
src="https://github.com/user-attachments/assets/e5ea4f1c-718c-493a-bda2-32787881881e"
/>


It works fine in debug, but not in release. This fixes #11489
2026-04-20 11:52:43 -07:00
Christo Wilken
9a9002202b macos: add pid and tty properties to AppleScript terminal class
Expose the foreground process PID and TTY device path as read-only properties on the AppleScript terminal class and App Intents TerminalEntity. This enables reliable process-to-terminal mapping for automation tools when multiple terminals share the same CWD.

Closes #11592
Closes #10756

Session: 019d341c-a165-7843-a2f7-2f426114cf17
2026-04-20 15:16:03 +02:00
Lukas
c7a73076e9 macOS: fix App Icon update in Finders
Looks like  `NSWorkspace.shared.setIcon` can only be called from the main App, DockTilePlugin is sandboxed and doesn't have the permission to `file-write-finderinfo`.

It works fine in debug, but not in release. This fixes #11489, #11290
2026-04-20 12:56:55 +02:00
Lukas
5939b8c1be macOS: fix 12266 by using the correct coordinates for the hitTest
Regression of #11872
2026-04-17 20:05:18 +02:00
Lukas
9bad9365b0 macOS: open preferred config if exists 2026-04-17 15:29:29 +02:00
Mitchell Hashimoto
ca7516bea6 macOS: move KeyStateIndicator on top of exit bar (#12282) 2026-04-16 20:33:48 -07:00
Lukas
b7d0be8e74 macOS: move KeyStateIndicator on top of exit bar 2026-04-14 19:55:46 +02:00
Lukas
858e856e2e macOS: fix shortcuts not showing on menu item for scroll_to_selection and search_selection
Incorrect link after 9b6a3be993 and 7d0157e69a
2026-04-14 19:21:16 +02:00
Lukas
6033c12790 macOS: reset menu shortcuts when its not updated 2026-04-13 19:59:20 +02:00
Lukas
fe8a6464b9 macOS: update MenuShortcutKey 2026-04-13 19:56:56 +02:00
Mitchell Hashimoto
4f36896ddb macOS: add bottom bar when child exits (#12251)
### Closes #7649

The bar lives alongside URL Hover in VStack at the bottom. The current
body of SurfaceView is becoming rather long and complicated, so this pr
also contains some refactors:

- Move URL Hover to a separate file

> The text is copied from previous input string to keep it consistent,
also I’m confused with text on GTK so this is my first choice, but it
can be changed as the same as GTK.

Separate prs will be opened for:
1. Set to Read-only after exits
2. Hide cursor when in Read-only

### Preview


https://github.com/user-attachments/assets/eb44e211-eac5-4f40-836c-4912b18dfb01
2026-04-13 06:47:47 -07:00
Lukas
073dd8a399 macOS: trim query before filtering commands 2026-04-13 12:47:48 +02:00
Lukas
2e169c42e8 macOS: Support initials matching in command palette search
Extend String.matchedIndices(for:) to fall back to initials
matching when no substring match is found. Typing the first letter
of each word now matches commands, e.g. "tbo" matches "Toggle
Background Opacity", with each matched initial highlighted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:47:47 +02:00
Lukas
2bdc6bb1f7 macOS: Highlight matching text in command palette search results
Add String.matchedIndices(for:) to find substring matches and use
it to bold and tint matched characters with the accent color in
both titles and subtitles. Title matches take priority — subtitles
are only highlighted when the title didn't match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:47:47 +02:00
Lukas
38e64c3706 macOS: add bottom bar when child exits 2026-04-13 10:08:13 +02:00
Lukas
c2a93db591 macOS: move url hover to a separate file 2026-04-13 08:18:11 +02:00
Mitchell Hashimoto
d2b79bea77 macOS: fix the arrow alignment of the secure input popover (#12249) 2026-04-12 13:16:15 -07:00
Mitchell Hashimoto
7f6d2a44b8 macOS: fix cannot rebind super+up and super+down (#12245)
Fix: #11989
Cause identified to: ab352b5af9
Original PR: #10003
Problem: I don't think it is OK to hard code the keybind like this at
all. Ghostty's config is flexible enough to achieve this.
Proposal: Revert the above commit via this PR.

@yasuf @bo2themax
2026-04-12 13:16:06 -07:00
Lukas
53019991f7 macOS: fix the arrow alignment of the secure input popover 2026-04-12 16:04:41 +02:00
Lukas
bf6fd4abe5 macOS: add focusDidChange & sizeDidChange placeholders to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
90ea604a7c macOS: move searchState to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
a541e23120 macOS: move surface to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
1665755a93 macOS: move highlighted to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
2efe851cda macOS: move readonly to OSSurfaceView 2026-04-12 14:23:45 +02:00
Lukas
3834751aef macOS: move surfaceSize to OSSurfaceView 2026-04-12 12:08:56 +02:00
Lukas
7c83561f9e macOS: move focusInstant to OSSurfaceView 2026-04-12 12:07:22 +02:00
Lukas
56b505cbb0 macOS: move keyTables to OSSurfaceView 2026-04-12 12:06:28 +02:00
Lukas
19af8e9ce2 macOS: move progressReport to OSSurfaceView 2026-04-12 12:04:09 +02:00
Lukas
8b99c77bf7 macOS: update title comments 2026-04-12 12:02:59 +02:00