Handle missing project workspace diff base ref

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-05-15 13:57:25 -05:00
1 parent af5f646e51
commit a2b6687b0a
2 files changed
+20 -2

No files matched your search

@@ -235,4 +235,22 @@ describe("ProjectWorkspaceDetail changes tab", () => {
"/projects/paperclip-app/workspaces/workspace-1?tab=changes&diffView=head&baseRef=origin%2Fmain",
);
});
it("opens the Changes tab in working-tree mode when no upstream ref is known", async () => {
mockProjectsApi.get.mockResolvedValue(project({
workspaces: [projectWorkspace({ defaultRef: null, repoRef: null })],
primaryWorkspace: projectWorkspace({ defaultRef: null, repoRef: null }),
codebase: null,
}));
await render();
await act(async () => {
(container.querySelector('[data-tab-value="changes"]') as HTMLButtonElement).click();
});
expect(mockNavigate).toHaveBeenCalledWith(
"/projects/paperclip-app/workspaces/workspace-1?tab=changes&diffView=working-tree",
);
});
});
+2 -2
View File
@@ -428,11 +428,11 @@ export function ProjectWorkspaceDetail() {
const handleTabChange = (tab: ProjectWorkspaceTab) => {
const workspacePath = projectWorkspaceUrl(project, routeWorkspaceId);
if (tab === "changes") {
const baseRef = upstreamBaseRef(workspace);
const params = new URLSearchParams({
tab: "changes",
diffView: "head",
diffView: baseRef ? "head" : "working-tree",
});
const baseRef = upstreamBaseRef(workspace);
if (baseRef) params.set("baseRef", baseRef);
navigate(`${workspacePath}?${params.toString()}`);
return;