Skip to content

Commit b596fef

Browse files
committed
fix: enable mobile diff view when no diff is preselected
1 parent f7f3ed8 commit b596fef

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ function MainApp() {
19331933
gitStatus,
19341934
fileStatus,
19351935
perFileDiffGroups,
1936+
hasActiveGitDiffs: activeDiffs.length > 0,
19361937
selectedDiffPath,
19371938
diffScrollRequestId,
19381939
onSelectDiff: handleSelectDiff,
@@ -2134,9 +2135,17 @@ function MainApp() {
21342135
setCenterMode("chat");
21352136
},
21362137
onShowSelectedDiff: () => {
2137-
if (!selectedDiffPath) {
2138+
const fallbackPath =
2139+
selectedDiffPath ?? activeDiffs[0]?.path;
2140+
2141+
if (!fallbackPath) {
21382142
return;
21392143
}
2144+
2145+
if (!selectedDiffPath) {
2146+
setSelectedDiffPath(fallbackPath);
2147+
}
2148+
21402149
setCenterMode("diff");
21412150
if (isPhone) {
21422151
setActiveTab("git");

src/features/layout/components/PhoneLayout.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,17 @@ export function PhoneLayout({
6565
{activeTab === "git" && (
6666
<div className="compact-panel">
6767
{!activeWorkspace && compactEmptyGitNode}
68-
{activeWorkspace && showGitDetail && (
69-
<>
70-
{compactGitBackNode}
71-
<div className="compact-git-viewer">{gitDiffViewerNode}</div>
72-
</>
73-
)}
74-
{activeWorkspace && !showGitDetail && (
68+
{activeWorkspace && (
7569
<>
7670
<MainTopbar leftNode={topbarLeftNode} className="compact-topbar" />
7771
{compactGitBackNode}
78-
<div className="compact-git">
79-
<div className="compact-git-list">{gitDiffPanelNode}</div>
80-
</div>
72+
{showGitDetail ? (
73+
<div className="compact-git-viewer">{gitDiffViewerNode}</div>
74+
) : (
75+
<div className="compact-git">
76+
<div className="compact-git-list">{gitDiffPanelNode}</div>
77+
</div>
78+
)}
8179
</>
8280
)}
8381
</div>

src/features/layout/hooks/layoutNodes/buildSecondaryNodes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function buildSecondaryNodes(options: LayoutNodesOptions): SecondaryLayou
9494
type="button"
9595
className={`compact-git-switch-button${compactGitDiffActive ? " active" : ""}`}
9696
onClick={options.onShowSelectedDiff}
97-
disabled={!options.selectedDiffPath}
97+
disabled={!options.hasActiveGitDiffs}
9898
>
9999
Diff
100100
</button>

src/features/layout/hooks/layoutNodes/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export type LayoutNodesOptions = {
260260
fileStatus: string;
261261
perFileDiffGroups: PerFileDiffGroup[];
262262
selectedDiffPath: string | null;
263+
hasActiveGitDiffs: boolean;
263264
diffScrollRequestId: number;
264265
onSelectDiff: (path: string) => void;
265266
onSelectPerFileDiff: (path: string) => void;

0 commit comments

Comments
 (0)