mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* fix(mobile): dismiss the keyboard after sending to an agent Sending a message left the software keyboard up, covering the reply the user was waiting on. Drop it once the send is accepted, on all three send paths: the terminal live input, the buffered command input, and the chat composer. Gated on the tab being an agent session. A plain shell keeps the keyboard so back-to-back commands stay typeable, a rejected send keeps it so the handed-back draft stays editable, and the accessory shortcut row is untouched because dismissing would pull away the row being tapped. * fix(mobile): gate keyboard dismissal on accepted sends * fix(mobile): fence keyboard dismissal completions * fix(mobile): fence stale send completions * test(mobile): update terminal guard expectations * fix(mobile): restore rejected buffered drafts by origin * fix(mobile): preserve intentional buffered draft clears * fix(mobile): harden send dismissal authority * test(mobile): preserve Strict Mode send dismissal * fix(mobile): preserve drafts across terminal remints * fix(mobile): preserve draft ownership through terminal races * fix(mobile): harden draft recovery and send freshness * fix(mobile): fence route reuse and native draft clears * fix(mobile): preserve native draft edits before clear * test(mobile): pin the terminal-list sweep that bounds buffered drafts `bufferedTerminalDraftState.pruneDrafts(retainedHandles)` is the only bound on two structures that live as long as the session screen — the buffered-draft record and the pending-restoration map — and nothing failed when it was deleted or when it was pointed at the raw `terminal.list` handles instead of the retained set. Both mutations reddened 0 of 3,949 mobile tests. Adds the wiring pin (both mutations now redden it) plus two behavioural tests showing why the argument matters: `terminal.list` omits a chat-covered handle while the desktop graph reloads, so the raw list drops a draft the user is still holding while the retained set keeps it. --------- Co-authored-by: Merge Sim <merge@sim.local> Co-authored-by: Merge Sim <sim@local>
29 lines
811 B
TypeScript
29 lines
811 B
TypeScript
import { useCallback, useLayoutEffect, useRef } from 'react'
|
|
import { useFocusEffect } from 'expo-router'
|
|
|
|
type Options = {
|
|
readonly onBlur: () => void
|
|
readonly surfaceKey: string
|
|
}
|
|
|
|
/** Fences async send completions after a surface change or retained-route blur. */
|
|
export function useMobileSendCompletionGeneration({ onBlur, surfaceKey }: Options): () => number {
|
|
const generationRef = useRef(0)
|
|
const surfaceRef = useRef(surfaceKey)
|
|
useLayoutEffect(() => {
|
|
if (surfaceRef.current !== surfaceKey) {
|
|
surfaceRef.current = surfaceKey
|
|
generationRef.current += 1
|
|
}
|
|
}, [surfaceKey])
|
|
useFocusEffect(
|
|
useCallback(() => {
|
|
return () => {
|
|
generationRef.current += 1
|
|
onBlur()
|
|
}
|
|
}, [onBlur])
|
|
)
|
|
return useCallback(() => generationRef.current, [])
|
|
}
|