From 6e59804e763bf482d3ab517a9e02996e1e0e97ae Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:36:00 +0800 Subject: [PATCH 1/6] Read archived Goal executions in the workspace drawer Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../presentation/dashboard/src/data/status.ts | 5 ++ .../personal-workspace/context-drawer.tsx | 76 ++++++++++++++----- .../src/features/personal-workspace/i18n.tsx | 18 +++++ .../personal-workspace-model.ts | 6 +- .../personal-workspace/personal-workspace.css | 4 + .../dashboard/src/views/dashboard-page.tsx | 4 + 6 files changed, 93 insertions(+), 20 deletions(-) diff --git a/apps/presentation/dashboard/src/data/status.ts b/apps/presentation/dashboard/src/data/status.ts index 4c778ac672..e28f220175 100644 --- a/apps/presentation/dashboard/src/data/status.ts +++ b/apps/presentation/dashboard/src/data/status.ts @@ -535,6 +535,11 @@ export const projectMapSchema = z.object({ export const runRecordSchema = z.object({ generated_at: z.string(), goal_id: z.string(), + turn_instance_id: z.string().nullish().catch(null), + vision_checkpoint: z.object({ + schema_version: z.literal("vision_checkpoint_v0"), + decision: z.string(), + }).nullish().catch(null), classification: z.string().optional().nullable(), lifecycle_phase: z.string().optional().nullable(), lifecycle_flags: z.array(z.string()).optional().default([]), diff --git a/apps/presentation/dashboard/src/features/personal-workspace/context-drawer.tsx b/apps/presentation/dashboard/src/features/personal-workspace/context-drawer.tsx index 9814753166..3a44b3f325 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/context-drawer.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/context-drawer.tsx @@ -54,6 +54,38 @@ import { formatMonitorDate } from "./monitor-readback"; import { parseTodoCompletionProof } from "./todo-completion-feedback"; import { useDrawerOverlay } from "./workspace-shell"; +function SourceRunHistory({ goal, heading = false }: { goal: WorkspaceGoal; heading?: boolean }) { + const { t } = useWorkspaceI18n(); + const history = goal.sourceRunHistory; + const recent = history?.recent ?? []; + const total = history?.total ?? null; + return
+ {heading ?

{t("drawer.sourceRunHistory")}

: null} + {goal.sourceAccess?.label} · {t("common.readOnly")} +
+
{t("drawer.sourceRunOriginalGoal")}
{goal.sourceAccess?.original_goal_id ?? goal.goalId}
+
+ {recent.length ? <> +

{total === null ? t("drawer.sourceRunRecent", {shown: recent.length}) + : t("drawer.sourceRunCount", {shown: recent.length, count: total})}

+
    {recent.map((run, index) =>
  1. +
    + +
    + {run.classification ?
    {t("drawer.sourceRunRecordType")}
    {run.classification}
    : null} +
    {t("drawer.sourceRunOriginalTurn")}
    + {run.turn_instance_id ? {run.turn_instance_id} : t("drawer.sourceRunUnrecorded")} +
    +
    {t("drawer.sourceRunCheckpoint")}
    + {run.vision_checkpoint ? {run.vision_checkpoint.decision} : t("drawer.sourceRunUnrecorded")} +
    +
    +
    +
  2. )}
+ :

{t(total === 0 ? "drawer.noExecutionHistory" : "drawer.sourceRunUnavailable")}

} +
; +} + function subagentModelRequest(include: boolean, model: string, effort: string) { if (!include) return {}; if (!model.trim()) return { modelConfig: null }; @@ -356,10 +388,13 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention const decisionFrame = selection.kind === "proposal" ? selection.item.reviewPlan?.decisionFrame : undefined; const completedTodoCreation = proposalTarget?.actionKind === "todo.create" && proposalTarget.reviewPlan?.interaction === "completed"; + const sourceRunGoal = selection.kind === "run" + ? goals.find(goal => goal.goalId === selection.item.goalId && goal.sourceAccess) + : undefined; const title = taskExecution ? t("drawer.taskLaunchReceipt") : selection.kind === "attention" ? t("drawer.titleAttention") : selection.kind === "todo" ? t("drawer.taskDetails") - : selection.kind === "run" ? t("drawer.runDetails") + : selection.kind === "run" ? t(sourceRunGoal ? "drawer.sourceRunHistory" : "drawer.runDetails") : selection.kind === "output" ? t("drawer.titleOutput") : selection.kind === "proposal" && selection.item.actionKind === "team.plan" && selection.item.status === "applied" ? t("proposal.teamPlan.resultTitle") : selection.kind === "proposal" && selection.item.actionKind === "operation.execute" ? t("drawer.operationReadOnly") @@ -675,7 +710,7 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention role="dialog" >
-

{title}

{selection.kind !== "goal" && !taskExecution ?

{contextLabel}

: null}
+

{title}

{selection.kind !== "goal" && !taskExecution && !sourceRunGoal ?

{contextLabel}

: null}
{selection.kind === "todo" && onToggleInspectorSize ? : null} - - ) : ( - <> -

{t("drawer.noRun")}

-

{t("drawer.noRunDescription")}

- - )} - + {selection.item.sourceAccess + ? + :
+ {t("drawer.runDetails")} + {selectedGoalRun?.sessionId ? ( + <> +

{localizedSessionStatus(selectedGoalRun.sessionStatus ?? selectedGoalRun.status, t)}

+

{selectedGoalRun.title}

+ {callbacks.onOpenRunSession ? : null} + + ) : ( + <> +

{t("drawer.noRun")}

+

{t("drawer.noRunDescription")}

+ + )} +
} {selection.item.zcodeGoalEligibleAgentIds?.length ? : null} {!readOnly ?
@@ -1080,7 +1117,8 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention ) : null} - {selection.kind === "run" ? ( + {sourceRunGoal ? : null} + {selection.kind === "run" && !sourceRunGoal ? ( <>
@@ -1340,7 +1378,7 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention ) : null} - {selection.kind === "run" || selection.kind === "proposal" || selection.kind === "schedule" ? ( + {((selection.kind === "run" && !sourceRunGoal) || selection.kind === "proposal" || selection.kind === "schedule") ? ( <>
+ {run.agent_vision ? + :

{t("drawer.sourceRunDecisionUnavailable")}

} )} :

{t(total === 0 ? "drawer.noExecutionHistory" : "drawer.sourceRunUnavailable")}

} diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx index 9615a01a98..db4aafc574 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx @@ -55,7 +55,9 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel goalId: string; originalGoalId: string; sourceUrl?: string; zh: boolean; selection: string; onSelect: (id: string, replace?: boolean) => void; onClose?: () => void; embedded?: boolean; }) { - const [snapshot, setSnapshot] = useState(null); + const [loaded, setSnapshot] = useState<{scope: string; value: Snapshot} | null>(null); + const scope = `${goalId}:${originalGoalId}:${sourceUrl ?? ""}`; + const snapshot = loaded?.scope === scope ? loaded.value : null; const [busy, setBusy] = useState(true), [failed, setFailed] = useState(false); const [revision, setRevision] = useState(0); const heading = useRef(null); @@ -73,10 +75,10 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel if (result.goal_id !== originalGoalId || result.source.namespace !== namespace || result.total !== result.items.length || result.native_run_count < result.total || new Set(result.items.map(item => item.id)).size !== result.total) throw new Error("Inconsistent source history"); - if (current) setSnapshot(result); + if (current) setSnapshot({scope, value: result}); }).catch(() => {if (current) setFailed(true);}).finally(() => {if (current) setBusy(false);}); return () => {current = false; controller.abort();}; - }, [goalId, originalGoalId, sourceUrl, namespace, revision]); + }, [goalId, originalGoalId, sourceUrl, namespace, revision, scope]); useEffect(() => { const previous = previousSelection.current; previousSelection.current = selection; @@ -85,6 +87,9 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel entry?.focus({preventScroll: true}); entry?.scrollIntoView({block: "nearest"}); } else if (!embedded || selection !== "all") heading.current?.focus({preventScroll: true}); }, [selection, embedded]); + const time = (stamp: string) => Number.isFinite(Date.parse(stamp)) + ? new Intl.DateTimeFormat(zh ? "zh-CN" : "en", {dateStyle: "medium", timeStyle: "medium"}).format(new Date(stamp)) + : (zh ? "时间未记录" : "Time not recorded"); const items = snapshot?.items ?? []; // Only recorded time orders this view. It establishes neither execution time // nor causal relationships; records without a usable time remain readable. @@ -96,19 +101,6 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel const dated = chronology.filter(item => Number.isFinite(Date.parse(item.recorded_at))); const index = items.findIndex(item => item.id === selection); const selected = items[index]; - const vision = record(selected?.agent_vision), patch = record(vision.vision_patch), path = record(vision.path_delta); - const stride = record(vision.stride_decision), probe = record(stride.next_probe), review = record(stride.previous_review); - const time = (stamp: string) => Number.isFinite(Date.parse(stamp)) - ? new Intl.DateTimeFormat(zh ? "zh-CN" : "en", {dateStyle: "medium", timeStyle: "medium"}).format(new Date(stamp)) - : (zh ? "时间未记录" : "Time not recorded"); - const prose = (label: string, value: unknown) => typeof value === "string" && value - ?

{label}

: null; - const list = (label: string, value: unknown) => Array.isArray(value) && value.length - ?

{label}

    {value.map((item, i) =>
  • - {typeof item === "string" ? :
    {JSON.stringify(item, null, 2)}
    } -
  • )}
: null; - const nextLabels = zh ? {scope: "范围", prediction: "预期", adoption_criterion: "采用条件", cost_bound: "成本边界", minimum_evidence: "所需依据"} - : {scope: "Scope", prediction: "Prediction", adoption_criterion: "Adoption criterion", cost_bound: "Cost bound", minimum_evidence: "Required evidence"}; return
{selection !== "all" || onClose ? : null}
@@ -147,8 +139,34 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel : null} {!items.length ?

{zh ? "原 Goal 没有保留策略记录。" : "The original Goal has no retained strategy records."}

: !selected && selection !== "all" ?

{zh ? "原来源中找不到所选版本。可选择其他记录。" : "The selected version is absent from this source. Other records remain readable."}

: null} - {selected ?
-

· {selected.agent_id}

+ {selected ? : null} + : null} +
; +} + +/** Read-only rendering shared by strategy history and native execution records. */ +export function GoalStrategyDocument({value, recordedAt, agentId, version, originalGoalId, namespace, zh, originalRecord, executionRecord = false}: { + originalRecord?: unknown; executionRecord?: boolean; + value: Record; recordedAt: string; agentId?: string; version: string; + originalGoalId: string; namespace: string; zh: boolean; +}) { + const vision = record(value), patch = record(vision.vision_patch), path = record(vision.path_delta); + const stride = record(vision.stride_decision), probe = record(stride.next_probe), review = record(stride.previous_review); + const time = (stamp: string) => Number.isFinite(Date.parse(stamp)) + ? new Intl.DateTimeFormat(zh ? "zh-CN" : "en", {dateStyle: "medium", timeStyle: "medium"}).format(new Date(stamp)) + : (zh ? "时间未记录" : "Time not recorded"); + const prose = (label: string, value: unknown) => typeof value === "string" && value + ?

{label}

: null; + const list = (label: string, value: unknown) => Array.isArray(value) && value.length + ?

{label}

    {value.map((item, i) =>
  • + {typeof item === "string" ? :
    {JSON.stringify(item, null, 2)}
    } +
  • )}
: null; + const nextLabels = zh ? {scope: "范围", prediction: "预期", adoption_criterion: "采用条件", cost_bound: "成本边界", minimum_evidence: "所需依据"} + : {scope: "Scope", prediction: "Prediction", adoption_criterion: "Adoption criterion", cost_bound: "Cost bound", minimum_evidence: "Required evidence"}; + return
+

{agentId ? ` · ${agentId}` : ""}

{prose(zh ? "当时的目标" : "Goal at the time", patch.vision_summary)} {prose(zh ? "验收条件" : "Acceptance", patch.acceptance_summary)} {prose(zh ? "原先的判断" : "Prior assumption", path.prior_assumption)} @@ -161,15 +179,25 @@ export function GoalSourceStrategies({goalId, originalGoalId, sourceUrl, zh, sel {Object.keys(probe).length ?

{zh ? "当时的后续计划" : "Recorded next plan"}

{Object.entries(nextLabels).map(([key, label]) => typeof probe[key] === "string" && probe[key] ? : null)}
: null} {prose(zh ? "对上轮的记录性回顾" : "Recorded review of the previous decision", review.lesson)} +
{zh ? "完整决策字段" : "All decision fields"} + +
{list(zh ? "依据引用" : "Evidence references", path.evidence_refs)}
{zh ? "完整原始记录与来源" : "Complete original record and source"} -
-
-
{JSON.stringify(selected, null, 2)}
+
+
+
{JSON.stringify(originalRecord ?? value, null, 2)}
-
: null} - : null} - ; + ; +} + +// Unknown optional fields remain readable without treating them as executable markup. +function NativeDecisionFields({value}: {value: unknown}) { + if (typeof value === "string") return ; + if (Array.isArray(value)) return
    {value.map((item, index) =>
  • )}
; + if (value !== null && typeof value === "object") return
{Object.entries(value).map(([key, item]) => +
{key}
)}
; + return {value === null ? "null" : String(value)}; } function FragmentField({label, value}: {label: string; value: string}) { diff --git a/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx b/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx index 4cbdeb16e6..382758adf0 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx @@ -381,6 +381,7 @@ const en = { "drawer.validationRevisionActor": "Revised by", "drawer.noExecutionHistory": "No execution history yet.", "drawer.sourceRunHistory": "Historical executions", + "drawer.sourceRunDecisionUnavailable": "No complete decision was retained in this execution record.", "drawer.sourceRunRecent": "{shown} recent records", "drawer.sourceRunCount": "Showing {shown} recent records of {count}", "drawer.sourceRunOriginalGoal": "Original Goal", @@ -2017,6 +2018,7 @@ const zhCN: Record = { "drawer.validationRevisionActor": "修订者", "drawer.noExecutionHistory": "暂无执行记录。", "drawer.sourceRunHistory": "历史执行", + "drawer.sourceRunDecisionUnavailable": "这条执行记录未保留完整决策正文。", "drawer.sourceRunRecent": "最近 {shown} 条记录", "drawer.sourceRunCount": "显示最近 {shown} 条,共 {count} 条", "drawer.sourceRunOriginalGoal": "原 Goal", diff --git a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs new file mode 100644 index 0000000000..502ac5414a --- /dev/null +++ b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs @@ -0,0 +1,24 @@ +import assert from "node:assert/strict"; +import React from "react"; +import {renderToStaticMarkup} from "react-dom/server"; +import {runRecordSchema} from "../../data/status"; +import {GoalStrategyDocument} from "./goal-source-strategies"; +const base = {goal_id:"archived", generated_at:"2026-01-01T00:00:00Z"}; +for (const agent_vision of [undefined, null, [], "invalid", 42]) { + assert.equal(runRecordSchema.parse({...base, agent_vision}).agent_vision ?? null, null); +} +const value = {vision_patch:{vision_summary:"Retain the independently verified baseline"}, + path_delta:{observed_reality:"The new route failed", unresolved_questions:["Cost remains unknown"]}, + stride_decision:{axes:{work_slice:{plan:"Compare before replacing",reason:"Preserve the counterexample"}}}, + future_field:{unknown_key:"Keep future evidence readable"}}; +const parsed = runRecordSchema.parse({...base, agent_vision:value}); +assert.deepEqual(parsed.agent_vision,value); +for (const zh of [true,false]) { + const html = renderToStaticMarkup(React.createElement(GoalStrategyDocument, { + value:parsed.agent_vision,recordedAt:base.generated_at,version:"retained-version", + originalGoalId:"original-goal",namespace:"source-a",zh, + })); + for (const text of ["Retain the independently verified baseline","The new route failed","Compare before replacing", + "Preserve the counterexample","Keep future evidence readable","original-goal","source-a","retained-version"]) assert.ok(html.includes(text),text); +} +console.log("Native decisions preserve optional compatibility, complete fields and provenance in both languages"); diff --git a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-model.ts b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-model.ts index 6bca73a6c7..efaa6ea569 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-model.ts +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-model.ts @@ -168,7 +168,7 @@ export type WorkspaceGoal = { sourceAccess?: {namespace: string; label: string; readOnly: true; original_goal_id?: string}; sourceRunHistory?: { total: number | null; - recent: Pick[]; + recent: Pick[]; }; sourceStrategy?: {recordedAt: string; summary: string; observation?: string}; /** Registry organization in this status source; not Agent ownership or execution dependency. */ diff --git a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css index 50ee87e675..3c140a67be 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css @@ -1445,7 +1445,7 @@ button.personal-execution-chip:focus-visible { outline: 2px solid #0070f3; outli .personal-report-detail li p { margin: 0; color: var(--pw-muted); font-size: var(--text-caption); line-height: var(--leading-caption); } .personal-report-detail > footer { display: grid; gap: 4px; margin-top: 10px; color: var(--pw-faint); font: var(--text-caption)/var(--leading-caption) var(--font-mono); overflow-wrap: anywhere; } .personal-source-run-history ol { list-style: none; margin: 10px 0 0; padding: 0; } -.personal-source-run-history li { border-top: 1px solid var(--pw-line); padding: 8px 0; } +.personal-source-run-history > ol > li { border-top: 1px solid var(--pw-line); padding: 8px 0; } .personal-source-run-history summary { cursor: pointer; overflow-wrap: anywhere; } .personal-source-run-history dd { min-width: 0; overflow-wrap: anywhere; } .personal-execution-history { margin-top: 18px; } @@ -2243,3 +2243,6 @@ button.personal-execution-chip:focus-visible { outline: 2px solid #0070f3; outli .personal-document-attachment > a { display: block; font-size: 12px; color: inherit; } .personal-document-attachment > pre { white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; max-height: 240px; margin: 8px 0 0; } .personal-composer-images figure:has(.personal-document-attachment) { flex: 0 1 360px; min-width: 0; height: auto; padding-right: 24px; } + +.personal-source-run-history .source-strategy-document .personal-md { font-size: var(--text-lead); line-height: var(--leading-prose); } +.personal-source-run-history .source-strategy-document dl dl > div { display: block; } From 5166e249a99222ce4a7391de92f8a419f887903d Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:45:57 +0800 Subject: [PATCH 3/6] Keep native decision paragraphs readable in the source drawer Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../src/features/personal-workspace/personal-workspace.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css index 3c140a67be..3dd3e675b9 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css @@ -2246,3 +2246,6 @@ button.personal-execution-chip:focus-visible { outline: 2px solid #0070f3; outli .personal-source-run-history .source-strategy-document .personal-md { font-size: var(--text-lead); line-height: var(--leading-prose); } .personal-source-run-history .source-strategy-document dl dl > div { display: block; } + +.personal-source-run-history .source-strategy-document .personal-md p, +.personal-source-run-history .source-strategy-document .personal-md li { font-size: inherit; line-height: inherit; color: var(--pw-text); } From 94f667efa224fe577c0f515346035f47fb7ac117 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:42:53 +0800 Subject: [PATCH 4/6] fix(research): preserve native decisions under workspace aliases Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../native-decision-read.test.mjs | 28 +++++++++++++++++++ .../presentation/goal_source_links.ts | 3 ++ 2 files changed, 31 insertions(+) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs index 502ac5414a..e1c353335b 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs +++ b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs @@ -3,6 +3,7 @@ import React from "react"; import {renderToStaticMarkup} from "react-dom/server"; import {runRecordSchema} from "../../data/status"; import {GoalStrategyDocument} from "./goal-source-strategies"; +import {projectGoalSourceStatus} from "../../../../../../loopx/control_plane/presentation/goal_source_links.ts"; const base = {goal_id:"archived", generated_at:"2026-01-01T00:00:00Z"}; for (const agent_vision of [undefined, null, [], "invalid", 42]) { assert.equal(runRecordSchema.parse({...base, agent_vision}).agent_vision ?? null, null); @@ -22,3 +23,30 @@ for (const zh of [true,false]) { "Preserve the counterexample","Keep future evidence readable","original-goal","source-a","retained-version"]) assert.ok(html.includes(text),text); } console.log("Native decisions preserve optional compatibility, complete fields and provenance in both languages"); + +// The original document must survive the real source routing and schema path. +for (const workspaceId of ["original-solver", "case-a"]) { + const decision = {goal_id:"original-solver", + vision_patch:{vision_summary:"Keep the native record"}, + future_field:{goal_id:"original-solver", nested:[{goal_id:"original-solver"}]}}; + const native = {...base, goal_id:"original-solver", agent_vision:decision}; + const snapshot = structuredClone(native); + const projected = projectGoalSourceStatus({ + status:{goal_filter:"original-solver",run_history:{goals:[{id:"original-solver",latest_runs:[native]}]}}, + row:{id:workspaceId,parent_goal_id:"parent",source_access:{original_goal_id:"original-solver"}}, + }); + const run = runRecordSchema.parse(projected.run_history.goals[0].latest_runs[0]); + assert.equal(run.goal_id, workspaceId, "workspace routing still uses the local alias"); + assert.deepEqual(run.agent_vision, decision, "native decision identities stay original"); + assert.deepEqual(native, snapshot, "native record remains unchanged"); + for (const zh of [true,false]) { + const html = renderToStaticMarkup(React.createElement(GoalStrategyDocument, { + value:run.agent_vision,recordedAt:base.generated_at,version:"native-version", + originalGoalId:"original-solver",namespace:"source-a",zh, + })); + assert.ok(html.includes("original-solver")); + assert.ok(html.includes("future_field")); + assert.ok(!html.includes("case-a"), "workspace alias cannot enter the original document"); + } +} +console.log("Native source decisions preserve original identities through alias and non-alias projection, schema and renderer"); diff --git a/loopx/control_plane/presentation/goal_source_links.ts b/loopx/control_plane/presentation/goal_source_links.ts index 44f8c21099..2216ec47b1 100644 --- a/loopx/control_plane/presentation/goal_source_links.ts +++ b/loopx/control_plane/presentation/goal_source_links.ts @@ -102,6 +102,9 @@ export function projectGoalSourceStatus(input: JsonObject): JsonObject { // These are status projection routing fields, not source document contents. // All children of this status were read from the same qualified namespace. const route = (value: unknown, key = ""): unknown => { + // Agent decisions are opaque native documents, including future fields. + // Only the enclosing run participates in workspace routing. + if (key === "agent_vision") return value; if ((key === "goal_id" || key === "goal_filter") && value === originalId) return workspaceId; if (Array.isArray(value)) return value.map(item => key === "goal_ids" && item === originalId ? workspaceId : route(item)); From cb84dd09b1c85d681cd5e341875bb29a8e867178 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:09:28 +0800 Subject: [PATCH 5/6] Show only additional fields in archived decision details Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../goal-source-strategies.tsx | 89 ++++++++++++++----- .../native-decision-read.test.mjs | 26 +++++- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx index db4aafc574..9c338977bb 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-source-strategies.tsx @@ -1,5 +1,5 @@ import {ArrowLeft, ArrowRight, RefreshCw} from "lucide-react"; -import {useEffect, useRef, useState} from "react"; +import {type ReactNode, useEffect, useRef, useState} from "react"; import {z} from "zod"; import {requestJson} from "../../data/chat"; import {sourceReadApiUrl} from "../../data/local-status-query"; @@ -152,37 +152,57 @@ export function GoalStrategyDocument({value, recordedAt, agentId, version, origi value: Record; recordedAt: string; agentId?: string; version: string; originalGoalId: string; namespace: string; zh: boolean; }) { - const vision = record(value), patch = record(vision.vision_patch), path = record(vision.path_delta); - const stride = record(vision.stride_decision), probe = record(stride.next_probe), review = record(stride.previous_review); + const additional = {...value}; const time = (stamp: string) => Number.isFinite(Date.parse(stamp)) ? new Intl.DateTimeFormat(zh ? "zh-CN" : "en", {dateStyle: "medium", timeStyle: "medium"}).format(new Date(stamp)) : (zh ? "时间未记录" : "Time not recorded"); - const prose = (label: string, value: unknown) => typeof value === "string" && value - ?

{label}

: null; - const list = (label: string, value: unknown) => Array.isArray(value) && value.length - ?

{label}

    {value.map((item, i) =>
  • + const prose = (label: string, fields: Record, key: string) => { + const text = readDecisionText(fields, key); + return text ?

    {label}

    : null; + }; + const list = (label: string, fields: Record, key: string) => { + const items = fields[key]; + if (!Array.isArray(items) || !items.length) return null; + delete fields[key]; + return

    {label}

      {items.map((item, i) =>
    • {typeof item === "string" ? :
      {JSON.stringify(item, null, 2)}
      } -
    • )}
    : null; +
  • )}
; + }; const nextLabels = zh ? {scope: "范围", prediction: "预期", adoption_criterion: "采用条件", cost_bound: "成本边界", minimum_evidence: "所需依据"} : {scope: "Scope", prediction: "Prediction", adoption_criterion: "Adoption criterion", cost_bound: "Cost bound", minimum_evidence: "Required evidence"}; + const objectives = readDecisionSection(additional, "vision_patch", patch => <> + {prose(zh ? "当时的目标" : "Goal at the time", patch, "vision_summary")} + {prose(zh ? "验收条件" : "Acceptance", patch, "acceptance_summary")} + ); + const path = readDecisionSection(additional, "path_delta", path => <> + {prose(zh ? "原先的判断" : "Prior assumption", path, "prior_assumption")} + {prose(zh ? "当时观察" : "Recorded observation", path, "observed_reality")} + {list(zh ? "改变" : "Changed", path, "changed")} + {list(zh ? "保留" : "Retained", path, "retained")} + {list(zh ? "停止" : "Stopped", path, "stopped")} + {list(zh ? "未解问题" : "Unresolved questions", path, "unresolved_questions")} + {prose(zh ? "再次进入的条件" : "Reentry condition", path, "reentry_condition")} + {list(zh ? "依据引用" : "Evidence references", path, "evidence_refs")} + ); + const stride = readDecisionSection(additional, "stride_decision", stride => <> + {readDecisionSection(stride, "next_probe", probe => { + const rows = Object.entries(nextLabels).flatMap(([key, label]) => { + const text = readDecisionText(probe, key); + return text ? [] : []; + }); + return rows.length ?

{zh ? "当时的后续计划" : "Recorded next plan"}

{rows}
: null; + })} + {readDecisionSection(stride, "previous_review", review => + prose(zh ? "对上轮的记录性回顾" : "Recorded review of the previous decision", review, "lesson"))} + ); return

{agentId ? ` · ${agentId}` : ""}

- {prose(zh ? "当时的目标" : "Goal at the time", patch.vision_summary)} - {prose(zh ? "验收条件" : "Acceptance", patch.acceptance_summary)} - {prose(zh ? "原先的判断" : "Prior assumption", path.prior_assumption)} - {prose(zh ? "当时观察" : "Recorded observation", path.observed_reality)} - {list(zh ? "改变" : "Changed", path.changed)} - {list(zh ? "保留" : "Retained", path.retained)} - {list(zh ? "停止" : "Stopped", path.stopped)} - {list(zh ? "未解问题" : "Unresolved questions", path.unresolved_questions)} - {prose(zh ? "再次进入的条件" : "Reentry condition", path.reentry_condition)} - {Object.keys(probe).length ?

{zh ? "当时的后续计划" : "Recorded next plan"}

{Object.entries(nextLabels).map(([key, label]) => typeof probe[key] === "string" && probe[key] - ? : null)}
: null} - {prose(zh ? "对上轮的记录性回顾" : "Recorded review of the previous decision", review.lesson)} -
{zh ? "完整决策字段" : "All decision fields"} - -
- {list(zh ? "依据引用" : "Evidence references", path.evidence_refs)} + {objectives} + {path} + {stride} + {Object.keys(additional).length ?
{zh ? "其他决策字段" : "Additional decision fields"} + +
: null}
{zh ? "完整原始记录与来源" : "Complete original record and source"}
@@ -191,6 +211,27 @@ export function GoalStrategyDocument({value, recordedAt, agentId, version, origi
; } +function readDecisionText(fields: Record, key: string) { + const text = fields[key]; + if (typeof text !== "string" || !text) return null; + delete fields[key]; + return text; +} + +// The structured view consumes fields from a private copy. Keep unsupported +// shapes and unrendered keys in the disclosure without changing the source record. +function readDecisionSection(fields: Record, key: string, + render: (section: Record) => ReactNode) { + const section = {...record(fields[key])}; + const hasFields = Object.keys(section).length > 0; + const content = render(section); + if (hasFields) { + if (Object.keys(section).length) fields[key] = section; + else delete fields[key]; + } + return content; +} + // Unknown optional fields remain readable without treating them as executable markup. function NativeDecisionFields({value}: {value: unknown}) { if (typeof value === "string") return ; diff --git a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs index e1c353335b..a3cf7506fe 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs +++ b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs @@ -8,9 +8,13 @@ const base = {goal_id:"archived", generated_at:"2026-01-01T00:00:00Z"}; for (const agent_vision of [undefined, null, [], "invalid", 42]) { assert.equal(runRecordSchema.parse({...base, agent_vision}).agent_vision ?? null, null); } -const value = {vision_patch:{vision_summary:"Retain the independently verified baseline"}, +const value = {vision_patch:{vision_summary:"Retain the independently verified baseline", future_context:"Preserve the recorded caveat"}, path_delta:{observed_reality:"The new route failed", unresolved_questions:["Cost remains unknown"]}, - stride_decision:{axes:{work_slice:{plan:"Compare before replacing",reason:"Preserve the counterexample"}}}, + stride_decision:{ + axes:{work_slice:{plan:"Compare before replacing",reason:"Preserve the counterexample"}}, + next_probe:{scope:"Compare both original routes", future_scope:{seen:0, accepted:false}}, + previous_review:{lesson:"The earlier record did not verify adoption", future_review:"Retain the limitation"}, + }, future_field:{unknown_key:"Keep future evidence readable"}}; const parsed = runRecordSchema.parse({...base, agent_vision:value}); assert.deepEqual(parsed.agent_vision,value); @@ -21,7 +25,25 @@ for (const zh of [true,false]) { })); for (const text of ["Retain the independently verified baseline","The new route failed","Compare before replacing", "Preserve the counterexample","Keep future evidence readable","original-goal","source-a","retained-version"]) assert.ok(html.includes(text),text); + const [reading, raw] = html.split('
'); + for (const text of [value.vision_patch.vision_summary, value.path_delta.observed_reality, + value.path_delta.unresolved_questions[0], value.stride_decision.next_probe.scope, value.stride_decision.previous_review.lesson]) { + assert.equal(reading.split(text).length - 1, 1, `Repeat-free reading for ${text}`); + assert.ok(raw.includes(text), `Complete original record for ${text}`); + } + const extraFields = reading.match(/(?:其他决策字段|Additional decision fields)<\/summary>(.*?)<\/details>/s)?.[1] ?? ""; + for (const text of ["Preserve the recorded caveat","Compare before replacing","Retain the limitation","Keep future evidence readable"]) { + assert.ok(extraFields.includes(text), `Additional native field remains readable: ${text}`); + } + assert.match(extraFields, /
seen<\/dt>
0<\/span>/); + assert.match(extraFields, /
accepted<\/dt>
false<\/span>/); + assert.deepEqual(parsed.agent_vision, value, "Reading the document does not mutate the decision"); } +const structuredOnly = renderToStaticMarkup(React.createElement(GoalStrategyDocument, { + value:{vision_patch:{vision_summary:"An entirely structured decision"}}, + recordedAt:base.generated_at,version:"retained-version",originalGoalId:"original-goal",namespace:"source-a",zh:false, +})); +assert.equal((structuredOnly.match(/ Date: Sat, 21 Nov 2026 14:55:15 +0800 Subject: [PATCH 6/6] Test archived execution diagnostics in the release browser gate Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- apps/presentation/dashboard/package.json | 6 +-- .../native-decision-read.test.mjs | 52 +++++++++++++++++++ .../personal-workspace-contract.test.mjs | 1 - 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/apps/presentation/dashboard/package.json b/apps/presentation/dashboard/package.json index 2ad05ce77c..9809927263 100644 --- a/apps/presentation/dashboard/package.json +++ b/apps/presentation/dashboard/package.json @@ -46,10 +46,10 @@ "smoke:home-route": "rm -rf /tmp/loopx-home-route-smoke && tsc --ignoreConfig --target ES2022 --module CommonJS --moduleResolution Node --ignoreDeprecations 6.0 --skipLibCheck --strict --outDir /tmp/loopx-home-route-smoke smoke/home-route-smoke.ts && node /tmp/loopx-home-route-smoke/home-route-smoke.js", "smoke:delegation-preflight": "rm -rf node_modules/.cache/loopx-delegation-preflight-smoke && tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --jsx react-jsx --skipLibCheck --strict --rootDir . --outDir node_modules/.cache/loopx-delegation-preflight-smoke smoke/delegation-preflight-smoke.tsx src/data/delegation-preflight.ts src/features/personal-workspace/delegation-preflight-status.tsx && node node_modules/.cache/loopx-delegation-preflight-smoke/smoke/delegation-preflight-smoke.js", "smoke:delegation-preflight-browser": "node --experimental-strip-types smoke/delegation-preflight-browser-smoke.mjs", - "smoke:personal-workspace": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser-smoke.mjs", + "smoke:personal-workspace": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && npm run test:native-decision-read && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser-smoke.mjs", "smoke:workspace-locale": "LOOPX_PERSONAL_WORKSPACE_SCENARIO=workspace-locale node ../../../examples/personal-workspace-browser-smoke.mjs", - "smoke:personal-workspace-packaged": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser/server-startup.test.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node ../../../examples/personal-workspace-browser-smoke.mjs && LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-evidence-return-smoke.mjs && LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-feedback-recovery-smoke.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/goal-workspace-craft-browser-smoke.mjs", - "smoke:personal-workspace-packaged:catalog": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser/server-startup.test.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node ../../../examples/personal-workspace-browser-smoke.mjs", + "smoke:personal-workspace-packaged": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && npm run test:native-decision-read && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser/server-startup.test.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node ../../../examples/personal-workspace-browser-smoke.mjs && LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-evidence-return-smoke.mjs && LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-feedback-recovery-smoke.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/goal-workspace-craft-browser-smoke.mjs", + "smoke:personal-workspace-packaged:catalog": "npm run smoke:goal-work-browse && npm run smoke:team-report && npm run smoke:answer-report && npm run smoke:chat-model-menu && npm run smoke:conversation-history-order && npm run smoke:goal-order && npm run smoke:goal-activity && npm run smoke:proposal-recency && node src/features/personal-workspace/conversation-order.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/steering-recovery.test.mjs src/features/personal-workspace/composer-keyboard.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/runtime-readiness.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/attention-notifications.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/since-you-looked.test.mjs && node --no-warnings --experimental-strip-types --test src/features/personal-workspace/goal-suggestions.test.mjs && npm run smoke:delegation-preflight && node src/features/personal-workspace/workspace-theme.test.mjs && node src/features/personal-workspace/font-token.test.mjs && npm run test:native-decision-read && node src/features/personal-workspace/personal-workspace-contract.test.mjs && node ../../../examples/personal-workspace-browser/server-startup.test.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node ../../../examples/personal-workspace-browser-smoke.mjs", "smoke:personal-workspace-packaged:team": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-evidence-return-smoke.mjs && LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/team-feedback-recovery-smoke.mjs", "smoke:personal-workspace-packaged:craft": "LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/goal-workspace-craft-browser-smoke.mjs && LOOPX_PERSONAL_WORKSPACE_PACKAGED=1 LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" npm run smoke:workspace-command-palette", "smoke:todo-resume-condition": "rm -rf /tmp/loopx-todo-resume-condition-smoke && tsc --ignoreConfig --target ES2022 --module commonjs --moduleResolution node --ignoreDeprecations 6.0 --skipLibCheck --strict --outDir /tmp/loopx-todo-resume-condition-smoke smoke/todo-resume-condition-smoke.ts src/features/personal-workspace/todo-resume-condition.ts && node /tmp/loopx-todo-resume-condition-smoke/smoke/todo-resume-condition-smoke.js", diff --git a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs index a3cf7506fe..b02a187bd4 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs +++ b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs @@ -2,7 +2,9 @@ import assert from "node:assert/strict"; import React from "react"; import {renderToStaticMarkup} from "react-dom/server"; import {runRecordSchema} from "../../data/status"; +import {ContextDrawer} from "./context-drawer"; import {GoalStrategyDocument} from "./goal-source-strategies"; +import {WorkspaceI18nProvider} from "./i18n"; import {projectGoalSourceStatus} from "../../../../../../loopx/control_plane/presentation/goal_source_links.ts"; const base = {goal_id:"archived", generated_at:"2026-01-01T00:00:00Z"}; for (const agent_vision of [undefined, null, [], "invalid", 42]) { @@ -72,3 +74,53 @@ for (const workspaceId of ["original-solver", "case-a"]) { } } console.log("Native source decisions preserve original identities through alias and non-alias projection, schema and renderer"); + +const run = { + runId: "execution-1", + goalId: "archived", + goalTitle: "Benchmark case", + agentId: "worker", + agentLabel: "Worker", + status: "completed", + title: "Original execution", + latestActivity: "Recorded an assessment", + completedSteps: 1, + totalSteps: 1, +}; +const archivedGoal = { + goalId: run.goalId, + sourceAccess: {label: "Retained snapshot", original_goal_id: "original-solver"}, + sourceRunHistory: {total: 1, recent: [{...base, agent_vision: value}]}, +}; +const renderDrawer = (selection, goals = []) => renderToStaticMarkup( + React.createElement(WorkspaceI18nProvider, null, React.createElement(ContextDrawer, { + agents: [], callbacks: {}, goals, onClose: () => {}, selection, + })), +); +const diagnosticsTrigger = /]+class="personal-diagnostics-trigger"/; +const archivedDrawer = renderDrawer({kind: "run", item: run}, [archivedGoal]); +assert.match(archivedDrawer, /class="personal-detail-card personal-source-run-history"/); +assert.ok(archivedDrawer.includes(value.vision_patch.vision_summary)); +assert.doesNotMatch(archivedDrawer, /personal-run-drawer-tabs/); +assert.doesNotMatch(archivedDrawer, diagnosticsTrigger, "Archived records have their own provenance"); + +const currentDrawer = renderDrawer({kind: "run", item: run}); +assert.match(currentDrawer, /personal-run-drawer-tabs/); +assert.match(currentDrawer, diagnosticsTrigger, "Current executions retain live diagnostics"); + +const proposalDrawer = renderDrawer({ + kind: "proposal", + item: {goalId: run.goalId, previewId: "preview-1", title: "Apply a change", actionKind: "goal.lifecycle", status: "ready", fields: []}, +}); +assert.match(proposalDrawer, diagnosticsTrigger); +const scheduleDrawer = renderDrawer({ + kind: "schedule", + item: {goalId: run.goalId, scheduleId: "schedule-1", label: "Refresh the report", scheduleKind: "heartbeat"}, +}); +assert.match(scheduleDrawer, diagnosticsTrigger); +const outputDrawer = renderDrawer({ + kind: "output", + item: {goalId: run.goalId, outputId: "output-1", title: "Assessment notes", safePreview: "Recorded evidence"}, +}); +assert.doesNotMatch(outputDrawer, diagnosticsTrigger); +console.log("Archived executions expose source provenance and live drawers retain diagnostics where applicable"); diff --git a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs index cf2ed749d0..0af67b7696 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs @@ -234,7 +234,6 @@ assert.match(status, /function withoutGoal/, "Status projection can remove a del assert.match(page, /applied\.reviewPlan\?\.interaction !== "completed"/, "Non-applied typed action results never project as successful Goal deletion"); assert.match(page, /t\("feedback\.stale"\)/, "Stale Goal deletion remains visible with a localized actionable error"); assert.match(page, /activityTimeLabel\(item\.output\.createdAt,\s*locale,\s*t\)/, "Files render locale-aware human-readable output timestamps"); -assert.match(drawer, /selection\.kind === "run" \|\| selection\.kind === "proposal" \|\| selection\.kind === "schedule"/, "Advanced diagnostics only appears on objects with actionable runtime details"); for (const field of ["agentId", "todoId", "runId", "safePreview"]) { assert.match(model, new RegExp(`${field}\\??:`), `Output exposes ${field}`);