From 20fd3c53ded2164722dfd971326edb1dd6531faa Mon Sep 17 00:00:00 2001
From: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Date: Wed, 11 Nov 2026 01:00:02 -0800
Subject: [PATCH] fix(source-control): wait for a git status read before
judging a merged workspace
Before the first status read the change count is zero and HEAD may be stale,
so the notice could call a dirty workspace safe to delete. Use the HEAD from
the latest successful status read and say nothing until one completes.
---
.../merged-review-workspace-notice.fixture.tsx | 18 ++++++++++++++----
.../panel/merged-review-workspace-notice.tsx | 8 ++++++--
.../source-control/panel/panel-content.tsx | 1 +
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.fixture.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.fixture.tsx
index fb63832e8c1..b66ae1f2e5b 100644
--- a/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.fixture.tsx
+++ b/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.fixture.tsx
@@ -18,7 +18,6 @@ const review: HostedReviewInfo = {
const worktree = {
id: 'repo-1::/work/app-sync',
path: '/work/app-sync',
- head: 'a1b2c3d',
branch: 'refs/heads/feature/sync-retry',
isMainWorktree: false
} as Worktree
@@ -31,7 +30,12 @@ export const safeToDelete = defineFixture({
width: 300,
render: () => (
-
+
)
})
@@ -40,7 +44,12 @@ export const uncommittedChanges = defineFixture({
width: 300,
render: () => (
-
+
)
})
@@ -51,7 +60,8 @@ export const headMovedPastReview = defineFixture({
diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.tsx
index 04ea0489022..cef5ad7a9e6 100644
--- a/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.tsx
+++ b/src/renderer/src/components/right-sidebar/source-control/panel/merged-review-workspace-notice.tsx
@@ -17,10 +17,13 @@ import { getDeleteStateForWorktreeHost } from '../../../sidebar/workspace-action
export function SourceControlMergedReviewNotice({
review,
worktree,
+ statusHeadOid,
uncommittedCount
}: {
review: HostedReviewInfo | null
worktree: Worktree
+ /** HEAD from the latest successful git status read; null until one completes. */
+ statusHeadOid: string | null
uncommittedCount: number
}): React.JSX.Element | null {
const t = useTranslate()
@@ -29,10 +32,11 @@ export function SourceControlMergedReviewNotice({
)
const readiness = resolveMergedReviewWorkspaceReadiness({
review,
- headOid: worktree.head,
+ headOid: statusHeadOid,
uncommittedCount
})
- if (!review || !readiness) {
+ // Without a status read the change count is unknown, so say nothing rather than guess.
+ if (!review || !readiness || !statusHeadOid) {
return null
}
const label = `${
diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx
index a6d96a9d0b4..39293b15071 100644
--- a/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx
+++ b/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx
@@ -140,6 +140,7 @@ export function SourceControlPanelContent(props: SourceControlPanelReadyProps) {
)}