feat(web): copy original run prompt

This commit is contained in:
2026-10-21 12:19:26 +01:00
parent 634f241019
commit cc094fc06d
6 changed files with 275 additions and 0 deletions
+5
View File
@@ -66,6 +66,11 @@ export const EMPTY_OUTPUT_MESSAGE = "No output recorded.";
export const EMPTY_TIMELINE_MESSAGE = "No visits recorded.";
export const NO_STAGE_DETAILS_MESSAGE = "No details recorded for this node.";
/** The original run prompt, without display formatting or a fallback source. */
export function originalRunPrompt(run) {
return typeof run?.input?.prompt === "string" ? run.input.prompt : undefined;
}
/** The stage-pane section titles (Android StageDetailPane constants). */
export const STAGE_ARTIFACTS_TITLE = "Artifacts";
export const STAGE_SESSION_TITLE = "Session";
+42
View File
@@ -17,6 +17,7 @@ import {
EMPTY_OUTPUT_MESSAGE,
EMPTY_TIMELINE_MESSAGE,
NO_STAGE_DETAILS_MESSAGE,
originalRunPrompt,
fieldSections,
summaryRows,
runIdentityLine,
@@ -974,6 +975,46 @@ function renderDecisionCard(decision) {
/** Run controls plus an independent schedule seeded from the original RunInfo. */
function renderRunActions(d) {
const buttons = [];
let status = null;
const prompt = originalRunPrompt(d);
if (prompt !== undefined) {
status = h("span", {
class: "run-action-status",
role: "status",
"aria-live": "polite",
"aria-atomic": "true",
hidden: true,
});
const report = (message, tone) => {
status.textContent = message;
status.dataset.state = tone;
status.hidden = false;
};
const copy = h("button", {
class: "run-action copy-prompt",
type: "button",
text: "Copy prompt",
"aria-label": "Copy prompt",
});
copy.addEventListener("click", async () => {
const clipboard = typeof navigator === "undefined" ? null : navigator.clipboard;
if (typeof clipboard?.writeText !== "function") {
report("Clipboard is unavailable in this browser.", "error");
return;
}
copy.disabled = true;
report("Copying prompt…", "pending");
try {
await clipboard.writeText(prompt);
report("Prompt copied to clipboard.", "success");
} catch {
report("Could not copy prompt to clipboard.", "error");
} finally {
copy.disabled = false;
}
});
buttons.push(copy);
}
if (rt.views?.schedules && Number(d.pipeline_id) > 0 && Number(d.version) > 0) {
buttons.push(h("button", {
class: "run-action schedule-run",
@@ -1013,6 +1054,7 @@ function renderRunActions(d) {
}),
);
}
if (status) buttons.push(status);
if (!buttons.length) return null;
return h("div", { class: "run-actions" }, ...buttons);
}