fix xdfx task start context recovery
This commit is contained in:
1 parent
17650afe96
commit
7d8656bfde
3 files changed
+47
-10
No files matched your search
+13
-2
@@ -37,6 +37,7 @@ import {
|
||||
} from "@/core/auth/task-purpose";
|
||||
import {
|
||||
fetchActionDetail,
|
||||
readActionDetail,
|
||||
readCopTaskDetail,
|
||||
type ActionDetail,
|
||||
} from "@/core/auth/task-deeplink";
|
||||
@@ -61,12 +62,22 @@ function useChatsBase(taskBase: string): {
|
||||
const agentId = agent_id ?? "";
|
||||
const ctx = readTaskContext();
|
||||
const detail = readCopTaskDetail();
|
||||
const isXdfx = taskBase.includes("/plan-task-action");
|
||||
const cachedAction = isXdfx ? readActionDetail() : null;
|
||||
const fallbackTaskId =
|
||||
detail?.id == null ? "" : String(detail.id).trim();
|
||||
const fallbackActionId = cachedAction?.id ? String(cachedAction.id).trim() : "";
|
||||
const fallbackActionTaskId = cachedAction?.taskId ? String(cachedAction.taskId).trim() : "";
|
||||
const hasMatchingAction =
|
||||
!!fallbackActionId && !!fallbackActionTaskId && fallbackActionTaskId === fallbackTaskId;
|
||||
// 3qfx 偶发会出现 task context 丢失,但任务详情仍在 sessionStorage 的情况。
|
||||
// 这里回退到任务详情里的 taskId,避免左侧对话列表直接失效成“空任务态”。
|
||||
const taskId = ctx?.taskId ?? fallbackTaskId;
|
||||
const actionId = ctx?.partitionByAction ? (ctx.actionId ?? "") : "";
|
||||
const taskId = ctx?.taskId ?? (hasMatchingAction ? fallbackActionTaskId : fallbackTaskId);
|
||||
const actionId = ctx?.partitionByAction
|
||||
? (ctx.actionId ?? "")
|
||||
: hasMatchingAction
|
||||
? fallbackActionId
|
||||
: "";
|
||||
return { taskId, agentId, actionId, chatsBase: `${taskBase}/agent/${agentId}/chats` };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user