Skip to content

refactor(fleet-ui): split tab_strip into mod/layout/render and extract render_pill#156

Merged
NagyVikt merged 1 commit into
mainfrom
agent/refactor-tab-strip-split
May 16, 2026
Merged

refactor(fleet-ui): split tab_strip into mod/layout/render and extract render_pill#156
NagyVikt merged 1 commit into
mainfrom
agent/refactor-tab-strip-split

Conversation

@NagyVikt
Copy link
Copy Markdown
Contributor

Summary

  • Convert fleet-ui/src/tab_strip.rs (439 lines) into a module folder:
    • tab_strip/mod.rs (251 lines) — Tab, TabHit, TabStrip struct, public API, tests
    • tab_strip/layout.rs (119 lines) — PillSpec, counter snapshot, format helpers, pill geometry
    • tab_strip/render.rs (103 lines) — background/logo/live-chip painters + extracted render_pill
  • Extract render_pill(frame, x, y, PillSpec) -> TabHit from the inlined pill loop
  • render() shrinks from ~135 lines to ~50 lines of orchestration

Behavior

Public API of TabStrip, Tab, TabHit, COUNTERS_PATH unchanged. Rendering identical.

Test plan

  • cargo check --workspace — clean (only pre-existing warnings remain)
  • cargo build -p fleet-ui — clean
  • cargo test -p fleet-ui --lib tab_strip — 6/6 pass

🤖 Generated with Claude Code

…helper

Splits the 439-line tab_strip.rs into a tab_strip/ module folder so the
single pill loop can call a dedicated render_pill helper instead of
inlining 30+ lines of span construction and hit-test bookkeeping per
iteration. Public API (TabStrip, Tab, TabHit, COUNTERS_PATH) is
unchanged, all 6 existing tests still pass, and rendering output is
identical.

- tab_strip/mod.rs: public types + render orchestrator
- tab_strip/layout.rs: CounterSnapshot, build_pills, natural width,
  format_clock, format_pill_label, render_counter
- tab_strip/render.rs: paint_background, paint_logo_chip,
  paint_live_chip, render_pill
@NagyVikt NagyVikt merged commit b559229 into main May 16, 2026
2 checks passed
@NagyVikt NagyVikt deleted the agent/refactor-tab-strip-split branch May 16, 2026 15:13
NagyVikt added a commit that referenced this pull request May 16, 2026
…166)

Operator review flagged three drift sources where per-binary code
disagreed with the canonical fleet-ui/data layer. This compound PR
unifies all three on the shared crates and deletes a stranded library.

(a) Palette migration
- Per-binary `ios_page_design.rs` modules in fleet-watcher and
  fleet-waves declared their own `IOS_BLUE/GREEN/RED/ORANGE`
  (watcher) and `ACCENT/SUCCESS/DANGER/WARNING` (waves) constants
  using iOS *Light* system values (#007aff, #34c759, #ff3b30, #ff9500).
- These dashboards render on a dark TUI surface, so iOS Dark variants
  are correct. `fleet-ui::palette` already exposed the canonical
  Dark-mode constants (#0a84ff, #30d158, #ff453a, #ff9f0a). Each
  binary now `use`s the palette names and aliases them in-place.
- Local surface tones (BG / SURFACE / TEXT / *_SOFT) stay in each
  binary because the mock pages intentionally use a deeper dark
  surface than the production board.
- Extended the `palette_hex_parity` test to lock in every constant
  the per-binary modules now import via `palette::*` so future drift
  fails the test rather than the dashboard.

(b) Renderer-polish deletion
- `rust/fleet-renderer-polish/` was library-only, unadopted, and
  declared a third copy of the same iOS-named colors (drift source).
- `git rm -r`d the whole crate; no workspace crate depended on it
  (verified via grep). The `fleet-*` glob in workspace `Cargo.toml`
  drops it automatically.

(c) is_live / is_capped unification
- `WorkerRow::is_live` was already on the data layer, but
  `fleet-state/src/ios_page_design.rs::Summary::from_rows` recomputed
  "capped" inline as `row.five_h_pct >= 100 || matches!(row.state,
  Some(PaneState::Capped))`. Any other dashboard that wanted the same
  tally would have re-derived this rule.
- Lifted that predicate to `WorkerRow::is_capped(&self) -> bool` with
  a docstring spelling out the two-signal contract (cap-pool % crossing
  the line OR pane classifier returning Capped). Migrated
  fleet-state's Summary to call `row.is_capped()`.

Verification
- `cargo check --workspace` clean.
- `cargo test --workspace --exclude fleet-ui` all green; `cargo test
  -p fleet-ui --lib` all green (palette hex-parity guard included).
- fleet-ui has a pre-existing test-only compile error in
  `tests/tab_strip_snapshot.rs` referencing the removed
  `fleet_ui::tab_strip` module (from PR #156's mod-folder split) —
  untouched by this PR.
- TestBackend snapshot output is text-only, so accent-color migration
  does not affect any snapshot fixture.

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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.

1 participant