Skip to content

feat(dev): show the source branch on dev windows - #52

Merged
titan-ron merged 2 commits into
mainfrom
titan/local-dev-branch-indicator-f84abc
Aug 12, 2026
Merged

feat(dev): show the source branch on dev windows#52
titan-ron merged 2 commits into
mainfrom
titan/local-dev-branch-indicator-f84abc

Conversation

@titan-ron

@titan-ron titan-ron commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Why

Running npm run dev from several worktrees at once gives you identical Cockpit windows — there is no way to tell which window belongs to which branch.

What

Dev builds now surface the source checkout's branch in two places:

  • Top banner — a 28px branch-tinted mono banner row spanning the full window width, naming the branch. It doubles as a window drag region (branch text stays selectable via no-drag) and absorbs the macOS traffic-light clearance, so .tree-top sheds its 40px pad underneath it.
  • Window titleCockpit — <branch>, so Mission Control / ⌘-Tab / the Dock disambiguate too (the renderer re-applies it because index.html's <title> would otherwise reset it on load).

How

  • Branch resolution is worktree-aware: follow a .git pointer file (gitdir: …) when present, then parse HEAD (ref: refs/heads/…, or an abbreviated hash when detached). The pure parsers live in dev-window.ts — the module is deliberately IO-free and unit-tested; the IO glue stays in index.ts.
  • The branch reaches the renderer as a ?devBranch= query param appended to the dev-server URL — no IPC surface growth for a dev-only affordance. Packaged apps never read the repo, never set the param, and keep the plain Cockpit title.
  • Banner layout rides the existing .app grid: the row spans both columns via grid-column: 1 / -1, activated with .app:has(.dev-banner) so the packaged layout is untouched.
  • design-system/cockpit/MASTER.md and pages/sidebar.md document the new element.

Validation

  • npm run typecheck clean; npm test 198/198 (unit tests for the two parsers, component tests for banner presence/absence).
  • Verified live via HMR in a running dev instance alongside four other dev instances (ports 5173–5176 already taken).

@github-code-quality

github-code-quality Bot commented Aug 12, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/unit

The overall coverage in commit 5906512 in the titan/local-dev-bran... branch remains at 61%, unchanged from commit d2e6bc2 in the main branch.

TypeScript / code-coverage/component

The overall coverage in commit 5906512 in the titan/local-dev-bran... branch remains at 48%, unchanged from commit d2e6bc2 in the main branch.

Show a code coverage summary of the most impacted files.
File main d2e6bc2 titan/local-dev-bran... 5906512 +/-
src/renderer/src/DevBanner.tsx 0% 100% +100%

Updated August 12, 2026 21:40 UTC

Parallel `npm run dev` instances from different worktrees are
indistinguishable. Dev builds now resolve the checkout's branch
(worktree-aware .git pointer + HEAD parse, IO-free in dev-window.ts),
brand the window title "Cockpit — <branch>", and pass the branch to
the renderer as a ?devBranch= query param on the dev-server URL — no
IPC surface for a dev-only affordance. The sidebar shows it as a
branch-blue mono chip next to the zoom chip, namespace prefix receded,
full name in the tooltip. Packaged apps never carry the param.
The chip was easy to miss in a busy tree-top. The branch now renders as
a 28px branch-tinted banner row spanning the window top — impossible to
confuse two worktree windows. The banner doubles as a drag region and
absorbs the traffic-light clearance, so .tree-top sheds its 40px pad
under it. Packaged apps never render it.
@titan-ron
titan-ron force-pushed the titan/local-dev-branch-indicator-f84abc branch from 9c3a57d to 5906512 Compare August 12, 2026 21:39
@titan-ron
titan-ron merged commit 4f399c6 into main Aug 12, 2026
5 checks passed
@titan-ron
titan-ron deleted the titan/local-dev-branch-indicator-f84abc branch August 12, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant