Fix session cancel and new task routing

This commit is contained in:
wuyang6
2026-06-12 16:35:38 +08:00
parent 0a3e044c9d
commit a2f39e7312
5 changed files with 58 additions and 8 deletions
+8 -5
View File
@@ -255,12 +255,15 @@ function AssistantWorkspace() {
setActiveSessionId(next);
};
const handleChanged = (event: Event) => {
const detail = (event as CustomEvent<{ sessionId?: string | null }>)
.detail;
const next =
detail?.sessionId ?? readSessionIdFromUrl() ?? readActiveSessionId();
const customEvent = event as CustomEvent<{ sessionId?: string | null }>;
const hasExplicitSession =
customEvent.detail &&
Object.prototype.hasOwnProperty.call(customEvent.detail, "sessionId");
const next = hasExplicitSession
? (customEvent.detail.sessionId ?? null)
: (readSessionIdFromUrl() ?? readActiveSessionId());
console.log("[active-session] event-changed", {
detailSessionId: detail?.sessionId,
detailSessionId: customEvent.detail?.sessionId,
next,
});
setActiveSessionId(next);
@@ -131,8 +131,8 @@ const ThreadListNew: FC = () => {
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();
clearActiveSessionId();
clearSession();
window.dispatchEvent(new Event("claw-active-session-cleared"));
}}
@@ -203,8 +203,8 @@ function CollapsedSidebarRail({
<CollapsedIconButton
label="新任务"
onClick={() => {
clearActiveSessionId();
pushHomeUrl();
clearActiveSessionId();
clearSession();
window.dispatchEvent(new Event("claw-active-session-cleared"));
}}