Refactor session runtime persistence
This commit is contained in:
@@ -124,24 +124,22 @@ export const ThreadList: FC = () => {
|
||||
};
|
||||
|
||||
const ThreadListNew: FC = () => {
|
||||
const { clearSession } = useClawSessionReplay();
|
||||
return (
|
||||
<div
|
||||
onClickCapture={() => {
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="aui-thread-list-new h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm hover:bg-muted data-active:bg-muted"
|
||||
onClick={() => {
|
||||
clearActiveSessionId();
|
||||
pushHomeUrl();
|
||||
clearSession();
|
||||
window.dispatchEvent(new Event("claw-active-session-cleared"));
|
||||
}}
|
||||
>
|
||||
<ThreadListPrimitive.New asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="aui-thread-list-new h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm hover:bg-muted data-active:bg-muted"
|
||||
>
|
||||
<PlusIcon className="size-4" />
|
||||
New Task
|
||||
</Button>
|
||||
</ThreadListPrimitive.New>
|
||||
</div>
|
||||
<PlusIcon className="size-4" />
|
||||
New Task
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -754,6 +752,7 @@ export function toReplayRepository(
|
||||
}
|
||||
const id = `${fallbackSessionId}-run-${runStatus.run_id ?? "active"}`;
|
||||
const runStartedAtMs = resolveRunStartedAtMs(runStatus);
|
||||
const runCreatedAt = new Date(runStartedAtMs ?? Date.now());
|
||||
const parts = buildActiveRunParts(runStatus) as UIMessage["parts"];
|
||||
const uiMessage: UIMessage = {
|
||||
id,
|
||||
@@ -763,12 +762,17 @@ export function toReplayRepository(
|
||||
sessionId: session.session_id ?? fallbackSessionId,
|
||||
runId: runStatus.run_id,
|
||||
runStartedAtMs,
|
||||
custom: {
|
||||
sessionId: session.session_id ?? fallbackSessionId,
|
||||
runId: runStatus.run_id,
|
||||
runStartedAtMs,
|
||||
},
|
||||
},
|
||||
} as UIMessage;
|
||||
const threadMessage = {
|
||||
id,
|
||||
role: "assistant",
|
||||
createdAt: new Date(),
|
||||
createdAt: runCreatedAt,
|
||||
content: toThreadMessageContent(parts),
|
||||
status: { type: "running" },
|
||||
metadata: {
|
||||
@@ -776,6 +780,9 @@ export function toReplayRepository(
|
||||
unstable_annotations: [],
|
||||
unstable_data: [],
|
||||
steps: [],
|
||||
sessionId: session.session_id ?? fallbackSessionId,
|
||||
runId: runStatus.run_id,
|
||||
runStartedAtMs,
|
||||
custom: {
|
||||
sessionId: session.session_id ?? fallbackSessionId,
|
||||
runId: runStatus.run_id,
|
||||
|
||||
Reference in New Issue
Block a user