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): replace work column space row buttons with a hover card (#105400)

Shy Alter2803922661c0
diff --git a/products/desktop/packages/ui/src/features/canvas/AGENTS.md b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
index 30c799e7f114..72c8e844e32f 100644
--- a/products/desktop/packages/ui/src/features/canvas/AGENTS.md
+++ b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
@@ -180,7 +180,8 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
(memoize the `menu`), and a surface that lists rows has to sit under the
provider, or its rows get no card at all.
- **A space has a card too, on the same handle.** `SpaceHoverCard` is a trigger on the one popup the session rows use, so crossing from a space to a session under it swaps the card's contents instead of closing one popup and opening another. The payload is a discriminated union (`ChannelPreviewPayload`), and `kind` picks `SpacePreview` or `ChannelItemPreview`.
- It shows who has been working in the space, what it is wired to, and the counts the row draws as dots: the creator leads the avatar group wearing a crown, then whoever ran the newest sessions.
+ It shows what kind of space it is, how many sessions it holds and when someone last worked in it, who has been working in the space, what it is wired to, and the counts the row draws as dots: the creator leads the avatar group wearing a crown, then whoever ran the newest sessions.
+ The work column's space rows (`WorkColumn`) carry no hover buttons: their actions, New session first, live in this card and the row's right-click menu. Buttons that appear on hover push the row's faces and dot aside.
The people are not a membership list — the backend has none. They come from `useSpaceOverview`, off the same `space-tree-tasks` page the tree's rows are built from, which the row's own hover prefetch has already warmed, so the card costs no request.
The group is `reverse`d, so each face tucks behind the one after it — which puts the creator's right corner under its neighbour, so the crown goes on its left corner instead.
`useChannelActions` memoizes its action list, and `ChannelSection` memoizes the payload, because both travel to the card's store on every identity change. Its memo comparator also compares `repositories` by content — the channel list is polled and hands out a new array each time.
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.stories.tsx
index 4d69cd06161d..3dde169175c6 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.stories.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.stories.tsx
@@ -14,11 +14,13 @@ function CardFrame({
people,
liveUuids,
total,
+ lastActivityAt,
...payload
}: SpacePreviewPayload & {
people: UserBasic[];
liveUuids?: string[];
total: number | null;
+ lastActivityAt: string | null;
}) {
return (
<div className="p-4">
@@ -31,6 +33,7 @@ function CardFrame({
people={people}
liveUuids={liveUuids ? new Set(liveUuids) : undefined}
total={total}
+ lastActivityAt={lastActivityAt}
onAction={() => {}}
/>
</Card>
@@ -86,6 +89,7 @@ const meta = {
blockedSessions: 0,
actions,
total: 14,
+ lastActivityAt: "2026-07-01T08:30:00Z",
people: [
user(1, "Ada", "Lovelace"),
user(2, "Grace", "Hopper"),
@@ -130,3 +134,18 @@ export const ManyRepos: Story = {
},
},
};
+
+export const Private: Story = {
+ args: {
+ channel: {
+ id: "channel-3",
+ name: "launch-planning",
+ channelType: "private",
+ starred: true,
+ repositories: [],
+ createdBy: user(1, "Ada", "Lovelace"),
+ },
+ total: 3,
+ people: [user(1, "Ada", "Lovelace"), user(2, "Grace", "Hopper")],
+ },
+};
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
index 039ea98750cb..f6b97e7e520a 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpacePreview.tsx
@@ -8,6 +8,7 @@ import {
ItemSeparator,
ItemTitle,
} from "@posthog/quill";
+import { formatRelativeAge } from "@posthog/shared";
import type { UserBasic } from "@posthog/shared/domain-types";
import {
type ChannelActionItem,
@@ -37,6 +38,12 @@ const MAX_PEOPLE = 5;
/** Repos past this are counted rather than named — the card has one line. */
const MAX_REPOS = 3;
+const SPACE_KIND: Record<Channel["channelType"], string> = {
+ public: "Space",
+ private: "Private space",
+ personal: "Personal space",
+};
+
/** A counted signal, drawn as the dot the row shows for it plus the words. */
function CountSignal({
count,
@@ -138,6 +145,7 @@ export function SpacePreviewContent({
people,
liveUuids,
total,
+ lastActivityAt,
onAction,
}: {
payload: SpacePreviewPayload;
@@ -146,6 +154,7 @@ export function SpacePreviewContent({
liveUuids?: ReadonlySet<string>;
/** Sessions in the space, or `null` while the page hasn't arrived. */
total: number | null;
+ lastActivityAt: string | null;
onAction: () => void;
}) {
const { channel, unreadSessions, blockedSessions, actions } = payload;
@@ -177,9 +186,16 @@ export function SpacePreviewContent({
{/* No count until the page lands: "0 sessions" on a space that has
them is a wrong answer, and the card is about to have a right
one. */}
- {total == null
- ? "Space"
- : `Space \u00b7 ${total} ${total === 1 ? "session" : "sessions"}`}
+ <span className="block">
+ {SPACE_KIND[channel.channelType]}
+ {total != null &&
+ ` \u00b7 ${total} ${total === 1 ? "session" : "sessions"}`}
+ </span>
+ {lastActivityAt && (
+ <span className="block">
+ Active {formatRelativeAge(lastActivityAt)}
+ </span>
+ )}
</ItemDescription>
</ItemContent>
{/* Top-aligned: the people belong to the space's name, not to the
@@ -231,6 +247,7 @@ export function SpacePreview({
people={overview.people}
liveUuids={overview.liveUuids}
total={overview.total}
+ lastActivityAt={overview.lastActivityAt}
onAction={onAction}
/>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsx
deleted file mode 100644
index a0eeacc8bbb4..000000000000
--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { PlusIcon } from "@phosphor-icons/react";
-import {
- Button,
- ButtonGroup,
- cn,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@posthog/quill";
-import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
-import {
- ChannelMenu,
- useChannelActions,
-} from "@posthog/ui/features/canvas/components/ChannelsList";
-import { SpaceActionDialogs } from "@posthog/ui/features/canvas/components/SpaceActionDialogs";
-import type { Channel } from "@posthog/ui/features/canvas/hooks/useChannels";
-import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
-import { openTaskInput } from "@posthog/ui/router/useOpenTask";
-import { track } from "@posthog/ui/shell/analytics";
-import { useState } from "react";
-
-export function SpaceRowControls({ channel }: { channel: Channel }) {
- const spacesLayout = useChannelsLayout();
- const noun = spacesLayout ? "space" : "channel";
- const [menuOpen, setMenuOpen] = useState(false);
- const channelActions = useChannelActions(channel);
- const { actions } = channelActions;
-
- const newTask = () => {
- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
- action_type: "new_task_open",
- surface: "sidebar",
- channel_id: channel.id,
- });
- openTaskInput({ channelId: channel.id });
- };
-
- return (
- <>
- <div className="absolute top-1 right-1">
- <ButtonGroup>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="outline"
- size="icon-xs"
- aria-label={`New session in ${channel.name}`}
- className={cn(
- "gap-1 transition-opacity group-hover:border-border",
- menuOpen
- ? "opacity-100"
- : "opacity-0 group-hover/chan:opacity-100",
- )}
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- newTask();
- }}
- >
- <PlusIcon size={12} weight="bold" />
- </Button>
- }
- />
- <TooltipContent side="top">New session</TooltipContent>
- </Tooltip>
- <ChannelMenu
- channelName={channel.name}
- actions={actions}
- open={menuOpen}
- onOpenChange={setMenuOpen}
- />
- </ButtonGroup>
- </div>
-
- <SpaceActionDialogs
- channel={channel}
- noun={noun}
- actions={channelActions}
- />
- </>
- );
-}
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.tsx
index cb22ed5dd0b3..4bb564009907 100644
--- 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.tsx
@@ -45,6 +45,12 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
vi.mock("@posthog/ui/features/canvas/hooks/useRecentSpaceTasks", () => ({
useSpacePresence: () => new Map(),
}));
+vi.mock("@posthog/ui/features/canvas/hooks/useUnreadSessionCount", () => ({
+ useUnreadSessionCount: () => () => 0,
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useBlockedSessionCount", () => ({
+ useBlockedSessionCount: () => () => 0,
+}));
vi.mock("@posthog/ui/features/canvas/hooks/useUnreadChannels", () => ({
useIsChannelUnread: () => () => false,
}));
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 18ace472a976..92d4b8c078ca 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
@@ -19,6 +19,9 @@ import {
Autocomplete,
AutocompleteList,
Button,
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuTrigger,
cn,
MenuLabel,
Skeleton,
@@ -34,24 +37,36 @@ import {
isInCommandCenter,
} from "@posthog/ui/features/canvas/commandCenterAssign";
import { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";
+import { SpaceHoverCard } from "@posthog/ui/features/canvas/components/ChannelItemHoverCard";
import { ChannelItemRow } from "@posthog/ui/features/canvas/components/ChannelItemRow";
+import {
+ ChannelActionItems,
+ useChannelActions,
+} from "@posthog/ui/features/canvas/components/ChannelsList";
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 { SpaceActionDialogs } from "@posthog/ui/features/canvas/components/SpaceActionDialogs";
+import type { SpacePreviewPayload } from "@posthog/ui/features/canvas/components/SpacePreview";
import { WorkRowSurface } from "@posthog/ui/features/canvas/components/WorkRowSurface";
+import { useBlockedSessionCount } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
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 { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";
-import { useSpacePresence } from "@posthog/ui/features/canvas/hooks/useRecentSpaceTasks";
+import {
+ usePrefetchSpaceTasks,
+ 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 { useUnreadSessionCount } from "@posthog/ui/features/canvas/hooks/useUnreadSessionCount";
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";
@@ -67,6 +82,7 @@ import {
navigateToSpaces,
navigateToTaskDetail,
} from "@posthog/ui/router/navigationBridge";
+import { openTaskInput } from "@posthog/ui/router/useOpenTask";
import { track } from "@posthog/ui/shell/analytics";
import { logger } from "@posthog/ui/shell/logger";
import { useRouterState } from "@tanstack/react-router";
@@ -75,6 +91,7 @@ import {
type ReactNode,
useCallback,
useDeferredValue,
+ useEffect,
useMemo,
useRef,
useState,
@@ -84,6 +101,8 @@ const log = logger.scope("work-column");
const RECENT_COLLAPSED_COUNT = 5;
+const SESSION_PREFETCH_DELAY_MS = 250;
+
// 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;
@@ -145,63 +164,128 @@ function IconAction({
);
}
-function SpaceRow({
+export function SpaceRow({
channel,
isActive,
unread,
+ unreadSessions,
+ blockedSessions,
presence,
}: {
channel: Channel;
isActive: boolean;
unread: boolean;
+ unreadSessions: number;
+ blockedSessions: number;
presence: ChannelPresence | undefined;
}) {
const people = presence?.people ?? [];
+ const noun = useChannelsLayout() ? "space" : "channel";
+ const channelActions = useChannelActions(channel);
+ const { actions } = channelActions;
+ const preview = useMemo<SpacePreviewPayload>(
+ () => ({
+ channel,
+ unreadSessions,
+ blockedSessions,
+ actions: [
+ {
+ key: "new-session",
+ label: "New session",
+ icon: <PlusIcon size={14} />,
+ onSelect: () => {
+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
+ action_type: "new_task_open",
+ surface: "sidebar",
+ channel_id: channel.id,
+ });
+ openTaskInput({ channelId: channel.id });
+ },
+ },
+ ...actions,
+ ],
+ }),
+ [channel, unreadSessions, blockedSessions, actions],
+ );
+
+ const prefetchSessions = usePrefetchSpaceTasks();
+ const prefetchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(
+ undefined,
+ );
+ useEffect(() => () => clearTimeout(prefetchTimer.current), []);
+
return (
- <div className="group/chan group relative">
- <WorkRowSurface
- optionValue={channel.id}
- data-selected={isActive || undefined}
- onClick={() => {
- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
- action_type: "nav_click",
- surface: "sidebar",
- channel_id: channel.id,
- nav_target: "space",
- });
- navigateToChannel(channel.id);
- }}
- >
- <span className="flex size-3.5 shrink-0 items-center justify-center text-muted-foreground">
- {channelGlyph(channel.name, {
- size: 13,
- space: false,
- personal: channel.channelType === "personal",
- private: channel.channelType === "private",
- })}
- </span>
- <span
- className={cn("min-w-0 flex-1 truncate", unread && "font-semibold")}
- >
- {channel.name}
- </span>
- <span className="flex shrink-0 items-center gap-1.5 group-hover/chan:mr-11">
- {people.length > 0 && (
- <PresenceAvatars people={people} liveUuids={presence?.liveUuids} />
- )}
- {unread && !isActive && (
- <span
- role="img"
- aria-label="Unread"
- className="size-1.5 shrink-0 rounded-full bg-primary"
- />
- )}
- </span>
- </WorkRowSurface>
- {channel.channelType !== "personal" && (
- <SpaceRowControls channel={channel} />
- )}
- </div>
+ <>
+ <SpaceHoverCard space={preview}>
+ <ContextMenu>
+ <ContextMenuTrigger
+ render={
+ <WorkRowSurface
+ optionValue={channel.id}
+ data-selected={isActive || undefined}
+ onPointerEnter={() => {
+ clearTimeout(prefetchTimer.current);
+ prefetchTimer.current = setTimeout(
+ () => prefetchSessions(channel.id),
+ SESSION_PREFETCH_DELAY_MS,
+ );
+ }}
+ onPointerLeave={() => clearTimeout(prefetchTimer.current)}
+ onClick={() => {
+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
+ action_type: "nav_click",
+ surface: "sidebar",
+ channel_id: channel.id,
+ nav_target: "space",
+ });
+ navigateToChannel(channel.id);
+ }}
+ >
+ <span className="flex size-3.5 shrink-0 items-center justify-center text-muted-foreground">
+ {channelGlyph(channel.name, {
+ size: 13,
+ space: false,
+ personal: channel.channelType === "personal",
+ private: channel.channelType === "private",
+ })}
+ </span>
+ <span
+ className={cn(
+ "min-w-0 flex-1 truncate",
+ unread && "font-semibold",
+ )}
+ >
+ {channel.name}
+ </span>
+ <span className="flex shrink-0 items-center gap-1.5">
+ {people.length > 0 && (
+ <PresenceAvatars
+ people={people}
+ liveUuids={presence?.liveUuids}
+ />
+ )}
+ {unread && !isActive && (
+ <span
+ role="img"
+ aria-label="Unread"
+ className="size-1.5 shrink-0 rounded-full bg-primary"
+ />
+ )}
+ </span>
+ </WorkRowSurface>
+ }
+ />
+ <ContextMenuContent>
+ <ChannelActionItems actions={preview.actions} kind="context" />
+ </ContextMenuContent>
+ </ContextMenu>
+ </SpaceHoverCard>
+ <SpaceActionDialogs
+ channel={channel}
+ noun={noun}
+ actions={channelActions}
+ />
+ </>
);
}
@@ -292,6 +376,8 @@ export function WorkColumn() {
);
const presenceBySpace = useSpacePresence();
+ const unreadSessionCount = useUnreadSessionCount();
+ const blockedSessionCount = useBlockedSessionCount();
const open = useCallback(
(item: ChannelItemModel) => {
const channelId = channelIdOf(item);
@@ -591,6 +677,8 @@ export function WorkColumn() {
channel={channel}
isActive={channel.id === activeChannelId}
unread={isChannelUnread(channel.id)}
+ unreadSessions={unreadSessionCount(channel.id)}
+ blockedSessions={blockedSessionCount(channel.id)}
presence={presenceBySpace.get(channel.id)}
/>
))}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumnSpaceRow.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumnSpaceRow.stories.tsx
new file mode 100644
index 000000000000..c3bd04a39f70
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumnSpaceRow.stories.tsx
@@ -0,0 +1,194 @@
+import type { ChannelPresence } from "@posthog/core/canvas/presence";
+import { Autocomplete, AutocompleteList, MenuLabel } from "@posthog/quill";
+import type { Task, UserBasic } from "@posthog/shared/domain-types";
+import { ChannelItemPreviewCardProvider } from "@posthog/ui/features/canvas/components/ChannelItemHoverCard";
+import type { Channel } from "@posthog/ui/features/canvas/hooks/useChannels";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useQueryClient } from "@tanstack/react-query";
+import { type ReactNode, useState } from "react";
+import { SpaceRow } from "./WorkColumn";
+
+function user(id: number, first: string, last: string): UserBasic {
+ return {
+ id,
+ uuid: `user-${id}`,
+ first_name: first,
+ last_name: last,
+ email: `${first.toLowerCase()}@example.com`,
+ };
+}
+
+const ada = user(1, "Ada", "Lovelace");
+const grace = user(2, "Grace", "Hopper");
+const alan = user(3, "Alan", "Turing");
+const katherine = user(4, "Katherine", "Johnson");
+
+const MINUTE = 60_000;
+
+interface SpaceFixture {
+ channel: Channel;
+ faces?: { people: UserBasic[]; live?: UserBasic[] };
+ unreadSessions?: number;
+ blockedSessions?: number;
+ sessions: { by: UserBasic; minutesAgo: number }[];
+}
+
+function channel(name: string, overrides: Partial<Channel> = {}): Channel {
+ return {
+ id: `space-${name}`,
+ name,
+ channelType: "public",
+ starred: true,
+ repositories: [],
+ createdBy: ada,
+ ...overrides,
+ };
+}
+
+const SPACES: SpaceFixture[] = [
+ {
+ channel: channel("personal", {
+ channelType: "personal",
+ systemRole: "personal",
+ }),
+ sessions: [{ by: ada, minutesAgo: 30 }],
+ },
+ {
+ channel: channel("design-system", {
+ repositories: ["example-org/webapp"],
+ }),
+ sessions: [
+ { by: grace, minutesAgo: 60 * 26 },
+ { by: ada, minutesAgo: 60 * 50 },
+ ],
+ },
+ {
+ channel: channel("billing", { repositories: ["example-org/billing"] }),
+ faces: { people: [grace], live: [grace] },
+ sessions: [
+ { by: grace, minutesAgo: 1 },
+ { by: alan, minutesAgo: 90 },
+ ],
+ },
+ {
+ channel: channel("growth-engineering", {
+ createdBy: alan,
+ repositories: ["example-org/webapp", "example-org/website"],
+ }),
+ faces: { people: [alan, katherine] },
+ unreadSessions: 3,
+ blockedSessions: 1,
+ sessions: [
+ { by: katherine, minutesAgo: 12 },
+ { by: alan, minutesAgo: 40 },
+ { by: grace, minutesAgo: 60 * 5 },
+ ],
+ },
+ {
+ channel: channel("onboarding", { createdBy: katherine }),
+ unreadSessions: 1,
+ sessions: [{ by: katherine, minutesAgo: 60 * 3 }],
+ },
+ {
+ channel: channel("web-analytics", { repositories: ["example-org/webapp"] }),
+ faces: { people: [katherine], live: [katherine] },
+ sessions: [{ by: katherine, minutesAgo: 2 }],
+ },
+ {
+ channel: channel("release-notes", {
+ repositories: ["example-org/website"],
+ }),
+ sessions: [{ by: ada, minutesAgo: 60 * 24 * 3 }],
+ },
+ {
+ channel: channel("launch-planning", { channelType: "private" }),
+ sessions: [
+ { by: ada, minutesAgo: 60 * 8 },
+ { by: grace, minutesAgo: 60 * 9 },
+ ],
+ },
+];
+
+function presenceOf(space: SpaceFixture): ChannelPresence | undefined {
+ if (!space.faces) return undefined;
+ return {
+ people: space.faces.people,
+ liveUuids: new Set((space.faces.live ?? []).map((person) => person.uuid)),
+ };
+}
+
+function SeededSpaces({ children }: { children: ReactNode }) {
+ const queryClient = useQueryClient();
+ useState(() => {
+ const now = Date.now();
+ for (const space of SPACES) {
+ const tasks = space.sessions.map(
+ ({ by, minutesAgo }, index) =>
+ ({
+ id: `${space.channel.id}-task-${index}`,
+ created_by: by,
+ last_activity_at: new Date(now - minutesAgo * MINUTE).toISOString(),
+ }) as Task,
+ );
+ queryClient.setQueryData(["space-tree-tasks", space.channel.id], {
+ tasks,
+ count: tasks.length,
+ });
+ }
+ return null;
+ });
+ return <>{children}</>;
+}
+
+function SpaceRows() {
+ return (
+ <>
+ {SPACES.map((space) => (
+ <SpaceRow
+ key={space.channel.id}
+ channel={space.channel}
+ isActive={false}
+ unread={
+ (space.unreadSessions ?? 0) + (space.blockedSessions ?? 0) > 0
+ }
+ unreadSessions={space.unreadSessions ?? 0}
+ blockedSessions={space.blockedSessions ?? 0}
+ presence={presenceOf(space)}
+ />
+ ))}
+ </>
+ );
+}
+
+const meta: Meta<typeof SpaceRows> = {
+ title: "Spaces/WorkColumnSpaceRow",
+ component: SpaceRows,
+ decorators: [
+ (Story) => (
+ <SeededSpaces>
+ <ChannelItemPreviewCardProvider>
+ <div className="w-[300px] bg-chrome p-2">
+ <MenuLabel className="py-1 font-semibold text-foreground/70">
+ Spaces
+ </MenuLabel>
+ <Autocomplete<string>
+ inline
+ open
+ items={SPACES.map((space) => space.channel.id)}
+ filter={null}
+ >
+ <AutocompleteList className="flex flex-col gap-px">
+ <Story />
+ </AutocompleteList>
+ </Autocomplete>
+ </div>
+ </ChannelItemPreviewCardProvider>
+ </SeededSpaces>
+ ),
+ ],
+};
+
+export default meta;
+type Story = StoryObj<typeof SpaceRows>;
+
+export const Rows: Story = {};
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
index 9c010d66ca03..b1c336ef85d5 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
@@ -299,12 +299,14 @@ export interface SpaceOverview {
* nothing has been fetched yet.
*/
total: number | null;
+ lastActivityAt: string | null;
}
const NO_OVERVIEW: SpaceOverview = {
people: [],
liveUuids: NO_LIVE_UUIDS,
total: null,
+ lastActivityAt: null,
};
/**
@@ -348,6 +350,8 @@ export function useSpaceOverview(
// server's total, which excludes archived tasks — bar any this device has
// archived and not yet mirrored.
total: data.tasks.length < TREE_FETCH_LIMIT ? live.length : data.count,
+ lastActivityAt:
+ live.find((task) => task.last_activity_at)?.last_activity_at ?? null,
};
}, [data, archivedTaskIds, createdBy, peopleLimit, now]);
}