Skip to content

fix(git): show branch name for SSH/container agents in header#1125

Open
pedramamini wants to merge 1 commit into
mainfrom
1124-ssh-container-branch-name-header
Open

fix(git): show branch name for SSH/container agents in header#1125
pedramamini wants to merge 1 commit into
mainfrom
1124-ssh-container-branch-name-header

Conversation

@pedramamini

@pedramamini pedramamini commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

closes #1124

Problem

When an agent runs inside a container over SSH (the reporter's "vssh" setup), the branch name was missing next to the agent name in the main panel header. Only the SSH remote / sandbox name (e.g. HARNESS-SANDBOX) was shown. For local agents the branch name appears as expected.

Root cause

In MainPanelHeader.tsx, the header pill is an either/or:

  • When sessionSshRemoteConfig.enabled && sshRemoteName is set, it renders an SSH host pill (Server icon + uppercase remote name) that replaces the GIT/branch badge entirely.
  • Otherwise it renders the git badge (GitBranch icon + gitInfo.branch).

So any SSH-backed git repo lost the inline branch name. The branch was only available in the host pill's hover tooltip (SSH Remote: <name> (<branch>)), confirming the data is fetched fine over SSH - it just wasn't rendered.

Fix

Render a dedicated branch badge next to the SSH host pill for SSH-backed git repos. It's styled like the existing local git badge (orange GitBranch + branch name, header-git-branch-text so it still collapses at narrow widths) and reuses the same click-to-open-git-log behavior. Non-git SSH agents are unaffected (no badge). Local agents are unchanged.

Result for a container/SSH git agent: [🖧 HARNESS-SANDBOX] [⎇ main] instead of just [🖧 HARNESS-SANDBOX].

Tests

Added two cases to MainPanelHeader.test.tsx:

  • branch name renders alongside the SSH pill for a remote git agent
  • no branch badge for a non-git SSH agent

All 21 header tests pass. Type-check is clean for the changed files (only the repo's pre-existing @codemirror/* module-resolution errors remain, unrelated to this change).

Summary by CodeRabbit

  • New Features

    • Improved the main panel header to better show SSH remote information and branch status together.
    • Added a branch badge for SSH-backed git sessions that opens the git log and refreshes status when clicked.
  • Bug Fixes

    • Fixed an issue where non-git SSH sessions could incorrectly show a git branch badge.
    • Updated hover and focus behavior so tooltips work more reliably in the SSH/remote area.

The main panel header rendered an SSH host pill (the remote name) that
fully replaced the GIT/branch badge whenever a session ran on an SSH
remote. For agents running inside a container over SSH this meant the
branch name disappeared - only the remote/sandbox name was shown - even
though the branch is fetched fine over SSH and was already available in
the pill's hover tooltip.

Render a dedicated branch badge next to the SSH host pill for SSH-backed
git repos, styled like the local git badge and reusing the same
click-to-open-git-log behavior, so remote/container agents surface the
branch the same way local agents do.

closes #1124
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7d336316-96bc-44a3-b0ae-934e1bb439c1

📥 Commits

Reviewing files that changed from the base of the PR and between 38eb216 and 7dffda6.

📒 Files selected for processing (2)
  • src/__tests__/renderer/components/MainPanel/MainPanelHeader.test.tsx
  • src/renderer/components/MainPanel/MainPanelHeader.tsx

📝 Walkthrough

Walkthrough

MainPanelHeader is updated to display a branch-name badge alongside the SSH host pill when an agent runs inside an SSH/container session that is also a git repo. The SSH pill area is wrapped in a new div carrying gitTooltip event handlers, and a conditional button renders the branch name (falling back to 'GIT') and opens the git log on click. Two regression tests are added to cover both the git and non-git SSH cases.

Changes

SSH Git Branch Badge in MainPanelHeader

Layer / File(s) Summary
SSH pill refactor and branch badge button
src/renderer/components/MainPanel/MainPanelHeader.tsx
Wraps the SSH pill in a div with gitTooltip mouse/focus event handlers and new layout classes. Adds a conditional button that renders gitInfo?.branch || 'GIT' in orange styling when SSH remote config is enabled and activeSession.isGitRepo is true; click handler calls refreshGitStatus() and setGitLogOpen?.(true).
Regression tests for SSH + git badge rendering
src/__tests__/renderer/components/MainPanel/MainPanelHeader.test.tsx
Adds a test asserting both SSH remote name and git branch are visible for SSH git-backed sessions, and a second test asserting the SSH remote name is visible but the GIT badge is absent for non-git SSH sessions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hopping through SSH tunnels with glee,
The branch name was hiding — now all can see!
A little orange badge, bright as can be,
Git info for containers, finally free.
No more mystery for vssh and me! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: showing branch names for SSH/container agents in the header.
Linked Issues check ✅ Passed The changes address the reported SSH/container bug by rendering the branch badge next to the SSH pill and preserving local behavior.
Out of Scope Changes check ✅ Passed The diff stays focused on the header fix and targeted tests, with no obvious unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1124-ssh-container-branch-name-header

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a regression where agents running inside SSH/container environments lost the branch name display in the header — only the SSH remote pill was shown, while local agents display an orange branch badge. The fix adds a dedicated branch badge rendered alongside the SSH host pill for git-backed SSH sessions, reusing existing styling and click behavior.

  • MainPanelHeader.tsx: The outer pill wrapper gains flex items-center gap-2, and a new branch badge (GitBranch icon + header-git-branch-text span) is conditionally rendered when sessionSshRemoteConfig.enabled && sshRemoteName && isGitRepo, matching the local-agent badge styling exactly.
  • MainPanelHeader.test.tsx: Two regression tests are added — one asserting both the remote name and branch appear for a git SSH agent, and one asserting no branch badge appears for a non-git SSH agent.

Confidence Score: 5/5

Safe to merge — the change is purely additive, limited to one conditional block in the header component, and leaves all existing rendering paths untouched.

The fix is small and well-contained: it adds one new branch badge element behind the same condition used by the SSH host pill, reuses existing styles and click handlers, and has no effect on local-agent or non-git paths. Two targeted regression tests cover both the git and non-git SSH cases. The only observation is a now-redundant branch name in the SSH pill's native tooltip title, which is cosmetic and harmless.

No files require special attention.

Important Files Changed

Filename Overview
src/renderer/components/MainPanel/MainPanelHeader.tsx Adds a branch badge alongside the SSH host pill for git-backed SSH sessions; wrapper gains flex layout. Logic is correct and consistent with the existing local-agent branch badge.
src/tests/renderer/components/MainPanel/MainPanelHeader.test.tsx Two new regression tests cover the SSH+git and SSH+non-git cases; both tests are well-scoped and match the new rendering conditions exactly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Render header pill area] --> B{SSH enabled AND sshRemoteName set?}
    B -- Yes --> C[Render SSH host pill 🖧 REMOTE-NAME]
    B -- No --> D[Render local badge]
    D --> E{isGitRepo?}
    E -- Yes --> F[🌿 branch or GIT]
    E -- No --> G[LOCAL]
    C --> H{isGitRepo?}
    H -- Yes --> I[Render branch badge 🌿 branch or GIT]
    H -- No --> J[No branch badge]
    I --> K[Hover outer div → git tooltip / Click either pill → git log]
    F --> K
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Render header pill area] --> B{SSH enabled AND sshRemoteName set?}
    B -- Yes --> C[Render SSH host pill 🖧 REMOTE-NAME]
    B -- No --> D[Render local badge]
    D --> E{isGitRepo?}
    E -- Yes --> F[🌿 branch or GIT]
    E -- No --> G[LOCAL]
    C --> H{isGitRepo?}
    H -- Yes --> I[Render branch badge 🌿 branch or GIT]
    H -- No --> J[No branch badge]
    I --> K[Hover outer div → git tooltip / Click either pill → git log]
    F --> K
Loading

Comments Outside Diff (1)

  1. src/renderer/components/MainPanel/MainPanelHeader.tsx, line 161 (link)

    P2 Redundant branch name in SSH pill tooltip

    Now that the branch is shown in its own dedicated badge, the parenthetical (branch) inside the SSH host pill's native title tooltip is redundant. It can also diverge from what the badge displays: if gitInfo hasn't loaded yet the pill shows no branch in the tooltip while the badge shows "GIT". Consider simplifying to `SSH Remote: ${sshRemoteName}`.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix(git): show branch name for SSH/conta..." | Re-trigger Greptile

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.

Bug: Branch name missing for agents in container over SSH (vssh)

1 participant