Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ jobs:
npm run smoke:chat-upgrade
npm run smoke:delegation-search
npm run smoke:task-inspector-route
npm run smoke:explore-timeline-scan
npm run smoke:conversation-find
- name: Qualify packaged team evidence and feedback recovery
if: matrix.shard == 2
Expand Down
2 changes: 2 additions & 0 deletions apps/presentation/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build": "tsc --noEmit && vite build && npm run build:chat",
"build:chat": "node ../../../scripts/chat_bundle_launcher.mjs build",
"build:desktop": "tsc --noEmit && vite build",
"benchmark:explore-timeline": "vite build --ssr smoke/explore-timeline-benchmark.tsx --outDir node_modules/.cache/explore-timeline-benchmark --emptyOutDir && NODE_ENV=production node node_modules/.cache/explore-timeline-benchmark/explore-timeline-benchmark.js",
"check:css-custom-properties": "node ../../../scripts/check-css-custom-properties.test.mjs && node ../../../scripts/check-css-custom-properties.mjs dashboard",
"dev": "bash ../../../scripts/dashboard-dev.sh",
"dev:web": "vite --host 127.0.0.1",
Expand All @@ -27,6 +28,7 @@
"smoke:capability-configuration": "rm -rf node_modules/.cache/loopx-capability-configuration-smoke && tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --types node --skipLibCheck --strict --outDir node_modules/.cache/loopx-capability-configuration-smoke smoke/capability-configuration-smoke.ts src/data/capability-configuration.ts && node node_modules/.cache/loopx-capability-configuration-smoke/smoke/capability-configuration-smoke.js",
"smoke:chat-model-menu": "vite build --ssr smoke/chat-model-menu-smoke.mjs --outDir node_modules/.cache/chat-model-menu --emptyOutDir && node node_modules/.cache/chat-model-menu/chat-model-menu-smoke.js",
"smoke:chat-route": "vite build --ssr smoke/chat-route-smoke.ts --outDir node_modules/.cache/loopx-chat-route-smoke --emptyOutDir && node node_modules/.cache/loopx-chat-route-smoke/chat-route-smoke.js",
"smoke:explore-timeline-scan": "vite build --ssr smoke/explore-timeline-scan-smoke.tsx --outDir node_modules/.cache/explore-timeline-scan --emptyOutDir && node node_modules/.cache/explore-timeline-scan/explore-timeline-scan-smoke.js",
"smoke:chat-stream-stall": "vite build --ssr smoke/chat-stream-stall-smoke.ts --outDir node_modules/.cache/loopx-chat-stream-stall --emptyOutDir && node node_modules/.cache/loopx-chat-stream-stall/chat-stream-stall-smoke.js",
"smoke:chat-turn-acceptance-retry": "vite build --ssr smoke/chat-turn-acceptance-retry-smoke.ts --outDir node_modules/.cache/loopx-chat-turn-acceptance-retry --emptyOutDir && node node_modules/.cache/loopx-chat-turn-acceptance-retry/chat-turn-acceptance-retry-smoke.js",
"smoke:demo-readiness": "bash ../../../scripts/loopx-python.sh --exec ../../../examples/dashboard-demo-readiness-smoke.py",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {createHash} from "node:crypto";
import {mkdirSync, readFileSync, writeFileSync} from "node:fs";
import {join} from "node:path";
import {performance} from "node:perf_hooks";
import {renderToStaticMarkup} from "react-dom/server";
import {GoalResearchTimeline} from "../src/features/personal-workspace/goal-research-timeline";
import {groupUnlinkedHistoryQuestions, parseExploreHistoryPage, projectExploreHistory} from "../../../../loopx/control_plane/presentation/explore_history";
import {buildExploreTimeline} from "../../../../loopx/control_plane/presentation/explore_timeline";

const [fixturePath, outputDir] = process.argv.slice(2);
if (!fixturePath || !outputDir) throw new Error("Use --make-fixture <new-file> or <fixture-file> <new-output-directory>");
if (fixturePath === "--make-fixture") {
const real = JSON.parse(readFileSync("src/data/fixtures/edgebench-graph-checkpoint-history.json", "utf8"));
const many: Record<string, unknown>[] = [], single: Record<string, unknown>[] = [];
const start = Date.UTC(2026, 0, 1);
const stamp = (ms: number) => new Date(ms).toISOString().replace(".000Z", "Z");
for (let index = 0; index < 1200; index++) {
const goal = "synthetic-timeline", parent = `route-${index}-parent`, child = `route-${index}-child`;
const when = start + index * 120_000;
const event = (kind: string, id: string, extra: Record<string, unknown> = {}) => ({
schema_version: "loopx_explore_result_event_v0", event_id: `${kind}-${id}`, goal_id: goal,
event_kind: kind, result_id: id, recorded_at: stamp(when), title: `${kind} ${id}`, ...extra,
});
many.push(event("node", child, {parent_id: parent, recorded_at: index % 100 === 0 ? "unknown" : stamp(when + 3_600_000), status: "open"}));
many.push(event("node", parent, {status: "exploring"}));
many.push(event("edge", `relation-${index}`, {from_node: parent, to_node: child,
edge_type: index % 3 === 0 ? "refutes" : "supports", summary: "Recorded relationship"}));
if (index % 25 === 0) many.push(event("edge", `dangling-${index}`, {from_node: parent, to_node: `missing-${index}`, edge_type: "supports"}));
if (index % 5 === 0) many.push(event("finding", `finding-${index}`, {node_id: parent,
status: index % 2 === 0 ? "refuted" : "confirmed", recorded_at: index % 50 === 0 ? "unknown" : stamp(when),
summary: index % 10 === 0
? "Input revision: fixture Applicability: local rendering Observation: recorded relationship Interpretation: Outcome: changed retained: - source context changed: - next route stopped: - previous route"
: "Recorded finding", evidence_refs: [`evidence:fixture-${index}`]}));
}
for (let index = 0; index < 800; index++) {
const goal = "synthetic-one-route", when = stamp(start + index * 300_000);
single.push({schema_version: "loopx_explore_result_event_v0", event_id: `node-${index}`, goal_id: goal,
event_kind: "node", result_id: `node-${index}`, recorded_at: when, title: `Node ${index}`,
parent_id: index ? `node-${index - 1}` : "", status: "open"});
if (index) single.push({schema_version: "loopx_explore_result_event_v0", event_id: `edge-${index}`, goal_id: goal,
event_kind: "edge", result_id: `edge-${index}`, recorded_at: when, title: `Edge ${index}`,
from_node: `node-${index - 1}`, to_node: `node-${index}`, edge_type: "supports", summary: "Recorded relationship"});
}
const fixture = [{name: "public-checkpoint", goal_id: real.goal_id, events: real.events},
{name: "synthetic-many-routes", goal_id: "synthetic-timeline", events: many},
{name: "synthetic-one-route", goal_id: "synthetic-one-route", events: single}];
const bytes = Buffer.from(JSON.stringify(fixture));
writeFileSync(outputDir, bytes, {flag: "wx"});
console.log(JSON.stringify({fixture_sha256: createHash("sha256").update(bytes).digest("hex"), cases: fixture.map(row => ({name: row.name, events: row.events.length}))}));
process.exit(0);
}
const fixtureBytes = readFileSync(fixturePath);
const fixtures = JSON.parse(fixtureBytes.toString()) as Array<{name: string; goal_id: string; events: unknown[]}>;
mkdirSync(outputDir);
const cases = [];
for (const fixture of fixtures) {
const events = parseExploreHistoryPage({ok: true, goal_id: fixture.goal_id, total: fixture.events.length,
next_cursor: null, items: fixture.events}, fixture.goal_id).items;
const history = projectExploreHistory(events, fixture.goal_id);
const timeline = buildExploreTimeline(history.nodes, history.edges, history.events);
const dayGroups = groupUnlinkedHistoryQuestions(history.nodes, history.edges).groups;
const render = (zh: boolean, phase: number | null, complete: boolean) => renderToStaticMarkup(
<GoalResearchTimeline timeline={timeline} complete={complete} zh={zh} selectedIds={[]} phase={phase}
selectedDay={null} dayGroups={dayGroups} onGroupSelect={() => {}} onSelect={() => {}}
onSelectMany={() => {}} onPhase={() => {}} timeLabel={value => new Date(value).toISOString()}
dayLabel={value => new Date(value).toISOString().slice(0, 10)}/>,
);
const snapshots = [];
for (const [name, zh, phase, complete] of [["zh-all", true, null, true], ["en-phase", false, 1, true], ["zh-partial", true, null, false]] as const) {
const html = render(zh, phase, complete);
writeFileSync(join(outputDir, `${fixture.name}-${name}.html`), html);
snapshots.push({name, bytes: Buffer.byteLength(html), sha256: createHash("sha256").update(html).digest("hex")});
}
for (let index = 0; index < 3; index++) render(true, null, true);
const samples = [];
for (let index = 0; index < 12; index++) {
const start = performance.now();
const html = render(true, null, true);
samples.push(performance.now() - start);
if (createHash("sha256").update(html).digest("hex") !== snapshots[0]!.sha256) throw new Error("Repeated render changed output");
}
const sorted = [...samples].sort((a, b) => a - b);
cases.push({name: fixture.name, events: events.length, nodes: timeline.nodes.size, edges: timeline.edges.length,
routes: timeline.routes.length, snapshots, samples_ms: samples, median_ms: (sorted[5]! + sorted[6]!) / 2});
}
const report = {node: process.version, node_env: process.env.NODE_ENV, fixture_sha256: createHash("sha256").update(fixtureBytes).digest("hex"), cases};
writeFileSync(join(outputDir, "report.json"), JSON.stringify(report, null, 2) + "\n");
console.log(JSON.stringify(report));
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import assert from "node:assert/strict";
import {renderToStaticMarkup} from "react-dom/server";
import {GoalResearchTimeline} from "../src/features/personal-workspace/goal-research-timeline";
import {parseExploreHistoryPage, projectExploreHistory} from "../../../../loopx/control_plane/presentation/explore_history";
import {buildExploreTimeline} from "../../../../loopx/control_plane/presentation/explore_timeline";

const goalId = "timeline-scan-fixture";
const events: Record<string, unknown>[] = [];
for (let index = 0; index < 40; index++) {
const parent = `parent-${index}`, child = `child-${index}`;
const event = (kind: string, id: string, extra: Record<string, unknown>) => ({
schema_version: "loopx_explore_result_event_v0", goal_id: goalId, event_kind: kind,
event_id: `${kind}-${id}`, result_id: id, title: id, recorded_at: "2026-01-01T00:00:00Z", ...extra,
});
if (index === 0) {
events.push(event("node", "child-later", {parent_id: parent, recorded_at: "2026-01-01T02:00:00Z"}));
events.push(event("node", "child-unknown", {parent_id: parent, recorded_at: "unknown"}));
}
events.push(event("node", child, {parent_id: parent, recorded_at: "2026-01-01T01:00:00Z"}));
events.push(event("node", parent, {}));
events.push(event("edge", `edge-${index}`, {from_node: parent, to_node: child, edge_type: "supports", summary: `route-edge-${index}`}));
if (index === 0) {
events.push(event("edge", "back", {from_node: child, to_node: parent, edge_type: "refutes", summary: "route-back"}));
events.push(event("edge", "unknown", {from_node: parent, to_node: "child-unknown", edge_type: "supports", summary: "unknown-time-edge"}));
events.push(event("edge", "missing", {from_node: parent, to_node: "missing-node", edge_type: "supports", summary: "missing-node-edge"}));
}
}
const parsed = parseExploreHistoryPage({ok: true, goal_id: goalId, total: events.length, next_cursor: null, items: events}, goalId).items;
const history = projectExploreHistory(parsed, goalId);
const timeline = buildExploreTimeline(history.nodes, history.edges, history.events);
// Count source accesses instead of depending on a machine-specific time limit.
let routeReads = 0, edgeReads = 0;
const nodes = new Map([...timeline.nodes].map(([id, item]) => [id, {
...item, get routeId() {routeReads++; return item.routeId;},
}]));
const edges = timeline.edges.map(edge => ({...edge, get from_node() {edgeReads++; return edge.from_node;}}));
const html = renderToStaticMarkup(<GoalResearchTimeline timeline={{...timeline, nodes, edges}} complete zh selectedIds={[]}
phase={null} selectedDay={null} dayGroups={[]} onGroupSelect={() => {}} onSelect={() => {}} onSelectMany={() => {}}
onPhase={() => {}} timeLabel={value => new Date(value).toISOString()} dayLabel={value => new Date(value).toISOString().slice(0, 10)}/>);
const routes = [...html.matchAll(/<svg[^>]*class="research-history-edges"[^>]*>(.*?)<\/svg>/gs)].map(match => match[1]!);
assert.equal(routes.length, 40);
for (const [index, route] of routes.entries()) {
const titles = [...route.matchAll(/<title>(.*?)<\/title>/g)].map(match => match[1]);
assert.deepEqual(titles, index ? [`supports: route-edge-${index}`] : ["supports: route-edge-0", "refutes: route-back"]);
}
const firstParents = [...routes[0]!.matchAll(/class="is-grouping" d="([^"]+)"/g)].map(match => match[1]!);
assert.equal(firstParents.length, 2);
const endpoint = (path: string) => Number(path.match(/ ([\d.]+),26$/)?.[1]);
assert.ok(endpoint(firstParents[0]!) > endpoint(firstParents[1]!), "parent arcs keep source order, not timestamp order");
assert.doesNotMatch(html, /unknown-time-edge|missing-node-edge/);
assert.ok(routeReads <= 4 * (nodes.size + edges.length), `nodes were repeatedly scanned: ${routeReads}`);
assert.ok(edgeReads <= 4 * edges.length, `edges were repeatedly scanned: ${edgeReads}`);
console.log(`explore timeline: 40 routes retained; ${routeReads} node and ${edgeReads} edge identity reads`);
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ export function GoalResearchTimeline({timeline, complete, zh, selectedIds, selec
const groupedIds = new Set(dayGroups.flatMap(group => group.nodes.map(node => node.id)));
const swarm = timeline.singles.filter(id => !groupedIds.has(id)).map(id => timeline.nodes.get(id)!).filter(item => item.first !== null);
const unknownTime = [...timeline.nodes.values()].filter(item => item.first === null).length;
const routeParents = new Map<string, TimelineNode[]>();
const routeEdges = new Map<string, (typeof timeline.edges)[number][]>();
const manyRoutes = timeline.routes.length > 1;
if (manyRoutes) {
// Routes join known edge endpoints; preserve source order in the indexes.
for (const item of timeline.nodes.values()) {
if (item.routeId === null || !item.node.latest.parent_id) continue;
const parents = routeParents.get(item.routeId) ?? [];
parents.push(item);
routeParents.set(item.routeId, parents);
}
for (const edge of timeline.edges) {
const routeId = timeline.nodes.get(edge.from_node)?.routeId;
if (routeId == null || routeId !== timeline.nodes.get(edge.to_node)?.routeId) continue;
const edges = routeEdges.get(routeId) ?? [];
edges.push(edge);
routeEdges.set(routeId, edges);
}
}
const phaseNote = timeline.phases.length === 1
? (zh ? "全部记录归入同一阅读分组,仅为阅读组织,不是预声明的评估窗口。" : "All records share one reading group, for reading only; not a pre-declared evaluation window.")
: copy.phaseNote;
Expand Down Expand Up @@ -185,10 +204,12 @@ export function GoalResearchTimeline({timeline, complete, zh, selectedIds, selec
const first = members[0]!, last = members.at(-1)!;
const position = new Map(members.map(item => [item.node.id, item.first ?? start]));
const x = (id: string) => ((position.get(id)! - start) / span) * 1000;
const parents = manyRoutes ? routeParents.get(route.id) ?? [] : [...timeline.nodes.values()];
const edges = manyRoutes ? routeEdges.get(route.id) ?? [] : timeline.edges;
const arcs = [
...[...timeline.nodes.values()].filter(item => item.routeId === route.id && position.has(item.node.id) && item.node.latest.parent_id && position.has(item.node.latest.parent_id))
...parents.filter(item => item.routeId === route.id && position.has(item.node.id) && item.node.latest.parent_id && position.has(item.node.latest.parent_id))
.map(item => ({key: `parent:${item.node.id}`, from: item.node.latest.parent_id, to: item.node.id, kind: "is-grouping", title: ""})),
...timeline.edges.filter(edge => position.has(edge.from_node) && position.has(edge.to_node))
...edges.filter(edge => position.has(edge.from_node) && position.has(edge.to_node))
.map(edge => ({key: edge.event_id, from: edge.from_node, to: edge.to_node, kind: edge.edge_type === "refutes" ? "is-refutation" : "", title: `${edge.edge_type}: ${edge.summary}`})),
];
return <div className="research-route" key={route.id} role="group" aria-label={`${members.length} · ${first.node.latest.title}`}>
Expand Down
Loading