Skip to content

feat(hud): adaptive layout engine (Wave 1-D)#1473

Closed
JeremyDev87 wants to merge 2 commits into
feat/statusbar-wow-refactorfrom
feat/statusbar-wow-layout
Closed

feat(hud): adaptive layout engine (Wave 1-D)#1473
JeremyDev87 wants to merge 2 commits into
feat/statusbar-wow-refactorfrom
feat/statusbar-wow-layout

Conversation

@JeremyDev87
Copy link
Copy Markdown
Owner

Closes #1472
Stacked on #1465 (Wave 0 refactor — must merge first)

Summary

Introduces width-aware segment rendering primitives so the status bar never spills out of narrow terminals. Wave 1-D ships the hud_layout helpers; Wave 3 integrator will wire them into format_status_line.

New Module: lib/hud_layout.py

Primitive Purpose
SEGMENT_PRIORITY Canonical drop order (9 slots)
SACRED_PRIORITY = 1 face_version / mode_health never dropped
visible_len(s) East-Asian-aware column count (emoji/CJK = 2)
terminal_width(*, fallback) shutil-backed detection with safe fallback
shorten_model_label(name, *, compact) "Opus 4.6 (1M context)" → "Opus 4.6" / "Opus(1M)"
fit_segments(segments, width, *, separator) Priority-based drop-until-fit with hard-truncate fallback

Tests

33 new tests in test_hud_layout.py. 188/188 total pass.

  • visible_len: ASCII, CJK, emoji, mixed, empty, ANSI awareness note
  • terminal_width: zero/fallback/custom/real/exception paths
  • shorten_model_label: strip, keep, compact, single-word, empty, case-insensitive
  • fit_segments: all-fit, drop-low, sacred-preserved, empty-skip, hard-truncate, order preservation, highest-priority-first, custom separator, width=0, width=1, empty list, single-sacred
  • SEGMENT_PRIORITY: sacred entries, non-decreasing, full slot coverage, sacred constant, default separator

Wave 3 integration preview

Once merged, Wave 3 integrator will replace the inline segments = [...]; " | ".join(segments) in format_status_line with a call to fit_segments, passing terminal_width() as the budget.

Introduces width-aware segment rendering primitives so the status
bar never spills out of narrow terminals. Wave 1-D ships the layout
helpers; Wave 3 integrator wires them into format_status_line.

New lib/hud_layout.py:
- SEGMENT_PRIORITY canonical drop-order list (9 slots)
- SACRED_PRIORITY=1 threshold (face_version, mode_health never dropped)
- visible_len(s): East-Asian-aware column count
- terminal_width(*, fallback): shutil-backed detection with fallback
- shorten_model_label: "Opus 4.6 (1M context)" -> "Opus 4.6" / "Opus(1M)"
- fit_segments: drop-until-fit with hard-truncate fallback (U+2026)

33 new tests in test_hud_layout.py cover all helpers, edge cases
(empty, zero-width, sacred overflow, custom separator, CJK/emoji
width), and SEGMENT_PRIORITY ordering invariants.

188/188 tests pass (Golden 133 + Wave 0 22 + Wave 1-D 33).

Part of #1464 (Wave 0 statusbar refactor)
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codingbuddy-landing Canceled Canceled Apr 11, 2026 1:15pm

Combined Wave 0 polish items from the #1465/#1485 review cycle:

1. Narrow `except Exception` to `except ImportError` in the 3 lib
   fallback import blocks (qual-1465 HIGH-1). Real logic bugs
   (SyntaxError, NameError, AttributeError) inside lib modules now
   surface immediately instead of being silently swallowed by a
   catch-all.

2. Drop inline stub functions for format_rate_limits and
   _get_fresh_version (qual-1465 HIGH-2). Eliminates the signature
   drift between canonical lib definitions and in-file fallback stubs
   observed on the integrator branch (Wave 1-A plugin_json_file
   kwarg drift). The outer main() try/except still catches any runtime
   failure and emits the minimal safe output via the BUDDY_FACE
   constant.

3. Hoist hud_velocity and hud_cache_savings imports to module top as
   _format_velocity_segment and _format_cache_savings (perf-1485 H1).
   Eliminates ~0.47us sys.modules lookup per render. Integrator branch
   only - no-op on refactor/wave branches where the inline imports
   don't exist yet.

4. Bump next to 16.2.3 for GHSA-q4gf-8mx6-v5v3 (landing-security-check).
   Aligns eslint-config-next and updates setup.test.ts assertion.

Refs: qual-1465 HIGH-1/2, perf-1485 H1,
GHSA-q4gf-8mx6-v5v3
@JeremyDev87 JeremyDev87 force-pushed the feat/statusbar-wow-layout branch from e8e68f8 to 72ddb34 Compare April 11, 2026 13:11
@JeremyDev87 JeremyDev87 added statusbar-wave:1 Statusbar Wow bug fixes (Wave 1-A~1-D) feat labels Apr 11, 2026
@JeremyDev87 JeremyDev87 added the review:approved EVAL review 통과 (Critical/High = 0) label Apr 11, 2026
@JeremyDev87
Copy link
Copy Markdown
Owner Author

Superseded by #1485

This PR was part of a stacked PR structure (feat/statusbar-wow-refactor base) that was incompatible with the repo's rebase & merge policy — each sub-PR targeted an intermediate branch, not master.

All of this PR's commits have been consolidated into #1485 (now with base: master and a linear 12-commit history after rebase). The consolidated PR contains:

  • Wave 0 — de622cc refactor(hud): extract 9 modules
  • Wave 1-A — cdf0772 fix(hud): version resolution fallback
  • Wave 1-B — 0606698 fix(hud): session self-heal
  • Wave 1-C — 87b779a feat(hud): rate limit severity icons
  • Wave 1-D — 894f515 feat(hud): adaptive layout engine
  • Wave 2-A — 5e8389d feat(hud): breathing buddy face states
  • Wave 2-B — 78ec6c5 feat(hud): cost velocity indicator
  • Wave 2-C — a306920 feat(hud): cache savings badge
  • Wave 2-D — 0fb3d5c feat(hud): mode rainbow ANSI coloring
  • Wave 2-E — 8cd78b2 feat(hud): smart context bar
  • Wave 3 — 295f5c4 feat(hud): integrate Wave 2-B/2-C
  • Review iter1 — b330528 fix(hud,landing): narrow fallback imports + next 16.2.3

EVAL review results from this PR (all reviewers, iter1 converged → Critical=0, High=0) already applied in #1485.

Closing as superseded. Use #1485 with GitHub's Rebase and merge button to land all 12 commits linearly on master.

@JeremyDev87 JeremyDev87 deleted the feat/statusbar-wow-layout branch April 11, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hud HUD / statusLine 영역 feat plugin packages/claude-code-plugin review:approved EVAL review 통과 (Critical/High = 0) statusbar-wave:1 Statusbar Wow bug fixes (Wave 1-A~1-D)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant