Skip to content

fix(mobile): pin Paste and Enter beside More keys on the terminal key row - #51793

Closed
asunghong wants to merge 1 commit into
stablyai:mainfrom
asunghong:feat/mobile-terminal-row-paste-and-enter
Closed

asunghong wants to merge 1 commit into
stablyai:mainfrom
asunghong:feat/mobile-terminal-row-paste-and-enter

Conversation

@asunghong

Copy link
Copy Markdown
Contributor

ELI5

After #48529 shortened the phone terminal key row (Esc, Tab, Ctrl, Alt, arrows, ⌫, Paste, custom keys + pinned ⋯), Esc through → filled the entire 390 pt phone width. That pushed Paste off the right edge of the scrollable row (where users thought it had disappeared) and moved Enter completely into the ⋯ sheet.

This PR pins Paste (when the clipboard has content) and Enter (↵) right beside ⋯ on the trailing end of the key row, and tightens the row's horizontal spacing slightly so Esc, Tab, Ctrl, Alt, ↑ ↓ ← →, Paste, Enter, and ⋯ all fit on one line on a standard 390 pt phone without horizontal scrolling.

What Changed

Before

  • Paste rendered inside the horizontal ScrollView after ⌫, completely scrolled past the right edge of a 390 pt phone (with showsHorizontalScrollIndicator={false}).
  • Enter was removed from the key row and only accessible inside the ⋯ sheet (TerminalMoreKeysSheet).
  • Copying terminal text via handleSelectionCopy / handleClipboardWrite did not update canPaste, so Paste could remain hidden until the app backgrounded and foregrounded.

After

  • Pinned Paste and Enter beside ⋯ (mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.tsx):
    • Moved the Paste button (ClipboardPaste, shown when canPaste) out of the ScrollView so it is pinned beside ⋯.
    • Added a pinned Enter button (CornerDownLeft) right beside ⋯, wired through builtInPressProps(ENTER_KEY) so plain taps send \r and held Ctrl/Alt modifiers compose cleanly (Ctrl+Enter / Alt+Enter).
  • Compact one-row fit on 390 pt phones (mobile/src/terminal/session/accessory-keys/terminal-dock-styles.ts):
    • Adjusted KEY_GAP (8 → 5), ARROW_SEGMENT_WIDTH (28 → 25), key (minWidth: 32, paddingHorizontal: 5), and keyText.fontSize (13 → 12) while keeping sheetKey at paddingHorizontal: 9 so keys inside the ⋯ sheet keep their wider padding.
    • All visible keys (Esc, Tab, Ctrl, Alt, ↑ ↓ ← →, Paste, Enter, ⋯) now fit cleanly within 390 pt (~366 pt total inside the 374 pt row inner width) while keeping 46 pt vertical hit targets via TERMINAL_KEY_HIT_SLOP / TERMINAL_ARROW_HIT_SLOP.
  • No duplicate Enter in ⋯ (mobile/src/terminal/key-input/terminal-accessory-layout.ts):
    • Added 'enter' to TERMINAL_RAIL_KEY_IDS so MobileTerminalMoreKeysSheet omits duplicate Enter from the sheet's Keys grid (while keeping Paste in the sheet's action list and keeping the Duo side rail unchanged).
  • Immediate Paste availability after terminal copy (mobile/src/terminal/session/accessory-keys/use-mobile-session-accessory-selection.ts):
    • Set setCanPaste(true) after clipboard.writeText(...) succeeds in handleSelectionCopy and handleClipboardWrite.

Why

  • Pinning Paste and Enter next to ⋯ keeps the single-row height rule from feat(mobile): put the terminal keys you use on one row and the rest under ⋯ #48529 intact while guaranteeing that both high-frequency actions stay one tap away — even on 390 pt phones, even when Smart Rail prepends agent keys at the front of the ScrollView, and even while scrolled over custom keys.
  • ⌫ remains in the ScrollView right after the arrow cluster (since the software keyboard already provides Backspace when open), while Enter is immediately reachable when confirming CLI prompts, after voice dictation, or when the software keyboard is dismissed.

Linked Issue

Fixes #51790

Visual Proof

No iOS simulator/device capture is attached from this CLI-only session; verified the horizontal 390 pt width budget (366 pt <= 374 pt inner row width) and unit-tested pinned rendering outside ScrollView.

Testing

  • I manually tested these changes locally (no paired phone/simulator in this CLI session)
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns
    • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.test.tsx: verifies Paste (when canPaste is true) and Enter render pinned outside the ScrollView next to ⋯, Paste hides when canPaste is false, Paste invokes handlePaste, Enter sends \r and composes with held modifiers (Ctrl+Enter CSI-u), and TERMINAL_RAIL_KEY_IDS includes 'enter'.
    • Mobile oxlint, oxfmt, pnpm --dir mobile typecheck, pnpm --dir mobile typecheck:tests, and vitest suites pass.

Performance

None — renders one lightweight CornerDownLeft icon button on the existing terminal key row with no new subscriptions or timers.

Risk

Level: Low

  • Pure mobile UI layout adjustment in the terminal accessory bar; zero RPC/protocol/storage schema changes, so older paired desktop/SSH hosts and mobile-web builds remain fully compatible.
  • TERMINAL_RAIL_KEY_IDS only controls deduplication in the ⋯ sheet (MobileTerminalMoreKeysSheet), leaving Duo side-rail sets (SHELL_ROW_KEY_IDS / AGENT_ROW_KEY_IDS) and saved user shortcut layouts untouched.
  • Backout: plain revert.

AI Disclosure

Prepared with Gemini in Antigravity (agy) under human direction and review.

Review

Self-reviewed across iOS, Android, mobile-web, Duo side rail (besideRail unchanged), Smart Rail (pinned Paste/Enter/⋯ stay reachable even when smart keys push leading keys rightward), React Compiler compatibility, and TERMINAL_KEY_HIT_SLOP / TERMINAL_ARROW_HIT_SLOP touch target geometry.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The mobile terminal accessory row now keeps Enter and the more-keys control pinned beside Paste when clipboard content is available. Successful clipboard writes enable Paste. The key sizing values change, and tests cover key placement, Paste handling, and Enter behavior.

Severity of issue fixed: Low

Merge Risk: Low · up to 136e3

After copying text, the Paste button can occasionally stay hidden until the next clipboard refresh. This is a minor, self-correcting issue that does not block the main workflow, so the change is mergeable with owner awareness.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Paste and Enter are pinned beside the More keys on the mobile terminal key row. The changeset matches this. It moves Paste out of the scroll view, adds a pinned Enter …
Description check Passed The description follows the repository template and covers the required sections. It has an ELI5, a before/after account of What Changed, a Why section, a linked issue (Fixes #51790), a Visual Proof s…
Linked Issues check Passed Issue #51790 requires Paste (when the clipboard has content) and Enter to stay visible on the key row, pinned beside ⋯, and a compact single row. At head, MobileSessionAccessoryKeys.tsx renders Paste …
Out of Scope Changes check Passed All changes relate to #51790. The Paste and Enter pinning, the key-row sizing tweaks, and the MobileSessionAccessoryKeys controller Pick type support the row layout the issue requests. The 'enter' add…
Full details: Title check

Explanation

The title names the main change: Paste and Enter are pinned beside the More keys on the mobile terminal key row. The changeset matches this. It moves Paste out of the scroll view, adds a pinned Enter key, and tightens key sizing. The title also uses the conventional fix(mobile) prefix and stays under 80 characters.

Full details: Description check

Explanation

The description follows the repository template and covers the required sections. It has an ELI5, a before/after account of What Changed, a Why section, a linked issue (Fixes #51790), a Visual Proof section that explains the missing capture, Testing, Performance, Risk with level and backout plan, AI Disclosure, and a completed checklist. The before/after explanation is detailed and the mechanism is described.

Full details: Linked Issues check

Explanation

Issue #51790 requires Paste (when the clipboard has content) and Enter to stay visible on the key row, pinned beside ⋯, and a compact single row. At head, MobileSessionAccessoryKeys.tsx renders Paste outside the horizontal ScrollView, gated on canPaste, with handlePaste on press. It also renders a pinned Enter Pressable using builtInPressProps(ENTER_KEY), placed before the ⋯ button. Both sit outside the ScrollView, so they stay visible when the scroll content is wide. The ⌫ key and arrow cluster remain inside the ScrollView, as the issue does not require otherwise. Compact sizing is present in terminal-dock-styles.ts: KEY_GAP 5, ARROW_SEGMENT_WIDTH 25, key minWidth 32, paddingHorizontal 5, keyText fontSize 12, and the 46 pt hit slop is kept. The one-line fit of all keys is not independently measured: the Ctrl/Alt latch widths were not read, and the 366 pt budget is the author's arithmetic. Any overflow would scroll rather than clip. The Enter removal from the More sheet relies on 'enter' in TERMINAL_RAIL_KEY_IDS, which was not read directly. The author's test coverage was not run during this review.

Full details: Out of Scope Changes check

Explanation

All changes relate to #51790. The Paste and Enter pinning, the key-row sizing tweaks, and the MobileSessionAccessoryKeys controller Pick type support the row layout the issue requests. The 'enter' addition to TERMINAL_RAIL_KEY_IDS removes a duplicate Enter from the More sheet, which follows from pinning Enter on the row. The setCanPaste(true) calls after a successful copy in use-mobile-session-accessory-selection.ts keep the Paste button available when the clipboard has content, which the issue requests. The sheetKey padding is kept at 9 so sheet keys are unchanged. No unrelated change was identified in the summarized diff. Some hunks were not read directly because the diff tool was unavailable.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17a8db32-de87-46a7-b808-230ffea398c6
Commits

Reviewing files that changed from the base of the PR and between b9a1d24 and 136e39a.

Files selected for processing: 5

  • mobile/src/terminal/key-input/terminal-accessory-layout.ts
  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.test.tsx
  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.tsx
  • mobile/src/terminal/session/accessory-keys/terminal-dock-styles.ts
  • mobile/src/terminal/session/accessory-keys/use-mobile-session-accessory-selection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

await clipboard.writeText(
trimsGutterRef.current ? stripTerminalSelectionGutter(text) : text
)
setCanPaste(true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Stale clipboard refreshes can hide Paste after a successful copy or clipboard write.

handleSelectionCopy (line 178) and handleClipboardWrite (line 205) set canPaste to true after a successful write. A clipboard read that started before the write can resolve after it. That read then calls setCanPaste(text || image) with its earlier, empty result, and Paste is hidden. The read path has no check that it is still current. The paste hook's lock does not cover this path.

The same race applies to the availability refresh in use-mobile-session-attachments.ts (lines 126-147). That refresh runs on select-mode changes and app activation. A fix limited to refreshCanPaste would leave that path unguarded.

Make each availability update ignore results from reads that started before the latest successful write. Apply the same ordering rule to every refresh path that calls setCanPaste. Paste should stay available after a successful write until a newer read reports otherwise.

AmethystLiang added a commit that referenced this pull request Nov 29, 2026
… More

The phone key row from #48529 left Enter only under More and scrolled Paste
off screen, or hid it with an empty clipboard. On native phones the key row
is now a fixed bar of five 48 pt keys with no overlapping hit slop: Up, Down,
Paste, Enter (taking the spare width) and More. Paste keeps its slot and dims
when the clipboard reports nothing. More opens the existing sheet, which gains
a Close button and starts with the rest of the key row (Esc, Tab, Ctrl, Alt,
arrows, Backspace and Smart Rail keys) so repeat and latches work as before;
custom keys and Paste stay in its close-first rows. More is outlined while a
Ctrl or Alt latch waits. Tablets, the page build and the Duo rail are
unchanged.

Fixes #51790. Reference: #51793.

Co-authored-by: ASH <[email protected]>
AmethystLiang added a commit that referenced this pull request Nov 29, 2026
Enter no longer takes the filled primary or the bar's spare width; every bar
key looks alike and shares the room. That makes space for ⌫ between Paste and
Enter when all six fit as full-size 48 pt keys with each word at its full
width. The words are measured from hidden copies that nothing on the bar
changes, so the decision settles on the first layout; a long language or a
large text size leaves ⌫ in More rather than cutting a label short on the page
build, which can't shrink one to fit. ⌫ reuses the key row's press, repeat and
button-role handling, and a hold stops if ⌫ leaves the bar.

Refs #51793

Co-authored-by: ASH <[email protected]>
AmethystLiang added a commit that referenced this pull request Nov 29, 2026
Keep the common terminal keys in a fixed phone row. Use Paste, Delete and More icons, and retain keyboard and assistive activation.

Fixes #51790. Thanks to @asunghong for #51793.

Co-authored-by: ASH <[email protected]>
@AmethystLiang

Copy link
Copy Markdown
Contributor

Thanks, @asunghong, for the original toolbar fix. We landed the updated phone toolbar in #52645 and credited you in the merge commit.

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.

[Feature]: Reinstate Paste and add Enter on the visible mobile terminal key row

2 participants