:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(desktop): reuse the space list row in the Work column (#105079)
Shy Alter6c78700d10f3
diff --git a/products/desktop/packages/core/src/canvas/channelItems.test.ts b/products/desktop/packages/core/src/canvas/channelItems.test.tsindex fc8376f1f7d5..a901e03e2c70 100644--- a/products/desktop/packages/core/src/canvas/channelItems.test.ts+++ b/products/desktop/packages/core/src/canvas/channelItems.test.ts@@ -473,6 +473,21 @@ describe("sortChannelItems", () => {expect(sortChannelItems(pinnedLast, sort)[0]?.id).toBe("pin");}});++ // The Work column's Recent list is one of these: a pin there marks the row+ // and nothing else, so holding it at the top would move a row nobody moved.+ it("leaves a pin in place for a list with no pinned run", () => {+ const pinnedOldest = [+ ...items,+ model({ id: "pin", title: "Z", ts: 0, createdAt: 0, pinned: true }),+ ];++ expect(+ sortChannelItems(pinnedOldest, "recent", { pinnedRun: false }).map(+ (i) => i.id,+ ),+ ).toEqual(["newest", "middle", "oldest", "pin"]);+ });});describe("groupChannelItems", () => {@@ -540,6 +555,19 @@ describe("groupChannelItems", () => {]);});+ it("dates a pin with the rest for a list with no pinned run", () => {+ const items = [+ model({ id: "today", ts: at(29, 9) }),+ model({ id: "kept", ts: at(29, 8), pinned: true }),+ ];++ expect(+ groupChannelItems(items, "recent", NOW, "date", undefined, {+ pinnedRun: false,+ }).map((section) => [section.label, ...section.items.map((i) => i.id)]),+ ).toEqual([["Today", "today", "kept"]]);+ });+// Dating a created-first list by last activity would reopen a day the list// had already passed, splitting one day across two headers.it("dates a created-first list by when each session started", () => {diff --git a/products/desktop/packages/core/src/canvas/channelItems.ts b/products/desktop/packages/core/src/canvas/channelItems.tsindex 8d9c04bebbdf..3a5d3072634f 100644--- a/products/desktop/packages/core/src/canvas/channelItems.ts+++ b/products/desktop/packages/core/src/canvas/channelItems.ts@@ -376,10 +376,24 @@ function compareChannelItems(* below the sort it would fall off the end of the list's cap. The order inside* each half is the one that was chosen.*/+/**+ * A list without a pinned run. A pin then orders and groups with everything+ * else, and only the row's own badge says it is pinned. For a list that is not+ * capped, or that a reader scrolls rather than scans, holding pins at the top+ * moves a row the reader did not ask to move.+ */+export interface ChannelItemPinOptions {+ pinnedRun?: boolean;+}+export function sortChannelItems(items: readonly ChannelItemModel[],sort: ChannelItemSort,+ { pinnedRun = true }: ChannelItemPinOptions = {},): ChannelItemModel[] {+ if (!pinnedRun) {+ return [...items].sort((a, b) => compareChannelItems(a, b, sort));+ }const pinned = items.filter((item) => item.pinned);const rest = items.filter((item) => !item.pinned);return [@@ -417,15 +431,16 @@ export function groupChannelItems(now: Date = new Date(),grouping: ChannelItemGrouping = DEFAULT_CHANNEL_ITEM_GROUPING,spaceOf?: (item: ChannelItemModel) => ChannelItemGroupKey | null,+ { pinnedRun = true }: ChannelItemPinOptions = {},): ChannelItemSection[] {const sections: ChannelItemSection[] = [];- const pinned = items.filter((item) => item.pinned);+ const pinned = pinnedRun ? items.filter((item) => item.pinned) : [];if (pinned.length > 0) {sections.push({ key: PINNED_SECTION_KEY, label: "Pinned", items: pinned });}- const rest = items.filter((item) => !item.pinned);+ const rest = pinnedRun ? items.filter((item) => !item.pinned) : [...items];if (rest.length === 0) return sections;if (grouping === "repository") {sections.push(...repositorySections(rest));diff --git a/products/desktop/packages/ui/src/features/canvas/commandCenterAssign.ts b/products/desktop/packages/ui/src/features/canvas/commandCenterAssign.tsnew file mode 100644index 000000000000..7ea3c9026e39--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/commandCenterAssign.ts@@ -0,0 +1,27 @@+import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import { getCanvasCellId } from "@posthog/core/command-center/grid";+import {+ placeCanvasInCommandCenter,+ placeTaskInCommandCenter,+} from "@posthog/ui/features/command-center/placeTaskInCommandCenter";++export function commandCenterAssigner(item: ChannelItemModel): () => void {+ return () => {+ if (item.kind === "canvas") {+ placeCanvasInCommandCenter(item.id, item.title);+ } else {+ placeTaskInCommandCenter(item.id, item.title);+ }+ };+}++export function isInCommandCenter(+ item: ChannelItemModel,+ commandCenterCells: readonly (string | null)[],+): boolean {+ return commandCenterCells.some((cell) =>+ item.kind === "canvas"+ ? getCanvasCellId(cell) === item.id+ : cell === item.id,+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsxindex 67facf6524dc..b0b932abf606 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx@@ -1,4 +1,5 @@import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import { Autocomplete, AutocompleteList } from "@posthog/quill";import { formatRelativeTimeShort } from "@posthog/shared";import type { Task } from "@posthog/shared/domain-types";import { useArchiveShortcut } from "@posthog/ui/features/archive/useArchiveShortcut";@@ -135,6 +136,25 @@ function renderRow(model: ChannelItemModel) {);}+/**+ * The Work column walks its rows with the keyboard, so its rows are options of+ * the column's own Autocomplete rather than plain buttons.+ */+function renderOptionRow(model: ChannelItemModel) {+ return renderInList(+ <Autocomplete<string> inline open items={[model.key]} filter={null}>+ <AutocompleteList>+ <ChannelItemRow+ actions={actions}+ isActive={false}+ item={model}+ optionValue={model.key}+ />+ </AutocompleteList>+ </Autocomplete>,+ );+}+beforeEach(() => {mocks.status = null;mocks.analysis = { canAnalyze: false, isPending: false, run: vi.fn() };@@ -902,4 +922,20 @@ describe("ChannelItemRow", () => {expect(screen.queryByText(/PostHog\/code/)).not.toBeInTheDocument();});++ // The Work column's rows moved onto the shared row. An option that loses the+ // session attribute is invisible to the marquee, and one that is not an+ // option at all drops off the column's arrow-key path.+ it("renders as an autocomplete option the marquee can still find", () => {+ renderOptionRow(item({ id: "task-7", kind: "task" }));++ const option = screen.getByRole("option");+ expect(option).toHaveAttribute("data-session-id", "task-7");+ });++ it("keeps a canvas option out of the marquee's reach", () => {+ renderOptionRow(item({ id: "canvas-1", kind: "canvas", key: "canvas:1" }));++ expect(screen.getByRole("option")).not.toHaveAttribute("data-session-id");+ });});diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsxindex c239e1d6a572..e81322b2b3df 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx@@ -11,6 +11,7 @@ import {AvatarFallback,AvatarGroup,Button,+ cn,Tooltip,TooltipContent,TooltipTrigger,@@ -26,6 +27,7 @@ import {TaskRowContextMenu,type TaskRowMenuProps,} from "@posthog/ui/features/canvas/components/TaskRowMenu";+import { WorkRowSurface } from "@posthog/ui/features/canvas/components/WorkRowSurface";import { useChannelItemMetadata } from "@posthog/ui/features/canvas/hooks/useChannelItemFacts";import { useChannelTaskStatus } from "@posthog/ui/features/canvas/hooks/useChannelTaskStatus";import { useIsCanvasPendingDelete } from "@posthog/ui/features/canvas/stores/pendingCanvasDeleteStore";@@ -49,6 +51,10 @@ import { SESSION_ROW_ATTRIBUTE } from "@posthog/ui/features/sidebar/useMarqueeSeimport { HandoffTaskDialog } from "@posthog/ui/features/task-detail/components/HandoffTaskDialog";import { useMountedOnceOpened } from "@posthog/ui/hooks/useMountedOnceOpened";import { DotsCircleSpinner } from "@posthog/ui/primitives/DotsCircleSpinner";+import {+ OverflowTickerText,+ useOverflowTickerReveal,+} from "@posthog/ui/primitives/OverflowTickerText";import {type DragEvent,type ReactNode,@@ -180,6 +186,49 @@ function ChannelItemDot({);}+/**+ * A row's trailing stack: who is here, then what the row is. Shared by both+ * surfaces below, so the marks a list is scanned for can't differ between them.+ */+function ChannelItemTrailing({+ item,+ status,+ pinBadge,+ currentUserUuid,+}: {+ item: ChannelItemModel;+ status: TaskStatusInput | null;+ pinBadge: boolean;+ currentUserUuid?: string;+}) {+ return (+ <span className={TRAILING_CLASS}>+ {/* Who's here, ahead of the badges: presence is the row's most+ time-sensitive fact, and it's absent on a quiet row. */}+ <RowPresence item={item} currentUserUuid={currentUserUuid} />+ {/* Badges take the timestamp's slot: identity (pin, source, cloud,+ PR) is what you scan a task list for, and the age is still on the+ preview card. */}+ {status ? (+ <TaskBadgeStack status={status} pinned={pinBadge} />+ ) : item.kind === "canvas" ? (+ <CanvasBadgeStack item={item} pinned={pinBadge} />+ ) : (+ <>+ {pinBadge && (+ <AvatarGroup stacked reverse size="xs" className="shrink-0">+ <PinnedBadge />+ </AvatarGroup>+ )}+ <span className={TIMESTAMP_CLASS}>+ {formatRelativeTimeShort(item.ts)}+ </span>+ </>+ )}+ </span>+ );+}+/*** What a row looks like, with nothing behind it, so the drag preview can draw* one without wiring it. Rendering `ChannelItemRow` for that opened a second PR@@ -187,6 +236,10 @@ function ChannelItemDot({** Takes `status` rather than resolving it: how much is worth resolving is the* caller's call, see `useChannelTaskStatus`.+ *+ * `optionValue` picks the root. A list that walks its rows with the keyboard is+ * an Autocomplete, and only an `AutocompleteItem` is on that path; every other+ * list keeps the plain `SidebarItem` button. The body is the same either way.*/export function ChannelItemRowView({item,@@ -198,6 +251,7 @@ export function ChannelItemRowView({showPinBadge = true,draggable = false,currentUserUuid,+ optionValue,onClick,onDragStart,onDragEnd,@@ -214,13 +268,82 @@ export function ChannelItemRowView({showPinBadge?: boolean;draggable?: boolean;currentUserUuid?: string;+ /** Renders the row as an autocomplete option under this value. */+ optionValue?: string;onClick?: (e: React.MouseEvent) => void;onDragStart?: (e: DragEvent) => void;onDragEnd?: (e: DragEvent) => void;onMouseEnter?: () => void;onMouseLeave?: () => void;}) {- const pinBadge = item.pinned && showPinBadge;+ const pinBadge = Boolean(item.pinned && showPinBadge);+ const { reveal, hoverProps, focusProps } = useOverflowTickerReveal();+ const icon = isArchiving ? (+ <>+ <DotsCircleSpinner size={12} className="text-muted-foreground" />+ <span className="sr-only">Archiving</span>+ </>+ ) : (+ <ChannelItemDot item={item} status={status} />+ );+ // Lets a drag-selection find the row and its session; canvases are not+ // selectable, so they stay unmarked and the marquee passes over them.+ const sessionAttribute =+ item.kind === "task" ? { [SESSION_ROW_ATTRIBUTE]: item.id } : {};+ const trailing = (+ <ChannelItemTrailing+ item={item}+ status={status}+ pinBadge={pinBadge}+ currentUserUuid={currentUserUuid}+ />+ );++ if (optionValue !== undefined) {+ return (+ <WorkRowSurface+ optionValue={optionValue}+ data-selected={isActive || undefined}+ aria-busy={isArchiving || undefined}+ disabled={isArchiving}+ className={cn(+ subtitle && "h-auto py-1",+ isArchiving && "opacity-60",+ // The open row keeps `data-selected`; a picked one takes the accent+ // over it, a shade above the rows picked around it.+ isSelected && (isActive ? "bg-primary/20!" : "bg-primary/10"),+ )}+ draggable={draggable && !isArchiving}+ onDragStart={onDragStart}+ onDragEnd={onDragEnd}+ onClick={onClick}+ onMouseEnter={onMouseEnter}+ onMouseLeave={onMouseLeave}+ {...sessionAttribute}+ {...hoverProps}+ {...focusProps}+ >+ <span+ className={cn(+ "flex size-3.5 shrink-0 items-center justify-center",+ subtitle && "self-start pt-0.5",+ )}+ >+ {icon}+ </span>+ <span className="flex min-w-0 flex-1 flex-col">+ <OverflowTickerText reveal={reveal}>{item.title}</OverflowTickerText>+ {subtitle && (+ <span className="truncate text-muted-foreground/70 text-xxs group-data-selected/button:text-muted-foreground">+ {subtitle}+ </span>+ )}+ </span>+ {trailing}+ </WorkRowSurface>+ );+ }+return (<SidebarItemonMouseEnter={onMouseEnter}@@ -230,16 +353,7 @@ export function ChannelItemRowView({// which keeps SidebarItem's native cursor-default.className={isArchiving ? "cursor-default" : "cursor-pointer"}depth={0}- icon={- isArchiving ? (- <>- <DotsCircleSpinner size={12} className="text-muted-foreground" />- <span className="sr-only">Archiving</span>- </>- ) : (- <ChannelItemDot item={item} status={status} />- )- }+ icon={icon}// A non-string label opts out of SidebarItem's truncation tooltip.label={<span>{item.title}</span>}subtitle={subtitle}@@ -248,39 +362,12 @@ export function ChannelItemRowView({aria-busy={isArchiving || undefined}isDimmed={isArchiving}disabled={isArchiving}- // Lets a drag-selection find the row and its session; canvases are not- // selectable, so they stay unmarked and the marquee passes over them.- {...(item.kind === "task" ? { [SESSION_ROW_ATTRIBUTE]: item.id } : {})}+ {...sessionAttribute}draggable={draggable && !isArchiving}onDragStart={onDragStart}onDragEnd={onDragEnd}onClick={onClick}- endContent={- <span className={TRAILING_CLASS}>- {/* Who's here, ahead of the badges: presence is the row's most- time-sensitive fact, and it's absent on a quiet row. */}- <RowPresence item={item} currentUserUuid={currentUserUuid} />- {/* Badges take the timestamp's slot: identity (pin, source, cloud,- PR) is what you scan a task list for, and the age is still on the- preview card. */}- {status ? (- <TaskBadgeStack status={status} pinned={pinBadge} />- ) : item.kind === "canvas" ? (- <CanvasBadgeStack item={item} pinned={pinBadge} />- ) : (- <>- {pinBadge && (- <AvatarGroup stacked reverse size="xs" className="shrink-0">- <PinnedBadge />- </AvatarGroup>- )}- <span className={TIMESTAMP_CLASS}>- {formatRelativeTimeShort(item.ts)}- </span>- </>- )}- </span>- }+ endContent={trailing}/>);}@@ -301,6 +388,9 @@ export function ChannelItemRow({onDragStart,onDragEnd,bulk,+ optionValue,+ spaceName,+ withPrStatus = true,onContextMenuOpenChange,}: {item: ChannelItemModel;@@ -330,10 +420,19 @@ export function ChannelItemRow({* `onArchive` belongs to the list, which owns the selection.*/bulk?: TaskRowBulkMenu | null;+ /** Renders the row as an autocomplete option, for a list the keyboard walks. */+ optionValue?: string;+ /** Named in the subtitle by a list that spans spaces, where it is not implied. */+ spaceName?: string;+ /**+ * Off for a long list that spans spaces: the lookup is a query per row into+ * git. The PR still shows where the task carries its own `prUrl`.+ */+ withPrStatus?: boolean;onContextMenuOpenChange?: (open: boolean) => void;}) {- const status = useChannelTaskStatus(item);- const subtitle = useChannelItemMetadata(item);+ const status = useChannelTaskStatus(item, { withPrStatus });+ const subtitle = useChannelItemMetadata(item, spaceName);const archivePresentation = useArchivingTasksStore((state) =>item.kind !== "task"? null@@ -465,6 +564,7 @@ export function ChannelItemRow({showPinBadge={showPinBadge}draggablecurrentUserUuid={currentUser.data?.uuid}+ optionValue={optionValue}onDragStart={handleDragStart}onDragEnd={onDragEnd}onClick={diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsxindex d186d07284a8..30d0252b2209 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx@@ -13,7 +13,6 @@ import {PINNED_SECTION_KEY,sortChannelItems,} from "@posthog/core/canvas/channelItems";-import { getCanvasCellId } from "@posthog/core/command-center/grid";import {Empty,EmptyDescription,@@ -33,6 +32,10 @@ import {} from "@posthog/shared/analytics-events";import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import {+ commandCenterAssigner,+ isInCommandCenter,+} from "@posthog/ui/features/canvas/commandCenterAssign";import { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";import { ChannelItemDragPreview } from "@posthog/ui/features/canvas/components/ChannelItemDragPreview";import type { ChannelItemActions } from "@posthog/ui/features/canvas/components/ChannelItemRow";@@ -41,10 +44,6 @@ import { PinnedRun } from "@posthog/ui/features/canvas/components/PinnedRun";import { useChannelItemSelection } from "@posthog/ui/features/canvas/hooks/useChannelItemSelection";import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";import { useCommandCenterStore } from "@posthog/ui/features/command-center/commandCenterStore";-import {- placeCanvasInCommandCenter,- placeTaskInCommandCenter,-} from "@posthog/ui/features/command-center/placeTaskInCommandCenter";import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";import { MarqueeOverlay } from "@posthog/ui/features/sidebar/components/MarqueeOverlay";import { SidebarBulkActionBar } from "@posthog/ui/features/sidebar/components/SidebarBulkActionBar";@@ -65,27 +64,6 @@ import {const log = logger.scope("channel-items-pane");-function commandCenterAssigner(item: ChannelItemModel): () => void {- return () => {- if (item.kind === "canvas") {- placeCanvasInCommandCenter(item.id, item.title);- } else {- placeTaskInCommandCenter(item.id, item.title);- }- };-}--function isInCommandCenter(- item: ChannelItemModel,- commandCenterCells: readonly (string | null)[],-): boolean {- return commandCenterCells.some((cell) =>- item.kind === "canvas"- ? getCanvasCellId(cell) === item.id- : cell === item.id,- );-}-const SKELETON_ROW_WIDTHS = [60, 80, 40, 75, 50, 66] as const;function ChannelItemsSkeleton() {diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkRowSurface.tsx b/products/desktop/packages/ui/src/features/canvas/components/WorkRowSurface.tsxsimilarity index 60%rename from products/desktop/packages/ui/src/features/canvas/components/work/WorkRowSurface.tsxrename to products/desktop/packages/ui/src/features/canvas/components/WorkRowSurface.tsxindex cdf63824f39d..bf0e0a731333 100644--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkRowSurface.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WorkRowSurface.tsx@@ -1,6 +1,17 @@import { AutocompleteItem, type Button, cn } from "@posthog/quill";import type { ComponentProps } from "react";+/**+ * A list row as an autocomplete option, which is what keeps it on the keyboard's+ * arrow path.+ *+ * The three overrides below answer quill's own defaults, which `AutocompleteItem`+ * does not parameterize: it wraps its children in a centered, truncating span,+ * it colours a highlighted option's contents, and it draws a ring and a border+ * on the highlight. A row supplies its own layout, its own marks and its own+ * hover fill, so each default has to give way. The `[&>span]` rules therefore+ * depend on that wrapper staying one span deep.+ */export function WorkRowSurface({optionValue,className,diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.stories.tsxindex eb5248ed9cc6..b3f1f2235f23 100644--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.stories.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.stories.tsx@@ -3,6 +3,7 @@ import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaimport { taskKeys } from "@posthog/ui/features/tasks/taskKeys";import type { Meta, StoryObj } from "@storybook/react-vite";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import type { ReactElement } from "react";import { WorkColumn } from "./WorkColumn";const ME_ID = 1;@@ -77,29 +78,46 @@ const CHANNELS: TaskChannel[] = [* The column reads its rows through authenticated queries that never resolve in* Storybook, so seed their caches — a disabled query still serves cached data.*/-function seededClient(): QueryClient {+function seededClient({+ pinnedTaskIds = [],+ tasks = TASKS,+}: {+ pinnedTaskIds?: string[];+ tasks?: Task[];+} = {}): QueryClient {const client = new QueryClient({defaultOptions: { queries: { retry: false } },});client.setQueryData(["me"], { id: ME_ID, uuid: "me-uuid" });client.setQueryData(TASK_CHANNELS_QUERY_KEY, CHANNELS);- client.setQueryData(taskKeys.list({ createdBy: ME_ID }), TASKS);+ client.setQueryData(taskKeys.list({ createdBy: ME_ID }), tasks);+ client.setQueryData(["task-pins"], pinnedTaskIds);return client;}-const meta = {- title: "Canvas/WorkColumn",- component: WorkColumn,- parameters: { layout: "fullscreen" },- decorators: [- (Story) => (- <QueryClientProvider client={seededClient()}>+/** The same sessions, with the facts a row draws a badge for. */+const MARKED_TASKS: Task[] = TASKS.map((entry, index) =>+ index === 1 ? { ...entry, origin_product: "slack" } : entry,+);++/** The column at the width the app gives it, against one seeded cache. */+function column(client: QueryClient) {+ return function Decorator(Story: () => ReactElement) {+ return (+ <QueryClientProvider client={client}><div className="h-screen w-[280px] border-border border-r"><Story /></div></QueryClientProvider>- ),- ],+ );+ };+}++const meta = {+ title: "Canvas/WorkColumn",+ component: WorkColumn,+ parameters: { layout: "fullscreen" },+ decorators: [column(seededClient())],} satisfies Meta<typeof WorkColumn>;export default meta;@@ -107,3 +125,14 @@ type Story = StoryObj<typeof meta>;/** Recent capped at five rows, spaces below it. */export const Default: Story = {};++/**+ * The marks a row carries: a pin, and where a session came from. Recent has no+ * pinned run, so a pinned session keeps its place in the list and says so with+ * its badge alone.+ */+export const WithBadges: Story = {+ decorators: [+ column(seededClient({ pinnedTaskIds: ["task-3"], tasks: MARKED_TASKS })),+ ],+};diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsxnew file mode 100644index 000000000000..cb22ed5dd0b3--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx@@ -0,0 +1,224 @@+import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import { ChannelItemPreviewCardProvider } from "@posthog/ui/features/canvas/components/ChannelItemHoverCard";+import { Theme } from "@radix-ui/themes";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++const mocks = vi.hoisted(() => ({+ items: [] as { item: ChannelItemModel; channelId: string | undefined }[],+ navigate: {+ toChannelTask: vi.fn(),+ toChannelDashboard: vi.fn(),+ toTaskDetail: vi.fn(),+ toChannel: vi.fn(),+ toSpaces: vi.fn(),+ },+}));++vi.mock("@posthog/ui/router/navigationBridge", () => ({+ navigateToChannel: mocks.navigate.toChannel,+ navigateToChannelDashboard: mocks.navigate.toChannelDashboard,+ navigateToChannelTask: mocks.navigate.toChannelTask,+ navigateToSpaces: mocks.navigate.toSpaces,+ navigateToTaskDetail: mocks.navigate.toTaskDetail,+}));++vi.mock("@posthog/ui/features/canvas/hooks/useRecentWorkItems", () => ({+ useRecentWorkItems: () => ({ items: mocks.items, isLoading: false }),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useChannelItems", () => ({+ useChannelItemActions: ({+ open,+ }: {+ open: (item: ChannelItemModel) => void;+ }) => ({+ open,+ togglePin: vi.fn(),+ setPinned: vi.fn(),+ archive: vi.fn(),+ }),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({+ useChannels: () => ({ channels: [], isLoading: false }),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useRecentSpaceTasks", () => ({+ useSpacePresence: () => new Map(),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useUnreadChannels", () => ({+ useIsChannelUnread: () => () => false,+}));+vi.mock("@tanstack/react-router", () => ({+ useNavigate: () => vi.fn(),+ useRouterState: () => "/spaces/channel-1",+}));+vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));+vi.mock("@posthog/ui/features/auth/authClient", () => ({+ useOptionalAuthenticatedClient: () => null,+}));+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({+ useCurrentUser: () => ({ data: { id: 1, uuid: "me-uuid" } }),+}));+vi.mock("@posthog/ui/features/tasks/useTaskMutations", () => ({+ useRenameTask: () => ({ renameTask: vi.fn() }),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useChannelTaskStatus", () => ({+ useChannelTaskStatus: () => null,+}));+vi.mock("@posthog/ui/features/canvas/hooks/useChannelTasksRunState", () => ({+ useChannelTasksRunState: () => [],+}));+// What each bulk action does has its own suite; this one is about whether the+// column offers them at all, so the bar only needs its count to be real.+vi.mock("@posthog/ui/features/sidebar/useSidebarBulkActions", () => ({+ useSidebarBulkActions: (selectedTaskIds: string[]) => ({+ selectedCount: selectedTaskIds.length,+ pinDirection: "pin",+ pinLabel: "Pin",+ channels: [],+ archiveDisabledReason: null,+ pinDisabledReason: null,+ commandCenterDisabledReason: null,+ fileDisabledReason: null,+ isArchiving: false,+ isPinning: false,+ isFiling: false,+ pinSelected: vi.fn(),+ addSelectedToCommandCenter: vi.fn(),+ fileSelected: vi.fn(),+ archiveSelected: vi.fn(),+ }),+}));+vi.mock("@posthog/ui/features/canvas/components/CreateChannelModal", () => ({+ CreateChannelModal: () => null,+}));+vi.mock(+ "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog",+ () => ({ EditListItemAppearanceDialog: () => null }),+);+vi.mock("@posthog/ui/features/browser-tabs/useOpenBrowserTab", () => ({+ useOpenBrowserTab: () => vi.fn(),+}));+vi.mock("@posthog/ui/features/canvas/hooks/useFileTaskToChannel", () => ({+ useFileTaskToChannel: () => vi.fn(),+}));++import { useTaskSelectionStore } from "@posthog/ui/features/sidebar/taskSelectionStore";+import { WorkColumn } from "./WorkColumn";++function entry(index: number): {+ item: ChannelItemModel;+ channelId: string | undefined;+} {+ return {+ channelId: "channel-1",+ item: {+ key: `task:task-${index}`,+ kind: "task",+ id: `task-${index}`,+ title: `Session ${index}`,+ ts: Date.parse("2026-07-17T12:00:00.000Z") - index * 60_000,+ createdAt: Date.parse("2026-07-16T12:00:00.000Z"),+ pinned: false,+ rawStatus: null,+ environment: null,+ source: null,+ needsInput: false,+ unread: false,+ authorUser: null,+ authorName: null,+ authorUuid: "me-uuid",+ templateId: null,+ repository: null,+ branch: null,+ task: null,+ },+ };+}++function renderColumn() {+ return render(+ <Theme>+ <ChannelItemPreviewCardProvider>+ <WorkColumn />+ </ChannelItemPreviewCardProvider>+ </Theme>,+ );+}++// By text rather than by role: the column renders a whole sidebar, and a role+// query walks all of it computing accessible names.+function row(index: number): HTMLElement {+ const label = screen.getByText(`Session ${index}`);+ const option = label.closest('[role="option"]');+ if (!(option instanceof HTMLElement)) throw new Error("row is not an option");+ return option;+}++const navigate = mocks.navigate;++beforeEach(() => {+ for (const spy of Object.values(mocks.navigate)) spy.mockClear();+ mocks.items = [1, 2, 3, 4, 5].map(entry);+ useTaskSelectionStore.setState({ selectedTaskIds: [], lastClickedId: null });+});++afterEach(cleanup);++describe("WorkColumn", () => {+ it("opens a session on a plain click", () => {+ renderColumn();++ fireEvent.click(row(1));++ expect(navigate.toChannelTask).toHaveBeenCalledWith("channel-1", "task-1");+ expect(useTaskSelectionStore.getState().selectedTaskIds).toEqual([]);+ });++ it("adds and drops rows with a modifier click, without opening them", () => {+ renderColumn();++ fireEvent.click(row(1), { metaKey: true });+ fireEvent.click(row(3), { metaKey: true });++ expect(useTaskSelectionStore.getState().selectedTaskIds).toEqual([+ "task-1",+ "task-3",+ ]);+ expect(navigate.toChannelTask).not.toHaveBeenCalled();++ fireEvent.click(row(3), { metaKey: true });++ expect(useTaskSelectionStore.getState().selectedTaskIds).toEqual([+ "task-1",+ ]);+ });++ it("extends the selection to a whole range with shift", () => {+ renderColumn();++ fireEvent.click(row(1), { metaKey: true });+ fireEvent.click(row(4), { shiftKey: true });++ expect(useTaskSelectionStore.getState().selectedTaskIds).toEqual([+ "task-1",+ "task-2",+ "task-3",+ "task-4",+ ]);+ });++ it("offers the bulk bar for a selection and clears it on Escape", async () => {+ renderColumn();++ fireEvent.click(row(1), { metaKey: true });+ fireEvent.click(row(2), { metaKey: true });++ expect(screen.getByText("2 selected")).toBeInTheDocument();++ await userEvent.keyboard("{Escape}");++ expect(useTaskSelectionStore.getState().selectedTaskIds).toEqual([]);+ expect(screen.queryByText("2 selected")).not.toBeInTheDocument();+ });+});diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsxindex a93090334f34..18ace472a976 100644--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx@@ -27,35 +27,39 @@ import {TooltipTrigger,} from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";-import { useArchiveTask } from "@posthog/ui/features/archive/useArchiveTask";import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import {+ commandCenterAssigner,+ isInCommandCenter,+} from "@posthog/ui/features/canvas/commandCenterAssign";import { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";-import type { ChannelItemActions } from "@posthog/ui/features/canvas/components/ChannelItemRow";+import { ChannelItemRow } from "@posthog/ui/features/canvas/components/ChannelItemRow";import { CreateChannelModal } from "@posthog/ui/features/canvas/components/CreateChannelModal";import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";import { PresenceAvatars } from "@posthog/ui/features/canvas/components/PresenceAvatars";import { SidebarSearchInput } from "@posthog/ui/features/canvas/components/SidebarSearchHeader";import { SpaceRowControls } from "@posthog/ui/features/canvas/components/SpaceRowControls";-import type { TaskRowMenuProps } from "@posthog/ui/features/canvas/components/TaskRowMenu";-import { WorkItemRow } from "@posthog/ui/features/canvas/components/work/WorkItemRow";-import { WorkRowSurface } from "@posthog/ui/features/canvas/components/work/WorkRowSurface";+import { WorkRowSurface } from "@posthog/ui/features/canvas/components/WorkRowSurface";+import { useChannelItemSelection } from "@posthog/ui/features/canvas/hooks/useChannelItemSelection";+import { useChannelItemActions } from "@posthog/ui/features/canvas/hooks/useChannelItems";import {type Channel,useChannels,} from "@posthog/ui/features/canvas/hooks/useChannels";-import { useDashboardMutations } from "@posthog/ui/features/canvas/hooks/useDashboards";import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";import { useSpacePresence } from "@posthog/ui/features/canvas/hooks/useRecentSpaceTasks";import { useRecentWorkItems } from "@posthog/ui/features/canvas/hooks/useRecentWorkItems";import { useSidebarSearchFocus } from "@posthog/ui/features/canvas/hooks/useSidebarSearchFocus";import { useIsChannelUnread } from "@posthog/ui/features/canvas/hooks/useUnreadChannels";import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import { useCommandCenterStore } from "@posthog/ui/features/command-center/commandCenterStore";import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";+import { MarqueeOverlay } from "@posthog/ui/features/sidebar/components/MarqueeOverlay";+import { SidebarBulkActionBar } from "@posthog/ui/features/sidebar/components/SidebarBulkActionBar";import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";-import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";+import { useRenameTask } from "@posthog/ui/features/tasks/useTaskMutations";import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";-import { toast } from "@posthog/ui/primitives/toast";import {navigateToChannel,navigateToChannelDashboard,@@ -64,6 +68,7 @@ import {navigateToTaskDetail,} from "@posthog/ui/router/navigationBridge";import { track } from "@posthog/ui/shell/analytics";+import { logger } from "@posthog/ui/shell/logger";import { useRouterState } from "@tanstack/react-router";import {Fragment,@@ -75,8 +80,14 @@ import {useState,} from "react";+const log = logger.scope("work-column");+const RECENT_COLLAPSED_COUNT = 5;+// Recent leads with the newest work, so a pin neither floats a row to the top+// nor opens a section of its own. The row's badge is what says it is pinned.+const NO_PINNED_RUN = { pinnedRun: false } as const;+function SectionHeading({label,expanded,@@ -235,22 +246,10 @@ export function WorkColumn() {[items],);const dayStart = useLocalDayStart();- const pinnedKeys = useMemo(- () =>- new Set(- items- .filter((entry) => entry.item.pinned)- .map((entry) => entry.item.key),- ),- [items],- );const matchingItems = useMemo(() => {const all = items.map((entry) => entry.item);const filtered = filterChannelItems(all, { query, filters, me });- const unpinned = filtered.map((item) =>- item.pinned ? { ...item, pinned: false } : item,- );- return sortChannelItems(unpinned, sort);+ return sortChannelItems(filtered, sort, NO_PINNED_RUN);}, [items, query, filters, me, sort]);const spaceNameById = useMemo(() => new Map(channels.map((channel) => [channel.id, channel.name])),@@ -260,13 +259,17 @@ export function WorkColumn() {() => new Map(items.map(({ item, channelId }) => [item.key, channelId])),[items],);+ const channelIdOf = useCallback(+ (item: ChannelItemModel) => channelByKey.get(item.key),+ [channelByKey],+ );const spaceOf = useCallback((item: ChannelItemModel) => {- const channelId = channelByKey.get(item.key);+ const channelId = channelIdOf(item);const label = channelId ? spaceNameById.get(channelId) : undefined;return channelId && label ? { key: channelId, label } : null;},- [channelByKey, spaceNameById],+ [channelIdOf, spaceNameById],);const sections = useMemo(() =>@@ -276,6 +279,7 @@ export function WorkColumn() {new Date(dayStart),grouping,spaceOf,+ NO_PINNED_RUN,),[matchingItems, sort, dayStart, grouping, spaceOf],);@@ -288,54 +292,25 @@ export function WorkColumn() {);const presenceBySpace = useSpacePresence();- const { togglePin, setPinnedMany } = usePinnedTasks();- const { archiveTask } = useArchiveTask({ navigateUnscoped: true });- const { setPinned: setCanvasPinned } = useDashboardMutations();- const actions = useMemo<ChannelItemActions>(- () => ({- open: (item: ChannelItemModel) => {- const channelId = channelByKey.get(item.key);- if (item.kind === "canvas") {- if (channelId) navigateToChannelDashboard(channelId, item.id);- return;- }- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {- action_type: "open_task",- surface: "sidebar",- channel_id: channelId,- task_id: item.id,- });- if (channelId) navigateToChannelTask(channelId, item.id);- else navigateToTaskDetail(item.id);- },- togglePin: (item) => {- const pin =- item.kind === "canvas"- ? setCanvasPinned(item.id, !item.pinned)- : togglePin(item.id);- pin.catch(() => {- toast.error("Couldn't update pin");- });- },- setPinned: (batch, pinned) => {- const onError = () => {- toast.error("Couldn't update pin");- };- const taskIds = batch- .filter((item) => item.kind !== "canvas")- .map((item) => item.id);- if (taskIds.length > 0) setPinnedMany(taskIds, pinned).catch(onError);- for (const item of batch) {- if (item.kind !== "canvas") continue;- setCanvasPinned(item.id, pinned).catch(onError);- }- },- archive: (item) => {- void archiveTask({ taskId: item.id });- },- }),- [archiveTask, channelByKey, setCanvasPinned, setPinnedMany, togglePin],+ const open = useCallback(+ (item: ChannelItemModel) => {+ const channelId = channelIdOf(item);+ if (item.kind === "canvas") {+ if (channelId) navigateToChannelDashboard(channelId, item.id);+ return;+ }+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: "open_task",+ surface: "sidebar",+ channel_id: channelId,+ task_id: item.id,+ });+ if (channelId) navigateToChannelTask(channelId, item.id);+ else navigateToTaskDetail(item.id);+ },+ [channelIdOf],);+ const actions = useChannelItemActions({ channelIdOf, open });const showAllRecent = useDeferredValue(recentExpanded || needle !== "");const recentRebuilding = showAllRecent !== (recentExpanded || needle !== "");@@ -357,28 +332,32 @@ export function WorkColumn() {const canExpandRecent =needle === "" && matchingItems.length > RECENT_COLLAPSED_COUNT;const recentFills = recentOpen && recentExpanded;+ const {+ selectedTaskIds,+ clearSelection,+ bulkActions,+ archiveConfirm,+ marquee,+ listAnchorRef,+ onRowClick,+ } = useChannelItemSelection({ listItems: shownItems, activeKey, open });+ const commandCenterCells = useCommandCenterStore((state) => state.cells);+ const { renameTask } = useRenameTask();+ const [editingTaskId, setEditingTaskId] = useState<string | null>(null);+const optionValues = useMemo(() => [- ...shownItems.map((item) => item.key),+ ...shownItems+ .filter((item) => item.id !== editingTaskId)+ .map((item) => item.key),...starredSpaces.map((channel) => channel.id),],- [shownItems, starredSpaces],+ [shownItems, starredSpaces, editingTaskId],);const spaceNameFor = (item: ChannelItemModel): string | undefined =>spaceOf(item)?.label;- const menuFor = (item: ChannelItemModel): TaskRowMenuProps => ({- kind: item.kind,- id: item.id,- title: item.title,- isPinned: pinnedKeys.has(item.key),- task: item.task ?? undefined,- channelId: channelByKey.get(item.key),- onTogglePin: () => actions.togglePin(item),- onArchive: item.kind === "task" ? () => actions.archive(item) : undefined,- });-return (<Autocomplete<string>inline@@ -402,8 +381,14 @@ export function WorkColumn() {<AutocompleteList className="sidebar-autocomplete-tree !max-h-none !px-2 !pt-2 !pb-2 flex min-h-0 flex-1 flex-col overflow-hidden">{/* The expanded list keeps a share of the column instead of all of it,so the spaces below it stay on screen. */}+ {/* Positioned and non-scrolling, because the marquee measures its band+ against this box and reads the rows inside it. */}<div- className={cn("flex min-h-0 flex-col", recentFills && "flex-[3]")}+ ref={listAnchorRef}+ className={cn(+ "relative flex min-h-0 flex-col",+ recentFills && "flex-[3]",+ )}><SectionHeadinglabel="Recent"@@ -477,23 +462,80 @@ export function WorkColumn() {{section.label}</div>)}- {section.items.map((item) => (- <WorkItemRow- key={item.key}- item={item}- isActive={item.key === activeKey}- onOpen={() => actions.open(item)}- menu={menuFor(item)}- spaceName={spaceNameFor(item)}- channelId={channelByKey.get(item.key)}- currentUserUuid={meUuid ?? undefined}- />- ))}+ {section.items.map((item) => {+ const inSelection =+ item.kind === "task" &&+ selectedTaskIds.includes(item.id);+ return (+ <ChannelItemRow+ key={item.key}+ item={item}+ optionValue={item.key}+ channelId={channelIdOf(item)}+ spaceName={spaceNameFor(item)}+ withPrStatus={false}+ isActive={item.key === activeKey}+ isSelected={inSelection}+ actions={actions}+ onClick={(event) => onRowClick(item, event)}+ bulk={+ inSelection && selectedTaskIds.length > 1+ ? {+ actions: bulkActions,+ onArchive: archiveConfirm.requestArchive,+ }+ : null+ }+ onContextMenuOpenChange={(open) => {+ if (open && !inSelection) clearSelection();+ }}+ isEditing={+ item.kind === "task" &&+ editingTaskId === item.id+ }+ onRename={+ item.kind === "task"+ ? () => setEditingTaskId(item.id)+ : undefined+ }+ onAddToCommandCenter={+ isInCommandCenter(item, commandCenterCells)+ ? undefined+ : commandCenterAssigner(item)+ }+ onEditSubmit={+ item.kind === "task"+ ? async (newTitle) => {+ setEditingTaskId(null);+ searchRef.current?.focus();+ try {+ await renameTask({+ taskId: item.id,+ currentTitle: item.title,+ newTitle,+ });+ } catch (error) {+ log.error(+ "Failed to rename task",+ error,+ );+ }+ }+ : undefined+ }+ onEditCancel={() => {+ setEditingTaskId(null);+ searchRef.current?.focus();+ }}+ />+ );+ })}</Fragment>))}</div>))}</div>+ <MarqueeOverlay rect={marquee} />{recentOpen && canExpandRecent && (<buttontype="button"@@ -566,7 +608,13 @@ export function WorkColumn() {)}</div></AutocompleteList>+ <SidebarBulkActionBar+ actions={bulkActions}+ onClearSelection={clearSelection}+ onArchive={archiveConfirm.requestArchive}+ /></div>+ {archiveConfirm.dialog}<CreateChannelModal open={createOpen} onOpenChange={setCreateOpen} /><EditListItemAppearanceDialogsurface="sidebar"diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkItemRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkItemRow.tsxdeleted file mode 100644index be4b41c01749..000000000000--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkItemRow.tsx+++ /dev/null@@ -1,106 +0,0 @@-import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";-import { cn } from "@posthog/quill";-import { formatRelativeTimeShort } from "@posthog/shared";-import { writeCanvasDragData } from "@posthog/ui/features/canvas/canvasDrag";-import { ChannelItemHoverCard } from "@posthog/ui/features/canvas/components/ChannelItemHoverCard";-import { RowPresence } from "@posthog/ui/features/canvas/components/ChannelItemPresence";-import { iconForTemplate } from "@posthog/ui/features/canvas/components/canvasTemplateIcon";-import {- TaskRowContextMenu,- type TaskRowMenuProps,-} from "@posthog/ui/features/canvas/components/TaskRowMenu";-import { WorkRowSurface } from "@posthog/ui/features/canvas/components/work/WorkRowSurface";-import { useChannelItemMetadata } from "@posthog/ui/features/canvas/hooks/useChannelItemFacts";-import { useChannelTaskStatus } from "@posthog/ui/features/canvas/hooks/useChannelTaskStatus";-import { TaskStatusDot } from "@posthog/ui/features/sidebar/components/items/TaskStatusDot";-import { taskDot } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";-import { writeTaskDragData } from "@posthog/ui/features/sidebar/taskDrag";-import {- OverflowTickerText,- useOverflowTickerReveal,-} from "@posthog/ui/primitives/OverflowTickerText";-import { type DragEvent, useCallback } from "react";--export function WorkItemRow({- item,- menu,- spaceName,- channelId,- isActive,- currentUserUuid,- onOpen,-}: {- item: ChannelItemModel;- menu: TaskRowMenuProps;- spaceName: string | undefined;- channelId: string | undefined;- isActive: boolean;- currentUserUuid: string | undefined;- onOpen: () => void;-}) {- const status = useChannelTaskStatus(item, { withPrStatus: false });- const subtitle = useChannelItemMetadata(item, spaceName);- const { reveal, hoverProps, focusProps } = useOverflowTickerReveal();- const handleDragStart = useCallback(- (event: DragEvent<HTMLElement>) => {- if (item.kind === "canvas") {- writeCanvasDragData(event.dataTransfer, item.id, {- name: item.title,- channelId: channelId ?? null,- });- event.dataTransfer.effectAllowed = "copy";- return;- }- writeTaskDragData(event.dataTransfer, item.id);- event.dataTransfer.effectAllowed = "copyMove";- },- [channelId, item.id, item.kind, item.title],- );- return (- <TaskRowContextMenu menu={menu}>- <ChannelItemHoverCard item={item} menu={menu}>- <WorkRowSurface- optionValue={item.key}- data-selected={isActive || undefined}- onClick={onOpen}- draggable- onDragStart={handleDragStart}- className={subtitle ? "h-auto py-1" : undefined}- {...hoverProps}- {...focusProps}- >- <span- className={cn(- "flex size-3.5 shrink-0 items-center justify-center",- subtitle && "self-start pt-0.5",- )}- >- {item.kind === "canvas" ? (- iconForTemplate(item.templateId ?? "freeform", {- size: 13,- className: "text-violet-9",- })- ) : (- <TaskStatusDot dot={taskDot(status ?? {})} hitArea="row" />- )}- </span>- <span className="flex min-w-0 flex-1 flex-col">- <OverflowTickerText reveal={reveal}>- {item.title}- </OverflowTickerText>- {subtitle && (- <span className="truncate text-muted-foreground/70 text-xxs group-data-selected/button:text-muted-foreground">- {subtitle}- </span>- )}- </span>-- <RowPresence item={item} currentUserUuid={currentUserUuid} />- <span className="shrink-0 text-[11px] text-muted-foreground tabular-nums opacity-0 transition-opacity group-hover/button:opacity-100 group-data-selected/button:opacity-100">- {formatRelativeTimeShort(item.ts)}- </span>- </WorkRowSurface>- </ChannelItemHoverCard>- </TaskRowContextMenu>- );-}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.tsx b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.tsxindex a3102566ac25..ac940fb42c40 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.tsx+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.tsx@@ -29,7 +29,7 @@ import { useWorkspaces } from "@posthog/ui/features/workspace/useWorkspace";import { toast } from "@posthog/ui/primitives/toast";import { track } from "@posthog/ui/shell/analytics";import { useNavigate } from "@tanstack/react-router";-import { useMemo } from "react";+import { useCallback, useMemo } from "react";/*** A channel's canvases + task feed as merged items, most recently active first, plus the@@ -71,32 +71,20 @@ export function useChannelSessionFacts(): ChannelSessionFacts {}, [sessions, timestamps, workspaces]);}-export function useChannelItems(channelId: string): {- items: ChannelItemModel[];- actions: ChannelItemActions;- /** Who the viewer is, for the created-by filter. */- me: ChannelItemOwner;- isLoading: boolean;- /** The channel id resolves to no channel in this project. */- channelMissing: boolean;-} {- const navigate = useNavigate();-- const { channels, isLoading: channelsLoading } = useChannels();- const channel = channels.find((c) => c.id === channelId);- const identityKnown = channel !== undefined;- const isPersonal = channel?.channelType === "personal";-- const { dashboards, isLoading: dashboardsLoading } = useDashboards(channelId);- const { tasks: feedTasks, isLoading: feedLoading } =- useChannelFeed(channelId);- const { tasks: filedTaskRecords, isLoading: filedTasksLoading } =- useChannelTasks(channelId);- const { data: allTasks = [], isLoading: allTasksLoading } = useTasks({- showAllUsers: true,- });- const archivedTaskIds = useArchivedTaskIds();- const { pinnedTaskIds, togglePin, setPinnedMany } = usePinnedTasks();+/**+ * The actions a row offers, for any list of channel items. Channel-agnostic on+ * purpose: the Work column's Recent list spans every space, so the channel a+ * row belongs to is asked per item rather than closed over.+ */+export function useChannelItemActions({+ channelIdOf,+ open,+}: {+ channelIdOf: (item: ChannelItemModel) => string | undefined;+ open: (item: ChannelItemModel) => void;+}): ChannelItemActions {+ const { channels } = useChannels();+ const { togglePin, setPinnedMany } = usePinnedTasks();const { archiveTask } = useArchiveTask({ navigateUnscoped: true });const {setPinned: setCanvasPinned,@@ -104,89 +92,10 @@ export function useChannelItems(channelId: string): {invalidateDashboards,} = useDashboardMutations();const primeCanvasView = usePrimeCanvasView();- const client = useOptionalAuthenticatedClient();- const { data: currentUser, isLoading: viewerLoading } = useCurrentUser({- client,- });-- // What the filters ask about beyond the task itself: a live session's- // permission prompt, when you last looked, and where the workspace is. The- // session map is the sidebar's own subscription, which ignores the streamed- // events a turn fires and only wakes on the fields a row reads.- const sessionFacts = useChannelSessionFacts();- const meUuid = currentUser?.uuid ?? null;- const me = useMemo<ChannelItemOwner>(() => ({ uuid: meUuid }), [meUuid]);- // Only a uuid establishes identity — ownership compares uuids, so a viewer- // resolved without one can't be matched against anything and reads as unknown.- const viewerKnown = meUuid != null;-- const items = useMemo<ChannelItemModel[]>(() => {- if (!identityKnown || (isPersonal && !viewerKnown)) return [];-- const tasksById = new Map(allTasks.map((task) => [task.id, task]));- const mergedTasks = [...feedTasks];- const seenTaskIds = new Set(feedTasks.map((task) => task.id));- for (const record of filedTaskRecords) {- const task = tasksById.get(record.taskId);- if (task && !seenTaskIds.has(task.id)) {- mergedTasks.push(task);- seenTaskIds.add(task.id);- }- }-- return buildChannelItems({- dashboards,- feedTasks: mergedTasks,- archivedTaskIds,- pinnedTaskIds,- // The personal channel is yours — but don't filter until we know- // who you are, or #me flashes everyone's items on a cold load.- ownedBy: isPersonal && viewerKnown ? me : null,- sessionFacts,- });- }, [- identityKnown,- sessionFacts,- dashboards,- feedTasks,- filedTaskRecords,- allTasks,- archivedTaskIds,- pinnedTaskIds,- isPersonal,- viewerKnown,- me,- ]);- const actions = useMemo<ChannelItemActions>(+ return useMemo<ChannelItemActions>(() => ({- open: (item) => {- if (item.kind === "canvas") {- // Canvases report as dashboard opens, the same event the canvases- // pane fires, so the two entry points can be compared.- track(ANALYTICS_EVENTS.DASHBOARD_ACTION, {- action_type: "open",- surface: "sidebar",- channel_id: channelId,- dashboard_id: item.id,- });- void navigate({- to: "/spaces/$channelId/dashboards/$dashboardId",- params: { channelId, dashboardId: item.id },- });- } else {- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {- action_type: "open_task",- surface: "sidebar",- channel_id: channelId,- task_id: item.id,- });- void navigate({- to: "/spaces/$channelId/tasks/$taskId",- params: { channelId, taskId: item.id },- });- }- },+ open,togglePin: (item) => {const pin =item.kind === "canvas"@@ -255,7 +164,7 @@ export function useChannelItems(channelId: string): {if (item.kind !== "canvas") return;deleteCanvasWithUndo({dashboardId: item.id,- channelId,+ channelId: channelIdOf(item) ?? "",name: item.title,surface: "sidebar",invalidate: invalidateDashboards,@@ -264,8 +173,8 @@ export function useChannelItems(channelId: string): {primeCanvas: primeCanvasView,}),[- channelId,- navigate,+ open,+ channelIdOf,setCanvasPinned,togglePin,setPinnedMany,@@ -276,6 +185,124 @@ export function useChannelItems(channelId: string): {primeCanvasView,],);+}++export function useChannelItems(channelId: string): {+ items: ChannelItemModel[];+ actions: ChannelItemActions;+ /** Who the viewer is, for the created-by filter. */+ me: ChannelItemOwner;+ isLoading: boolean;+ /** The channel id resolves to no channel in this project. */+ channelMissing: boolean;+} {+ const navigate = useNavigate();++ const { channels, isLoading: channelsLoading } = useChannels();+ const channel = channels.find((c) => c.id === channelId);+ const identityKnown = channel !== undefined;+ const isPersonal = channel?.channelType === "personal";++ const { dashboards, isLoading: dashboardsLoading } = useDashboards(channelId);+ const { tasks: feedTasks, isLoading: feedLoading } =+ useChannelFeed(channelId);+ const { tasks: filedTaskRecords, isLoading: filedTasksLoading } =+ useChannelTasks(channelId);+ const { data: allTasks = [], isLoading: allTasksLoading } = useTasks({+ showAllUsers: true,+ });+ const archivedTaskIds = useArchivedTaskIds();+ const { pinnedTaskIds } = usePinnedTasks();+ const client = useOptionalAuthenticatedClient();+ const { data: currentUser, isLoading: viewerLoading } = useCurrentUser({+ client,+ });++ // What the filters ask about beyond the task itself: a live session's+ // permission prompt, when you last looked, and where the workspace is. The+ // session map is the sidebar's own subscription, which ignores the streamed+ // events a turn fires and only wakes on the fields a row reads.+ const sessionFacts = useChannelSessionFacts();+ const meUuid = currentUser?.uuid ?? null;+ const me = useMemo<ChannelItemOwner>(() => ({ uuid: meUuid }), [meUuid]);+ // Only a uuid establishes identity — ownership compares uuids, so a viewer+ // resolved without one can't be matched against anything and reads as unknown.+ const viewerKnown = meUuid != null;++ const items = useMemo<ChannelItemModel[]>(() => {+ if (!identityKnown || (isPersonal && !viewerKnown)) return [];++ const tasksById = new Map(allTasks.map((task) => [task.id, task]));+ const mergedTasks = [...feedTasks];+ const seenTaskIds = new Set(feedTasks.map((task) => task.id));+ for (const record of filedTaskRecords) {+ const task = tasksById.get(record.taskId);+ if (task && !seenTaskIds.has(task.id)) {+ mergedTasks.push(task);+ seenTaskIds.add(task.id);+ }+ }++ return buildChannelItems({+ dashboards,+ feedTasks: mergedTasks,+ archivedTaskIds,+ pinnedTaskIds,+ // The personal channel is yours — but don't filter until we know+ // who you are, or #me flashes everyone's items on a cold load.+ ownedBy: isPersonal && viewerKnown ? me : null,+ sessionFacts,+ });+ }, [+ identityKnown,+ sessionFacts,+ dashboards,+ feedTasks,+ filedTaskRecords,+ allTasks,+ archivedTaskIds,+ pinnedTaskIds,+ isPersonal,+ viewerKnown,+ me,+ ]);++ const openInChannel = useCallback(+ (item: ChannelItemModel) => {+ if (item.kind === "canvas") {+ // Canvases report as dashboard opens, the same event the canvases+ // pane fires, so the two entry points can be compared.+ track(ANALYTICS_EVENTS.DASHBOARD_ACTION, {+ action_type: "open",+ surface: "sidebar",+ channel_id: channelId,+ dashboard_id: item.id,+ });+ void navigate({+ to: "/spaces/$channelId/dashboards/$dashboardId",+ params: { channelId, dashboardId: item.id },+ });+ return;+ }+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: "open_task",+ surface: "sidebar",+ channel_id: channelId,+ task_id: item.id,+ });+ void navigate({+ to: "/spaces/$channelId/tasks/$taskId",+ params: { channelId, taskId: item.id },+ });+ },+ [channelId, navigate],+ );++ const channelIdOf = useCallback(() => channelId, [channelId]);+ const actions = useChannelItemActions({+ channelIdOf,+ open: openInChannel,+ });// A channel that isn't in the list will never resolve, so stop reporting// loading and let the caller say so instead of spinning forever.