Skip to content

Fix cramped card title when commit grid is wide#75

Merged
0101 merged 5 commits into
mainfrom
fix-cramped-title
May 20, 2026
Merged

Fix cramped card title when commit grid is wide#75
0101 merged 5 commits into
mainfrom
fix-cramped-title

Conversation

@0101
Copy link
Copy Markdown
Owner

@0101 0101 commented May 20, 2026

Problem

When a worktree has many commits, the commit grid visualization and diff stats (+1735 -660) consume all horizontal space in the card header, causing the branch name to shrink until it completely disappears — showing only "de..." or "embedd..." instead of a readable title.

Fix

Add a FitOrHide React component that uses a ResizeObserver to detect when the card header overflows, and progressively hides metrics that don't fit.

Structural change: wrap the status dot + branch name + metrics in a .header-info flex container with overflow: hidden. Buttons remain outside so they're always top-right.

Progressive hiding: FitOrHide takes a list of items ordered by priority (lowest first). When the parent overflows, items are hidden from first to last:

  1. Commit grid hidden first (it's wider)
  2. Diff stats (+/- counts) hidden last (compact, stays visible longer)
  3. Title always visible with min-width: 100px

Key details:

  • FitOrHide uses ResizeObserver on the parent element to re-check on resize
  • Each render re-checks overflow via useEffect to handle content changes
  • Binary show/hide — no partial clipping (items either show fully or not at all)
  • Zero commits → Html.none → no second row or empty wrappers

Changes

  • ArchiveViews.fs — add FitOrHide component with ResizeObserver interop, extract commitGridElement/diffStatsElement helpers, add workMetricsItems for progressive hiding
  • App.fs — wrap dot + title + FitOrHide(metrics) in .header-info div in both card types
  • index.html — add .header-info, .fit-or-hide, .fit-or-hide > span CSS rules; set .branch-name min-width: 100px inside header-info

0101 added 5 commits May 20, 2026 13:48
Add FitOrHide React component that uses ResizeObserver to detect
when the header-info container overflows. When metrics (commit grid
+ diff stats) don't fit alongside the title and buttons, they're
hidden entirely rather than partially clipping.

Structure: wrap dot + title + metrics in a .header-info flex container
with overflow:hidden. Buttons remain outside so they're always visible.
The title gets min-width:80px to stay readable.
FitOrHide now takes a list of items and progressively hides them
from first (lowest priority) to last (highest priority). The commit
grid is hidden first since it's wider; diff stats (+/-) stay visible
longer since they're compact and informative.

Extract commitGridElement and diffStatsElement helpers shared by
both workMetricsView (archive card) and workMetricsItems (FitOrHide).
The commit grid now hides earlier, giving the branch name more
visible characters before truncation kicks in.
Tests now use .commit-grid selector instead of .work-metrics (removed),
and check DOM attachment instead of visibility since FitOrHide may hide
overflow items in narrow viewports.
Extract relativeTime, FitOrHide, workMetricsView, and workMetricsItems
into Components.fs. ArchiveViews.fs now contains only archive-specific
code (Msg, update, archiveCard, archiveSection).

Add module-cohesion review rule to catch code placed in unrelated modules.
@0101 0101 merged commit ea8acd8 into main May 20, 2026
1 check passed
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