Cleanup: shared queue badge states and a typed job class #107

Closed
opened 2026-10-08 23:56:59 +00:00 by crowmaki · 0 comments
Owner

Parent

#24

What to clean up

Two code-review findings left over from #52 (PR #106). Neither changes behaviour.

1. Badge labels are spelled out twice

takeBadge / TakeBadge in src/lib/scenes/takes.ts and jobBadge / JobBadge in src/lib/queue/summary.ts each define the same badges:

  • Held: amber
  • Finishing: accent
  • "Rendering N%" (or "Rendering…" before any progress): accent
  • Failed: red, with the error as the tooltip
  • Queued: plain

If a label or tone changes in one place, the Take tiles and the Queue panel / Shot rows will drift apart. Give the shared states one helper, and have both badge functions call it. The badge type, with its tone union, should be shared too.

2. The job class is converted to text by hand

In src-tauri/src/dto.rs, From<JobView> for JobDto turns JobClass into "image" | "draft" | "final" with a hand-written match. JobClass already derives Serialize with rename_all = "snake_case", so the strings are written down twice. In TypeScript, JobDto.class is a plain string.

Make JobDto.class a typed enum DTO (or reuse JobClass through specta), so the strings live in one place and the TypeScript type is the "image" | "draft" | "final" union. Regenerate the bindings with cargo test -p ai-studio --test smoke exports. Then check waitingGroups in src/lib/queue/summary.ts, which mixes the class with its own "run_next" group key.

Acceptance criteria

  • One definition of the shared badge states, used by both takeBadge and jobBadge. Existing badge tests still pass unchanged.
  • JobDto.class is typed in bindings.ts, and there is no hand-written class-to-string match in dto.rs.
  • cargo test --workspace --all-features, bun test src scripts and bun run check pass.

Blocked by

## Parent #24 ## What to clean up Two code-review findings left over from #52 (PR #106). Neither changes behaviour. ### 1. Badge labels are spelled out twice `takeBadge` / `TakeBadge` in `src/lib/scenes/takes.ts` and `jobBadge` / `JobBadge` in `src/lib/queue/summary.ts` each define the same badges: - Held: amber - Finishing: accent - "Rendering N%" (or "Rendering…" before any progress): accent - Failed: red, with the error as the tooltip - Queued: plain If a label or tone changes in one place, the Take tiles and the Queue panel / Shot rows will drift apart. Give the shared states one helper, and have both badge functions call it. The badge type, with its tone union, should be shared too. ### 2. The job class is converted to text by hand In `src-tauri/src/dto.rs`, `From<JobView> for JobDto` turns `JobClass` into `"image" | "draft" | "final"` with a hand-written `match`. `JobClass` already derives `Serialize` with `rename_all = "snake_case"`, so the strings are written down twice. In TypeScript, `JobDto.class` is a plain `string`. Make `JobDto.class` a typed enum DTO (or reuse `JobClass` through specta), so the strings live in one place and the TypeScript type is the `"image" | "draft" | "final"` union. Regenerate the bindings with `cargo test -p ai-studio --test smoke exports`. Then check `waitingGroups` in `src/lib/queue/summary.ts`, which mixes the class with its own `"run_next"` group key. ## Acceptance criteria - [ ] One definition of the shared badge states, used by both `takeBadge` and `jobBadge`. Existing badge tests still pass unchanged. - [ ] `JobDto.class` is typed in `bindings.ts`, and there is no hand-written class-to-string `match` in `dto.rs`. - [ ] `cargo test --workspace --all-features`, `bun test src scripts` and `bun run check` pass. ## Blocked by - #52
Sign in to join this conversation.
No description provided.