From a8ad6d804797ee3252211d9ad01ea6508abd1685 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Wed, 25 Nov 2026 12:36:16 +0800 Subject: [PATCH] Show recorded history before saved research cases Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- ...esearch-evidence-version-browser-smoke.mjs | 38 ++++++++- .../src/data/fixtures/case-study-child.json | 83 ++++++++++++++++++- .../goal-research-history.tsx | 5 +- 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/apps/presentation/dashboard/smoke/research-evidence-version-browser-smoke.mjs b/apps/presentation/dashboard/smoke/research-evidence-version-browser-smoke.mjs index 9ea0e4771e..9f4c5e879f 100644 --- a/apps/presentation/dashboard/smoke/research-evidence-version-browser-smoke.mjs +++ b/apps/presentation/dashboard/smoke/research-evidence-version-browser-smoke.mjs @@ -123,11 +123,45 @@ try { research_reading: "case", research_analysis_goal: child.goal_id, research_pack: studyPack.pack_id}); address.hash = "case-section-" + studyPack.pack_id + "-" + chapter.id; const atChapter = () => page.waitForFunction(id => document.activeElement?.id === id, address.hash.slice(1)); - await page.goto(address.href); - await atChapter(); const views = page.getByRole("group", {name: "研究视图", exact: true}); const historyView = views.getByRole("button", {name: "研究历程", exact: true}); const caseView = views.getByRole("button", {name: "案例解读", exact: true}); + const ordinary = new URL(study); + const fullAxis = page.locator('.research-timeline .research-axis time.is-end[datetime="PT64800S"]'); + await page.goto(ordinary.href); + await fullAxis.waitFor(); + await caseView.waitFor(); + assert.equal(await historyView.getAttribute("aria-pressed"), "true"); + assert.equal(await page.locator(".research-case-reader").count(), 0); + assert.equal(new URL(page.url()).searchParams.has("research_reading"), false); + await caseView.press("Enter"); + await page.locator(".case-opening h2").waitFor(); + await page.goBack(); + await fullAxis.waitFor(); + + await page.setViewportSize({width: 390, height: 900}); + const historyGet = url => url.pathname === "/api/chat/explore-results" + && url.searchParams.get("goal_id") === child.goal_id && url.searchParams.get("view") === "history"; + await page.route(historyGet, route => route.fulfill({status: 503, json: {ok: false}}), {times: 1}); + await page.goto(ordinary.href); + const historyError = page.locator(".research-history-read-error"); + await historyError.waitFor(); + await caseView.waitFor(); + assert.equal(await historyView.getAttribute("aria-pressed"), "true"); + await historyError.getByRole("button", {name: "重试", exact: true}).press("Enter"); + await fullAxis.waitFor(); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false); + + const caseOnly = await start("case-only", {...child, events: []}, parent); + await page.goto(caseOnly); + await page.locator(".case-opening h2").waitFor(); + assert.equal(await caseView.getAttribute("aria-pressed"), "true"); + const caseOnlyReadback = await (await fetch(new URL("/fixture/readback", caseOnly))).json(); + assert(caseOnlyReadback.history_reads > 0 && caseOnlyReadback.source_unchanged); + await page.setViewportSize({width: 1200, height: 900}); + + await page.goto(address.href); + await atChapter(); assert.equal(await caseView.getAttribute("aria-pressed"), "true"); await historyView.press("Enter"); await page.locator(".research-history-heading").waitFor(); diff --git a/apps/presentation/dashboard/src/data/fixtures/case-study-child.json b/apps/presentation/dashboard/src/data/fixtures/case-study-child.json index d736ab7f91..9990b1bf9c 100644 --- a/apps/presentation/dashboard/src/data/fixtures/case-study-child.json +++ b/apps/presentation/dashboard/src/data/fixtures/case-study-child.json @@ -2,7 +2,88 @@ "goal_id": "synthetic-case-search", "parent_goal_id": "synthetic-benchmark", "display_name": "Search · Case 研究", - "events": [], + "events": [ + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "synthetic-case-search", + "event_kind": "node", + "recorded_at": "2026-11-21T01:00:00Z", + "title": "Can an early candidate satisfy both checks?", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "agent_id": "synthetic-researcher", + "result_id": "history-start", + "node_kind": "question", + "status": "open", + "event_id": "b12628df1f9fcc7c" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "synthetic-case-search", + "event_kind": "finding", + "recorded_at": "2026-11-21T02:00:00Z", + "title": "Early probe missed the second check", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "agent_id": "synthetic-researcher", + "result_id": "ruled-out-probe", + "node_id": "history-start", + "status": "refuted", + "event_id": "c4c1d855090973bd" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "synthetic-case-search", + "event_kind": "node", + "recorded_at": "2026-11-21T17:00:00Z", + "title": "Does the retained candidate cover both cases?", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "agent_id": "synthetic-researcher", + "result_id": "history-end", + "node_kind": "question", + "status": "open", + "event_id": "969d2846d7e02569" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "synthetic-case-search", + "event_kind": "finding", + "recorded_at": "2026-11-21T19:00:00Z", + "title": "Retained candidate covered both cases", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "agent_id": "synthetic-researcher", + "result_id": "recorded-outcome", + "node_id": "history-end", + "status": "confirmed", + "event_id": "da42d4af65d99f3a" + } + ], "analyses": [ { "title": "初版解读", diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx index fe29766715..bdd016c0b9 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx @@ -66,7 +66,6 @@ export function GoalResearchHistory({goalId, originalGoalId = goalId, preferHist }; const [caseMode, setCaseReading] = useState(readCaseMode); const requestedCase = caseMode.goalId === goalId ? caseMode.requested : null; - const caseReading = requestedCase ?? !preferHistory; const hasCases = (analysis.snapshot?.catalog.packs ?? []).some(pack => pack.case_study_summary); // A link to a particular version stays in the case reader even when that // version has no study. An unpinned visit can fall back to ordinary history. @@ -521,7 +520,9 @@ export function GoalResearchHistory({goalId, originalGoalId = goalId, preferHist : null; const emptyHistoryMessage = zh ? "这个 Goal 尚无研究历程" : "No research history for this Goal yet"; const selectedStrategy = hasNativeSource && !emptySourceHistory ? strategies.selection : null; - const readingCase = caseReading && caseViewAvailable && (requestedCase === true || selectedStrategy === null); + // An unaddressed local visit can open its saved case once its own history is confirmed empty. + const readingCase = caseViewAvailable && (requestedCase === true + || requestedCase === null && !hasNativeSource && openedHistorySource === historySource && emptyHistory); const alternateReading = readingCase ? : selectedStrategy !== null ?