提交代码
This commit is contained in:
1 parent
cc5ada1f3d
commit
7282a32859
76 files changed
+9757
-8
No files matched your search
@@ -190,6 +190,21 @@ export async function createTask(
|
||||
return readJson<SavedTask>(res, "create task");
|
||||
}
|
||||
|
||||
/**
|
||||
* get-or-create:存在则返回(含 messages 回显),不存在则用该 id 初始化一条空记录。
|
||||
* 宿主传的 taskId 不固定,新 id 不再 404。幂等。
|
||||
*/
|
||||
export async function ensureTask(
|
||||
cfg: ApiConfig,
|
||||
payload: { id: string; title?: string; brief?: string; agents?: AgentInput[] },
|
||||
): Promise<SavedTask> {
|
||||
const res = await authedFetch(cfg, `${TASKS(cfg)}/ensure`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ title: "", agents: [], ...payload }),
|
||||
});
|
||||
return readJson<SavedTask>(res, "ensure task");
|
||||
}
|
||||
|
||||
export async function updateTask(
|
||||
cfg: ApiConfig,
|
||||
id: string,
|
||||
|
||||
@@ -11,7 +11,15 @@
|
||||
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||
import type { AgentInput, AgentResult, Dialogue, SavedTask, SeatView } from "@/types";
|
||||
import { useParallelRun } from "@/composables/useParallelRun";
|
||||
import { createTask, getTask, listModels, listTasks, updateTask, type ApiConfig, type ModelItem } from "@/api";
|
||||
import {
|
||||
createTask,
|
||||
ensureTask,
|
||||
listModels,
|
||||
listTasks,
|
||||
updateTask,
|
||||
type ApiConfig,
|
||||
type ModelItem,
|
||||
} from "@/api";
|
||||
import { DEFAULT_BASE_URL, DEFAULT_MODEL } from "@/config";
|
||||
import ParallelSeatStrip from "./ParallelSeatStrip.vue";
|
||||
import MessageBubble from "./MessageBubble.vue";
|
||||
@@ -208,13 +216,21 @@ async function loadTask(id: string) {
|
||||
showHistory.value = false;
|
||||
errorMsg.value = null;
|
||||
try {
|
||||
const task = await getTask(cfg.value, id);
|
||||
if (!task) return;
|
||||
// get-or-create:新 id 直接初始化空记录(不 404);已存在则回显其聊天记录。
|
||||
const task = await ensureTask(cfg.value, {
|
||||
id,
|
||||
agents: props.agents.map((a) => ({ ...a })),
|
||||
});
|
||||
currentTaskId.value = task.id;
|
||||
form.taskName = task.title ?? "";
|
||||
form.brief = task.brief ?? "";
|
||||
selected.value = [];
|
||||
run.hydrate(task.messages ?? []);
|
||||
if (task.messages && task.messages.length) {
|
||||
form.taskName = task.title ?? "";
|
||||
form.brief = task.brief ?? "";
|
||||
run.hydrate(task.messages);
|
||||
} else {
|
||||
// 空记录(新初始化):清空当前会话,等用户填任务 / 开始分析。
|
||||
run.reset();
|
||||
}
|
||||
emit("update:taskId", task.id);
|
||||
} catch (err) {
|
||||
errorMsg.value = err instanceof Error ? err.message : String(err);
|
||||
|
||||
Reference in new issue
Block a user