The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | /** |
| 2 | * The one mapping from plan actions / apply statuses to brand colors and |
| 3 | * icons — shared by the plan tree, the live progress view, and the plain |
| 4 | * logging CLI so an action never renders two different hues. |
| 5 | */ |
| 6 | import type { ApplyStatus } from "../../../Events.ts"; |
| 7 | import { theme, type GlyphName } from "../../../Util/Theme.ts"; |
| 8 | |
| 9 | /** Every verb a plan row can carry (resource CRUD + namespace/action rollups). */ |
| 10 | export type PlanAction = |
| 11 | | "create" |
| 12 | | "update" |
| 13 | | "adopted" |
| 14 | | "delete" |
| 15 | | "orphaned" |
| 16 | | "replace" |
| 17 | | "noop" |
| 18 | | "mixed" |
| 19 | | "run"; |
| 20 | |
| 21 | export const actionStyle: Record<PlanAction, { readonly color: string; readonly icon: GlyphName }> = |
| 22 | { |
| 23 | create: { color: theme.color.success, icon: "add" }, |
| 24 | update: { color: theme.color.warning, icon: "edit" }, |
| 25 | adopted: { color: theme.color.magenta, icon: "adopt" }, |
| 26 | delete: { color: theme.color.danger, icon: "delete" }, |
| 27 | orphaned: { color: theme.color.coral, icon: "orphan" }, |
| 28 | replace: { color: theme.color.magenta, icon: "replace" }, |
| 29 | noop: { color: theme.color.muted, icon: "bullet" }, |
| 30 | mixed: { color: theme.color.info, icon: "info" }, |
| 31 | run: { color: theme.color.info, icon: "run" }, |
| 32 | }; |
| 33 | |
| 34 | export const applyStatusColor = (status: ApplyStatus | "no change"): string | undefined => { |
| 35 | switch (status) { |
| 36 | case "no change": |
| 37 | case "pending": |
| 38 | case "skipped": |
| 39 | return theme.color.muted; |
| 40 | case "attaching": |
| 41 | case "post-attach": |
| 42 | case "pre-creating": |
| 43 | return theme.color.info; |
| 44 | case "creating": |
| 45 | case "creating replacement": |
| 46 | case "created": |
| 47 | case "orphaning": |
| 48 | case "orphaned": |
| 49 | return theme.color.success; |
| 50 | case "updating": |
| 51 | case "adopting": |
| 52 | case "replacing": |
| 53 | case "replaced": |
| 54 | case "updated": |
| 55 | case "adopted": |
| 56 | return theme.color.warning; |
| 57 | case "deleting": |
| 58 | case "deleted": |
| 59 | return theme.color.danger; |
| 60 | case "running": |
| 61 | case "ran": |
| 62 | return theme.color.info; |
| 63 | case "fail": |
| 64 | return theme.color.danger; |
| 65 | default: |
| 66 | return undefined; |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | /** Settled states — the row will not change again. */ |
| 71 | export const isTerminalStatus = (status: ApplyStatus): boolean => |
| 72 | status === "created" || |
| 73 | status === "updated" || |
| 74 | status === "adopted" || |
| 75 | status === "deleted" || |
| 76 | status === "orphaned" || |
| 77 | status === "replaced" || |
| 78 | status === "ran" || |
| 79 | status === "skipped" || |
| 80 | status === "fail"; |
| 81 | |
| 82 | export const isInProgress = (status: ApplyStatus): boolean => |
| 83 | status === "attaching" || |
| 84 | status === "post-attach" || |
| 85 | status === "pre-creating" || |
| 86 | status === "creating" || |
| 87 | status === "creating replacement" || |
| 88 | status === "updating" || |
| 89 | status === "adopting" || |
| 90 | status === "deleting" || |
| 91 | status === "orphaning" || |
| 92 | status === "replacing" || |
| 93 | status === "running"; |