fix(ui): correct Go to Session navigation across instances
This commit is contained in:
@@ -82,8 +82,20 @@ interface TaskSessionLocation {
|
|||||||
parentId: string | null
|
parentId: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
function findTaskSessionLocation(sessionId: string): TaskSessionLocation | null {
|
function findTaskSessionLocation(sessionId: string, preferredInstanceId?: string): TaskSessionLocation | null {
|
||||||
if (!sessionId) return null
|
if (!sessionId) return null
|
||||||
|
|
||||||
|
if (preferredInstanceId) {
|
||||||
|
const session = sessions().get(preferredInstanceId)?.get(sessionId)
|
||||||
|
if (session) {
|
||||||
|
return {
|
||||||
|
sessionId: session.id,
|
||||||
|
instanceId: preferredInstanceId,
|
||||||
|
parentId: session.parentId ?? null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const allSessions = sessions()
|
const allSessions = sessions()
|
||||||
for (const [instanceId, sessionMap] of allSessions) {
|
for (const [instanceId, sessionMap] of allSessions) {
|
||||||
const session = sessionMap?.get(sessionId)
|
const session = sessionMap?.get(sessionId)
|
||||||
@@ -440,7 +452,7 @@ export default function MessageBlock(props: MessageBlockProps) {
|
|||||||
const hasToolState =
|
const hasToolState =
|
||||||
Boolean(toolState) && (isToolStateRunning(toolState) || isToolStateCompleted(toolState) || isToolStateError(toolState))
|
Boolean(toolState) && (isToolStateRunning(toolState) || isToolStateCompleted(toolState) || isToolStateError(toolState))
|
||||||
const taskSessionId = hasToolState ? extractTaskSessionId(toolState) : ""
|
const taskSessionId = hasToolState ? extractTaskSessionId(toolState) : ""
|
||||||
const taskLocation = taskSessionId ? findTaskSessionLocation(taskSessionId) : null
|
const taskLocation = taskSessionId ? findTaskSessionLocation(taskSessionId, props.instanceId) : null
|
||||||
const handleGoToTaskSession = (event: MouseEvent) => {
|
const handleGoToTaskSession = (event: MouseEvent) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
setActivePermissionIdForInstance,
|
setActivePermissionIdForInstance,
|
||||||
setActiveQuestionIdForInstance,
|
setActiveQuestionIdForInstance,
|
||||||
} from "../stores/instances"
|
} from "../stores/instances"
|
||||||
import { loadMessages, setActiveSession } from "../stores/sessions"
|
import { ensureSessionParentExpanded, loadMessages, sessions as sessionStateSessions, setActiveSessionFromList } from "../stores/sessions"
|
||||||
import { messageStoreBus } from "../stores/message-v2/bus"
|
import { messageStoreBus } from "../stores/message-v2/bus"
|
||||||
import ToolCall from "./tool-call"
|
import ToolCall from "./tool-call"
|
||||||
|
|
||||||
@@ -201,7 +201,14 @@ const PermissionApprovalModal: Component<PermissionApprovalModalProps> = (props)
|
|||||||
|
|
||||||
function handleGoToSession(sessionId: string) {
|
function handleGoToSession(sessionId: string) {
|
||||||
if (!sessionId) return
|
if (!sessionId) return
|
||||||
setActiveSession(props.instanceId, sessionId)
|
|
||||||
|
const session = sessionStateSessions().get(props.instanceId)?.get(sessionId)
|
||||||
|
const parentId = session?.parentId ?? session?.id
|
||||||
|
if (parentId) {
|
||||||
|
ensureSessionParentExpanded(props.instanceId, parentId)
|
||||||
|
}
|
||||||
|
|
||||||
|
setActiveSessionFromList(props.instanceId, sessionId)
|
||||||
props.onClose()
|
props.onClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user