Skip to content

Commit 2990bd0

Browse files
PR Batch Testerclaude
andcommitted
fix(web): the index route skips a project removed since it rendered
The index route picks its project during render and starts the draft in an effect. A removal landing in between left a draft for a project the store no longer has; the effect now waits for the next render instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent dea3c6c commit 2990bd0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎apps/web/src/routes/_chat.index.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { SidebarInset } from "../components/ui/sidebar";
1414
import { WorkspacePageHeader } from "../components/WorkspacePageHeader";
1515
import { useNewThreadHandler } from "../hooks/useHandleNewThread";
1616
import {
17+
readProject,
1718
useAllEnvironmentShellsBootstrapped,
1819
useProjects,
1920
useThreadShells,
@@ -59,10 +60,14 @@ function IndexDraftLanding() {
5960
if (mostRecentProject === null || startingRef.current) {
6061
return;
6162
}
63+
const projectRef = scopeProjectRef(mostRecentProject.environmentId, mostRecentProject.id);
64+
// A project removed since this render is gone from the store; the next
65+
// render picks another one.
66+
if (readProject(projectRef) === null) {
67+
return;
68+
}
6269
startingRef.current = true;
63-
void handleNewThread(scopeProjectRef(mostRecentProject.environmentId, mostRecentProject.id), {
64-
replace: true,
65-
})
70+
void handleNewThread(projectRef, { replace: true })
6671
.then((opened) => {
6772
// The project was removed while its draft started; land on the next one.
6873
if (opened === null) {

0 commit comments

Comments
 (0)