mirror of
https://github.com/stablyai/orca.git
synced 2026-10-03 08:02:12 +00:00
* fix(native-chat): show Claude working from the send, not the provider echo A structured session read as working only once a turnLifecycle row existed. Codex writes that row ~150ms after the send; Claude cannot write it until the SDK echoes the user message back, measured at a 3.4s median and 18s at p90, so the chat and every session list read idle for the whole wait. The journalled submission is the host's own evidence a turn is owed, so the shared projection reads it too. `unknown` still counts -- the ack budget elapsing answers delivery, not whether work is owed -- while a recovered `unknown` does not, which needed the existing row flag carried onto the projected submission. Claude's activity line now stays the generic fallback. Its only turn-wide frame carries a bare token, and its task_* prose describes a spawned task rather than this turn; compaction is kept because it explains an otherwise silent wait. * Fix structured chat pending-work lifecycle and mobile cancellation --------- Co-authored-by: Merge Sim <sim@local>
123 lines
4.9 KiB
TypeScript
123 lines
4.9 KiB
TypeScript
import { useMemo } from 'react'
|
|
import { StyleSheet, View } from 'react-native'
|
|
import { MobileNativeChatView, type MobileNativeChatInputLockReason } from './MobileNativeChatView'
|
|
import { foldMobileNativeChatMessages } from './mobile-native-chat-render-data'
|
|
import type { MobileNativeChatImageAttachments } from './use-mobile-native-chat-image-attachments'
|
|
import type { MobileNativeChatController } from './use-mobile-native-chat-controller'
|
|
import { useMobileNativeChatStreamingBubble } from './use-mobile-native-chat-streaming-bubble'
|
|
|
|
type Props = {
|
|
controller: MobileNativeChatController
|
|
/** Opens a tapped file reference (worktree-relative or absolute, optional
|
|
* :line(:col) suffix) through the shared tap-to-open flow. */
|
|
onOpenFile: (pathText: string) => void
|
|
/** Native-chat image attachments: picking adds a composer chip, and sending
|
|
* rides the pending images along with the message text (desktop parity). */
|
|
images: MobileNativeChatImageAttachments
|
|
onMicPress: () => void
|
|
micActive: boolean
|
|
dictationMode: 'toggle' | 'hold'
|
|
onMicPressIn: () => void
|
|
onMicPressOut: () => void
|
|
inputLockReason: MobileNativeChatInputLockReason | null
|
|
/** Latest send failure, rendered inline above the composer. */
|
|
sendErrorMessage: string | null
|
|
/** Drops that failure once a later send succeeds. */
|
|
onClearSendError: () => void
|
|
/** Stable host/worktree/tab identity for accepted-send completion fencing. */
|
|
sendSurfaceId: string
|
|
/** Reads the retained route's focus generation for accepted-send fencing. */
|
|
getSendCompletionGeneration: () => number
|
|
keyboardInset: number
|
|
}
|
|
|
|
/** Keeps the terminal mounted underneath chat so its PTY subscription survives
|
|
* view toggles while the native surface owns the visible composer. Also owns
|
|
* the streaming gate: this component stays mounted across those toggles, while
|
|
* the chat list below it does not. */
|
|
export function MobileNativeChatOverlay({
|
|
controller,
|
|
onOpenFile,
|
|
images,
|
|
onMicPress,
|
|
micActive,
|
|
dictationMode,
|
|
onMicPressIn,
|
|
onMicPressOut,
|
|
inputLockReason,
|
|
sendErrorMessage,
|
|
onClearSendError,
|
|
sendSurfaceId,
|
|
getSendCompletionGeneration,
|
|
keyboardInset
|
|
}: Props): React.JSX.Element | null {
|
|
const session = controller.nativeChatSession
|
|
const folded = useMemo(() => foldMobileNativeChatMessages(session.messages), [session.messages])
|
|
const streaming = useMobileNativeChatStreamingBubble(
|
|
folded,
|
|
controller.nativeChatStreamingText,
|
|
controller.nativeChatStreamScopeKey,
|
|
controller.nativeChatStreamLive
|
|
)
|
|
if (!controller.showNativeChat) {
|
|
return null
|
|
}
|
|
return (
|
|
<View style={styles.overlay}>
|
|
<MobileNativeChatView
|
|
messages={session.messages}
|
|
folded={folded}
|
|
status={session.status}
|
|
error={session.error}
|
|
agent={controller.nativeChatAgent}
|
|
agentWorking={controller.nativeChatAgentWorking}
|
|
canStop={controller.nativeChatCanStop}
|
|
structuredActivityUi={controller.nativeChatStructured}
|
|
streaming={streaming}
|
|
onStop={controller.handleNativeChatStop}
|
|
ask={controller.nativeChatAsk}
|
|
askKey={controller.nativeChatAskKey}
|
|
onDismissAsk={controller.dismissNativeChatAsk}
|
|
onAnswerAsk={controller.handleNativeChatAnswerAsk}
|
|
onCancelAsk={controller.handleNativeChatCancelAsk}
|
|
question={controller.nativeChatQuestion}
|
|
onAnswerQuestion={controller.handleNativeChatQuestionAnswer}
|
|
permission={controller.nativeChatPermission}
|
|
onRespondPermission={controller.handleNativeChatRespondPermission}
|
|
onOpenFile={onOpenFile}
|
|
hasMore={session.hasMore}
|
|
loadingEarlier={session.loadingEarlier}
|
|
onLoadEarlier={session.loadEarlier}
|
|
onSend={images.sendNativeChat}
|
|
sendSurfaceId={sendSurfaceId}
|
|
getSendCompletionGeneration={getSendCompletionGeneration}
|
|
getComposerEditGeneration={controller.getChatComposerEditGeneration}
|
|
pending={controller.chatPending}
|
|
imagePreviewsByMessageId={controller.chatImagePreviewsByMessageId}
|
|
composerText={controller.chatComposerText}
|
|
onComposerTextChange={controller.setChatComposerText}
|
|
onAttachImage={() => void images.attachImage('library')}
|
|
attachments={images.attachments}
|
|
onRemoveAttachment={images.removeAttachment}
|
|
isAttaching={images.isAttaching}
|
|
onMicPress={onMicPress}
|
|
micActive={micActive}
|
|
dictationMode={dictationMode}
|
|
onMicPressIn={onMicPressIn}
|
|
onMicPressOut={onMicPressOut}
|
|
inputLockReason={inputLockReason}
|
|
sendErrorMessage={sendErrorMessage}
|
|
onClearSendError={onClearSendError}
|
|
filePaths={controller.nativeChatFilePaths}
|
|
onNeedFiles={controller.loadNativeChatFiles}
|
|
sessionOptions={controller.nativeChatSessionOptions}
|
|
keyboardInset={keyboardInset}
|
|
/>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
overlay: StyleSheet.absoluteFillObject
|
|
})
|