Skip to content

harness: status-bar git slot drops branch during a turn (shows @sha only) #659

Description

@btipling

Summary

The status-bar git slot (line 2, branch@sha[*]) loses the branch name while a turn is in flight and paints only @<short-sha>. Idle / post-turn it is the full branch@sha again.

Observed

  • Idle / after done: git slot is main@abc1234 (or whatever branch).
  • Mid-turn: same slot becomes @abc1234 — the @ and SHA stay, the branch prefix is gone.
  • Other slots (sandbox · cwd · context) stay painted. This is not a full pack clear.
  • Not a detached-HEAD workspace as a lasting state — the branch name comes back when the turn ends.

Likely seam

formatGitStatusSlot (lib/agent/statusProbe.ts) is exactly this string when branch is missing:

const branch = res.branch ?? '';
const sha = res.sha ? `@${res.sha}` : '';
return `${branch}${sha}${res.dirty ? '*' : ''}`;

probeGitStatus also deletes branch when rev-parse --abbrev-ref HEAD returns HEAD (detached).

Phase 2 live pack (#627) re-probes git mid-turn on every successful exec (and on meta_sandbox_switch). The 10 s cadence Busy-skips, so the mid-turn on-demand probe is the only refresh during the turn. A plausible race:

  1. Agent exec is still holding a git lock / mutating HEAD.
  2. Host on-demand probe runs rev-parse --abbrev-ref HEAD + --short HEAD in parallel.
  3. Branch command fails or returns HEAD → branch stripped; SHA still succeeds.
  4. Slot is replaced with @sha. Fail-soft is supposed to keep the last git value on probe failure, but a partial result ({ sha } with no branch) is treated as success and overwrites the honest branch@sha.

Goal

  • Mid-turn git slot keeps the last honest branch@sha[*] unless the probe returns a new real branch (or a real detached-HEAD we choose to show).
  • A SHA-only / HEAD-stripped probe must not clobber a previously painted branch.
  • Detached HEAD as a lasting workspace state can still omit the branch (today's HEAD reject) — but a transient mid-turn miss must not look like that.

Non-goals

  • Full git UI / checkout.
  • Changing STATUS_PROBE_MIN_INTERVAL_MS or the 10 s Busy-skip cadence.
  • DOM status chips.

Related

Suggested next: confirm whether the mid-turn @sha is a SHA-only probe overwrite vs a paint clip, then fail-soft unless branch is a real name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingharnessHarness / agent UIui

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions