fix(mobile): Send on Enter placeholder i18n, one-line field on desktop

- input-cjk.js translates its placeholder with CodemanI18n.t(), like the
  prompt composer, since i18n.js skips <textarea> subtrees; the zh-CN
  entries now show.
- The field only grows on touch devices, where it is position: fixed.
  On a desktop it sits under the terminal, so growing would shrink the
  terminal box and resize the PTY on every line; it stays one line and
  scrolls there.
- Input And Voice: a line break needs a hardware keyboard (no Shift+Enter
  on a phone keyboard, and the extended bar's newline key goes to the CLI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kamil KaliszandClaude Opus 5.5 committed 2026-11-17 06:42:37 +01:00
1 parent 57fdb52f7c
commit 3c5b7e2199
3 files changed
+56 -15

No files matched your search

+29 -3
View File
@@ -49,7 +49,12 @@ function makeTextarea() {
};
}
function load({ hold = true, promptResult = true } = {}) {
function load({
hold = true,
promptResult = true,
touch = true,
translate,
}: { hold?: boolean; promptResult?: boolean; touch?: boolean; translate?: (s: string) => string } = {}) {
const textarea = makeTextarea();
const sent: string[] = [];
const prompts: string[] = [];
@@ -65,8 +70,12 @@ function load({ hold = true, promptResult = true } = {}) {
},
};
const context = vm.createContext({
window: {},
document: { getElementById: (id: string) => (id === 'cjkInput' ? textarea : null), activeElement: null },
window: translate ? { CodemanI18n: { t: translate } } : {},
document: {
getElementById: (id: string) => (id === 'cjkInput' ? textarea : null),
activeElement: null,
body: { classList: { contains: (c: string) => touch && c === 'touch-device' } },
},
navigator: { userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X)' },
KeyboardHandler: { updateLayoutForKeyboard: layout },
KeyboardAccessoryBar: bar,
@@ -321,6 +330,23 @@ describe('CJK input: Send on Enter', () => {
expect(textarea.value).toBe(PHANTOM);
});
it('stays one line on a desktop, where growing would resize the PTY', () => {
const { textarea, layout } = load({ touch: false });
layout.mockClear();
textarea.scrollHeight = 60;
type(textarea, 'a\nb\nc');
vi.advanceTimersByTime(1000);
expect(textarea.style.height).toBe('');
expect(layout).not.toHaveBeenCalled();
});
it('translates its placeholder itself, since i18n.js skips textareas', () => {
const { CjkInput, textarea } = load({ translate: (s) => `zh:${s}` });
expect(textarea.placeholder).toBe('zh:Type, Enter to send (Shift+Enter: new line, Esc: clear)');
CjkInput.setHoldUntilEnter(false);
expect(textarea.placeholder).toBe('zh:CJK input (Enter = send, Esc = clear)');
});
it('turns autocorrect on in the mode and back off without it', () => {
const { CjkInput, textarea } = load();
expect(textarea.attrs.autocorrect).toBe('on');