mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 10:37:35 +00:00
* feat(mobile): show a native chat's subagents like desktop
Move the background-tasks roster, header, view and the transcript roster
header into src/shared, with the words behind one English table that desktop
translates under its existing keys, so desktop output is unchanged.
The phone now draws the running child work strip above the composer (with
Stop, under desktop's conditions) and the transcript's subagent-group row,
from the host data it already receives. Child rows read unverifiable once the
session stream is lost.
* fix(mobile): review round 1 for the phone's subagent strip and roster row
- Roster row: spoken through one label that names its clock only once the group
settles; the verdict wraps instead of pushing the headline or chevron out.
- One twin rule: derive() and the phone both call isReplacedSubagentGroupTwin.
- Desktop strip says Stop / Stop all / details-unavailable through the shared table.
- One memoized composer tray holds the strip and the queued cards; the strip
carries its own conversation key.
- The strip latches the host clock offset once per conversation, so frames that
change nothing keep its rows memoized, and reads elapsed on the host's clock.
- Initial narrow guess includes the strip's margins; group labels uppercase by
style; the header ellipsizes at large text; row state words reuse mobile's.
* fix(mobile): give the child-work strip its own key beside the queued cards
Both siblings in the composer tray were keyed by the conversation's sessionKey, so
React logged a duplicate-key error whenever a structured chat with running
subagents opened.
* fix(mobile): re-derive the strip's host clock offset from every frame
The offset was latched per conversation, so a host restart or clock correction
while the chat stayed open left every elapsed time off until the chat was left.
It is now derived from each frame's host sample, rounded to a second so jitter
alone keeps the rows memoized.
* feat(native-chat): keep one kind's state forms on a narrow strip
The narrow total ("N background tasks") now replaces only a breakdown across
several kinds. A single kind keeps its state forms at every width, so a phone and
a narrow desktop pane still read "2 agents waiting — needs approval".
* test(native-chat): check catalog objects before reading keys
156 lines
6.7 KiB
TypeScript
156 lines
6.7 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'
|
|
import { useMobileNativeChatComposerTray } from './use-mobile-native-chat-composer-tray'
|
|
import { useMobileNativeChatVisualRenderer } from './MobileNativeChatVisual'
|
|
import { MobileNativeChatVisualContext } from './mobile-native-chat-visual-context'
|
|
|
|
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: string | undefined
|
|
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
|
|
)
|
|
const queued = controller.nativeChatQueued
|
|
const composerTray = useMobileNativeChatComposerTray({
|
|
queued: {
|
|
cards: queued.cards,
|
|
onSend: queued.send,
|
|
onDelete: queued.delete,
|
|
onEdit: queued.edit,
|
|
pause: queued.pause,
|
|
onResume: queued.resume,
|
|
sessionKey: queued.sessionKey,
|
|
// Nothing steers into a turn a Stop is ending; the host holds such a send until it ends.
|
|
// The indicator's `stopping` is the display status, decided once in the session hook.
|
|
steerHeld: controller.nativeChatTurnIndicator?.stopping === true
|
|
},
|
|
backgroundTasks: controller.nativeChatBackgroundTasks
|
|
})
|
|
const visuals = useMobileNativeChatVisualRenderer(controller.nativeChatVisualSource)
|
|
if (!controller.showNativeChat) {
|
|
return null
|
|
}
|
|
return (
|
|
<View style={styles.overlay}>
|
|
<MobileNativeChatVisualContext.Provider value={visuals}>
|
|
<MobileNativeChatView
|
|
messages={session.messages}
|
|
folded={folded}
|
|
status={session.status}
|
|
error={session.error}
|
|
readFailedFinally={session.readFailedFinally === true}
|
|
agent={controller.nativeChatAgent}
|
|
agentWorking={controller.nativeChatAgentWorking}
|
|
canStop={controller.nativeChatCanStop}
|
|
structuredActivityUi={controller.nativeChatStructured}
|
|
turnIndicator={controller.nativeChatTurnIndicator}
|
|
workingStartedAt={controller.nativeChatWorkingStartedAt}
|
|
settledTurns={controller.nativeChatSettledTurns}
|
|
turnJournal={controller.nativeChatTurnJournal}
|
|
streaming={streaming}
|
|
onStop={controller.handleNativeChatStop}
|
|
ask={controller.nativeChatAsk}
|
|
askKey={controller.nativeChatAskKey}
|
|
promptKey={controller.nativeChatPromptKey}
|
|
onDismissAsk={controller.dismissNativeChatAsk}
|
|
onAnswerAsk={controller.handleNativeChatAnswerAsk}
|
|
onCancelAsk={controller.handleNativeChatCancelAsk}
|
|
onCancelPrompt={controller.handleNativeChatCancelPrompt}
|
|
onCollapseAsk={controller.collapseNativeChatAsk}
|
|
onCollapsePrompt={controller.collapseNativeChatPrompt}
|
|
collapsedPrompt={controller.nativeChatCollapsedPrompt}
|
|
question={controller.nativeChatQuestion}
|
|
onAnswerQuestion={controller.handleNativeChatQuestionAnswer}
|
|
permission={controller.nativeChatPermission}
|
|
onRespondPermission={controller.handleNativeChatRespondPermission}
|
|
composerTray={composerTray}
|
|
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}
|
|
/>
|
|
</MobileNativeChatVisualContext.Provider>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
overlay: StyleSheet.absoluteFillObject
|
|
})
|