Skip to content

Commit 3bcb1a9

Browse files
author
Zoo (VP)
committed
feat(history): add pin toggles to grouped-mode task rows for Welcome/History parity
1 parent eb2e228 commit 3bcb1a9

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎webview-ui/src/components/history/HistoryView.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ const HistoryViewInner = memo(({ onDone }: HistoryViewProps) => {
413413
onDelete={handleDelete}
414414
onToggleExpand={() => toggleExpand(rootId)}
415415
onToggleSubtaskExpand={toggleExpand}
416+
showPin
417+
isPinned={isPinned({ kind: "task", taskId: rootId })}
418+
canPin={canPin}
419+
onTogglePin={() => void togglePin({ kind: "task", taskId: rootId })}
416420
/>
417421
</DraggableTaskEntry>
418422
</ManualFolderMemberItem>
@@ -688,6 +692,10 @@ const HistoryViewInner = memo(({ onDone }: HistoryViewProps) => {
688692
onDelete={handleDelete}
689693
onToggleExpand={() => toggleExpand(rootId)}
690694
onToggleSubtaskExpand={toggleExpand}
695+
showPin
696+
isPinned={isPinned({ kind: "task", taskId: rootId })}
697+
canPin={canPin}
698+
onTogglePin={() => void togglePin({ kind: "task", taskId: rootId })}
691699
/>
692700
</DraggableTaskEntry>
693701
)

‎webview-ui/src/components/history/__tests__/HistoryView.taskOrganization.spec.tsx‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { useTaskSearch } from "../useTaskSearch"
7676
import { useGroupedTasks } from "../useGroupedTasks"
7777
import { useExtensionState } from "@src/context/ExtensionStateContext"
7878
import { useTaskOrganizationDnd } from "../useTaskOrganizationDnd"
79+
import TaskGroupItem from "../TaskGroupItem"
7980

8081
const mockUseTaskSearch = useTaskSearch as any
8182
const mockUseGroupedTasks = useGroupedTasks as any
@@ -332,6 +333,65 @@ describe("HistoryView task organization integration", () => {
332333
expect(screen.getByTestId("draggable-entry-unfiled-unit-t3")).toBeInTheDocument()
333334
})
334335

336+
it("passes pin props to grouped rows and pins a task via the row toggle", async () => {
337+
mockUseTaskOrganizationDnd.mockReturnValue({
338+
sensors: [],
339+
activeDrag: null,
340+
targetMeta: { isOverTarget: false },
341+
handleDragStart: vi.fn(),
342+
handleDragOver: vi.fn(),
343+
handleDragEnd: vi.fn(),
344+
handleDragCancel: vi.fn(),
345+
UNFILED_DROP_ZONE_ID,
346+
})
347+
const t1 = makeTask("t1")
348+
const t2 = makeTask("t2")
349+
const t3 = makeTask("t3")
350+
const mutateSpy = vi.fn().mockResolvedValue({
351+
requestId: "",
352+
success: true,
353+
committedRevision: 1,
354+
})
355+
356+
mockUseExtensionState.mockReturnValue({
357+
taskOrganization: {
358+
...createEmptyOrganizationState(),
359+
pins: [{ target: { kind: "task", taskId: "t3" }, pinnedAt: 100 }],
360+
},
361+
mutateTaskOrganization: mutateSpy,
362+
cwd: "/test/workspace",
363+
})
364+
mockUseTaskSearch.mockReturnValue({
365+
...defaultSearchResult,
366+
tasks: [t1, t2, t3],
367+
})
368+
mockUseGroupedTasks.mockReturnValue({
369+
groups: [makeGroup(t1), makeGroup(t2), makeGroup(t3)],
370+
flatTasks: null,
371+
toggleExpand: vi.fn(),
372+
isSearchMode: false,
373+
})
374+
375+
render(<HistoryView onDone={vi.fn()} />)
376+
377+
// Every grouped row receives pin props; only t3 is pinned.
378+
const calls = vi.mocked(TaskGroupItem).mock.calls.map(([props]) => props)
379+
const byId = new Map(calls.map((props) => [props.group.parent.id, props]))
380+
expect(byId.get("t1")).toMatchObject({ showPin: true, isPinned: false, canPin: true })
381+
expect(byId.get("t2")).toMatchObject({ showPin: true, isPinned: false, canPin: true })
382+
expect(byId.get("t3")).toMatchObject({ showPin: true, isPinned: true, canPin: true })
383+
384+
// Toggling t1's pin posts a setPinned mutation with the task target.
385+
byId.get("t1")?.onTogglePin?.()
386+
await waitFor(() => {
387+
expect(mutateSpy).toHaveBeenCalledWith({
388+
kind: "setPinned",
389+
target: { kind: "task", taskId: "t1" },
390+
pinned: true,
391+
})
392+
})
393+
})
394+
335395
it("opens the folder-name dialog after a real task-on-task drop and posts createFolder on confirm", async () => {
336396
const mutateSpy = vi.fn().mockResolvedValue({
337397
requestId: "",

0 commit comments

Comments
 (0)