diff --git a/apps/presentation/dashboard/package.json b/apps/presentation/dashboard/package.json index 46d308a86b..9809927263 100644 --- a/apps/presentation/dashboard/package.json +++ b/apps/presentation/dashboard/package.json @@ -5,6 +5,7 @@ "license": "Apache-2.0", "type": "module", "scripts": { + "test:native-decision-read": "vite build --ssr src/features/personal-workspace/native-decision-read.test.mjs --outDir node_modules/.cache/native-decision-read --emptyOutDir && node node_modules/.cache/native-decision-read/native-decision-read.test.js", "smoke:goal-created-session": "tsc --noEmit --ignoreConfig --target ES2022 --module ES2022 --moduleResolution Bundler --allowImportingTsExtensions --types node --skipLibCheck --strict smoke/goal-created-session-smoke.ts src/vite-env.d.ts && vite build --ssr smoke/goal-created-session-smoke.ts --outDir node_modules/.cache/goal-created-session --emptyOutDir && node node_modules/.cache/goal-created-session/goal-created-session-smoke.js", "smoke:goal-created-session-browser": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/goal-created-session-browser-smoke.mjs", "smoke:conversation-find": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/conversation-find-browser-smoke.mjs", @@ -45,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/data/status.ts b/apps/presentation/dashboard/src/data/status.ts index 4c778ac672..60d10a7ace 100644 --- a/apps/presentation/dashboard/src/data/status.ts +++ b/apps/presentation/dashboard/src/data/status.ts @@ -533,8 +533,15 @@ export const projectMapSchema = z.object({ }); export const runRecordSchema = z.object({ + agent_id: z.string().nullish().catch(null), generated_at: z.string(), goal_id: z.string(), + turn_instance_id: z.string().nullish().catch(null), + agent_vision: z.record(z.string(), z.unknown()).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..6af9f3cb95 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,45 @@ import { formatMonitorDate } from "./monitor-readback"; import { parseTodoCompletionProof } from "./todo-completion-feedback"; import { useDrawerOverlay } from "./workspace-shell"; +import { GoalStrategyDocument } from "./goal-source-strategies"; + +function SourceRunHistory({ goal, heading = false }: { goal: WorkspaceGoal; heading?: boolean }) { + const { t, locale } = 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")} +
    +
    + {run.agent_vision ? + :

    {t("drawer.sourceRunDecisionUnavailable")}

    } +
    +
  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 +395,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 +717,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 +1124,8 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention ) : null} - {selection.kind === "run" ? ( + {sourceRunGoal ? : null} + {selection.kind === "run" && !sourceRunGoal ? ( <>
@@ -1340,7 +1385,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") ? ( <> : null}
@@ -147,31 +139,108 @@ 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}

- {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)} - {list(zh ? "依据引用" : "Evidence references", path.evidence_refs)} -
{zh ? "完整原始记录与来源" : "Complete original record and source"} -
-
-
{JSON.stringify(selected, null, 2)}
-
-
: null} + {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 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, 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)}
    } +
  • )}
; + }; + 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}` : ""}

+ {objectives} + {path} + {stride} + {Object.keys(additional).length ?
{zh ? "其他决策字段" : "Additional decision fields"} + +
: null} +
{zh ? "完整原始记录与来源" : "Complete original record and source"} +
+
+
{JSON.stringify(originalRecord ?? value, null, 2)}
+
+
; +} + +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 ; + 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}) { return
{label}
{value}
; } diff --git a/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx b/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx index 71e75b04b5..382758adf0 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/i18n.tsx @@ -380,6 +380,16 @@ const en = { "drawer.completedAt": "Completed at", "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", + "drawer.sourceRunOriginalTurn": "Original turn", + "drawer.sourceRunRecordType": "Record type", + "drawer.sourceRunCheckpoint": "Strategy checkpoint", + "drawer.sourceRunUnrecorded": "Unrecorded", + "drawer.sourceRunUnavailable": "Historical execution records are unavailable.", "drawer.noRun": "Execution Session has not started", "drawer.noRunDescription": "Run records will appear here after an Agent starts execution.", "drawer.notAssigned": "Unassigned", @@ -2007,6 +2017,16 @@ const zhCN: Record = { "drawer.completedAt": "完成时间", "drawer.validationRevisionActor": "修订者", "drawer.noExecutionHistory": "暂无执行记录。", + "drawer.sourceRunHistory": "历史执行", + "drawer.sourceRunDecisionUnavailable": "这条执行记录未保留完整决策正文。", + "drawer.sourceRunRecent": "最近 {shown} 条记录", + "drawer.sourceRunCount": "显示最近 {shown} 条,共 {count} 条", + "drawer.sourceRunOriginalGoal": "原 Goal", + "drawer.sourceRunOriginalTurn": "原回合", + "drawer.sourceRunRecordType": "记录类型", + "drawer.sourceRunCheckpoint": "策略检查点", + "drawer.sourceRunUnrecorded": "未记录", + "drawer.sourceRunUnavailable": "原始执行记录暂不可读。", "drawer.noRun": "尚未启动执行 Session", "drawer.noRunDescription": "Agent 开始执行后,运行记录会稳定显示在这里。", "drawer.notAssigned": "未分配", 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..b02a187bd4 --- /dev/null +++ b/apps/presentation/dashboard/src/features/personal-workspace/native-decision-read.test.mjs @@ -0,0 +1,126 @@ +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]) { + assert.equal(runRecordSchema.parse({...base, agent_vision}).agent_vision ?? null, null); +} +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"}}, + 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); +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); + 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(/ 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 ba6e3bd6a1..773deada6e 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}`); 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 8c2af83600..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 @@ -7,7 +7,7 @@ import type { ActionReviewPlan } from "../../../../../../loopx/control_plane/pre import type { GoalAcceptanceObservation } from "../../data/goal-acceptance-observation"; import type { AttentionDetails } from "./attention-details"; import type { WorkspaceLoadError, WorkspaceReadScope } from "../../data/workspace-progressive-status"; -import type { TodoItem } from "../../data/status"; +import type { RunRecord, TodoItem } from "../../data/status"; import type { TodoUpdateSourceBasis } from "../../data/action-source-basis"; import { goalWorkKind, type GoalHostThreadActivity, type WorkspaceGoalExecution } from "./goal-activity"; import { receiptRetryReadback } from "./monitor-readback"; @@ -166,6 +166,10 @@ export type WorkspaceGoalSubagentConfiguration = { export type WorkspaceGoal = { sourceAccess?: {namespace: string; label: string; readOnly: true; original_goal_id?: string}; + sourceRunHistory?: { + total: number | null; + recent: Pick[]; + }; sourceStrategy?: {recordedAt: string; summary: string; observation?: string}; /** Registry organization in this status source; not Agent ownership or execution dependency. */ parentGoalId?: string | null; 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 937d3f00cb..f87520f1fb 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css @@ -1444,6 +1444,10 @@ button.personal-execution-chip:focus-visible { outline: 2px solid #0070f3; outli .personal-report-detail li strong { font-size: var(--text-caption); line-height: var(--leading-caption); } .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 > 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; } .personal-execution-history h3 { margin: 0 0 10px; font-size: var(--text-caption); line-height: var(--leading-caption); font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--pw-faint); } .personal-execution-history > p { color: var(--pw-muted); font-size: var(--text-caption); line-height: var(--leading-caption); } @@ -2239,3 +2243,9 @@ 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; } + +.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); } diff --git a/apps/presentation/dashboard/src/views/dashboard-page.tsx b/apps/presentation/dashboard/src/views/dashboard-page.tsx index a3a6eabbba..d3047a170c 100644 --- a/apps/presentation/dashboard/src/views/dashboard-page.tsx +++ b/apps/presentation/dashboard/src/views/dashboard-page.tsx @@ -1148,6 +1148,10 @@ function buildPersonalHomeModel( goalId: goal.id, parentGoalId: goal.parent_goal_id, sourceAccess: goal.source_access ? {...goal.source_access, readOnly: true} : undefined, + sourceRunHistory: goal.source_access ? { + total: goal.index_exists ? goal.unique_runs : null, + recent: goal.latest_runs.filter(run => run.goal_id === goal.id), + } : undefined, sourceStrategy: sourceStrategies?.sort((left, right) => Date.parse(right.recordedAt) - Date.parse(left.recordedAt))[0], latestActivity: row.latestRun?.generated_at ?? "", needsYou, 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));