Repository navigation
fix(mobile): bound live terminal input latency - #12763
Conversation
📝 WalkthroughWalkthroughThe terminal session passes captured live input to 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
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].tsxmobile/src/session/MobileTerminalLiveInputStatus.tsxmobile/src/terminal/terminal-live-input-affordance.test.tsmobile/src/terminal/terminal-live-pending-flush-state.test.tsmobile/src/terminal/terminal-live-pending-flush-state.tsmobile/src/terminal/use-terminal-live-pending-input-flush.ts
| 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 |
There was a problem hiding this comment.
🩺 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/srcRepository: 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.tsRepository: 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)
})
JSRepository: 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.
ec7f215 to
565c528
Compare
|
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. |
Summary
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.