Skip to content

Cosmetic: Fix the checked-out branch badge being dim and never updating - #697

Merged
hannesa2 merged 2 commits into
masterfrom
refresh-the-checked-out-badge
Sep 21, 2026
Merged

hannesa2 merged 2 commits into
masterfrom
refresh-the-checked-out-badge

Conversation

@goneng

@goneng goneng commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Make the sidebar's checked-out badge show the state the window is actually
in, rather than the one it happened to be in when the row was built, and
give its two states a look that tells them apart.

How We Got Here

Found while chasing why the UI screenshot comparison reports differences
on pull requests that change nothing visible (#693). Two back-to-back
runs of the screenshot tests, same commit and same repository state,
produced a badge that was grey in one and blue in the other.

  • Refresh the badge when its window becomes or stops being the main
    window. Nothing in the app observed window state at all, and the badge
    is a bitmap baked at the moment the row is configured. The first
    sidebar reload runs from awakeFromNib, before the window is main, so
    the badge baked grey and stayed grey until some unrelated reload
    happened to rebuild it. Which side of the shutter that landed on is
    the difference above.
  • Give the checkmark the highlight color when its row is emphasized in
    an active window. A row is only emphasized while its window is key, so
    the key-window branch this replaces could never be taken by the
    selected row and the checkmark was always dimmed.

The two belong together: after the second change isMainWindow is the
only window signal the control reads, so the observers added by the
first cover all of it.

Beyond the screenshots, this is visible in ordinary use: the badge does
not dim when GitX goes to the background, nor light up when it comes
back, for any row that is not the selected one.

Making The Inactive State Actually Look Inactive

Fixing the refresh exposed a second problem: the badge now updated on
losing focus, but barely changed when it did. The active and inactive
capsule colors turned out to have the same brightness, 0.3972 against
0.3987 in relative luminance, so going inactive changed only the hue.

  • Darken the inactive capsule, a 22% drop in relative luminance, so an
    inactive badge reads as dim rather than merely as less blue.
  • Knock the checkmark out of the capsule while the window is inactive,
    leaving it hollow so the row behind shows through it. Painting the
    checkmark the sidebar's own color was the obvious alternative and is
    wrong: the sidebar is 246 and a selected row is 220, so a fixed color
    matches on an unselected row and reads as a pale checkmark on a
    selected one.

The two are linked. The hole is only visible while the capsule differs
from what shows through it, which puts a floor under how light the
capsule can go. Matching the capsule to the selection color, which would
be the natural next step, makes the badge vanish outright on a selected
row: same color, and a checkmark that is a hole rather than a shape.

Expected Behavior (and Look)

  1. Click a branch row in the sidebar.
    The checked-out row's capsule turns white -
    the checkmark inside should be blue, not grey.
    image
  2. Click into the history list.
    Badge returns to blue capsule with white checkmark.
    image
  3. Switch to another app, then back.
    The badge should dim and re-light. (Master does neither.)
    The capsule goes to a darker grey and the checkmark becomes a hole.
    image
  4. Select a different branch so the checked-out row is unselected, then
    switch apps again (the case AppKit never rescued, where Master is
    most obviously stuck).
    image

The images in 3 and 4 were taken before the hollow checkmark and the
softer capsule, so they show the right states in the older colors.

Test plan

  • Every change here was run with the fix stashed out and again with it
    applied. In each case only the case under test failed without it,
    while the controls passed in both runs.
  • make unit-test passes: 158 tests, no failures.
  • The color tests use a window double reporting itself main, a test
    process having no way to make a window genuinely main; the refresh
    tests assert the badge is rebuilt rather than what color it becomes,
    for the same reason.
  • The dim and hollow states are asserted on measurements rather than on
    fixed colors: one test computes relative luminance and requires the
    inactive capsule to be at least 20% darker, another renders both
    badges and requires the inactive one to carry more transparent pixels.

@goneng goneng changed the title Fix the checked-out branch badge being dim and never updating Cosmetic: Fix the checked-out branch badge being dim and never updating Sep 20, 2026
@goneng goneng added the bugfix label Sep 20, 2026
@goneng
goneng marked this pull request as ready for review September 20, 2026 21:56
@goneng
goneng force-pushed the refresh-the-checked-out-badge branch from 8d3c004 to 4d0e819 Compare September 21, 2026 05:25
Refresh the sidebar's checked-out badge whenever its window becomes or
stops being the main window, so it shows the state the window is in
rather than the one it happened to be in when the row was built.

- Observe the window's main-state notifications from the cell and
  re-derive the badge on each change.
- Re-derive it on entering a window too, which is what the first sidebar
  reload misses: that reload runs from awakeFromNib, before the window
  is main.
- Cover the wiring rather than the colour, a test process having no way
  to make a window genuinely main.
@goneng
goneng force-pushed the refresh-the-checked-out-badge branch 2 times, most recently from 975f77d to a9ef30c Compare September 21, 2026 07:05
@goneng
goneng marked this pull request as draft September 21, 2026 07:08
@goneng
goneng force-pushed the refresh-the-checked-out-badge branch from a9ef30c to d6b5770 Compare September 21, 2026 07:12
The badge has a colour for each state it can be in, but none of them
read as different: the checkmark stayed dim on the row just selected,
and the inactive colour matched the active one in brightness, so
losing focus changed only the hue.

- Decide the checkmark colour from the window being main, the way the
  capsule around it already does.
- Drop the key-window branch this replaces: a row is only emphasized
  while its window is key, so the dimmed result was the only one the
  selected row could reach.
- Darken the inactive colour, a 22% drop in relative luminance, so an
  inactive badge reads as dim rather than merely as less blue.
- Knock the checkmark out of the capsule while the window is inactive,
  leaving it hollow. Painting it the sidebar's own colour would match
  only on an unselected row, and read as a pale checkmark on a
  selected one.
@goneng
goneng force-pushed the refresh-the-checked-out-badge branch from d6b5770 to c883fcf Compare September 21, 2026 07:22
@goneng
goneng marked this pull request as ready for review September 21, 2026 07:23
@goneng
goneng requested a review from hannesa2 September 21, 2026 07:26
@hannesa2

Copy link
Copy Markdown
Contributor

Screenshot differs: emulatorApi=arm64 with 1 screenshot(s)

setpoint (old) | diff | actual screenshot (new)

staging-view.pngscreenshot

@hannesa2 hannesa2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, it comes even with a test

@hannesa2
hannesa2 merged commit 1fdb038 into master Sep 21, 2026
3 checks passed
@hannesa2
hannesa2 deleted the refresh-the-checked-out-badge branch September 21, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants