Improve mobile terminal input, selection, and resizing (#1607)

* Improve mobile terminal typing and selection

* Address mobile terminal review feedback

* Remove dead native terminal input branch

* Replay bracketed paste in terminal preamble

* Stop per-key terminal resize claims

* Stabilize terminal resize browser test

* Use tracked terminal mode for native paste

* Restore terminal toolbar focus handling

* Adapt native terminal to active visibility state

* Stabilize native mobile terminal interactions

* Add native terminal fallback boundary

* test(app): expect explicit terminal resize reclaim

* fix(app): stabilize terminal buffer coordinates

* fix(app): restrict terminal resize ownership

* fix(terminal): gate restored input modes

* fix(app): recover stalled terminal WebViews

* chore(app): remove obsolete terminal harnesses

* fix(app): make terminal resize claims explicit

* test(app): stabilize native terminal device flows

* test(app): track absolute scrollback coordinates

* fix(app): isolate terminal WebView streams

* fix(terminal): arbitrate size ownership across clients

The daemon now distinguishes explicit ownership claims from passive geometry updates. This keeps the active client authoritative while allowing its split, viewport, and keyboard changes to resize the PTY without idle clients stealing it.

* test(server): make worker resize assertion portable

Query the worker's authoritative terminal snapshot instead of invoking a Unix-only shell command, so the resize regression exercises the same boundary on Windows and Unix.
This commit is contained in:
Mohamed Boudra
2026-08-03 19:01:34 +08:00
committed by GitHub
parent 2948a435ed
commit 04fe30a3e2
119 changed files with 9843 additions and 1032 deletions
+25 -6
View File
@@ -125,6 +125,10 @@ function csiWithModifier(finalByte: string, input: TerminalKeyInput): string {
return mod === 1 ? `\x1b[${finalByte}` : `\x1b[1;${mod}${finalByte}`;
}
function ss3WithModifier(finalByte: string, input: TerminalKeyInput): string {
return modifierParam(input) === 1 ? `\x1bO${finalByte}` : csiWithModifier(finalByte, input);
}
function csiTilde(base: number, input: TerminalKeyInput): string {
const mod = modifierParam(input);
return mod === 1 ? `\x1b[${base}~` : `\x1b[${base};${mod}~`;
@@ -161,16 +165,31 @@ function encodeFunctionKey(key: string, input: TerminalKeyInput): string | null
}
}
function encodeNavigationKey(key: string, input: TerminalKeyInput): string | null {
function encodeArrowKey(
finalByte: string,
input: TerminalKeyInput,
options: TerminalKeyInputEncodingOptions,
): string {
if (options.inputMode?.applicationCursorKeys) {
return ss3WithModifier(finalByte, input);
}
return csiWithModifier(finalByte, input);
}
function encodeNavigationKey(
key: string,
input: TerminalKeyInput,
options: TerminalKeyInputEncodingOptions,
): string | null {
switch (key) {
case "ArrowUp":
return csiWithModifier("A", input);
return encodeArrowKey("A", input, options);
case "ArrowDown":
return csiWithModifier("B", input);
return encodeArrowKey("B", input, options);
case "ArrowRight":
return csiWithModifier("C", input);
return encodeArrowKey("C", input, options);
case "ArrowLeft":
return csiWithModifier("D", input);
return encodeArrowKey("D", input, options);
case "Home":
return csiWithModifier("H", input);
case "End":
@@ -225,7 +244,7 @@ export function encodeTerminalKeyInput(
break;
}
const nav = encodeNavigationKey(key, input);
const nav = encodeNavigationKey(key, input, options);
if (nav !== null) return nav;
const fn = encodeFunctionKey(key, input);
if (fn !== null) return fn;