web: open authored stage definitions in managed graph popup
This commit is contained in:
+16
-15
@@ -9,6 +9,7 @@ import { resolveArtifactUrl } from "../serverUrl.js";
|
||||
import { runStateOf, runStatusLabel } from "../runs.js";
|
||||
import { PIPELINE_GRAPH_EMPTY, RUN_GRAPH_MISSING, mount as mountGraph } from "../graph.js";
|
||||
import { writeGraphExpanded } from "../graphPrefs.js";
|
||||
import { definitionDocument } from "./stageDefinition.js";
|
||||
import {
|
||||
RENDERED_RUN_TABS,
|
||||
EMPTY_INPUT_MESSAGE,
|
||||
@@ -26,8 +27,6 @@ import {
|
||||
headlineFields,
|
||||
runStepFields,
|
||||
stageSectionSpecs,
|
||||
stageDefinitionFields,
|
||||
terminalFields,
|
||||
clampVisitIndex,
|
||||
referencedVerdictArtifacts,
|
||||
verdictReasonSegments,
|
||||
@@ -174,8 +173,8 @@ function renderRunDetail(now = Date.now()) {
|
||||
* The Graph tab (R5): the run's own guidance note plus the shared workflow graph
|
||||
* mounted in run mode, or the app's exact missing-graph sentence when the server
|
||||
* sent no stages. The active stage pulses with its elapsed time while the run
|
||||
* executes; clicking a stage opens the existing visit pane at that stage's most
|
||||
* recent visit. The mount handle is tracked in `state.runGraph` so a re-render
|
||||
* executes; clicking a stage opens its authored definition without navigating.
|
||||
* The mount handle is tracked in `state.runGraph` so a re-render
|
||||
* (or a tab/run change) always unmounts the previous wheel/pointer/resize
|
||||
* listeners and the elapsed timer.
|
||||
*/
|
||||
@@ -191,7 +190,9 @@ function renderRunGraphTab(d) {
|
||||
state.runGraph = mountGraph(host, d.graph, {
|
||||
runState: runGraphState(d),
|
||||
expanded: state.runGraphExpanded,
|
||||
onStageTap: (key) => openStagePane(key, latestVisitIndex(d, key)),
|
||||
onStageTap: (key) => rt.views.dialogs.openStageDefinition(
|
||||
runDefinition(d), key, `Run ${d.id} · pipeline ${d.pipeline_id} · v${d.version}`,
|
||||
),
|
||||
onExpandedChange: (value) => {
|
||||
state.runGraphExpanded = value;
|
||||
writeGraphExpanded(value);
|
||||
@@ -212,8 +213,6 @@ function latestVisitIndex(d, key) {
|
||||
/** Open the audit dialog for one visit: its turn files, session and definition. */
|
||||
function openAuditFor(d, step, stageKey, visitIndex) {
|
||||
if (!step) return;
|
||||
const graph = d.graph ?? { stages: [] };
|
||||
const stage = (graph.stages ?? []).find((candidate) => candidate.key === stageKey) ?? null;
|
||||
showStageAudit({
|
||||
title: `${nodeLabel(stageKey)} audit`,
|
||||
subtitle: `Visit ${visitIndex + 1} · ${runLabelFor(d)}`,
|
||||
@@ -222,7 +221,9 @@ function openAuditFor(d, step, stageKey, visitIndex) {
|
||||
{ key: "output", label: "Output", body: () => auditArtifact(step, "output.md", EMPTY_OUTPUT_MESSAGE) },
|
||||
{ key: "memory", label: "Memory", body: () => auditArtifact(step, "memory.md", "No memory recorded for this visit.") },
|
||||
{ key: "session", label: "Session", body: () => auditSession(step) },
|
||||
{ key: "definition", label: "Definition", body: () => auditDefinition(stage, stageKey, graph) },
|
||||
{ key: "definition", label: "Definition", body: () => definitionDocument(
|
||||
runDefinition(d), stageKey, (text) => rt.views.chat.renderMarkdown(text),
|
||||
) },
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -341,13 +342,13 @@ function auditSession(step) {
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** The stage's own definition (prompt, tools, configs, edges) in the audit. */
|
||||
function auditDefinition(stage, stageKey, graph) {
|
||||
const fields = stage ? stageDefinitionFields(stage) : terminalFields(graph, stageKey);
|
||||
if (!fields.length) return h("div", { class: "muted", text: NO_STAGE_DETAILS_MESSAGE });
|
||||
const body = h("div", { class: "audit-definition" });
|
||||
for (const field of fields) body.append(renderStageField(field));
|
||||
return body;
|
||||
/** Load authored source for exactly the run's recorded version. */
|
||||
function runDefinition(d) {
|
||||
// Never fall back to latest: a run must show the version it executed.
|
||||
if (!(Number(d.pipeline_id) > 0 && Number(d.version) > 0)) {
|
||||
return Promise.reject(new Error("The run did not include its pipeline version."));
|
||||
}
|
||||
return repo.getPipeline(d.pipeline_id, d.version);
|
||||
}
|
||||
|
||||
/** The Summary tab: identity, key/value rows, diagnostic and the sections. */
|
||||
|
||||
Reference in New Issue
Block a user