fix(ui): add opt-in mobile keyboard resize mode and stabilize touch terminal input (#1107)

* fix(ui): add opt-in mobile keyboard resize mode

* fix(ui): stabilize touch terminal input and tab layout

* fix(ui): narrow touch terminal handling to mobile and tablet

* fix(ui): refine touch terminal input handling

* fix(ui): re-key terminal viewport on session id

* fix(ui): avoid touch-laptop terminal overlay regression

* fix(ui): hide ghostty system caret surfaces

* fix(settings): normalize mobile keyboard mode sanitization

* fix(ui): honor terminal quick keys toggle on mobile

* fix(ui): gate mobile keyboard resize mode on iOS

---------

Co-authored-by: vhqtvn <8930337+vhqtvn@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
vhqtvn
2026-05-05 12:26:34 +03:00
committed by GitHub
co-authored by vhqtvn Bohdan Triapitsyn
parent 63b4a5b996
commit 962ee41bba
25 changed files with 604 additions and 128 deletions
@@ -19,6 +19,7 @@ export const createSettingsHelpers = (dependencies) => {
const PWA_APP_NAME_MAX_LENGTH = 64;
const PWA_ORIENTATION_VALUES = new Set(['system', 'portrait', 'landscape']);
const MOBILE_KEYBOARD_MODE_VALUES = new Set(['native', 'resize-content']);
const normalizePwaAppName = (value, fallback = '') => {
if (typeof value !== 'string') {
@@ -42,6 +43,17 @@ export const createSettingsHelpers = (dependencies) => {
return fallback;
};
const normalizeMobileKeyboardMode = (value, fallback = 'native') => {
if (typeof value !== 'string') {
return fallback;
}
const normalized = value.trim();
if (MOBILE_KEYBOARD_MODE_VALUES.has(normalized)) {
return normalized;
}
return fallback;
};
const sanitizeSettingsUpdate = (payload) => {
if (!payload || typeof payload !== 'object') {
return {};
@@ -310,6 +322,12 @@ export const createSettingsHelpers = (dependencies) => {
if (typeof candidate.pwaOrientation === 'string') {
result.pwaOrientation = normalizePwaOrientation(candidate.pwaOrientation, undefined);
}
if (typeof candidate.mobileKeyboardMode === 'string') {
const mode = normalizeMobileKeyboardMode(candidate.mobileKeyboardMode, undefined);
if (mode) {
result.mobileKeyboardMode = mode;
}
}
if (typeof candidate.toolCallExpansion === 'string') {
const mode = candidate.toolCallExpansion.trim();
if (mode === 'collapsed' || mode === 'activity' || mode === 'detailed' || mode === 'changes') {
@@ -650,12 +668,14 @@ export const createSettingsHelpers = (dependencies) => {
const hasManagedRemoteTunnelToken = typeof settings?.managedRemoteTunnelToken === 'string' && settings.managedRemoteTunnelToken.trim().length > 0;
const pwaAppName = normalizePwaAppName(settings?.pwaAppName, '');
const pwaOrientation = normalizePwaOrientation(settings?.pwaOrientation, 'system');
const mobileKeyboardMode = normalizeMobileKeyboardMode(settings?.mobileKeyboardMode, 'native');
return {
...sanitized,
hasManagedRemoteTunnelToken,
...(pwaAppName ? { pwaAppName } : {}),
pwaOrientation,
mobileKeyboardMode,
approvedDirectories: approved,
securityScopedBookmarks: bookmarks,
pinnedDirectories: normalizeStringArray(settings.pinnedDirectories),
@@ -672,6 +692,7 @@ export const createSettingsHelpers = (dependencies) => {
return {
normalizePwaAppName,
normalizePwaOrientation,
normalizeMobileKeyboardMode,
sanitizeSettingsUpdate,
mergePersistedSettings,
formatSettingsResponse,
@@ -51,4 +51,24 @@ describe('settings helpers', () => {
desktopLanAccessEnabled: false,
});
});
it('accepts mobileKeyboardMode as a persisted shared setting', () => {
const helpers = createTestHelpers();
expect(helpers.sanitizeSettingsUpdate({ mobileKeyboardMode: 'native' })).toEqual({
mobileKeyboardMode: 'native',
});
expect(helpers.sanitizeSettingsUpdate({ mobileKeyboardMode: 'resize-content' })).toEqual({
mobileKeyboardMode: 'resize-content',
});
expect(helpers.sanitizeSettingsUpdate({ mobileKeyboardMode: ' resize-content ' })).toEqual({
mobileKeyboardMode: 'resize-content',
});
});
it('rejects invalid mobileKeyboardMode values', () => {
const helpers = createTestHelpers();
expect(helpers.sanitizeSettingsUpdate({ mobileKeyboardMode: 'fixed-layout' })).toEqual({});
});
});