diff --git a/web/src/components/layout/WorkspaceShell.tsx b/web/src/components/layout/WorkspaceShell.tsx index 32e140e..9ee3bff 100644 --- a/web/src/components/layout/WorkspaceShell.tsx +++ b/web/src/components/layout/WorkspaceShell.tsx @@ -107,8 +107,13 @@ function TerminalTabs({ workspaceId }: { workspaceId: string }) { setShellsForWorkspace(workspaceId, ids); } const currentActive = activeShellId; - if (!currentActive || !ids.includes(currentActive)) { - setActiveShell(workspaceId, ids[0] ?? ""); + // Only set an active shell when the list is non-empty. If ids is empty, + // the auto-start effect above will create a shell; the next list refetch + // will populate ids and this branch will run with a real candidate. + // (Setting it to "" here would loop: "" is falsy, so the same branch + // would fire on the next render.) + if (ids.length > 0 && (!currentActive || !ids.includes(currentActive))) { + setActiveShell(workspaceId, ids[0]); } }, [ workspaceId,