Skip to content
Open
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
27 changes: 21 additions & 6 deletions plugins/automations/detail-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import {
} from "./lib/model-label";
import { AutomationProviderIcon } from "./lib/provider-icon";
import { AutomationMetadataItem } from "./metadata";
import {
formatRunDomainLabel,
formatRunTransportLabel,
} from "./src/run-summary";

export interface AutomationRunsViewState {
runs: readonly AutomationRunResponse[];
Expand Down Expand Up @@ -505,17 +509,17 @@ export const AUTOMATION_RUN_STATUS_VISUALS: Record<
}
> = {
running: {
label: "Running",
label: "transport=running",
icon: "Loading",
className: "animate-spin text-muted-foreground",
},
failed: {
label: "Failed",
label: "transport=failed",
icon: "CircleX",
className: "text-destructive",
},
skipped: {
label: "Skipped",
label: "transport=skipped",
// Not CircleDashed: icon.tsx aliases it to the same DashedLineCircleIcon as
// Spinner, so a skipped run rendered an identical shape to a running one.
// ArrowTurnForward is the only glyph in the map that reads as "passed
Expand All @@ -524,7 +528,7 @@ export const AUTOMATION_RUN_STATUS_VISUALS: Record<
className: "text-subtle-foreground",
},
succeeded: {
label: "Succeeded",
label: "transport=succeeded",
icon: "CircleCheck",
className: "text-success",
},
Expand Down Expand Up @@ -567,6 +571,8 @@ function RunRow({
run.runMode === "script" &&
(run.output !== null || run.error !== null || silent);
const visual = AUTOMATION_RUN_STATUS_VISUALS[run.status];
const transportLabel = formatRunTransportLabel(run.status);
const domainLabel = formatRunDomainLabel(run.terminalToken);
const running = run.status === "running";
const openable = run.runMode === "agent" && run.threadId !== null;
// The whole row is the affordance when there is a thread, so the destination
Expand Down Expand Up @@ -619,9 +625,18 @@ function RunRow({
: "text-subtle-foreground",
)}
>
{running ? `${visual.label}\u2026` : (duration ?? "")}
{run.skipReason ? `${duration ? " · " : ""}${run.skipReason}` : ""}
{running ? `${transportLabel}\u2026` : transportLabel}
{duration ? ` · ${duration}` : ""}
{run.skipReason ? ` · ${run.skipReason}` : ""}
</span>
{domainLabel ? (
<span
aria-label={domainLabel}
className="max-w-40 shrink-0 truncate rounded-full bg-surface-recessed/70 px-2 py-0.5 font-mono text-xs text-muted-foreground"
>
{domainLabel}
</span>
) : null}
{openable ? (
<Icon
name="ChevronRight"
Expand Down
6 changes: 3 additions & 3 deletions plugins/automations/src/automations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import { sweepDueAutomations } from "./sweep.js";
import { createAutomationService } from "./service.js";
import { automationScriptDir } from "./script-files.js";

function createTestDb(): Db {
function createTestDb(includeRunMigration = true): Db {
const db = new Database(":memory:");
db.exec(migrations[0] ?? "");
db.exec(includeRunMigration ? migrations.join("\n") : (migrations[0] ?? ""));
return db;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ function createAutomationServiceBb() {

describe("data migrations", () => {
it("migrates stored agent automations to current permission modes", () => {
const db = createTestDb();
const db = createTestDb(false);
const insert = db.prepare(
`INSERT INTO automations (
id, project_id, name, enabled, trigger_type, trigger_config,
Expand Down
9 changes: 7 additions & 2 deletions plugins/automations/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
AUTOMATION_SCRIPT_TIMEOUT_DEFAULT_MS,
automationScriptInterpreterSchema,
} from "./rpc-types.js";
import {
formatRunDomainLabel,
formatRunTransportLabel,
} from "./run-summary.js";

const DURATION_PATTERN =
/^(\d+)\s*(s|sec|secs|second|seconds|m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)$/iu;
Expand Down Expand Up @@ -523,10 +527,11 @@ function printAutomationTable(automations: AutomationResponse[]): string {

function printRunTable(runs: AutomationRunResponse[]): string {
return table(
["ID", "Status", "Started", "Thread/Exit", "Detail"],
["ID", "Transport", "Domain", "Started", "Thread/Exit", "Detail"],
runs.map((run) => [
run.id,
run.status,
formatRunTransportLabel(run.status),
formatRunDomainLabel(run.terminalToken) ?? "-",
formatTimestamp(run.startedAt),
run.threadId ?? (run.exitCode === null ? "-" : `exit ${run.exitCode}`),
run.skipReason ?? run.error ?? "-",
Expand Down
Loading
Loading