Skip to content

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

Open
kkalisz wants to merge 12 commits into
Ark0N:masterfrom
kkalisz:feat/mobile-cjk-send-on-enter
Open

kkalisz wants to merge 12 commits into
Ark0N:masterfrom
kkalisz:feat/mobile-cjk-send-on-enter

Conversation

@kkalisz

@kkalisz kkalisz commented Nov 15, 2026 •

Copy link
Copy Markdown

Why

Sometimes an agent asks me a lot of questions at once. With a "grill me" skill, for example, it lists ten or twenty questions and I answer them in one go. To do that I need to see the questions and my answer at the same time: scroll the terminal to the next question, write a bit, scroll again, keep writing.

On my phone that doesn't work today. Whatever I type goes straight into the terminal. If I scroll up to reread a question, the keyboard closes and my half-written answer is stuck somewhere I can't see.

The prompt composer (#359, #444) helps, but it's a pop-up that covers the terminal: close it to scroll, reopen it to keep typing. For a long list of questions, that gets tiring.

The CJK Input field is almost what I wanted. It sits above the keyboard and stays put while the terminal scrolls. It just sends each character to the terminal right away and then empties itself.

What this adds

A new setting next to CJK Input: Input Field: Send on Enter (off by default, saved per device).

With CJK Input and this setting on, the field works like a chat box:

  • Your text stays in the field while you scroll the terminal, reread and edit.
  • Enter sends it.
  • Shift+Enter adds a new line. Several lines are sent as one paste, so a line break doesn't submit early.
  • Esc clears the field.
  • Backspace on an empty field still goes to the terminal, as before.
  • Autocorrect and spellcheck turn on, since nothing has been sent yet.
  • The field grows as you type, and the keyboard layout makes room for it.

With the setting off, CJK Input works exactly as it does today.

Screen.Recording.2026-11-16.at.11.38.25.mov
Implementation notes
  • Setting key: cjkInputHoldUntilEnter. Like cjkInputEnabled, it's in displayKeys and the mobile defaults, and it's stripped from the server PUT because SettingsUpdateSchema is strict.
  • _flush() returns early in this mode, so the debounce, the physical-key fast path and composition end no longer send anything. Only Enter does.
  • One line is sent as text + CR in one write, the same bytes live mode sends, so CLI menus that take a digit still work. Several lines go as one bracketed paste, with Enter as a separate write 120 ms later. That's the same approach as the composer's _sendComposedPrompt, and paste markers inside the text are dropped first.
  • Enter while an IME is still composing is treated as a newline.
  • The field grows up to the existing max-height: 68px, then scrolls. When the field is visible, KeyboardHandler.updateLayoutForKeyboard() reserves its real height instead of a fixed 44px.
  • Switching sessions still clears the field, held text included. A per-session draft like the composer's could be a follow-up.
  • Docs: one row in docs/wiki/Settings-Reference.md and a paragraph in the CJK input section of docs/wiki/Input-And-Voice.md. Also zh-CN strings for the new setting.

Testing

  • New test/input-cjk-hold.test.ts (14 tests). It runs the real input-cjk.js and covers each behavior above, plus the default mode still streaming text. Removing the hold check makes 4 of these tests fail, and removing the multi-line path makes the 2 paste tests fail.
  • Existing CJK, mobile keyboard, settings-structure and prompt-composer tests still pass.
  • typecheck, lint, format and the frontend checks pass.
  • Full npm test: 17,059 of 17,146 pass. The failing tests are in git, file, worktree, watcher and sensor code (none in input or mobile code), and they fail the same way on master on my Mac.

Verified

I've been running this on my own install (1.51.0 plus this change) since 2026-11-15, from my Android phone. My answer stays in the field while I scroll back to the question, and Enter sends it.

Open question

This is a draft. I'm happy to rename the setting or move it. It could also be a third option under "Mobile prompt entry" from #359.

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>
@kkalisz
kkalisz force-pushed the feat/mobile-cjk-send-on-enter branch from 7e2e4f1 to e0e2f68 Compare November 15, 2026 17:39
…nter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz
kkalisz marked this pull request as ready for review November 16, 2026 10:43
@Ark0N

Ark0N commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for this and for the clear write-up, and welcome to Codeman. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and goes out only when you press Enter. The change is focused, the settings plumbing is right (display key, mobile default, stripped from the strict settings PUT, zh-CN strings), live mode is unchanged, and typecheck, lint, format, the frontend checks and the related tests all pass locally.

These need fixing before merge:

  1. A long single-line answer goes out as one <text>\r burst (src/web/public/input-cjk.js:229-231). Over the WebSocket the whole frame reaches the pane in one write (src/web/routes/ws-routes.ts:198). src/web/route-helpers.ts:515-531 records that Claude Code 2.1.283 treats a burst like that of about 100 characters or more as a paste: the \r becomes a newline, the prompt sits unsent, and a later bare \r does not recover it (see also "A prompt must never be written into the pane as ONE burst" in CLAUDE.md). Live mode rarely hits this because its Enter carries only the last few characters. This mode carries the whole answer. Please keep val + '\r' for short input only (a menu digit, a one-word answer) and send anything longer as the text followed by a separately delayed Enter, as the local-echo Enter does (src/web/public/terminal-ui.js:1876-1897) and as the composer does. A test with a long line would pin it.

  2. Deleting the last held character also sends a Backspace to the CLI (src/web/public/input-cjk.js:458-465). The delete branch forwards \x7f whenever the field reads empty after a deletion, so typing ab and deleting both characters sends one \x7f (reproduced against this branch). In this mode the CLI's composer is not always empty: Attach, image paste, the Path key and the mic all put text there, and the stray DEL removes its last character. Please forward \x7f in this mode only when the phantom itself was deleted (the value no longer contains U+200B), and add a test.

  3. The delayed Enter after a multi-line paste is not bound to its session (src/web/public/input-cjk.js:236). _handleCjkInput reads activeSessionId when the 120 ms timer fires, and clear() does not cancel the timer, so switching tabs in that window sends the paste to one session and the Enter to another. The composer captures the session and sends that Enter with { useMux: true } (src/web/public/keyboard-accessory.js:1460-1463, and the "Mobile prompt composer" rule in src/web/CLAUDE.md). Sending the multi-line case through KeyboardAccessoryBar._sendComposedPrompt(sessionId, text) gives you both, plus its length check.

  4. The shell bar's one-shot Ctrl no longer works in this mode (src/web/public/input-cjk.js:196-201). Arm Ctrl and type c: nothing goes out until Enter, then c\r arrives with the modifier spent but not applied, so a shell runs c instead of getting Ctrl+C. While KeyboardAccessoryBar.isCtrlArmed() is true, please let the next single character bypass the hold.

  5. Please add a test that pins the new key as per-device (src/web/public/settings-ui.js:3446 and :5214). If cjkInputHoldUntilEnter ever reached the settings PUT, the strict schema would reject every save. test/tile-grid-per-device-setting.test.ts shows the short pattern.

Smaller ones, fine in this PR or as a follow-up:

  • Tapping the tab you are already on wipes the held text. src/web/public/app.js:7881 calls selectSession(id, { forceReload: true }), which reaches CjkInput.clear() at app.js:9440. No session switch happened, and the answer is gone. Skipping the clear on a same-session reload covers it.
  • With the keyboard down, .main keeps a fixed 84 px reserve (src/web/public/styles.css:14238), while the grown field can be 68 px tall above the 40 px toolbar. A three-line draft then covers about 24 px at the bottom of the terminal. Applying the measured reserve there as well, or shrinking the field to one line while the keyboard is down, fixes it.
  • The new placeholder (src/web/public/input-cjk.js:539-541) has no zh-CN entry in i18n.js.

Your question about where the setting should live (a mode of the CJK field, or an option of the mobile prompt entry from #359) is still open. The fixes above apply wherever it ends up.

Once 1 to 5 are addressed, this is in good shape to merge.

- 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>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks a lot for the detailed review, really helpful. I could reproduce all of them, and they're fixed in 95fb147. I've also been using it on my Android phone today and it behaves well.

  1. Long lines: short answers (up to 64 chars, so menu digits and one-word answers) still go out as text\r. Anything longer, or with several lines, now goes through _sendComposedPrompt(), passed in from terminal-ui.js as a sendPrompt callback. If the composer refuses the text, it stays in the field.
  2. Stray DEL: Backspace only reaches the CLI now when the field was already empty before the deletion. I went with that instead of checking for U+200B, because select-all + delete also removes the phantom and would still have sent a DEL.
  3. Enter going to the wrong session: gone with the change in 1. The session is captured at Enter and the composer sends the delayed Enter there. The old timer in input-cjk.js is removed.
  4. One-shot Ctrl: with Ctrl armed, the next single character skips the hold and goes through _handleCjkInput, so Ctrl then c is Ctrl+C again. It also works when Gboard commits the letter through composition. Anything else spends the modifier, like in live mode.
  5. Per-device test: added test/cjk-hold-per-device-setting.test.ts, based on the tile-grid one.

I did the smaller ones in this PR too:

  • Tapping the current tab: a reload of the same session keeps the draft now. It turned out the sidebar row and the geometry retry hit the same path, so the retry could wipe a draft without any tap.
  • Keyboard down: the field stays one line tall with the keyboard down, so the .main padding doesn't need to change with every new line.
  • zh-CN: added entries for both placeholders, including the old CJK one.

The docs paragraph is updated as well. On where the setting should live, I'm fine either way. If you'd rather have it as an option of the mobile prompt entry from #359, I can move it.

@Ark0N

Ark0N commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for turning the first review around so quickly, kkalisz. This PR adds a per-device Send on Enter mode to the pinned CJK input field, so on a phone a typed answer stays in the field while you scroll the terminal and goes out on Enter. All five fixes and the three smaller ones from the first review are in and correct: the long and multi-line path through _sendComposedPrompt with the session captured at Enter, the DEL only on an already empty field, the one-shot Ctrl, the per-device test, the same-session draft, the one-line field with the keyboard down, and the zh-CN strings. typecheck, lint, format, the frontend checks and the related tests (15 files, 355 tests) all pass here.

Two things still need fixing before merge. The first comes from my own suggestion in the first review, so sorry for the extra round.

  1. Short answers do not submit in a Codex session (src/web/public/input-cjk.js:247-250). A single line of up to 64 characters goes out as <text>\r in one write, and the WebSocket path writes it into the pane in one piece. I ran that against Codex 0.162.0 through a tmux client PTY. hello there friend\r, yes\r and even 1\r, each written in one go, stayed in Codex's composer as text plus a newline, and nothing was submitted. The same text followed by \r 80 ms or 120 ms later submitted every time. Codex treats characters that arrive in one fast burst as a paste and folds an Enter inside that burst into it. src/tmux-manager.ts:568-580 records this, which is why TmuxManager.sendInput (src/tmux-manager.ts:4351-4364) always sends Enter as its own write: a single character is typed (so a dialog takes a digit) and anything longer is pasted with markers. My suggestion to keep val + '\r' for short input was wrong for Codex. Please drop HELD_DIRECT_MAX and send:

    • a single character as the bare character, then \r as a separate write about 120 ms later, bound to the session captured at Enter;
    • anything longer through _sendPrompt, as you already do for long and multi-line text.

    If both go through _sendCjkPrompt, that also fixes the short path returning true (input-cjk.js:248-250) when _handleCjkInput drops the text because no session is active, which today clears the field. Please also update the tests that pin the one-write form (test/input-cjk-hold.test.ts:139 and :168-175) and the sentence "A short one-line answer is sent as typed" in docs/wiki/Input-And-Voice.md:73-75.

  2. On desktop the field grows without limit (src/web/public/styles.css:14187, input-cjk.js:228-236). The 68 px cap is only in the .touch-device rule, and the setting is not limited to phones. In Chromium with the real stylesheet, 25 lines made the field 502 px tall and shrank the terminal box from 768 px to 298 px. Every growth step also resizes the session's PTY through the terminal's ResizeObserver. A max-height: 68px with overflow-y: auto on #cjkInput outside the touch rule (or growing only on touch devices) fixes it.

Smaller ones, fine in this PR or as a follow-up:

  • _autoGrow sets the height 2 px short (input-cjk.js:232). The field is border-box with a 1 px border and scrollHeight leaves borders out, so a two-line draft scrolls inside the field. scrollHeight + (offsetHeight - clientHeight) fixes it.
  • setHoldUntilEnter (input-cjk.js:620) runs on every session select and every SSE reconnect and rewrites the field's attributes each time, even while you are typing in it. Returning early when the mode did not change keeps it from touching a focused field mid-composition.
  • A held draft is still cleared on a real session switch (src/web/public/app.js:9444), so a stray sideways swipe while scrolling loses the answer. You mentioned this in the description. A per-session Map like the composer's _composerDrafts would cover it.
  • The phone toolbar's Enter button does nothing while the CJK field is visible. sendEnterKey() (src/web/public/session-ui.js:2083) goes through xterm's onData, which returns early while window.cjkActive is set (terminal-ui.js:1778). Live CJK mode has the same problem today, but in this mode it is the key people will reach for.

Where the setting should live (a mode of the CJK field, or an option of the mobile prompt entry from #359) is still an open question. The fixes above apply either way.

Once 1 and 2 are in, this is ready to merge.

- Never send a held answer as text + CR in one write: Codex folds an Enter
  in the same burst into a paste. A single character is typed, then CR
  ~120 ms later to the session captured at Enter; anything longer goes
  through _sendComposedPrompt. Drops HELD_DIRECT_MAX. No session keeps the
  text in the field.
- Cap #cjkInput at 68px on every device, not only touch.
- _autoGrow adds the border height and skips a hidden field.
- setHoldUntilEnter returns early when the mode is unchanged.
- Per-session held drafts: stashed on switch and tile focus, restored on
  return, dropped when the session is removed.
- Toolbar Enter presses Enter in the visible CJK field (commits an active
  composition first).
- Blank-only field sends a bare Enter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks again, and no worries about the 64-char suggestion. I hadn't tested with Codex either, and the note in tmux-manager.ts explains it well. All of it is in 64ee504, including the smaller ones.

  1. Codex: HELD_DIRECT_MAX is gone and every held answer goes through _sendCjkPrompt. A single character is typed bare, then \r goes out 120 ms later to the session captured at Enter, the same split as submitsAsKeys. Anything longer goes through _sendComposedPrompt. With no session it returns false, so the field keeps the text. A field with only blank lines sends a bare Enter. Tests and the docs sentence are updated.
  2. Desktop height: max-height: 68px; overflow-y: auto is on #cjkInput itself now. _autoGrow also leaves the height alone while the field is hidden, otherwise it got stuck at 0px when the mode was applied before a session was shown.

Smaller ones:

  • _autoGrow adds offsetHeight - clientHeight, so two lines no longer scroll.
  • setHoldUntilEnter returns early when the mode didn't change.
  • Drafts are per session: stashed on switch, restored when you come back, dropped when the session is removed. The tile grid does the same on tile focus, since the one field follows focus and Enter would otherwise send tile A's draft to tile B.
  • The toolbar Enter calls CjkInput.submit() while the field is visible. If an IME is still composing, it blurs and refocuses first so the composition commits before the field is read.

I couldn't run Codex here, so the Codex part relies on your measurement.

@Ark0N

Ark0N commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the third round, kkalisz, and for building the Codex split exactly as described without a Codex to test against. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and only goes out when you press Enter.

Both fixes from the second review are in and correct. Every held answer now goes out with Enter as its own write. A single character is typed and \r follows 120 ms later to the session captured at Enter; anything longer goes through _sendComposedPrompt. #cjkInput is capped at 68 px on every device. The smaller items are in as well: the border-box height, the early return in setHoldUntilEnter, per-session drafts (tile focus included) and the toolbar Enter. Here, typecheck, lint, format, the frontend checks and the related tests (15 files, 322 tests) all pass.

I found one more small bug and two doc lines to update. I will apply them on top at merge time, so you don't need to push anything:

  1. Going Home loses the draft (src/web/public/app.js:11131). goHome() is the Codeman logo, and on a phone it is also how you get to the session overview. It sets activeSessionId to null without stashing the field, so when you pick the session again, _cleanupPreviousSession sees no outgoing session (app.js:9447) and clears the field. I reproduced this with the real goHome(), _cleanupPreviousSession() and input-cjk.js: a draft survives A, B, A but not Home, A. One stash before the null in goHome() fixes it: if (typeof CjkInput !== 'undefined' && this.activeSessionId) CjkInput.stashDraft?.(this.activeSessionId);. With that in place, the sentence in docs/wiki/Input-And-Voice.md:78 is true as written.
  2. src/web/CLAUDE.md:89 still says sendEnterKey() must go through triggerDataEvent. The new branch for the visible CJK field (src/web/public/session-ui.js:2088-2094) is a deliberate exception and needs a sentence there. In the same file, line 59 lists the per-device keys the strict schema does not declare, and cjkInputHoldUntilEnter belongs in that list.

Your question about where the setting should live (a mode of the CJK field, or an option of the mobile prompt entry from #359) is still open. None of the code above depends on it.

Thanks again for sticking with this through three rounds, and for running it on your own phone the whole way.

goHome() nulled activeSessionId without stashing the field, so picking the
session again cleared the draft. Stash it first.

Docs: src/web/CLAUDE.md lists cjkInputHoldUntilEnter among the per-device
keys the strict schema does not declare, and notes the sendEnterKey()
exception for the visible CJK field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks! I went ahead and pushed those three in 80d719d so you don't have to apply them at merge: the stash before the null in goHome(), and both src/web/CLAUDE.md lines (cjkInputHoldUntilEnter in the per-device list, and a sentence on the sendEnterKey() exception for the visible CJK field). The related tests pass here.

On where the setting lives, I'm happy with whatever you prefer, now or in a follow-up.

@Ark0N

Ark0N commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the fourth round, kkalisz, and for pushing the Home fix and both src/web/CLAUDE.md lines yourself. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and only goes out when you press Enter.

80d719d does what it should. goHome() now stashes the draft before it drops the active session, the new test pins that, and the per-device list and the sendEnterKey() exception in src/web/CLAUDE.md are right. On my side, typecheck, lint, format, the frontend syntax, browser-exclude and public-asset checks and the related tests (57 files, 1263 tests) pass.

Two things need fixing before merge. The second comes from my own suggestion in the second review, so sorry for one more round:

  1. The full npm test is red on this branch. test/file-browser-search.test.ts:1657 fails (1 failed, 17177 passed); the file fails the same way on its own and passes on master. That test pins this._activateFileBrowserSession?.(sessionId); as the line right after this.activeSessionId = sessionId; in selectSession(), and 64ee504 put CjkInput.restoreDraft?.(sessionId) between them (src/web/public/app.js:10050). Moving the restoreDraft line below the _activateFileBrowserSession call fixes it. Both calls are synchronous, so nothing else changes, and I checked the test's assertions against that order.

  2. When a digit answers a dialog, the Enter that follows lands on the next prompt (src/web/public/terminal-ui.js:4594-4598). Claude Code's dialogs act on the digit keypress itself, and Codeman already relies on that in two places: the Approvals Inbox never sends Enter after a menu answer (src/web/routes/approval-routes.ts:30-33), and the Discord bridge drops the Enter after a lone digit while a dialog is pending (src/discord-bridge.ts:1323-1324: "an Enter after it would land on whatever comes next"). In this mode every answer needs Enter to leave the field. So typing 1 and Enter at a permission prompt approves it with the 1, and the \r that follows 120 ms later confirms the highlighted option of whatever the CLI shows next. If Claude asked for two parallel tool calls, that is the second permission prompt, approved without anyone seeing it. Please send a lone digit without the delayed Enter while the session has a pending permission_prompt or elicitation_dialog (this.pendingHooks.get(sessionId), the same rule the server applies for the Discord bridge at src/web/server.ts:574), and keep the delayed Enter in every other case. Please also add a test next to the single-character one in test/mobile-shell-keyboard.test.ts, and a clause to the sentence at docs/wiki/Input-And-Voice.md:74.

Smaller things, fine in this PR or in a follow-up:

  • With a hardware keyboard, the Ctrl shortcuts still go to the CLI while the field holds a draft (src/web/public/input-cjk.js:483). Ctrl+Z (undo in the field) sends \x1a to the session, Ctrl+A on Windows or Linux sends \x01 instead of selecting the draft, and Ctrl+C on a selection sends an interrupt instead of copying. Live mode has the same handler, but there the field is almost always empty. In this mode it is enough to forward them only while the field is empty, which is the rule Backspace and the arrows already follow.
  • Two more paths drop the active session before the next cleanup and lose a held draft, the same way goHome() did: _replaceTileGrid (src/web/public/tile-grid.js:1850, Open group as tiles with a grid already open) and _onTileAdoptedElsewhere (src/web/public/tile-grid.js:3038). Rather than adding a stash before each of those nulls, CjkInput can remember which session the field's text belongs to and stash under that session inside clear(). That handles all of them at once.
  • Closing the focused tile from this tab stashes the closed session's draft again after discardDraft removed it (src/web/public/app.js:10917 reaching src/web/public/tile-grid.js:2660), so the entry stays in the map until the page reloads. Skipping the stash when this.sessions no longer has that id fixes it.
  • The phone toolbar's Enter now sends the CJK field in live mode too (src/web/public/session-ui.js:2088-2094). Before, it did nothing while the field was visible. That is a good change, and one sentence about it in .changeset/cjk-send-on-enter.md gets it into the release notes.

Where the setting should live (a mode of the CJK field, or an option of the mobile prompt entry from #359) is still an open question. None of the code above depends on it.

Once 1 and 2 are in, this is ready to merge. Thanks again for the care you've put into every round.

- selectSession restores the CJK draft after _activateFileBrowserSession,
  which test/file-browser-search.test.ts pins right after the
  activeSessionId assignment.
- A lone digit while the session has a pending permission_prompt or
  elicitation_dialog goes out without the delayed Enter: the dialog acts
  on the digit, and the Enter would confirm whatever comes next. Same
  rule as the Approvals Inbox and the Discord bridge.
- Changeset mentions the toolbar Enter sending the CJK field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks, and good catch on the digit. Both are in b5ad7af.

  1. npm test red: restoreDraft now comes after _activateFileBrowserSession in selectSession(), so test/file-browser-search.test.ts passes again (94 tests). test/cjk-hold-per-device-setting.test.ts pinned the old order; it now pins the new one, with a comment pointing at the file-browser test.
  2. Digit at a dialog: in _sendCjkPrompt, a lone digit goes out without the delayed Enter while this.pendingHooks.get(sessionId) has permission_prompt or elicitation_dialog. Every other case keeps the Enter, including a digit with only idle_prompt pending and a letter at a dialog. Two tests next to the single-character one in test/mobile-shell-keyboard.test.ts cover both sides; the first fails with the branch removed. docs/wiki/Input-And-Voice.md has the clause.

Also the changeset sentence for the toolbar Enter. I've left the other smaller items for a follow-up so this round stays small.

Checks here: typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass. Full npm test: the failures on this branch are the same ones current master shows on this Mac (git, remote files, folder routes, watchers, local model; environment), apart from test/tui/tui-e2e.test.ts "says so when the dialog has already left the screen", which passes and fails on alternate runs here and isn't touched by this branch.

…a held field

- CjkInput remembers which session the field's text belongs to (set by
  restoreDraft) and clear() stashes a held draft under it, so the paths
  that drop the active session before the next cleanup (goHome,
  _replaceTileGrid, _onTileAdoptedElsewhere) keep the answer.
  discardDraft() drops the owner of a removed session.
- Tile focus no longer stashes again for a tile closed from this tab.
- With a draft in the field, Ctrl shortcuts (undo, select all, copy) are
  the field's; they reach the CLI only while it is empty, like Backspace
  and the arrows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

I went ahead with the smaller items from your last review too, in 673a656, so they don't need a follow-up:

  • Drafts on every path: CjkInput now remembers which session the field's text belongs to (set by restoreDraft, which every session show and tile focus already calls), and clear() stashes a held draft under it. That covers goHome(), _replaceTileGrid and _onTileAdoptedElsewhere at once; the explicit stashes stay and are harmless. restoreDraft keeps the old owner while the field still holds another session's text.
  • Closed tile: discardDraft() drops the owner of a removed session, and tile focus only stashes when this.sessions still has the id, so a closed tile's draft no longer comes back into the map.
  • Hardware Ctrl: with a draft in the field, Ctrl+Z/A/C (and the other CTRL_KEYS) are left to the field; they reach the CLI only while it is empty, like Backspace and the arrows. Live mode is unchanged.

Tests in test/input-cjk-hold.test.ts (owner stash without a stash call, the dropped owner, the kept owner, Ctrl with and without a draft, live mode) and a pin for the tile guard; removing the owner stash or the Ctrl guard fails them. One existing test assumed clear() drops a restored draft; it now checks that a consumed stash doesn't come back once the field is emptied. One sentence in docs/wiki/Input-And-Voice.md for the Ctrl rule.

typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass. Full npm test here: the only failures are the ones current master shows on this Mac.

@Ark0N

Ark0N commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the fifth round, kkalisz, and for picking up the smaller items as well. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal, and goes out only when you press Enter.

b5ad7af and 673a656 work as described. test/file-browser-search.test.ts passes again, a lone digit at a permission or question dialog goes out without the trailing Enter, the field's owner covers Home, _replaceTileGrid and _onTileAdoptedElsewhere, a closed tile's draft stays out of the map, and Ctrl shortcuts stay in a field that holds a draft. On my side, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude and public-asset checks and the full npm test (758 files, 17,187 tests) all pass.

The owner stash in clear() introduced one regression:

  1. The keyboard bar's "⌫ All" key no longer throws a held draft away (src/web/public/input-cjk.js:630-634, reached from src/web/public/terminal-ui.js:5137). clearTerminalInput() empties the field through CjkInput.clear(), and since 673a656 that first stashes the field's text under its owner. So the text you just cleared comes back the next time the session is shown, either when you tap its own tab (the same-session reload keeps the field, then restoreDraft refills it) or when you switch away and back (the outgoing stash sees an empty field and leaves the stash alone). I reproduced both against the real input-cjk.js. If someone comes back to the tab and presses Enter to accept a default, expecting an empty field, they send the text they discarded.

    To fix it, give clear() a { discard } option that skips the stash, deletes any stash for _owner and keeps _owner, call CjkInput.clear({ discard: true }) from clearTerminalInput(), and add a test next to the owner-stash tests in test/input-cjk-hold.test.ts: clear with discard, then check that a same-tab restore and a switch away and back both leave the field empty. I tried that change on a patched copy of the module. Both paths stay empty, and the owner stash for Home still works.

I will apply that on top at merge time, along with a short Send on Enter section in the @fileoverview of src/web/public/input-cjk.js (it still describes only the live mode), so you don't need to push anything.

Where the setting should live (a mode of the CJK field, or an option of the mobile prompt entry from #359) is still an open question. None of the code above depends on it.

Thanks again for sticking with this across five rounds and testing each one on your own phone.

clear({ discard: true }) skips the owner stash, drops any older stash of
the owner and keeps the owner; clearTerminalInput() (the keyboard bar's
clear-line key) uses it, so a cleared draft does not come back on a
same-tab reload or a switch back. @fileoverview gains a Send on Enter
section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks! I pushed both in 387cb83 so there's nothing left to apply at merge:

  • "⌫ All" and a held draft: clear() takes { discard } as you described. It skips the owner stash, deletes any stash for _owner and keeps _owner. clearTerminalInput() calls CjkInput.clear({ discard: true }). Two tests next to the owner-stash ones in test/input-cjk-hold.test.ts: after a discard, a same-tab restore and a switch away and back both leave the field empty, and an older stash of the same session goes too. Both fail with the discard branch removed. The owner stash for Home is unchanged.
  • @fileoverview: input-cjk.js now has a short Send on Enter section next to the live-mode description.

typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass, and so do the CJK and keyboard tests. Full npm test here: the failures are the ones master shows on this Mac, plus test/tui/tui-e2e.test.ts "says so when the dialog has already left the screen", which flips between pass and fail on reruns here and isn't touched by this branch.

@Ark0N

Ark0N commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the sixth round, kkalisz, and for pushing the clear-line fix and the @fileoverview section yourself. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and goes out only when you press Enter.

387cb83 does what it should. The keyboard bar's clear-line key now throws a held draft away, both new tests pin that, and the @fileoverview describes both modes. Here, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude, public-asset and lockfile checks and the full npm test (758 files, 17,189 tests) all pass. npm run test:mobile -- test/mobile/keyboard.test.ts fails only the 5 tests that also fail on master.

I found one more small edge and one out-of-date doc sentence:

  1. If you turn Send on Enter off while a draft is held, the next keystroke sends that draft (src/web/public/input-cjk.js:670). setHoldUntilEnter(false) leaves the held text in the field, and live mode's next flush sends everything in it. With hold mode on, type rm -rf build, press Shift+Enter, type second line, turn the setting off and type x: the PTY receives rm -rf build\nsecond linex in one write, and in a shell the line feed runs the first line. The stashed drafts of other sessions also stay in the map and come back if the mode is switched on again. To fix it, remember the previous mode in setHoldUntilEnter, and when it goes from on to off, call _drafts.clear() and _resetToPhantom(). I tried that on a patched copy, and only the new key goes out. A test next to "turns autocorrect on in the mode and back off without it" in test/input-cjk-hold.test.ts pins it.

  2. docs/architecture-invariants.md:1272 and the comment at src/web/public/terminal-ui.js:4558 call _handleCjkInput() the CJK field's single choke point to the PTY, but in Send on Enter a held answer leaves through _sendCjkPrompt. The one-shot Ctrl rule still holds, since _sendCjkPrompt spends the modifier and an armed next character still goes through _handleCjkInput. One clause naming _sendCjkPrompt in both places is enough.

Both are small, so I will apply them on top at merge time and you don't need to push anything.

Where the setting should live (a mode of the CJK field, or an option of "Mobile prompt entry" from #359) is still an open question. None of the code above depends on it.

Thanks again for six careful rounds, and for testing each one on your own phone.

setHoldUntilEnter going from on to off clears the stashed drafts and
resets the field, so live mode's next flush sends only the new key, not
a held multi-line draft. The invariants doc and the _handleCjkInput
comment name _sendCjkPrompt as the path a held answer takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 17, 2026

Copy link
Copy Markdown
Author

Thanks! Both are in 57fdb52, so again nothing to apply at merge:

  1. Turning the mode off: setHoldUntilEnter remembers the previous mode, and going from on to off calls _drafts.clear() and _resetToPhantom(). A test next to "turns autocorrect on in the mode and back off without it" types a two-line draft, stashes another session's, turns the mode off and checks that the field is empty, a typed x is the only thing sent, and the other session's stash doesn't come back after turning the mode on again. It fails with the branch removed.
  2. Choke point wording: docs/architecture-invariants.md and the comment above the Ctrl handling in _handleCjkInput now say it is the single path in live mode, and that in Send on Enter a held answer leaves through _sendCjkPrompt(), which spends the modifier, while an armed next character still goes through _handleCjkInput().

typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass, and so do the CJK and keyboard tests. Full npm test here: the same machine-specific failures as master, plus the test/tui/tui-e2e.test.ts pty test that flips on reruns here.

@Ark0N

Ark0N commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the seventh round, kkalisz, and for testing every round on your own phone. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and goes out only when you press Enter.

57fdb52 does what the last review asked. Turning the mode off now drops the held draft and the stashed ones, so live mode's next flush sends only the new key, and the "single choke point" wording in docs/architecture-invariants.md and _handleCjkInput names _sendCjkPrompt. I also traced every path that clears the active session against the field's owner, and none of them sends one session's draft into another. Here, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude, public-asset and lockfile checks pass, and so do the related tests (13 files, 382 tests) and the full npm test (758 files, 17,190 tests).

I found three small things. I will apply them on top at merge time, so you don't need to push anything.

  1. The zh-CN placeholders never show (src/web/public/input-cjk.js:692). i18n.js skips every <textarea> ('textarea' is in SKIP_SELECTOR, src/web/public/i18n.js:36), so the placeholder setHoldUntilEnter() writes stays in English and the two entries at i18n.js:747-748 are never used. In a quick JSDOM check, an <input> with the same placeholder was translated and #cjkInput was not. The composer gets around this by translating in the module (src/web/public/keyboard-accessory.js:1546-1551), and I will do the same here with window.CodemanI18n.t().

  2. On desktop, the field still resizes the session's PTY while you type (src/web/public/input-cjk.js:246). Outside the touch rule the field sits in the flex column under the terminal, so any height it gains comes out of the terminal box. In Chromium with this stylesheet, the box went from 767 to 748 to 732 px for a one, two and three line draft. Each step refits and sends a resize (src/web/public/terminal-ui.js:1645-1700), which repaints the CLI, and when the terminal is at the bottom it first clears xterm's local scrollback (terminal-ui.js:1677). The 68 px cap limits this to two steps. I will keep the field at one fixed height on desktop while Send on Enter is on, and let it grow only on touch devices, where it is position: fixed and does not change the terminal's size.

  3. A phone's on-screen keyboard has no Shift+Enter, and the extended bar's newline key (src/web/public/keyboard-accessory.js:1224) sends ESC CR straight to the CLI. So in this mode the line break lands in the CLI's composer, ahead of the held text, instead of in the field. I will reword the sentence in docs/wiki/Input-And-Voice.md:72 to say a line break needs a hardware keyboard. If you want to make that key insert a newline into the field while the field is visible, that can be a follow-up PR.

Where the setting should live (a mode of the CJK field, or an option of "Mobile prompt entry" from #359) is still an open question. None of the code above depends on it.

Thanks again for sticking with this across seven rounds.

- 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>
@kkalisz

kkalisz commented Nov 17, 2026

Copy link
Copy Markdown
Author

Thanks! I pushed all three in 3c5b7e2, so there's nothing left to apply at merge:

  1. zh-CN placeholders: setHoldUntilEnter() translates the placeholder with window.CodemanI18n.t(), the same way the composer does, in both modes, so the two entries at i18n.js:747-748 now show. A test checks both placeholders go through t().
  2. Desktop PTY resizes: _autoGrow() only grows the field on a touch device (body.touch-device), where it is position: fixed. On a desktop it keeps its one-line CSS height and scrolls inside, so the terminal box and the PTY keep their size while you type. A test checks a three-line draft leaves the height alone and doesn't re-run the keyboard layout; it fails with the guard removed.
  3. Line breaks on a phone: docs/wiki/Input-And-Voice.md now says Shift+Enter needs a hardware keyboard, and that the extended bar's newline key goes to the CLI, not the field. Making that key insert into the field can be a follow-up PR, as you suggested.

typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass, and so do the related tests. Full npm test here: the same machine-specific failures as master, plus the flaky test/tui/tui-e2e.test.ts pty test.

@Ark0N

Ark0N commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the eighth round, kkalisz, and for testing every round on your own phone. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal and goes out only when you press Enter.

3c5b7e2 covers what the last review asked for on desktop and in the docs. _autoGrow() now grows the field only on touch devices, so a desktop draft no longer resizes the PTY. The Input And Voice paragraph now says Shift+Enter needs a hardware keyboard. On my side, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude, public-asset and lockfile checks and the full npm test (758 files, 17,192 tests) all pass. The CJK tests in npm run test:mobile -- test/mobile/keyboard.test.ts have one failure, and it fails the same way on master.

Three things are left, all small:

  1. The placeholder does not follow a live language switch (src/web/public/input-cjk.js:683). The new CodemanI18n.t() write at :707 comes after the early return for an unchanged mode. App Settings applies a language change live: applyLocalization(), then _updateCjkInputState() (src/web/public/settings-ui.js:3399 and :3412), which calls setHoldUntilEnter() with the same mode. So after a switch between English and Chinese, the field shows the old placeholder until the page reloads. Writing the placeholder above the early return, only when the translated text differs from the current one, fixes it and still leaves the other attributes alone during a composition. A test that changes what t returns and calls setHoldUntilEnter(true) again pins it.
  2. docs/wiki/Settings-Reference.md:51 still says "Shift+Enter adds a line" without the hardware-keyboard qualifier that 3c5b7e2 added to Input And Voice.
  3. The comment on the #cjkInput cap (src/web/public/styles.css:14202-14204) says the cap keeps the field from pushing the terminal down on desktop. The field no longer grows there, so the cap is only a backstop now, and the comment should say that.

I will apply these on top at merge time, so you do not need to push anything.

Where the setting should live (a mode of the CJK field, or an option of "Mobile prompt entry" from #359) is still an open question. None of the code above depends on it.

Thanks again for eight careful rounds.

…an, iOS lift

Found on a real Android phone (Chrome) and iPhone (Safari) with Send on Enter:

- A swipe that started on the live screen closed the keyboard: the content
  touchstart blurred the focused input before the gesture was known to be a
  tap or a scroll. It now skips the visible #cjkInput
  (_contentTouchStartBlurs()); a real tap still closes it (inert content, a
  link, a long press).
- Focusing the field scrolled the terminal off screen: KeyboardHandler's
  focusin scrollIntoView({ block: 'center' }) centred the fixed field in its
  ancestors. isInputElement() skips #cjkInput like xterm's inputs.
- Android pans the visual viewport to reveal the field (offsetTop 285 in a
  458/744 viewport), leaving only the terminal's last line visible. On phones
  .app now follows visualViewport.offsetTop while the keyboard is up, and the
  fixed bars inside .app are lifted from .app's bottom, so a partial pan does
  not lift them twice. Non-phone branches and resetLayout() clear the shift.
- On iOS the first keyboard open reported innerHeight as the visual height
  (323 vs 640), zeroing the bars' lift; the layout height is now the larger of
  innerHeight and documentElement.clientHeight.

Tests in test/keyboard-handler-pinned-field.test.ts and
test/terminal-touch-tap.test.ts; docs in architecture-invariants and
src/web/CLAUDE.md; changeset sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 17, 2026 •

Copy link
Copy Markdown
Author

Using Send on Enter on real phones turned up four more keyboard problems around the pinned field, so I tested it properly on both platforms and fixed them in e85bb83 (one commit). To see what the browsers actually do, I ran a temporary diagnostics build on my own install (not part of the PR) that logged touch targets, focus and blur, visualViewport and the position of the field, accessory bar and toolbar on every keyboard open.

What was wrong

  1. A swipe on the live screen closed the keyboard (Android). The content touchstart in initTerminal blurs the focused input before the gesture is known to be a tap or a scroll, and _blurMobileTerminalInput() blurs #cjkInput too. The log showed blur() called from that touchstart on div.xterm-screen, with no button involved. Swipes in scrolled-up history did not hit it ('history'), which is why it looked random. _contentTouchStartBlurs() now leaves the visible field focused; a real tap still closes the keyboard (inert content through the second-tap rule, a link in the link branch, which now blurs because touchstart did not, a long press in _beginTouchSelection).
  2. Focusing the field scrolled the terminal off screen (Android). KeyboardHandler's focusin handler runs scrollIntoView({ block: 'center' }) 400 ms later. isInputElement() skipped xterm's inputs but not #cjkInput, so the fixed field was centred in its ancestors. It skips #cjkInput now.
  3. Android pans the visual viewport to reveal the field. Measured on Chrome: offsetTop went 39 → 285 with a 458 px visual viewport in a 744 px layout one, while .app (sized to the visual viewport) stayed at the top: main at 50–458, the terminal at 50–328, so only its last line was visible. On phones updateLayoutForKeyboard() now moves .app by visualViewport.offsetTop while the keyboard is up, whatever has focus (no pan, the usual case, moves nothing). ⚠️ The transform makes .app the box its fixed children are placed against (header, toolbar, accessory bar, field), so their lift is measured from .app's bottom (insideLift); lifting them by the layout gap as well floated them above the keyboard on a partial pan. The case sheet lives outside .app and keeps the layout lift. The tablet branch and resetLayout() clear the shift.
  4. iOS: the toolbar area was empty on the first keyboard open. Logged per layout pass: innerHeight 323, documentElement.clientHeight 640, visual height 323, so innerHeight - visualBottom gave a lift of 0 and the field, accessory bar and toolbar stayed at 520–640, behind the keyboard; a second open had innerHeight 640 and was right. This was masked before by the delayed scrollIntoView from (2), which re-ran the layout once innerHeight had caught up. The layout height is now Math.max(innerHeight, documentElement.clientHeight).

(3) and (4) change the shared phone keyboard layout, so they apply to every phone user, not only the field; the changeset says so.

Tested on both platforms

On my own install (this branch plus the diagnostics), on an Android phone and an iPhone, with CJK Input and Send on Enter on, in a Claude session and a shell session:

  • Android: tap the field: the keyboard opens with the terminal still on screen above the field (before: only its last line). Type a draft, then swipe repeatedly starting on the live screen, on scrolled history and on the empty area: the keyboard stays up and the draft stays (before: a swipe on the live screen closed it). Enter sends. (That a real tap still closes the keyboard is covered by the existing and new unit tests; I did not check each tap kind on the phone.)
  • iPhone: tap the field: on the first open the field, accessory bar and toolbar sit directly on the keyboard and are filled (log: field 203–239, bar 239–283, toolbar 283–323 in a 323 px visual viewport; before: 520–640). Typing, swiping and sending with Enter work the same as on Android. No pan happened on iOS (offsetTop stayed 0), so (3) does nothing there.

Automated

  • test/keyboard-handler-pinned-field.test.ts (new, 9 tests): isInputElement skips the field but still scrolls ordinary inputs; the measured Android pan; a partial pan (offsetTop 100) does not lift twice; no pan keeps the old lift; a pan is followed whatever has focus; the tablet branch clears the shift; resetLayout() clears it; the measured iOS case (innerHeight 323, clientHeight 640) lifts by 317. Reverting insideLift to the layout gap fails two of them, reverting the layout height to innerHeight fails the iOS one.
  • test/terminal-touch-tap.test.ts: _contentTouchStartBlurs() true for xterm's textarea and false for the field; a link tap blurs the field and leaves other focus alone; and a pin on the touchstart line itself, since initTerminal is not run by that harness.
  • npm test: 17,097 of 17,217 pass; the failing files (git status/fetch, remote files, folder and worktree routes, watchers, host sensors, the local-model skill, public-asset tooling, shell launch) fail identically on master on this Mac. typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass.
  • npm run test:mobile -- test/mobile/keyboard.test.ts: 6 of 53 fail, the same 6 as master here (the toolbar-transform test, CJK local echo, three tap-intent tests, and the Codex streaming one).

Docs: a paragraph each in the keyboard-dismiss and folding-devices parts of docs/architecture-invariants.md (the latter also notes the iOS innerHeight), and the matching sentence in src/web/CLAUDE.md.

One edge I could not make happen but want to name: while .app carries the transform it is its own stacking context, so a menu inside it opened mid-pan could paint under a page-level overlay. It only applies on a phone with the keyboard up during a pan.

@Ark0N

Ark0N commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the ninth round, kkalisz, and for tracking these layout problems down on both an Android phone and an iPhone. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal, and it goes out only when you press Enter.

e85bb83 fixes real problems. A swipe on the live screen no longer closes the field's keyboard, and focusing the field no longer scrolls the terminal away. With the pan-follow, the header and terminal stay on screen when Chrome pans to the field. Here, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude and public-asset checks and the full npm test (759 files, 17,205 tests) all pass. npm run test:mobile -- test/mobile/keyboard.test.ts fails the same 5 tests as on master.

There is one regression in the new layout code:

  1. On a partial pan the case-picker sheet is lifted twice (src/web/public/mobile-handlers.js:478). The comment at :449 and docs/architecture-invariants.md:1144 say the case sheet lives outside .app, but #mobileCasePickerModal is inside it (index.html:4186; .app closes at :4348). Once .app carries the translate, the sheet is placed against .app's bottom like the bars, but it still gets the layout-viewport lift on top of that. In Chromium with the real stylesheets (390x744, a 458 px visual viewport panned 100 px, case picker open), the sheet ends up 186 px above the keyboard: its bottom is at 372 px and the keyboard starts at 558 px. On master it sits on the keyboard. Giving it the same lift as the bars fixes it:

    caseSheet.style.transform = insideLift > 0 ? `translateY(${-insideLift}px)` : '';

    With that change, the same probe puts the sheet on the keyboard at pans of 0, 100 and 285 px. Without a pan insideLift equals keyboardOffset, so test/mobile-case-sheet-keyboard-lift.test.ts still holds. The comment, the sentence in architecture-invariants and a test case (the open sheet at offsetTop 100 in test/keyboard-handler-pinned-field.test.ts) need to change with it.

The three items from the last round are still open. I will apply them at merge time together with the fix above, so you don't need to push anything:

  • The placeholder does not follow a live language switch, because the early return at src/web/public/input-cjk.js:683 comes before the CodemanI18n.t() write at :707.
  • docs/wiki/Settings-Reference.md:51 still says "Shift+Enter adds a line" without the hardware-keyboard qualifier.
  • The comment on the #cjkInput cap (src/web/public/styles.css:14202) still says the cap keeps the field from pushing the terminal down on desktop.

On scope: as your changeset says, the .app pan-follow and the iOS layout-height change apply to every phone user, not only to Send on Enter.

Where the setting should live (a mode of the CJK field, or an option of "Mobile prompt entry" from #359) is still an open question. None of the code above depends on it.

Thanks again for nine careful rounds.

- The phone case sheet (#mobileCasePickerModal) is inside .app, so once
  .app follows a pan it takes the same insideLift as the bars. The layout
  gap on top lifted it twice (186px above the keyboard at offsetTop 100).
  Comment, architecture-invariants and a test case updated.
- setHoldUntilEnter() writes the placeholder before the unchanged-mode
  early return, only when the text differs, so a live language switch
  shows up without touching the rest of the field.
- Settings-Reference: Shift+Enter needs a hardware keyboard.
- styles.css: the #cjkInput cap is a backstop now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kkalisz

kkalisz commented Nov 17, 2026

Copy link
Copy Markdown
Author

Thanks, good catch on the case sheet. You were right that it sits inside .app. All four are in c639b38, so nothing to apply at merge:

  1. Case sheet on a partial pan: it now takes insideLift like the bars. The comment in mobile-handlers.js and the sentence in docs/architecture-invariants.md now say it is inside .app. In test/keyboard-handler-pinned-field.test.ts the partial-pan case (offsetTop 100) checks the open sheet gets no extra lift, and the no-pan case checks it keeps the 286 px lift. The partial-pan check fails with the old line.
  2. Placeholder on a live language switch: setHoldUntilEnter() writes the placeholder before the early return, and only when the translated text differs. A new test switches what t() returns and calls it again with the same mode: the placeholder follows, and setAttribute is not called. It fails on the old order. The "unchanged mode" test now checks the placeholder is not written either.
  3. Settings-Reference.md: says Shift+Enter needs a hardware keyboard.
  4. The #cjkInput cap comment: now says it is a backstop, since the field only grows on touch devices.

typecheck, lint, format:check, check:frontend-syntax, check:frontend-dead and check:browser-excludes pass, and so do the 19 test files that load mobile-handlers.js or input-cjk.js (527 tests).

@Ark0N

Ark0N commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the tenth round, kkalisz, and for testing each change on both an Android phone and an iPhone. This PR adds a per-device Send on Enter mode to the pinned CJK input field: on a phone, a typed answer stays in the field while you scroll the terminal, and it goes out only when you press Enter.

c639b38 fixes everything from the last review. On a partial pan the case sheet now gets the same lift as the bars. The placeholder follows a live language switch and leaves the rest of the field alone. docs/wiki/Settings-Reference.md has the hardware-keyboard qualifier, and the comment on the #cjkInput cap now calls it a backstop.

On my side, typecheck, lint, format, the frontend syntax, dead-code, browser-exclude, public-asset and lockfile checks and the full npm test (760 files, 17,206 tests passed) all pass. npm run test:mobile -- test/mobile/keyboard.test.ts fails 5 tests, and the same 5 fail on master here too.

Nothing is left to change, and I have nothing to add at merge time, so this can be merged as it is.

Your question about where the setting should live (a mode of the CJK field, or an option of "Mobile prompt entry" from #359) is still open. None of the code depends on the answer.

Thanks again for sticking with this through ten rounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants