@burdenoff/microfe-stewards 2026.1202.1 → 2026.1202.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunStepsSection.js","names":["HEADER_CELL","StepRow","selected","step","onPick","enumLabel","t","Badge","VERDICT_TONE","StepsTable","useStewardsT","steps","StateMessage","selectedId","RunStepsSection","picked","setPicked","useState","s","detailTitle","Card","StepDetail","APPROVAL_TONE","RunApprovalsCard","approvals","a"],"sources":["../../../../src/stewards/components/run/RunStepsSection.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { StewardRunDetailFieldsFragment } from '../../../generated/wspace-operations';\nimport { useStewardsT, type StewardsT } from '../../i18n/useStewardsT';\nimport { enumLabel, VERDICT_TONE } from '../stewardLabels';\nimport { Badge, Card, StateMessage } from '../ui';\nimport { StepDetail, type RunStep } from './StepDetail';\n\nconst HEADER_CELL = 'px-2 py-1 font-medium';\n\nfunction StepRow({\n step,\n selected,\n onPick,\n t,\n}: {\n step: RunStep;\n selected: boolean;\n onPick: (id: string) => void;\n t: StewardsT;\n}) {\n return (\n <tr\n aria-selected={selected}\n className={`border-b border-(color:--color-border-seam) last:border-b-0 ${selected ? 'bg-(--color-accent-soft)' : ''}`}\n >\n <td className=\"px-2 py-2 text-(color:--color-text-secondary) tabular-nums\">{step.seq}</td>\n <td className=\"px-2 py-2\">\n <button\n type=\"button\"\n className=\"text-left focus-visible:outline-2 focus-visible:outline-(color:--color-focus-ring)\"\n onClick={() => onPick(step.id)}\n >\n <span className=\"block font-medium text-(color:--color-text-primary)\">\n {enumLabel(t, 'stepKind', step.kind)}\n </span>\n <span className=\"block break-all font-mono text-xs text-(color:--color-text-secondary)\">\n {[step.toolKey, step.targetSummary].filter(Boolean).join(' · ')}\n </span>\n </button>\n </td>\n <td className=\"px-2 py-2\">\n <Badge tone={VERDICT_TONE[step.verdict]}>{enumLabel(t, 'verdict', step.verdict)}</Badge>\n </td>\n <td className=\"px-2 py-2 text-(color:--color-text-primary) tabular-nums\">\n {step.creditsUsed.toFixed(2)}\n </td>\n </tr>\n );\n}\n\nfunction StepsTable({\n steps,\n selectedId,\n onPick,\n}: {\n steps: readonly RunStep[];\n selectedId: string | undefined;\n onPick: (id: string) => void;\n}) {\n const t = useStewardsT();\n if (steps.length === 0) {\n return <StateMessage kind=\"empty\" title={t('stewards.run.noSteps')} />;\n }\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full text-sm\" aria-label={t('stewards.run.stepsHeading')}>\n <thead>\n <tr className=\"border-b border-(color:--color-border-seam) text-left text-xs text-(color:--color-text-secondary)\">\n <th scope=\"col\" className={HEADER_CELL}>\n {t('stewards.run.colNumber')}\n </th>\n <th scope=\"col\" className={HEADER_CELL}>\n {t('stewards.run.colStep')}\n </th>\n <th scope=\"col\" className={HEADER_CELL}>\n {t('stewards.run.colVerdict')}\n </th>\n <th scope=\"col\" className={HEADER_CELL}>\n {t('stewards.run.colCredits')}\n </th>\n </tr>\n </thead>\n <tbody>\n {steps.map((step) => (\n <StepRow\n key={step.id}\n step={step}\n selected={selectedId === step.id}\n onPick={onPick}\n t={t}\n />\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\n/**\n * The run's steps in order, with the picked step's detail beside them. Until the person picks\n * one, the latest step is shown, so a live run follows its newest step.\n */\nexport function RunStepsSection({\n steps,\n timeZone,\n}: {\n steps: StewardRunDetailFieldsFragment['steps'];\n timeZone: string;\n}) {\n const t = useStewardsT();\n const [picked, setPicked] = useState<string | null>(null);\n const selected = steps.find((s) => s.id === picked) ?? steps[steps.length - 1];\n const detailTitle = selected\n ? t('stewards.run.stepDetail', {\n seq: selected.seq,\n tool: selected.toolKey ?? enumLabel(t, 'stepKind', selected.kind),\n })\n : t('stewards.run.stepsHeading');\n\n return (\n <div className=\"grid grid-cols-1 gap-4 xl:grid-cols-5\">\n <Card\n title={t('stewards.run.stepsHeading')}\n hint={t('stewards.run.stepsOrdered')}\n className=\"xl:col-span-2\"\n >\n <StepsTable steps={steps} selectedId={selected?.id} onPick={setPicked} />\n </Card>\n <Card title={detailTitle} className=\"xl:col-span-3\">\n {selected ? (\n <StepDetail step={selected} timeZone={timeZone} />\n ) : (\n <p className=\"text-sm text-(color:--color-text-secondary)\">\n {t('stewards.run.pickStep')}\n </p>\n )}\n </Card>\n </div>\n );\n}\n\nconst APPROVAL_TONE: Record<string, 'warning' | 'success' | 'neutral'> = {\n PENDING: 'warning',\n APPROVED: 'success',\n};\n\n/** Approval requests the run raised, with their status and requested scope. */\nexport function RunApprovalsCard({\n approvals,\n}: {\n approvals: StewardRunDetailFieldsFragment['approvals'];\n}) {\n const t = useStewardsT();\n if (approvals.length === 0) return null;\n return (\n <Card title={t('stewards.run.approvalsTitle')}>\n <ul className=\"flex flex-col gap-1 text-sm\">\n {approvals.map((a) => (\n <li\n key={a.id}\n className=\"flex flex-wrap items-center gap-2 text-(color:--color-text-primary)\"\n >\n <code className=\"text-xs\">{a.toolName}</code>\n <Badge tone={APPROVAL_TONE[a.status] ?? 'neutral'}>\n {enumLabel(t, 'approvalStatus', a.status)}\n </Badge>\n {a.requestedScope && (\n <span className=\"text-xs text-(color:--color-text-secondary)\">\n {enumLabel(t, 'scope', a.requestedScope)}\n </span>\n )}\n </li>\n ))}\n </ul>\n </Card>\n );\n}\n"],"mappings":";;;;;;;AAOA,IAAMA,IAAc;AAEpB,SAASC,EAAQ,EACf,SACA,aACA,WACA,QAMC;CACD,OACE,kBAAC,MAAD;EACE,iBAAeC;EACf,WAAW,+DAA+DA,IAAW,6BAA6B;EAFpH,UAAA;GAIE,kBAAC,MAAD;IAAI,WAAU;IAA8D,UAAAC,EAAK;GAAQ,CAAA;GACzF,kBAAC,MAAD;IAAI,WAAU;IACZ,UAAA,kBAAC,UAAD;KACE,MAAK;KACL,WAAU;KACV,eAAeC,EAAOD,EAAK,EAAE;KAH/B,UAAA,CAKE,kBAAC,QAAD;MAAM,WAAU;MACb,UAAAE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AMe,EAAcG,EAAE,WAAW;MACrC,UAAApB,EAAUC,GAAG,kBAAkBmB,EAAE,MAAM;KACnC,CAAA;KACNA,EAAE,kBACD,kBAAC,QAAD;MAAM,WAAU;MACb,UAAApB,EAAUC,GAAG,SAASmB,EAAE,cAAc;KACnC,CAAA;IAEN;GAZG,GAAAA,EAAE,EAYL,CACL;EACC,CAAA;CACA,CAAA;AAEV"}
@@ -0,0 +1,8 @@
1
+ import { StewardDetailFieldsFragment, StewardRunDetailFieldsFragment } from '../../../generated/wspace-operations';
2
+ interface RunSummaryCardsProps {
3
+ run: StewardRunDetailFieldsFragment;
4
+ steward: StewardDetailFieldsFragment | undefined;
5
+ }
6
+ /** Trust, credit budget, step budget and verdict counts of one run. */
7
+ export declare function RunSummaryCards({ run, steward }: RunSummaryCardsProps): import('react').JSX.Element;
8
+ export {};
@@ -0,0 +1,92 @@
1
+ import { BotmanorExecutionStepVerdict as e } from "../../../generated/wspace-types.js";
2
+ import { useStewardsT as t } from "../../i18n/useStewardsT.js";
3
+ import { budgetRatio as n, enumLabel as r } from "../stewardLabels.js";
4
+ import { Badge as i, Card as a, ProgressBar as o } from "../ui.js";
5
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ // src/stewards/components/run/RunSummaryCards.tsx
7
+ function u(t) {
8
+ return {
9
+ allowed: t.filter((t) => t.verdict === e.Allowed || t.verdict === e.Approved).length,
10
+ asked: t.filter((t) => t.verdict === e.Asked).length,
11
+ denied: t.filter((t) => t.verdict === e.Denied).length
12
+ };
13
+ }
14
+ function d(e) {
15
+ return e.find((e) => e.trustLevelAfter !== e.trustLevelBefore);
16
+ }
17
+ function f({ used: e, cap: t }) {
18
+ return /* @__PURE__ */ l("p", {
19
+ className: "text-2xl font-semibold text-(color:--color-text-primary) tabular-nums",
20
+ children: [e, /* @__PURE__ */ l("span", {
21
+ className: "text-sm font-normal text-(color:--color-text-secondary)",
22
+ children: [
23
+ " ",
24
+ "/ ",
25
+ t ?? "—"
26
+ ]
27
+ })]
28
+ });
29
+ }
30
+ function p({ run: e, steward: p }) {
31
+ let m = t(), h = u(e.steps), g = d(e.steps), _ = p?.charter.budgetPerRun.credits ?? null, v = p?.charter.budgetPerRun.steps ?? null, y = e.budgetUsed.credits ?? 0;
32
+ return /* @__PURE__ */ l("div", {
33
+ className: "grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4",
34
+ children: [
35
+ /* @__PURE__ */ l(a, {
36
+ title: m("stewards.run.trustTitle"),
37
+ children: [/* @__PURE__ */ l("p", {
38
+ className: "flex flex-wrap items-center gap-2 text-sm",
39
+ children: [/* @__PURE__ */ c(i, {
40
+ tone: "success",
41
+ children: r(m, "trust", e.initialTrustLevel)
42
+ }), e.trustLevel !== e.initialTrustLevel && /* @__PURE__ */ l(s, { children: ["→", /* @__PURE__ */ c(i, {
43
+ tone: "warning",
44
+ children: r(m, "trust", e.trustLevel)
45
+ })] })]
46
+ }), /* @__PURE__ */ c("p", {
47
+ className: "mt-1 text-xs text-(color:--color-text-secondary)",
48
+ children: g ? `${m("stewards.run.trustDegraded")} · #${g.seq}` : m("stewards.run.trustSame")
49
+ })]
50
+ }),
51
+ /* @__PURE__ */ l(a, {
52
+ title: m("stewards.run.budgetTitle"),
53
+ children: [/* @__PURE__ */ c(f, {
54
+ used: y.toFixed(2),
55
+ cap: _
56
+ }), /* @__PURE__ */ c(o, {
57
+ ratio: n(y, _),
58
+ label: m("stewards.run.budgetTitle")
59
+ })]
60
+ }),
61
+ /* @__PURE__ */ l(a, {
62
+ title: m("stewards.run.stepsTitle"),
63
+ children: [/* @__PURE__ */ c(f, {
64
+ used: e.stepCount,
65
+ cap: v
66
+ }), /* @__PURE__ */ c(o, {
67
+ ratio: n(e.stepCount, v),
68
+ label: m("stewards.run.stepsTitle")
69
+ })]
70
+ }),
71
+ /* @__PURE__ */ l(a, {
72
+ title: m("stewards.run.verdictsTitle"),
73
+ children: [/* @__PURE__ */ l("p", {
74
+ className: "text-2xl font-semibold text-(color:--color-text-primary) tabular-nums",
75
+ children: [
76
+ h.allowed,
77
+ " · ",
78
+ h.asked,
79
+ " · ",
80
+ h.denied
81
+ ]
82
+ }), /* @__PURE__ */ c("p", {
83
+ className: "text-xs text-(color:--color-text-secondary)",
84
+ children: m("stewards.run.verdictsLegend")
85
+ })]
86
+ })
87
+ ]
88
+ });
89
+ }
90
+ export { p as RunSummaryCards };
91
+
92
+ //# sourceMappingURL=RunSummaryCards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunSummaryCards.js","names":["_Fragment","countVerdicts","steps","s","BotmanorExecutionStepVerdict","trustDrop","UsageFigure","used","cap","RunSummaryCards","t","useStewardsT","verdicts","run","drop","runCap","steward","stepCap","credits","Card","Badge","enumLabel","Fragment","ProgressBar","budgetRatio"],"sources":["../../../../src/stewards/components/run/RunSummaryCards.tsx"],"sourcesContent":["import type {\n StewardDetailFieldsFragment,\n StewardRunDetailFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { BotmanorExecutionStepVerdict } from '../../../generated/wspace-types';\nimport { useStewardsT } from '../../i18n/useStewardsT';\nimport { budgetRatio, enumLabel } from '../stewardLabels';\nimport { Badge, Card, ProgressBar } from '../ui';\nimport type { RunStep } from './StepDetail';\n\nfunction countVerdicts(steps: readonly RunStep[]) {\n const allowed = steps.filter(\n (s) =>\n s.verdict === BotmanorExecutionStepVerdict.Allowed ||\n s.verdict === BotmanorExecutionStepVerdict.Approved\n ).length;\n const asked = steps.filter((s) => s.verdict === BotmanorExecutionStepVerdict.Asked).length;\n const denied = steps.filter((s) => s.verdict === BotmanorExecutionStepVerdict.Denied).length;\n return { allowed, asked, denied };\n}\n\n/** The first step where the run's trust level dropped, if it did. */\nfunction trustDrop(steps: readonly RunStep[]): RunStep | undefined {\n return steps.find((s) => s.trustLevelAfter !== s.trustLevelBefore);\n}\n\nfunction UsageFigure({ used, cap }: { used: string | number; cap: number | null }) {\n return (\n <p className=\"text-2xl font-semibold text-(color:--color-text-primary) tabular-nums\">\n {used}\n <span className=\"text-sm font-normal text-(color:--color-text-secondary)\">\n {' '}\n / {cap ?? '—'}\n </span>\n </p>\n );\n}\n\ninterface RunSummaryCardsProps {\n run: StewardRunDetailFieldsFragment;\n steward: StewardDetailFieldsFragment | undefined;\n}\n\n/** Trust, credit budget, step budget and verdict counts of one run. */\nexport function RunSummaryCards({ run, steward }: RunSummaryCardsProps) {\n const t = useStewardsT();\n const verdicts = countVerdicts(run.steps);\n const drop = trustDrop(run.steps);\n const runCap = steward?.charter.budgetPerRun.credits ?? null;\n const stepCap = steward?.charter.budgetPerRun.steps ?? null;\n const credits = run.budgetUsed.credits ?? 0;\n\n return (\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4\">\n <Card title={t('stewards.run.trustTitle')}>\n <p className=\"flex flex-wrap items-center gap-2 text-sm\">\n <Badge tone=\"success\">{enumLabel(t, 'trust', run.initialTrustLevel)}</Badge>\n {run.trustLevel !== run.initialTrustLevel && (\n <>\n →<Badge tone=\"warning\">{enumLabel(t, 'trust', run.trustLevel)}</Badge>\n </>\n )}\n </p>\n <p className=\"mt-1 text-xs text-(color:--color-text-secondary)\">\n {drop ? `${t('stewards.run.trustDegraded')} · #${drop.seq}` : t('stewards.run.trustSame')}\n </p>\n </Card>\n <Card title={t('stewards.run.budgetTitle')}>\n <UsageFigure used={credits.toFixed(2)} cap={runCap} />\n <ProgressBar ratio={budgetRatio(credits, runCap)} label={t('stewards.run.budgetTitle')} />\n </Card>\n <Card title={t('stewards.run.stepsTitle')}>\n <UsageFigure used={run.stepCount} cap={stepCap} />\n <ProgressBar\n ratio={budgetRatio(run.stepCount, stepCap)}\n label={t('stewards.run.stepsTitle')}\n />\n </Card>\n <Card title={t('stewards.run.verdictsTitle')}>\n <p className=\"text-2xl font-semibold text-(color:--color-text-primary) tabular-nums\">\n {verdicts.allowed} · {verdicts.asked} · {verdicts.denied}\n </p>\n <p className=\"text-xs text-(color:--color-text-secondary)\">\n {t('stew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AC,EAAUX,GAAG,SAASG,EAAI,UAAU;KAAS,CAAA,CACrE,EAAA,CAAA,CAEH;IACH,CAAA,GAAA,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAC,IAAO,GAAGJ,EAAE,4BAA4B,EAAE,MAAMI,EAAK,QAAQJ,EAAE,wBAAwB;IACvF,CAAA,CACC;;GACN,kBAACS,GAAD;IAAM,OAAOT,EAAE,0BAA0B;IAAzC,UAAA,CACE,kBAACJ,GAAD;KAAa,MAAMY,EAAQ,QAAQ,CAAC;KAAG,KAAKH;IAAS,CAAA,GACrD,kBAACQ,GAAD;KAAa,OAAOC,EAAYN,GAASH,CAAM;KAAG,OAAOL,EAAE,0BAA0B;IAAI,CAAA,CACrF;;GACN,kBAACS,GAAD;IAAM,OAAOT,EAAE,yBAAyB;IAAxC,UAAA,CACE,kBAACJ,GAAD;KAAa,MAAMO,EAAI;KAAW,KAAKI;IAAU,CAAA,GACjD,kBAACM,GAAD;KACE,OAAOC,EAAYX,EAAI,WAAWI,CAAO;KACzC,OAAOP,EAAE,yBAAyB;IACnC,CAAA,CACG;;GACN,kBAACS,GAAD;IAAM,OAAOT,EAAE,4BAA4B;IAA3C,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGE,EAAS;MAAQ;MAAIA,EAAS;MAAM;MAAIA,EAAS;KACjD;IACH,CAAA,GAAA,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAF,EAAE,6BAA6B;IAC/B,CAAA,CACC;;EACH;;AAET"}
@@ -0,0 +1,6 @@
1
+ import { StewardRunDetailFieldsFragment } from '../../../generated/wspace-operations';
2
+ export type RunStep = StewardRunDetailFieldsFragment['steps'][number];
3
+ export declare function StepDetail({ step, timeZone }: {
4
+ step: RunStep;
5
+ timeZone: string;
6
+ }): import('react').JSX.Element;
@@ -0,0 +1,126 @@
1
+ import { useGetStewardStepScreenshotUrlQuery as e } from "../../../generated/wspace-operations.js";
2
+ import { VERDICT_TONE as t, enumLabel as n } from "../stewardLabels.js";
3
+ import { Alert as r, Badge as i } from "../ui.js";
4
+ import { useStewardsT as a } from "../../i18n/useStewardsT.js";
5
+ import { clockTime as o } from "../../utils/dates.js";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ import { useState as l } from "react";
8
+ // src/stewards/components/run/StepDetail.tsx
9
+ var u = 900;
10
+ function d({ fileId: t }) {
11
+ let n = a(), [i, o] = l(!1), { data: d, loading: f, error: p } = e({
12
+ variables: {
13
+ id: t,
14
+ expiresIn: u
15
+ },
16
+ fetchPolicy: "network-only"
17
+ }), m = d?.getFileDownloadUrl;
18
+ return f ? /* @__PURE__ */ s("p", {
19
+ className: "text-xs text-(color:--color-text-secondary)",
20
+ children: n("stewards.common.loading")
21
+ }) : p || !m || i ? /* @__PURE__ */ c(r, { children: [
22
+ n("stewards.run.screenshotError"),
23
+ " ",
24
+ n("stewards.run.screenshotRef", { id: t })
25
+ ] }) : /* @__PURE__ */ s("img", {
26
+ src: m,
27
+ alt: n("stewards.run.screenshotAlt"),
28
+ loading: "lazy",
29
+ className: "max-h-96 w-full rounded-md border border-(color:--color-border-seam) object-contain",
30
+ onError: () => o(!0)
31
+ });
32
+ }
33
+ function f({ step: e, timeZone: r }) {
34
+ let l = a(), u = e.argumentsRedacted, f = typeof u == "object" && !!u && Object.keys(u).length > 0;
35
+ return /* @__PURE__ */ c("div", {
36
+ className: "grid grid-cols-1 gap-4 xl:grid-cols-2",
37
+ children: [/* @__PURE__ */ c("div", {
38
+ className: "flex flex-col gap-3",
39
+ children: [
40
+ /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h3", {
41
+ className: "mb-1 text-xs font-medium text-(color:--color-text-secondary)",
42
+ children: l("stewards.run.arguments")
43
+ }), /* @__PURE__ */ s("pre", {
44
+ className: "max-h-64 overflow-auto rounded-md bg-(--color-bg-sunken) p-3 text-xs text-(color:--color-text-primary)",
45
+ children: f ? JSON.stringify(u, null, 2) : l("stewards.run.noArguments")
46
+ })] }),
47
+ e.resultSummary && /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h3", {
48
+ className: "mb-1 text-xs font-medium text-(color:--color-text-secondary)",
49
+ children: l("stewards.run.result")
50
+ }), /* @__PURE__ */ s("p", {
51
+ className: "whitespace-pre-wrap rounded-md bg-(--color-bg-sunken) p-3 text-sm text-(color:--color-text-primary)",
52
+ children: e.resultSummary
53
+ })] }),
54
+ /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h3", {
55
+ className: "mb-1 text-xs font-medium text-(color:--color-text-secondary)",
56
+ children: l("stewards.run.screenshot")
57
+ }), e.screenshotFileId ? /* @__PURE__ */ s(d, { fileId: e.screenshotFileId }, e.screenshotFileId) : /* @__PURE__ */ s("div", {
58
+ className: "rounded-md border border-dashed border-(color:--color-border-seam) p-4 text-center text-xs text-(color:--color-text-secondary)",
59
+ children: l("stewards.run.screenshotNone")
60
+ })] })
61
+ ]
62
+ }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h3", {
63
+ className: "mb-1 text-xs font-medium text-(color:--color-text-secondary)",
64
+ children: l("stewards.run.trail")
65
+ }), /* @__PURE__ */ c("ol", {
66
+ className: "flex flex-col gap-2 text-sm text-(color:--color-text-primary)",
67
+ children: [
68
+ /* @__PURE__ */ c("li", { children: [
69
+ l("stewards.run.trailVerdict"),
70
+ ":",
71
+ " ",
72
+ /* @__PURE__ */ s(i, {
73
+ tone: t[e.verdict],
74
+ children: n(l, "verdict", e.verdict)
75
+ })
76
+ ] }),
77
+ e.classification && /* @__PURE__ */ c("li", { children: [
78
+ l("stewards.run.trailClassification"),
79
+ ": ",
80
+ e.classification
81
+ ] }),
82
+ /* @__PURE__ */ c("li", { children: [
83
+ l("stewards.run.trailTrust"),
84
+ ": ",
85
+ n(l, "trust", e.trustLevelBefore),
86
+ " →",
87
+ " ",
88
+ n(l, "trust", e.trustLevelAfter)
89
+ ] }),
90
+ e.verdictReasons.length > 0 && /* @__PURE__ */ c("li", { children: [
91
+ l("stewards.run.trailReasons"),
92
+ ":",
93
+ /* @__PURE__ */ s("ul", {
94
+ className: "ml-4 list-disc text-(color:--color-text-secondary)",
95
+ children: e.verdictReasons.map((e) => /* @__PURE__ */ s("li", { children: e }, e))
96
+ })
97
+ ] }),
98
+ e.approvalRequestId && /* @__PURE__ */ s("li", { children: l("stewards.run.trailApproval", { id: e.approvalRequestId }) }),
99
+ e.approvalRuleId && /* @__PURE__ */ s("li", { children: l("stewards.run.trailRule", { id: e.approvalRuleId }) }),
100
+ e.dryRun && /* @__PURE__ */ s("li", {
101
+ className: "text-(color:--color-text-secondary)",
102
+ children: l("stewards.run.trailDryRun")
103
+ }),
104
+ /* @__PURE__ */ c("li", {
105
+ className: "text-(color:--color-text-secondary)",
106
+ children: [
107
+ l("stewards.run.cost"),
108
+ ": ",
109
+ e.creditsUsed.toFixed(2),
110
+ " ·",
111
+ " ",
112
+ l("stewards.run.deskSeconds"),
113
+ ": ",
114
+ e.deskSeconds,
115
+ "s ·",
116
+ " ",
117
+ o(e.startedAt, r)
118
+ ]
119
+ })
120
+ ]
121
+ })] })]
122
+ });
123
+ }
124
+ export { f as StepDetail };
125
+
126
+ //# sourceMappingURL=StepDetail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepDetail.js","names":["SCREENSHOT_TTL_SECONDS","StepScreenshot","t","useStewardsT","broken","setBroken","useState","useGetStewardStepScreenshotUrlQuery","fileId","url","data","loading","error","Alert","StepDetail","args","step","hasArgs","Badge","VERDICT_TONE","enumLabel","r","clockTime","timeZone"],"sources":["../../../../src/stewards/components/run/StepDetail.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n useGetStewardStepScreenshotUrlQuery,\n type StewardRunDetailFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { enumLabel, VERDICT_TONE } from '../stewardLabels';\nimport { Alert, Badge } from '../ui';\nimport { useStewardsT } from '../../i18n/useStewardsT';\nimport { clockTime } from '../../utils/dates';\n\nexport type RunStep = StewardRunDetailFieldsFragment['steps'][number];\n\nconst SCREENSHOT_TTL_SECONDS = 900;\n\n/** Fetches a short-lived download URL for the step's desk screenshot and shows it. */\nfunction StepScreenshot({ fileId }: { fileId: string }) {\n const t = useStewardsT();\n const [broken, setBroken] = useState(false);\n const { data, loading, error } = useGetStewardStepScreenshotUrlQuery({\n variables: { id: fileId, expiresIn: SCREENSHOT_TTL_SECONDS },\n fetchPolicy: 'network-only',\n });\n const url = data?.getFileDownloadUrl;\n if (loading) {\n return (\n <p className=\"text-xs text-(color:--color-text-secondary)\">{t('stewards.common.loading')}</p>\n );\n }\n if (error || !url || broken) {\n return (\n <Alert>\n {t('stewards.run.screenshotError')} {t('stewards.run.screenshotRef', { id: fileId })}\n </Alert>\n );\n }\n return (\n <img\n src={url}\n alt={t('stewards.run.screenshotAlt')}\n loading=\"lazy\"\n className=\"max-h-96 w-full rounded-md border border-(color:--color-border-seam) object-contain\"\n onError={() => setBroken(true)}\n />\n );\n}\n\nexport function StepDetail({ step, timeZone }: { step: RunStep; timeZone: string }) {\n const t = useStewardsT();\n const args = step.argumentsRedacted;\n const hasArgs = args !== null && typeof args === 'object' && Object.keys(args).length > 0;\n return (\n <div className=\"grid grid-cols-1 gap-4 xl:grid-cols-2\">\n <div className=\"flex flex-col gap-3\">\n <div>\n <h3 className=\"mb-1 text-xs font-medium text-(color:--color-text-secondary)\">\n {t('stewards.run.arguments')}\n </h3>\n <pre className=\"max-h-64 overflow-auto rounded-md bg-(--color-bg-sunken) p-3 text-xs text-(color:--color-text-primary)\">\n {hasArgs ? JSON.stringify(args, null, 2) : t('stewards.run.noArguments')}\n </pre>\n </div>\n {step.resultSummary && (\n <div>\n <h3 className=\"mb-1 text-xs font-medium text-(color:--color-text-secondary)\">\n {t('stewards.run.result')}\n </h3>\n <p className=\"whitespace-pre-wrap rounded-md bg-(--color-bg-sunken) p-3 text-sm text-(color:--color-text-primary)\">\n {step.resultSummary}\n </p>\n </div>\n )}\n <div>\n <h3 className=\"mb-1 text-xs font-medium text-(color:--color-text-secondary)\">\n {t('stewards.run.screenshot')}\n </h3>\n {step.screenshotFileId ? (\n <StepScreenshot key={step.screenshotFileId} fileId={step.screenshotFileId} />\n ) : (\n <div className=\"rounded-md border border-dashed border-(color:--color-border-seam) p-4 text-center text-xs text-(color:--color-text-secondary)\">\n {t('stewards.run.screenshotNone')}\n </div>\n )}\n </div>\n </div>\n <div>\n <h3 className=\"mb-1 text-xs font-medium text-(color:--color-text-secondary)\">\n {t('stewards.run.trail')}\n </h3>\n <ol className=\"flex flex-col gap-2 text-sm text-(color:--color-text-primary)\">\n <li>\n {t('stewards.run.trailVerdict')}:{' '}\n <Badge tone={VERDICT_TONE[step.verdict]}>{enumLabel(t, 'verdict', step.verdict)}</Badge>\n </li>\n {step.classification && (\n <li>\n {t('stewards.run.trailClassification')}: {step.classification}\n </li>\n )}\n <li>\n {t('stewards.run.trailTrust')}: {enumLabel(t, 'trust', step.trustLevelBefore)} →{' '}\n {enumLabel(t, 'trust', step.trustLevelAfter)}\n </li>\n {step.verdictReasons.length > 0 && (\n <li>\n {t('stewards.run.trailReasons')}:\n <ul className=\"ml-4 list-disc text-(color:--color-text-secondary)\">\n {step.verdictReasons.map((r) => (\n <li key={r}>{r}</li>\n ))}\n </ul>\n </li>\n )}\n {step.approvalRequestId && (\n <li>{t('stewards.run.trailApproval', { id: step.approvalRequestId })}</li>\n )}\n {step.approvalRuleId && (\n <li>{t('stewards.run.trailRule', { id: step.approvalRuleId })}</li>\n )}\n {step.dryRun && (\n <li className=\"text-(color:--color-text-secondary)\">{t('stewards.run.trailDryRun')}</li>\n )}\n <li className=\"text-(color:--color-text-secondary)\">\n {t('stewards.run.cost')}: {step.creditsUsed.toFixed(2)} ·{' '}\n {t('stewards.run.deskSeconds')}: {step.deskSeconds}s ·{' '}\n {clockTime(step.startedAt, timeZone)}\n </li>\n </ol>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAYA,IAAMA,IAAyB;AAG/B,SAASC,EAAe,EAAE,a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EAAM,CAAA;IAE1EA,EAAK,kBACJ,kBAAC,MAAD,EAAA,UAAKd,EAAE,0BAA0B,EAAE,IAAIc,EAAK,eAAe,CAAC,EAAM,CAAA;IAEnEA,EAAK,UACJ,kBAAC,MAAD;KAAI,WAAU;KAAuC,UAAAd,EAAE,0BAA0B;IAAM,CAAA;IAEzF,kBAAC,MAAD;KAAI,WAAU;KAAd,UAAA;MACGA,EAAE,mBAAmB;MAAE;MAAGc,EAAK,YAAY,QAAQ,CAAC;MAAE;MAAG;MACzDd,EAAE,0BAA0B;MAAE;MAAGc,EAAK;MAAY;MAAI;MACtDM,EAAUN,EAAK,WAAWO,CAAQ;KACjC;;GACF;EACD,CAAA,CAAA,EAAA,CAAA,CACF;;AAET"}
@@ -13,5 +13,10 @@ export interface DeskStream {
13
13
  }
14
14
  /**
15
15
  * Thin React binding over `DeskStreamConnection`: one connection per run, closed on unmount.
16
+ *
17
+ * `wanted` is the mode the caller wants the stream in, or `null` for no stream. The hook keeps
18
+ * the connection in step with it, so a mode change (control changing hands) reconnects in the
19
+ * new mode and `null` disconnects. `start` stays available for an explicit reconnect after the
20
+ * stream ended or failed while `wanted` did not change.
16
21
  */
17
- export declare function useDeskStream(runId: string): DeskStream;
22
+ export declare function useDeskStream(runId: string, wanted?: StreamMode | null): DeskStream;
@@ -4,20 +4,22 @@ import { useEffect as n, useMemo as r, useSyncExternalStore as i } from "react";
4
4
  import { useApolloClient as a } from "@apollo/client/react";
5
5
  import { useAuthTokenOrNull as o } from "@burdenoff/fe-libs/shared/providers/shell";
6
6
  // src/stewards/live/useDeskStream.ts
7
- function s(s) {
8
- let c = a(), l = o(), u = r(() => e(c, s), [c, s]);
7
+ function s(s, c = null) {
8
+ let l = a(), u = o(), d = r(() => e(l, s), [l, s]);
9
9
  n(() => {
10
- u.setSession(l);
11
- }, [u, l]), n(() => () => u.connection.stop(), [u]);
12
- let { connection: d } = u;
13
- return {
14
- state: i(d.subscribe, d.getState, () => t),
10
+ d.setSession(u);
11
+ }, [d, u]), n(() => () => d.connection.stop(), [d]);
12
+ let { connection: f } = d;
13
+ return n(() => {
14
+ c ? f.start(c) : f.stop();
15
+ }, [f, c]), {
16
+ state: i(f.subscribe, f.getState, () => t),
15
17
  ...r(() => ({
16
- start: (e) => d.start(e),
17
- stop: () => d.stop(),
18
- send: (e) => d.send(e),
19
- setFrameSink: u.setFrameSink
20
- }), [d, u])
18
+ start: (e) => f.start(e),
19
+ stop: () => f.stop(),
20
+ send: (e) => f.send(e),
21
+ setFrameSink: d.setFrameSink
22
+ }), [f, d])
21
23
  };
22
24
  }
23
25
  export { s as useDeskStream };
@@ -1 +1 @@
1
- {"version":3,"file":"useDeskStream.js","names":["useDeskStream","client","useApolloClient","auth","useAuthTokenOrNull","bundle","useMemo","createBrowserConnection","runId","useEffect","useSyncExternalStore","connection","INITIAL_STREAM_STATE","mode","frame"],"sources":["../../../src/stewards/live/useDeskStream.ts"],"sourcesContent":["import { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useAuthTokenOrNull } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { createBrowserConnection, type FrameSink } from './browserConnection';\nimport { INITIAL_STREAM_STATE, type StreamState } from './DeskStreamConnection';\nimport type { StreamMode } from './protocol';\n\nexport type { FrameSink };\n\nexport interface DeskStream {\n state: StreamState;\n start: (mode: StreamMode) => void;\n stop: () => void;\n /** Write one input frame; false when the stream is not live control. */\n send: (frame: string) => boolean;\n /** Where desk frames go (the canvas). Frames are not kept in React state. */\n setFrameSink: (sink: FrameSink | null) => void;\n}\n\n/**\n * Thin React binding over `DeskStreamConnection`: one connection per run, closed on unmount.\n */\nexport function useDeskStream(runId: string): DeskStream {\n const client = useApolloClient();\n const auth = useAuthTokenOrNull();\n const bundle = useMemo(() => createBrowserConnection(client, runId), [client, runId]);\n\n useEffect(() => {\n bundle.setSession(auth);\n }, [bundle, auth]);\n useEffect(() => () => bundle.connection.stop(), [bundle]);\n\n const { connection } = bundle;\n const state = useSyncExternalStore(\n connection.subscribe,\n connection.getState,\n () => INITIAL_STREAM_STATE\n );\n // Stable identities: the panel's connect effect depends on `start` and `stop`.\n const actions = useMemo(\n () => ({\n start: (mode: StreamMode) => connection.start(mode),\n stop: () => connection.stop(),\n send: (frame: string) => connection.send(frame),\n setFrameSink: bundle.setFrameSink,\n }),\n [connection, bundle]\n );\n return { state, ...actions };\n}\n"],"mappings":";;;;;;AAsBA,SAAgBA,EAAc,GAA2B;CACvD,IAAMC,IAASC,EAAgB,GACzBC,IAAOC,EAAmB,GAC1BC,IAASC,QAAcC,EAAwBN,GAAQO,CAAK,GAAG,CAACP,GAAQO,CAAK,CAAC;CAKpF,AAHAC,QAAgB;EACd,EAAO,WAAWN,CAAI;CACxB,GAAG,CAACE,GAAQF,CAAI,CAAC,GACjBM,cAAsBJ,EAAO,WAAW,KAAK,GAAG,CAACA,CAAM,CAAC;CAExD,IAAM,EAAE,kBAAeA;CAgBvB,OAAO;EAAE,OAfKK,EACZC,EAAW,WACXA,EAAW,gBACLC,CAYC;EAAO,GATAN,SACP;GACL,QAAQ,MAAqBK,EAAW,MAAME,CAAI;GAClD,YAAYF,EAAW,KAAK;GAC5B,OAAO,MAAkBA,EAAW,KAAKG,CAAK;GAC9C,cAAcT,EAAO;EACvB,IACA,CAACM,GAAYN,CAAM,CAEF;CAAQ;AAC7B"}
1
+ {"version":3,"file":"useDeskStream.js","names":["useDeskStream","client","useApolloClient","auth","useAuthTokenOrNull","bundle","useMemo","createBrowserConnection","runId","useEffect","wanted","connection","useSyncExternalStore","INITIAL_STREAM_STATE","mode","frame"],"sources":["../../../src/stewards/live/useDeskStream.ts"],"sourcesContent":["import { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useAuthTokenOrNull } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { createBrowserConnection, type FrameSink } from './browserConnection';\nimport { INITIAL_STREAM_STATE, type StreamState } from './DeskStreamConnection';\nimport type { StreamMode } from './protocol';\n\nexport type { FrameSink };\n\nexport interface DeskStream {\n state: StreamState;\n start: (mode: StreamMode) => void;\n stop: () => void;\n /** Write one input frame; false when the stream is not live control. */\n send: (frame: string) => boolean;\n /** Where desk frames go (the canvas). Frames are not kept in React state. */\n setFrameSink: (sink: FrameSink | null) => void;\n}\n\n/**\n * Thin React binding over `DeskStreamConnection`: one connection per run, closed on unmount.\n *\n * `wanted` is the mode the caller wants the stream in, or `null` for no stream. The hook keeps\n * the connection in step with it, so a mode change (control changing hands) reconnects in the\n * new mode and `null` disconnects. `start` stays available for an explicit reconnect after the\n * stream ended or failed while `wanted` did not change.\n */\nexport function useDeskStream(runId: string, wanted: StreamMode | null = null): DeskStream {\n const client = useApolloClient();\n const auth = useAuthTokenOrNull();\n const bundle = useMemo(() => createBrowserConnection(client, runId), [client, runId]);\n\n useEffect(() => {\n bundle.setSession(auth);\n }, [bundle, auth]);\n useEffect(() => () => bundle.connection.stop(), [bundle]);\n\n const { connection } = bundle;\n useEffect(() => {\n if (wanted) connection.start(wanted);\n else connection.stop();\n }, [connection, wanted]);\n\n const state = useSyncExternalStore(\n connection.subscribe,\n connection.getState,\n () => INITIAL_STREAM_STATE\n );\n // Stable identities, so callers can pass them to memoised children.\n const actions = useMemo(\n () => ({\n start: (mode: StreamMode) => connection.start(mode),\n stop: () => connection.stop(),\n send: (frame: string) => connection.send(frame),\n setFrameSink: bundle.setFrameSink,\n }),\n [connection, bundle]\n );\n return { state, ...actions };\n}\n"],"mappings":";;;;;;AA2BA,SAAgBA,EAAc,GAAe,IAA4B,MAAkB;CACzF,IAAMC,IAASC,EAAgB,GACzBC,IAAOC,EAAmB,GAC1BC,IAASC,QAAcC,EAAwBN,GAAQO,CAAK,GAAG,CAACP,GAAQO,CAAK,CAAC;CAKpF,AAHAC,QAAgB;EACd,EAAO,WAAWN,CAAI;CACxB,GAAG,CAACE,GAAQF,CAAI,CAAC,GACjBM,cAAsBJ,EAAO,WAAW,KAAK,GAAG,CAACA,CAAM,CAAC;CAExD,IAAM,EAAE,kBAAeA;CAqBvB,OApBAI,QAAgB;EACd,AAAIC,IAAQC,EAAW,MAAMD,CAAM,IAC9BC,EAAW,KAAK;CACvB,GAAG,CAACA,GAAYD,CAAM,CAAC,GAiBhB;EAAE,OAfKE,EACZD,EAAW,WACXA,EAAW,gBACLE,CAYC;EAAO,GATAP,SACP;GACL,QAAQ,MAAqBK,EAAW,MAAMG,CAAI;GAClD,YAAYH,EAAW,KAAK;GAC5B,OAAO,MAAkBA,EAAW,KAAKI,CAAK;GAC9C,cAAcV,EAAO;EACvB,IACA,CAACM,GAAYN,CAAM,CAEF;CAAQ;AAC7B"}