Skip to content

Commit f17f172

Browse files
PrateekJannuclaude
andcommitted
refactor(ui): RunStatusBadge consumes the shared status vocabulary
Web/desktop's RunStatusBadge had a local copy of the status tone/label map identical to @open-cowork/tokens' RUN_STATUS_META (which mobile's StatusChip already uses). Import the shared map instead of duplicating it, so the run status vocabulary is single-sourced and web ↔ mobile stay identical by construction. Promotes @open-cowork/tokens to a runtime dependency of the lib. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a267667 commit f17f172

3 files changed

Lines changed: 10 additions & 26 deletions

File tree

packages/ui/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
"test:coverage": "vitest run --coverage --passWithNoTests",
1717
"typecheck": "tsc --noEmit"
1818
},
19+
"dependencies": {
20+
"@open-cowork/tokens": "workspace:*"
21+
},
1922
"peerDependencies": {
2023
"react": ">=18",
2124
"react-dom": ">=18"
2225
},
2326
"devDependencies": {
24-
"@open-cowork/tokens": "workspace:*",
2527
"@testing-library/jest-dom": "catalog:",
2628
"@testing-library/react": "catalog:",
2729
"@testing-library/user-event": "catalog:",

packages/ui/src/components/RunStatusBadge.tsx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
import { cx } from '../cx';
22
import { Badge } from './Badge';
3-
import type { BadgeTone } from './Badge';
3+
import { RUN_STATUS_META, type RunStatus } from '@open-cowork/tokens';
44

55
/**
6-
* Run lifecycle states, mirroring the Coasty run state machine
7-
* (`queued -> running <-> awaiting_human -> terminal`).
8-
*
9-
* Defined locally so this package stays independent of `@open-cowork/core`;
10-
* apps map core's run status union into this identical type.
6+
* Run lifecycle states + their curated tone/label come from the shared
7+
* `@open-cowork/tokens` source, so web/desktop and React Native render an
8+
* identical status vocabulary (mobile's StatusChip consumes the same map).
119
*/
12-
export type RunStatus =
13-
| 'queued'
14-
| 'running'
15-
| 'awaiting_human'
16-
| 'succeeded'
17-
| 'failed'
18-
| 'cancelled'
19-
| 'timed_out';
20-
21-
const RUN_STATUS_META: Record<RunStatus, { tone: BadgeTone; label: string }> = {
22-
queued: { tone: 'neutral', label: 'Queued' },
23-
running: { tone: 'info', label: 'Running' },
24-
awaiting_human: { tone: 'warning', label: 'Awaiting human' },
25-
succeeded: { tone: 'success', label: 'Succeeded' },
26-
failed: { tone: 'danger', label: 'Failed' },
27-
cancelled: { tone: 'neutral', label: 'Cancelled' },
28-
timed_out: { tone: 'danger', label: 'Timed out' },
29-
};
10+
export type { RunStatus };
3011

3112
/** Props for {@link RunStatusBadge}. */
3213
export interface RunStatusBadgeProps {

pnpm-lock.yaml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)