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 apps/presentation/dashboard/src/data/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export const runRecordSchema = z.object({
generated_at: z.string(),
goal_id: z.string(),
turn_instance_id: z.string().nullish().catch(null),
execution_ref: z.string().regex(/^[a-f0-9]{64}$/).optional().catch(undefined),
agent_vision: z.record(z.string(), z.unknown()).nullish().catch(null),
vision_checkpoint: z.object({
schema_version: z.literal("vision_checkpoint_v0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { parseTodoResumeCondition, todoResumeTransition } from "./todo-resume-co
import { MarkdownText } from "./markdown";
import { formatMonitorDate } from "./monitor-readback";
import { parseTodoCompletionProof } from "./todo-completion-feedback";
import { SourceRunHistory } from "./source-run-history";
import { useDrawerOverlay } from "./workspace-shell";
import {
deriveGoalWorkerRoster,
Expand Down Expand Up @@ -96,45 +97,6 @@ function runRosterState(run: WorkspaceRun): WorkerRosterState {
return "waiting";
}

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 <section className="personal-detail-card personal-source-run-history" aria-label={t("drawer.sourceRunHistory")}>
{heading ? <h3>{t("drawer.sourceRunHistory")}</h3> : null}
<small>{goal.sourceAccess?.label} · {t("common.readOnly")}</small>
<dl><div>
<dt>{t("drawer.sourceRunOriginalGoal")}</dt><dd><code>{goal.sourceAccess?.original_goal_id ?? goal.goalId}</code></dd>
</div></dl>
{recent.length ? <>
<p>{total === null ? t("drawer.sourceRunRecent", {shown: recent.length})
: t("drawer.sourceRunCount", {shown: recent.length, count: total})}</p>
<ol>{recent.map((run, index) => <li key={`${run.generated_at}:${run.turn_instance_id ?? ""}:${index}`}>
<details>
<summary><time dateTime={run.generated_at}>{run.generated_at}</time></summary>
<dl>
{run.classification ? <div><dt>{t("drawer.sourceRunRecordType")}</dt><dd>{run.classification}</dd></div> : null}
<div><dt>{t("drawer.sourceRunOriginalTurn")}</dt><dd>
{run.turn_instance_id ? <code>{run.turn_instance_id}</code> : t("drawer.sourceRunUnrecorded")}
</dd></div>
<div><dt>{t("drawer.sourceRunCheckpoint")}</dt><dd>
{run.vision_checkpoint ? <code>{run.vision_checkpoint.decision}</code> : t("drawer.sourceRunUnrecorded")}
</dd></div>
</dl>
{run.agent_vision ? <GoalStrategyDocument executionRecord value={run.agent_vision}
recordedAt={run.generated_at} agentId={run.agent_id ?? undefined} version={`${run.generated_at} · ${run.turn_instance_id ?? ""}`}
originalGoalId={goal.sourceAccess?.original_goal_id ?? goal.goalId}
namespace={goal.sourceAccess?.namespace ?? ""} zh={locale === "zh-CN"}/>
: <p>{t("drawer.sourceRunDecisionUnavailable")}</p>}
</details>
</li>)}</ol>
</> : <p>{t(total === 0 ? "drawer.noExecutionHistory" : "drawer.sourceRunUnavailable")}</p>}
</section>;
}

function subagentModelRequest(include: boolean, model: string, effort: string) {
if (!include) return {};
if (!model.trim()) return { modelConfig: null };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ export function GoalStrategyDocument({value, recordedAt, agentId, version, origi
{Object.keys(additional).length ? <details><summary>{zh ? "其他决策字段" : "Additional decision fields"}</summary>
<NativeDecisionFields value={additional}/>
</details> : null}
<details className="research-node-provenance"><summary>{zh ? "完整原始记录与来源" : "Complete original record and source"}</summary>
<details className="research-node-provenance"><summary>{executionRecord
? (zh ? "执行记录详情与来源" : "Execution record details and source")
: (zh ? "完整原始记录与来源" : "Complete original record and source")}</summary>
<dl><FragmentField label="Goal" value={originalGoalId}/><FragmentField label={zh ? "来源" : "Source"} value={namespace}/>
<FragmentField label={executionRecord ? (zh ? "执行记录身份" : "Execution record identity") : (zh ? "版本" : "Version")} value={version}/><FragmentField label={zh ? "记录时间" : "Recorded time"} value={recordedAt}/></dl>
<pre tabIndex={0}>{JSON.stringify(originalRecord ?? value, null, 2)}</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ const en = {
"drawer.sourceRunCheckpoint": "Strategy checkpoint",
"drawer.sourceRunUnrecorded": "Unrecorded",
"drawer.sourceRunUnavailable": "Historical execution records are unavailable.",
"drawer.sourceRunLoading": "Reading the source execution…",
"drawer.sourceRunReadFailed": "The source record is unavailable. The index summary is shown below.",
"drawer.sourceRunRetry": "Retry reading the source",
"drawer.sourceRunOutcome": "Delivery outcome",
"drawer.noRun": "Execution Session has not started",
"drawer.noRunDescription": "Run records will appear here after an Agent starts execution.",
"drawer.notAssigned": "Unassigned",
Expand Down Expand Up @@ -2036,6 +2040,10 @@ const zhCN: Record<WorkspaceMessageKey, string> = {
"drawer.sourceRunCheckpoint": "策略检查点",
"drawer.sourceRunUnrecorded": "未记录",
"drawer.sourceRunUnavailable": "原始执行记录暂不可读。",
"drawer.sourceRunLoading": "正在读取原始执行记录…",
"drawer.sourceRunReadFailed": "原始执行记录暂不可读。下面显示索引摘要。",
"drawer.sourceRunRetry": "重试读取原件",
"drawer.sourceRunOutcome": "交付结果",
"drawer.noRun": "尚未启动执行 Session",
"drawer.noRunDescription": "Agent 开始执行后,运行记录会稳定显示在这里。",
"drawer.notAssigned": "未分配",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export type WorkspaceGoal = {
sourceAccess?: {namespace: string; label: string; readOnly: true; original_goal_id?: string};
sourceRunHistory?: {
total: number | null;
recent: Pick<RunRecord, "generated_at" | "classification" | "turn_instance_id" | "vision_checkpoint" | "agent_vision" | "agent_id">[];
recent: Pick<RunRecord, "generated_at" | "classification" | "turn_instance_id" | "execution_ref" | "vision_checkpoint" | "agent_vision" | "agent_id">[];
};
sourceStrategy?: {recordedAt: string; summary: string; observation?: string};
/** Registry organization in this status source; not Agent ownership or execution dependency. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import {useEffect, useState} from "react";
import {z} from "zod";
import {requestJson} from "../../data/chat";
import {GoalStrategyDocument} from "./goal-source-strategies";
import {useWorkspaceI18n} from "./i18n";
import type {WorkspaceGoal} from "./personal-workspace-model";

type Run = NonNullable<WorkspaceGoal["sourceRunHistory"]>["recent"][number];
const digest = z.string().regex(/^[a-f0-9]{64}$/);
const executionResponse = z.object({
ok: z.literal(true),
goal_id: z.string(),
source: z.object({namespace: digest}),
execution_ref: digest,
sha256: digest,
record: z.object({
goal_id: z.string(),
generated_at: z.string(),
agent_id: z.string().nullish(),
classification: z.string().nullish(),
turn_instance_id: z.string().nullish(),
agent_vision: z.record(z.string(), z.unknown()).nullish(),
vision_checkpoint: z.object({decision: z.string().optional()}).passthrough().nullish(),
delivery_outcome: z.string().nullish(),
}).passthrough(),
});
type Execution = z.infer<typeof executionResponse>;

function SourceRun({goal, run}: {goal: WorkspaceGoal; run: Run}) {
const {t, locale} = useWorkspaceI18n();
const [expanded, setExpanded] = useState(false);
const [retry, setRetry] = useState(0);
const [result, setResult] = useState<Execution | "unavailable" | null>(null);
const {goalId} = goal;
const namespace = goal.sourceAccess?.namespace;
const originalGoal = goal.sourceAccess?.original_goal_id ?? goalId;
const ref = run.execution_ref;
const generatedAt = run.generated_at;

useEffect(() => {
if (!expanded || !ref || !namespace) return;
const controller = new AbortController();
setResult(null);
const query = new URLSearchParams({
goal_id: goalId, source_namespace: namespace, execution_ref: ref, generated_at: generatedAt,
});
void requestJson<unknown>(`/api/chat/goal-source-execution?${query}`, {signal: controller.signal})
.then(payload => {
const detail = executionResponse.parse(payload);
if (detail.goal_id !== originalGoal || detail.record.goal_id !== originalGoal
|| detail.source.namespace !== namespace || detail.execution_ref !== ref
|| detail.record.generated_at !== generatedAt) {
throw new Error("Inconsistent execution source");
}
if (!controller.signal.aborted) setResult(detail);
})
.catch(() => {if (!controller.signal.aborted) setResult("unavailable");});
return () => controller.abort();
}, [expanded, ref, generatedAt, namespace, originalGoal, goalId, retry]);

const execution = result && result !== "unavailable" ? result : null;
const record = execution?.record ?? run;
const loading = Boolean(expanded && ref && namespace && result === null);
return <details onToggle={event => setExpanded(event.currentTarget.open)}>
<summary><time dateTime={run.generated_at}>{run.generated_at}</time></summary>
{loading ? <p role="status">{t("drawer.sourceRunLoading")}</p> : null}
{result === "unavailable" ? <div role="alert">
<p>{t("drawer.sourceRunReadFailed")}</p>
<button type="button" onClick={() => setRetry(value => value + 1)}>{t("drawer.sourceRunRetry")}</button>
</div> : null}
<dl>
{record.classification ? <div><dt>{t("drawer.sourceRunRecordType")}</dt><dd>{record.classification}</dd></div> : null}
<div><dt>{t("drawer.sourceRunOriginalTurn")}</dt><dd>
{record.turn_instance_id ? <code>{record.turn_instance_id}</code> : t("drawer.sourceRunUnrecorded")}
</dd></div>
<div><dt>{t("drawer.sourceRunCheckpoint")}</dt><dd>
{record.vision_checkpoint?.decision ? <code>{record.vision_checkpoint.decision}</code> : t("drawer.sourceRunUnrecorded")}
</dd></div>
{execution?.record.delivery_outcome ? <div><dt>{t("drawer.sourceRunOutcome")}</dt>
<dd>{execution.record.delivery_outcome}</dd></div> : null}
</dl>
{record.agent_vision || execution ? <GoalStrategyDocument executionRecord value={record.agent_vision ?? {}}
originalRecord={execution?.record} recordedAt={run.generated_at} agentId={record.agent_id ?? undefined}
version={execution?.sha256 ?? `${run.generated_at} · ${run.turn_instance_id ?? ""}`}
originalGoalId={originalGoal} namespace={namespace ?? ""} zh={locale === "zh-CN"}/>
: !loading ? <p>{t("drawer.sourceRunDecisionUnavailable")}</p> : null}
</details>;
}

export function SourceRunHistory({goal, heading = false}: {goal: WorkspaceGoal; heading?: boolean}) {
const {t} = useWorkspaceI18n();
const recent = goal.sourceRunHistory?.recent ?? [];
const total = goal.sourceRunHistory?.total ?? null;
return <section className="personal-detail-card personal-source-run-history" aria-label={t("drawer.sourceRunHistory")}>
{heading ? <h3>{t("drawer.sourceRunHistory")}</h3> : null}
<small>{goal.sourceAccess?.label} · {t("common.readOnly")}</small>
<dl><div><dt>{t("drawer.sourceRunOriginalGoal")}</dt><dd><code>{goal.sourceAccess?.original_goal_id ?? goal.goalId}</code></dd></div></dl>
{recent.length ? <>
<p>{total === null ? t("drawer.sourceRunRecent", {shown: recent.length})
: t("drawer.sourceRunCount", {shown: recent.length, count: total})}</p>
<ol>{recent.map((run, index) => <li key={`${goal.sourceAccess?.namespace}:${run.execution_ref ?? run.generated_at}:${index}`}>
<SourceRun goal={goal} run={run}/>
</li>)}</ol>
</> : <p>{t(total === 0 ? "drawer.noExecutionHistory" : "drawer.sourceRunUnavailable")}</p>}
</section>;
}
6 changes: 5 additions & 1 deletion loopx/chat_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@
from .chat.completed_todos import CompletedTodoPages, CompletedTodoRequestMixin
from .presentation.explore_results_api import ExploreResultsRequestMixin
from .presentation.research_analysis_api import RESEARCH_ANALYSIS_PATH, ResearchAnalysisRequestMixin
from .presentation.goal_source_routing import GOAL_SOURCE_LINKS_PATH, GOAL_SOURCE_STRATEGIES_PATH, GOAL_SOURCE_DOCUMENT_PATH, GoalSourceRequestMixin
from .presentation.goal_source_routing import (
GOAL_SOURCE_DOCUMENT_PATH, GOAL_SOURCE_EXECUTION_PATH, GOAL_SOURCE_LINKS_PATH,
GOAL_SOURCE_STRATEGIES_PATH, GoalSourceRequestMixin,
)
from .chat.todo_detail import TodoDetailRequestMixin
from .kiro_cli_goal_mode import KIRO_CLI_BIN
from .paths import resolve_runtime_root
Expand Down Expand Up @@ -1455,6 +1458,7 @@ def do_GET(self) -> None:
GOAL_SOURCE_LINKS_PATH: self._goal_source_links,
GOAL_SOURCE_STRATEGIES_PATH: self._goal_source_strategies,
GOAL_SOURCE_DOCUMENT_PATH: self._goal_source_document,
GOAL_SOURCE_EXECUTION_PATH: self._goal_source_execution,
"/api/chat/todo/detail": self._todo_detail,
"/api/chat/completed-todos": self._completed_todos,
"/api/chat/explore-results": self._explore_results,
Expand Down
Loading
Loading