Fix Jupyter workspace session handoff
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
SidebarTrigger,
|
||||
} from "@/components/ui/sidebar";
|
||||
import {
|
||||
consumePendingWorkspaceSessionId,
|
||||
readActiveSessionId,
|
||||
writeActiveSessionId,
|
||||
} from "@/lib/claw-active-session";
|
||||
@@ -37,10 +38,21 @@ export const Assistant = () => {
|
||||
const messages = options.messages as UIMessage[];
|
||||
const selectedSessionId = readActiveSessionId();
|
||||
const lastSessionId = getLastSessionId(messages);
|
||||
const pendingWorkspaceSessionId =
|
||||
messages.length <= 1 ? consumePendingWorkspaceSessionId() : null;
|
||||
const usablePendingWorkspaceSessionId =
|
||||
pendingWorkspaceSessionId &&
|
||||
(!selectedSessionId ||
|
||||
selectedSessionId === pendingWorkspaceSessionId)
|
||||
? pendingWorkspaceSessionId
|
||||
: null;
|
||||
const selectedResumeSessionId =
|
||||
messages.length > 1 ? selectedSessionId : null;
|
||||
const outgoingSessionId =
|
||||
lastSessionId ?? selectedResumeSessionId ?? options.id;
|
||||
lastSessionId ??
|
||||
selectedResumeSessionId ??
|
||||
usablePendingWorkspaceSessionId ??
|
||||
options.id;
|
||||
const lastUserMessage = [...messages]
|
||||
.reverse()
|
||||
.find((message) => message.role === "user");
|
||||
@@ -49,7 +61,7 @@ export const Assistant = () => {
|
||||
return {
|
||||
body: {
|
||||
...body,
|
||||
id: options.id,
|
||||
id: outgoingSessionId,
|
||||
messages: lastUserMessage ? [lastUserMessage] : [],
|
||||
resumeSessionId:
|
||||
lastSessionId ?? selectedResumeSessionId ?? undefined,
|
||||
|
||||
Reference in New Issue
Block a user