feat(mobile): Send on Enter for the pinned CJK input field

A per-device setting next to CJK Input keeps typed text in the pinned
field until Enter instead of streaming it to the PTY, so a phone user can
scroll the terminal and edit an answer before sending (Termux-style).
One line goes as text + CR, several lines as one bracketed paste with a
delayed Enter, like the prompt composer. Shift+Enter is a newline,
Escape clears, Backspace on an empty field still reaches the PTY, and
autocorrect is on in this mode. The field grows with its text and the
keyboard layout reserves its real height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kamil KaliszandClaude Opus 5.5 committed 2026-11-15 18:38:25 +01:00
1 parent e99b42c387
commit e0e2f689cf
8 files changed
+307 -3

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"aicodeman": patch
---
Add a per-device "Send on Enter" mode for the pinned CJK input field, so phone users can scroll the terminal while a typed answer waits in the field until Enter.
+1
View File
@@ -48,6 +48,7 @@ non-updatable. See [Running As A Service](Running-As-A-Service).
| Local Echo | On for touch devices | Paints keystrokes locally and flushes on Enter. See [Input And Voice](Input-And-Voice). | | Local Echo | On for touch devices | Paints keystrokes locally and flushes on Enter. See [Input And Voice](Input-And-Voice). |
| Keep Size Under Keyboard | On | For local Claude sessions, the on-screen keyboard no longer resizes the session: the terminal keeps its rows and the view scrolls so the prompt sits just above the keyboard. Resizing made Claude reprint its screen and drop transcript lines from history. Codex, Claude's fullscreen mode, remote and Docker sessions resize as before. See [Mobile Guide](Mobile-Guide). | | Keep Size Under Keyboard | On | For local Claude sessions, the on-screen keyboard no longer resizes the session: the terminal keeps its rows and the view scrolls so the prompt sits just above the keyboard. Resizing made Claude reprint its screen and drop transcript lines from history. Codex, Claude's fullscreen mode, remote and Docker sessions resize as before. See [Mobile Guide](Mobile-Guide). |
| CJK Input | Off | IME composition through a dedicated text field. | | CJK Input | Off | IME composition through a dedicated text field. |
| Input Field: Send on Enter | Off | With CJK Input on, typed text stays in the pinned field until Enter instead of streaming to the CLI, so on a phone you can scroll the terminal and edit an answer first. Shift+Enter adds a line, Esc clears, autocorrect is on. |
| Extended Keyboard Bar | Per device | Which accessory bar phones get. Shell sessions override it while they are active. | | Extended Keyboard Bar | Per device | Which accessory bar phones get. Shell sessions override it while they are active. |
| Wheel Scrolls Local History | Off | Keeps the wheel on the local buffer instead of forwarding it to the CLI. Fullscreen pi leaves that buffer empty and has no paging fallback, so with this on the wheel does nothing there. | | Wheel Scrolls Local History | Off | Keeps the wheel on the local buffer instead of forwarding it to the CLI. Fullscreen pi leaves that buffer empty and has no paging fallback, so with this on the wheel does nothing there. |
| Auto Copy Selection | Off | Copies highlighted terminal text to the clipboard the moment you finish selecting it. Ctrl+C still copies on demand. | | Auto Copy Selection | Off | Copies highlighted terminal text to the clipboard the moment you finish selecting it. Ctrl+C still copies on demand. |
+5
View File
@@ -4929,6 +4929,11 @@ class CodemanApp {
document.body.classList.toggle('cjk-input-visible', !!showCjk); document.body.classList.toggle('cjk-input-visible', !!showCjk);
cjkEl.style.display = showCjk ? 'block' : 'none'; cjkEl.style.display = showCjk ? 'block' : 'none';
cjkEl.setAttribute('aria-hidden', showCjk ? 'false' : 'true'); cjkEl.setAttribute('aria-hidden', showCjk ? 'false' : 'true');
if (typeof CjkInput !== 'undefined') {
CjkInput.setHoldUntilEnter?.(
!!(settings.cjkInputHoldUntilEnter ?? defaults.cjkInputHoldUntilEnter ?? false)
);
}
if (!showCjk) window.cjkActive = false; if (!showCjk) window.cjkActive = false;
if (typeof KeyboardHandler !== 'undefined') KeyboardHandler.updateLayoutForKeyboard(); if (typeof KeyboardHandler !== 'undefined') KeyboardHandler.updateLayoutForKeyboard();
} }
+7
View File
@@ -2064,6 +2064,13 @@
</div> </div>
<label class="switch switch-sm"><input type="checkbox" id="appSettingsCjkInput"><span class="slider"></span></label> <label class="switch switch-sm"><input type="checkbox" id="appSettingsCjkInput"><span class="slider"></span></label>
</div> </div>
<div class="set-row" data-search="cjk input send on enter hold draft pinned prompt field phone">
<div class="set-row-text">
<span class="set-row-label">Input Field: Send on Enter</span>
<span class="set-row-desc">With CJK Input on, keep typed text in the field until Enter instead of sending it as you type, so you can scroll the terminal and edit before sending. Autocorrect is on in this mode.</span>
</div>
<label class="switch switch-sm"><input type="checkbox" id="appSettingsCjkHoldUntilEnter"><span class="slider"></span></label>
</div>
<div class="set-row" data-search="extended keyboard bar tab esc arrows phone"> <div class="set-row" data-search="extended keyboard bar tab esc arrows phone">
<div class="set-row-text"> <div class="set-row-text">
<span class="set-row-label">Extended Keyboard Bar <span class="set-tag">phone</span></span> <span class="set-row-label">Extended Keyboard Bar <span class="set-tag">phone</span></span>
+76 -1
View File
@@ -57,6 +57,10 @@ const CjkInput = (() => {
let _dictationActive = false; let _dictationActive = false;
let _dictationDecayTimer = null; let _dictationDecayTimer = null;
let _printableKeydownAt = null; let _printableKeydownAt = null;
// Send-on-Enter mode (setting cjkInputHoldUntilEnter): typed text stays in the
// field until Enter, like a chat box, instead of streaming to the PTY as it is
// typed. Lets a phone user scroll the terminal and edit an answer before sending.
let _hold = false;
const _listeners = {}; const _listeners = {};
const PHANTOM = '​'; const PHANTOM = '​';
@@ -189,6 +193,12 @@ const CjkInput = (() => {
_t('flush SKIP composing'); _t('flush SKIP composing');
return; return;
} }
// Send-on-Enter: nothing leaves the field until Enter (keydown handler).
if (_hold) {
_t('flush SKIP hold');
_autoGrow();
return;
}
const val = _strip(_textarea.value); const val = _strip(_textarea.value);
_t(`flush ${val ? 'send len=' + val.length : 'empty'}`); _t(`flush ${val ? 'send len=' + val.length : 'empty'}`);
if (val) { if (val) {
@@ -197,6 +207,35 @@ const CjkInput = (() => {
_resetToPhantom(); _resetToPhantom();
} }
/** Send-on-Enter: grow the field with its content (up to the CSS max-height)
* and let the keyboard layout re-read its height. */
function _autoGrow() {
if (!_textarea) return;
const before = _textarea.style.height;
_textarea.style.height = 'auto';
_textarea.style.height = `${_textarea.scrollHeight}px`;
if (_textarea.style.height !== before && typeof KeyboardHandler !== 'undefined') {
KeyboardHandler.updateLayoutForKeyboard?.();
}
}
/** Send-on-Enter: deliver the held text as one prompt, then Enter. One line
* goes as typed text + CR in one write (what live mode's Enter sends, so CLI
* menus that answer to a digit keep working). Several lines go as one
* bracketed paste with Enter as a separate, delayed write, the same bytes as
* the mobile prompt composer (keyboard-accessory.js _sendComposedPrompt), so
* embedded newlines don't submit early. */
function _sendHeld(val) {
if (!/\n/.test(val)) {
_send(val + '\r');
return;
}
let text = val;
while (/\x1b\[20[01]~/.test(text)) text = text.replace(/\x1b\[20[01]~/g, '');
_send(`\x1b[200~${text.replace(/\r?\n/g, '\r')}\x1b[201~`);
setTimeout(() => _send('\r'), 120);
}
/** Cancel any pending debounced flush */ /** Cancel any pending debounced flush */
function _cancelDebouncedFlush() { function _cancelDebouncedFlush() {
if (_flushTimer) { if (_flushTimer) {
@@ -316,16 +355,25 @@ const CjkInput = (() => {
_t(`keydown ${_kdesc(e.key)} kc=${e.keyCode} ic=${e.isComposing} c=${_composing}`); _t(`keydown ${_kdesc(e.key)} kc=${e.keyCode} ic=${e.isComposing} c=${_composing}`);
_printableKeydownAt = null; _printableKeydownAt = null;
if (e.key === 'Enter') { if (e.key === 'Enter') {
// Send-on-Enter: Shift+Enter (or an IME still composing) is a newline
// in the field, never a send.
if (_hold && (e.shiftKey || e.isComposing || e.keyCode === 229)) {
setTimeout(_autoGrow, 0);
return;
}
e.preventDefault(); e.preventDefault();
_composing = false; _composing = false;
_cancelDebouncedFlush(); _cancelDebouncedFlush();
const val = _strip(_textarea.value); const val = _strip(_textarea.value);
if (val) { if (_hold && val) {
_sendHeld(val);
} else if (val) {
_send(val + '\r'); _send(val + '\r');
} else { } else {
_send('\r'); _send('\r');
} }
_resetToPhantom(); _resetToPhantom();
if (_hold) _autoGrow();
return; return;
} }
@@ -334,6 +382,7 @@ const CjkInput = (() => {
_composing = false; _composing = false;
_cancelDebouncedFlush(); _cancelDebouncedFlush();
_resetToPhantom(); _resetToPhantom();
if (_hold) _autoGrow();
return; return;
} }
@@ -475,6 +524,32 @@ const CjkInput = (() => {
_resetToPhantom(); _resetToPhantom();
}, },
/**
* Send-on-Enter mode on or off (setting cjkInputHoldUntilEnter). On: text
* stays in the field until Enter and the browser's autocorrect is allowed,
* since nothing typed has reached the PTY yet. Off: the original live mode.
*/
setHoldUntilEnter(on) {
_hold = !!on;
if (!_textarea) return;
const v = _hold ? 'on' : 'off';
_textarea.setAttribute('autocorrect', v);
_textarea.setAttribute('autocapitalize', _hold ? 'sentences' : 'off');
_textarea.setAttribute('spellcheck', _hold ? 'true' : 'false');
_textarea.placeholder = _hold
? 'Type, Enter to send (Shift+Enter: new line, Esc: clear)'
: 'CJK input (Enter = send, Esc = clear)';
if (_hold) {
_cancelDebouncedFlush();
_autoGrow();
} else {
_textarea.style.height = '';
}
_t(`hold ${v}`);
},
get holdUntilEnter() { return _hold; },
/** Diagnostic: recent IME event trace (ring buffer). */ /** Diagnostic: recent IME event trace (ring buffer). */
getTrace() { getTrace() {
return _trace.slice(); return _trace.slice();
+5 -1
View File
@@ -455,7 +455,11 @@ const KeyboardHandler = {
caseSheet.style.transform = keyboardOffset > 0 ? `translateY(${-keyboardOffset}px)` : ''; caseSheet.style.transform = keyboardOffset > 0 ? `translateY(${-keyboardOffset}px)` : '';
} }
if (main && keyboardHeight > 0) { if (main && keyboardHeight > 0) {
const cjkInputHeight = cjkInput?.classList.contains('cjk-input-visible') ? 44 : 0; // The field grows with its text in Send-on-Enter mode, so reserve its
// real height (44 = the one-line field plus its border, the old constant).
const cjkInputHeight = cjkInput?.classList.contains('cjk-input-visible')
? Math.max(44, cjkInput.offsetHeight + 10)
: 0;
main.style.paddingBottom = `${84 + cjkInputHeight}px`; main.style.paddingBottom = `${84 + cjkInputHeight}px`;
} }
} else if (keyboardHeight > 0) { } else if (keyboardHeight > 0) {
+6 -1
View File
@@ -649,6 +649,8 @@ Object.assign(CodemanApp.prototype, {
document.getElementById('appSettingsTerminalWheelLocal').checked = document.getElementById('appSettingsTerminalWheelLocal').checked =
settings.terminalWheelLocalScrollback ?? defaults.terminalWheelLocalScrollback ?? false; settings.terminalWheelLocalScrollback ?? defaults.terminalWheelLocalScrollback ?? false;
document.getElementById('appSettingsCjkInput').checked = settings.cjkInputEnabled ?? defaults.cjkInputEnabled ?? false; document.getElementById('appSettingsCjkInput').checked = settings.cjkInputEnabled ?? defaults.cjkInputEnabled ?? false;
document.getElementById('appSettingsCjkHoldUntilEnter').checked =
settings.cjkInputHoldUntilEnter ?? defaults.cjkInputHoldUntilEnter ?? false;
document.getElementById('appSettingsExtendedKeyboardBar').checked = settings.extendedKeyboardBar ?? false; document.getElementById('appSettingsExtendedKeyboardBar').checked = settings.extendedKeyboardBar ?? false;
document.getElementById('appSettingsTabTwoRows').checked = settings.tabTwoRows ?? defaults.tabTwoRows ?? false; document.getElementById('appSettingsTabTwoRows').checked = settings.tabTwoRows ?? defaults.tabTwoRows ?? false;
document.getElementById('appSettingsShowTabCliLogos').checked = this.tabCliLogosEnabled(settings); document.getElementById('appSettingsShowTabCliLogos').checked = this.tabCliLogosEnabled(settings);
@@ -3195,6 +3197,7 @@ Object.assign(CodemanApp.prototype, {
), ),
terminalWheelLocalScrollback: document.getElementById('appSettingsTerminalWheelLocal').checked, terminalWheelLocalScrollback: document.getElementById('appSettingsTerminalWheelLocal').checked,
cjkInputEnabled: document.getElementById('appSettingsCjkInput').checked, cjkInputEnabled: document.getElementById('appSettingsCjkInput').checked,
cjkInputHoldUntilEnter: document.getElementById('appSettingsCjkHoldUntilEnter').checked,
webglRendererEnabled: document.getElementById('appSettingsWebglRenderer').checked, webglRendererEnabled: document.getElementById('appSettingsWebglRenderer').checked,
extendedKeyboardBar: document.getElementById('appSettingsExtendedKeyboardBar').checked, extendedKeyboardBar: document.getElementById('appSettingsExtendedKeyboardBar').checked,
tabTwoRows: document.getElementById('appSettingsTabTwoRows').checked, tabTwoRows: document.getElementById('appSettingsTabTwoRows').checked,
@@ -3440,6 +3443,7 @@ Object.assign(CodemanApp.prototype, {
// SettingsUpdateSchema (.strict()), so sending it would 400 the whole PUT. // SettingsUpdateSchema (.strict()), so sending it would 400 the whole PUT.
keyboardHoldsRows: _khr, keyboardHoldsRows: _khr,
cjkInputEnabled: _cjk, cjkInputEnabled: _cjk,
cjkInputHoldUntilEnter: _cjkHold,
extendedKeyboardBar: _ekb, extendedKeyboardBar: _ekb,
skin: _skin, skin: _skin,
language: _language, language: _language,
@@ -4478,6 +4482,7 @@ Object.assign(CodemanApp.prototype, {
sessionListLayout: 'header', sessionListLayout: 'header',
sessionSidebarFontSize: 12, sessionSidebarFontSize: 12,
cjkInputEnabled: false, cjkInputEnabled: false,
cjkInputHoldUntilEnter: false,
terminalWheelLocalScrollback: false, // mobile scrolls via touch, not wheel terminalWheelLocalScrollback: false, // mobile scrolls via touch, not wheel
webglRendererEnabled: false, // mobile always uses the DOM renderer webglRendererEnabled: false, // mobile always uses the DOM renderer
skin: 'daylight-blue', skin: 'daylight-blue',
@@ -5206,7 +5211,7 @@ Object.assign(CodemanApp.prototype, {
'showFontControls', 'showSystemStats', 'showGpuStats', 'showCpuMhz', 'headerStatsStyle', 'showTokenCount', 'showCost', 'showFontControls', 'showSystemStats', 'showGpuStats', 'showCpuMhz', 'headerStatsStyle', 'showTokenCount', 'showCost',
'showLifecycleLog', 'showResponseViewer', 'showRedrawButton', 'showLifecycleLog', 'showResponseViewer', 'showRedrawButton',
'showMonitor', 'showProjectInsights', 'showFileBrowser', 'showSubagents', 'showMonitor', 'showProjectInsights', 'showFileBrowser', 'showSubagents',
'subagentActiveTabOnly', 'tabTwoRows', 'showTabCliLogos', 'tabOrientation', 'tabRailWidth', 'tabRailDetail', 'tabRailSort', 'tabArrangement', 'tabStateOrder', 'sessionListLayout', 'sessionSidebarFontSize', 'localEchoEnabled', 'keyboardHoldsRows', 'cjkInputEnabled', 'extendedKeyboardBar', 'subagentActiveTabOnly', 'tabTwoRows', 'showTabCliLogos', 'tabOrientation', 'tabRailWidth', 'tabRailDetail', 'tabRailSort', 'tabArrangement', 'tabStateOrder', 'sessionListLayout', 'sessionSidebarFontSize', 'localEchoEnabled', 'keyboardHoldsRows', 'cjkInputEnabled', 'cjkInputHoldUntilEnter', 'extendedKeyboardBar',
'skin', 'showPlanUsageLimits', 'showAttachmentsButton', 'showFileViewerButton', 'webglRendererEnabled', 'skin', 'showPlanUsageLimits', 'showAttachmentsButton', 'showFileViewerButton', 'webglRendererEnabled',
'terminalFontFamily', 'terminalFontWeight', 'terminalFontWeightBold', 'terminalFontFamily', 'terminalFontWeight', 'terminalFontWeightBold',
'language', 'language',
+202
View File
@@ -0,0 +1,202 @@
/**
* @fileoverview Send-on-Enter mode of the CJK input field (input-cjk.js,
* setting cjkInputHoldUntilEnter): typed text stays in the field until Enter,
* so a phone user can scroll the terminal and edit an answer before sending.
*
* Same vm-sandbox approach as input-cjk.test.ts, with a stub textarea that also
* carries the attributes and style the mode touches.
*/
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import vm from 'node:vm';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
const PHANTOM = '​';
function makeTextarea() {
const listeners = new Map<string, Array<(e?: unknown) => void>>();
const attrs: Record<string, string> = {};
return {
value: '',
placeholder: '',
style: { height: '' } as Record<string, string>,
scrollHeight: 34,
attrs,
blur: () => {},
focus: () => {},
classList: { contains: (c: string) => c === 'cjk-input-visible' },
setSelectionRange: () => {},
setAttribute: (k: string, v: string) => {
attrs[k] = v;
},
addEventListener: (ev: string, fn: (e?: unknown) => void) => {
listeners.set(ev, [...(listeners.get(ev) ?? []), fn]);
},
removeEventListener: (ev: string, fn: (e?: unknown) => void) => {
listeners.set(
ev,
(listeners.get(ev) ?? []).filter((f) => f !== fn)
);
},
fire(ev: string, arg: Record<string, unknown> = {}) {
const base = { preventDefault: () => {}, stopPropagation: () => {}, ...arg };
for (const fn of listeners.get(ev) ?? []) fn(base);
},
};
}
function load({ hold = true } = {}) {
const textarea = makeTextarea();
const sent: string[] = [];
const layout = vi.fn();
const context = vm.createContext({
window: {},
document: { getElementById: (id: string) => (id === 'cjkInput' ? textarea : null), activeElement: null },
navigator: { userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X)' },
KeyboardHandler: { updateLayoutForKeyboard: layout },
setTimeout: (fn: () => void, ms?: number) => setTimeout(fn, ms),
clearTimeout: (t: ReturnType<typeof setTimeout>) => clearTimeout(t),
performance: { now: () => performance.now() },
console,
});
const src = readFileSync(resolve(import.meta.dirname, '../src/web/public/input-cjk.js'), 'utf8');
vm.runInContext(src, context, { filename: 'input-cjk.js' });
const CjkInput = vm.runInContext('CjkInput', context);
CjkInput.init({ send: (t: string) => sent.push(t) });
CjkInput.setHoldUntilEnter(hold);
textarea.fire('focus');
return { CjkInput, textarea, sent, layout };
}
function type(textarea: ReturnType<typeof makeTextarea>, text: string) {
textarea.value = PHANTOM + text;
textarea.fire('input', { isComposing: false, inputType: 'insertText' });
}
describe('CJK input: Send on Enter', () => {
beforeEach(() => {
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'Date', 'performance'] });
});
afterEach(() => {
vi.useRealTimers();
});
it('keeps typed text in the field instead of streaming it', () => {
const { textarea, sent } = load();
type(textarea, 'use Postgres');
vi.advanceTimersByTime(5000);
expect(sent).toEqual([]);
expect(textarea.value).toBe(PHANTOM + 'use Postgres');
});
it('keeps text after a physical keystroke (no zero-latency flush)', () => {
const { textarea, sent } = load();
textarea.fire('keydown', { key: 'a', keyCode: 65, ctrlKey: false, altKey: false, metaKey: false });
type(textarea, 'a');
vi.advanceTimersByTime(1000);
expect(sent).toEqual([]);
});
it('keeps text across a composition cycle and autocorrect rewrites', () => {
const { textarea, sent } = load();
textarea.fire('compositionstart');
textarea.value = PHANTOM + 'teh';
textarea.fire('input', { isComposing: true, inputType: 'insertCompositionText' });
textarea.fire('compositionend');
textarea.value = PHANTOM + 'the';
textarea.fire('input', { isComposing: false, inputType: 'insertReplacementText' });
vi.advanceTimersByTime(5000);
expect(sent).toEqual([]);
expect(textarea.value).toBe(PHANTOM + 'the');
});
it('sends one line as text + CR on Enter, then clears the field', () => {
const { textarea, sent } = load();
type(textarea, 'yes, use Postgres');
const preventDefault = vi.fn();
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: false, preventDefault });
expect(preventDefault).toHaveBeenCalled();
expect(sent).toEqual(['yes, use Postgres\r']);
expect(textarea.value).toBe(PHANTOM);
});
it('sends a digit as typed so CLI menus still answer to it', () => {
const { textarea, sent } = load();
type(textarea, '2');
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: false });
expect(sent).toEqual(['2\r']);
});
it('sends several lines as one bracketed paste, Enter as a later write', () => {
const { textarea, sent } = load();
type(textarea, 'line one\nline two');
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: false });
expect(sent).toEqual(['\x1b[200~line one\rline two\x1b[201~']);
vi.advanceTimersByTime(150);
expect(sent).toEqual(['\x1b[200~line one\rline two\x1b[201~', '\r']);
});
it('drops paste markers inside the held text', () => {
const { textarea, sent } = load();
type(textarea, 'a\x1b[201~b\nc');
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: false });
expect(sent[0]).toBe('\x1b[200~ab\rc\x1b[201~');
});
it('treats Shift+Enter as a newline, never a send', () => {
const { textarea, sent } = load();
type(textarea, 'first');
const preventDefault = vi.fn();
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: true, preventDefault });
vi.advanceTimersByTime(10);
expect(preventDefault).not.toHaveBeenCalled();
expect(sent).toEqual([]);
});
it('sends a bare Enter when the field is empty (accepting a default answer)', () => {
const { textarea, sent } = load();
textarea.fire('keydown', { key: 'Enter', keyCode: 13, shiftKey: false });
expect(sent).toEqual(['\r']);
});
it('still forwards Backspace on an empty field to the PTY', () => {
const { textarea, sent } = load();
textarea.fire('keydown', { key: 'Backspace', keyCode: 8 });
expect(sent).toEqual(['\x7f']);
});
it('Escape clears the held text without sending', () => {
const { textarea, sent } = load();
type(textarea, 'never mind');
textarea.fire('keydown', { key: 'Escape', keyCode: 27 });
expect(sent).toEqual([]);
expect(textarea.value).toBe(PHANTOM);
});
it('turns autocorrect on in the mode and back off without it', () => {
const { CjkInput, textarea } = load();
expect(textarea.attrs.autocorrect).toBe('on');
expect(textarea.attrs.spellcheck).toBe('true');
CjkInput.setHoldUntilEnter(false);
expect(textarea.attrs.autocorrect).toBe('off');
expect(textarea.attrs.spellcheck).toBe('false');
expect(CjkInput.holdUntilEnter).toBe(false);
});
it('grows the field with its text and re-runs the keyboard layout', () => {
const { textarea, layout } = load();
layout.mockClear();
textarea.scrollHeight = 60;
type(textarea, 'a\nb\nc');
vi.advanceTimersByTime(1000);
expect(textarea.style.height).toBe('60px');
expect(layout).toHaveBeenCalled();
});
it('live mode is unchanged: text streams after the debounce', () => {
const { textarea, sent } = load({ hold: false });
type(textarea, 'hi');
vi.advanceTimersByTime(1000);
expect(sent).toEqual(['hi']);
});
});