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.
This commit is contained in:
José Almeida
2026-05-06 02:07:06 +01:00
parent 9dc7f8a43b
commit b14f473855
2 changed files with 21 additions and 1 deletions
@@ -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"
>
<IconPlus className="h-4 w-4" />
@@ -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,