@vibecook/ghosttea-react 0.13.2 → 0.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,12 @@
1
- import type { SessionSummary, TerminalScrollbarState } from "@vibecook/ghosttea-protocol";
1
+ import type { KeyboardEvent } from "react";
2
+ import type { SessionSummary, TerminalKeyEvent, TerminalScrollbarState } from "@vibecook/ghosttea-protocol";
3
+ import { terminalKeyUp } from "./keyboard-input.js";
4
+ import { type TerminalEffect } from "./bindings/action-route.js";
5
+ import { type ResolvedTerminalBinding } from "./terminal-bindings.js";
2
6
  import type { GhosttyBindingEntry } from "./bindings/ghostty-bindings.js";
7
+ import { type KeyEventLike } from "./bindings/ghostty-triggers.js";
3
8
  import { type CellPoint, type TerminalEffects, type TerminalTheme } from "./renderers/types.js";
9
+ import { TerminalTextInput, type TerminalTextInputAction, type TerminalTextKeyEventLike } from "./text-input.js";
4
10
  import type { GhostteaTerminalRuntime } from "./runtime.js";
5
11
  export type TerminalMenuAction = "copy" | "paste" | "select-all" | "clear-screen";
6
12
  export type TerminalInputPolicy = "inherit" | "read-only";
@@ -46,6 +52,134 @@ export declare function syncSurfaceFocus(runtime: Pick<GhostteaTerminalRuntime,
46
52
  cols: number;
47
53
  rows: number;
48
54
  }, focused: boolean, wasFocused: boolean, policy: SurfaceFocusPolicy): void;
55
+ /**
56
+ * Who takes a keydown on the surface, in order: the text system when an IME or
57
+ * another text service processed it (its result arrives as composition or
58
+ * input events, so the terminal neither encodes nor prevents it), a terminal
59
+ * binding, or else the terminal, as a key.
60
+ */
61
+ export type SurfaceKeyDownRoute = {
62
+ readonly type: "text-system";
63
+ } | {
64
+ readonly type: "binding";
65
+ readonly binding: ResolvedTerminalBinding;
66
+ } | {
67
+ readonly type: "terminal";
68
+ };
69
+ export declare function routeSurfaceKeyDown(event: TerminalTextKeyEventLike & KeyEventLike, textInput: TerminalTextInput, platform: string | undefined, bindings: readonly GhosttyBindingEntry[] | undefined): SurfaceKeyDownRoute;
70
+ /**
71
+ * What running a terminal binding's effect did: Ghostty's performed or not,
72
+ * or, for a paste on a host without `readClipboard`, left to the keydown's
73
+ * default action. That is the platform's own paste only when the keydown is
74
+ * one of its paste chords (`isPlatformPasteChord`), and only then is it left
75
+ * unprevented; any other chord counts it unperformed.
76
+ */
77
+ export type TerminalEffectOutcome = "performed" | "unperformed" | "default-action";
78
+ /** What the surface's effects depend on. */
79
+ export interface TerminalEffectState {
80
+ readonly hasSelection: boolean;
81
+ readonly interactive: boolean;
82
+ /** The host gave the surface `readClipboard`. */
83
+ readonly readsClipboard: boolean;
84
+ }
85
+ /**
86
+ * Whether the surface can perform a terminal binding's effect now, as Ghostty
87
+ * decides it for the same actions: copying, adjusting or scrolling to a
88
+ * selection needs one (Surface.zig: "If we don't have a selection we do not
89
+ * perform this action, allowing the keybind to fall through to the terminal"),
90
+ * text and pastes need a surface that takes input, and a host without
91
+ * `readClipboard` leaves its paste to the keydown's default action, which
92
+ * `handleSurfaceKeyDown` honours only for the platform's paste chords.
93
+ */
94
+ export declare function terminalEffectAvailability(effect: TerminalEffect, state: TerminalEffectState): TerminalEffectOutcome;
95
+ /**
96
+ * Whether a text field's default action for this keydown is a paste: Cmd+V or
97
+ * Cmd+Shift+V on macOS; Ctrl+V, Ctrl+Shift+V or Shift+Insert elsewhere. Only
98
+ * these may be left to the platform when the host gives no `readClipboard`;
99
+ * another chord's default would type its text instead (Option+V types "√").
100
+ */
101
+ export declare function isPlatformPasteChord(event: KeyEventLike, platform: string | undefined): boolean;
102
+ /**
103
+ * A macOS Cmd chord that would type its text on a session host that is not
104
+ * macOS. Ghostty on macOS encodes no legacy text for Cmd+key
105
+ * (key_encode.zig:543-545, `builtin.os.tag == .macos and all_mods.super`), but
106
+ * the session's daemon encodes the key, and a remote session's daemon on Linux
107
+ * or Windows types the letter. Ctrl takes Ghostty's CSI u path first, so a
108
+ * chord with Ctrl is not one. A stopgap until a key carries the client's
109
+ * platform to the host.
110
+ */
111
+ export declare function isMacCommandText(event: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey">, platform: string | undefined): boolean;
112
+ /** The keydown fields the surface reads: the text system's, a binding's and the terminal key's. */
113
+ export type SurfaceKeyboardEventLike = TerminalTextKeyEventLike & KeyEventLike & Pick<KeyboardEvent, "code" | "location" | "repeat" | "timeStamp">;
114
+ /** The event's dispatch controls. For a React handler, its synthetic event. */
115
+ export interface SurfaceKeyDispatch {
116
+ preventDefault(): void;
117
+ stopPropagation(): void;
118
+ }
119
+ /** What a keydown on the surface reaches. */
120
+ export interface SurfaceKeyInput {
121
+ readonly textInput: TerminalTextInput;
122
+ readonly platform: string | undefined;
123
+ readonly bindings: readonly GhosttyBindingEntry[] | undefined;
124
+ /** Whether the surface takes input. A read-only surface sends no key. */
125
+ readonly interactive: boolean;
126
+ readonly runtime: Pick<GhostteaTerminalRuntime, "sendKey" | "interrupt">;
127
+ readonly surface: {
128
+ readonly sessionId: string;
129
+ readonly viewId: string;
130
+ };
131
+ /** The presses sent to the terminal, by `code`, so that each one's release follows it. */
132
+ readonly forwardedKeys: Map<string, TerminalKeyEvent>;
133
+ executeEffect(effect: TerminalEffect): TerminalEffectOutcome;
134
+ /** Ends the view's selection, as typing does. */
135
+ clearSelection(): void;
136
+ }
137
+ /**
138
+ * What became of a keydown: left to the text system, taken by a binding, left
139
+ * to its default action (a binding's paste), withheld (a macOS Cmd chord a
140
+ * performable binding could not act on), prevented on a read-only surface,
141
+ * sent as the interrupt, or sent as a key.
142
+ */
143
+ export type SurfaceKeyDownOutcome = "text-system" | "binding" | "default-action" | "withheld" | "read-only" | "interrupt" | "key";
144
+ /** A modifier pressed alone: it is sent to the terminal but, as in Ghostty, it is not typing. */
145
+ export declare function isModifierKey(event: Pick<KeyboardEvent, "code">): boolean;
146
+ /**
147
+ * The keydown the surface sends as the session's interrupt (ETX): Ctrl+C, and
148
+ * only the chord Ghostty encodes as ETX. Alt only prefixes ESC there, but with
149
+ * Shift or Super added Ghostty no longer takes it for a control character and
150
+ * encodes it as a key (CSI u), so Ctrl+Shift+C reaches the encoder.
151
+ */
152
+ export declare function isTerminalInterrupt(event: Pick<KeyboardEvent, "key" | "ctrlKey" | "altKey" | "shiftKey" | "metaKey">): boolean;
153
+ /**
154
+ * Handles a keydown on the surface as Ghostty's `Surface.keyCallback` does:
155
+ * the text system's keydowns are its own; a terminal binding's effect runs, and
156
+ * the key ends there unless the binding does not consume it. An `unconsumed:`
157
+ * bind's key, after its effect, and a `performable:` bind's whose effect could
158
+ * not be performed (no selection to copy or adjust) go on as the key, exactly
159
+ * as an unbound key does: nothing on a read-only surface, the selection ended
160
+ * unless it is a modifier alone, then the interrupt or the key, its release
161
+ * paired through `forwardedKeys`.
162
+ *
163
+ * One exception: a macOS Cmd chord with text that a performable bind could not
164
+ * act on (Cmd+C or Cmd+J with no selection) is withheld, because
165
+ * the session may live on a host whose encoder types its letter
166
+ * (`isMacCommandText`). A macOS host would encode nothing for it in legacy
167
+ * mode anyway.
168
+ */
169
+ export declare function handleSurfaceKeyDown(event: SurfaceKeyboardEventLike, dispatch: SurfaceKeyDispatch, input: SurfaceKeyInput): SurfaceKeyDownOutcome;
170
+ /** Sends the release of a press the surface sent, once. A release of anything else is not the terminal's. */
171
+ export declare function handleSurfaceKeyUp(event: Parameters<typeof terminalKeyUp>[1], dispatch: SurfaceKeyDispatch, input: Pick<SurfaceKeyInput, "runtime" | "surface" | "forwardedKeys">): boolean;
172
+ /**
173
+ * Sends the text system's input to the terminal as typing: it clears the
174
+ * view's selection, as a forwarded key does, then sends each action in order
175
+ * through typing's verbs. Committed text is text, a paste or drop is a paste,
176
+ * and an edit key is the press and release the physical key sends.
177
+ */
178
+ export declare function commitTerminalTextInput(runtime: Pick<GhostteaTerminalRuntime, "setSelection" | "sendText" | "paste" | "sendKey">, surface: {
179
+ sessionId: string;
180
+ sessionHandle: string;
181
+ viewId: string;
182
+ }, actions: readonly TerminalTextInputAction[], timestamp: number): void;
49
183
  export interface TerminalSurfaceProps {
50
184
  session: SessionSummary;
51
185
  theme: TerminalTheme;
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalSurface.d.ts","sourceRoot":"","sources":["../src/TerminalSurface.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAoB,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAK5G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAML,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,cAAc,CAAC;AAClF,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;AAE1D,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,sDAAsD;IACtD,cAAc,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAE7G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAE3F;AAED;mEACmE;AACnE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,EAC3D,OAAO,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAA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AAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/E;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,EACzD,SAAS,EAAE,sBAAsB,EACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAoBhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,+BAG1D"}
@@ -1,13 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useTerminalLinks } from "./use-terminal-links.js";
3
- import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { useGhostteaRuntime } from "./context.js";
5
5
  import { terminalKeyboardLayout, terminalKeyDown, terminalKeyUp } from "./keyboard-input.js";
6
- import { terminalEffectShouldConsume } from "./bindings/action-route.js";
6
+ import { bindingKeyDisposition } from "./bindings/action-route.js";
7
7
  import { resolveTerminalBinding } from "./terminal-bindings.js";
8
+ import { parseGhosttyTrigger, triggerMatchesEvent } from "./bindings/ghostty-triggers.js";
8
9
  import { CELL_WIDTH, DEFAULT_EFFECTS, LINE_HEIGHT, ORIGIN_X, ORIGIN_Y, } from "./renderers/types.js";
9
10
  import { accumulateWheelRows, wheelDeltaPixels } from "./scroll-input.js";
10
11
  import { adjustSelectionFocus, usesLocalSelection } from "./selection-input.js";
12
+ import { attachTerminalTextInput, TerminalTextInput, terminalEditKeyEvents, } from "./text-input.js";
11
13
  /**
12
14
  * Whether a focus change takes the geometry seat: only a focus gain, only when
13
15
  * the host opted in, and only for a surface that controls resize and takes
@@ -44,6 +46,186 @@ export function syncSurfaceFocus(runtime, surface, focused, wasFocused, policy)
44
46
  runtime.takeResizeControl(surface.sessionHandle, surface.viewId, surface.cols, surface.rows);
45
47
  }
46
48
  }
49
+ export function routeSurfaceKeyDown(event, textInput, platform, bindings) {
50
+ if (textInput.keyDown(event))
51
+ return { type: "text-system" };
52
+ // Terminal-scoped Ghostty binds only (workspace/platform/unhandled owned by Workspace).
53
+ const binding = resolveTerminalBinding(event, platform, bindings);
54
+ return binding ? { type: "binding", binding } : { type: "terminal" };
55
+ }
56
+ /**
57
+ * Whether the surface can perform a terminal binding's effect now, as Ghostty
58
+ * decides it for the same actions: copying, adjusting or scrolling to a
59
+ * selection needs one (Surface.zig: "If we don't have a selection we do not
60
+ * perform this action, allowing the keybind to fall through to the terminal"),
61
+ * text and pastes need a surface that takes input, and a host without
62
+ * `readClipboard` leaves its paste to the keydown's default action, which
63
+ * `handleSurfaceKeyDown` honours only for the platform's paste chords.
64
+ */
65
+ export function terminalEffectAvailability(effect, state) {
66
+ switch (effect.type) {
67
+ case "copy":
68
+ case "adjust_selection":
69
+ case "scroll_to_selection":
70
+ return state.hasSelection ? "performed" : "unperformed";
71
+ case "paste":
72
+ if (!state.interactive)
73
+ return "unperformed";
74
+ return state.readsClipboard ? "performed" : "default-action";
75
+ case "text":
76
+ return state.interactive ? "performed" : "unperformed";
77
+ default:
78
+ return "performed";
79
+ }
80
+ }
81
+ /** Whether the platform's key bindings are macOS's, as the binding tables choose them: darwin, or unknown. */
82
+ function macKeyboard(platform) {
83
+ return platform !== "linux" && platform !== "win32";
84
+ }
85
+ const MAC_PASTE_CHORDS = ["super+v", "super+shift+v"].map(parseGhosttyTrigger);
86
+ const PC_PASTE_CHORDS = ["ctrl+v", "ctrl+shift+v", "shift+insert"].map(parseGhosttyTrigger);
87
+ /**
88
+ * Whether a text field's default action for this keydown is a paste: Cmd+V or
89
+ * Cmd+Shift+V on macOS; Ctrl+V, Ctrl+Shift+V or Shift+Insert elsewhere. Only
90
+ * these may be left to the platform when the host gives no `readClipboard`;
91
+ * another chord's default would type its text instead (Option+V types "√").
92
+ */
93
+ export function isPlatformPasteChord(event, platform) {
94
+ return (macKeyboard(platform) ? MAC_PASTE_CHORDS : PC_PASTE_CHORDS).some((chord) => triggerMatchesEvent(chord, event));
95
+ }
96
+ /**
97
+ * A macOS Cmd chord that would type its text on a session host that is not
98
+ * macOS. Ghostty on macOS encodes no legacy text for Cmd+key
99
+ * (key_encode.zig:543-545, `builtin.os.tag == .macos and all_mods.super`), but
100
+ * the session's daemon encodes the key, and a remote session's daemon on Linux
101
+ * or Windows types the letter. Ctrl takes Ghostty's CSI u path first, so a
102
+ * chord with Ctrl is not one. A stopgap until a key carries the client's
103
+ * platform to the host.
104
+ */
105
+ export function isMacCommandText(event, platform) {
106
+ if (!macKeyboard(platform) || !event.metaKey || event.ctrlKey)
107
+ return false;
108
+ const chars = [...event.key];
109
+ return chars.length === 1 && !/\p{Cc}/u.test(event.key);
110
+ }
111
+ /** The physical modifier keys, which Ghostty's `Key.modifier` names. Firefox before 118 called Meta "OS". */
112
+ const MODIFIER_CODES = new Set([
113
+ "ShiftLeft",
114
+ "ShiftRight",
115
+ "ControlLeft",
116
+ "ControlRight",
117
+ "AltLeft",
118
+ "AltRight",
119
+ "MetaLeft",
120
+ "MetaRight",
121
+ "OSLeft",
122
+ "OSRight",
123
+ ]);
124
+ /** A modifier pressed alone: it is sent to the terminal but, as in Ghostty, it is not typing. */
125
+ export function isModifierKey(event) {
126
+ return MODIFIER_CODES.has(event.code);
127
+ }
128
+ /**
129
+ * The keydown the surface sends as the session's interrupt (ETX): Ctrl+C, and
130
+ * only the chord Ghostty encodes as ETX. Alt only prefixes ESC there, but with
131
+ * Shift or Super added Ghostty no longer takes it for a control character and
132
+ * encodes it as a key (CSI u), so Ctrl+Shift+C reaches the encoder.
133
+ */
134
+ export function isTerminalInterrupt(event) {
135
+ return event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey && event.key.toLowerCase() === "c";
136
+ }
137
+ /**
138
+ * Handles a keydown on the surface as Ghostty's `Surface.keyCallback` does:
139
+ * the text system's keydowns are its own; a terminal binding's effect runs, and
140
+ * the key ends there unless the binding does not consume it. An `unconsumed:`
141
+ * bind's key, after its effect, and a `performable:` bind's whose effect could
142
+ * not be performed (no selection to copy or adjust) go on as the key, exactly
143
+ * as an unbound key does: nothing on a read-only surface, the selection ended
144
+ * unless it is a modifier alone, then the interrupt or the key, its release
145
+ * paired through `forwardedKeys`.
146
+ *
147
+ * One exception: a macOS Cmd chord with text that a performable bind could not
148
+ * act on (Cmd+C or Cmd+J with no selection) is withheld, because
149
+ * the session may live on a host whose encoder types its letter
150
+ * (`isMacCommandText`). A macOS host would encode nothing for it in legacy
151
+ * mode anyway.
152
+ */
153
+ export function handleSurfaceKeyDown(event, dispatch, input) {
154
+ const route = routeSurfaceKeyDown(event, input.textInput, input.platform, input.bindings);
155
+ if (route.type === "text-system")
156
+ return "text-system";
157
+ let withhold = false;
158
+ if (route.type === "binding") {
159
+ const { effect, flags } = route.binding;
160
+ const outcome = input.executeEffect(effect);
161
+ if (outcome === "default-action" && isPlatformPasteChord(event, input.platform))
162
+ return "default-action";
163
+ const performed = outcome === "performed";
164
+ if (bindingKeyDisposition(flags, performed) === "consume") {
165
+ dispatch.preventDefault();
166
+ dispatch.stopPropagation();
167
+ return "binding";
168
+ }
169
+ withhold = flags.performable && !performed && flags.unconsumed !== true && isMacCommandText(event, input.platform);
170
+ }
171
+ if (!input.interactive) {
172
+ dispatch.preventDefault();
173
+ return "read-only";
174
+ }
175
+ if (withhold) {
176
+ dispatch.preventDefault();
177
+ dispatch.stopPropagation();
178
+ return "withheld";
179
+ }
180
+ if (!isModifierKey(event))
181
+ input.clearSelection();
182
+ const { sessionId, viewId } = input.surface;
183
+ if (isTerminalInterrupt(event)) {
184
+ input.runtime.interrupt(sessionId, viewId);
185
+ dispatch.preventDefault();
186
+ dispatch.stopPropagation();
187
+ return "interrupt";
188
+ }
189
+ const terminalEvent = terminalKeyDown(event);
190
+ input.runtime.sendKey(sessionId, viewId, terminalEvent);
191
+ input.forwardedKeys.set(event.code, terminalEvent);
192
+ dispatch.preventDefault();
193
+ dispatch.stopPropagation();
194
+ return "key";
195
+ }
196
+ /** Sends the release of a press the surface sent, once. A release of anything else is not the terminal's. */
197
+ export function handleSurfaceKeyUp(event, dispatch, input) {
198
+ const pressed = input.forwardedKeys.get(event.code);
199
+ if (!pressed)
200
+ return false;
201
+ input.forwardedKeys.delete(event.code);
202
+ input.runtime.sendKey(input.surface.sessionId, input.surface.viewId, terminalKeyUp(pressed, event));
203
+ dispatch.preventDefault();
204
+ dispatch.stopPropagation();
205
+ return true;
206
+ }
207
+ /**
208
+ * Sends the text system's input to the terminal as typing: it clears the
209
+ * view's selection, as a forwarded key does, then sends each action in order
210
+ * through typing's verbs. Committed text is text, a paste or drop is a paste,
211
+ * and an edit key is the press and release the physical key sends.
212
+ */
213
+ export function commitTerminalTextInput(runtime, surface, actions, timestamp) {
214
+ runtime.setSelection(surface.sessionHandle, null, surface.viewId);
215
+ for (const action of actions) {
216
+ if (action.type === "text") {
217
+ runtime.sendText(surface.sessionId, surface.viewId, action.text);
218
+ }
219
+ else if (action.type === "paste") {
220
+ runtime.paste(surface.sessionId, surface.viewId, action.text);
221
+ }
222
+ else {
223
+ for (const event of terminalEditKeyEvents(action.key, timestamp)) {
224
+ runtime.sendKey(surface.sessionId, surface.viewId, event);
225
+ }
226
+ }
227
+ }
228
+ }
47
229
  export function viewportSelection(selection, scrollbar, cols, rows) {
48
230
  if (!selection)
49
231
  return null;
@@ -104,6 +286,9 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
104
286
  const selectionAutoScrollEdgeRef = useRef(null);
105
287
  const scrollbarDragRef = useRef(null);
106
288
  const forwardedKeysRef = useRef(new Map());
289
+ // What the platform's text system puts in the textarea: IME commits, the
290
+ // emoji pickers, voice typing, soft keyboards, drops.
291
+ const [textInput] = useState(() => new TerminalTextInput());
107
292
  const restoreInputFocusRef = useRef(false);
108
293
  const [scrollbar, setScrollbar] = useState(() => terminalRuntime.scrollbar(session.handle) ?? {
109
294
  total: session.rows,
@@ -153,23 +338,27 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
153
338
  const { cols, rows } = gridRef.current;
154
339
  const total = Math.max(rows, scrollbarRef.current.total);
155
340
  const viewportLen = Math.max(1, scrollbarRef.current.length || rows);
156
- if (effect.type === "copy") {
157
- if (!selectionRef.current)
158
- return false;
341
+ const selection = selectionRef.current;
342
+ const availability = terminalEffectAvailability(effect, {
343
+ hasSelection: selection !== null,
344
+ interactive,
345
+ readsClipboard: readClipboard !== undefined,
346
+ });
347
+ if (availability !== "performed")
348
+ return availability;
349
+ if (effect.type === "copy" && selection) {
159
350
  void terminalRuntime
160
- .copySelection(session.id, viewId, selectionRef.current, selectionAllRef.current)
351
+ .copySelection(session.id, viewId, selection, selectionAllRef.current)
161
352
  .catch((error) => console.error("[terminal-runtime] clipboard copy failed", error));
162
- return true;
353
+ return "performed";
163
354
  }
164
355
  if (effect.type === "select_all") {
165
356
  setLocalSelection({ anchor: { column: 0, row: 0 }, focus: { column: cols - 1, row: total - 1 } }, true);
166
357
  terminalRuntime.setSelection(session.handle, viewportSelection(selectionRef.current, scrollbarRef.current, cols, rows), viewId);
167
- return true;
358
+ return "performed";
168
359
  }
169
360
  if (effect.type === "paste") {
170
- if (!interactive || !readClipboard)
171
- return false;
172
- void Promise.resolve(readClipboard())
361
+ void Promise.resolve(readClipboard?.())
173
362
  .then((text) => {
174
363
  if (!text)
175
364
  return;
@@ -179,67 +368,59 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
179
368
  terminalRuntime.paste(session.id, viewId, text);
180
369
  })
181
370
  .catch((error) => console.error("[terminal-runtime] clipboard paste failed", error));
182
- return true;
371
+ return "performed";
183
372
  }
184
373
  if (effect.type === "text" || effect.type === "clear_screen") {
185
- if (!interactive && effect.type === "text")
186
- return false;
187
374
  selectionAnchorRef.current = null;
188
375
  setLocalSelection(null);
189
376
  terminalRuntime.setSelection(session.handle, null, viewId);
190
377
  terminalRuntime.sendText(session.id, viewId, effect.type === "clear_screen" ? "\u000c" : effect.text);
191
- return true;
378
+ return "performed";
192
379
  }
193
380
  if (effect.type === "scroll_to_top") {
194
381
  terminalRuntime.scrollTo(session.id, viewId, 0);
195
- return true;
382
+ return "performed";
196
383
  }
197
384
  if (effect.type === "scroll_to_bottom") {
198
385
  terminalRuntime.scrollTo(session.id, viewId, Math.max(0, total - viewportLen));
199
- return true;
386
+ return "performed";
200
387
  }
201
388
  if (effect.type === "scroll_to_row") {
202
389
  terminalRuntime.scrollTo(session.id, viewId, Math.max(0, effect.row));
203
- return true;
390
+ return "performed";
204
391
  }
205
- if (effect.type === "scroll_to_selection") {
206
- const selection = selectionRef.current;
207
- if (!selection)
208
- return false;
392
+ if (effect.type === "scroll_to_selection" && selection) {
209
393
  const row = Math.min(selection.anchor.row, selection.focus.row);
210
394
  terminalRuntime.scrollTo(session.id, viewId, Math.max(0, row));
211
- return true;
395
+ return "performed";
212
396
  }
213
397
  if (effect.type === "scroll_page_up") {
214
398
  terminalRuntime.scroll(session.id, viewId, -rows);
215
- return true;
399
+ return "performed";
216
400
  }
217
401
  if (effect.type === "scroll_page_down") {
218
402
  terminalRuntime.scroll(session.id, viewId, rows);
219
- return true;
403
+ return "performed";
220
404
  }
221
405
  if (effect.type === "scroll_page_fractional") {
222
406
  const delta = Math.trunc(rows * effect.amount);
223
407
  if (delta !== 0)
224
408
  terminalRuntime.scroll(session.id, viewId, delta);
225
- return true;
409
+ return "performed";
226
410
  }
227
411
  if (effect.type === "scroll_page_lines") {
228
412
  if (effect.lines !== 0)
229
413
  terminalRuntime.scroll(session.id, viewId, effect.lines);
230
- return true;
414
+ return "performed";
231
415
  }
232
- if (effect.type === "adjust_selection") {
233
- const selection = selectionRef.current;
234
- if (!selection)
235
- return false;
416
+ if (effect.type === "adjust_selection" && selection) {
236
417
  const nextFocus = adjustSelectionFocus(selection.focus, effect.direction, {
237
418
  cols,
238
419
  rows,
239
420
  totalRows: total,
240
421
  });
241
422
  if (!nextFocus)
242
- return false;
423
+ return "unperformed";
243
424
  setLocalSelection({ anchor: selection.anchor, focus: nextFocus });
244
425
  // Keep keyboard-adjusted focus visible (Ghostty scrolls selection into view).
245
426
  const offset = scrollbarRef.current.offset;
@@ -250,10 +431,23 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
250
431
  terminalRuntime.scrollTo(session.id, viewId, Math.max(0, nextFocus.row - rows + 1));
251
432
  }
252
433
  terminalRuntime.setSelection(session.handle, viewportSelection(selectionRef.current, scrollbarRef.current, cols, rows), viewId);
253
- return true;
434
+ return "performed";
254
435
  }
255
- return false;
436
+ return "unperformed";
256
437
  }, [interactive, readClipboard, session.handle, session.id, setLocalSelection, terminalRuntime, viewId]);
438
+ // Text input is typing: it ends the local selection, as a forwarded key does.
439
+ const commitTextInput = useCallback((actions) => {
440
+ selectionAnchorRef.current = null;
441
+ setLocalSelection(null);
442
+ commitTerminalTextInput(terminalRuntime, { sessionId: session.id, sessionHandle: session.handle, viewId }, actions, performance.now());
443
+ }, [session.handle, session.id, setLocalSelection, terminalRuntime, viewId]);
444
+ const textInputSink = useMemo(() => ({ interactive, commit: commitTextInput }), [commitTextInput, interactive]);
445
+ useEffect(() => {
446
+ const input = inputRef.current;
447
+ if (!input)
448
+ return;
449
+ return attachTerminalTextInput(input, textInput, textInputSink);
450
+ }, [textInput, textInputSink]);
257
451
  useEffect(() => {
258
452
  if (!onMenuAction)
259
453
  return;
@@ -401,47 +595,26 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
401
595
  terminalRuntime.setFocused(session.handle, viewId, false, cols, rows);
402
596
  };
403
597
  }, [active, inputFocused, releaseForwardedKeys, session.handle, terminalRuntime, viewId]);
598
+ const keyInput = () => ({
599
+ textInput,
600
+ platform,
601
+ bindings,
602
+ interactive,
603
+ runtime: terminalRuntime,
604
+ surface: { sessionId: session.id, viewId },
605
+ forwardedKeys: forwardedKeysRef.current,
606
+ executeEffect: executeTerminalEffect,
607
+ clearSelection: () => {
608
+ selectionAnchorRef.current = null;
609
+ setLocalSelection(null);
610
+ terminalRuntime.setSelection(session.handle, null, viewId);
611
+ },
612
+ });
404
613
  const onKeyDown = (event) => {
405
- if (event.nativeEvent.isComposing)
406
- return;
407
- // Terminal-scoped Ghostty binds only (workspace/platform/unhandled owned by Workspace).
408
- const terminalMatch = resolveTerminalBinding(event.nativeEvent, platform, bindings);
409
- if (terminalMatch) {
410
- const applied = executeTerminalEffect(terminalMatch.effect);
411
- // Performable binds only consume when applied (Ghostty Binding.Flags.performable).
412
- if (terminalEffectShouldConsume(terminalMatch.effect, applied, terminalMatch.flags)) {
413
- event.preventDefault();
414
- event.stopPropagation();
415
- }
416
- return;
417
- }
418
- if (!interactive) {
419
- event.preventDefault();
420
- return;
421
- }
422
- selectionAnchorRef.current = null;
423
- setLocalSelection(null);
424
- terminalRuntime.setSelection(session.handle, null, viewId);
425
- if (event.ctrlKey && !event.altKey && event.key.toLowerCase() === "c") {
426
- terminalRuntime.interrupt(session.id, viewId);
427
- event.preventDefault();
428
- event.stopPropagation();
429
- return;
430
- }
431
- const terminalEvent = terminalKeyDown(event.nativeEvent);
432
- terminalRuntime.sendKey(session.id, viewId, terminalEvent);
433
- forwardedKeysRef.current.set(event.code, terminalEvent);
434
- event.preventDefault();
435
- event.stopPropagation();
614
+ handleSurfaceKeyDown(event.nativeEvent, event, keyInput());
436
615
  };
437
616
  const onKeyUp = (event) => {
438
- const pressed = forwardedKeysRef.current.get(event.code);
439
- if (!pressed)
440
- return;
441
- forwardedKeysRef.current.delete(event.code);
442
- terminalRuntime.sendKey(session.id, viewId, terminalKeyUp(pressed, event.nativeEvent));
443
- event.preventDefault();
444
- event.stopPropagation();
617
+ handleSurfaceKeyUp(event.nativeEvent, event, keyInput());
445
618
  };
446
619
  const onPaste = (event) => {
447
620
  if (!interactive) {
@@ -703,12 +876,6 @@ function TerminalSurfaceSession({ session, theme, effects = DEFAULT_EFFECTS, bin
703
876
  }, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, onWheel: onWheel, onContextMenu: (event) => {
704
877
  event.preventDefault();
705
878
  onContextMenu?.(selectionRef.current !== null);
706
- }, onCompositionEnd: (event) => {
707
- terminalRuntime.sendText(session.id, viewId, event.currentTarget.value);
708
- event.currentTarget.value = "";
709
- }, onInput: (event) => {
710
- if (!event.nativeEvent.isComposing)
711
- event.currentTarget.value = "";
712
879
  } }), links.hoveredLink ? (_jsx("div", { className: "terminal-link-overlay", "aria-hidden": "true", children: links.hoveredLink.spans.map((span, index) => (_jsx("span", { style: {
713
880
  left: ORIGIN_X + span.startColumn * CELL_WIDTH,
714
881
  top: ORIGIN_Y + (span.row + 1) * LINE_HEIGHT - 3,