mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
fix(mobile): keep chat's lease-only stream when a terminal pane unmounts
This commit is contained in:
@@ -55,6 +55,19 @@ export function useMobileSessionTerminalSubscriptionFoundation(
|
||||
// react-doctor-disable-next-line react-doctor/no-ref-current-in-render
|
||||
unsubscribeTerminalRef.current = unsubscribeTerminal
|
||||
|
||||
// An unmounted pane took its xterm with it; the next mount is a new document that needs a snapshot.
|
||||
// Chat's lease-only stream never drew into the document, so it stays.
|
||||
const releaseTerminalDocument = useCallback(
|
||||
(handle: string) => {
|
||||
if (terminalUnsubsRef.current.has(handle) && !leaseOnlyHandlesRef.current.has(handle)) {
|
||||
unsubscribeTerminalRef.current(handle)
|
||||
}
|
||||
webReadyHandlesRef.current.delete(handle)
|
||||
terminalResume.forget(handle)
|
||||
},
|
||||
[terminalResume]
|
||||
)
|
||||
|
||||
const clearTerminalCache = useCallback(() => {
|
||||
terminalUnsubsRef.current.forEach((unsub) => unsub())
|
||||
clearNativeChatInputLease()
|
||||
@@ -79,6 +92,7 @@ export function useMobileSessionTerminalSubscriptionFoundation(
|
||||
getTerminalRef,
|
||||
unsubscribeTerminal,
|
||||
unsubscribeTerminalRef,
|
||||
releaseTerminalDocument,
|
||||
clearTerminalCache
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ export function useMobileSessionTerminalWebview(scope: MobileSessionTabSwitching
|
||||
pendingSelectionRef,
|
||||
activeSessionTab,
|
||||
unsubscribeTerminal,
|
||||
unsubscribeTerminalRef,
|
||||
subscribeToTerminal,
|
||||
nativeChatStream,
|
||||
readMarkdownTab,
|
||||
@@ -108,18 +107,6 @@ export function useMobileSessionTerminalWebview(scope: MobileSessionTabSwitching
|
||||
}
|
||||
}, [])
|
||||
|
||||
// An unmounted pane took its xterm with it; the next mount is a new document that needs a snapshot.
|
||||
const releaseTerminalDocument = useCallback(
|
||||
(handle: string) => {
|
||||
if (terminalUnsubsRef.current.has(handle)) {
|
||||
unsubscribeTerminalRef.current(handle)
|
||||
}
|
||||
webReadyHandlesRef.current.delete(handle)
|
||||
terminalResume.forget(handle)
|
||||
},
|
||||
[terminalResume, terminalUnsubsRef, unsubscribeTerminalRef, webReadyHandlesRef]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
// Imperative handles change without layout events; inventory removal owns geometry cleanup.
|
||||
const liveHandles = new Set(terminals.map((terminal) => terminal.handle))
|
||||
@@ -306,7 +293,6 @@ export function useMobileSessionTerminalWebview(scope: MobileSessionTabSwitching
|
||||
sendTerminalUserInput,
|
||||
sendTerminalOrderedInput,
|
||||
setTerminalWebViewRef,
|
||||
releaseTerminalDocument,
|
||||
handleTerminalWebReady,
|
||||
notifyTerminalFrame,
|
||||
notifyTerminalPaneFrame,
|
||||
|
||||
Reference in New Issue
Block a user