From 47f00923528449c8ded04d6187af458af3d4e3c9 Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Fri, 13 Nov 2026 16:45:04 +0100 Subject: [PATCH] fix(board): close the open task when the board button is pressed again On the board, with a task open in the side panel, the header's board button did nothing, since the board was already the active view. It now closes the side panel, as its close button and Escape do, and returns focus to the task's card. A draft in the side panel stays, left to its own Cancel. Co-Authored-By: Claude Opus 5.5 --- .../WorkspaceControls.client.test.tsx | 41 +++++++++++++++++++ src/components/WorkspaceControls.tsx | 22 +++++++--- 2 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 src/components/WorkspaceControls.client.test.tsx diff --git a/src/components/WorkspaceControls.client.test.tsx b/src/components/WorkspaceControls.client.test.tsx new file mode 100644 index 000000000..efd0e10ab --- /dev/null +++ b/src/components/WorkspaceControls.client.test.tsx @@ -0,0 +1,41 @@ +import { render } from 'solid-js/web'; +import { afterEach, beforeEach, expect, it, vi } from 'vitest'; +import { setStore, store } from '../store/core'; +import { WorkspaceControls } from './WorkspaceControls'; + +vi.mock('../lib/ipc', () => ({ invoke: vi.fn(async () => ({})) })); + +let dispose: () => void; + +function boardButton(): HTMLButtonElement { + const button = document.querySelector('[aria-label^="Board:"]'); + if (!button) throw new Error('missing board button'); + return button; +} + +beforeEach(() => { + setStore('boardView', true); + setStore('boardPeek', true); + setStore('showNewTaskPanel', false); + setStore('githubIssuesProjectId', null); + const root = document.createElement('div'); + document.body.append(root); + dispose = render(() => , root); +}); +afterEach(() => { + dispose(); + document.body.replaceChildren(); +}); + +it('closes the task open beside the board, keeping the board', () => { + boardButton().click(); + expect(store.boardPeek).toBe(false); + expect(store.boardView).toBe(true); +}); + +it('leaves a draft beside the board to its own Cancel', () => { + setStore('showNewTaskPanel', true); + boardButton().click(); + expect(store.boardPeek).toBe(true); + expect(store.boardView).toBe(true); +}); diff --git a/src/components/WorkspaceControls.tsx b/src/components/WorkspaceControls.tsx index 2ea8231b4..8b9f2efa2 100644 --- a/src/components/WorkspaceControls.tsx +++ b/src/components/WorkspaceControls.tsx @@ -9,8 +9,10 @@ import { workspaceViewTransitionTypes, type WorkspaceView, } from '../store/store'; +import { boardShown } from '../store/project-pages'; import { mod } from '../lib/platform'; import { withViewTransition } from '../lib/viewTransition'; +import { closeSidePanel } from './BoardSidePanel'; import { ChevronLeftAltIcon, GearIcon } from './icons'; import { FeatureHint } from './FeatureHint'; import { IconButton } from './IconButton'; @@ -82,6 +84,19 @@ function visibleTaskCount(): number { return store.taskOrder.filter((id) => !isHiddenAgentTaskId(id)).length; } +/** + * Shows `view`. The board's own button, pressed while a task is open beside + * the board, closes that side panel instead, as its close button and Escape + * do; a draft stays, left to its own Cancel. + */ +function selectView(view: WorkspaceView): void { + if (view === 'board' && boardShown() && store.boardPeek && !store.showNewTaskPanel) { + closeSidePanel(); + return; + } + withViewTransition(() => setWorkspaceView(view), workspaceViewTransitionTypes(view)); +} + /** Focus, tiles or board: three views of the same tasks, one pressed at a time. */ function WorkspaceViewToggle() { let boardButton: HTMLButtonElement | undefined; @@ -96,12 +111,7 @@ function WorkspaceViewToggle() { title={item.title} label={item.title} pressed={workspaceView() === item.view} - onClick={() => - withViewTransition( - () => setWorkspaceView(item.view), - workspaceViewTransitionTypes(item.view), - ) - } + onClick={() => selectView(item.view)} > {item.icon()}