Skip to content

: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.

fix(desktop): keep spaces visible when recent work expands (#104302)

Shy Alter8b445f54ed35
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.tsx
new file mode 100644
index 000000000000..eb5248ed9cc6
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.stories.tsx
@@ -0,0 +1,109 @@
+import type { Task, TaskChannel } from "@posthog/shared/domain-types";
+import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
+import { taskKeys } from "@posthog/ui/features/tasks/taskKeys";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { WorkColumn } from "./WorkColumn";
+
+const ME_ID = 1;
+const HOUR = 60 * 60 * 1000;
+
+function task(index: number, title: string, hoursAgo: number): Task {
+ const at = new Date(Date.UTC(2026, 6, 1, 10, 30) - hoursAgo * HOUR);
+ return {
+ id: `task-${index}`,
+ task_number: index,
+ slug: `task-${index}`,
+ title,
+ description: "",
+ created_at: at.toISOString(),
+ updated_at: at.toISOString(),
+ last_activity_at: at.toISOString(),
+ origin_product: "user_created",
+ channel: "channel-personal",
+ created_by: { id: ME_ID, uuid: "me-uuid", first_name: "Sam", email: null },
+ };
+}
+
+const TASK_TITLES = [
+ "Trim the empty state on the endpoints list",
+ "Cache the repository picker between opens",
+ "Drop the duplicate poll on the activity feed",
+ "Make the filter menu remember its last sort",
+ "Handle a missing avatar on a mention row",
+ "Split the oversized settings module",
+ "Add a retry to the flaky upload test",
+ "Rename the branch column in the runs table",
+ "Fix the caret alignment in the sidebar tree",
+ "Stop the toast from covering the composer",
+ "Measure how long a cold start takes",
+ "Move the copy button beside the title",
+ "Guard the submit button against a double click",
+ "Truncate long space names in the picker",
+];
+
+const TASKS: Task[] = TASK_TITLES.map((title, index) =>
+ task(index + 1, title, index * 3),
+);
+
+function channel(
+ name: string,
+ overrides: Partial<TaskChannel> = {},
+): TaskChannel {
+ return {
+ id: `channel-${name}`,
+ name,
+ channel_type: "public",
+ starred: true,
+ created_at: "2026-06-01T00:00:00Z",
+ ...overrides,
+ };
+}
+
+const CHANNELS: TaskChannel[] = [
+ channel("me", { channel_type: "personal", system_role: "personal" }),
+ channel("desktop-canvas"),
+ channel("desktop-cost-management"),
+ channel("desktop-multiplayer"),
+ channel("desktop-subscriptions"),
+ channel("growth-experiments"),
+ channel("ingestion-pipeline"),
+ channel("replay-vision"),
+ channel("support-triage"),
+ channel("web-analytics"),
+];
+
+/**
+ * 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 {
+ 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);
+ return client;
+}
+
+const meta = {
+ title: "Canvas/WorkColumn",
+ component: WorkColumn,
+ parameters: { layout: "fullscreen" },
+ decorators: [
+ (Story) => (
+ <QueryClientProvider client={seededClient()}>
+ <div className="h-screen w-[280px] border-border border-r">
+ <Story />
+ </div>
+ </QueryClientProvider>
+ ),
+ ],
+} satisfies Meta<typeof WorkColumn>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+/** Recent capped at five rows, spaces below it. */
+export const Default: Story = {};
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.tsx
index bb2d252cc2f5..a93090334f34 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
@@ -356,6 +356,7 @@ export function WorkColumn() {
);
const canExpandRecent =
needle === "" && matchingItems.length > RECENT_COLLAPSED_COUNT;
+ const recentFills = recentOpen && recentExpanded;
const optionValues = useMemo(
() => [
...shownItems.map((item) => item.key),
@@ -398,114 +399,129 @@ export function WorkColumn() {
<ChromeBar>
<h2 className="font-bold text-base">Work</h2>
</ChromeBar>
- <AutocompleteList className="sidebar-autocomplete-tree scroll-mask-8 !max-h-none !px-2 !pt-2 !pb-2 min-h-0 flex-1 scroll-py-8 flex-col gap-px overflow-y-auto">
- <SectionHeading
- label="Recent"
- expanded={recentOpen}
- onToggle={() => setRecentOpen((value) => !value)}
- />
- {recentOpen && (
- <div className="flex items-center gap-1 px-1 pt-0.5 pb-1.5">
- <SidebarSearchInput
- ref={searchRef}
- query={query}
- placeholder="Search recent…"
- searchLabel="Search recent"
- onClear={() => setQuery("")}
- className="min-w-0 flex-1"
- />
- <ChannelFilterMenu
- filters={filters}
- onFilterChange={(key, value) =>
- setFilters({ ...filters, [key]: value })
- }
- onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}
- sort={sort}
- onSortChange={setSort}
- grouping={grouping}
- onGroupingChange={setGrouping}
- onEditAppearance={() => setAppearanceOpen(true)}
- sources={sources}
- showCreatedBy
- showRunFilters
- showKindFilter
- groupings={["date", "space", "repository"]}
- active={hasActiveChannelItemFilters(filters)}
- />
- </div>
- )}
- {recentOpen &&
- (isLoading && items.length === 0 ? (
- <div className="flex flex-col gap-2 px-2 py-1.5">
- <Skeleton className="h-3.5 w-4/5" />
- <Skeleton className="h-3.5 w-3/5" />
- <Skeleton className="h-3.5 w-2/3" />
+ <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. */}
+ <div
+ className={cn("flex min-h-0 flex-col", recentFills && "flex-[3]")}
+ >
+ <SectionHeading
+ label="Recent"
+ expanded={recentOpen}
+ onToggle={() => setRecentOpen((value) => !value)}
+ />
+ {recentOpen && (
+ <div className="flex items-center gap-1 px-1 pt-0.5 pb-1.5">
+ <SidebarSearchInput
+ ref={searchRef}
+ query={query}
+ placeholder="Search recent…"
+ searchLabel="Search recent"
+ onClear={() => setQuery("")}
+ className="min-w-0 flex-1"
+ />
+ <ChannelFilterMenu
+ filters={filters}
+ onFilterChange={(key, value) =>
+ setFilters({ ...filters, [key]: value })
+ }
+ onClearFilters={() =>
+ setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)
+ }
+ sort={sort}
+ onSortChange={setSort}
+ grouping={grouping}
+ onGroupingChange={setGrouping}
+ onEditAppearance={() => setAppearanceOpen(true)}
+ sources={sources}
+ showCreatedBy
+ showRunFilters
+ showKindFilter
+ groupings={["date", "space", "repository"]}
+ active={hasActiveChannelItemFilters(filters)}
+ />
</div>
- ) : shownItems.length === 0 ? (
- <p className="px-2 py-1 text-[12px] text-muted-foreground">
- {needle || hasActiveChannelItemFilters(filters)
- ? "Nothing here matches."
- : "Sessions and canvases you open show up here."}
- </p>
- ) : (
- <div
- className={cn(
- "flex flex-col gap-px transition-opacity duration-150",
- recentRebuilding && "pointer-events-none opacity-50",
- )}
- >
- {shownSections.map((section, index) => (
- <Fragment key={section.key}>
- {section.label && (
- <div
- className={cn(
- "px-2 pb-1 font-medium text-[11px] text-muted-foreground",
- index === 0
- ? "pt-1"
- : "mt-2 border-border/70 border-t pt-2",
- )}
- >
- {section.label}
- </div>
+ )}
+ <div className="scroll-mask-8 flex min-h-0 flex-1 scroll-py-8 flex-col gap-px overflow-y-auto">
+ {recentOpen &&
+ (isLoading && items.length === 0 ? (
+ <div className="flex flex-col gap-2 px-2 py-1.5">
+ <Skeleton className="h-3.5 w-4/5" />
+ <Skeleton className="h-3.5 w-3/5" />
+ <Skeleton className="h-3.5 w-2/3" />
+ </div>
+ ) : shownItems.length === 0 ? (
+ <p className="px-2 py-1 text-[12px] text-muted-foreground">
+ {needle || hasActiveChannelItemFilters(filters)
+ ? "Nothing here matches."
+ : "Sessions and canvases you open show up here."}
+ </p>
+ ) : (
+ <div
+ className={cn(
+ "flex flex-col gap-px transition-opacity duration-150",
+ recentRebuilding && "pointer-events-none opacity-50",
)}
- {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}
- />
+ >
+ {shownSections.map((section, index) => (
+ <Fragment key={section.key}>
+ {section.label && (
+ <div
+ className={cn(
+ "px-2 pb-1 font-medium text-[11px] text-muted-foreground",
+ index === 0
+ ? "pt-1"
+ : "mt-2 border-border/70 border-t pt-2",
+ )}
+ >
+ {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}
+ />
+ ))}
+ </Fragment>
))}
- </Fragment>
+ </div>
))}
- </div>
- ))}
- {recentOpen && canExpandRecent && (
- <button
- type="button"
- aria-expanded={recentExpanded}
- className="group/expand mt-0.5 flex h-6 w-full items-center justify-center gap-1 rounded-md text-[11px] text-muted-foreground transition-colors hover:bg-fill-hover hover:text-foreground"
- onClick={() => setRecentExpanded((value) => !value)}
- >
- {recentExpanded ? (
- <>
- <CaretUpIcon size={11} weight="bold" />
- Show fewer
- </>
- ) : (
- <>
- <CaretDownIcon size={11} weight="bold" />
- {matchingItems.length - shownItems.length} more
- </>
- )}
- </button>
- )}
+ </div>
+ {recentOpen && canExpandRecent && (
+ <button
+ type="button"
+ aria-expanded={recentExpanded}
+ className="group/expand mt-0.5 flex h-6 w-full shrink-0 items-center justify-center gap-1 rounded-md text-[11px] text-muted-foreground transition-colors hover:bg-fill-hover hover:text-foreground"
+ onClick={() => setRecentExpanded((value) => !value)}
+ >
+ {recentExpanded ? (
+ <>
+ <CaretUpIcon size={11} weight="bold" />
+ Show fewer
+ </>
+ ) : (
+ <>
+ <CaretDownIcon size={11} weight="bold" />
+ {matchingItems.length - shownItems.length} more
+ </>
+ )}
+ </button>
+ )}
+ </div>
- <div className="mt-2">
+ <div
+ className={cn(
+ "mt-2 flex min-h-0 flex-col",
+ recentFills ? "flex-[2]" : "flex-1",
+ )}
+ >
<SectionHeading
label="Spaces"
expanded={spacesExpanded}
@@ -526,7 +542,7 @@ export function WorkColumn() {
}
/>
{spacesExpanded && (
- <div className="flex flex-col gap-px">
+ <div className="scroll-mask-8 flex min-h-0 flex-1 scroll-py-8 flex-col gap-px overflow-y-auto">
{starredSpaces.map((channel) => (
<SpaceRow
key={channel.id}