Skip to content

fix(mobile): bound live terminal input latency - #12763

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/mobile-live-input-latency
Aug 5, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/mobile-live-input-latency

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep at most one live terminal input RPC in flight while coalescing ordered pending bytes
  • cancel stale queued input when the terminal mirror resets
  • show native live-input text immediately while remote PTY echo catches up

This is transport-agnostic and improves high-RTT relay, Tailscale, and direct connections.

Deterministic regression

The queue test holds the first send unresolved, types a/b/c, and verifies the wire sends a followed by one coalesced bc request instead of one acknowledged request per character.

Validation

Physical iOS validation over an artificially delayed connection remains desirable.

Known caveat

The immediate local preview cannot currently detect when remote terminal echo is disabled, so password input may remain visible in the mobile input bar. This should be resolved or explicitly accepted before merge.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The terminal session passes captured live input to MobileTerminalLiveInputStatus. The status control displays live input with head truncation and uses the keyboard prompt when no input exists. Pending mirror sends use typed shared state with batching, coalescing, sequential draining, cancellation, and generation tracking. The flush hook uses this state for queueing and cleanup. Tests cover display, batching, failures, exceptions, and cancellation.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the change and validation, but it omits the required Screenshots, AI Review Report, and Security Audit sections. Add the required Screenshots, AI Review Report, and Security Audit sections, and state whether each platform and security area was reviewed.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: reducing mobile live terminal input latency.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd54e48f-55fb-4173-89b2-9dd1337564c2

📥 Commits

Reviewing files that changed from the base of the PR and between fde816e and ec7f2159dcd6fa1b58ce8c213b7ab478761efcf5.

📒 Files selected for processing (6)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/MobileTerminalLiveInputStatus.tsx
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/terminal-live-pending-flush-state.test.ts
  • mobile/src/terminal/terminal-live-pending-flush-state.ts
  • mobile/src/terminal/use-terminal-live-pending-input-flush.ts

Comment on lines +60 to +68
state.activeRequests = batch.requests
const sent = await batch.sender(batch.handle, batch.payload).catch(() => false)
if (state.generation !== generation) {
return false
}

state.activeRequests = []
batch.requests.forEach(({ resolve }) => resolve(sent))
allSent &&= sent

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 4 --glob '*.{ts,tsx}' \
  'sendLiveTerminalInputRef|sendLiveTerminalInput' mobile

rg -n -C 5 --glob '*.{ts,tsx}' \
  'queueTerminalLiveMirrorSend|TerminalLiveMirrorSender' mobile/src

Repository: stablyai/orca

Length of output: 33537


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo '--- terminal-live-pending-flush-state.ts ---'
sed -n '1,120p' mobile/src/terminal/terminal-live-pending-flush-state.ts

echo '--- sendLiveTerminalInput implementation ---'
sed -n '3010,3138p' mobile/app/h/[hostId]/session/[worktreeId].tsx

echo '--- current tests mentioning throwing errors / sync throws ---'
sed -n '116,140p' mobile/src/terminal/terminal-live-pending-flush-state.test.ts
sed -n '152,172p' mobile/src/terminal/terminal-live-pending-flush-state.test.ts

Repository: stablyai/orca

Length of output: 9061


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

node - <<'JS'
async function drain(sender) {
  try {
    return await sender()
  } catch {
    return false
  }
}

let resolveR;
const request = new Promise((resolve) => { resolveR = resolve });
// Simulates a sender that throws in its async function body before any await.
request.then((value) => {
  console.log('returns', value)
}).catch((error) => {
  console.log('caught', error.message === 'boom')
})
drain(() => { throw new Error('boom') })
  .then(() => {}, () => {})
  .then(() => {
    console.log('drain returns false:', true)
    console.log('request remains pending:', request.pendingPending !== false)
    let rejected = false
    request.catch(() => { rejected = true })
    setTimeout(() => {
      if (rejected) return
      console.log('request is actually not resolved during drain catch path')
      process.exit(2)
    }, 0)
  })
JS

Repository: stablyai/orca

Length of output: 264


Resolve pending requests during synchronous sender failures.

batch.sender(...).catch(...) handles promises rejected after batch.sender returns but not synchronized throws inside an async sender body, such as sendLiveTerminalInput. That leaves the drain resolved while the queued request stays pending and activeRequests non-empty. Use Promise.resolve().then(() => batch.sender(...)) before catching, or make the current sender explicitly not throw synchronously and cover activeRequests in the queue tests.

@Jinwoo-H
Jinwoo-H force-pushed the fix/mobile-live-input-latency branch from ec7f215 to 565c528 Compare August 5, 2026 20:47
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Jinwoo-H
Jinwoo-H merged commit 73cd4c3 into main Aug 5, 2026
44 checks passed
@Jinwoo-H
Jinwoo-H deleted the fix/mobile-live-input-latency branch August 5, 2026 20:52
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

1 participant