Skip to content

🙌 OpenHands: AI-Driven Development

fix(automations): render the shipped current_phase on live runs (#17122)

Artem Altukhov1508fcf26951
diff --git a/__tests__/components/automations/automation-card.test.tsx b/__tests__/components/automations/automation-card.test.tsx
index af093b0017..cdaefeb020 100644
--- a/__tests__/components/automations/automation-card.test.tsx
+++ b/__tests__/components/automations/automation-card.test.tsx
@@ -363,9 +363,7 @@ describe("AutomationCard — run phase", () => {
conversation_id: null,
bash_command_id: null,
error_detail: null,
- phase_code: "running_agent",
- phase_label: null,
- phase_updated_at: null,
+ current_phase: "Agent is working on the task",
started_at: "2026-01-01T09:00:00Z",
completed_at: null,
},
@@ -379,7 +377,7 @@ describe("AutomationCard — run phase", () => {
renderHarness();
// Assert: the phase renders ...
- await screen.findByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT);
+ await screen.findByText("Agent is working on the task");
// ... and exactly one request was made — the pre-existing insights
// fetch, not a new one just for the phase.
expect(callCount).toBe(1);
diff --git a/__tests__/components/automations/detail/activity-log-item.test.tsx b/__tests__/components/automations/detail/activity-log-item.test.tsx
index 4ba16efe48..4484a7f6b3 100644
--- a/__tests__/components/automations/detail/activity-log-item.test.tsx
+++ b/__tests__/components/automations/detail/activity-log-item.test.tsx
@@ -358,45 +358,31 @@ describe("ActivityLogItem — run phase", () => {
__resetActiveStoreForTests();
});
- it("shows the phase as the place of failure for a FAILED run", () => {
- // Arrange: the run failed after reaching sandbox_provisioning — a code
- // known to the frontend, so it renders translated (raw key in tests).
+ it("shows the current_phase as the place of failure for a FAILED run", () => {
const run = makeRun({
status: AutomationRunStatus.FAILED,
conversation_id: null,
bash_command_id: null,
- phase_code: "sandbox_provisioning",
- phase_label: null,
- phase_updated_at: "2026-01-01T10:01:30Z",
+ current_phase: "Installing dependencies",
});
- // Act
renderItem(run);
- // Assert
- expect(
- screen.getByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_SANDBOX_PROVISIONING),
- ).toBeInTheDocument();
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(
+ "Installing dependencies",
+ );
});
it("does not display the phase for a COMPLETED run, even though it was saved", () => {
- // Arrange: the run completed, but a phase was recorded along the way.
const run = makeRun({
status: AutomationRunStatus.COMPLETED,
- phase_code: "running_agent",
- phase_label: null,
- phase_updated_at: "2026-01-01T10:01:30Z",
+ current_phase: "Agent is working on the task",
});
- // Act
renderItem(run);
- // Assert: the field exists on the run (saved), but nothing renders it.
- expect(run.phase_code).toBe("running_agent");
+ expect(run.current_phase).toBe("Agent is working on the task");
expect(screen.queryByTestId("run-phase")).not.toBeInTheDocument();
- expect(
- screen.queryByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT),
- ).not.toBeInTheDocument();
});
});
@@ -413,17 +399,15 @@ describe("ActivityLogItem — run phase absent entirely", () => {
});
it("renders a RUNNING row unchanged, without console errors, when the automation service omits phase fields entirely", () => {
- // Arrange: an older automation service response — no phase_code,
- // phase_label or phase_updated_at keys at all (not even null).
+ // Arrange: an older automation service response — no current_phase key
+ // at all (not even null).
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
const run = makeRun({
status: AutomationRunStatus.RUNNING,
completed_at: null,
});
- delete (run as Partial<AutomationRun>).phase_code;
- delete (run as Partial<AutomationRun>).phase_label;
- delete (run as Partial<AutomationRun>).phase_updated_at;
+ delete (run as Partial<AutomationRun>).current_phase;
// Act
expect(() => renderItem(run)).not.toThrow();
@@ -450,7 +434,7 @@ describe("ActivityLogItem — run phase updates without reload", () => {
__resetActiveStoreForTests();
});
- it("reflects a new phase_code from a prop update (as a poll refetch would produce), with no remount needed", () => {
+ it("reflects a new current_phase from a prop update (as a poll refetch would produce), with no remount needed", () => {
// Arrange
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
@@ -467,31 +451,27 @@ describe("ActivityLogItem — run phase updates without reload", () => {
const runningRun = makeRun({
status: AutomationRunStatus.RUNNING,
completed_at: null,
- phase_code: "queued",
- phase_label: null,
+ current_phase: "Preparing environment",
});
const { rerender } = render(buildTree(runningRun));
- expect(
- screen.getByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_QUEUED),
- ).toBeInTheDocument();
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(
+ "Preparing environment",
+ );
// Act: same run id, new phase — what the 3s poll in
// useAutomationRuns would hand down as a new `run` prop.
rerender(
buildTree({
...runningRun,
- phase_code: "running_agent",
- phase_label: null,
+ current_phase: "Agent is working on the task",
}),
);
// Assert: the new phase is shown, the old one is gone — no reload.
- expect(
- screen.getByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT),
- ).toBeInTheDocument();
- expect(
- screen.queryByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_QUEUED),
- ).not.toBeInTheDocument();
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(
+ "Agent is working on the task",
+ );
+ expect(screen.queryByText("Preparing environment")).not.toBeInTheDocument();
});
});
@@ -506,13 +486,12 @@ describe("ActivityLogItem — run phase (badge still shown)", () => {
__resetActiveStoreForTests();
});
- it("shows only the existing status badge (not merely 'no phase') for an active run whose phase is blank on both fields", () => {
+ it("shows only the existing status badge (not merely 'no phase') for an active run whose phase is blank", () => {
// Arrange
const run = makeRun({
status: AutomationRunStatus.RUNNING,
completed_at: null,
- phase_code: null,
- phase_label: "",
+ current_phase: "",
});
// Act
@@ -526,21 +505,18 @@ describe("ActivityLogItem — run phase (badge still shown)", () => {
).toBeInTheDocument();
});
- it("keeps the status badge beside a phase reported as a bare code", () => {
- // Arrange: the service accepts `{"code": "custom_step"}` with no label.
+ it("keeps the status badge beside a reported current_phase", () => {
const run = makeRun({
status: AutomationRunStatus.RUNNING,
completed_at: null,
- phase_code: "custom_step",
- phase_label: "",
+ current_phase: "Checking out the branch",
});
- // Act
renderItem(run);
- // Assert: the phase reaches the row, and it is added to the badge rather
- // than replacing it.
- expect(screen.getByTestId("run-phase")).toHaveTextContent("custom_step");
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(
+ "Checking out the branch",
+ );
expect(
screen.getByText(I18nKey.AUTOMATIONS$DETAIL$RUNNING),
).toBeInTheDocument();
@@ -562,25 +538,17 @@ describe("ActivityLogItem — run phase hidden for CANCELLED/SKIPPED", () => {
[AutomationRunStatus.CANCELLED, I18nKey.AUTOMATIONS$DETAIL$CANCELLED],
[AutomationRunStatus.SKIPPED, I18nKey.AUTOMATIONS$DETAIL$SKIPPED],
])(
- "does not show the phase for a %s run, even with a known phase_code on record",
+ "does not show the phase for a %s run, even with a current_phase on record",
(status, badgeKey) => {
- // Arrange
const run = makeRun({
status,
- phase_code: "running_agent",
- phase_label: null,
+ current_phase: "Agent is working on the task",
completed_at: "2026-01-01T10:02:00Z",
});
- // Act
renderItem(run);
- // Assert: phase hidden, but the status badge for this terminal
- // status is still shown.
expect(screen.queryByTestId("run-phase")).not.toBeInTheDocument();
- expect(
- screen.queryByText(I18nKey.AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT),
- ).not.toBeInTheDocument();
expect(screen.getByText(badgeKey)).toBeInTheDocument();
},
);
diff --git a/__tests__/components/automations/detail/run-phase.test.tsx b/__tests__/components/automations/detail/run-phase.test.tsx
index 309df937c5..7c3aeca488 100644
--- a/__tests__/components/automations/detail/run-phase.test.tsx
+++ b/__tests__/components/automations/detail/run-phase.test.tsx
@@ -2,96 +2,37 @@ import { describe, it, expect, vi, afterEach } from "vitest";
import { render, screen } from "@testing-library/react";
import {
- formatRunPhaseAge,
resolveRunPhaseText,
RunPhase,
} from "#/components/features/automations/detail/run-phase";
-import { I18nKey } from "#/i18n/declaration";
-// Source of truth for translated values — not a hand-maintained duplicate.
-import translationData from "#/i18n/translation.json";
-import { AutomationRunStatus } from "#/types/automation";
-import { formatRelativeTime } from "#/utils/format-relative-time";
-type TranslationEntry = Record<string, string>;
-const TRANSLATIONS = translationData as unknown as Record<
- string,
- TranslationEntry
->;
+describe("RunPhase — current_phase", () => {
+ it("shows the user-facing string as-is", () => {
+ render(<RunPhase currentPhase="Examining the diff" />);
-// `t()` is mocked to resolve against the real translation.json content for
-// French ("fr"), the same pattern used elsewhere in this repo (see
-// server-status.test.tsx) to assert on genuine translated copy rather than
-// the ambient test i18n backend, which never resolves real values.
-function translate(key: string, options?: Record<string, unknown>): string {
- const value = TRANSLATIONS[key]?.fr ?? key;
- if (!options) return value;
- // Interpolate the same way i18next does, so a test can assert on "il y a
- // 12min" rather than on the untouched "il y a {{count}}min" placeholder.
- return value.replace(/{{(\w+)}}/g, (_, name: string) =>
- String(options[name] ?? `{{${name}}}`),
- );
-}
-
-vi.mock("react-i18next", async () => {
- const actual = await vi.importActual("react-i18next");
- return {
- ...actual,
- useTranslation: () => ({
- t: translate,
- i18n: { language: "fr" },
- }),
- };
-});
-
-const minutesAgo = (minutes: number) =>
- new Date(Date.now() - minutes * 60_000).toISOString();
-
-const RUNNING = AutomationRunStatus.RUNNING;
-
-describe("RunPhase — known code, non-English language", () => {
- it("shows the French translation.json value for a known phase code, not the raw code", () => {
- render(
- <RunPhase status={RUNNING} code="sandbox_provisioning" label={null} />,
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(
+ "Examining the diff",
);
-
- const expected =
- TRANSLATIONS[I18nKey.AUTOMATIONS$DETAIL$PHASE_SANDBOX_PROVISIONING].fr;
- expect(screen.getByText(expected)).toBeInTheDocument();
- expect(screen.queryByText("sandbox_provisioning")).not.toBeInTheDocument();
});
-});
-describe("RunPhase — unknown code (custom automations)", () => {
- it("shows the label as-is, including emoji and non-Latin text, for an unknown code", () => {
- render(
- <RunPhase status={RUNNING} code="poll_prs" label="🔍 Опрашиваем PR-ы" />,
- );
+ it("shows emoji and non-Latin text as-is", () => {
+ render(<RunPhase currentPhase="🔍 Опрашиваем PR-ы" />);
expect(screen.getByText("🔍 Опрашиваем PR-ы")).toBeInTheDocument();
});
- it("shows the raw code when the automation reported a code and no label", () => {
- // The service accepts `{"code": "checking_out"}` with no label at all, so
- // this run has a real phase and dropping it would show nothing.
- render(<RunPhase status={RUNNING} code="checking_out" label={null} />);
-
- expect(screen.getByTestId("run-phase")).toHaveTextContent("checking_out");
- });
-
it.each([
- ["null code and empty label", null, ""],
- ["undefined on both fields (an older service)", undefined, undefined],
- ["null on both fields", null, null],
- ["whitespace on both fields", " ", " "],
+ ["undefined (an older service)", undefined],
+ ["null", null],
+ ["empty string", ""],
+ ["whitespace only", " "],
])(
"renders nothing and never touches the console with %s",
- (_case, code, label) => {
+ (_case, phase) => {
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
- expect(() =>
- render(<RunPhase status={RUNNING} code={code} label={label} />),
- ).not.toThrow();
+ expect(() => render(<RunPhase currentPhase={phase} />)).not.toThrow();
expect(screen.queryByTestId("run-phase")).not.toBeInTheDocument();
expect(errorSpy).not.toHaveBeenCalled();
@@ -103,244 +44,43 @@ describe("RunPhase — unknown code (custom automations)", () => {
vi.restoreAllMocks();
});
- it("boundary: a 200-character label (the contract's max) reaches the DOM whole, so truncation stays visual", () => {
- // Arrange: the longest label the backend contract allows.
- const label = "x".repeat(200);
-
- // Act
- render(<RunPhase status={RUNNING} code="poll_prs" label={label} />);
-
- // Assert: the full string is still there — clipping must be CSS, never a
- // JS slice that would lose characters no tooltip could bring back.
- expect(screen.getByTestId("run-phase")).toHaveTextContent(label);
- });
+ it("boundary: a 200-character phase (the contract's max) reaches the DOM whole, so truncation stays visual", () => {
+ const phase = "x".repeat(200);
- it("renders the label when only a label was reported and no code", () => {
- // The service accepts a phase carrying just a label, so a custom
- // automation may report one. An absent code is the most unknown code
- // there is, and an unknown code falls back to its label.
- render(
- <RunPhase status={RUNNING} code={null} label="Reticulating splines" />,
- );
+ render(<RunPhase currentPhase={phase} />);
- expect(screen.getByTestId("run-phase")).toHaveTextContent(
- "Reticulating splines",
- );
+ expect(screen.getByTestId("run-phase")).toHaveTextContent(phase);
});
});
-describe("RunPhase — phase text is data, not a lookup into JavaScript itself", () => {
- // `phase_code` is author-supplied, so a plain-object lookup answers these
- // from `Object.prototype` and hands a function to `t()` — taking the card
- // tree down inside render instead of falling back to the label.
- it.each(["toString", "constructor", "__proto__", "hasOwnProperty"])(
- "treats %s as an ordinary unknown code and shows the label",
- (code) => {
- expect(() =>
- render(<RunPhase status={RUNNING} code={code} label="Полный аудит" />),
- ).not.toThrow();
-
- expect(screen.getByTestId("run-phase")).toHaveTextContent("Полный аудит");
- },
- );
-});
-
describe("resolveRunPhaseText — one answer for the row and its tooltip", () => {
- // The row shows a clipped copy of this text and the tooltip shows all of
- // it, so both have to resolve the same phase the same way; a surface that
- // resolved it on its own could show one thing and reveal another.
- const t = (key: string) => TRANSLATIONS[key]?.fr ?? key;
-
- it("resolves a known code to its translation", () => {
- expect(resolveRunPhaseText(t, "sandbox_provisioning", null)).toBe(
- TRANSLATIONS[I18nKey.AUTOMATIONS$DETAIL$PHASE_SANDBOX_PROVISIONING].fr,
+ it("resolves current_phase as-is", () => {
+ expect(resolveRunPhaseText("Preparing environment")).toBe(
+ "Preparing environment",
);
});
- it("resolves an unknown code to the author's label, verbatim", () => {
- expect(resolveRunPhaseText(t, "poll_prs", "🔍 Опрашиваем PR-ы")).toBe(
- "🔍 Опрашиваем PR-ы",
- );
- });
-
- it("resolves a phase carrying only a label to that label", () => {
- expect(resolveRunPhaseText(t, null, "Reticulating splines")).toBe(
- "Reticulating splines",
- );
- });
-
- it("resolves a phase carrying only a code to that code, verbatim", () => {
- // Mirrors the backend contract: `code` and `label` are independently
- // optional, so a code-only phase is valid and must reach the screen.
- expect(resolveRunPhaseText(t, "checking_out", null)).toBe("checking_out");
- expect(resolveRunPhaseText(t, "checking_out", "")).toBe("checking_out");
- });
-
- it("prefers the author's label over the raw code when both are present", () => {
- expect(resolveRunPhaseText(t, "poll_prs", "Polling PRs")).toBe(
- "Polling PRs",
- );
- });
-
- it("falls through a whitespace-only label, which the service stores as sent", () => {
- // Only a phase blank on *both* fields is rejected: `{"code": "x",
- // "label": " "}` is recorded verbatim, and rendering that label would
- // put an empty span on the row with the age dangling beside it.
- expect(resolveRunPhaseText(t, "checking_out", " ")).toBe("checking_out");
- expect(resolveRunPhaseText(t, " ", " ")).toBeNull();
+ it("trims padding", () => {
+ expect(resolveRunPhaseText(" Queued ")).toBe("Queued");
});
it("resolves to null when there is nothing to show", () => {
- expect(resolveRunPhaseText(t, "", "")).toBeNull();
- expect(resolveRunPhaseText(t, null, null)).toBeNull();
- });
-});
-
-describe("formatRunPhaseAge — telling a moving run from a stalled one", () => {
- it("reports how long the run has held the phase, localized", () => {
- expect(formatRunPhaseAge(minutesAgo(12), "fr", translate)).toBe(
- "il y a 12min",
- );
- });
-
- it("reports a phase written seconds ago as 'just now', not as zero minutes", () => {
- expect(formatRunPhaseAge(minutesAgo(0), "fr", translate)).toBe(
- TRANSLATIONS[I18nKey.AUTOMATIONS$DETAIL$TIME_JUST_NOW].fr,
- );
- });
-
- it("boundary: 60 minutes rolls over to the hours wording", () => {
- expect(formatRunPhaseAge(minutesAgo(60), "fr", translate)).toBe(
- "il y a 1h",
- );
- });
-
- it("returns null when the service reported no timestamp", () => {
- expect(formatRunPhaseAge(null, "fr", translate)).toBeNull();
- expect(formatRunPhaseAge(undefined, "fr", translate)).toBeNull();
- });
-
- it("negative: returns null for timestamps the formatter would print as garbage", () => {
- // The guard is the whole point: left to itself, the shared relative-time
- // formatter prints "Invalid Date" for an unparseable string and a 1970
- // date for the epoch, which is how the backend leaves a datetime unset.
- expect(formatRelativeTime("not-a-date", "fr", translate)).toMatch(
- /Invalid/,
- );
- expect(formatRelativeTime("1970-01-01T00:00:00Z", "fr", translate)).toMatch(
- /1970/,
- );
-
- expect(formatRunPhaseAge("not-a-date", "fr", translate)).toBeNull();
- expect(
- formatRunPhaseAge("1970-01-01T00:00:00Z", "fr", translate),
- ).toBeNull();
- });
-});
-
-describe("RunPhase — how long the run has been in this phase", () => {
- it("shows the age beside the phase, so a stalled run reads differently from a moving one", () => {
- render(
- <RunPhase
- status={RUNNING}
- code="running_agent"
- label={null}
- updatedAt={minutesAgo(41)}
- />,
- );
-
- expect(screen.getByTestId("run-phase-age")).toHaveTextContent(
- "il y a 41min",
- );
- });
-
- it("keeps the age in its own node, outside the clipped text, so a maximum-length label cannot push it out of sight", () => {
- // Arrange: the longest label the backend contract allows, in the surface
- // with the least room.
- const label = "x".repeat(200);
-
- render(
- <RunPhase
- status={RUNNING}
- code="poll_prs"
- label={label}
- updatedAt={minutesAgo(7)}
- />,
- );
-
- const text = screen.getByTestId("run-phase");
- const age = screen.getByTestId("run-phase-age");
- expect(text).not.toContainElement(age);
- });
-
- it("shows no age at all against a service that reports phases without a timestamp", () => {
- render(<RunPhase status={RUNNING} code="running_agent" label={null} />);
-
- expect(screen.getByTestId("run-phase")).toBeInTheDocument();
- expect(screen.queryByTestId("run-phase-age")).not.toBeInTheDocument();
- });
-
- it.each([
- ["unparseable", "not-a-date"],
- [
- "the epoch, which is how an unset datetime arrives",
- "1970-01-01T00:00:00Z",
- ],
- ])("shows no age when the timestamp is %s", (_case, updatedAt) => {
- render(
- <RunPhase
- status={RUNNING}
- code="running_agent"
- label={null}
- updatedAt={updatedAt}
- />,
- );
-
- expect(screen.queryByTestId("run-phase-age")).not.toBeInTheDocument();
- });
-
- it("drops the age on a failed run, whose phase is where it stopped rather than something still running", () => {
- // A months-old failure would otherwise render an absolute date — a
- // second timestamp beside the one the row already shows.
- render(
- <RunPhase
- status={AutomationRunStatus.FAILED}
- code="sandbox_provisioning"
- label={null}
- updatedAt={minutesAgo(41)}
- />,
- );
-
- expect(screen.getByTestId("run-phase")).toBeInTheDocument();
- expect(screen.queryByTestId("run-phase-age")).not.toBeInTheDocument();
+ expect(resolveRunPhaseText(undefined)).toBeNull();
+ expect(resolveRunPhaseText(null)).toBeNull();
+ expect(resolveRunPhaseText("")).toBeNull();
+ expect(resolveRunPhaseText(" ")).toBeNull();
});
});
describe("RunPhase — reachable without a mouse", () => {
- it("leaves the whole phase, age included, in the accessibility tree", () => {
- // Truncation is CSS only, so a 200-character label is readable in full
- // by a screen reader as long as nothing hides it — and nothing may hide
- // it behind a tab stop, because every surface nests the phase inside a
- // link, where a focusable descendant is invalid and swallows Enter.
- const label = "x".repeat(200);
+ it("leaves the whole phase in the accessibility tree", () => {
+ const phase = "x".repeat(200);
- render(
- <RunPhase
- status={RUNNING}
- code="poll_prs"
- label={label}
- updatedAt={minutesAgo(7)}
- />,
- );
+ render(<RunPhase currentPhase={phase} />);
const text = screen.getByTestId("run-phase");
- const age = screen.getByTestId("run-phase-age");
- expect(text).toHaveTextContent(label);
- expect(age).toHaveTextContent("il y a 7min");
+ expect(text).toHaveTextContent(phase);
expect(text).not.toHaveAttribute("aria-hidden");
- expect(age).not.toHaveAttribute("aria-hidden");
- // No focusable ancestor: the phase must never be its own tab stop
- // inside the link every surface wraps it in.
expect(text.closest("[tabindex]")).toBeNull();
});
});
diff --git a/__tests__/components/features/home/featured-automations-section.test.tsx b/__tests__/components/features/home/featured-automations-section.test.tsx
index 9f709099e3..f4436a86f2 100644
--- a/__tests__/components/features/home/featured-automations-section.test.tsx
+++ b/__tests__/components/features/home/featured-automations-section.test.tsx
@@ -521,8 +521,7 @@ describe("home automations composer layout", () => {
makeRun({
status: AutomationRunStatus.RUNNING,
completed_at: null,
- phase_code: "running_agent",
- phase_label: null,
+ current_phase: "Agent is working on the task",
}),
],
total: 1,
@@ -543,9 +542,7 @@ describe("home automations composer layout", () => {
// Assert: the pinned card shows the phase ...
const dashboard = await screen.findByTestId("pinned-automations-dashboard");
expect(
- await within(dashboard).findByText(
- "AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT",
- ),
+ await within(dashboard).findByText("Agent is working on the task"),
).toBeInTheDocument();
// ... and only one runs request was ever made for this automation.
expect(AutomationService.getAutomationRuns).toHaveBeenCalledTimes(1);
diff --git a/__tests__/components/features/home/home-automation-run-tooltip.test.tsx b/__tests__/components/features/home/home-automation-run-tooltip.test.tsx
index fb99debaea..85e033cc43 100644
--- a/__tests__/components/features/home/home-automation-run-tooltip.test.tsx
+++ b/__tests__/components/features/home/home-automation-run-tooltip.test.tsx
@@ -61,64 +61,13 @@ describe("HomeAutomationRunTooltip — phase", () => {
render(
<HomeAutomationRunTooltip
automation={automation}
- runState={makeState(
- makeRun({ phase_code: "drafting_notes", phase_label: LONG_LABEL }),
- )}
+ runState={makeState(makeRun({ current_phase: LONG_LABEL }))}
/>,
);
expect(screen.getByTestId("run-phase-row")).toHaveTextContent(LONG_LABEL);
});
- it("translates a phase code the frontend knows instead of printing it raw", () => {
- render(
- <HomeAutomationRunTooltip
- automation={automation}
- runState={makeState(
- makeRun({ phase_code: "bundle_upload", phase_label: null }),
- )}
- />,
- );
-
- expect(screen.getByTestId("run-phase-row")).toHaveTextContent(
- "AUTOMATIONS$DETAIL$PHASE_BUNDLE_UPLOAD",
- );
- });
-
- it("says how long the run has held the phase, so a stall is visible without opening the run", () => {
- render(
- <HomeAutomationRunTooltip
- automation={automation}
- runState={makeState(
- makeRun({
- phase_code: "drafting_notes",
- phase_label: LONG_LABEL,
- phase_updated_at: new Date(Date.now() - 25 * 60_000).toISOString(),
- }),
- )}
- />,
- );
-
- expect(screen.getByTestId("run-phase-row")).toHaveTextContent(
- "AUTOMATIONS$DETAIL$TIME_MINUTES_AGO:25",
- );
- });
-
- it("shows the phase without an age against a service that sends no timestamp", () => {
- render(
- <HomeAutomationRunTooltip
- automation={automation}
- runState={makeState(
- makeRun({ phase_code: "drafting_notes", phase_label: LONG_LABEL }),
- )}
- />,
- );
-
- const row = screen.getByTestId("run-phase-row");
- expect(row).toHaveTextContent(LONG_LABEL);
- expect(row.textContent).not.toContain("AUTOMATIONS$DETAIL$TIME_");
- });
-
it("omits the phase row for a finished run, matching every other surface", () => {
render(
<HomeAutomationRunTooltip
@@ -127,8 +76,7 @@ describe("HomeAutomationRunTooltip — phase", () => {
makeRun({
status: AutomationRunStatus.COMPLETED,
completed_at: "2026-08-01T10:05:00Z",
- phase_code: "running_agent",
- phase_label: null,
+ current_phase: "Agent is working on the task",
}),
)}
/>,
diff --git a/__tests__/mocks/automation-runs.mock.test.ts b/__tests__/mocks/automation-runs.mock.test.ts
index afe46b7fb3..a813a5f352 100644
--- a/__tests__/mocks/automation-runs.mock.test.ts
+++ b/__tests__/mocks/automation-runs.mock.test.ts
@@ -6,7 +6,6 @@ import {
shouldShowRunPhase,
} from "#/components/features/automations/detail/run-phase";
import { AutomationRunStatus, type AutomationRun } from "#/types/automation";
-import { I18nKey } from "#/i18n/declaration";
// `VITE_MOCK_API=true` is how the automations UI is developed and demoed
// without a local automation service, so a phase branch that no fixture
@@ -20,62 +19,19 @@ const IN_FLIGHT = ALL_RUNS.filter(
run.status === AutomationRunStatus.PENDING,
);
-// Stands in for `t()`: a known code must resolve to something other than the
-// code itself, so the assertions below cannot pass on a raw code.
-const t = (key: I18nKey) => `translated:${key}`;
-
describe("mock automation runs — the phase branches mock mode has to reach", () => {
it("has in-flight runs at all, or no surface ever shows a phase", () => {
expect(IN_FLIGHT.length).toBeGreaterThan(0);
});
- it("covers a phase code the frontend translates", () => {
- const translated = IN_FLIGHT.filter(
- (run) =>
- resolveRunPhaseText(t, run.phase_code, run.phase_label)?.startsWith(
- "translated:",
- ) ?? false,
- );
-
- expect(translated.length).toBeGreaterThan(0);
- });
-
- it("covers a custom automation's own code, falling back to its free-form label", () => {
- const custom = IN_FLIGHT.filter(
- (run) =>
- run.phase_code != null &&
- run.phase_label != null &&
- resolveRunPhaseText(t, run.phase_code, run.phase_label) ===
- run.phase_label,
- );
-
- expect(custom.length).toBeGreaterThan(0);
- });
-
- it("covers a phase carrying only a label, which the service also accepts", () => {
- const labelOnly = IN_FLIGHT.filter(
- (run) => run.phase_code == null && !!run.phase_label,
- );
+ it("covers the shipped current_phase string", () => {
+ const shipped = IN_FLIGHT.filter((run) => !!run.current_phase);
- expect(labelOnly.length).toBeGreaterThan(0);
- });
-
- it("covers a phase carrying only a code, which the service also accepts", () => {
- const codeOnly = IN_FLIGHT.filter(
- (run) =>
- !run.phase_label &&
- !!run.phase_code &&
- resolveRunPhaseText(t, run.phase_code, run.phase_label) ===
- run.phase_code,
- );
-
- expect(codeOnly.length).toBeGreaterThan(0);
+ expect(shipped.length).toBeGreaterThan(0);
});
it("covers an in-flight run with no phase fields at all — an older service", () => {
- const noPhase = IN_FLIGHT.filter(
- (run) => run.phase_code === undefined && run.phase_label === undefined,
- );
+ const noPhase = IN_FLIGHT.filter((run) => run.current_phase === undefined);
expect(noPhase.length).toBeGreaterThan(0);
});
@@ -84,7 +40,7 @@ describe("mock automation runs — the phase branches mock mode has to reach", (
const failedWithPhase = ALL_RUNS.filter(
(run) =>
run.status === AutomationRunStatus.FAILED &&
- resolveRunPhaseText(t, run.phase_code, run.phase_label) != null,
+ resolveRunPhaseText(run.current_phase) != null,
);
expect(failedWithPhase.length).toBeGreaterThan(0);
@@ -94,32 +50,16 @@ describe("mock automation runs — the phase branches mock mode has to reach", (
const hiddenPhase = ALL_RUNS.filter(
(run) =>
!shouldShowRunPhase(run.status) &&
- resolveRunPhaseText(t, run.phase_code, run.phase_label) != null,
+ resolveRunPhaseText(run.current_phase) != null,
);
expect(hiddenPhase.length).toBeGreaterThan(0);
});
- it("gives every phase-bearing run a usable timestamp, or the age would read 'Invalid Date'", () => {
- const withPhase = ALL_RUNS.filter(
- (run) => run.phase_code || run.phase_label,
- );
- expect(withPhase.length).toBeGreaterThan(0);
-
- for (const run of withPhase) {
- if (run.phase_updated_at == null) continue;
- expect(Number.isNaN(new Date(run.phase_updated_at).getTime())).toBe(
- false,
- );
- }
- });
-
- it("keeps every fixture within the service's own limits on code and label", () => {
+ it("keeps every fixture within the service's own limit on phase text", () => {
for (const run of ALL_RUNS) {
- if (run.phase_code)
- expect(run.phase_code.length).toBeLessThanOrEqual(128);
- if (run.phase_label)
- expect(run.phase_label.length).toBeLessThanOrEqual(200);
+ if (run.current_phase)
+ expect(run.current_phase.length).toBeLessThanOrEqual(200);
}
});
});
diff --git a/__tests__/utils/automation-activity-log-export.test.ts b/__tests__/utils/automation-activity-log-export.test.ts
index 4ef35c29f0..4aee9f6bf4 100644
--- a/__tests__/utils/automation-activity-log-export.test.ts
+++ b/__tests__/utils/automation-activity-log-export.test.ts
@@ -114,64 +114,34 @@ describe("automation-activity-log-export", () => {
expect(csv.split("\n")[1]).toContain("0.4213");
});
- it("carries the run's raw phase_code into the export row's phase field", () => {
- // Arrange
- const run = sampleRun({ phase_code: "sandbox_provisioning" });
+ it("carries current_phase into the export row's phase field", () => {
+ const run = sampleRun({ current_phase: "Examining the diff" });
- // Act
const row = mapAutomationRunToExportRow(run, automation);
- // Assert
- expect(row.phase).toBe("sandbox_provisioning");
+ expect(row.phase).toBe("Examining the diff");
});
it.each([
["null", null],
["undefined", undefined],
])(
- "normalizes a %s phase_code to a null phase field",
- (_label, phase_code) => {
- // Arrange
- const run = sampleRun({ phase_code });
+ "normalizes a %s current_phase to a null phase field",
+ (_label, current_phase) => {
+ const run = sampleRun({ current_phase });
- // Act
const row = mapAutomationRunToExportRow(run, automation);
- // Assert
expect(row.phase).toBeNull();
},
);
- it.each([
- ["an empty", ""],
- ["a whitespace-only", " "],
- ])(
- "falls back to the label when phase_code is %s string",
- (_label, phase_code) => {
- // The service stores a whitespace-only field as sent — it rejects only
- // a phase blank on *both* — so a blank code arrives alongside a real
- // label. Nullish-coalescing exports the blank and loses the label,
- // which is the empty cell the fallback exists to prevent.
- const run = sampleRun({
- phase_code,
- phase_label: "Running QA checks on PR #4821",
- });
-
- const row = mapAutomationRunToExportRow(run, automation);
-
- expect(row.phase).toBe("Running QA checks on PR #4821");
- },
- );
-
it("trims a padded phase before exporting it", () => {
- // Arrange
- const run = sampleRun({ phase_code: " queued ", phase_label: null });
+ const run = sampleRun({ current_phase: " Queued " });
- // Act
const row = mapAutomationRunToExportRow(run, automation);
- // Assert
- expect(row.phase).toBe("queued");
+ expect(row.phase).toBe("Queued");
});
it.each([
@@ -187,13 +157,12 @@ describe("automation-activity-log-export", () => {
// indistinguishable from one that never reported a phase at all.
const run = sampleRun({
status,
- phase_code: "running_agent",
- phase_label: null,
+ current_phase: "Agent is working on the task",
});
const row = mapAutomationRunToExportRow(run, automation);
- expect(row.phase).toBe("running_agent");
+ expect(row.phase).toBe("Agent is working on the task");
},
);
@@ -212,7 +181,7 @@ describe("automation-activity-log-export", () => {
sampleRow({
run_id: "r-with-phase",
trigger: { type: "cron" },
- phase: "running_agent",
+ phase: "Agent is working on the task",
}),
sampleRow({
run_id: "r-without-phase",
@@ -230,7 +199,9 @@ describe("automation-activity-log-export", () => {
// Assert
const withPhaseCells = lines[1].split(",");
const withoutPhaseCells = lines[2].split(",");
- expect(withPhaseCells[phaseColumnIndex]).toBe("running_agent");
+ expect(withPhaseCells[phaseColumnIndex]).toBe(
+ "Agent is working on the task",
+ );
expect(withoutPhaseCells[phaseColumnIndex]).toBe("");
expect(withoutPhaseCells[phaseColumnIndex]).not.toBe("null");
});
@@ -344,19 +315,11 @@ describe("automation-activity-log-export", () => {
expect(blob.type).toBe("text/csv;charset=utf-8");
});
- it("falls back to the label when a phase carries no code, so an empty cell means no phase", () => {
- // Arrange — the service accepts a phase with only a label, and the UI
- // shows it. Exporting the code alone would make such a run look identical
- // to one that never reported a phase.
- const run = sampleRun({
- phase_code: null,
- phase_label: "Reticulating splines",
- });
+ it("exports whitespace-only current_phase as an empty cell, same as no phase", () => {
+ const run = sampleRun({ current_phase: " " });
- // Act
const row = mapAutomationRunToExportRow(run, automation);
- // Assert
- expect(row.phase).toBe("Reticulating splines");
+ expect(row.phase).toBeNull();
});
});
diff --git a/src/components/features/automations/automation-card.tsx b/src/components/features/automations/automation-card.tsx
index 152c29b8c5..c0b9024a41 100644
--- a/src/components/features/automations/automation-card.tsx
+++ b/src/components/features/automations/automation-card.tsx
@@ -236,12 +236,7 @@ export function AutomationCard({
/>
{showPhase ? (
- <RunPhase
- status={latestRun.status}
- code={latestRun.phase_code}
- label={latestRun.phase_label}
- updatedAt={latestRun.phase_updated_at}
- />
+ <RunPhase currentPhase={latestRun.current_phase} />
) : null}
{shortSummary ? (
diff --git a/src/components/features/automations/detail/activity-log-item.tsx b/src/components/features/automations/detail/activity-log-item.tsx
index 9ec8f4ed12..03cdcdbb91 100644
--- a/src/components/features/automations/detail/activity-log-item.tsx
+++ b/src/components/features/automations/detail/activity-log-item.tsx
@@ -141,15 +141,7 @@ export function ActivityLogItem({ run, automation }: ActivityLogItemProps) {
</span>
)}
{logsButton}
- {showPhase && (
- <RunPhase
- status={run.status}
- code={run.phase_code}
- label={run.phase_label}
- updatedAt={run.phase_updated_at}
- wide
- />
- )}
+ {showPhase && <RunPhase currentPhase={run.current_phase} wide />}
<RunStatusBadge status={display.badgeStatus} />
</div>
</>
diff --git a/src/components/features/automations/detail/run-phase.tsx b/src/components/features/automations/detail/run-phase.tsx
index 0ef3d943b5..14683581ff 100644
--- a/src/components/features/automations/detail/run-phase.tsx
+++ b/src/components/features/automations/detail/run-phase.tsx
@@ -1,11 +1,5 @@
import { Tooltip } from "@heroui/react";
-import { useTranslation } from "react-i18next";
-import { I18nKey } from "#/i18n/declaration";
import { AutomationRunStatus } from "#/types/automation";
-import {
- formatRelativeTime,
- isInvalidTimestamp,
-} from "#/utils/format-relative-time";
import { cn } from "#/utils/utils";
/**
@@ -24,133 +18,32 @@ export function shouldShowRunPhase(
);
}
-/**
- * Whether the phase's age is worth showing. Only for a run still in flight:
- * the age exists to separate a moving run from a stalled one, and a run that
- * has failed is neither — its phase is the place it stopped. Left in, the age
- * of an old failure degrades to an absolute date (`formatRelativeTime` gives
- * up past a week), which reads as a second timestamp beside the one the row
- * already shows.
- */
-export function shouldShowRunPhaseAge(
- status: AutomationRunStatus | null | undefined,
-): boolean {
- return (
- status === AutomationRunStatus.PENDING ||
- status === AutomationRunStatus.RUNNING
- );
-}
-
-interface RunPhaseFields {
- /** `AutomationRun.status` — decides whether the age is meaningful. */
- status: AutomationRunStatus | null | undefined;
- /** `AutomationRun.phase_code` — `null`/absent means no phase reported. */
- code: string | null | undefined;
- /** `AutomationRun.phase_label` — free-form author text, not interface copy. */
- label: string | null | undefined;
- /** `AutomationRun.phase_updated_at` — when this phase was last written. */
- updatedAt?: string | null;
-}
-
-interface RunPhaseProps extends RunPhaseFields {
- /** More width before clipping, for rows far wider than a card. */
- wide?: boolean;
-}
-
-/**
- * Codes the frontend can translate: the automation service's own milestones
- * and the preset templates'. Any other code is by design unknown — custom
- * automations emit their own — and falls back to `phase_label`.
- */
-const KNOWN_PHASE_CODES: Record<string, I18nKey> = {
- queued: I18nKey.AUTOMATIONS$DETAIL$PHASE_QUEUED,
- sandbox_provisioning: I18nKey.AUTOMATIONS$DETAIL$PHASE_SANDBOX_PROVISIONING,
- bundle_upload: I18nKey.AUTOMATIONS$DETAIL$PHASE_BUNDLE_UPLOAD,
- entrypoint_start: I18nKey.AUTOMATIONS$DETAIL$PHASE_ENTRYPOINT_START,
- preparing: I18nKey.AUTOMATIONS$DETAIL$PHASE_PREPARING,
- running_agent: I18nKey.AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT,
-};
-
/**
* The one place a stored phase becomes text, so a run cannot read one way on
- * a card and another way in that card's own tooltip. An absent code counts as
- * unrecognized rather than as an absent phase: the service accepts a phase
- * carrying only a label, and dropping those would hide a real phase.
+ * a card and another way in that card's own tooltip.
*
- * `code` and `label` are independently optional in the service's contract, so
- * the last resort is the raw code — a code-only phase is a real phase and
- * must reach the screen. It is shown as stored rather than prettified: the
- * code is data like the label, and turning `poll_prs` into "Poll prs" would
- * invent English-shaped copy no automation author wrote.
- *
- * Both fields are author-supplied, which is why the lookup is an own-property
- * check and both are trimmed. A code of `toString` would otherwise resolve to
- * `Object.prototype.toString` and be handed to `t()`, and the service stores
- * a whitespace-only field as sent — it rejects only a phase blank on *both*.
+ * Automation ≥1.9.0 sends `current_phase` as already user-facing copy — not a
+ * translation key, never passed through `t()`. Whitespace-only is treated as
+ * absent: the service stores such a field as sent, and rendering it would put
+ * an empty span on the row.
*/
export function resolveRunPhaseText(
- t: (key: I18nKey) => string,
- code: string | null | undefined,
- label: string | null | undefined,
+ currentPhase?: string | null,
): string | null {
- const knownKey =
- code && Object.hasOwn(KNOWN_PHASE_CODES, code)
- ? KNOWN_PHASE_CODES[code]
- : undefined;
- if (knownKey) return t(knownKey);
- return label?.trim() || code?.trim() || null;
+ return currentPhase?.trim() || null;
}
-/**
- * How long the run has been in this phase, as localized relative time.
- *
- * This is the half of the phase that separates progress from a stall: the
- * phase text alone says a run is "Running agent", and only its age says
- * whether it entered that phase seconds ago or forty minutes ago. Returns
- * `null` when the service reported no usable timestamp — an older service
- * omits the field entirely, and an unset datetime arrives as the epoch — so
- * an age nobody can compute never surfaces as "Invalid Date" or "Jan 1, 1970".
- */
-export function formatRunPhaseAge(
- updatedAt: string | null | undefined,
- locale: string,
- t: (key: I18nKey, options?: Record<string, unknown>) => string,
-): string | null {
- if (!updatedAt || isInvalidTimestamp(updatedAt)) return null;
- return formatRelativeTime(updatedAt, locale, t);
-}
-
-/**
- * The resolved phase of a run, or `null` when it has none worth showing.
- * Every surface goes through this — the clipped row below, the home
- * hovercard's wrapping one — so they cannot drift into resolving a phase, or
- * deciding to show its age, on their own terms.
- */
-export function useRunPhase({
- status,
- code,
- label,
- updatedAt,
-}: RunPhaseFields): { text: string; age: string | null } | null {
- const { t, i18n } = useTranslation("openhands");
-
- const text = resolveRunPhaseText(t, code, label);
- if (!text) return null;
-
- const age = shouldShowRunPhaseAge(status)
- ? formatRunPhaseAge(updatedAt, i18n.language, t)
- : null;
-
- return { text, age };
+interface RunPhaseProps {
+ /** `AutomationRun.current_phase` — `null`/absent means no phase reported. */
+ currentPhase?: string | null;
+ /** More width before clipping, for rows far wider than a card. */
+ wide?: boolean;
}
/**
- * A run's current or last-known phase and how long it has held it, clipped to
- * the room the surface has with the full text one hover away — author-supplied
- * labels routinely outgrow any row. The label is data, not interface copy, so
- * it is rendered as-is: passing it through `t()` would be wrong, it is not a
- * key. The age sits outside the clipped text so a long label can never push it
- * out of sight — it is the part that stays legible when everything else is cut.
+ * A run's current or last-known phase, clipped to the room the surface has
+ * with the full text one hover away. The string is data, not interface copy,
+ * so it is rendered as-is.
*
* The text stays in the accessibility tree rather than hiding behind an
* accessible name on a focusable wrapper. Every surface nests this inside a
@@ -160,26 +53,13 @@ export function useRunPhase({
* Truncation is CSS only, so the full label is already in the DOM and reads
* in full; the tooltip is the sighted mouse user's route to it.
*/
-export function RunPhase({
- status,
- code,
- label,
- updatedAt,
- wide = false,
-}: RunPhaseProps) {
- const phase = useRunPhase({ status, code, label, updatedAt });
- if (!phase) return null;
-
- const { text, age } = phase;
+export function RunPhase({ currentPhase, wide = false }: RunPhaseProps) {
+ const text = resolveRunPhaseText(currentPhase);
+ if (!text) return null;
return (
<Tooltip
- content={
- <>
- {text}
- {age ? <span className="mt-1 block text-muted">{age}</span> : null}
- </>
- }
+ content={text}
placement="top"
closeDelay={100}
disableAnimation={import.meta.env.MODE === "test"}
@@ -198,14 +78,6 @@ export function RunPhase({
>
{text}
</span>
- {age ? (
- <span
- data-testid="run-phase-age"
- className="shrink-0 whitespace-nowrap text-xs text-muted"
- >
- · {age}
- </span>
- ) : null}
</span>
</Tooltip>
);
diff --git a/src/components/features/home/featured-automations/home-automation-run-tooltip.tsx b/src/components/features/home/featured-automations/home-automation-run-tooltip.tsx
index e6d90d2ccc..61fb96c543 100644
--- a/src/components/features/home/featured-automations/home-automation-run-tooltip.tsx
+++ b/src/components/features/home/featured-automations/home-automation-run-tooltip.tsx
@@ -5,8 +5,8 @@ import type { LatestAutomationRunState } from "#/hooks/query/use-latest-automati
import { I18nKey } from "#/i18n/declaration";
import ClockIcon from "#/icons/clock.svg?react";
import {
+ resolveRunPhaseText,
shouldShowRunPhase,
- useRunPhase,
} from "#/components/features/automations/detail/run-phase";
import type { Automation, AutomationRun } from "#/types/automation";
import {
@@ -56,32 +56,19 @@ function PreviewRow({
}
/**
- * The run's phase and how long it has held it. The row that opens this
- * hovercard has to clip a long phase; here there is room to wrap, so this is
- * where the whole thing is readable — and the age is what says whether the
- * run is moving through phases or sitting in one. Only the layout differs
- * from the row's: what the phase says, and whether its age is meaningful,
- * comes from the same hook the row uses.
+ * The run's phase. The row that opens this hovercard has to clip a long
+ * phase; here there is room to wrap, so this is where the whole thing is
+ * readable. What the phase says comes from the same helper the row uses.
*/
function PhaseRow({ run }: { run: AutomationRun | null }) {
const { t } = useTranslation("openhands");
- const phase = useRunPhase({
- status: run?.status,
- code: run?.phase_code,
- label: run?.phase_label,
- updatedAt: run?.phase_updated_at,
- });
+ const text = resolveRunPhaseText(run?.current_phase);
- if (!run || !shouldShowRunPhase(run.status) || !phase) return null;
-
- const { text, age } = phase;
+ if (!run || !shouldShowRunPhase(run.status) || !text) return null;
return (
<PreviewRow label={t(I18nKey.AUTOMATIONS$DETAIL$PHASE)}>
- <span data-testid="run-phase-row">
- {text}
- {age ? <span className="text-muted"> · {age}</span> : null}
- </span>
+ <span data-testid="run-phase-row">{text}</span>
</PreviewRow>
);
}
diff --git a/src/components/features/home/featured-automations/pinned-automation-card.tsx b/src/components/features/home/featured-automations/pinned-automation-card.tsx
index d4a273ed4e..3ac5fd7a09 100644
--- a/src/components/features/home/featured-automations/pinned-automation-card.tsx
+++ b/src/components/features/home/featured-automations/pinned-automation-card.tsx
@@ -285,12 +285,7 @@ export function PinnedAutomationCard({
/>
{showPhase ? (
- <RunPhase
- status={latestRun.status}
- code={latestRun.phase_code}
- label={latestRun.phase_label}
- updatedAt={latestRun.phase_updated_at}
- />
+ <RunPhase currentPhase={latestRun.current_phase} />
) : null}
{shortSummary ? (
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 2978498754..a31de48356 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -16937,114 +16937,6 @@
"zh-TW": "階段",
"id": "Fase"
},
- "AUTOMATIONS$DETAIL$PHASE_QUEUED": {
- "ar": "في قائمة الانتظار",
- "ca": "A la cua",
- "de": "In der Warteschlange",
- "en": "Queued",
- "es": "En cola",
- "fr": "En file d'attente",
- "it": "In coda",
- "ja": "待機中",
- "ko-KR": "대기 중",
- "no": "I kø",
- "pt": "Na fila",
- "tr": "Sırada",
- "uk": "У черзі",
- "zh-CN": "排队中",
- "zh-TW": "排隊中",
- "id": "Dalam antrean"
- },
- "AUTOMATIONS$DETAIL$PHASE_SANDBOX_PROVISIONING": {
- "ar": "جارٍ إعداد بيئة العمل",
- "ca": "Configurant l'entorn aïllat",
- "de": "Sandbox wird eingerichtet",
- "en": "Setting up sandbox",
- "es": "Configurando entorno aislado",
- "fr": "Préparation du bac à sable",
- "it": "Configurazione sandbox",
- "ja": "サンドボックスを準備中",
- "ko-KR": "샌드박스 준비 중",
- "no": "Setter opp sandkasse",
- "pt": "Configurando sandbox",
- "tr": "Sandbox hazırlanıyor",
- "uk": "Налаштування пісочниці",
- "zh-CN": "正在配置沙盒",
- "zh-TW": "正在設定沙盒",
- "id": "Menyiapkan sandbox"
- },
- "AUTOMATIONS$DETAIL$PHASE_BUNDLE_UPLOAD": {
- "ar": "جارٍ رفع الحزمة",
- "ca": "Pujant el paquet",
- "de": "Paket wird hochgeladen",
- "en": "Uploading bundle",
- "es": "Subiendo paquete",
- "fr": "Téléversement du paquet",
- "it": "Caricamento del pacchetto",
- "ja": "バンドルをアップロード中",
- "ko-KR": "번들 업로드 중",
- "no": "Laster opp pakke",
- "pt": "Enviando pacote",
- "tr": "Paket yükleniyor",
- "uk": "Завантаження пакета",
- "zh-CN": "正在上传软件包",
- "zh-TW": "正在上傳套件",
- "id": "Mengunggah bundel"
- },
- "AUTOMATIONS$DETAIL$PHASE_ENTRYPOINT_START": {
- "ar": "جارٍ البدء",
- "ca": "S'està iniciant",
- "de": "Wird gestartet",
- "en": "Starting",
- "es": "Iniciando",
- "fr": "Démarrage",
- "it": "Avvio in corso",
- "ja": "起動中",
- "ko-KR": "시작 중",
- "no": "Starter",
- "pt": "Iniciando",
- "tr": "Başlatılıyor",
- "uk": "Запуск",
- "zh-CN": "正在启动",
- "zh-TW": "正在啟動",
- "id": "Memulai"
- },
- "AUTOMATIONS$DETAIL$PHASE_PREPARING": {
- "ar": "جارٍ التحضير",
- "ca": "Preparant",
- "de": "Wird vorbereitet",
- "en": "Preparing",
- "es": "Preparando",
- "fr": "Préparation",
- "it": "Preparazione",
- "ja": "準備中",
- "ko-KR": "준비 중",
- "no": "Forbereder",
- "pt": "Preparando",
- "tr": "Hazırlanıyor",
- "uk": "Підготовка",
- "zh-CN": "正在准备",
- "zh-TW": "正在準備",
- "id": "Mempersiapkan"
- },
- "AUTOMATIONS$DETAIL$PHASE_RUNNING_AGENT": {
- "ar": "الوكيل قيد التشغيل",
- "ca": "Executant l'agent",
- "de": "Agent wird ausgeführt",
- "en": "Running agent",
- "es": "Ejecutando agente",
- "fr": "Agent en cours d'exécution",
- "it": "Agente in esecuzione",
- "ja": "エージェントを実行中",
- "ko-KR": "에이전트 실행 중",
- "no": "Kjører agent",
- "pt": "Executando agente",
- "tr": "Ajan çalışıyor",
- "uk": "Агент виконується",
- "zh-CN": "代理运行中",
- "zh-TW": "代理執行中",
- "id": "Menjalankan agen"
- },
"AUTOMATIONS$DETAIL$INACTIVE": {
"en": "Inactive",
"ja": "非アクティブ",
diff --git a/src/mocks/automation-handlers.ts b/src/mocks/automation-handlers.ts
index d536a69210..cd1bf7dc7a 100644
--- a/src/mocks/automation-handlers.ts
+++ b/src/mocks/automation-handlers.ts
@@ -564,11 +564,9 @@ export const AUTOMATION_HANDLERS = [
conversation_id: null,
bash_command_id: null,
error_detail: null,
- // A freshly dispatched run has not reported a phase yet — the service
- // sends the fields as null rather than omitting them.
- phase_code: null,
- phase_label: null,
- phase_updated_at: null,
+ // A freshly dispatched run has not reported a phase yet — the 1.9.0+
+ // service sends `current_phase: null`.
+ current_phase: null,
started_at: new Date().toISOString(),
completed_at: null,
};
diff --git a/src/mocks/automation-runs.mock.ts b/src/mocks/automation-runs.mock.ts
index de05c8c863..1d8d8d2e4d 100644
--- a/src/mocks/automation-runs.mock.ts
+++ b/src/mocks/automation-runs.mock.ts
@@ -10,24 +10,9 @@ const daysAgo = (days: number, hour = 9) => {
const minutesAgo = (minutes: number) =>
new Date(Date.now() - minutes * 60_000).toISOString();
-/** Omitting this entirely is a case too: an older service sends no phase. */
-interface PhaseFixture {
- code: string | null;
- label: string | null;
- /** Minutes since the phase was last written; defaults to the run's start. */
- ageMinutes?: number;
-}
-
-function phaseFields(phase: PhaseFixture | undefined, fallbackAt: string) {
- if (!phase) return {};
- return {
- phase_code: phase.code,
- phase_label: phase.label,
- phase_updated_at:
- phase.ageMinutes === undefined
- ? fallbackAt
- : minutesAgo(phase.ageMinutes),
- };
+function phaseFields(currentPhase: string | null | undefined) {
+ if (currentPhase === undefined) return {};
+ return { current_phase: currentPhase };
}
function makeRun(
@@ -36,7 +21,7 @@ function makeRun(
startedDaysAgo: number,
hour = 9,
hasConversation = true,
- phase?: PhaseFixture,
+ currentPhase?: string | null,
): AutomationRun {
const started = daysAgo(startedDaysAgo, hour);
return {
@@ -50,7 +35,7 @@ function makeRun(
status === AutomationRunStatus.FAILED
? "Process exited with code 1"
: null,
- ...phaseFields(phase, started),
+ ...phaseFields(currentPhase),
started_at: started,
completed_at: new Date(new Date(started).getTime() + 120_000).toISOString(),
};
@@ -67,7 +52,7 @@ function makeInFlightRun(
status: AutomationRunStatus.RUNNING | AutomationRunStatus.PENDING,
startedMinutesAgo: number,
hasConversation = true,
- phase?: PhaseFixture,
+ currentPhase?: string | null,
): AutomationRun {
const startedAt = minutesAgo(startedMinutesAgo);
return {
@@ -76,7 +61,7 @@ function makeInFlightRun(
conversation_id: hasConversation ? `conv-${id}` : null,
bash_command_id: hasConversation ? `cmd-${id}` : null,
error_detail: null,
- ...phaseFields(phase, startedAt),
+ ...phaseFields(currentPhase),
started_at: startedAt,
completed_at: null,
};
@@ -90,16 +75,25 @@ export const MOCK_AUTOMATION_RUNS: Record<string, AutomationRun[]> = {
"a1000000-0000-0000-0000-000000000001": [
makeRun("r1-01", AutomationRunStatus.COMPLETED, 0),
makeRun("r1-02", AutomationRunStatus.COMPLETED, 1),
- // Failed, keeping the phase it stopped at: died while the sandbox came up.
- makeRun("r1-03", AutomationRunStatus.FAILED, 2, 9, true, {
- code: "sandbox_provisioning",
- label: null,
- }),
+ // Failed, keeping the phase it stopped at. Production 1.9.0+ shape:
+ // a single `current_phase` string.
+ makeRun(
+ "r1-03",
+ AutomationRunStatus.FAILED,
+ 2,
+ 9,
+ true,
+ "Installing dependencies",
+ ),
// A phase on record that no screen shows, but the export still carries.
- makeRun("r1-04", AutomationRunStatus.COMPLETED, 3, 9, true, {
- code: "running_agent",
- label: null,
- }),
+ makeRun(
+ "r1-04",
+ AutomationRunStatus.COMPLETED,
+ 3,
+ 9,
+ true,
+ "Agent is working on the task",
+ ),
makeRun("r1-05", AutomationRunStatus.COMPLETED, 4),
makeRun("r1-06", AutomationRunStatus.COMPLETED, 7),
makeRun("r1-07", AutomationRunStatus.FAILED, 8),
@@ -109,10 +103,13 @@ export const MOCK_AUTOMATION_RUNS: Record<string, AutomationRun[]> = {
],
"a1000000-0000-0000-0000-000000000002": [
// Queued: no sandbox or conversation yet, and only the phase says so.
- makeInFlightRun("r2-00", AutomationRunStatus.PENDING, 2, false, {
- code: "queued",
- label: null,
- }),
+ makeInFlightRun(
+ "r2-00",
+ AutomationRunStatus.PENDING,
+ 2,
+ false,
+ "Preparing environment",
+ ),
makeRun("r2-01", AutomationRunStatus.COMPLETED, 0, 1),
makeRun("r2-02", AutomationRunStatus.COMPLETED, 1, 1),
makeRun("r2-03", AutomationRunStatus.COMPLETED, 2, 1),
@@ -120,14 +117,14 @@ export const MOCK_AUTOMATION_RUNS: Record<string, AutomationRun[]> = {
makeRun("r2-05", AutomationRunStatus.COMPLETED, 4, 1),
],
"a1000000-0000-0000-0000-000000000003": [
- // The case the issue is about: 52 minutes into a job that usually takes
- // two, stuck on one step for 41 of them. The code is the automation's
- // own, so its label is shown verbatim — and is long enough to be clipped.
- makeInFlightRun("r3-00", AutomationRunStatus.RUNNING, 52, true, {
- code: "diffing_docs_tree",
- label: "Diffing 340 changed files against main",
- ageMinutes: 41,
- }),
+ // Long free-form phase, clipped on the card, readable in the tooltip.
+ makeInFlightRun(
+ "r3-00",
+ AutomationRunStatus.RUNNING,
+ 52,
+ true,
+ "Diffing 340 changed files against main",
+ ),
makeRun("r3-01", AutomationRunStatus.COMPLETED, 1),
// Terminal statuses the backend emits besides COMPLETED/FAILED.
makeRun("r3-02", AutomationRunStatus.CANCELLED, 2),
@@ -139,18 +136,13 @@ export const MOCK_AUTOMATION_RUNS: Record<string, AutomationRun[]> = {
],
"a1000000-0000-0000-0000-000000000005": [],
"a1000000-0000-0000-0000-000000000006": [
- // A label with no code: the service accepts that, so the UI must show it.
- makeInFlightRun("r6-00", AutomationRunStatus.RUNNING, 13, true, {
- code: null,
- label: "Running QA checks on PR #4821",
- ageMinutes: 4,
- }),
- // A code with no label: also accepted, and shown as the raw code.
- makeInFlightRun("r6-06", AutomationRunStatus.RUNNING, 6, true, {
- code: "checking_out",
- label: null,
- ageMinutes: 2,
- }),
+ makeInFlightRun(
+ "r6-00",
+ AutomationRunStatus.RUNNING,
+ 13,
+ true,
+ "Running QA checks on PR #4821",
+ ),
// No phase fields at all — an older service: a status pill, no empty
// slot. Below the head, so it costs no card its health.
makeInFlightRun("r6-07", AutomationRunStatus.RUNNING, 21),
diff --git a/src/types/automation.ts b/src/types/automation.ts
index ca04ecf69c..3ccc6e00e8 100644
--- a/src/types/automation.ts
+++ b/src/types/automation.ts
@@ -232,20 +232,12 @@ export interface AutomationRun {
*/
cost?: number | null;
/**
- * Machine-readable code for the run's current or last-known phase (e.g.
- * "sandbox_provisioning"). `null` means nothing has reported one; absent
- * entirely against an automation service that predates phase reporting.
- * Code and label are one value, always written together.
+ * User-facing live phase from automation ≥1.9.0. Free-form text the
+ * service already sanitised for the dashboard — not a translation key.
+ * `null` means nothing has been reported; absent entirely against a
+ * service older than phase reporting.
*/
- phase_code?: string | null;
- /**
- * Author-supplied description of the phase (at most 200 characters, no
- * control or separator characters, emoji and non-Latin text allowed).
- * Data, not translatable interface copy.
- */
- phase_label?: string | null;
- /** UTC datetime the phase was last written. Same nullability as `phase_code`. */
- phase_updated_at?: string | null;
+ current_phase?: string | null;
started_at: string;
completed_at: string | null;
}
@@ -284,8 +276,7 @@ export interface AutomationRunExportRow {
*/
cost: number | null;
/**
- * The raw `phase_code`, like `status`, falling back to `phase_label` for a
- * phase reported without a code. Null only when the run has no phase.
+ * The run's `current_phase` as stored. Null only when the run has no phase.
*/
phase: string | null;
}
diff --git a/src/utils/automation-activity-log-export.ts b/src/utils/automation-activity-log-export.ts
index 5d095106f0..e12c36a42f 100644
--- a/src/utils/automation-activity-log-export.ts
+++ b/src/utils/automation-activity-log-export.ts
@@ -111,14 +111,7 @@ export function mapAutomationRunToExportRow(
// not a screen — a completed run's last phase is real data, and dropping
// it here would make the phase of a run that finished indistinguishable
// from one that never reported a phase at all.
- //
- // Falling back to the label: without it, a phase reported with only a
- // label would export as an empty cell, indistinguishable from no phase.
- // Trimmed rather than nullish-coalesced: the service stores a
- // whitespace-only field as sent — it rejects only a phase blank on
- // *both* — so `??` would let a blank code suppress a real label, which
- // is exactly the empty cell this fallback exists to prevent.
- phase: run.phase_code?.trim() || run.phase_label?.trim() || null,
+ phase: run.current_phase?.trim() || null,
};
}