Skip to content

refactor(web): consolidate StatusBadge import path + flatten color ternary (BEN-56)#58

Open
benSepanski wants to merge 1 commit intomainfrom
claude/nifty-bardeen-93lM1
Open

refactor(web): consolidate StatusBadge import path + flatten color ternary (BEN-56)#58
benSepanski wants to merge 1 commit intomainfrom
claude/nifty-bardeen-93lM1

Conversation

@benSepanski
Copy link
Copy Markdown
Owner

Context

BEN-56 ("Code quality") asks for DRY / style cleanups. While reviewing
src/web/, the StatusBadge helper had two consumer paths: most files
imported from ./shared.js, but RunDetail.tsx and Search.tsx imported it
from ./Dashboard.js, which existed only because Dashboard.tsx re-exported
it. Two paths for one helper is a DRY hazard.

TL;DR

Drop the StatusBadge re-export from Dashboard.tsx, point all consumers at
./shared.js, and replace its 7-deep nested ternary with a lookup map.

Summary

  • src/web/Dashboard.tsx: remove export { StatusBadge } from "./shared.js" re-export.
  • src/web/RunDetail.tsx + src/web/Search.tsx: import StatusBadge from ./shared.js directly (matches MetricsPanel.tsx, Dashboard.tsx).
  • src/web/shared.tsx: replace the nested ternary in StatusBadge with a STATUS_BADGE_COLORS: Record<string, string> lookup + named default — same rendering, easier to extend with new run statuses.
  • No behaviour change. Class names, ARIA, and the running pulse indicator are unchanged.

Demo

n/a — internal refactor, no user-visible surface.

Alternatives

  • Leave the re-export and just delete the duplicate by adding a lint rule
    that bans re-exporting from feature files. Rejected: the rule would have
    exactly one trigger today; a one-line refactor is cheaper.
  • Keep the nested ternary. Rejected: the structure encodes status → color
    mapping, which is data, and the ternary form makes adding cancelled
    vs. rate_limited non-obvious — see how cancelled and the unknown
    fallback shared the same arm.
  • Move StatusBadge color tokens into a Tailwind plugin / theme file.
    Deferred: the codebase doesn't have one and this PR isn't the place to
    add framework infrastructure for one helper.

Test Plan

  • pnpm all — typecheck + fmt:check + lint + test (151) + eval (5)
  • pnpm build:web — not run; touched no bundling, no new deps
  • Manual: grep -rn "from \"./Dashboard" src/web/ — only App.tsx (which imports Dashboard itself) remains.

Generated by Claude Code

…rnary (BEN-56)

`Dashboard.tsx` re-exported `StatusBadge` from `./shared.js` solely to support
RunDetail.tsx + Search.tsx importing it from there. Two import paths for one
helper is a DRY hazard. Make every consumer import from `./shared.js` and
drop the re-export.

While in `shared.tsx`, replace the 7-deep nested ternary in StatusBadge with
a `STATUS_BADGE_COLORS` lookup map + default — same behaviour, easier to
extend with a new run status.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants