fix(mobile): Send on Enter review fixes

- A long single line (over 64 characters) or several lines now go through
  the composer's _sendComposedPrompt: one bracketed paste, then Enter as a
  separate delayed write to the session captured at Enter. Claude Code took
  a long `<text>\r` burst as a paste and left it unsent, and the old delayed
  Enter followed a tab switch. A refused prompt keeps the text in the field.
- Deleting held text no longer sends Backspace to the PTY. It goes out only
  when the field was already empty (the phantom itself deleted), so
  select-all + delete is covered too.
- With the one-shot Ctrl armed, the next single typed character skips the
  hold and reaches _handleCjkInput, which turns it into the control byte;
  any other change spends the modifier, as in live mode.
- A reload of the session already shown (tapping its tab, the geometry
  retry) keeps a held draft.
- With the keyboard down the field stays one line tall, so it no longer
  covers the terminal's last rows.
- zh-CN strings for both field placeholders, and a test pinning
  cjkInputHoldUntilEnter as per-device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kamil KaliszandClaude Opus 5.5 committed 2026-11-16 14:18:18 +01:00
1 parent b8a4466643
commit 95fb147e9c
9 files changed
+474 -33

No files matched your search

+45
View File
@@ -547,6 +547,51 @@ describe('one-shot Ctrl through the CJK input field', () => {
});
});
describe('Send on Enter: a long or multi-line held answer goes out as a composed prompt', () => {
// _sendCjkPrompt is CjkInput's sendPrompt callback. It hands the text to the
// composer's _sendComposedPrompt with the session captured at Enter, so the
// delayed Enter cannot follow a tab switch.
function promptApp() {
const { CodemanApp, bar } = loadTerminalModule();
bar.clearCtrl();
const app = Object.create(CodemanApp.prototype) as {
activeSessionId: string | null;
_sendCjkPrompt(text: string): boolean;
};
app.activeSessionId = 'session-a';
const composed = vi
.spyOn(bar as unknown as { _sendComposedPrompt: (s: string, t: string) => boolean }, '_sendComposedPrompt')
.mockReturnValue(true);
return { app, bar, composed };
}
it('sends through the composer path, bound to the session active at Enter', () => {
const { app, composed } = promptApp();
expect(app._sendCjkPrompt('line one\nline two')).toBe(true);
app.activeSessionId = 'session-b';
expect(composed).toHaveBeenCalledWith('session-a', 'line one\nline two');
composed.mockRestore();
});
it('spends an armed one-shot Ctrl, like any multi-character chunk', () => {
const { app, bar, composed } = promptApp();
bar.toggleCtrl();
app._sendCjkPrompt('x'.repeat(100));
expect(bar.isCtrlArmed()).toBe(false);
composed.mockRestore();
});
it('reports a refusal so the field keeps the text', () => {
const { app, composed } = promptApp();
composed.mockReturnValue(false);
expect(app._sendCjkPrompt('x'.repeat(100))).toBe(false);
app.activeSessionId = null;
expect(app._sendCjkPrompt('x'.repeat(100))).toBe(false);
expect(composed).toHaveBeenCalledTimes(1);
composed.mockRestore();
});
});
describe('armed styling survives the light-skin overrides', () => {
const mobileCss = readFileSync(resolve('src/web/public/mobile.css'), 'utf8');