Repository navigation
fix(host-service): resolve Against-base diff to local branch when origin/<branch> missing - #6237
andyst-dev wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Mergeability Score: ⚪ Minimal · up to This localized fix resolves comparisons against unpushed local branches while preserving remote-branch behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1
✨ Finishing Touches
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. Comment |
Greptile SummaryThis PR fixes against-base comparisons for stacked workspaces whose base exists only as an unpushed local branch.
Confidence Score: 5/5The PR appears safe to merge, with the intended local-base fallback covered while preserving remote-ref precedence. The new resolution path selects an existing local branch only when no configured upstream or matching origin ref exists, and no concrete blocking or non-blocking defect remains.
|
| Filename | Overview |
|---|---|
| packages/host-service/src/trpc/router/git/utils/git-helpers.ts | Adds remote-first ref detection and a local-only branch fallback without changing configured-upstream behavior. |
| packages/host-service/src/trpc/router/git/utils/git-helpers.integration.test.ts | Adds real-repository coverage for local-only branch resolution and remote-ref precedence. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Resolve base branch] --> B{Configured upstream?}
B -->|Yes| C[Use upstream ref and fetch target]
B -->|No| D{origin/branch exists?}
D -->|Yes| E[Use origin/branch and fetch target]
D -->|No| F{Local branch exists?}
F -->|Yes| G[Use local branch with no fetch]
F -->|No| H[Preserve origin/branch fallback]
Reviews (1): Last reviewed commit: "fix(host-service): resolve Against-base ..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Architecture diagram
sequenceDiagram
participant UI as Changes Tab (UI)
participant API as resolveBaseComparison
participant Git as Git Client
participant LocalRefs as refs/heads/*
participant RemoteRefs as refs/remotes/origin/*
Note over UI,RemoteRefs: NEW: Resolve Against-base diff for stacked workspace
UI->>API: request base comparison for branch
API->>Git: check for configured upstream
alt upstream configured
API->>API: return upstream baseRef + fetchTarget
else no upstream configured
API->>Git: rev-parse --verify refs/remotes/origin/<branch>
Git->>RemoteRefs: check remote ref existence
alt remote ref exists
RemoteRefs-->>Git: confirm exists
Git-->>API: exists
API->>API: return remote baseRef + fetchTarget
else remote ref absent
Git-->>API: not found
API->>Git: rev-parse --verify refs/heads/<branch>
Git->>LocalRefs: check local ref existence
alt local ref exists
LocalRefs-->>Git: confirm exists
Git-->>API: exists
API-->>UI: return local baseRef, fetchTarget=null
else local ref absent
API-->>UI: return fallback origin/<branch>
end
end
end
Note over UI: NEW: Local base branch renders real diff<br>instead of silent empty result
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Thanks — both P3s are addressed in
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Thanks - both findings are addressed in
Coverage now includes concurrent three-remote probing with Validation:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/host-service/src/trpc/router/git/utils/git-helpers.test.ts`:
- Line 31: Replace the setTimeout-based delay in the raw test helper with a
microtask yield using Promise.resolve(), preserving the activeProbes increment
and concurrency assertion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c738d1e-f0c8-4c94-a3c7-e550cf31219f
📒 Files selected for processing (3)
packages/host-service/src/trpc/router/git/utils/git-helpers.integration.test.tspackages/host-service/src/trpc/router/git/utils/git-helpers.test.tspackages/host-service/src/trpc/router/git/utils/git-helpers.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/host-service/src/trpc/router/git/utils/git-helpers.ts
- packages/host-service/src/trpc/router/git/utils/git-helpers.integration.test.ts
|
Good catch - fixed in The concurrency helper now yields with Validation:
|
5f2e203 to
01af228
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
01af228 to
b4ff1eb
Compare
…anch A stacked workspace whose base is another local branch that was never pushed rendered an empty Changes tab even though a real committed diff existed. `resolveBaseComparison` looked the base up as `<remote>/<branch>` and, with no upstream configured, silently fell through to `origin/<branchName>` - a ref that does not exist for an unpushed local base, and a diff against a missing ref is empty (#5298). Now: probe every remote for `refs/remotes/<remote>/<branch>` (origin first, since the old fallback hardcoded it) and use the first match, then fall back to the local `refs/heads/<branch>` with `fetchTarget: null` - there is nothing to fetch for a local branch - before the unchanged last-resort fallback. Workspace branches are created with `--no-track`, so `resolveUpstream` returns null for this case and main still returns `origin/<branchName>`: the bug is live in main, not superseded. Rebased onto current main (was 1378 commits behind). Integration tests build real on-disk repos and cover the missing-remote-ref path.
b4ff1eb to
8e651c0
Compare
Fixes #5298
Problem
For a stacked workspace whose base is another local branch that has never been pushed, the Changes tab rendered empty — even though a real, committed, non-empty diff existed against that base.
resolveBaseComparisonresolved the "Against base" view via the remote reforigin/<base>and, when no upstream was configured, silently fell through toorigin/<branch>— a ref that does not exist for an unpushed local base. The diff against a missing ref is empty, so the UI showed nothing.Fix
In
resolveBaseComparison, when no upstream is configured:refs/remotes/origin/<branch>exists →baseRef: origin/<branch>+ fetch target (unchanged behavior);refs/heads/<branch>exists (local-only base) →baseRef: <branch>withfetchTarget: null(there is nothing to fetch for a local branch);Validation
Two integration tests against real on-disk repos (same suite as the existing
resolveBaseComparisontests):Changestab is empty when a workspace's base branch is a local-only, unpushed branch #5298 repro): base branch checked out locally, never pushed → resolves tobaseRef: "feature/stacked",fetchTarget: null;refs/remotes/origin/featureexists → still prefersorigin/featurewith its fetch target.bun teston git-helpers.integration.test.ts: 22/22 pass ·tsc --noEmit: 0 errors · Biome: clean.Summary by cubic
Fixes an empty Changes tab for stacked workspaces by resolving the “Against base” diff to a real ref when
origin/<branch>is missing. Previously we fell back toorigin/<branch>and showed an empty diff; now we probe remotes and use a remote match (preferorigin), otherwise the local branch, so the diff shows actual changes. Addresses #5298.resolveBaseComparison: probe all remotes in parallel; deterministically prioritizeoriginregardless of remote order; if no remote ref exists butrefs/heads/<branch>does, return the local branch withfetchTarget: null.originremotes (fork workflows) and retains preference fororigin/<branch>when both remote and local refs exist.Changestab is empty when a workspace's base branch is a local-only, unpushed branch #5298 pipeline (base→diff returns committed work), coexistence and fork cases; unit tests verify parallel probing without wall-clock delays andoriginpriority.Written for commit 8e651c0. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests