feat(pi-workflow): add human-readable run labels

This commit is contained in:
jb
2026-08-25 21:22:08 -04:00
parent a1d0b1415c
commit 54a7921227
17 changed files with 385 additions and 52 deletions
+14 -3
View File
@@ -11,6 +11,7 @@ import {
type ContextTransitionRuntime,
} from "./context-transition.ts";
import type { WorkflowCommand, WorkflowView } from "./engine.ts";
import { deriveRunLabel } from "./run-label.ts";
const ACTIONS = ["start", "inspect", "decide", "abort"] as const;
const WORKFLOW_MODES = ["feature", "feature-script", "analysis-script"] as const;
@@ -370,9 +371,9 @@ function boundToolOutput(contents: string) {
return `${characters.join("")}${marker}`;
}
function resultText(details: WorkflowToolDetails) {
function resultText(details: WorkflowToolDetails, label: string) {
const lines = [
`Workflow ${details.runId}: ${details.status} at revision ${details.revision}.`,
`Workflow ${label}: ${details.status} at revision ${details.revision}.`,
];
if (details.openGate) {
lines.push(
@@ -479,6 +480,14 @@ export function registerPiWorkflowTool(
await cancellationWork;
throw cancellationError();
}
} catch (error) {
if (params.action === "inspect" && params.runId) {
const reason = error instanceof Error ? error.message : String(error);
throw new Error(
`Workflow Run ${params.runId} could not be loaded: ${reason}`,
);
}
throw error;
} finally {
executionSignal.removeEventListener("abort", onAbort);
}
@@ -488,7 +497,9 @@ export function registerPiWorkflowTool(
ctx.sessionManager.getSessionId(),
);
return {
content: [{ type: "text" as const, text: resultText(details) }],
content: [
{ type: "text" as const, text: resultText(details, deriveRunLabel(view)) },
],
details,
};
},