From b14f47385577729756b86ed613679fda1dcfee5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Almeida?= Date: Wed, 6 May 2026 02:07:06 +0100 Subject: [PATCH] fix(web): preserve task.repositories in sheet-hooks kanban mappers mapSnapshotToKanban (workspace switch) and handleTaskCreated (newly created task) only carried the first repository_id, dropping the full TaskRepository array. The mobile repo picker (useTaskRepoCount + MobileReposSection) reads task.repositories.length, so it silently disappeared after a workspace switch and for freshly created multi-repo tasks. Map the array with the same shape the SSR mapper uses (id, repository_id, base_branch, checkout_branch, position). Also address a small nit: wrap addTerminal in an arrow at the New terminal button so the click MouseEvent isn't passed as the (unused) first argument. --- .../task/mobile/mobile-terminals-section.tsx | 2 +- .../session-task-switcher-sheet-hooks.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/web/components/task/mobile/mobile-terminals-section.tsx b/apps/web/components/task/mobile/mobile-terminals-section.tsx index c8952a09e2..2cdb58ccb9 100644 --- a/apps/web/components/task/mobile/mobile-terminals-section.tsx +++ b/apps/web/components/task/mobile/mobile-terminals-section.tsx @@ -168,7 +168,7 @@ const MobileTerminalsList = memo(function MobileTerminalsList({ size="sm" variant="outline" className="h-7 gap-1 cursor-pointer" - onClick={addTerminal} + onClick={() => addTerminal()} data-testid="mobile-add-terminal" > diff --git a/apps/web/components/task/mobile/session-task-switcher-sheet-hooks.ts b/apps/web/components/task/mobile/session-task-switcher-sheet-hooks.ts index 2d036b3947..b1d9fc3901 100644 --- a/apps/web/components/task/mobile/session-task-switcher-sheet-hooks.ts +++ b/apps/web/components/task/mobile/session-task-switcher-sheet-hooks.ts @@ -40,6 +40,17 @@ function mapSnapshotToKanban(snapshot: WorkflowSnapshot, newWorkflowId: string) position: task.position ?? 0, state: task.state, repositoryId: task.repositories?.[0]?.repository_id ?? undefined, + // Carry the full TaskRepository array so the mobile repo picker + // (useTaskRepoCount + MobileReposSection) keeps working after a + // workspace switch. Without this, the picker silently disappears for + // multi-repo tasks because length defaults to 0. + repositories: task.repositories?.map((r) => ({ + id: r.id, + repository_id: r.repository_id, + base_branch: r.base_branch, + checkout_branch: r.checkout_branch, + position: r.position, + })), primarySessionId: task.primary_session_id ?? undefined, primarySessionState: task.primary_session_state ?? undefined, sessionCount: task.session_count ?? undefined, @@ -247,6 +258,15 @@ function useWorkspaceAndTaskCreatedActions(opts: SheetNavOptions) { position: task.position ?? 0, state: task.state, repositoryId: task.repositories?.[0]?.repository_id ?? undefined, + // See mapSnapshotToKanban — keep the full repos array so the mobile + // repo picker shows up for newly created multi-repo tasks too. + repositories: task.repositories?.map((r) => ({ + id: r.id, + repository_id: r.repository_id, + base_branch: r.base_branch, + checkout_branch: r.checkout_branch, + position: r.position, + })), updatedAt: task.updated_at, primaryExecutorId: task.primary_executor_id ?? undefined, primaryExecutorType: task.primary_executor_type ?? undefined,