Simplify search agent activity state
This commit is contained in:
+21
-19
@@ -521,22 +521,26 @@ function routeButtons(routes) {
|
||||
`;
|
||||
}
|
||||
|
||||
function searchSteps(steps = []) {
|
||||
function searchActivity(steps = []) {
|
||||
const current =
|
||||
steps.find((step) => step.status === "running") ||
|
||||
[...steps].reverse().find((step) => step.status === "done") ||
|
||||
steps[0] ||
|
||||
{};
|
||||
const doneCount = steps.filter((step) => step.status === "done").length;
|
||||
const currentIndex = Math.min(doneCount + (current.status === "running" ? 1 : 0), steps.length || 1);
|
||||
const statusLabel = current.status === "running" ? "working" : current.status || "pending";
|
||||
return `
|
||||
<div class="agent-steps">
|
||||
${steps
|
||||
.map(
|
||||
(step) => `
|
||||
<div class="agent-step ${escapeHtml(step.status)}">
|
||||
<span class="step-dot"></span>
|
||||
<div>
|
||||
<strong>${escapeHtml(step.label)}</strong>
|
||||
<span>${escapeHtml(step.detail || step.status)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
)
|
||||
.join("")}
|
||||
<div class="agent-activity ${escapeHtml(current.status || "pending")}">
|
||||
<span class="activity-dot"></span>
|
||||
<div class="activity-copy">
|
||||
<div class="activity-title">
|
||||
<span>Search Agent</span>
|
||||
<strong>${escapeHtml(current.label || "准备搜索")}</strong>
|
||||
</div>
|
||||
<div class="activity-detail">${escapeHtml(current.detail || "正在准备检索上下文")}</div>
|
||||
</div>
|
||||
<div class="activity-meta">${escapeHtml(statusLabel)} · ${currentIndex}/${steps.length || 1}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -596,10 +600,7 @@ function renderSearchRunning(job) {
|
||||
elements.lensTitle.textContent = job?.query || elements.searchInput.value.trim() || "搜索";
|
||||
elements.lensBody.innerHTML = `
|
||||
<section class="section">
|
||||
<p class="statement">Search Agent 正在理解问题、扩展关键词并检索本地论文库。</p>
|
||||
</section>
|
||||
<section class="section">
|
||||
${searchSteps(job?.steps || [])}
|
||||
${searchActivity(job?.steps || [])}
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
@@ -873,6 +874,7 @@ async function runSearch() {
|
||||
],
|
||||
};
|
||||
renderSearchRunning(starter);
|
||||
scrollLensIntoView();
|
||||
try {
|
||||
const payload = await api("/api/search/agent", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user