: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): one Work column for spaces, sessions and canvases (#103476)
Shy Alter199e42970852
diff --git a/products/desktop/packages/core/src/canvas/channelItems.ts b/products/desktop/packages/core/src/canvas/channelItems.tsindex d86500fae57c..8d9c04bebbdf 100644--- a/products/desktop/packages/core/src/canvas/channelItems.ts+++ b/products/desktop/packages/core/src/canvas/channelItems.ts@@ -236,9 +236,12 @@ export type EnvironmentFilter = "any" | ChannelItemEnvironment;export type SourceFilter = string;export type ChannelItemSort = "recent" | "created" | "alpha";+export type KindFilter = "any" | "task" | "canvas";+export const ANY_SOURCE = "any";export interface ChannelItemFilters {+ kind: KindFilter;createdBy: CreatedByFilter;attention: AttentionFilter;pinned: PinnedFilter;@@ -247,6 +250,7 @@ export interface ChannelItemFilters {}export const DEFAULT_CHANNEL_ITEM_FILTERS: ChannelItemFilters = {+ kind: "any",createdBy: "anyone",attention: "any",pinned: "any",@@ -269,7 +273,7 @@ export function channelItemSortEvent(}/** What the list's section headers stand for. */-export type ChannelItemGrouping = "date" | "repository";+export type ChannelItemGrouping = "date" | "repository" | "space";/** Days, because when something happened is what a session list is scanned by. */export const DEFAULT_CHANNEL_ITEM_GROUPING: ChannelItemGrouping = "date";@@ -283,6 +287,7 @@ export function hasActiveChannelItemFilters(filters: ChannelItemFilters,): boolean {return (+ filters.kind !== "any" ||filters.createdBy !== "anyone" ||filters.attention !== "any" ||filters.pinned !== "any" ||@@ -326,6 +331,7 @@ export function filterChannelItems() {return false;}+ if (filters.kind !== "any" && item.kind !== filters.kind) return false;if (filters.createdBy !== "anyone") {// An item with no creator uuid (e.g. the backend returns `created_by:// null` once a creator is deleted) belongs to neither bucket: it isn't@@ -410,6 +416,7 @@ export function groupChannelItems(sort: ChannelItemSort,now: Date = new Date(),grouping: ChannelItemGrouping = DEFAULT_CHANNEL_ITEM_GROUPING,+ spaceOf?: (item: ChannelItemModel) => ChannelItemGroupKey | null,): ChannelItemSection[] {const sections: ChannelItemSection[] = [];@@ -424,6 +431,10 @@ export function groupChannelItems(sections.push(...repositorySections(rest));return sections;}+ if (grouping === "space" && spaceOf) {+ sections.push(...spaceSections(rest, spaceOf));+ return sections;+ }if (sort === "alpha") {sections.push({ key: "all", label: null, items: rest });return sections;@@ -445,34 +456,63 @@ export function groupChannelItems(return sections;}-/** The repository a row belongs under, or null where it names none. */-const NO_REPOSITORY_KEY = "repo:none";+export interface ChannelItemGroupKey {+ key: string;+ label: string;+}-/**- * One section per repository, in the order the sorted list first reaches each- * one — so a repository-grouped list still opens on the most recent work rather- * than on whichever repository sorts first alphabetically. Sessions with no- * repository are a run of their own at the end, where they don't interrupt the- * named ones.- */-function repositorySections(+function keyedSections(items: readonly ChannelItemModel[],+ resolve: (item: ChannelItemModel) => ChannelItemGroupKey | null,+ fallback: ChannelItemGroupKey,): ChannelItemSection[] {- const byRepo = new Map<string, ChannelItemSection>();+ const byKey = new Map<string, ChannelItemSection>();for (const item of items) {- const key = item.repository- ? `repo:${item.repository.key}`- : NO_REPOSITORY_KEY;- const label = item.repository?.label ?? "No repository";- const open = byRepo.get(key);+ const group = resolve(item) ?? fallback;+ const open = byKey.get(group.key);if (open) {open.items.push(item);continue;}- byRepo.set(key, { key, label, items: [item] });+ byKey.set(group.key, { key: group.key, label: group.label, items: [item] });}+ const sections = [...byKey.values()];+ return [+ ...sections.filter((s) => s.key !== fallback.key),+ ...sections.filter((s) => s.key === fallback.key),+ ];+}- const sections = [...byRepo.values()];- const unnamed = sections.filter((s) => s.key === NO_REPOSITORY_KEY);- return [...sections.filter((s) => s.key !== NO_REPOSITORY_KEY), ...unnamed];+const NO_REPOSITORY: ChannelItemGroupKey = {+ key: "repo:none",+ label: "No repository",+};++const NO_SPACE: ChannelItemGroupKey = { key: "space:none", label: "No space" };++function repositorySections(+ items: readonly ChannelItemModel[],+): ChannelItemSection[] {+ return keyedSections(+ items,+ (item) =>+ item.repository+ ? { key: `repo:${item.repository.key}`, label: item.repository.label }+ : null,+ NO_REPOSITORY,+ );+}++function spaceSections(+ items: readonly ChannelItemModel[],+ spaceOf: (item: ChannelItemModel) => ChannelItemGroupKey | null,+): ChannelItemSection[] {+ return keyedSections(+ items,+ (item) => {+ const space = spaceOf(item);+ return space ? { key: `space:${space.key}`, label: space.label } : null;+ },+ NO_SPACE,+ );}diff --git a/products/desktop/packages/core/src/git-interaction/prStatus.ts b/products/desktop/packages/core/src/git-interaction/prStatus.tsindex 866d885d9fc3..13959fdbe8a3 100644--- a/products/desktop/packages/core/src/git-interaction/prStatus.ts+++ b/products/desktop/packages/core/src/git-interaction/prStatus.ts@@ -1,4 +1,4 @@-import type { PrActionType } from "@posthog/shared";+import type { PrActionType, PrCheck } from "@posthog/shared";export type PrVisualIcon = "merged" | "pull-request";@@ -87,3 +87,27 @@ export const PR_ACTION_LABELS: Record<PrActionType, string> = {export function parsePrNumber(prUrl: string): string | undefined {return prUrl.match(/\/pull\/(\d+)/)?.[1];}++// A PR's CI in one line: failing beats running beats passing.+export function summarizePrChecks(+ checks: PrCheck[] | null | undefined,+): { label: string; color: string } | null {+ if (!checks || checks.length === 0) return null;+ let failed = 0;+ let pending = 0;+ let passed = 0;+ for (const check of checks) {+ if (check.bucket === "fail" || check.bucket === "cancel") failed++;+ else if (check.bucket === "pending") pending++;+ else if (check.bucket === "pass") passed++;+ }+ if (failed) {+ return {+ label: `CI failing · ${failed} ${failed === 1 ? "check" : "checks"}`,+ color: "var(--red-11)",+ };+ }+ if (pending) return { label: "CI running", color: "var(--amber-11)" };+ if (passed) return { label: "CI passing", color: "var(--green-11)" };+ return null;+}diff --git a/products/desktop/packages/core/src/tasks/taskStatusPresentation.ts b/products/desktop/packages/core/src/tasks/taskStatusPresentation.tsindex 66c2ad319526..cc95a3894968 100644--- a/products/desktop/packages/core/src/tasks/taskStatusPresentation.ts+++ b/products/desktop/packages/core/src/tasks/taskStatusPresentation.ts@@ -3,6 +3,7 @@ import type {Task,TaskRunEnvironment,TaskRunStatus,+ UserBasic,} from "@posthog/shared/domain-types";export type TaskStatusPresentationKind =@@ -61,3 +62,11 @@ export function getTaskStatusPresentationKind(return "chat";}}++// Who to show a task under: only a task a person started names an author; an+// agent-made one would otherwise credit whoever the backend recorded.+export function taskStarter(task: Task): UserBasic | null {+ return task.origin_product === "user_created"+ ? (task.created_by ?? null)+ : null;+}diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.tsindex 0017660dbae2..4e592ab75d2a 100644--- a/products/desktop/packages/shared/src/analytics-events.ts+++ b/products/desktop/packages/shared/src/analytics-events.ts@@ -342,7 +342,7 @@ export interface ProjectMenuActionProperties {export type TaskListSurface = "sidebar" | "space" | "saved_search";export interface TaskListGroupingChangedProperties {- group_by: "repository" | "date";+ group_by: "repository" | "date" | "space";sort_by: "updated" | "created" | "alpha";surface: TaskListSurface;}@@ -358,7 +358,13 @@ export interface BrowserTabTileCountProperties {}export interface TaskListAppearanceChangedProperties {- secondary_fields: ("repository" | "branch" | "creator" | "activity")[];+ secondary_fields: (+ | "space"+ | "repository"+ | "branch"+ | "creator"+ | "activity"+ )[];secondary_field_count: number;surface: TaskListSurface;}@@ -1177,7 +1183,8 @@ export type ChannelsSurface =| "thread_panel"| "activity_panel"| "activity"- | "canvases_pane";+ | "canvases_pane"+ | "spaces_index";type ChannelActionType =| "enter_space"diff --git a/products/desktop/packages/shared/src/feature-flag-keys.json b/products/desktop/packages/shared/src/feature-flag-keys.jsonindex 483604e605d2..4e1c030c1fb8 100644--- a/products/desktop/packages/shared/src/feature-flag-keys.json+++ b/products/desktop/packages/shared/src/feature-flag-keys.json@@ -13,6 +13,7 @@"CONTEXT_LAYER_FLAG": "context-layer","CUSTOM_IMAGES_FEATURE_FLAG": "tasks-modal-vm-sandbox","DESKTOP_HOME_FLAG": "desktop-home-flag",+ "DESKTOP_WORK_LAYOUT_FLAG": "desktop-work-layout","DISCOVERY_RUN_FLAG": "posthog-code-discovery-run","EXPERIMENT_SUGGESTIONS_FLAG": "posthog-code-experiment-suggestions","FAST_MODE_FLAG": "posthog-desktop-fast-mode",diff --git a/products/desktop/packages/shared/src/flags.ts b/products/desktop/packages/shared/src/flags.tsindex aa39fa2fc936..901f7bd09651 100644--- a/products/desktop/packages/shared/src/flags.ts+++ b/products/desktop/packages/shared/src/flags.ts@@ -24,6 +24,8 @@ export const LOOPS_FLAG = featureFlagKeys.LOOPS_FLAG;/** Desktop Loops read and write workflows (`hog_flows`) instead of the loops API. */export const LOOPS_HOG_FLOWS_FLAG = featureFlagKeys.LOOPS_HOG_FLOWS_FLAG;export const DESKTOP_HOME_FLAG = featureFlagKeys.DESKTOP_HOME_FLAG;+export const DESKTOP_WORK_LAYOUT_FLAG =+ featureFlagKeys.DESKTOP_WORK_LAYOUT_FLAG;export const SAVED_SEARCHES_RAIL_FLAG =featureFlagKeys.SAVED_SEARCHES_RAIL_FLAG;export const TASKS_PREWARM_SANDBOX_FLAG =diff --git a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsxindex b5fa5239b8f1..dccd7b030bc1 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx+++ b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx@@ -1,4 +1,4 @@-import { MagnifyingGlassIcon } from "@phosphor-icons/react";+import { MagnifyingGlassIcon, PlusIcon } from "@phosphor-icons/react";import { humanizeReportTitle } from "@posthog/core/inbox/reportPresentation";import { useService } from "@posthog/di/react";import {@@ -29,6 +29,7 @@ import {import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";import { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";import { useSelectedCanvasId } from "@posthog/ui/features/canvas/hooks/useSelectedCanvasId";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { isRestorableVisitHref } from "@posthog/ui/features/canvas/railPane";import {activityReportIdFromHref,@@ -58,7 +59,10 @@ import { useFocusTab } from "@posthog/ui/features/tab-tiling/useFocusTab";import { getTaskInputSessionId } from "@posthog/ui/features/task-detail/taskInputSession";import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";import { useTasks } from "@posthog/ui/features/tasks/useTasks";-import { reportIdFromHref } from "@posthog/ui/router/reportNavigation";+import {+ hrefPath,+ reportIdFromHref,+} from "@posthog/ui/router/reportNavigation";import { useAppView } from "@posthog/ui/router/useAppView";import { track } from "@posthog/ui/shell/analytics";import { isMac } from "@posthog/ui/utils/platform";@@ -99,6 +103,8 @@ import { useTabsSnapshot } from "./useBrowserTabs";import { useGoToTab } from "./useGoToTab";import { useOpenBrowserTab } from "./useOpenBrowserTab";+const NEW_SESSION_TAB_HREF = "/new";+/*** Module-level caches of display info, keyed by id. Tabs store only references;* names are resolved here as the user navigates (which loads each channel's@@ -154,6 +160,8 @@ function BrowserTabStripImpl() {const router = useRouter();const client = useService<BrowserTabsClient>(BROWSER_TABS_CLIENT);const openBrowserTab = useOpenBrowserTab();+ const workLayout = useWorkLayout();+ const defaultTabHref = workLayout ? NEW_SESSION_TAB_HREF : DEFAULT_TAB_HREF;const params = useParams({ strict: false }) as {channelId?: string;dashboardId?: string;@@ -651,6 +659,15 @@ function BrowserTabStripImpl() {pinned,};}+ if (workLayout && hrefPath(t.href ?? "") === NEW_SESSION_TAB_HREF) {+ return {+ id: t.id,+ label: "New session",+ icon: <PlusIcon size={13} />,+ channelName: null,+ pinned,+ };+ }return {id: t.id,label: t.viewState?.title ?? "New tab",@@ -720,6 +737,7 @@ function BrowserTabStripImpl() {routeFeedId,feedName,spacesLayout,+ workLayout,]);// Navigate to a tab, tagging the history entry with its id so the switch is@@ -774,7 +792,7 @@ function BrowserTabStripImpl() {const next = applyLocalTransform((s) =>closeTabLocal(s, tabId, {- href: DEFAULT_TAB_HREF,+ href: defaultTabHref,makeId: () => newTabId,now: Date.now,}).snapshot,@@ -810,7 +828,7 @@ function BrowserTabStripImpl() {s,tabIds,{- href: DEFAULT_TAB_HREF,+ href: defaultTabHref,makeId: () => newTabId,now: Date.now,},@@ -881,10 +899,10 @@ function BrowserTabStripImpl() {const landOnDefault = (tabId?: string): void => {const state = tabId ? (prev: object) => ({ ...prev, tabId }) : undefined;- navigate({ to: DEFAULT_TAB_HREF, state });+ navigate({ to: defaultTabHref, state });};- const handleNewTab = (): void => openBrowserTab(DEFAULT_TAB_HREF);+ const handleNewTab = (): void => openBrowserTab(defaultTabHref);// Cmd/Ctrl+T opens a new browser tab. Bound here (not globally) so it only// fires where the strip is mounted; the new-task shortcut owns Cmd/Ctrl+N.diff --git a/products/desktop/packages/ui/src/features/browser-tabs/TaskTabIcon.tsx b/products/desktop/packages/ui/src/features/browser-tabs/TaskTabIcon.tsxindex 27e7a7e3ddb5..371c11ed0756 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/TaskTabIcon.tsx+++ b/products/desktop/packages/ui/src/features/browser-tabs/TaskTabIcon.tsx@@ -14,9 +14,11 @@ import { useWorkspace } from "@posthog/ui/features/workspace/useWorkspace";export function TaskTabIcon({task,size = 14,+ showPrState = true,}: {task: Task | undefined;size?: number;+ showPrState?: boolean;}) {const taskData = useChannelTaskData(task);const workspace = useWorkspace(task?.id);@@ -44,8 +46,8 @@ export function TaskTabIcon({runMode={taskData.runMode}originProduct={taskData.originProduct}slackThreadUrl={taskData.slackThreadUrl}- prState={prState}- hasDiff={hasDiff}+ prState={showPrState ? prState : null}+ hasDiff={showPrState ? hasDiff : false}size={size}/>);diff --git a/products/desktop/packages/ui/src/features/browser-tabs/useGoToTab.ts b/products/desktop/packages/ui/src/features/browser-tabs/useGoToTab.tsindex 6db5522efe16..22216f2a410f 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/useGoToTab.ts+++ b/products/desktop/packages/ui/src/features/browser-tabs/useGoToTab.ts@@ -1,5 +1,6 @@import { DEFAULT_TAB_HREF, type TabIdentity } from "@posthog/shared";import { channelSectionFor } from "@posthog/ui/features/canvas/channelSections";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";import { useNavigate, useRouter } from "@tanstack/react-router";import { useCallback } from "react";@@ -12,6 +13,7 @@ export function useGoToTab(): (tab: TabRef) => void {const navigate = useNavigate();const router = useRouter();const channelReportsEnabled = useChannelReportsEnabled();+ const workLayout = useWorkLayout();return useCallback((tab: TabRef) => {const state = (prev: object) => ({ ...prev, tabId: tab.id });@@ -107,9 +109,9 @@ export function useGoToTab(): (tab: TabRef) => void {}}} else {- navigate({ to: DEFAULT_TAB_HREF, state });+ navigate({ to: workLayout ? "/new" : DEFAULT_TAB_HREF, state });}},- [channelReportsEnabled, navigate, router.history],+ [channelReportsEnabled, navigate, router.history, workLayout],);}diff --git a/products/desktop/packages/ui/src/features/canvas/components/CanvasPreviewFrame.tsx b/products/desktop/packages/ui/src/features/canvas/components/CanvasPreviewFrame.tsxnew file mode 100644index 000000000000..14d7b77e11ef--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/CanvasPreviewFrame.tsx@@ -0,0 +1,75 @@+import { publishedCanvasBuild } from "@posthog/core/canvas/canvasBuildSchemas";+import { Text } from "@posthog/quill";+import { BuiltCanvas } from "@posthog/ui/features/canvas/freeform/BuiltCanvas";+import { useCanvasBuilds } from "@posthog/ui/features/canvas/hooks/useCanvasBuilds";+import { useInView } from "@posthog/ui/primitives/hooks/useInView";+import { useCallback, useEffect, useState } from "react";++const LAYOUT_WIDTH = 1200;+const LAYOUT_HEIGHT = 820;++export function CanvasPreviewFrame({+ dashboardId,+ className,+}: {+ dashboardId: string;+ className?: string;+}) {+ const [ref, inView] = useInView<HTMLDivElement>({ rootMargin: "400px 0px" });+ const [box, setBox] = useState<HTMLDivElement | null>(null);+ const [width, setWidth] = useState(0);+ const attach = useCallback(+ (node: HTMLDivElement | null) => {+ ref(node);+ setBox(node);+ },+ [ref],+ );+ useEffect(() => {+ if (!box) return;+ const observer = new ResizeObserver(([entry]) => {+ setWidth(entry.contentRect.width);+ });+ observer.observe(box);+ setWidth(box.clientWidth);+ return () => observer.disconnect();+ }, [box]);++ const { lifecycle, isLoading } = useCanvasBuilds(dashboardId, {+ enabled: inView,+ });+ const build = lifecycle ? publishedCanvasBuild(lifecycle) : undefined;+ const artifactUrl = build?.artifactUrl ?? null;++ const denyDataRequest = useCallback(+ () => Promise.reject(new Error("A canvas preview has no data access")),+ [],+ );++ return (+ <div ref={attach} className={className}>+ {inView && artifactUrl && width > 0 ? (+ <div+ className="pointer-events-none origin-top-left"+ style={{+ width: LAYOUT_WIDTH,+ height: LAYOUT_HEIGHT,+ transform: `scale(${width / LAYOUT_WIDTH})`,+ }}+ >+ <BuiltCanvas+ artifactUrl={artifactUrl}+ capabilities={undefined}+ onDataRequest={denyDataRequest}+ />+ </div>+ ) : (+ <div className="flex h-full w-full items-center justify-center">+ <Text size="xs" variant="muted">+ {isLoading || !inView ? "" : "No preview yet"}+ </Text>+ </div>+ )}+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsxindex 9b7d4ceb9743..9c078d1d47a6 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx@@ -8,19 +8,34 @@ import {RobotIcon,} from "@phosphor-icons/react";import { taskFeedRunStatus } from "@posthog/core/canvas/channelFeed";+import {+ type ChannelItemFilters,+ type ChannelItemGrouping,+ type ChannelItemModel,+ type ChannelItemOwner,+ type ChannelItemSort,+ DEFAULT_CHANNEL_ITEM_SORT,+ filterChannelItems,+ hasActiveChannelItemFilters,+} from "@posthog/core/canvas/channelItems";+import type { DashboardRecord } from "@posthog/core/canvas/dashboardSchemas";import {RUN_STATUS_LABELS,runStatusVariant,} from "@posthog/core/canvas/runStatus";import { buildThreadTimeline } from "@posthog/core/canvas/threadTimeline";-import type { PrCheck } from "@posthog/core/git/router-schemas";-import { parsePrNumber } from "@posthog/core/git-interaction/prStatus";+import {+ parsePrNumber,+ summarizePrChecks,+} from "@posthog/core/git-interaction/prStatus";import { xmlToPlainText } from "@posthog/core/message-editor/content";import type { TaskData } from "@posthog/core/sidebar/sidebarData.types";import { isTaskActivelyRunning } from "@posthog/core/sidebar/taskRunning";+import { taskStarter } from "@posthog/core/tasks/taskStatusPresentation";import {AvatarGroup,Badge,+ Button,Card,CardContent,cn,@@ -49,10 +64,20 @@ import { useArchiveTask } from "@posthog/ui/features/archive/useArchiveTask";import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";import { TaskTabIcon } from "@posthog/ui/features/browser-tabs/TaskTabIcon";import {+ ActivityPresenceAvatar,+ canvasAuthor,+} from "@posthog/ui/features/canvas/components/ChannelItemPresence";+import { iconForTemplate } from "@posthog/ui/features/canvas/components/canvasTemplateIcon";+import {+ buildFeedSections,+ entryKey,type FeedEntry,type FeedKindFilter,feedEntryMatchesKind,+ feedEntryMatchesTypes,+ keepFilteredEntries,mergeFeedEntries,+ type SpaceActivityType,stripContextBlocks,} from "@posthog/ui/features/canvas/components/channelFeedDisplay";import { ReportFeedRow } from "@posthog/ui/features/canvas/components/ReportFeedRow";@@ -63,6 +88,8 @@ import {type TaskRowMenuProps,} from "@posthog/ui/features/canvas/components/TaskRowMenu";import { buildRows } from "@posthog/ui/features/canvas/components/taskArtifactRows";+import { PrFeedRow } from "@posthog/ui/features/canvas/components/work/PrFeedRow";+import type { SpacePullRequest } from "@posthog/ui/features/canvas/components/work/useSpacePullRequests";import type { ChannelFeedSystemMessage } from "@posthog/ui/features/canvas/hooks/useChannelFeedMessages";import type { ChannelReportsFilters } from "@posthog/ui/features/canvas/hooks/useChannelReports";import { useChannelTaskData } from "@posthog/ui/features/canvas/hooks/useChannelTaskData";@@ -91,6 +118,7 @@ import { FileIcon } from "@posthog/ui/primitives/FileIcon";import { useInView } from "@posthog/ui/primitives/hooks/useInView";import { Spinner } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";+import { navigateToChannelDashboard } from "@posthog/ui/router/navigationBridge";import { openExternalUrl } from "@posthog/ui/shell/openExternal";import { parseHttpsUrl } from "@posthog/ui/utils/posthogLinks";import { Text } from "@radix-ui/themes";@@ -371,12 +399,6 @@ export function TaskCard({);}-function channelTaskStarter(task: Task): UserBasic | null {- return task.origin_product === "user_created"- ? (task.created_by ?? null)- : null;-}-export function ExpandablePrompt({children,lines,@@ -537,7 +559,7 @@ const CHIP_CLASS =// render. Deliberately no focus handlers: closing returns focus to the// trigger, so opening on focus re-opens the popover in an endless blink loop// (and hands it to whichever trigger focus lands on next).-function HoverPopover({+export function HoverPopover({trigger,content,contentClassName,@@ -579,30 +601,6 @@ function HoverPopover({);}-// One line summarizing a PR's CI: failing beats running beats passing.-function summarizePrChecks(- checks: PrCheck[] | null | undefined,-): { label: string; color: string } | null {- if (!checks || checks.length === 0) return null;- let failed = 0;- let pending = 0;- let passed = 0;- for (const check of checks) {- if (check.bucket === "fail" || check.bucket === "cancel") failed++;- else if (check.bucket === "pending") pending++;- else if (check.bucket === "pass") passed++;- }- if (failed) {- return {- label: `CI failing · ${failed} ${failed === 1 ? "check" : "checks"}`,- color: "var(--red-11)",- };- }- if (pending) return { label: "CI running", color: "var(--amber-11)" };- if (passed) return { label: "CI passing", color: "var(--green-11)" };- return null;-}-function PrCiLine({ url }: { url: string }) {const checks = usePrChecks(url);const ci = summarizePrChecks(checks.data);@@ -629,7 +627,7 @@ function PrCiLine({ url }: { url: string }) {// The hover card for one PR chip: number + state, truncated title, CI line.// Mounted only while the popover is open, so its title/checks fetches never// run for chips just sitting in the feed.-function PrPopoverContent({ url }: { url: string }) {+export function PrPopoverContent({ url }: { url: string }) {const { prNumber, stateLabel, Icon, iconColor } = usePrArtifact(url);const prUrls = useMemo(() => [url], [url]);const titles = usePrTitles(prUrls);@@ -776,7 +774,7 @@ const FeedItem = memo(function FeedItem({const [stopConfirmOpen, setStopConfirmOpen] = useState(false);const isActive = taskData ? isTaskActivelyRunning(taskData) : false;const canStop = taskData?.taskRunEnvironment === "cloud" && isActive;- const starter = channelTaskStarter(task);+ const starter = taskStarter(task);const prompt = useMemo(() =>stripContextBlocks(@@ -953,7 +951,7 @@ const FeedItem = memo(function FeedItem({size="sm"role="button"tabIndex={0}- className="mx-auto my-1.5 w-full max-w-[660px] cursor-pointer rounded-xl bg-(--gray-2) py-0 transition-colors hover:border-(--gray-7) hover:bg-(--gray-3)"+ className="my-1.5 w-full cursor-pointer rounded-xl bg-(--gray-2) py-0 transition-colors hover:border-(--gray-7) hover:bg-(--gray-3)"onClick={(event) => {if (event.target instanceof Element &&@@ -979,6 +977,9 @@ const FeedItem = memo(function FeedItem({<CardContent className="flex flex-col px-4 pt-3.5 pb-3"><div className="flex items-center gap-3"><div className="flex min-w-0 flex-1 items-baseline gap-1.5">+ <span className="flex size-3.5 shrink-0 translate-y-0.5 items-center justify-center">+ <TaskTabIcon task={task} size={14} showPrState={false} />+ </span>{editingTitle ? (<InputautoFocus@@ -1220,16 +1221,212 @@ function FeedRow({);}+const CanvasFeedRow = memo(function CanvasFeedRow({+ canvas,+ channelId,+ listRow,+}: {+ canvas: DashboardRecord;+ channelId: string;+ listRow: boolean;+}) {+ const open = () => navigateToChannelDashboard(channelId, canvas.id);+ const author = canvasAuthor(canvas);+ if (!listRow) {+ return (+ <Card+ size="sm"+ role="button"+ tabIndex={0}+ className="my-1.5 w-full cursor-pointer rounded-xl bg-(--gray-2) py-0 transition-colors hover:border-(--gray-7) hover:bg-(--gray-3)"+ onClick={open}+ onKeyDown={(event) => {+ if (event.target !== event.currentTarget) return;+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ open();+ }+ }}+ >+ <CardContent className="flex flex-col px-4 pt-3.5 pb-3">+ <div className="flex items-center gap-3">+ <div className="flex min-w-0 flex-1 items-baseline gap-1.5">+ <span className="flex size-3.5 shrink-0 translate-y-0.5 items-center justify-center">+ {iconForTemplate(canvas.templateId, {+ size: 14,+ className: "text-violet-9",+ })}+ </span>+ <span className="min-w-0 truncate font-semibold text-sm">+ {canvas.name}+ </span>+ <span className="shrink-0 text-muted-foreground text-xs tabular-nums">+ · {formatRelativeTimeShort(canvas.updatedAt)}+ </span>+ </div>+ <Badge>Canvas</Badge>+ </div>+ {canvas.description && (+ <p className="mt-1 line-clamp-2 text-(--gray-11) text-[13px]">+ {canvas.description}+ </p>+ )}+ <div className="mt-3 flex items-center justify-end">+ {author && <UserAvatar user={author} size="xs" />}+ </div>+ </CardContent>+ </Card>+ );+ }+ return (+ <button+ type="button"+ onClick={open}+ title={canvas.name}+ className="group relative flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] transition-colors hover:bg-fill-selected"+ >+ <span className="flex size-3.5 shrink-0 items-center justify-center">+ {iconForTemplate(canvas.templateId, {+ size: 13,+ className: "text-violet-9",+ })}+ </span>+ <span className="min-w-0 flex-1 truncate font-medium">{canvas.name}</span>+ <ActivityPresenceAvatar+ user={author}+ label="on this canvas"+ activityAt={canvas.updatedAt}+ />+ <span className="w-8 shrink-0 text-right text-muted-foreground text-xs tabular-nums">+ {formatRelativeTimeShort(canvas.updatedAt)}+ </span>+ </button>+ );+});++const FEED_PAGE = 30;++const NO_CANVASES: readonly DashboardRecord[] = [];++const NO_ITEMS: readonly ChannelItemModel[] = [];++const NO_PULL_REQUESTS: readonly SpacePullRequest[] = [];++const NOBODY = { uuid: null };++const FeedLogRow = memo(function FeedLogRow({+ task,+ onOpenTask,+ onOpenThread,+}: {+ task: Task;+ onOpenTask: (task: Task) => void;+ onOpenThread: (task: Task, tab?: ThreadPanelTab) => void;+}) {+ const [ref, inView] = useInView<HTMLDivElement>({ rootMargin: "600px 0px" });+ const { mutate: markTasksRead } = useMarkTaskActivityRead();+ const taskData = useChannelTaskData(task);+ const statusDisplay = useTaskStatusDisplay(task, taskData, {+ resolvePrStatus: inView,+ });+ const { togglePin } = usePinnedTasks();+ const { archiveTask } = useArchiveTask();+ const commandCenterCells = useCommandCenterStore((state) => state.cells);+ const starter = taskStarter(task);+ const markRead = useCallback(() => {+ markTasksRead([+ { task_id: task.id, seen_before: new Date().toISOString() },+ ]);+ }, [markTasksRead, task.id]);+ const menu: TaskRowMenuProps = useMemo(+ () => ({+ kind: "task",+ id: task.id,+ title: task.title,+ isPinned: taskData?.isPinned ?? false,+ task,+ channelId: task.channel ?? undefined,+ onAddToCommandCenter: commandCenterCells.includes(task.id)+ ? undefined+ : () => placeTaskInCommandCenter(task.id, task.title),+ onTogglePin: () => {+ void togglePin(task.id).catch(() => {+ toast.error("Couldn't update pin", { description: "Try again." });+ });+ },+ onArchive: () => {+ void archiveTask({ taskId: task.id }).catch(() => {+ toast.error("Couldn't archive task", { description: "Try again." });+ });+ },+ }),+ [archiveTask, commandCenterCells, task, taskData?.isPinned, togglePin],+ );+ return (+ <TaskRowContextMenu menu={menu}>+ {/* biome-ignore lint/a11y/useSemanticElements: the row holds its own buttons (title, menu), and buttons cannot nest */}+ <div+ ref={ref}+ role="button"+ tabIndex={0}+ className="group relative flex h-8 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors hover:bg-fill-selected"+ onClick={(event) => {+ if (+ event.target instanceof Element &&+ event.target.closest('[data-slot="dropdown-menu-trigger"]')+ ) {+ return;+ }+ markRead();+ onOpenThread(task);+ }}+ onKeyDown={(event) => {+ if (event.target !== event.currentTarget) return;+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ markRead();+ onOpenThread(task);+ }+ }}+ >+ <TaskTabIcon task={task} size={14} showPrState={false} />+ <button+ type="button"+ className="min-w-0 flex-1 truncate text-left font-medium"+ onClick={(event) => {+ event.stopPropagation();+ markRead();+ onOpenTask(task);+ }}+ >+ {task.title || "Untitled task"}+ </button>+ <TaskStatusBadge display={statusDisplay} />++ <ActivityPresenceAvatar+ user={starter}+ label="on this session"+ activityAt={task.last_activity_at ?? task.updated_at}+ />++ <span className="w-8 shrink-0 text-right text-muted-foreground text-xs tabular-nums transition-opacity group-hover:opacity-0">+ {formatRelativeTimeShort(task.updated_at)}+ </span>+ <span className="absolute right-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100">+ <TaskRowDropdownMenu menu={menu} />+ </span>+ </div>+ </TaskRowContextMenu>+ );+});+// The optimistic kickoff row: the user's prompt as a "Starting…" card, shown// at the top of the feed the moment they submit. Deliberately dumb — no// per-task data hooks or polls (there's no task id to query yet); it's// replaced by a real FeedRow as soon as the task is created.function PendingFeedRow({ pending }: { pending: PendingKickoff }) {return (- <Card- size="sm"- className="mx-auto my-1.5 w-full max-w-[660px] rounded-xl bg-(--gray-2) py-0"- >+ <Card size="sm" className="my-1.5 w-full rounded-xl bg-(--gray-2) py-0"><CardContent className="flex flex-col px-4 pt-3.5 pb-3"><div className="flex items-start gap-3"><span className="min-w-0 flex-1 font-semibold text-sm leading-snug">@@ -1254,7 +1451,7 @@ function PendingFeedRow({ pending }: { pending: PendingKickoff }) {// as a task row, minus the task card and reply footer.function SystemFeedRow({ message }: { message: ChannelFeedSystemMessage }) {return (- <div className="mx-auto flex w-full min-w-0 max-w-[660px] items-center gap-2 px-1 py-1.5 text-(--gray-9) text-xs">+ <div className="flex w-full min-w-0 items-center gap-2 px-1 py-1.5 text-(--gray-9) text-xs">{message.author ? (<UserAvatar user={message.author} size="xs" />) : (@@ -1282,8 +1479,7 @@ function SystemFeedRow({ message }: { message: ChannelFeedSystemMessage }) {const DAY_MS = 86_400_000;// "Today" / "Yesterday" / "Aug 8" (with the year once it differs) for the-// feed's day separators.-function feedDayLabel(iso: string, now: Date): string {+export function feedDayLabel(iso: string, now: Date): string {const date = new Date(iso);const startOfDay = (d: Date) =>new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();@@ -1304,10 +1500,7 @@ function feedDayLabel(iso: string, now: Date): string {*/function FeedRowSkeleton({ wide }: { wide?: boolean }) {return (- <Card- size="sm"- className="mx-auto my-1.5 w-full max-w-[660px] rounded-xl py-0"- >+ <Card size="sm" className="my-1.5 w-full rounded-xl py-0"><CardContent className="flex flex-col px-4 pt-3.5 pb-3"><div className="flex items-start gap-3"><Skeleton className={cn("h-4", wide ? "w-3/5" : "w-2/5")} />@@ -1326,15 +1519,49 @@ function FeedRowSkeleton({ wide }: { wide?: boolean }) {);}+function FeedLogRowSkeleton({ width }: { width: string }) {+ return (+ <div className="flex h-8 w-full items-center gap-2 px-2">+ <Skeleton className="size-3.5 shrink-0 rounded-sm" />+ <Skeleton className={cn("h-3.5", width)} />+ <Skeleton className="ml-auto h-4 w-14 shrink-0 rounded-full" />+ <Skeleton className="size-4 shrink-0 rounded-full" />+ <Skeleton className="h-3 w-6 shrink-0" />+ </div>+ );+}++function FeedLogSkeleton() {+ const widths = ["w-2/5", "w-3/5", "w-1/3", "w-1/2", "w-2/5", "w-1/4"];+ return (+ <div aria-hidden className="flex flex-col">+ {[0, 1].map((group) => (+ <div+ key={group}+ className={cn("flex flex-col", group === 1 && "opacity-50")}+ >+ <div className="w-full px-2 pt-3 pb-0.5">+ <Skeleton className="h-2.5 w-14" />+ </div>+ {widths.slice(group * 3, group * 3 + 3).map((width) => (+ <FeedLogRowSkeleton key={width} width={width} />+ ))}+ </div>+ ))}+ </div>+ );+}+/*** The loading feed: a faded stack of card skeletons under a separator-shaped* bar. Each card fainter than the one above, so the stack reads as content* arriving rather than a wall of grey.*/-function FeedSkeleton() {+function FeedSkeleton({ compact }: { compact: boolean }) {+ if (compact) return <FeedLogSkeleton />;return (<div aria-hidden className="flex flex-col">- <div className="mx-auto flex w-full max-w-[660px] items-center gap-3 pt-5 pb-2">+ <div className="flex w-full items-center gap-3 pt-5 pb-2"><span className="h-px flex-1 bg-(--gray-5)" /><Skeleton className="h-3 w-12" /><span className="h-px flex-1 bg-(--gray-5)" />@@ -1353,9 +1580,22 @@ function FeedSkeleton() {);}-function DaySeparator({ label }: { label: string }) {+function DaySeparator({+ label,+ compact = false,+}: {+ label: string;+ compact?: boolean;+}) {+ if (compact) {+ return (+ <div className="sticky top-0 z-10 w-full bg-gray-1 px-2 pt-3 pb-1 font-medium text-[11px] text-muted-foreground uppercase tracking-wider">+ {label}+ </div>+ );+ }return (- <div className="mx-auto flex w-full max-w-[660px] items-center gap-3 pt-5 pb-2 font-semibold text-(--gray-9) text-[11px] uppercase tracking-wider">+ <div className="flex w-full items-center gap-3 pt-5 pb-2 font-semibold text-(--gray-9) text-[11px] uppercase tracking-wider"><span className="h-px flex-1 bg-(--gray-5)" />{label}<span className="h-px flex-1 bg-(--gray-5)" />@@ -1393,6 +1633,19 @@ export function ChannelFeedView({composer,onOpenTask,onOpenThread,+ compact = false,+ canvases,+ pullRequests = NO_PULL_REQUESTS,+ types,+ spaceItems = NO_ITEMS,+ me,+ controls,+ onClearFilters,+ rebuilding = false,+ rowStyle,+ filters,+ sort = DEFAULT_CHANNEL_ITEM_SORT,+ grouping = "date",}: {channelId: string;tasks: Task[];@@ -1422,6 +1675,19 @@ export function ChannelFeedView({composer?: ReactNode;onOpenTask: (task: Task) => void;onOpenThread: (task: Task, tab?: ThreadPanelTab) => void;+ compact?: boolean;+ canvases?: readonly DashboardRecord[];+ pullRequests?: readonly SpacePullRequest[];+ types?: readonly SpaceActivityType[];+ spaceItems?: readonly ChannelItemModel[];+ me?: ChannelItemOwner;+ controls?: ReactNode;+ rebuilding?: boolean;+ onClearFilters?: () => void;+ rowStyle?: "cards" | "list";+ filters?: ChannelItemFilters;+ sort?: ChannelItemSort;+ grouping?: ChannelItemGrouping;}) {// Archiving is local-only host state the server task list doesn't know about,// so a just-archived card would otherwise reappear on the next poll. Drop@@ -1441,16 +1707,63 @@ export function ChannelFeedView({const activeKindFilter =kindFilter.channelId === channelId ? kindFilter.value : "all";- const entries = useMemo<FeedEntry[]>(- () =>- mergeFeedEntries(- visibleTasks,- systemMessages ?? [],- reports ?? [],- ).filter((entry) => feedEntryMatchesKind(entry, activeKindFilter)),- [visibleTasks, systemMessages, reports, activeKindFilter],+ const narrowed = filters ? hasActiveChannelItemFilters(filters) : false;+ const allowedKeys = useMemo(() => {+ if (!filters || !narrowed) return null;+ const kept = filterChannelItems(spaceItems, {+ query: "",+ filters,+ me: me ?? NOBODY,+ });+ return new Set(kept.map((item) => item.key));+ }, [filters, narrowed, spaceItems, me]);+ const itemByKey = useMemo(+ () => new Map(spaceItems.map((item) => [item.key, item])),+ [spaceItems],);+ const entries = useMemo<readonly FeedEntry[]>(() => {+ const merged = mergeFeedEntries(+ visibleTasks,+ systemMessages ?? [],+ reports ?? [],+ canvases ?? NO_CANVASES,+ pullRequests,+ )+ .filter((entry) => feedEntryMatchesKind(entry, activeKindFilter))+ .filter((entry) => !types || feedEntryMatchesTypes(entry, types));+ const kept = keepFilteredEntries(merged, allowedKeys);+ if (sort === "created") return kept;+ const key = (entry: FeedEntry) =>+ itemByKey.get(entryKey(entry) ?? "")?.ts ?? Date.parse(entry.createdAt);+ const title = (entry: FeedEntry) =>+ entry.kind === "task"+ ? entry.task.title+ : entry.kind === "canvas"+ ? entry.canvas.name+ : entry.kind === "report"+ ? entry.report.title+ : entry.kind === "pr"+ ? (entry.pullRequest.title ?? entry.pullRequest.task.title)+ : entry.message.text;+ return [...kept].sort((a, b) =>+ sort === "alpha"+ ? (title(a) ?? "").localeCompare(title(b) ?? "")+ : key(b) - key(a),+ );+ }, [+ visibleTasks,+ systemMessages,+ reports,+ canvases,+ pullRequests,+ types,+ activeKindFilter,+ allowedKeys,+ sort,+ itemByKey,+ ]);+// The channel's dominant repo: on a single-repo channel every card would// repeat the same chip, so the repo chip only renders on tasks that target a// different repo than most of the channel.@@ -1472,6 +1785,20 @@ export function ChannelFeedView({}, [visibleTasks]);const viewportRef = useRef<HTMLDivElement>(null);+ const [visibleCount, setVisibleCount] = useState(FEED_PAGE);+ const [moreRef, moreInView] = useInView<HTMLDivElement>({+ rootMargin: "400px 0px",+ });+ // biome-ignore lint/correctness/useExhaustiveDependencies: visibleCount is a trigger — the sentinel can stay in view after a page lands, so the loader has to run again on the new count+ useEffect(() => {+ if (!moreInView) return;+ setVisibleCount((count) => Math.min(count + FEED_PAGE, entries.length));+ }, [moreInView, visibleCount, entries.length]);+ const feedKey = `${channelId}|${sort}|${activeKindFilter}|${JSON.stringify(filters)}`;+ // biome-ignore lint/correctness/useExhaustiveDependencies: feedKey is a trigger — a different filter set is a different list, which starts at the first page+ useEffect(() => {+ setVisibleCount(FEED_PAGE);+ }, [feedKey]);// biome-ignore lint/correctness/useExhaustiveDependencies: channelId is a trigger — switching channels or finishing the initial load swaps/completes the rows without a remount, so re-land at the latest cardsuseLayoutEffect(() => {if (isLoading) return;@@ -1490,15 +1817,28 @@ export function ChannelFeedView({prevPendingRef.current = latestPendingId;}, [latestPendingId]);+ const listRows = rowStyle ? rowStyle === "list" : compact;const composerBlock = composer && (- <div className="mx-auto mb-2 w-full max-w-[660px]">{composer}</div>+ <div+ className={cn(+ "w-full",+ compact ? "mb-1 border-border border-b pb-4" : "mb-2",+ )}+ >+ {composer}+ </div>);// One row: the kind tabs, and — on the Reports kind only — the same compact// funnel the sidebar uses. Reports deliberately get no extra filter chrome// beyond that, so the row reads the same weight whichever kind is active.const kindFilterBlock = reports !== undefined && showKindFilter && (- <div className="mx-auto flex w-full max-w-[660px] items-center gap-1 pt-1">+ <div+ className={cn(+ "flex w-full items-center gap-1",+ compact ? "mt-4 border-border border-t pt-2" : "pt-1",+ )}+ ><Tabsvalue={activeKindFilter}onValueChange={(value: string) =>@@ -1546,11 +1886,11 @@ export function ChannelFeedView({// say so, and point at the next action, instead of dead space.const kindEmptyNote =activeKindFilter === "sessions" ? (- <p className="mx-auto w-full max-w-[660px] py-6 text-center text-(--gray-10) text-[13px]">+ <p className="w-full py-6 text-center text-(--gray-10) text-[13px]">No sessions yet. Start one from the composer above.</p>) : activeKindFilter === "reports" ? (- <p className="mx-auto w-full max-w-[660px] py-6 text-center text-(--gray-10) text-[13px]">+ <p className="w-full py-6 text-center text-(--gray-10) text-[13px]">No reports here yet. Open the filter to widen the list.</p>) : null;@@ -1562,25 +1902,60 @@ export function ChannelFeedView({return (<div className="min-h-0 flex-1 overflow-y-auto" aria-busy="true"><output className="sr-only">Loading tasks</output>- <div className="mx-auto w-full px-4 pt-4 pb-10">- {intro && <div className="mx-auto w-full max-w-[660px]">{intro}</div>}- {composerBlock}- <FeedSkeleton />+ <div className="flex w-full items-stretch">+ <div+ className={cn(+ "min-w-0 flex-1",+ "mx-auto w-full",+ compact+ ? "max-w-[calc(70ch+3rem)] px-6 pt-5 pb-10"+ : "max-w-[692px] px-4 pt-4 pb-10",+ )}+ >+ {intro && <div className="w-full">{intro}</div>}+ {composerBlock}+ <FeedSkeleton compact={listRows} />+ </div></div></div>);}+ const noResults = (+ <div className="flex w-full flex-col items-start gap-2 pt-6">+ <p className="text-[13px] text-muted-foreground">+ Nothing here matches these filters.+ </p>+ {onClearFilters && (+ <Button variant="outline" size="sm" onClick={onClearFilters}>+ Clear filters+ </Button>+ )}+ </div>+ );+if (entries.length === 0 && pending.length === 0 && !intro) {return (<div className="min-h-0 flex-1 overflow-y-auto">- <div className="mx-auto w-full px-4 pt-4 pb-10">+ <div+ className={cn(+ "w-full",+ "mx-auto w-full",+ compact+ ? "max-w-[calc(70ch+3rem)] px-6 pt-5 pb-10"+ : "max-w-[692px] px-4 pt-4 pb-10",+ )}+ >{composerBlock}- {/* The filter stays visible while it's what emptied the list, so the- user can switch back out of an empty kind. A selected kind shows- its own note; the channel welcome is only for a truly empty feed. */}++ {controls}{kindFilterBlock}- {activeKindFilter === "all" ? emptyState : kindEmptyNote}++ {narrowed+ ? noResults+ : activeKindFilter === "all"+ ? emptyState+ : kindEmptyNote}</div></div>);@@ -1588,52 +1963,154 @@ export function ChannelFeedView({const now = new Date();const rows: ReactNode[] = [];+ const shownEntries = entries.slice(0, visibleCount);// Pending kickoffs land at the top, newest first, under a "Today" separator.let lastDayLabel: string | null = null;if (pending.length > 0) {lastDayLabel = "Today";- rows.push(<DaySeparator key="separator-pending" label="Today" />);+ rows.push(+ <DaySeparator key="separator-pending" label="Today" compact={listRows} />,+ );for (let i = pending.length - 1; i >= 0; i--) {const p = pending[i];rows.push(<PendingFeedRow key={p.id} pending={p} />);}}- for (const entry of entries) {- const label = feedDayLabel(entry.createdAt, now);- if (label !== lastDayLabel) {- lastDayLabel = label;- rows.push(<DaySeparator key={`separator-${label}`} label={label} />);+ const activityIso = (entry: FeedEntry): string => {+ if (sort === "created") return entry.createdAt;+ if (entry.kind === "canvas") {+ return new Date(entry.canvas.updatedAt).toISOString();+ }+ const ts = itemByKey.get(entryKey(entry) ?? "")?.ts;+ return ts ? new Date(ts).toISOString() : entry.createdAt;+ };+ const sectionLabel = (entry: FeedEntry): string | null => {+ if (sort === "alpha") return null;+ if (grouping === "repository") {+ if (entry.kind === "task")+ return entry.task.repository ?? "No repository";+ if (entry.kind === "pr") {+ return entry.pullRequest.task.repository ?? "No repository";+ }+ return "No repository";+ }+ return feedDayLabel(activityIso(entry), now);+ };+ const sectionKey = (entry: FeedEntry): string =>+ grouping === "date"+ ? `day:${activityIso(entry).slice(0, 10)}`+ : (sectionLabel(entry) ?? "all");+ const sections = buildFeedSections(shownEntries, {+ labelOf: sectionLabel,+ keyOf: sectionKey,+ });+ for (const section of sections) {+ if (section.label !== null && section.label !== lastDayLabel) {+ lastDayLabel = section.label;+ rows.push(+ <DaySeparator+ key={`separator-${section.key}`}+ label={section.label}+ compact={listRows}+ />,+ );+ }+ let striped = false;+ const lastEntry = section.entries[section.entries.length - 1];+ for (const entry of section.entries) {+ const row =+ entry.kind === "task" ? (+ listRows ? (+ <FeedLogRow+ key={entry.id}+ task={entry.task}+ onOpenTask={onOpenTask}+ onOpenThread={onOpenThread}+ />+ ) : (+ <FeedRow+ key={entry.id}+ task={entry.task}+ showRepo={+ !!entry.task.repository &&+ entry.task.repository !== dominantRepo+ }+ onOpenTask={onOpenTask}+ onOpenThread={onOpenThread}+ />+ )+ ) : entry.kind === "canvas" ? (+ <CanvasFeedRow+ key={entry.id}+ canvas={entry.canvas}+ channelId={channelId}+ listRow={listRows}+ />+ ) : entry.kind === "pr" ? (+ <PrFeedRow+ key={entry.id}+ pullRequest={entry.pullRequest}+ listRow={listRows}+ />+ ) : entry.kind === "report" ? (+ <ReportFeedRow+ key={entry.id}+ report={entry.report}+ onOpenReport={onOpenReport ?? (() => {})}+ />+ ) : (+ <SystemFeedRow key={entry.id} message={entry.message} />+ );+ if (!listRows || entry.kind === "system") {+ rows.push(row);+ continue;+ }+ rows.push(+ <div+ key={`stripe-${entry.id}`}+ className={cn(+ entry !== lastEntry && "border-border/60 border-b",+ striped &&+ "bg-[color-mix(in_oklab,var(--foreground)_2%,transparent)]",+ )}+ >+ {row}+ </div>,+ );+ striped = !striped;}- rows.push(- entry.kind === "task" ? (- <FeedRow- key={entry.id}- task={entry.task}- showRepo={- !!entry.task.repository && entry.task.repository !== dominantRepo- }- onOpenTask={onOpenTask}- onOpenThread={onOpenThread}- />- ) : entry.kind === "report" ? (- <ReportFeedRow- key={entry.id}- report={entry.report}- onOpenReport={onOpenReport ?? (() => {})}- />- ) : (- <SystemFeedRow key={entry.id} message={entry.message} />- ),- );}return (<div ref={viewportRef} className="min-h-0 flex-1 overflow-y-auto">- <div className="mx-auto w-full px-4 pt-4 pb-10">- {intro && <div className="mx-auto w-full max-w-[660px]">{intro}</div>}- {composerBlock}- {kindFilterBlock}- {rows.length === 0 ? kindEmptyNote : rows}+ <div className="flex w-full items-stretch">+ <div+ className={cn(+ "min-w-0 flex-1",+ "mx-auto w-full",+ compact+ ? "max-w-[calc(70ch+3rem)] px-6 pt-5 pb-10"+ : "max-w-[692px] px-4 pt-4 pb-10",+ )}+ >+ {intro && <div className="w-full">{intro}</div>}+ {composerBlock}+ {controls}+ {kindFilterBlock}++ <div+ className={cn(+ "transition-opacity duration-150",+ rebuilding && "pointer-events-none opacity-50",+ )}+ >+ {rows.length === 0 ? (narrowed ? noResults : kindEmptyNote) : rows}++ {visibleCount < entries.length && (+ <div ref={moreRef} className="h-8" aria-hidden />+ )}+ </div>+ </div></div></div>);diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsxindex 36e31c858663..56d043907f37 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx@@ -7,6 +7,7 @@ import {type ChannelItemSort,type CreatedByFilter,type EnvironmentFilter,+ type KindFilter,type PinnedFilter,} from "@posthog/core/canvas/channelItems";import {@@ -40,6 +41,12 @@ interface Option<T extends string> {// The two states a session can be in that are yours to clear, in the list's own// vocabulary: blue is blocked on you, the brand yellow is output you haven't// read. Everything settled is what's left, and has nothing to filter for.+const KIND_OPTIONS: readonly Option<KindFilter>[] = [+ { value: "any", label: "Sessions and canvases" },+ { value: "task", label: "Sessions" },+ { value: "canvas", label: "Canvases" },+];+const ATTENTION_OPTIONS: readonly Option<AttentionFilter>[] = [{ value: "any", label: "Any status" },{ value: "needs_input", label: "Needs input", tone: "blue" },@@ -63,11 +70,17 @@ const ENVIRONMENT_OPTIONS: readonly Option<EnvironmentFilter>[] = [{ value: "cloud", label: "Cloud" },];-const GROUPING_OPTIONS: readonly Option<ChannelItemGrouping>[] = [- { value: "date", label: "Date" },- { value: "repository", label: "Repository" },+const DEFAULT_GROUPINGS: readonly ChannelItemGrouping[] = [+ "date",+ "repository",];+const GROUPING_LABELS: Record<ChannelItemGrouping, string> = {+ date: "Date",+ repository: "Repository",+ space: "Space",+};+const SORT_OPTIONS: readonly Option<ChannelItemSort>[] = [{ value: "recent", label: "Recent activity" },{ value: "created", label: "Date created" },@@ -159,10 +172,12 @@ export function ChannelFilterMenu({sort,onSortChange,grouping,+ groupings,onGroupingChange,onEditAppearance,sources,showCreatedBy,+ showKindFilter = false,showRunFilters,active,}: {@@ -185,17 +200,23 @@ export function ChannelFilterMenu({/** What the list's section headers stand for. */grouping: ChannelItemGrouping;onGroupingChange: (grouping: ChannelItemGrouping) => void;+ groupings?: readonly ChannelItemGrouping[];/** Opens the list's appearance dialog, which the list itself renders. */- onEditAppearance: () => void;+ onEditAppearance?: () => void;/** `origin_product` keys present in the list. */sources: readonly string[];/** False in #me, where every session is yours and the filter says nothing. */showCreatedBy: boolean;/** False on the canvases tab: a canvas has no run to ask these about. */showRunFilters: boolean;+ showKindFilter?: boolean;/** A filter is narrowing the list, so the button says so. */active: boolean;}) {+ const groupingOptions: Option<ChannelItemGrouping>[] = (+ groupings ?? (showRunFilters ? DEFAULT_GROUPINGS : [])+ ).map((value) => ({ value, label: GROUPING_LABELS[value] }));+const sourceOptions: Option<string>[] = [{ value: ANY_SOURCE, label: "Any source" },...sources.map((source) => ({@@ -232,11 +253,10 @@ export function ChannelFilterMenu({sideOffset={6}className="min-w-fit">- {/* A canvas has no repository, so the canvas tab cannot group by repository. */}- {showRunFilters && (+ {groupingOptions.length > 1 && (<FilterSubmenulabel="Group by"- options={GROUPING_OPTIONS}+ options={groupingOptions}value={grouping}onChange={onGroupingChange}/>@@ -248,6 +268,15 @@ export function ChannelFilterMenu({onChange={onSortChange}/><DropdownMenuSeparator />++ {showKindFilter && (+ <FilterSubmenu+ label="Type"+ options={KIND_OPTIONS}+ value={filters.kind}+ onChange={(value) => onFilterChange("kind", value)}+ />+ )}{showRunFilters && (<FilterSubmenulabel="Status"@@ -289,8 +318,8 @@ export function ChannelFilterMenu({/></>)}- {/* A canvas has no configurable second row, so the canvas tab has no appearance editor. */}- {showRunFilters && (++ {showRunFilters && onEditAppearance && (<><DropdownMenuSeparator /><DropdownMenuItemdiff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPresence.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPresence.tsxnew file mode 100644index 000000000000..34c115c4a215--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemPresence.tsx@@ -0,0 +1,130 @@+import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import type { DashboardRecord } from "@posthog/core/canvas/dashboardSchemas";+import { presenceTier } from "@posthog/core/canvas/presence";+import {+ type AvatarPerson,+ UserAvatar,+} from "@posthog/ui/features/auth/UserAvatar";+import { PresenceAvatar } from "@posthog/ui/features/canvas/components/PresenceAvatars";+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";+import { useNow } from "@posthog/ui/hooks/useNow";++export function canvasAuthor(canvas: DashboardRecord): AvatarPerson | null {+ if (canvas.createdByUser) return canvas.createdByUser;+ if (!canvas.createdBy && !canvas.createdByUuid) return null;+ const [first, ...rest] = (canvas.createdBy ?? "")+ .split(/\s+/)+ .filter(Boolean);+ return {+ uuid: canvas.createdByUuid,+ first_name: first ?? null,+ last_name: rest.join(" ") || null,+ };+}++export function rowAuthor(+ item: ChannelItemModel,+): { user: AvatarPerson; label: string } | null {+ if (item.authorUser) {+ return { user: item.authorUser, label: userDisplayName(item.authorUser) };+ }+ if (item.kind === "task") return null;+ const name = item.authorName;+ if (!name && !item.authorUuid) return null;+ const [first, ...rest] = (name ?? "").split(/\s+/).filter(Boolean);+ return {+ user: {+ uuid: item.authorUuid,+ first_name: first ?? null,+ last_name: rest.join(" ") || null,+ },+ label: name ?? "Unknown",+ };+}++export function RowPresence({+ item,+ currentUserUuid,+}: {+ item: ChannelItemModel;+ currentUserUuid?: string;+}) {+ const author = rowAuthor(item);+ if (!author) return null;+ if (presenceTier(item.ts, Date.now()) === "idle") return null;+ return (+ <ActiveRowPresence+ item={item}+ author={author}+ isCurrentUser={author.user.uuid === currentUserUuid}+ />+ );+}++function ActiveRowPresence({+ item,+ author,+ isCurrentUser,+}: {+ item: ChannelItemModel;+ author: NonNullable<ReturnType<typeof rowAuthor>>;+ isCurrentUser: boolean;+}) {+ const tier = presenceTier(item.ts, useNow());+ if (tier === "idle") return null;+ return (+ <PresenceAvatar+ user={author.user}+ tier={tier}+ label={+ isCurrentUser && tier === "live"+ ? "You are working on this"+ : isCurrentUser+ ? "You were here recently"+ : tier === "live"+ ? `${author.label} is working on this`+ : `${author.label} was here recently`+ }+ />+ );+}++export function ActivityPresenceAvatar({+ user,+ label,+ activityAt,+ size = "xs",+}: {+ user: AvatarPerson | null | undefined;+ label: string;+ activityAt: number | string | null | undefined;+ size?: "lg" | "default" | "sm" | "xs";+}) {+ const now = useNow();+ if (!user) return null;+ const ts =+ typeof activityAt === "string"+ ? Date.parse(activityAt)+ : (activityAt ?? Number.NaN);+ const tier = Number.isNaN(ts) ? "idle" : presenceTier(ts, now);+ const name = userDisplayName(user);+ if (tier === "idle") {+ return (+ <span className="shrink-0" title={name}>+ <UserAvatar user={user} size={size} />+ </span>+ );+ }+ return (+ <PresenceAvatar+ user={user}+ tier={tier}+ size={size}+ label={+ tier === "live"+ ? `${name} is working ${label}`+ : `${name} was here recently`+ }+ />+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsxindex 10f002b161e3..c239e1d6a572 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx@@ -1,5 +1,4 @@import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";-import { presenceTier } from "@posthog/core/canvas/presence";import {AlertDialog,AlertDialogClose,@@ -17,12 +16,11 @@ import {TooltipTrigger,} from "@posthog/quill";import { formatRelativeTimeShort } from "@posthog/shared";-import type { AvatarPerson } from "@posthog/ui/features/auth/UserAvatar";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";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 { PresenceAvatar } from "@posthog/ui/features/canvas/components/PresenceAvatars";import {type TaskRowBulkMenu,TaskRowContextMenu,@@ -31,7 +29,6 @@ import {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";-import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";import { useArchivingTasksStore } from "@posthog/ui/features/sidebar/archivingTasksStore";import { InlineEditInput } from "@posthog/ui/features/sidebar/components/items/TaskItem";import {@@ -51,7 +48,6 @@ import { writeTaskDragData } from "@posthog/ui/features/sidebar/taskDrag";import { SESSION_ROW_ATTRIBUTE } from "@posthog/ui/features/sidebar/useMarqueeSelection";import { HandoffTaskDialog } from "@posthog/ui/features/task-detail/components/HandoffTaskDialog";import { useMountedOnceOpened } from "@posthog/ui/hooks/useMountedOnceOpened";-import { useNow } from "@posthog/ui/hooks/useNow";import { DotsCircleSpinner } from "@posthog/ui/primitives/DotsCircleSpinner";import {type DragEvent,@@ -161,85 +157,6 @@ function CanvasBadgeStack({}/** The person a row is attributed to, as a face can draw them. */-function rowAuthor(- item: ChannelItemModel,-): { user: AvatarPerson; label: string } | null {- if (item.authorUser) {- return { user: item.authorUser, label: userDisplayName(item.authorUser) };- }- if (item.kind === "task") return null;- const name = item.authorName;- if (!name && !item.authorUuid) return null;- const [first, ...rest] = (name ?? "").split(/\s+/).filter(Boolean);- return {- user: {- uuid: item.authorUuid,- first_name: first ?? null,- last_name: rest.join(" ") || null,- },- label: name ?? "Unknown",- };-}--/**- * The face of whoever is working on a row, shown only while the item is live or- * recently active — a quiet row stays clean.- *- * Idle is decided here, once, off the clock: an item's activity time is fixed,- * so a row that is idle now stays idle until its item changes, and re-rendering- * it every minute would buy nothing. Only a row with a face to fade subscribes.- */-function RowPresence({- item,- currentUserUuid,-}: {- item: ChannelItemModel;- currentUserUuid?: string;-}) {- const author = rowAuthor(item);- if (!author) return null;- if (presenceTier(item.ts, Date.now()) === "idle") return null;- return (- <ActiveRowPresence- item={item}- author={author}- isCurrentUser={author.user.uuid === currentUserUuid}- />- );-}--/**- * Subscribed to the clock rather than reading it once: the row is memoized on- * its item, which a poll returning the same rows leaves untouched, so nothing- * else would re-render it as the live window closes and the recent one ends.- */-function ActiveRowPresence({- item,- author,- isCurrentUser,-}: {- item: ChannelItemModel;- author: NonNullable<ReturnType<typeof rowAuthor>>;- isCurrentUser: boolean;-}) {- const tier = presenceTier(item.ts, useNow());- if (tier === "idle") return null;- return (- <PresenceAvatar- user={author.user}- tier={tier}- label={- isCurrentUser && tier === "live"- ? "You are working on this"- : isCurrentUser- ? "You were here recently"- : tier === "live"- ? `${author.label} is working on this`- : `${author.label} was here recently`- }- />- );-}/*** A row's leading mark, always the task-list state vocabulary. Canvases have nodiff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsxindex 6a08e2227e5c..ee8e2fd04663 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx@@ -15,18 +15,11 @@ import {import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";import type { ChannelPresence } from "@posthog/core/canvas/presence";import {- AlertDialogClose,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,Autocomplete,AutocompleteItem,AutocompleteList,Button,ButtonGroup,- AlertDialog as ConfirmDialog,ContextMenu,ContextMenuContent,ContextMenuItem,@@ -61,8 +54,8 @@ import { CreateChannelModal } from "@posthog/ui/features/canvas/components/Creatimport type { ChannelActionItem } from "@posthog/ui/features/canvas/components/channelActions";import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";import { PresenceAvatars } from "@posthog/ui/features/canvas/components/PresenceAvatars";-import { RenameChannelModal } from "@posthog/ui/features/canvas/components/RenameChannelModal";import { SidebarSearchHeader } from "@posthog/ui/features/canvas/components/SidebarSearchHeader";+import { SpaceActionDialogs } from "@posthog/ui/features/canvas/components/SpaceActionDialogs";import type { SpacePreviewPayload } from "@posthog/ui/features/canvas/components/SpacePreview";import {TaskRowContextMenu,@@ -756,7 +749,7 @@ function SpaceTaskRows({// The channel actions and their dialogs. Single source of truth so the dropdown// and context menus stay in lockstep.-function useChannelActions(channel: Channel): {+export function useChannelActions(channel: Channel): {actions: ChannelActionItem[];autoArchiveOpen: boolean;setAutoArchiveOpen: (open: boolean) => void;@@ -984,7 +977,7 @@ function useChannelActions(channel: Channel): {// Renders the shared channel actions into either menu primitive. Branching by// `kind` (rather than a union-typed component) keeps the item/separator props// type-checked against each primitive.-function ChannelActionItems({+export function ChannelActionItems({actions,kind,}: {@@ -1031,7 +1024,7 @@ function ChannelActionItems({// Hover-revealed "..." menu on a channel header. Presentation only — the action// list comes from `useChannelActions`, so it matches the right-click menu.-function ChannelMenu({+export function ChannelMenu({channelName,actions,open,@@ -1133,20 +1126,8 @@ const ChannelSection = memo(useEffect(() => () => clearTimeout(prefetchTimer.current), []);// Shared by the "..." dropdown and the right-click context menu so both offer// the same star / edit / rename / delete actions.- const {- actions,- autoArchiveOpen,- setAutoArchiveOpen,- saveAutoArchive,- isUpdatingAutoArchive,- renameOpen,- setRenameOpen,- confirmDeleteOpen,- setConfirmDeleteOpen,- confirmDelete,- isDeleting,- } = useChannelActions(channel);- const renameMounted = useMountedOnceOpened(renameOpen);+ const channelActions = useChannelActions(channel);+ const { actions } = channelActions;const newTask = () => {track(ANALYTICS_EVENTS.CHANNEL_ACTION, {@@ -1369,64 +1350,10 @@ const ChannelSection = memo(</ButtonGroup></div></SpaceHoverCard>- {/* One modal for both the dropdown and context-menu "Rename" actions. */}- {renameMounted && (- <RenameChannelModal- channel={channel}- open={renameOpen}- onOpenChange={setRenameOpen}- />- )}- {/* Destructive confirm for "Delete channel" — spells out what's removed. */}- <ConfirmDialog- open={confirmDeleteOpen}- onOpenChange={setConfirmDeleteOpen}- >- <AlertDialogContent className="max-w-md">- <AlertDialogHeader>- <AlertDialogTitle>Delete {channel.name}?</AlertDialogTitle>- <AlertDialogDescription>- This permanently deletes the {noun} and can’t be undone.- <ul className="list-disc ps-4">- <li>- The {noun} and its{" "}- <span className="font-medium">CONTEXT.md</span> are- deleted.- </li>- <li>- Every canvas saved in this {noun} is permanently deleted.- </li>- <li>- Filed tasks are removed from the {noun}, but the tasks- themselves are not deleted.- </li>- </ul>- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogClose- render={<Button variant="outline">Cancel</Button>}- />- <Button- variant="primary"- loading={isDeleting}- onClick={() =>- void confirmDelete().then((ok) => {- if (ok) setConfirmDeleteOpen(false);- })- }- >- Delete {noun}- </Button>- </AlertDialogFooter>- </AlertDialogContent>- </ConfirmDialog>- <AutoArchiveSettingsDialog+ <SpaceActionDialogschannel={channel}- open={autoArchiveOpen}- onOpenChange={setAutoArchiveOpen}- onSave={saveAutoArchive}- isSaving={isUpdatingAutoArchive}+ noun={noun}+ actions={channelActions}/></div>{expanded && (diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsxindex b4a32d011bbf..b103ee3a0078 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx@@ -23,6 +23,9 @@ const mocks = vi.hoisted(() => ({historyTabId: undefined as string | undefined,}));+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/shell/analytics", () => ({track: (...args: unknown[]) => mocks.track(...args),}));diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsxindex df97ae4a9301..cbb4464f60a6 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx@@ -10,6 +10,8 @@ import { ChannelsFab } from "@posthog/ui/features/canvas/components/ChannelsFab"import { ChannelsList } from "@posthog/ui/features/canvas/components/ChannelsList";import { useChannelsSidebarStore } from "@posthog/ui/features/canvas/components/channelsSidebarStore";import { TaskFeedPane } from "@posthog/ui/features/canvas/components/TaskFeedPane";+import { WorkActivityColumn } from "@posthog/ui/features/canvas/components/work/WorkActivityColumn";+import { WorkColumn } from "@posthog/ui/features/canvas/components/work/WorkColumn";import { useChannelPaneSwipe } from "@posthog/ui/features/canvas/hooks/useChannelPaneSwipe";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";import { useChannelsWorld } from "@posthog/ui/features/canvas/hooks/useChannelsWorld";@@ -17,7 +19,11 @@ import { useCurrentChannel } from "@posthog/ui/features/canvas/hooks/useCurrentCimport { useMarkChannelSeen } from "@posthog/ui/features/canvas/hooks/useMarkChannelSeen";import { useRailSurface } from "@posthog/ui/features/canvas/hooks/useRailSurface";import { useTrackChannelsSpaceViewed } from "@posthog/ui/features/canvas/hooks/useTrackChannelsSpaceViewed";-import type { NavRailPane } from "@posthog/ui/features/canvas/railPane";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";+import {+ type NavRailPane,+ railPaneFoldsIntoWork,+} from "@posthog/ui/features/canvas/railPane";import {selectActivityItem,selectActivityReport,@@ -29,6 +35,7 @@ import {useChannelPaneStore,} from "@posthog/ui/features/canvas/stores/channelPaneStore";import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import { useWorkActivityStore } from "@posthog/ui/features/canvas/stores/workActivityStore";import { InboxPane } from "@posthog/ui/features/inbox/components/InboxPane";import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";import { NavResizeTooltip } from "@posthog/ui/features/sidebar/components/NavResizeTooltip";@@ -153,6 +160,8 @@ type ActivityFeedListProps = ComponentProps<typeof ActivityFeedList>;*/function RailPaneBody({railPane,+ workLayout,+ workActivityOpen,showsActivityDetail,selectedActivityId,onActivityActivate,@@ -164,6 +173,8 @@ function RailPaneBody({pendingTabSwitch,}: {railPane: NavRailPane;+ workLayout: boolean;+ workActivityOpen: boolean;showsActivityDetail: boolean;selectedActivityId: string | undefined;// Taken from the list rather than restated, so the row's payload can change@@ -176,6 +187,9 @@ function RailPaneBody({sidebarVisible: boolean;pendingTabSwitch: boolean;}): ReactElement {+ if (workLayout && workActivityOpen) {+ return <WorkActivityColumn className="min-h-0 flex-1" />;+ }if (showsActivityDetail) {return (<ActivityFeedList@@ -187,6 +201,7 @@ function RailPaneBody({);}if (railPane === "inbox") return <InboxPane className="min-h-0 flex-1" />;+ if (workLayout && railPaneFoldsIntoWork(railPane)) return <WorkColumn />;if (railPane === "canvases") {return <CanvasesPane className="min-h-0 flex-1" />;}@@ -279,6 +294,8 @@ function ChannelsSidebarImpl() {// (route and main pane unchanged) while you look around. With no channel to// slide to there's only the list.const { pane: railPane, showsActivityDetail } = useRailSurface();+ const workLayout = useWorkLayout();+ const workActivityOpen = useWorkActivityStore((state) => state.open);const selectedActivityId = useActivitySelection()?.id;const sourceFeedId = useRouterState({select: (state) =>@@ -341,6 +358,8 @@ function ChannelsSidebarImpl() {{channelsLayout ? (<RailPaneBodyrailPane={railPane}+ workLayout={workLayout}+ workActivityOpen={workActivityOpen}showsActivityDetail={showsActivityDetail}selectedActivityId={selectedActivityId}onActivityActivate={selectActivityItem}diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsxindex eb2392d91641..8d0f12b8479b 100644--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx@@ -24,13 +24,21 @@ import {pickRailDestination,type RailCounts,type RailDestination,+ showWorkColumn,visibleRailDestinations,+ visibleWorkRailDestinations,} from "@posthog/ui/features/canvas/components/railDestinations";import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";import { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";+import { railPaneFoldsIntoWork } from "@posthog/ui/features/canvas/railPane";import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import {+ closeWorkActivity,+ useWorkActivityStore,+} from "@posthog/ui/features/canvas/stores/workActivityStore";import {formatHotkey,SHORTCUTS,@@ -199,13 +207,19 @@ function NavRailImpl() {const savedSearchesRailEnabled = useFeatureFlag(SAVED_SEARCHES_RAIL_FLAG);const hasSavedSearches = useProjectTaskFeeds().length > 0;- const destinations = visibleRailDestinations({+ const workLayout = useWorkLayout();+ const workActivityOpen = useWorkActivityStore((state) => state.open);+ const toggleWorkActivity = useWorkActivityStore((state) => state.toggle);+ const railFlags = {home: homeEnabled,inbox: inboxAvailable,loops: loopsEnabled,context: contextEnabled,savedSearches: savedSearchesRailEnabled && hasSavedSearches,- });+ };+ const destinations = workLayout+ ? visibleWorkRailDestinations(railFlags)+ : visibleRailDestinations(railFlags);const topDestinations = destinations.filter(({ placement }) => placement !== "bottom",);@@ -246,12 +260,30 @@ function NavRailImpl() {openBrowserTab(destination.href);return;}+ if (workLayout) {+ if (destination.pane === "activity") {+ if (!workActivityOpen) showWorkColumn();+ toggleWorkActivity();+ return;+ }+ closeWorkActivity();+ if (destination.pane === "spaces" && railPaneFoldsIntoWork(railPane)) {+ showWorkColumn();+ return;+ }+ }pickRailDestination(destination, railPane);};const renderDestination = (destination: RailDestination): ReactNode => {const { pane, label, Icon, count, countTone } = destination;- const isActive = railPane === pane;+ const isActive = workLayout+ ? pane === "activity"+ ? workActivityOpen+ : pane === "spaces"+ ? !workActivityOpen && railPaneFoldsIntoWork(railPane)+ : !workActivityOpen && railPane === pane+ : railPane === pane;const destinationCount = count?.(counts) ?? 0;const usesNotificationDot = pane === "activity" || pane === "inbox";let badge: ReactNode;@@ -290,8 +322,8 @@ function NavRailImpl() {key={pane}icon={<Icon- className={pane === "spaces" ? "size-5" : undefined}- size={pane === "spaces" ? 20 : 16}+ className={pane === "spaces" && !workLayout ? "size-5" : undefined}+ size={pane === "spaces" && !workLayout ? 20 : 16}weight={isActive ? "fill" : "regular"}/>}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ReportFeedRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ReportFeedRow.tsxindex 236065ddaf67..8de50eedae7b 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ReportFeedRow.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ReportFeedRow.tsx@@ -43,7 +43,7 @@ export function ReportFeedRow({<><Cardsize="sm"- className="group/report mx-auto my-1.5 w-full max-w-[660px] cursor-pointer rounded-xl py-0 transition-colors hover:bg-(--gray-2)"+ className="group/report my-1.5 w-full cursor-pointer rounded-xl py-0 transition-colors hover:bg-(--gray-2)"onClick={() => onOpenReport(report.id)}><CardContent className="flex flex-col gap-1 px-4 pt-3 pb-2.5">diff --git a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsxindex 4cbf19f2ba6d..3fc4e2c359e7 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx@@ -3,6 +3,9 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { fireEvent, render, screen } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({useChannelsLayout: () => false,}));diff --git a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsxindex 145b096695d9..57c73f126dcd 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx@@ -42,6 +42,7 @@ import {useDashboardMutations,} from "@posthog/ui/features/canvas/hooks/useDashboards";import { useSelectedCanvasId } from "@posthog/ui/features/canvas/hooks/useSelectedCanvasId";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { useCanvasChatPanelStore } from "@posthog/ui/features/canvas/stores/canvasChatPanelStore";import {useDashboardEditStore,@@ -335,6 +336,7 @@ function CanvasBreadcrumb({export function ShellLayout() {const spacesLayout = useChannelsLayout();+ const workLayout = useWorkLayout();const pathname = useRouterState({select: (s) =>s.location.pathname.startsWith("/spaces/") ? s.location.pathname : "",@@ -386,7 +388,7 @@ export function ShellLayout() {// The canvases grid (its own sub-route now that the channel index is the// static homepage, which carries its own header content).const isDashboardsGrid =- Boolean(channelId) && pathname === `${base}/canvases`;+ !workLayout && Boolean(channelId) && pathname === `${base}/canvases`;// Whether the single toolbar should render: the canvases grid, or any single// canvas (so Edit lives here too).diff --git a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsxindex df205838685e..9aa195f1c839 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx@@ -1,15 +1,15 @@import { AutocompleteClear, AutocompleteInput, Kbd } from "@posthog/quill";-import { useSidebarSearchStore } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";+import { useSidebarSearchFocus } from "@posthog/ui/features/canvas/hooks/useSidebarSearchFocus";import {formatHotkey,SHORTCUTS,} from "@posthog/ui/features/command/keyboard-shortcuts";import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";import {+ forwardRef,type ReactElement,type KeyboardEvent as ReactKeyboardEvent,type ReactNode,- useEffect,useRef,} from "react";@@ -23,14 +23,6 @@ interface SidebarSearchHeaderProps {onKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;}-function focusSearch(input: HTMLInputElement): void {- input.focus();- input.dispatchEvent(- new KeyboardEvent("keydown", { key: "Home", bubbles: true }),- );- input.select();-}-export function SidebarSearchHeader({title,actions,@@ -41,17 +33,7 @@ export function SidebarSearchHeader({onKeyDown,}: SidebarSearchHeaderProps): ReactElement {const searchRef = useRef<HTMLInputElement | null>(null);- const focusRequest = useSidebarSearchStore((state) => state.focusRequest);-- useEffect(() => {- if (focusRequest === 0) return;- const input = searchRef.current;- if (!input || input.closest("[inert]")) return;- // Claim after the inert guard so an offscreen header leaves the request for- // the visible one, and so each request focuses a single header once.- if (!useSidebarSearchStore.getState().claimFocus(focusRequest)) return;- focusSearch(input);- }, [focusRequest]);+ useSidebarSearchFocus(searchRef);return (<>@@ -59,39 +41,67 @@ export function SidebarSearchHeader({<h2 className="font-bold text-base">{title}</h2></ChromeBar><div className="shrink-0 px-2 pt-2">- <AutocompleteInput+ <SidebarSearchInputref={searchRef}+ query={query}placeholder={placeholder}- aria-label={searchLabel}- showSearchIcon={false}- className="h-7 text-[13px] hover:bg-fill-hover"- onKeyDown={(event) => {- onKeyDown?.(event);- if (- event.defaultPrevented ||- event.key !== "Escape" ||- query === ""- ) {- return;- }- event.preventDefault();- event.stopPropagation();- onClear();- }}- >- {query === "" ? (- <Kbd className="-mr-0.5 shrink-0">- {formatHotkey(SHORTCUTS.FOCUS_SIDEBAR_SEARCH)}- </Kbd>- ) : (- <AutocompleteClear- tabIndex={0}- aria-label="Clear search"- onClick={onClear}- />- )}- </AutocompleteInput>+ searchLabel={searchLabel}+ onClear={onClear}+ onKeyDown={onKeyDown}+ /></div></>);}++export const SidebarSearchInput = forwardRef<+ HTMLInputElement,+ {+ query: string;+ placeholder: string;+ searchLabel: string;+ onClear: () => void;+ onKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;+ className?: string;+ }+>(function SidebarSearchInput(+ { query, placeholder, searchLabel, onClear, onKeyDown, className },+ ref,+) {+ return (+ <div className={className}>+ <AutocompleteInput+ ref={ref}+ placeholder={placeholder}+ aria-label={searchLabel}+ showSearchIcon={false}+ className="h-7 text-[13px] hover:bg-fill-hover"+ onKeyDown={(event) => {+ onKeyDown?.(event);+ if (+ event.defaultPrevented ||+ event.key !== "Escape" ||+ query === ""+ ) {+ return;+ }+ event.preventDefault();+ event.stopPropagation();+ onClear();+ }}+ >+ {query === "" ? (+ <Kbd className="-mr-0.5 shrink-0">+ {formatHotkey(SHORTCUTS.FOCUS_SIDEBAR_SEARCH)}+ </Kbd>+ ) : (+ <AutocompleteClear+ tabIndex={0}+ aria-label="Clear search"+ onClick={onClear}+ />+ )}+ </AutocompleteInput>+ </div>+ );+});diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceActionDialogs.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceActionDialogs.tsxnew file mode 100644index 000000000000..e03e6883ddc6--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceActionDialogs.tsx@@ -0,0 +1,101 @@+import {+ AlertDialogClose,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ Button,+ AlertDialog as ConfirmDialog,+} from "@posthog/quill";+import { AutoArchiveSettingsDialog } from "@posthog/ui/features/canvas/components/AutoArchiveSettingsDialog";+import type { useChannelActions } from "@posthog/ui/features/canvas/components/ChannelsList";+import { RenameChannelModal } from "@posthog/ui/features/canvas/components/RenameChannelModal";+import type { Channel } from "@posthog/ui/features/canvas/hooks/useChannels";+import { useMountedOnceOpened } from "@posthog/ui/hooks/useMountedOnceOpened";+import type { ReactElement } from "react";++export function SpaceActionDialogs({+ channel,+ noun,+ actions,+}: {+ channel: Channel;+ noun: string;+ actions: ReturnType<typeof useChannelActions>;+}): ReactElement {+ const {+ renameOpen,+ setRenameOpen,+ confirmDeleteOpen,+ setConfirmDeleteOpen,+ confirmDelete,+ isDeleting,+ autoArchiveOpen,+ setAutoArchiveOpen,+ saveAutoArchive,+ isUpdatingAutoArchive,+ } = actions;+ const renameMounted = useMountedOnceOpened(renameOpen);++ return (+ <>+ {renameMounted && (+ <RenameChannelModal+ channel={channel}+ open={renameOpen}+ onOpenChange={setRenameOpen}+ />+ )}+ <ConfirmDialog+ open={confirmDeleteOpen}+ onOpenChange={setConfirmDeleteOpen}+ >+ <AlertDialogContent className="max-w-md">+ <AlertDialogHeader>+ <AlertDialogTitle>Delete {channel.name}?</AlertDialogTitle>+ <AlertDialogDescription>+ This permanently deletes the {noun} and can’t be undone.+ <ul className="list-disc ps-4">+ <li>+ The {noun} and its{" "}+ <span className="font-medium">CONTEXT.md</span> are deleted.+ </li>+ <li>+ Every canvas saved in this {noun} is permanently deleted.+ </li>+ <li>+ Filed tasks are removed from the {noun}, but the tasks+ themselves are not deleted.+ </li>+ </ul>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogClose+ render={<Button variant="outline">Cancel</Button>}+ />+ <Button+ variant="primary"+ loading={isDeleting}+ onClick={() =>+ void confirmDelete().then((ok) => {+ if (ok) setConfirmDeleteOpen(false);+ })+ }+ >+ Delete {noun}+ </Button>+ </AlertDialogFooter>+ </AlertDialogContent>+ </ConfirmDialog>+ <AutoArchiveSettingsDialog+ channel={channel}+ open={autoArchiveOpen}+ onOpenChange={setAutoArchiveOpen}+ onSave={saveAutoArchive}+ isSaving={isUpdatingAutoArchive}+ />+ </>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsxindex dd148e474cc8..76fcdb089611 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx@@ -13,6 +13,9 @@ const activityMocks = vi.hoisted(() => ({} | null,}));+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/canvas/stores/activityDetailStore", () => ({clearActivitySelection: activityMocks.clearSelection,useActivitySelection: () => activityMocks.selection,diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.test.tsxindex 72ceeba9f015..6a498bf2ae57 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.test.tsx@@ -41,6 +41,9 @@ const NO_WIKI_PAGE = {// TaskInput is a huge hook-heavy component; stub it down to just the surface// this test cares about — a button that fires onContextChipClick when wired.+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/task-detail/components/TaskInput", () => ({TaskInput: (props: {allowNoRepo?: boolean;diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.tsxindex 7c87e4275fe6..fc5586d18e6d 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceNewTask.tsx@@ -4,10 +4,12 @@ import { CHANNEL_TASK_SUGGESTIONS } from "@posthog/ui/features/canvas/channelTasimport { ChannelBreadcrumb } from "@posthog/ui/features/canvas/components/ChannelBreadcrumb";import { ChannelContextPanel } from "@posthog/ui/features/canvas/components/ChannelContextPanel";import { SpaceSelect } from "@posthog/ui/features/canvas/components/SpaceSelect";+import { NewSessionHeading } from "@posthog/ui/features/canvas/components/work/NewSessionHeading";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";import { useChannelTaskMutations } from "@posthog/ui/features/canvas/hooks/useChannelTasks";import { useFolderInstructions } from "@posthog/ui/features/canvas/hooks/useFolderInstructions";import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { useChannelWikiContext } from "@posthog/ui/features/context-wiki/hooks/useContextWiki";import { useContextLayerFlag } from "@posthog/ui/features/feature-flags/useContextLayerFlag";import { TaskInput } from "@posthog/ui/features/task-detail/components/TaskInput";@@ -39,9 +41,9 @@ export function SpaceNewTask({ channelId }: { channelId: string }) {const channelName = channel?.name;const contextLayerEnabled = useContextLayerFlag();const wiki = useChannelWikiContext(channelId, contextLayerEnabled);+ const workLayout = useWorkLayout();// Surface the channel breadcrumb in the shared header, same as the other- // channel scenes ("# channel / New session").useSetHeaderContent(useMemo(() => (@@ -53,6 +55,7 @@ export function SpaceNewTask({ channelId }: { channelId: string }) {),[channelName, channelId, spacesLayout],),+ !workLayout,);// The channel's CONTEXT.md, passed to the agent as optional background so// tasks created here start with the shared context. Absent/empty is fine.@@ -137,13 +140,25 @@ export function SpaceNewTask({ channelId }: { channelId: string }) {// Beside the Cloud/Local chip: which space the task files into.// Arriving from a space's own "+" this is pre-filled; the global// new-task entry points land on #me.- spaceSelector={({ disabled }) => (- <SpaceSelect- value={channelId}- onChange={handleSpaceChange}- disabled={disabled}- />- )}+ spaceSelector={+ workLayout+ ? undefined+ : ({ disabled }) => (+ <SpaceSelect+ value={channelId}+ onChange={handleSpaceChange}+ disabled={disabled}+ />+ )+ }+ heading={+ workLayout ? (+ <NewSessionHeading+ channelId={channelId}+ onChangeSpace={handleSpaceChange}+ />+ ) : undefined+ }onTaskCreatedEffect={onTaskCreatedEffect}channelContext={channelContext}channelContextPath={wiki.path}diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsxnew file mode 100644index 000000000000..a0eeacc8bbb4--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceRowControls.tsx@@ -0,0 +1,83 @@+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/SpaceSelect.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsxindex 08688b1fb7e5..f0b391e574e4 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx@@ -1,3 +1,4 @@+import { CaretDownIcon } from "@phosphor-icons/react";import {Button,Combobox,@@ -11,6 +12,7 @@ import {ComboboxList,ComboboxSeparator,ComboboxTrigger,+ cn,} from "@posthog/quill";import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";@@ -32,9 +34,11 @@ export function SpaceSelect({value,onChange,disabled = false,+ variant = "chip",}: {value: string;onChange: (channelId: string) => void;+ variant?: "chip" | "headline";/*** Held shut while a task is being created. Retargeting mid-submit navigates* away from the composer that owns the in-flight request, so the task lands@@ -92,26 +96,44 @@ export function SpaceSelect({itemToStringLabel={(id) => byId.get(id)?.name ?? ""}disabled={disabled}>- <div ref={anchorRef} className="inline-flex">+ <div ref={anchorRef} className="inline-flex max-w-full"><ComboboxTriggerrender={- <Button- type="button"- variant="default"- size="sm"- disabled={disabled}- aria-label="Space"- title={current?.name}- >- {triggerGlyph && (- <span className="shrink-0 text-muted-foreground">- {triggerGlyph}+ variant === "headline" ? (+ <button+ type="button"+ disabled={disabled}+ aria-label="Space"+ title={current?.name}+ className={cn(+ "inline-flex max-w-full items-center gap-1.5 border-border border-b-2 border-dashed text-foreground transition-colors hover:border-foreground disabled:opacity-60",+ !current && "text-muted-foreground",+ )}+ >+ <span className="min-w-0 truncate">+ {current?.name ?? "choose a space"}</span>- )}- <span className="min-w-0 truncate">- {current?.name ?? "Space"}- </span>- </Button>+ <CaretDownIcon size={18} weight="bold" className="shrink-0" />+ </button>+ ) : (+ <Button+ type="button"+ variant="default"+ size="sm"+ disabled={disabled}+ aria-label="Space"+ title={current?.name}+ >+ {triggerGlyph && (+ <span className="shrink-0 text-muted-foreground">+ {triggerGlyph}+ </span>+ )}+ <span className="min-w-0 truncate">+ {current?.name ?? "Space"}+ </span>+ </Button>+ )}/></div>diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsxindex fc297bd5f0ed..64c90cd522df 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx@@ -1,3 +1,4 @@+import { Text } from "@posthog/quill";import { ChannelHeader } from "@posthog/ui/features/canvas/components/ChannelHeader";import { SpaceMembersSettings } from "@posthog/ui/features/canvas/components/SpaceMembersSettings";import { SpaceRepositories } from "@posthog/ui/features/canvas/components/SpaceRepositories";@@ -8,6 +9,7 @@ import {useChannels,} from "@posthog/ui/features/canvas/hooks/useChannels";import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { SettingsSection } from "@posthog/ui/features/settings/components/SettingsCard";import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";import {@@ -33,11 +35,12 @@ export function SpaceSettings({ channelId }: { channelId: string }) {const { channels: taskChannels, isLoading: tasksLoading } = useTaskChannels();const channel = channels.find((item) => item.id === channelId);const taskChannel = taskChannels.find((item) => item.id === channelId);+ const workLayout = useWorkLayout();const header = useMemo(() => <ChannelHeader channelId={channelId} page="settings" />,[channelId],);- useSetHeaderContent(header);+ useSetHeaderContent(header, !workLayout);const isPrivate = channel?.channelType === "private";const { members } = useChannelMembers(isPrivate ? channelId : null);@@ -54,16 +57,25 @@ export function SpaceSettings({ channelId }: { channelId: string }) {return (<div className="h-full overflow-y-auto">- <PageHeader>- <PageHeaderHeading>- <PageHeaderTitle>Settings</PageHeaderTitle>- <PageHeaderDescription>+ {workLayout ? (+ <div className="flex h-11 shrink-0 items-center border-border border-b px-6">+ <Text size="xs" variant="muted">Repositories and who can see this space. Changes save as you makethem.- </PageHeaderDescription>- </PageHeaderHeading>- </PageHeader>- <div className="flex max-w-[800px] flex-col gap-7 px-6 py-5">+ </Text>+ </div>+ ) : (+ <PageHeader>+ <PageHeaderHeading>+ <PageHeaderTitle>Settings</PageHeaderTitle>+ <PageHeaderDescription>+ Repositories and who can see this space. Changes save as you make+ them.+ </PageHeaderDescription>+ </PageHeaderHeading>+ </PageHeader>+ )}+ <div className="flex max-w-[800px] flex-col gap-7 px-6 pt-6 pb-5"><SettingsSectionlabel="Repositories"description="Sessions in this space start with these repositories checked out."diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsxindex a69f042d49b8..239df85fca29 100644--- a/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx@@ -1,66 +1,173 @@-import { PlusIcon, StarIcon } from "@phosphor-icons/react";-import { channelDisplayLabel } from "@posthog/core/canvas/channelName";+import { MagnifyingGlassIcon, PlusIcon, StarIcon } from "@phosphor-icons/react";import {Button,- Card,- CardContent,+ cn,Empty,EmptyDescription,EmptyHeader,EmptyMedia,EmptyTitle,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,Skeleton,Text,+ Tooltip,+ TooltipContent,+ TooltipTrigger,} from "@posthog/quill";+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";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 { SpacesIcon } from "@posthog/ui/features/canvas/components/SpacesIcon";+import { useChannelStarToggle } from "@posthog/ui/features/canvas/hooks/useChannelStars";import {type Channel,useChannels,} from "@posthog/ui/features/canvas/hooks/useChannels";+import { useSpaceOverview } from "@posthog/ui/features/canvas/hooks/useRecentSpaceTasks";+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";+import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";+import { useInView } from "@posthog/ui/primitives/hooks/useInView";+import { track } from "@posthog/ui/shell/analytics";import { Link } from "@tanstack/react-router";-import { useState } from "react";+import { useMemo, useState } from "react";-function SpaceCard({ channel }: { channel: Channel }) {+function StarToggle({ channel }: { channel: Channel }) {+ const { isStarred, toggleStar } = useChannelStarToggle(channel);+ const label = isStarred ? "Unstar space" : "Star space";+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ variant="default"+ size="icon-sm"+ aria-label={label}+ className={cn(+ "shrink-0",+ isStarred+ ? "text-warning"+ : "text-muted-foreground/40 group-hover/space:text-muted-foreground",+ )}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: isStarred ? "unstar" : "star",+ surface: "spaces_index",+ channel_id: channel.id,+ });+ toggleStar();+ }}+ >+ <StarIcon size={14} weight={isStarred ? "fill" : "regular"} />+ </Button>+ }+ />+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ );+}++const FACES_PER_ROW = 3;++const PEOPLE_PER_SPACE = 12;++function SpaceRow({ channel }: { channel: Channel }) {+ const [ref, inView] = useInView<HTMLAnchorElement>({+ rootMargin: "300px 0px",+ once: true,+ });+ const { people } = useSpaceOverview(channel.id, null, PEOPLE_PER_SPACE, {+ enabled: inView,+ });const personal = channel.channelType === "personal";+ const repositories = channel.repositories.join(", ");return (<Link+ ref={ref}to="/spaces/$channelId"params={{ channelId: channel.id }}- className="no-underline"+ className="group/space flex h-8 items-center gap-3 rounded-(--radius-2) pr-1 pl-2 no-underline transition-colors hover:bg-fill-hover">- <Card className="h-full transition-colors hover:bg-fill-hover">- <CardContent className="flex flex-col gap-2 p-4">- <div className="flex min-w-0 items-center gap-1.5">- {channelGlyph(channel.name, {- size: 14,- personal,- private: channel.channelType === "private",- })}- <Text weight="semibold" className="truncate">- {channelDisplayLabel(channel.name, channel.channelType)}- </Text>- {channel.starred && (- <StarIcon- size={12}- weight="fill"- className="shrink-0 text-warning"+ {channelGlyph(channel.name, {+ size: 13,+ personal,+ private: channel.channelType === "private",+ })}++ <Text size="sm" weight="medium" className="min-w-0 shrink-0 truncate">+ {channel.name}+ </Text>+ <Text size="xxs" variant="muted" className="min-w-0 flex-1 truncate">+ {repositories}+ </Text>+ {people.length > 0 && (+ <span className="flex shrink-0 items-center gap-1">+ <PresenceAvatars+ people={people.slice(0, FACES_PER_ROW)}+ className="shrink-0"+ />+ {people.length > FACES_PER_ROW && (+ <Tooltip>+ <TooltipTrigger+ render={+ <span className="text-[11px] text-muted-foreground tabular-nums opacity-0 transition-opacity group-hover/space:opacity-100">+ +{people.length - FACES_PER_ROW}+ </span>+ }/>- )}- </div>- <Text size="sm" variant="muted" className="truncate">- {channel.repositories.length > 0- ? channel.repositories.join(", ")- : "No repositories wired up"}- </Text>- </CardContent>- </Card>+ <TooltipContent side="top">+ {people+ .slice(FACES_PER_ROW)+ .map((person) => userDisplayName(person))+ .join(", ")}+ </TooltipContent>+ </Tooltip>+ )}+ </span>+ )}+ {personal ? <div className="size-6" /> : <StarToggle channel={channel} />}</Link>);}+function SpaceList({ channels }: { channels: Channel[] }) {+ return (+ <div className="flex flex-col gap-px">+ {channels.map((channel) => (+ <SpaceRow key={channel.id} channel={channel} />+ ))}+ </div>+ );+}++function SectionLabel({+ children,+ count,+}: {+ children: string;+ count: number;+}) {+ return (+ <div className="mb-1 flex items-baseline gap-2 px-2">+ <Text+ size="xxs"+ weight="semibold"+ className="text-foreground/70 uppercase tracking-wider"+ >+ {children}+ </Text>+ <Text size="xxs" variant="muted">+ {count}+ </Text>+ </div>+ );+}+/*** The `/spaces` page: every space in the project, and a way to make one.*@@ -70,45 +177,109 @@ function SpaceCard({ channel }: { channel: Channel }) {export function SpacesIndex() {const { channels, isLoading } = useChannels();const [createOpen, setCreateOpen] = useState(false);+ const [query, setQuery] = useState("");- return (- <div className="h-full overflow-auto bg-gray-1">- <div className="mx-auto w-full max-w-5xl px-6 py-6">- <div className="mb-4 flex items-center justify-between gap-3">- <Text size="lg" weight="semibold">- Spaces- </Text>- <Button variant="primary" onClick={() => setCreateOpen(true)}>+ const needle = query.trim().toLowerCase();+ const { starred, rest } = useMemo(() => {+ const shown = needle+ ? channels.filter((c) => c.name.toLowerCase().includes(needle))+ : channels;+ const personal = shown.filter((c) => c.channelType === "personal");+ return {+ starred: [+ ...personal,+ ...shown.filter((c) => c.starred && c.channelType !== "personal"),+ ],+ rest: shown.filter((c) => !c.starred && c.channelType !== "personal"),+ };+ }, [channels, needle]);+ const noMatches = starred.length === 0 && rest.length === 0;++ useSetHeaderContent(+ useMemo(+ () => (+ <>+ <div className="flex min-w-0 items-center gap-1.5 pl-5">+ <span className="shrink-0 text-muted-foreground">+ <SpacesIcon size={14} />+ </span>+ <span className="min-w-0 truncate font-medium text-[13px]">+ Spaces+ </span>+ </div>+ <Button+ variant="primary"+ size="sm"+ onClick={() => setCreateOpen(true)}+ ><PlusIcon size={14} />New space…</Button>- </div>+ </>+ ),+ [],+ ),+ );- {isLoading ? (- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">- {[0, 1, 2].map((i) => (- <Skeleton key={i} className="h-[86px] w-full" />- ))}- </div>- ) : channels.length === 0 ? (- <Empty>- <EmptyHeader>- <EmptyMedia variant="icon">- <SpacesIcon size={20} />- </EmptyMedia>- <EmptyTitle>No spaces yet</EmptyTitle>- <EmptyDescription>- A space gets its own sessions, canvases, and context.- </EmptyDescription>- </EmptyHeader>- </Empty>- ) : (- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">- {channels.map((channel) => (- <SpaceCard key={channel.id} channel={channel} />- ))}- </div>- )}+ return (+ <div className="flex h-full min-h-0 flex-col bg-gray-1">+ <div className="scroll-mask-4 min-h-0 flex-1 overflow-auto">+ <div className="mx-auto w-full max-w-5xl px-6 py-5">+ <InputGroup className="mb-5 max-w-xs">+ <InputGroupAddon>+ <MagnifyingGlassIcon size={14} aria-hidden />+ </InputGroupAddon>+ <InputGroupInput+ value={query}+ placeholder="Search spaces…"+ aria-label="Search spaces"+ onChange={(event) => setQuery(event.target.value)}+ />+ </InputGroup>++ {isLoading ? (+ <div className="flex flex-col gap-px">+ {[0, 1, 2, 3, 4, 5].map((i) => (+ <Skeleton key={i} className="h-8 w-full" />+ ))}+ </div>+ ) : channels.length === 0 ? (+ <Empty>+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <SpacesIcon size={20} />+ </EmptyMedia>+ <EmptyTitle>No spaces yet</EmptyTitle>+ <EmptyDescription>+ A space gets its own sessions, canvases, and context.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ ) : noMatches ? (+ <Text size="sm" variant="muted">+ No space by that name.+ </Text>+ ) : (+ <div className="flex flex-col gap-5">+ {starred.length > 0 && (+ <div>+ <SectionLabel count={starred.length}>Starred</SectionLabel>+ <SpaceList channels={starred} />+ </div>+ )}+ {rest.length > 0 && (+ <div>+ {starred.length > 0 && (+ <SectionLabel count={rest.length}>+ Everything else+ </SectionLabel>+ )}+ <SpaceList channels={rest} />+ </div>+ )}+ </div>+ )}+ </div></div><CreateChannelModal open={createOpen} onOpenChange={setCreateOpen} /></div>diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.test.tsxindex 0bb72d54791a..4aafbe575390 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.test.tsx@@ -47,9 +47,50 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannelFeedMessages", () => ({useChannelFeedMessages: () => ({ messages: [], isLoading: false }),channelCreationMessage: () => null,}));+vi.mock(+ "@posthog/ui/features/canvas/components/work/useSpacePullRequests",+ () => ({ useSpacePullRequests: () => [] }),+);vi.mock("@posthog/ui/features/canvas/hooks/useFolderInstructions", () => ({useFolderInstructions: () => ({ data: undefined, isLoading: false }),}));+vi.mock(+ "@posthog/ui/features/canvas/hooks/useDashboards",+ async (original) => ({+ ...(await original<object>()),+ useDashboards: () => ({ dashboards: [], isLoading: false }),+ }),+);+vi.mock(+ "@posthog/ui/features/archive/useArchivedTaskIds",+ async (original) => ({+ ...(await original<object>()),+ useArchivedTaskIds: () => new Set<string>(),+ }),+);+vi.mock("@posthog/ui/features/sidebar/usePinnedTasks", async (original) => ({+ ...(await original<object>()),+ usePinnedTasks: () => ({ pinnedTaskIds: new Set<string>() }),+}));+vi.mock(+ "@posthog/ui/features/canvas/hooks/useChannelItems",+ async (original) => ({+ ...(await original<object>()),+ useChannelSessionFacts: () => ({+ needsInputTaskIds: new Set<string>(),+ viewedTimestamps: {},+ workspaceByTaskId: new Map(),+ }),+ }),+);+vi.mock("@posthog/ui/features/auth/authClient", async (original) => ({+ ...(await original<object>()),+ useOptionalAuthenticatedClient: () => null,+}));+vi.mock("@posthog/ui/features/auth/useCurrentUser", async (original) => ({+ ...(await original<object>()),+ useCurrentUser: () => ({ data: undefined }),+}));vi.mock("@posthog/ui/features/canvas/hooks/useChannelTasks", () => ({useChannelTaskMutations: () => ({ fileTask: () => Promise.resolve() }),}));@@ -62,6 +103,16 @@ vi.mock("@posthog/ui/features/feature-flags/useFeatureFlag", () => ({vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));vi.mock("@tanstack/react-query", () => ({useQueryClient: () => ({ setQueryData: vi.fn(), invalidateQueries: vi.fn() }),+ keepPreviousData: <T,>(previous: T): T => previous,+ useQuery: () => ({ data: undefined, isLoading: false, isPending: false }),+ useQueries: () => [],+ useInfiniteQuery: () => ({+ data: undefined,+ isLoading: false,+ hasNextPage: false,+ fetchNextPage: vi.fn(),+ }),+ useMutation: () => ({ mutateAsync: vi.fn(), mutate: vi.fn() }),}));vi.mock("@tanstack/react-router", () => ({ useNavigate: () => vi.fn() }));diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsxindex 626c40cc0057..bfcf1aaae8df 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx@@ -1,8 +1,16 @@+import {+ buildChannelItems,+ DEFAULT_CHANNEL_ITEM_FILTERS,+} from "@posthog/core/canvas/channelItems";import { isPersonalChannel } from "@posthog/core/canvas/channelName";import { insertTaskDedup } from "@posthog/core/tasks/taskDelete";+import { cn } from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import type { Task } from "@posthog/shared/domain-types";import { isTerminalStatus } from "@posthog/shared/domain-types";+import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";import { CHANNEL_TASK_SUGGESTIONS } from "@posthog/ui/features/canvas/channelTaskSuggestions";import {ChannelFeedView,@@ -19,39 +27,65 @@ import {} from "@posthog/ui/features/canvas/components/ChannelIntro";import { CreateChannelModal } from "@posthog/ui/features/canvas/components/CreateChannelModal";import { ThreadSidebar } from "@posthog/ui/features/canvas/components/ThreadSidebar";+import { SpaceActivityControls } from "@posthog/ui/features/canvas/components/work/SpaceActivityControls";+import { useSpacePullRequests } from "@posthog/ui/features/canvas/components/work/useSpacePullRequests";import { CONTEXT_MD_TASK_TITLE_PREFIX } from "@posthog/ui/features/canvas/contextPrompt";import {channelFeedQueryKey,useChannelFeed,} from "@posthog/ui/features/canvas/hooks/useChannelFeed";import { useChannelFeedMessages } from "@posthog/ui/features/canvas/hooks/useChannelFeedMessages";+import { useChannelSessionFacts } from "@posthog/ui/features/canvas/hooks/useChannelItems";+import {+ DEFAULT_CHANNEL_REPORTS_FILTERS,+ useChannelReports,+} from "@posthog/ui/features/canvas/hooks/useChannelReports";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";import { useChannelTaskMutations } from "@posthog/ui/features/canvas/hooks/useChannelTasks";+import { useDashboards } from "@posthog/ui/features/canvas/hooks/useDashboards";import { useFolderInstructions } from "@posthog/ui/features/canvas/hooks/useFolderInstructions";import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";import { useChannelIntroStore } from "@posthog/ui/features/canvas/stores/channelIntroStore";+import { useSpaceActivityViewStore } from "@posthog/ui/features/canvas/stores/spaceActivityViewStore";import {type ThreadPanelTab,useThreadPanelStore,} from "@posthog/ui/features/canvas/stores/threadPanelStore";import { openRightPanelSide } from "@posthog/ui/features/navigation/rightPanelSide";+import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";import { SuggestedPromptCard } from "@posthog/ui/features/task-detail/components/SuggestedPromptCard";import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";import { toast } from "@posthog/ui/primitives/toast";+import { navigateToChannelReportDetail } from "@posthog/ui/router/navigationBridge";import { track } from "@posthog/ui/shell/analytics";-import { Heading, Text } from "@radix-ui/themes";import { useQueryClient } from "@tanstack/react-query";import { useNavigate } from "@tanstack/react-router";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import {+ useCallback,+ useDeferredValue,+ useEffect,+ useMemo,+ useRef,+ useState,+} from "react";++const NO_TASKS: Task[] = [];// A channel: a multiplayer feed. Each member message kicks off a task rendered// as a card everyone in the channel sees; the composer stays pinned at the top// (Twitter-style — new session first, newest cards under it) and threads open// in a right-hand panel. The channel's artifacts/history/context views stay in// the tabs above (ChannelHeader).-export function WebsiteChannelHome({ channelId }: { channelId: string }) {+export function WebsiteChannelHome({+ channelId,+ variant = "feed",+}: {+ channelId: string;+ variant?: "feed" | "work";+}) {const spacesLayout = useChannelsLayout();+ const isWork = variant === "work";const navigate = useNavigate();const queryClient = useQueryClient();// The raw channel row (creator + creation time) feeds the intro and the@@ -68,6 +102,39 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {const channelContext = instructions?.content;const { tasks, isLoading: isLoadingFeed } = useChannelFeed(channelId);+ const { dashboards: spaceCanvases } = useDashboards(channelId);+ const archivedTaskIds = useArchivedTaskIds();+ const { pinnedTaskIds } = usePinnedTasks();+ const sessionFacts = useChannelSessionFacts();+ const homeClient = useOptionalAuthenticatedClient();+ const { data: homeUser } = useCurrentUser({ client: homeClient });+ const me = useMemo(+ () => ({ uuid: homeUser?.uuid ?? null }),+ [homeUser?.uuid],+ );+ // The Slack-style intro pinned at the feed's start — public channels only;+ // the personal channel keeps the welcome empty state below.+ const isPersonal = channel ? isPersonalChannel(channel) : false;+ const spaceItems = useMemo(+ () =>+ buildChannelItems({+ dashboards: spaceCanvases,+ feedTasks: tasks,+ archivedTaskIds,+ pinnedTaskIds,+ ownedBy: isPersonal && me.uuid ? me : null,+ sessionFacts,+ }),+ [+ spaceCanvases,+ tasks,+ archivedTaskIds,+ pinnedTaskIds,+ isPersonal,+ me,+ sessionFacts,+ ],+ );// Marking this channel read lives in ChannelHeader (rendered by every channel// surface), so opening Artifacts or CONTEXT.md counts as reading it too.@@ -84,7 +151,38 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {() => <ChannelHeader channelId={channelId} page="home" />,[channelId],),+ !isWork,);+ const { reports } = useChannelReports(+ { kind: "channel", channelId },+ DEFAULT_CHANNEL_REPORTS_FILTERS,+ { enabled: isWork },+ );++ const pullRequests = useSpacePullRequests(isWork ? tasks : NO_TASKS);+ const activityView = useSpaceActivityViewStore((s) => s.view);+ const activityTypes = useSpaceActivityViewStore((s) => s.types);+ const activityFilters = useSpaceActivityViewStore((s) => s.filters);+ const activitySort = useSpaceActivityViewStore((s) => s.sort);+ const activityGrouping = useSpaceActivityViewStore((s) => s.grouping);+ const shownView = useDeferredValue(activityView);+ const shownTypes = useDeferredValue(activityTypes);+ const shownFilters = useDeferredValue(activityFilters);+ const shownSort = useDeferredValue(activitySort);+ const shownGrouping = useDeferredValue(activityGrouping);+ const activityPending =+ shownView !== activityView ||+ shownTypes !== activityTypes ||+ shownFilters !== activityFilters ||+ shownSort !== activitySort ||+ shownGrouping !== activityGrouping;+ const activitySources = useMemo(() => {+ const seen = new Set<string>();+ for (const task of tasks) {+ if (task.origin_product) seen.add(task.origin_product);+ }+ return [...seen].sort();+ }, [tasks]);const composerRef = useRef<ChannelHomeComposerHandle>(null);@@ -208,23 +306,28 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {// — including a chip's tab, which lands on the matching panel side there.const handleOpenThread = useCallback((task: Task, tab?: ThreadPanelTab) => {- if (spacesLayout) {+ if (spacesLayout && !isWork) {if (tab) openRightPanelSide(tab, task.id);handleOpenFull(task.id);return;}openThread(channelId, task.id, tab ? { tab } : undefined);},- [channelId, openThread, spacesLayout, handleOpenFull],+ [channelId, openThread, spacesLayout, isWork, handleOpenFull],+ );+ const handleOpenReport = useCallback(+ (reportId: string) => navigateToChannelReportDetail(channelId, reportId),+ [channelId],);+ const showsThreadDock =+ (!spacesLayout || isWork) &&+ !!threadTaskId &&+ threadTaskId !== inheritedThreadTaskId;const threadTask = threadTaskId? tasks.find((t) => t.id === threadTaskId): undefined;- // The Slack-style intro pinned at the feed's start — public channels only;- // the personal channel keeps the welcome empty state below.- const isPersonal = channel ? isPersonalChannel(channel) : false;const hasContextMd = (channelContext ?? "").trim().length > 0;// An in-flight build is spotted by its plan task in this channel's feed (by// title prefix — the only task↔context.md tie until the backend links them),@@ -249,7 +352,7 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {);const dismissIntro = useChannelIntroStore((s) => s.dismissIntro);const intro =- !isPersonal && !introDismissed && channelName && channel ? (+ !isWork && !isPersonal && !introDismissed && channelName && channel ? (<ChannelIntrochannel={channel}channelName={channelName}@@ -260,24 +363,46 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {) : undefined;const emptyState = (- <div className="mx-auto flex min-h-full w-full max-w-[680px] flex-col justify-center gap-6 px-4 py-10">- <div className="flex flex-col items-center gap-2 text-center">- <Heading className="font-bold text-2xl">+ <div+ className={cn(+ "flex w-full flex-col gap-6",+ isWork+ ? "max-w-[900px] pt-8 pb-10"+ : "mx-auto min-h-full max-w-[680px] justify-center px-4 py-10",+ )}+ >+ <div+ className={cn(+ "flex flex-col gap-2",+ isWork ? "items-start" : "items-center text-center",+ )}+ >+ <h2+ className={cn(+ "text-foreground",+ isWork ? "font-semibold text-lg" : "font-bold text-2xl",+ )}+ >{isPersonal? "Welcome to your own personal context": channelName? `Welcome to ${channelName}`: "Welcome"}- </Heading>- <Text>+ </h2>+ <p+ className={cn(+ "text-muted-foreground",+ isWork ? "max-w-[560px] text-[13px]" : "text-sm",+ )}+ >Contexts are for areas of work. Context.md is self-updating, so startsome work and the context file will update itself.- </Text>+ </p></div><div className="flex flex-col gap-2">- <Text size="1" weight="medium" className="px-1 text-(--gray-11)">+ <p className="px-1 font-medium text-[13px] text-muted-foreground">Suggestions- </Text>+ </p><div className="grid grid-cols-2 gap-2">{CHANNEL_TASK_SUGGESTIONS.map((suggestion) => (<SuggestedPromptCard@@ -319,20 +444,47 @@ export function WebsiteChannelHome({ channelId }: { channelId: string }) {}onOpenTask={handleOpenTask}onOpenThread={handleOpenThread}+ compact={isWork}+ rowStyle={isWork ? shownView : undefined}+ rebuilding={activityPending}+ onClearFilters={+ isWork+ ? () =>+ useSpaceActivityViewStore+ .getState()+ .setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)+ : undefined+ }+ canvases={isWork ? spaceCanvases : undefined}+ pullRequests={isWork ? pullRequests : undefined}+ types={isWork ? shownTypes : undefined}+ spaceItems={isWork ? spaceItems : undefined}+ me={isWork ? me : undefined}+ controls={+ isWork ? (+ <div className="mb-1 flex w-full items-center justify-end">+ <SpaceActivityControls sources={activitySources} />+ </div>+ ) : undefined+ }+ filters={isWork ? shownFilters : undefined}+ sort={isWork ? shownSort : undefined}+ grouping={isWork ? shownGrouping : undefined}+ reports={isWork ? reports : undefined}+ onOpenReport={isWork ? handleOpenReport : undefined}+ showKindFilter={!isWork}/></div>- {!spacesLayout &&- threadTaskId &&- threadTaskId !== inheritedThreadTaskId && (- <ThreadSidebar- taskId={threadTaskId}- channelId={channelId}- task={threadTask}- onClose={() => closeThread(channelId)}- onOpenFull={() => handleOpenFull(threadTaskId)}- />- )}+ {showsThreadDock ? (+ <ThreadSidebar+ taskId={threadTaskId}+ channelId={channelId}+ task={threadTask}+ onClose={() => closeThread(channelId)}+ onOpenFull={() => handleOpenFull(threadTaskId)}+ />+ ) : null}{channelName && (<CreateChannelModaldiff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.test.tsxindex 0df039ba041e..560c30976955 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.test.tsx@@ -23,6 +23,9 @@ const mocks = vi.hoisted(() => {};});+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({useChannels: () => ({channels: mocks.channels,diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.tsxindex a6351dbbf8ec..82ac35959fa6 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteChannelLoops.tsx@@ -2,6 +2,7 @@ import { CloudIcon, PlusIcon } from "@phosphor-icons/react";import { channelDisplayReference } from "@posthog/core/canvas/channelName";import { ChannelHeader } from "@posthog/ui/features/canvas/components/ChannelHeader";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";import { Button } from "@posthog/ui/primitives/Button";import {@@ -77,7 +78,7 @@ export function WebsiteChannelLoops({ channelId }: { channelId: string }) {}function ChannelLoopsLoading({ headerContent }: { headerContent: ReactNode }) {- useSetHeaderContent(headerContent);+ useSetHeaderContent(headerContent, !useWorkLayout());return (<div className="mx-auto w-full max-w-5xl px-8 py-8"><LoopsSkeleton />@@ -100,11 +101,13 @@ function SpaceAttachedLoops({? `You've reached the limit of ${limits.max} loops for this project. Delete one to add another.`: null;+ const workLayout = useWorkLayout();useSetHeaderContent(useMemo(() => <ChannelHeader channelId={channelId} page="loops" />,[channelId],),+ !workLayout,);const attachedLoops = useMemo(diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsxindex 2ae8945487a8..28a1d69390b5 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx@@ -1,6 +1,7 @@import { ChannelHeader } from "@posthog/ui/features/canvas/components/ChannelHeader";import { SpaceContextPage } from "@posthog/ui/features/canvas/components/context/SpaceContextPage";import { SpaceContextDocument } from "@posthog/ui/features/canvas/components/SpaceContextDocument";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";import { navigateToSpacesContext } from "@posthog/ui/router/navigationBridge";import { useMemo } from "react";@@ -10,11 +11,12 @@ interface WebsiteContextProps {}export function WebsiteContext({ channelId }: WebsiteContextProps) {+ const workLayout = useWorkLayout();const headerContent = useMemo(() => <ChannelHeader channelId={channelId} page="context" />,[channelId],);- useSetHeaderContent(headerContent);+ useSetHeaderContent(headerContent, !workLayout);return (<SpaceContextDocument channelId={channelId}>@@ -24,6 +26,7 @@ export function WebsiteContext({ channelId }: WebsiteContextProps) {channelName={channelName}store={store}wikiPath={wikiPath}+ hideTitle={workLayout}onOpenInWiki={wikiPath ? () => navigateToSpacesContext(wikiPath) : undefined}diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteDashboardsIndex.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteDashboardsIndex.tsxindex cf25a02cdaf3..6b7658b8c5a3 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteDashboardsIndex.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteDashboardsIndex.tsx@@ -1,4 +1,10 @@-import { DotsThreeIcon, LinkIcon, TrashIcon } from "@phosphor-icons/react";+import {+ DotsThreeIcon,+ LinkIcon,+ PushPinIcon,+ PushPinSlashIcon,+ TrashIcon,+} from "@phosphor-icons/react";import type { DashboardRecord } from "@posthog/core/canvas/dashboardSchemas";import {Badge,@@ -14,6 +20,11 @@ import {} from "@posthog/quill";import { formatRelativeTimeShort } from "@posthog/shared";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import { CanvasPreviewFrame } from "@posthog/ui/features/canvas/components/CanvasPreviewFrame";+import {+ ActivityPresenceAvatar,+ canvasAuthor,+} from "@posthog/ui/features/canvas/components/ChannelItemPresence";import { NewCanvasMenu } from "@posthog/ui/features/canvas/components/NewCanvasMenu";import { deleteCanvasWithUndo } from "@posthog/ui/features/canvas/deleteCanvasWithUndo";import { useCanvasTemplates } from "@posthog/ui/features/canvas/hooks/useCanvasTemplates";@@ -23,15 +34,23 @@ import {} from "@posthog/ui/features/canvas/hooks/useDashboards";import { useIsCanvasPendingDelete } from "@posthog/ui/features/canvas/stores/pendingCanvasDeleteStore";import { copyCanvasLink } from "@posthog/ui/features/canvas/utils/copyCanvasLink";+import { toast } from "@posthog/ui/primitives/toast";import { track } from "@posthog/ui/shell/analytics";-import { Box, Flex, Grid } from "@radix-ui/themes";+import { Box, Flex } from "@radix-ui/themes";import { Link } from "@tanstack/react-router";import { memo, useState } from "react";// A channel's dashboards index: a grid of cards, each showing a scaled-down// live preview. Clicking a card opens the full dashboard.-export function WebsiteDashboardsIndex({ channelId }: { channelId: string }) {+export function WebsiteDashboardsIndex({+ channelId,+ variant = "page",+}: {+ channelId: string;+ variant?: "page" | "work";+}) {const { dashboards, isLoading } = useDashboards(channelId);+ const isWork = variant === "work";// templateId -> display name, for the per-card badge ("Freeform (React)", …).// Falls back to the raw id for any template not in the registry.@@ -63,20 +82,72 @@ export function WebsiteDashboardsIndex({ channelId }: { channelId: string }) {);}+ const card = (d: DashboardRecord) => (+ <DashboardCard+ key={d.id}+ channelId={channelId}+ summary={d}+ templateLabel={templateLabels.get(d.templateId) ?? d.templateId}+ canPin={isWork}+ compactMeta={isWork}+ />+ );++ if (!isWork) {+ return (+ <div className="scroll-mask-4 h-full overflow-auto bg-gray-1">+ <div className="p-5">+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">+ {dashboards.map(card)}+ </div>+ </div>+ </div>+ );+ }++ const pinned = dashboards+ .filter((d) => d.pinnedAt != null)+ .sort((a, b) => (b.pinnedAt ?? 0) - (a.pinnedAt ?? 0));+ const rest = dashboards.filter((d) => d.pinnedAt == null);+ const countLabel =+ dashboards.length === 1 ? "1 canvas" : `${dashboards.length} canvases`;+return (<div className="scroll-mask-4 h-full overflow-auto bg-gray-1">- <Box className="p-5">- <Grid columns={{ initial: "1", sm: "2", md: "3" }} gap="4">- {dashboards.map((d) => (- <DashboardCard- key={d.id}- channelId={channelId}- summary={d}- templateLabel={templateLabels.get(d.templateId) ?? d.templateId}- />- ))}- </Grid>- </Box>+ <div className="px-6 py-5">+ <div className="mb-3 flex items-center justify-between">+ <Text size="xs" variant="muted">+ {countLabel}+ </Text>+ <NewCanvasMenu channelId={channelId} />+ </div>+ {pinned.length > 0 && (+ <>+ <Text+ size="xxs"+ variant="muted"+ className="mb-2 block font-medium uppercase tracking-wider"+ >+ Pinned+ </Text>+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">+ {pinned.map(card)}+ </div>+ {rest.length > 0 && (+ <Text+ size="xxs"+ variant="muted"+ className="mt-5 mb-2 block font-medium uppercase tracking-wider"+ >+ All+ </Text>+ )}+ </>+ )}+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">+ {rest.map(card)}+ </div>+ </div></div>);}@@ -85,10 +156,14 @@ const DashboardCard = memo(function DashboardCard({channelId,summary,templateLabel,+ canPin = false,+ compactMeta = false,}: {channelId: string;summary: DashboardRecord;templateLabel: string;+ canPin?: boolean;+ compactMeta?: boolean;}) {// Inside its delete-undo window the card stays in the grid (Undo puts it// straight back) but is dimmed and inert.@@ -115,22 +190,37 @@ const DashboardCard = memo(function DashboardCard({}><Card className="gap-0 overflow-hidden p-0">- <PreviewFrame />- <CardContent className="flex flex-col gap-0.5 p-3">- <Flex align="center" justify="between" gap="2">- <Text size="sm" weight="medium" className="truncate">+ <PreviewFrame dashboardId={summary.id} />+ <CardContent className="flex flex-col gap-1 p-3">+ <div className="flex items-center justify-between gap-2">+ <Text size="sm" weight="medium" className="min-w-0 truncate">{summary.name}</Text>- <Badge>{templateLabel}</Badge>- </Flex>- <Text size="xxs" variant="muted">- Updated {formatRelativeTimeShort(summary.updatedAt)}- </Text>- <Text size="xxs" variant="muted">- Created by{" "}- {summary.createdBy ? `${summary.createdBy}` : "Unknown"}- </Text>+ <ActivityPresenceAvatar+ user={canvasAuthor(summary)}+ label="on this canvas"+ activityAt={summary.updatedAt}+ />+ {!compactMeta && <Badge>{templateLabel}</Badge>}+ </div>+ {compactMeta ? (+ <Text size="xxs" variant="muted" className="truncate">+ {templateLabel} · updated{" "}+ {formatRelativeTimeShort(summary.updatedAt)}+ {summary.createdBy ? ` · ${summary.createdBy}` : ""}+ </Text>+ ) : (+ <>+ <Text size="xxs" variant="muted">+ Updated {formatRelativeTimeShort(summary.updatedAt)}+ </Text>+ <Text size="xxs" variant="muted">+ Created by{" "}+ {summary.createdBy ? `${summary.createdBy}` : "Unknown"}+ </Text>+ </>+ )}</CardContent></Card></Link>@@ -140,19 +230,17 @@ const DashboardCard = memo(function DashboardCard({id={summary.id}name={summary.name}channelId={channelId}+ pinned={canPin ? summary.pinnedAt != null : undefined}/></Box>);});-// The card's preview frame. Canvas records no longer carry source code — the-// rendered output is the published build's artifact, wired up separately — so-// the grid shows a stable placeholder frame instead of a live per-card render.-function PreviewFrame() {+function PreviewFrame({ dashboardId }: { dashboardId: string }) {return (- <Box className="relative h-44 overflow-hidden border-border border-b bg-muted">- <PreviewPlaceholder label="Canvas preview" />- </Box>+ <div className="relative h-44 overflow-hidden border-border border-b bg-muted">+ <CanvasPreviewFrame dashboardId={dashboardId} className="h-full w-full" />+ </div>);}@@ -160,13 +248,21 @@ function DashboardCardMenu({id,name,channelId,+ pinned,}: {id: string;name: string;channelId: string;+ pinned?: boolean;}) {const [open, setOpen] = useState(false);- const { invalidateDashboards } = useDashboardMutations();+ const { invalidateDashboards, setPinned } = useDashboardMutations();++ const onTogglePin = () => {+ setPinned(id, !pinned).catch(() => {+ toast.error("Couldn't update pin");+ });+ };const onDelete = () => {deleteCanvasWithUndo({@@ -206,6 +302,16 @@ function DashboardCardMenu({<LinkIcon size={14} />Copy link</DropdownMenuItem>+ {pinned !== undefined && (+ <DropdownMenuItem onClick={onTogglePin}>+ {pinned ? (+ <PushPinSlashIcon size={14} />+ ) : (+ <PushPinIcon size={14} />+ )}+ {pinned ? "Unpin" : "Pin"}+ </DropdownMenuItem>+ )}<DropdownMenuItem variant="destructive" onClick={onDelete}><TrashIcon size={14} />Delete@@ -215,17 +321,3 @@ function DashboardCardMenu({</Box>);}--function PreviewPlaceholder({ label }: { label: string }) {- return (- <Flex- align="center"- justify="center"- className="absolute inset-0 text-center"- >- <Text size="xs" variant="muted">- {label}- </Text>- </Flex>- );-}diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.test.ts b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.test.tsindex e805652bdd02..5b5949b66786 100644--- a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.test.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.test.ts@@ -1,73 +1,62 @@-import type { SignalReport, Task } from "@posthog/shared/domain-types";-import type { ChannelFeedSystemMessage } from "@posthog/ui/features/canvas/hooks/useChannelFeedMessages";import { describe, expect, it } from "vitest";-import {- feedEntryMatchesKind,- mergeFeedEntries,- stripContextBlocks,-} from "./channelFeedDisplay";+import { buildFeedSections, type FeedEntry } from "./channelFeedDisplay";-function task(id: string, createdAt: string): Task {- return { id, created_at: createdAt } as Task;+function task(id: string, repository: string | null): FeedEntry {+ return {+ kind: "task",+ id,+ createdAt: "2026-09-18T10:00:00Z",+ task: { id, repository } as FeedEntry extends { task: infer T } ? T : never,+ } as FeedEntry;}-function report(id: string, createdAt: string): SignalReport {- return { id, created_at: createdAt } as SignalReport;-}--function system(id: string, createdAt: string): ChannelFeedSystemMessage {- return { id, createdAt } as ChannelFeedSystemMessage;-}--describe("channelFeedDisplay", () => {- it("interleaves reports with tasks and system rows newest-first", () => {- const entries = mergeFeedEntries(- [task("t1", "2026-01-02T00:00:00Z")],- [system("s1", "2026-01-01T00:00:00Z")],- [report("r1", "2026-01-03T00:00:00Z")],+describe("buildFeedSections", () => {+ it("gives a group one section however often the list returns to it", () => {+ const sections = buildFeedSections(+ [+ task("a", "posthog/posthog"),+ task("b", null),+ task("c", "posthog/posthog"),+ task("d", "posthog/charts"),+ task("e", null),+ ],+ {+ labelOf: (entry) =>+ entry.kind === "task"+ ? (entry.task.repository ?? "No repository")+ : "No repository",+ },);- expect(entries.map((e) => e.id)).toEqual(["r1", "t1", "s1"]);- });- it("keeps a tied task above its announcement with reports present", () => {- const entries = mergeFeedEntries(- [task("t1", "2026-01-01T00:00:00Z")],- [system("s1", "2026-01-01T00:00:00Z")],- [report("r1", "2026-01-01T00:00:00Z")],- );- expect(entries[0].id).toBe("t1");+ expect(sections.map((s) => s.label)).toEqual([+ "posthog/posthog",+ "No repository",+ "posthog/charts",+ ]);+ expect(sections[0].entries.map((e) => e.id)).toEqual(["a", "c"]);+ expect(sections[1].entries.map((e) => e.id)).toEqual(["b", "e"]);});- it.each([- ["all", ["task", "report", "system"]],- ["sessions", ["task", "system"]],- ["reports", ["report"]],- ] as const)("kind filter %s keeps only %j", (filter, expectedKinds) => {- const entries = mergeFeedEntries(- [task("t1", "2026-01-03T00:00:00Z")],- [system("s1", "2026-01-01T00:00:00Z")],- [report("r1", "2026-01-02T00:00:00Z")],+ it("keeps sections apart when a key separates two equal labels", () => {+ const sections = buildFeedSections(+ [task("a", null), task("b", null), task("c", null)],+ {+ labelOf: () => "SEP 18",+ keyOf: (entry) => (entry.id === "b" ? "y" : "x"),+ },);- const kept = entries- .filter((entry) => feedEntryMatchesKind(entry, filter))- .map((entry) => entry.kind);- expect(kept).toEqual(expectedKinds);++ expect(sections.map((s) => s.key)).toEqual(["x", "y"]);+ expect(sections[0].entries.map((e) => e.id)).toEqual(["a", "c"]);});- it.each([- {- name: "a channel context block",- text: '<channel_context channel="growth">body</channel_context>\n\nfix the bug',- },- {- name: "PostHog app context blocks",- text: "<posthog_trusted_context>\n- act with tools\n</posthog_trusted_context>\n<posthog_untrusted_context>\n- dashboard 1\n</posthog_untrusted_context>\n\nfix the bug",- },- {- name: "a truncated channel context block",- text: 'fix the bug\n<channel_context channel="growth">\nprivate context',- },- ])("strips $name from the feed text", ({ text }) => {- expect(stripContextBlocks(text)).toBe("fix the bug");+ it("runs an unlabelled list together as one section", () => {+ const sections = buildFeedSections([task("a", null), task("b", null)], {+ labelOf: () => null,+ });++ expect(sections).toHaveLength(1);+ expect(sections[0].label).toBeNull();+ expect(sections[0].entries).toHaveLength(2);});});diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.tsindex c88b9ead7fb4..459c9c8c4057 100644--- a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts@@ -1,5 +1,7 @@+import type { DashboardRecord } from "@posthog/core/canvas/dashboardSchemas";import { stripInjectedBlocks } from "@posthog/core/editor/injectedBlocks";import type { SignalReport, Task } from "@posthog/shared/domain-types";+import type { SpacePullRequest } from "@posthog/ui/features/canvas/components/work/useSpacePullRequests";import type { ChannelFeedSystemMessage } from "@posthog/ui/features/canvas/hooks/useChannelFeedMessages";const incompleteContextBlock =@@ -16,7 +18,19 @@ export function stripContextBlocks(text: string): string {// tagged with the timestamp used to interleave them.export type FeedEntry =| { kind: "task"; id: string; createdAt: string; task: Task }+ | {+ kind: "canvas";+ id: string;+ createdAt: string;+ canvas: DashboardRecord;+ }| { kind: "report"; id: string; createdAt: string; report: SignalReport }+ | {+ kind: "pr";+ id: string;+ createdAt: string;+ pullRequest: SpacePullRequest;+ }| {kind: "system";id: string;@@ -27,6 +41,40 @@ export type FeedEntry =/** Which entry kinds the feed shows. Sessions cover tasks and their system rows. */export type FeedKindFilter = "all" | "sessions" | "reports";+export type SpaceActivityType = "task" | "canvas" | "report" | "pr";++export const ALL_SPACE_ACTIVITY_TYPES: readonly SpaceActivityType[] = [+ "task",+ "canvas",+ "report",+ "pr",+];++export function feedEntryMatchesTypes(+ entry: FeedEntry,+ types: readonly SpaceActivityType[],+): boolean {+ if (entry.kind === "system") return types.includes("task");+ return types.includes(entry.kind);+}++export function entryKey(entry: FeedEntry): string | null {+ if (entry.kind === "task") return `task:${entry.task.id}`;+ if (entry.kind === "canvas") return `canvas:${entry.canvas.id}`;+ return null;+}++export function keepFilteredEntries(+ entries: readonly FeedEntry[],+ allowedKeys: ReadonlySet<string> | null,+): readonly FeedEntry[] {+ if (!allowedKeys) return entries;+ return entries.filter((entry) => {+ const key = entryKey(entry);+ return key === null || allowedKeys.has(key);+ });+}+export function feedEntryMatchesKind(entry: FeedEntry,filter: FeedKindFilter,@@ -45,6 +93,8 @@ export function mergeFeedEntries(tasks: Task[],systemMessages: ChannelFeedSystemMessage[],reports: SignalReport[] = [],+ canvases: readonly DashboardRecord[] = [],+ pullRequests: readonly SpacePullRequest[] = [],): FeedEntry[] {const merged: FeedEntry[] = [...tasks.map((task) => ({@@ -59,6 +109,18 @@ export function mergeFeedEntries(createdAt: report.created_at,report,})),+ ...canvases.map((canvas) => ({+ kind: "canvas" as const,+ id: `canvas:${canvas.id}`,+ createdAt: new Date(canvas.createdAt).toISOString(),+ canvas,+ })),+ ...pullRequests.map((pullRequest) => ({+ kind: "pr" as const,+ id: `pr:${pullRequest.url}`,+ createdAt: pullRequest.task.updated_at,+ pullRequest,+ })),...systemMessages.map((message) => ({kind: "system" as const,id: message.id,@@ -79,3 +141,46 @@ export function mergeFeedEntries();return merged;}++export interface FeedSection {+ key: string;+ label: string | null;+ entries: FeedEntry[];+}++export function buildFeedSections(+ entries: readonly FeedEntry[],+ {+ labelOf,+ keyOf,+ }: {+ labelOf: (entry: FeedEntry) => string | null;+ keyOf?: (entry: FeedEntry) => string;+ },+): FeedSection[] {+ const sections: FeedSection[] = [];+ const byKey = new Map<string, FeedSection>();+ for (const entry of entries) {+ const label = labelOf(entry);+ if (label === null) {+ const open = sections[0];+ if (open && open.label === null) {+ open.entries.push(entry);+ continue;+ }+ const section = { key: "all", label: null, entries: [entry] };+ sections.push(section);+ continue;+ }+ const key = keyOf ? keyOf(entry) : label;+ const open = byKey.get(key);+ if (open) {+ open.entries.push(entry);+ continue;+ }+ const section = { key, label, entries: [entry] };+ byKey.set(key, section);+ sections.push(section);+ }+ return sections;+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelFeedEntries.test.ts b/products/desktop/packages/ui/src/features/canvas/components/channelFeedEntries.test.tsnew file mode 100644index 000000000000..7bee1cd50f14--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/channelFeedEntries.test.ts@@ -0,0 +1,95 @@+import { describe, expect, it } from "vitest";+import {+ type FeedEntry,+ feedEntryMatchesTypes,+ keepFilteredEntries,+ mergeFeedEntries,+} from "./channelFeedDisplay";++function task(id: string): FeedEntry {+ return {+ kind: "task",+ id,+ createdAt: "2026-09-18T10:00:00Z",+ task: { id },+ } as unknown as FeedEntry;+}++function report(id: string): FeedEntry {+ return {+ kind: "report",+ id,+ createdAt: "2026-09-18T10:00:00Z",+ report: { id, title: "A report" },+ } as unknown as FeedEntry;+}++describe("keepFilteredEntries", () => {+ it("returns every entry when no filter is applied", () => {+ const entries = [task("a"), report("r")];+ expect(keepFilteredEntries(entries, null)).toBe(entries);+ });++ it("keeps a report that no filter can speak for", () => {+ const kept = keepFilteredEntries(+ [task("a"), task("b"), report("r")],+ new Set(["task:a"]),+ );+ expect(kept.map((entry) => entry.kind)).toEqual(["task", "report"]);+ });++ it("drops a session the filter excludes", () => {+ const kept = keepFilteredEntries(+ [task("a"), task("b")],+ new Set(["task:b"]),+ );+ expect(kept).toHaveLength(1);+ expect(kept[0]).toMatchObject({ kind: "task", id: "b" });+ });+});++describe("mergeFeedEntries", () => {+ it("dates a pull request by the session that opened it", () => {+ const older = {+ id: "t1",+ title: "Older",+ created_at: "2026-09-16T10:00:00Z",+ updated_at: "2026-09-16T12:00:00Z",+ };+ const newer = {+ id: "t2",+ title: "Newer",+ created_at: "2026-09-18T10:00:00Z",+ updated_at: "2026-09-18T12:00:00Z",+ };+ const merged = mergeFeedEntries(+ [older, newer] as never,+ [],+ [],+ [],+ [+ { url: "https://github.com/a/b/pull/1", task: older } as never,+ { url: "https://github.com/a/b/pull/2", task: newer } as never,+ ],+ );+ expect(merged.map((entry) => entry.id)).toEqual([+ "pr:https://github.com/a/b/pull/2",+ "t2",+ "pr:https://github.com/a/b/pull/1",+ "t1",+ ]);+ });+});++describe("feedEntryMatchesTypes", () => {+ it("keeps a system row with the sessions it reports on", () => {+ const system = { kind: "system" } as unknown as FeedEntry;+ expect(feedEntryMatchesTypes(system, ["task"])).toBe(true);+ expect(feedEntryMatchesTypes(system, ["canvas", "pr"])).toBe(false);+ });++ it("drops a kind its segment turned off", () => {+ expect(feedEntryMatchesTypes(report("r"), ["task", "pr"])).toBe(false);+ expect(feedEntryMatchesTypes(report("r"), ["report"])).toBe(true);+ });+});diff --git a/products/desktop/packages/ui/src/features/canvas/components/context/SpaceContextPage.tsx b/products/desktop/packages/ui/src/features/canvas/components/context/SpaceContextPage.tsxindex d7d9cf290be5..d17261aa8c95 100644--- a/products/desktop/packages/ui/src/features/canvas/components/context/SpaceContextPage.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/context/SpaceContextPage.tsx@@ -37,12 +37,14 @@ import { KnowledgeList } from "./KnowledgeList";import { MarkdownFileDialog } from "./MarkdownFileDialog";const COLUMN = "mx-auto w-full max-w-[1100px] px-8";+const TAB_COLUMN = "w-full px-6";interface SpaceContextPageProps {channelId: string;channelName: string;store: ContextDocumentStore;wikiPath: string | null;+ hideTitle?: boolean;onOpenInWiki?: () => void;}@@ -51,6 +53,7 @@ export function SpaceContextPage({channelName,store,wikiPath,+ hideTitle = false,onOpenInWiki,}: SpaceContextPageProps) {const [agentOpen, setAgentOpen] = useState(false);@@ -120,50 +123,10 @@ export function SpaceContextPage({);};- return (- <div className="flex h-full flex-col overflow-hidden">- <PageHeader className="px-0">- <div className={COLUMN}>- <PageHeaderHeading>- <PageHeaderTitleRow>- <PageHeaderTitle>Context</PageHeaderTitle>- {store.isRefreshing || store.isSaving ? (- <Spinner size="xs" aria-hidden="true" />- ) : null}- <PageHeaderActions>- {onOpenInWiki ? (- <Button variant="outline" size="sm" onClick={onOpenInWiki}>- <ArrowSquareOutIcon size={14} />- Open in wiki- </Button>- ) : null}- {!isBlank ? (- <Button- variant="outline"- size="sm"- onClick={() => setAgentOpen(true)}- >- <SparkleIcon size={14} />- Update with agent- </Button>- ) : null}- </PageHeaderActions>- </PageHeaderTitleRow>- <PageHeaderDescription>- {isBlank- ? "Every agent working in this space reads this first."- : null}- {!isBlank && store.updatedAt ? (- <>- Updated <RelativeTimestamp timestamp={store.updatedAt} />- </>- ) : null}- </PageHeaderDescription>- </PageHeaderHeading>- </div>- </PageHeader>-+ const body = (+ <>{store.isLoading ? <LoadingState className="flex-1" /> : null}+{store.error ? (<div className="flex flex-1 flex-col items-center justify-center gap-2 px-6"><Text size="xs" variant="muted">@@ -176,7 +139,13 @@ export function SpaceContextPage({) : null}{ready ? (<div className="min-h-0 flex-1 overflow-y-auto">- <div className={cn(COLUMN, "flex flex-col gap-6 pt-10 pb-24")}>+ <div+ className={cn(+ hideTitle ? TAB_COLUMN : COLUMN,+ "flex flex-col gap-6",+ hideTitle ? "pt-6 pb-24" : "pt-10 pb-24",+ )}+ >{store.saveError ? (<div className="flex items-center justify-between gap-3 border-border border-y py-2.5"><Text size="xs" className="text-warning-foreground">@@ -246,6 +215,71 @@ export function SpaceContextPage({onClose={() => setEditingContextFile(false)}/>) : null}+ </>+ );++ const purpose = isBlank ? (+ "Every agent working in this space reads this first."+ ) : store.updatedAt ? (+ <>+ Updated <RelativeTimestamp timestamp={store.updatedAt} />+ </>+ ) : null;+ const actions = (+ <>+ {onOpenInWiki ? (+ <Button variant="outline" size="sm" onClick={onOpenInWiki}>+ <ArrowSquareOutIcon size={14} />+ Open in wiki+ </Button>+ ) : null}+ {!isBlank ? (+ <Button variant="outline" size="sm" onClick={() => setAgentOpen(true)}>+ <SparkleIcon size={14} />+ Update with agent+ </Button>+ ) : null}+ </>+ );++ if (hideTitle) {+ return (+ <div className="flex h-full flex-col overflow-hidden">+ <div className="shrink-0 border-border border-b">+ <div className="flex h-11 w-full items-center gap-2 px-6">+ <Text size="xs" variant="muted" className="min-w-0 truncate">+ {purpose}+ </Text>+ {store.isRefreshing || store.isSaving ? (+ <Spinner size="xs" aria-hidden="true" />+ ) : null}+ <div className="ml-auto flex shrink-0 items-center gap-2">+ {actions}+ </div>+ </div>+ </div>+ {body}+ </div>+ );+ }++ return (+ <div className="flex h-full flex-col overflow-hidden">+ <PageHeader className="px-0">+ <div className={COLUMN}>+ <PageHeaderHeading>+ <PageHeaderTitleRow>+ <PageHeaderTitle>Context</PageHeaderTitle>+ {store.isRefreshing || store.isSaving ? (+ <Spinner size="xs" aria-hidden="true" />+ ) : null}+ <PageHeaderActions>{actions}</PageHeaderActions>+ </PageHeaderTitleRow>+ <PageHeaderDescription>{purpose}</PageHeaderDescription>+ </PageHeaderHeading>+ </div>+ </PageHeader>+ {body}</div>);}diff --git a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.tsindex c1dc0cda63e2..d900b6ee1325 100644--- a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts@@ -1,6 +1,7 @@import {BellIcon,BookOpenTextIcon,+ ChatsCircleIcon,EnvelopeSimple,HouseSimple,type IconProps,@@ -15,6 +16,7 @@ import { SpacesIcon } from "@posthog/ui/features/canvas/components/SpacesIcon";import {isRestorableVisitHref,type NavRailPane,+ railPaneFoldsIntoWork,} from "@posthog/ui/features/canvas/railPane";import {applyTabViewState,@@ -260,3 +262,30 @@ export function visibleRailDestinations(): readonly RailDestination[] {return RAIL_DESTINATIONS.filter(({ enabled }) => enabled?.(flags) ?? true);}++export function showWorkColumn(): void {+ useSidebarStore.getState().setOpen(true);+}++const WORK_DESTINATION: RailDestination = {+ pane: "spaces",+ label: "Work",+ analyticsId: "spaces",+ Icon: ChatsCircleIcon,+ href: "/spaces",+ onPick: () => {+ showWorkColumn();+ navigateToSpaces();+ },+ onReclick: showWorkColumn,+};++export function visibleWorkRailDestinations(+ flags: RailFlags,+): readonly RailDestination[] {+ const rest = RAIL_DESTINATIONS.filter(+ ({ enabled, pane }) =>+ !railPaneFoldsIntoWork(pane) && (enabled?.(flags) ?? true),+ );+ return [WORK_DESTINATION, ...rest];+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/NewSessionHeading.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/NewSessionHeading.tsxnew file mode 100644index 000000000000..70497672fc1e--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/NewSessionHeading.tsx@@ -0,0 +1,27 @@+import { SpaceSelect } from "@posthog/ui/features/canvas/components/SpaceSelect";++export function NewSessionHeading({+ channelId,+ onChangeSpace,+ disabled = false,+}: {+ channelId: string | null;+ onChangeSpace: (channelId: string) => void;+ disabled?: boolean;+}) {+ return (+ <div className="mb-5 flex flex-col font-semibold text-[26px] leading-tight tracking-tight">+ <span>Start a new session</span>+ <span className="flex min-w-0 flex-wrap items-baseline gap-x-2 text-muted-foreground">+ in+ <SpaceSelect+ variant="headline"+ value={channelId ?? ""}+ onChange={onChangeSpace}+ disabled={disabled}+ />+ {channelId ? "space" : null}+ </span>+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/PrFeedRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/PrFeedRow.tsxnew file mode 100644index 000000000000..bae3eadd100b--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/PrFeedRow.tsx@@ -0,0 +1,136 @@+import {+ getPrVisualConfig,+ parsePrNumber,+ summarizePrChecks,+} from "@posthog/core/git-interaction/prStatus";+import { taskStarter } from "@posthog/core/tasks/taskStatusPresentation";+import { Badge, Card, CardContent } from "@posthog/quill";+import { formatRelativeTimeShort } from "@posthog/shared";+import { ActivityPresenceAvatar } from "@posthog/ui/features/canvas/components/ChannelItemPresence";+import type { SpacePullRequest } from "@posthog/ui/features/canvas/components/work/useSpacePullRequests";+import { getPrVisualIcon } from "@posthog/ui/features/git-interaction/prIcon";+import { usePrChecks } from "@posthog/ui/features/pr-review/usePrChecks";+import { openExternalUrl } from "@posthog/ui/shell/openExternal";++function CiDot({ ci }: { ci: { label: string; color: string } }) {+ return (+ <span+ role="img"+ aria-label={ci.label}+ className="size-1.5 shrink-0 rounded-full"+ style={{ backgroundColor: ci.color }}+ />+ );+}++export function PrFeedRow({+ pullRequest,+ listRow,+}: {+ pullRequest: SpacePullRequest;+ listRow: boolean;+}) {+ const { url, task, details, title } = pullRequest;+ const live = !!details && !details.merged && details.state !== "closed";+ const checks = usePrChecks(live ? url : null);+ const ci = summarizePrChecks(checks.data);+ const config = getPrVisualConfig(+ details?.state ?? "open",+ details?.merged ?? false,+ details?.draft ?? false,+ );+ const Icon = getPrVisualIcon(config.icon);+ const prNumber = parsePrNumber(url);+ const settled = details !== undefined;+ const label = title ?? task.title;+ const number = prNumber ? `#${prNumber}` : "PR";+ const starter = taskStarter(task);+ const open = () => openExternalUrl(url);+ const icon = (+ <Icon+ size={listRow ? 13 : 14}+ style={settled ? { color: `var(--${config.color}-9)` } : undefined}+ className={settled ? undefined : "opacity-50"}+ aria-hidden+ />+ );++ if (!listRow) {+ return (+ <Card+ size="sm"+ role="button"+ tabIndex={0}+ className="my-1.5 w-full cursor-pointer rounded-xl bg-(--gray-2) py-0 transition-colors hover:border-(--gray-7) hover:bg-(--gray-3)"+ onClick={open}+ onKeyDown={(event) => {+ if (event.target !== event.currentTarget) return;+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ open();+ }+ }}+ >+ <CardContent className="flex flex-col px-4 pt-3.5 pb-3">+ <div className="flex items-center gap-3">+ <div className="flex min-w-0 flex-1 items-baseline gap-1.5">+ <span className="flex size-3.5 shrink-0 translate-y-0.5 items-center justify-center">+ {icon}+ </span>+ <span className="shrink-0 text-muted-foreground text-xs tabular-nums">+ {number}+ </span>+ <span className="min-w-0 truncate font-semibold text-sm">+ {label}+ </span>+ <span className="shrink-0 text-muted-foreground text-xs tabular-nums">+ · {formatRelativeTimeShort(task.updated_at)}+ </span>+ </div>+ <Badge>{config.label}</Badge>+ </div>+ <p className="mt-1 line-clamp-1 text-(--gray-11) text-[13px]">+ {task.repository ? `${task.repository} · ` : ""}+ {task.title}+ </p>+ <div className="mt-3 flex items-center justify-end gap-2">+ {ci && <CiDot ci={ci} />}+ {starter && (+ <ActivityPresenceAvatar+ user={starter}+ label="on this pull request"+ activityAt={task.updated_at}+ />+ )}+ </div>+ </CardContent>+ </Card>+ );+ }++ return (+ <button+ type="button"+ onClick={open}+ title={label}+ className="group relative flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] transition-colors hover:bg-fill-selected"+ >+ <span className="flex size-3.5 shrink-0 items-center justify-center">+ {icon}+ </span>+ <span className="shrink-0 text-muted-foreground text-xs tabular-nums">+ {number}+ </span>+ <span className="min-w-0 flex-1 truncate font-medium">{label}</span>+ {ci && <CiDot ci={ci} />}+ <ActivityPresenceAvatar+ user={starter}+ label="on this pull request"+ activityAt={task.updated_at}+ />+ <span className="w-8 shrink-0 text-right text-muted-foreground text-xs tabular-nums">+ {formatRelativeTimeShort(task.updated_at)}+ </span>+ </button>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/SpaceActivityControls.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/SpaceActivityControls.tsxnew file mode 100644index 000000000000..1b2e1a43f800--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/SpaceActivityControls.tsx@@ -0,0 +1,110 @@+import { CardsThreeIcon, ListIcon } from "@phosphor-icons/react";+import {+ DEFAULT_CHANNEL_ITEM_FILTERS,+ hasActiveChannelItemFilters,+} from "@posthog/core/canvas/channelItems";+import {+ ToggleGroup,+ ToggleGroupItem,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from "@posthog/quill";+import { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";+import type { SpaceActivityType } from "@posthog/ui/features/canvas/components/channelFeedDisplay";+import {+ type SpaceActivityView,+ useSpaceActivityViewStore,+} from "@posthog/ui/features/canvas/stores/spaceActivityViewStore";++const GROUPINGS = ["date", "repository"] as const;++const TYPES: { value: SpaceActivityType; label: string }[] = [+ { value: "task", label: "Tasks" },+ { value: "canvas", label: "Canvases" },+ { value: "report", label: "Reports" },+ { value: "pr", label: "PRs" },+];++const VIEWS: {+ value: SpaceActivityView;+ label: string;+ Icon: typeof ListIcon;+}[] = [+ { value: "list", label: "List", Icon: ListIcon },+ { value: "cards", label: "Cards", Icon: CardsThreeIcon },+];++export function SpaceActivityControls({+ sources,+}: {+ sources: readonly string[];+}) {+ const types = useSpaceActivityViewStore((s) => s.types);+ const setTypes = useSpaceActivityViewStore((s) => s.setTypes);+ const view = useSpaceActivityViewStore((s) => s.view);+ const setView = useSpaceActivityViewStore((s) => s.setView);+ const filters = useSpaceActivityViewStore((s) => s.filters);+ const setFilters = useSpaceActivityViewStore((s) => s.setFilters);+ const sort = useSpaceActivityViewStore((s) => s.sort);+ const setSort = useSpaceActivityViewStore((s) => s.setSort);+ const grouping = useSpaceActivityViewStore((s) => s.grouping);+ const setGrouping = useSpaceActivityViewStore((s) => s.setGrouping);++ return (+ <div className="flex items-center gap-1">+ <ToggleGroup+ multiple+ value={types}+ onValueChange={(next) => setTypes(next as SpaceActivityType[])}+ aria-label="Types shown"+ >+ {TYPES.map(({ value, label }) => (+ <ToggleGroupItem key={value} value={value} size="sm">+ {label}+ </ToggleGroupItem>+ ))}+ </ToggleGroup>+ <ToggleGroup+ value={[view]}+ onValueChange={(next) => {+ const picked = next[0];+ if (picked === "list" || picked === "cards") setView(picked);+ }}+ >+ {VIEWS.map(({ value, label, Icon }) => (+ <Tooltip key={value}>+ <TooltipTrigger+ render={+ <ToggleGroupItem+ value={value}+ size="sm"+ aria-label={`${label} view`}+ >+ <Icon size={14} />+ </ToggleGroupItem>+ }+ />+ <TooltipContent side="top">{label}</TooltipContent>+ </Tooltip>+ ))}+ </ToggleGroup>+ <ChannelFilterMenu+ filters={filters}+ onFilterChange={(key, value) =>+ setFilters({ ...filters, [key]: value })+ }+ onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}+ sort={sort}+ onSortChange={setSort}+ grouping={grouping}+ onGroupingChange={setGrouping}+ groupings={GROUPINGS}+ sources={sources}+ showCreatedBy+ showRunFilters+ active={hasActiveChannelItemFilters(filters)}+ />+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/SpaceTabbedPage.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/SpaceTabbedPage.tsxnew file mode 100644index 000000000000..2f0bd6d03776--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/SpaceTabbedPage.tsx@@ -0,0 +1,170 @@+import { StarIcon } from "@phosphor-icons/react";+import {+ Button,+ cn,+ Skeleton,+ Tabs,+ TabsList,+ TabsTrigger,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from "@posthog/quill";+import { LOOPS_FLAG } from "@posthog/shared";+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";+import { useChannelStarToggle } from "@posthog/ui/features/canvas/hooks/useChannelStars";+import {+ type Channel,+ useChannels,+} from "@posthog/ui/features/canvas/hooks/useChannels";+import { useMarkChannelSeen } from "@posthog/ui/features/canvas/hooks/useMarkChannelSeen";+import {+ useChannelContextWikiPage,+ useContextWikiPage,+} from "@posthog/ui/features/context-wiki/hooks/useContextWiki";+import { useContextLayerFlag } from "@posthog/ui/features/feature-flags/useContextLayerFlag";+import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";+import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";+import { track } from "@posthog/ui/shell/analytics";+import { useNavigate, useRouter } from "@tanstack/react-router";+import { type ReactNode, useEffect, useMemo } from "react";++export type SpaceTab =+ | "context"+ | "activity"+ | "canvases"+ | "loops"+ | "settings";++const TABS: readonly { key: SpaceTab; label: string; segment: string }[] = [+ { key: "activity", label: "Activity", segment: "" },+ { key: "context", label: "Context", segment: "/context" },+ { key: "canvases", label: "Canvases", segment: "/canvases" },+ { key: "loops", label: "Loops", segment: "/loops" },+ { key: "settings", label: "Settings", segment: "/settings" },+];++function SpaceStar({ channel }: { channel: Channel }) {+ const { isStarred, toggleStar } = useChannelStarToggle(channel);+ const label = isStarred ? "Unstar space" : "Star space";+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ variant="default"+ size="icon-sm"+ aria-label={label}+ className={cn(+ "text-muted-foreground",+ isStarred && "text-foreground",+ )}+ onClick={() => {+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: isStarred ? "unstar" : "star",+ surface: "sidebar",+ channel_id: channel.id,+ });+ toggleStar();+ }}+ >+ <StarIcon size={14} weight={isStarred ? "fill" : "regular"} />+ </Button>+ }+ />+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ );+}++export const SPACE_TAB_INSET = "px-6";++export function SpaceTabbedPage({+ channelId,+ tab,+ children,+}: {+ channelId: string;+ tab: SpaceTab;+ children: ReactNode;+}) {+ const navigate = useNavigate();+ const router = useRouter();+ const { channels, isLoading } = useChannels();+ const channel = channels.find((c) => c.id === channelId);+ const loopsEnabled = useFeatureFlag(LOOPS_FLAG);+ useMarkChannelSeen(channelId);+ const contextLayerEnabled = useContextLayerFlag();+ const contextPage = useChannelContextWikiPage(channelId, contextLayerEnabled);+ useContextWikiPage(contextPage.data?.path ?? "");+ const tabs = loopsEnabled ? TABS : TABS.filter((t) => t.key !== "loops");+ const base = `/spaces/${channelId}`;++ useEffect(() => {+ for (const entry of tabs) {+ void router.preloadRoute({ to: `${base}${entry.segment}` });+ }+ }, [base, router, tabs]);++ useSetHeaderContent(+ useMemo(+ () => (+ <div className="flex min-w-0 items-center gap-1.5 pl-5">+ <span className="shrink-0 text-muted-foreground">+ {channelGlyph(channel?.name, {+ size: 14,+ space: true,+ personal: channel?.channelType === "personal",+ private: channel?.channelType === "private",+ })}+ </span>+ {channel ? (+ <span className="min-w-0 truncate font-medium text-[13px]">+ {channel.name}+ </span>+ ) : isLoading ? (+ <Skeleton className="h-3.5 w-40" />+ ) : (+ <span className="font-medium text-[13px]">Space</span>+ )}+ {channel && channel.channelType !== "personal" && (+ <SpaceStar channel={channel} />+ )}+ </div>+ ),+ [channel, isLoading],+ ),+ );++ return (+ <div className="flex h-full min-h-0 min-w-0 flex-col">+ <div className={cn("shrink-0 border-border border-b", SPACE_TAB_INSET)}>+ <Tabs+ value={tab}+ onValueChange={(value: string) => {+ const next = tabs.find((entry) => entry.key === value);+ if (next) void navigate({ to: `${base}${next.segment}` });+ }}+ >+ <TabsList variant="line" aria-label="Space pages">+ {tabs.map((entry) => (+ <TabsTrigger+ key={entry.key}+ value={entry.key}+ onPointerEnter={() => {+ void router.preloadRoute({+ to: `${base}${entry.segment}`,+ });+ }}+ >+ {entry.label}+ </TabsTrigger>+ ))}+ </TabsList>+ </Tabs>+ </div>+ <div className="min-h-0 min-w-0 flex-1">{children}</div>+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkActivityColumn.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkActivityColumn.tsxnew file mode 100644index 000000000000..88f72fb6fbc2--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkActivityColumn.tsx@@ -0,0 +1,16 @@+import { ActivityFeedList } from "@posthog/ui/features/canvas/components/ActivityFeedList";+import { openActivityItem } from "@posthog/ui/features/canvas/components/openActivityItem";+import { closeWorkActivity } from "@posthog/ui/features/canvas/stores/workActivityStore";++export function WorkActivityColumn({ className }: { className?: string }) {+ return (+ <ActivityFeedList+ className={className}+ onActivate={(item) => {+ openActivityItem(item);+ closeWorkActivity();+ }}+ onOpened={closeWorkActivity}+ />+ );+}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.tsxnew file mode 100644index 000000000000..bb2d252cc2f5--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx@@ -0,0 +1,562 @@+import {+ CaretDownIcon,+ CaretRightIcon,+ CaretUpIcon,+ ListMagnifyingGlassIcon,+ PlusIcon,+} from "@phosphor-icons/react";+import {+ type ChannelItemModel,+ channelItemSources,+ DEFAULT_CHANNEL_ITEM_FILTERS,+ filterChannelItems,+ groupChannelItems,+ hasActiveChannelItemFilters,+ sortChannelItems,+} from "@posthog/core/canvas/channelItems";+import type { ChannelPresence } from "@posthog/core/canvas/presence";+import {+ Autocomplete,+ AutocompleteList,+ Button,+ cn,+ MenuLabel,+ Skeleton,+ Tooltip,+ TooltipContent,+ 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 { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";+import type { ChannelItemActions } 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 {+ 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 { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";+import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";+import { toast } from "@posthog/ui/primitives/toast";+import {+ navigateToChannel,+ navigateToChannelDashboard,+ navigateToChannelTask,+ navigateToSpaces,+ navigateToTaskDetail,+} from "@posthog/ui/router/navigationBridge";+import { track } from "@posthog/ui/shell/analytics";+import { useRouterState } from "@tanstack/react-router";+import {+ Fragment,+ type ReactNode,+ useCallback,+ useDeferredValue,+ useMemo,+ useRef,+ useState,+} from "react";++const RECENT_COLLAPSED_COUNT = 5;++function SectionHeading({+ label,+ expanded,+ onToggle,+ trailing,+}: {+ label: string;+ expanded: boolean;+ onToggle: () => void;+ trailing?: ReactNode;+}) {+ const Caret = expanded ? CaretDownIcon : CaretRightIcon;+ return (+ <div className="flex items-center gap-1">+ <MenuLabel+ render={<button type="button" />}+ aria-expanded={expanded}+ onClick={onToggle}+ className="flex min-w-0 flex-1 items-center gap-1 rounded-sm py-1 font-semibold text-foreground/70 hover:text-foreground"+ >+ {label}+ <Caret size={11} className="shrink-0 opacity-60" />+ </MenuLabel>+ {trailing}+ </div>+ );+}++function IconAction({+ label,+ onClick,+ children,+}: {+ label: string;+ onClick: () => void;+ children: ReactNode;+}) {+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ variant="default"+ size="icon-sm"+ aria-label={label}+ onClick={onClick}+ className="text-muted-foreground"+ >+ {children}+ </Button>+ }+ />+ <TooltipContent side="right">{label}</TooltipContent>+ </Tooltip>+ );+}++function SpaceRow({+ channel,+ isActive,+ unread,+ presence,+}: {+ channel: Channel;+ isActive: boolean;+ unread: boolean;+ presence: ChannelPresence | undefined;+}) {+ const people = presence?.people ?? [];+ 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>+ );+}++export function WorkColumn() {+ const [query, setQuery] = useState("");+ const [recentOpen, setRecentOpen] = useState(true);+ const [appearanceOpen, setAppearanceOpen] = useState(false);+ const searchRef = useRef<HTMLInputElement | null>(null);+ useSidebarSearchFocus(searchRef);+ const [recentExpanded, setRecentExpanded] = useState(false);+ const [spacesExpanded, setSpacesExpanded] = useState(true);+ const [createOpen, setCreateOpen] = useState(false);++ const { items, isLoading } = useRecentWorkItems();+ const { channels } = useChannels();+ const currentChannelId = useCurrentChannelStore((s) => s.currentChannelId);+ const isChannelUnread = useIsChannelUnread();+ const pathname = useRouterState({ select: (s) => s.location.pathname });+ const activeKey = useMemo(() => {+ const dashboard = pathname.match(/\/dashboards\/([^/]+)$/);+ if (dashboard) return `canvas:${dashboard[1]}`;+ const task = pathname.match(/\/tasks\/([^/]+)$/);+ return task ? `task:${task[1]}` : null;+ }, [pathname]);+ const activeChannelId = pathname.startsWith("/spaces/")+ ? currentChannelId+ : null;++ const needle = query.trim().toLowerCase();+ const filters = useSidebarStore((state) => state.channelItemFilters);+ const setFilters = useSidebarStore((state) => state.setChannelItemFilters);+ const sort = useSidebarStore((state) => state.channelItemSort);+ const setSort = useSidebarStore((state) => state.setChannelItemSort);+ const grouping = useSidebarStore((state) => state.channelItemGrouping);+ const setGrouping = useSidebarStore((state) => state.setChannelItemGrouping);+ const client = useOptionalAuthenticatedClient();+ const { data: currentUser } = useCurrentUser({ client });+ const meUuid = currentUser?.uuid ?? null;+ const me = useMemo(() => ({ uuid: meUuid }), [meUuid]);+ const sources = useMemo(+ () => channelItemSources(items.map((entry) => entry.item)),+ [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);+ }, [items, query, filters, me, sort]);+ const spaceNameById = useMemo(+ () => new Map(channels.map((channel) => [channel.id, channel.name])),+ [channels],+ );+ const channelByKey = useMemo(+ () => new Map(items.map(({ item, channelId }) => [item.key, channelId])),+ [items],+ );+ const spaceOf = useCallback(+ (item: ChannelItemModel) => {+ const channelId = channelByKey.get(item.key);+ const label = channelId ? spaceNameById.get(channelId) : undefined;+ return channelId && label ? { key: channelId, label } : null;+ },+ [channelByKey, spaceNameById],+ );+ const sections = useMemo(+ () =>+ groupChannelItems(+ matchingItems,+ sort,+ new Date(dayStart),+ grouping,+ spaceOf,+ ),+ [matchingItems, sort, dayStart, grouping, spaceOf],+ );+ const starredSpaces = useMemo(+ () => [+ ...channels.filter((c) => c.channelType === "personal"),+ ...channels.filter((c) => c.channelType !== "personal" && c.starred),+ ],+ [channels],+ );++ 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 showAllRecent = useDeferredValue(recentExpanded || needle !== "");+ const recentRebuilding = showAllRecent !== (recentExpanded || needle !== "");+ const shownSections = useMemo(() => {+ if (showAllRecent) return sections;+ const out: typeof sections = [];+ let left = RECENT_COLLAPSED_COUNT;+ for (const section of sections) {+ if (left <= 0) break;+ out.push({ ...section, items: section.items.slice(0, left) });+ left -= section.items.length;+ }+ return out;+ }, [sections, showAllRecent]);+ const shownItems = useMemo(+ () => shownSections.flatMap((section) => section.items),+ [shownSections],+ );+ const canExpandRecent =+ needle === "" && matchingItems.length > RECENT_COLLAPSED_COUNT;+ const optionValues = useMemo(+ () => [+ ...shownItems.map((item) => item.key),+ ...starredSpaces.map((channel) => channel.id),+ ],+ [shownItems, starredSpaces],+ );++ 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+ open+ items={optionValues}+ filter={null}+ value={query}+ onValueChange={(value, eventDetails) => {+ if (+ eventDetails.reason === "input-change" &&+ typeof value === "string"+ ) {+ setQuery(value);+ }+ }}+ >+ <div className="flex h-full min-h-0 flex-col">+ <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" />+ </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>+ )}+ {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>+ ))}+ </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 className="mt-2">+ <SectionHeading+ label="Spaces"+ expanded={spacesExpanded}+ onToggle={() => setSpacesExpanded((value) => !value)}+ trailing={+ <div className="flex items-center">+ <IconAction+ label="New space…"+ onClick={() => setCreateOpen(true)}+ >+ <PlusIcon size={14} />+ </IconAction>++ <IconAction label="Browse spaces…" onClick={navigateToSpaces}>+ <ListMagnifyingGlassIcon size={14} />+ </IconAction>+ </div>+ }+ />+ {spacesExpanded && (+ <div className="flex flex-col gap-px">+ {starredSpaces.map((channel) => (+ <SpaceRow+ key={channel.id}+ channel={channel}+ isActive={channel.id === activeChannelId}+ unread={isChannelUnread(channel.id)}+ presence={presenceBySpace.get(channel.id)}+ />+ ))}+ {starredSpaces.length <= 1 && needle === "" && (+ <button+ type="button"+ className="mt-1 flex items-center gap-1.5 rounded-md border border-border border-dashed px-2 py-1.5 text-left font-medium text-[12px] text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground"+ onClick={navigateToSpaces}+ >+ <PlusIcon size={13} aria-hidden />+ Add the spaces you work in+ </button>+ )}+ </div>+ )}+ </div>+ </AutocompleteList>+ </div>+ <CreateChannelModal open={createOpen} onOpenChange={setCreateOpen} />+ <EditListItemAppearanceDialog+ surface="sidebar"+ open={appearanceOpen}+ onOpenChange={setAppearanceOpen}+ />+ </Autocomplete>+ );+}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.tsxnew file mode 100644index 000000000000..be4b41c01749--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkItemRow.tsx@@ -0,0 +1,106 @@+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/components/work/WorkRowSurface.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkRowSurface.tsxnew file mode 100644index 000000000000..cdf63824f39d--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkRowSurface.tsx@@ -0,0 +1,25 @@+import { AutocompleteItem, type Button, cn } from "@posthog/quill";+import type { ComponentProps } from "react";++export function WorkRowSurface({+ optionValue,+ className,+ children,+ ...rest+}: ComponentProps<typeof Button> & { optionValue: string }) {+ return (+ <AutocompleteItem+ value={optionValue}+ className={cn(+ "w-full min-w-0 cursor-pointer pr-1 text-left data-selected:bg-fill-selected data-selected:text-foreground",+ "[&>span]:w-full [&>span]:min-w-0 [&>span]:justify-start [&>span]:gap-2 [&>span]:overflow-visible",+ "[&_svg_*]:text-inherit!",+ "ring-offset-0 data-highlighted:border-transparent data-highlighted:bg-fill-hover data-highlighted:ring-0",+ className,+ )}+ {...(rest as ComponentProps<typeof AutocompleteItem>)}+ >+ {children}+ </AutocompleteItem>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/useSpacePullRequests.ts b/products/desktop/packages/ui/src/features/canvas/components/work/useSpacePullRequests.tsnew file mode 100644index 000000000000..fb82db75c201--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/work/useSpacePullRequests.ts@@ -0,0 +1,52 @@+import { readPrUrls } from "@posthog/shared";+import type { Task } from "@posthog/shared/domain-types";+import {+ type PrStateDetails,+ usePrDetailsMap,+ usePrTitles,+} from "@posthog/ui/features/git-interaction/usePrDetails";+import { parseHttpsUrl } from "@posthog/ui/utils/posthogLinks";+import { useMemo } from "react";++export interface SpacePullRequest {+ url: string;+ task: Task;+ details: PrStateDetails | undefined;+ title: string | undefined;+}++const MAX_PULL_REQUESTS = 30;++export function useSpacePullRequests(tasks: Task[]): SpacePullRequest[] {+ const sources = useMemo(() => {+ const seen = new Set<string>();+ const out: { url: string; task: Task }[] = [];+ const byActivity = [...tasks].sort(+ (a, b) => Date.parse(b.updated_at) - Date.parse(a.updated_at),+ );+ for (const task of byActivity) {+ for (const raw of readPrUrls(task.latest_run?.output)) {+ if (out.length >= MAX_PULL_REQUESTS) return out;+ const parsed = parseHttpsUrl(raw);+ const url =+ parsed?.origin === "https://github.com" ? parsed.href : null;+ if (!url || seen.has(url)) continue;+ seen.add(url);+ out.push({ url, task });+ }+ }+ return out;+ }, [tasks]);+ const urls = useMemo(() => sources.map((entry) => entry.url), [sources]);+ const details = usePrDetailsMap(urls);+ const titles = usePrTitles(urls);+ return useMemo(+ () =>+ sources.map((source) => ({+ ...source,+ details: details[source.url],+ title: titles[source.url],+ })),+ [sources, details, titles],+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemFacts.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemFacts.tsindex 31fbd48813f1..758dd6f27ea4 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemFacts.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemFacts.ts@@ -29,8 +29,12 @@ export function channelItemAuthor(item: ChannelItemModel): string | null {return item.authorName;}-function channelItemFacts(item: ChannelItemModel): ChannelItemFacts {+function channelItemFacts(+ item: ChannelItemModel,+ spaceName: string | undefined,+): ChannelItemFacts {return {+ space: spaceName,repository: item.repository?.label,branch: item.branch ?? undefined,creator: channelItemAuthor(item) ?? undefined,@@ -44,8 +48,9 @@ function channelItemFacts(item: ChannelItemModel): ChannelItemFacts {*/export function useChannelItemMetadata(item: ChannelItemModel,+ spaceName?: string,): ReactNode | undefined {const fields = useSidebarStore((state) => state.listItemMetadataFields);if (fields.length === 0) return undefined;- return metadataFromValues(channelItemFacts(item), fields);+ return metadataFromValues(channelItemFacts(item, spaceName), fields);}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.tsindex e27192887dc0..edd14738a8bc 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts@@ -1,9 +1,12 @@import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import {type NavRailPane,+ railPaneFoldsIntoWork,railPaneForHref,railPaneHasSidebar,} from "@posthog/ui/features/canvas/railPane";+import { useWorkActivityStore } from "@posthog/ui/features/canvas/stores/workActivityStore";import { isInboxTriagePath } from "@posthog/ui/features/inbox/triageRoute";import { useRouterState } from "@tanstack/react-router";@@ -28,14 +31,19 @@ export function useRailPane(): NavRailPane {* that need it. */export function useRailSurface(): RailSurface {const channelsLayout = useChannelsLayout();+ const workLayout = useWorkLayout();+ const workActivityOpen = useWorkActivityStore((state) => state.open);const pane = useRailPane();const inTriage = useRouterState({select: (state) => isInboxTriagePath(state.location.pathname),});+ const workSidebar =+ workLayout && (railPaneFoldsIntoWork(pane) || workActivityOpen);return {pane,- hasSidebar: !inTriage && (!channelsLayout || railPaneHasSidebar(pane)),+ hasSidebar:+ !inTriage && (!channelsLayout || railPaneHasSidebar(pane) || workSidebar),showsActivityDetail: channelsLayout && pane === "activity",};}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.tsindex d98a0a583a11..b724641355cd 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts@@ -319,12 +319,13 @@ export function useSpaceOverview(spaceId: string,createdBy: UserBasic | null,peopleLimit: number,+ { enabled = true }: { enabled?: boolean } = {},): SpaceOverview {const client = useOptionalAuthenticatedClient();const archivedTaskIds = useArchivedTaskIds();const { data } = useQuery({...spaceTaskPageQuery(client, spaceId),- enabled: !!client,+ enabled: enabled && !!client,});// A dependency, not `Date.now()` inline: the query keeps `data` referentially// equal across polls that return the same rows, so without the clock in the@@ -442,7 +443,10 @@ export function useSpacePresence(): ReadonlyMap<string, ChannelPresence> {return useMemo(() => {if (!data) return NO_PRESENCE;const live = data.tasks.filter((task) => !archivedTaskIds.has(task.id));- const fresh = presenceByChannel(live, { now, limit: SPACE_PRESENCE_LIMIT });+ const fresh = presenceByChannel(live, {+ now,+ limit: SPACE_PRESENCE_LIMIT,+ });const stable = new Map<string, ChannelPresence>();for (const [channelId, next] of fresh) {const prev = cache.current.get(channelId);diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentWorkItems.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentWorkItems.tsnew file mode 100644index 000000000000..8e671ee8dff5--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentWorkItems.ts@@ -0,0 +1,80 @@+import {+ buildChannelItems,+ type ChannelItemModel,+} from "@posthog/core/canvas/channelItems";+import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import { useChannelSessionFacts } from "@posthog/ui/features/canvas/hooks/useChannelItems";+import { useAllCanvases } from "@posthog/ui/features/canvas/hooks/useDashboards";+import { useCanvasViewedStore } from "@posthog/ui/features/canvas/stores/canvasViewedStore";+import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";+import { useTasks } from "@posthog/ui/features/tasks/useTasks";+import { useMemo } from "react";++export const RECENT_WORK_CAP = 50;++export interface RecentWorkItem {+ item: ChannelItemModel;+ channelId: string | undefined;+}++export function useRecentWorkItems(): {+ items: RecentWorkItem[];+ isLoading: boolean;+} {+ const { data: tasks = [], isLoading: tasksLoading } = useTasks();+ const { dashboards, isLoading: canvasesLoading } = useAllCanvases();+ const lastViewedByCanvasId = useCanvasViewedStore(+ (state) => state.lastViewedAtByCanvasId,+ );+ const archivedTaskIds = useArchivedTaskIds();+ const { pinnedTaskIds } = usePinnedTasks();+ const sessionFacts = useChannelSessionFacts();+ const client = useOptionalAuthenticatedClient();+ const { data: currentUser } = useCurrentUser({ client });+ const meUuid = currentUser?.uuid ?? null;++ const items = useMemo<RecentWorkItem[]>(() => {+ const mine = dashboards.filter(+ (canvas) =>+ lastViewedByCanvasId[canvas.id] != null ||+ (meUuid != null && canvas.createdByUuid === meUuid),+ );+ const channelByKey = new Map<string, string | undefined>();+ for (const canvas of mine)+ channelByKey.set(`canvas:${canvas.id}`, canvas.channelId);+ for (const task of tasks) {+ channelByKey.set(`task:${task.id}`, task.channel ?? undefined);+ }+ const built = buildChannelItems({+ dashboards: mine,+ feedTasks: tasks,+ archivedTaskIds,+ pinnedTaskIds,+ ownedBy: null,+ sessionFacts,+ });+ return built+ .map((item) => {+ const viewedAt =+ item.kind === "canvas"+ ? (lastViewedByCanvasId[item.id] ?? 0)+ : (sessionFacts.viewedTimestamps[item.id]?.lastViewedAt ?? 0);+ return { item: { ...item, ts: Math.max(item.ts, viewedAt) } };+ })+ .sort((a, b) => b.item.ts - a.item.ts)+ .slice(0, RECENT_WORK_CAP)+ .map(({ item }) => ({ item, channelId: channelByKey.get(item.key) }));+ }, [+ dashboards,+ lastViewedByCanvasId,+ meUuid,+ tasks,+ archivedTaskIds,+ pinnedTaskIds,+ sessionFacts,+ ]);++ return { items, isLoading: tasksLoading || canvasesLoading };+}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useSidebarSearchFocus.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useSidebarSearchFocus.tsnew file mode 100644index 000000000000..11da44c48c9f--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useSidebarSearchFocus.ts@@ -0,0 +1,22 @@+import { useSidebarSearchStore } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";+import { type RefObject, useEffect } from "react";++export function useSidebarSearchFocus(+ ref: RefObject<HTMLInputElement | null>,+): void {+ const focusRequest = useSidebarSearchStore((state) => state.focusRequest);++ useEffect(() => {+ if (focusRequest === 0) return;+ const input = ref.current;+ if (!input || input.closest("[inert]")) return;+ // Claim after the inert guard so an offscreen header leaves the request for+ // the visible one, and so each request focuses a single header once.+ if (!useSidebarSearchStore.getState().claimFocus(focusRequest)) return;+ input.focus();+ input.dispatchEvent(+ new KeyboardEvent("keydown", { key: "Home", bubbles: true }),+ );+ input.select();+ }, [focusRequest, ref]);+}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useWorkLayout.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useWorkLayout.tsnew file mode 100644index 000000000000..bd874a29377a--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useWorkLayout.ts@@ -0,0 +1,9 @@+import { DESKTOP_WORK_LAYOUT_FLAG } from "@posthog/shared";+import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";+import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";++export function useWorkLayout(): boolean {+ const channelsLayout = useChannelsLayout();+ const enabled = useFeatureFlag(DESKTOP_WORK_LAYOUT_FLAG, import.meta.env.DEV);+ return channelsLayout && enabled;+}diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts b/products/desktop/packages/ui/src/features/canvas/railPane.test.tsindex f5f927f33b13..ecf6bb126a2c 100644--- a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts+++ b/products/desktop/packages/ui/src/features/canvas/railPane.test.ts@@ -12,6 +12,9 @@ import {const routing = vi.hoisted(() => ({ href: "/inbox", channelsLayout: true }));+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({useChannelsLayout: () => routing.channelsLayout,}));diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.ts b/products/desktop/packages/ui/src/features/canvas/railPane.tsindex d2c597823b47..b75013fe4bb0 100644--- a/products/desktop/packages/ui/src/features/canvas/railPane.ts+++ b/products/desktop/packages/ui/src/features/canvas/railPane.ts@@ -109,3 +109,9 @@ const PANES_WITH_SIDEBAR = new Set<NavRailPane>([export function railPaneHasSidebar(pane: NavRailPane): boolean {return PANES_WITH_SIDEBAR.has(pane);}++const WORK_FOLDED_PANES = new Set<NavRailPane>(["spaces", "home", "canvases"]);++export function railPaneFoldsIntoWork(pane: NavRailPane): boolean {+ return WORK_FOLDED_PANES.has(pane);+}diff --git a/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.tsnew file mode 100644index 000000000000..15c36b4613db--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/stores/spaceActivityViewStore.ts@@ -0,0 +1,63 @@+import {+ type ChannelItemFilters,+ type ChannelItemGrouping,+ type ChannelItemSort,+ DEFAULT_CHANNEL_ITEM_FILTERS,+ DEFAULT_CHANNEL_ITEM_SORT,+} from "@posthog/core/canvas/channelItems";+import type { SpaceActivityType } from "@posthog/ui/features/canvas/components/channelFeedDisplay";+import { ALL_SPACE_ACTIVITY_TYPES } from "@posthog/ui/features/canvas/components/channelFeedDisplay";+import { create } from "zustand";+import { persist } from "zustand/middleware";++export type SpaceActivityView = "list" | "cards";++interface SpaceActivityViewState {+ view: SpaceActivityView;+ types: SpaceActivityType[];+ filters: ChannelItemFilters;+ sort: ChannelItemSort;+ grouping: ChannelItemGrouping;+ setView: (view: SpaceActivityView) => void;+ setTypes: (types: SpaceActivityType[]) => void;+ setFilters: (filters: ChannelItemFilters) => void;+ setSort: (sort: ChannelItemSort) => void;+ setGrouping: (grouping: ChannelItemGrouping) => void;+}++export const useSpaceActivityViewStore = create<SpaceActivityViewState>()(+ persist(+ (set) => ({+ view: "list",+ types: [...ALL_SPACE_ACTIVITY_TYPES],+ filters: DEFAULT_CHANNEL_ITEM_FILTERS,+ sort: DEFAULT_CHANNEL_ITEM_SORT,+ grouping: "date",+ setView: (view) => set({ view }),+ setTypes: (types) => set(types.length > 0 ? { types } : {}),+ setFilters: (filters) => set({ filters }),+ setSort: (sort) => set({ sort }),+ setGrouping: (grouping) => set({ grouping }),+ }),+ {+ name: "ph-space-activity-view",+ merge: (persisted, current) => {+ const saved = persisted as Partial<SpaceActivityViewState> | undefined;+ const savedTypes = saved?.types?.filter((type) =>+ ALL_SPACE_ACTIVITY_TYPES.includes(type),+ );+ return {+ ...current,+ ...saved,+ types:+ savedTypes && savedTypes.length > 0 ? savedTypes : current.types,+ filters: {+ ...current.filters,+ ...saved?.filters,+ kind: "any",+ },+ };+ },+ },+ ),+);diff --git a/products/desktop/packages/ui/src/features/canvas/stores/workActivityStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/workActivityStore.tsnew file mode 100644index 000000000000..f9c00b01b012--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/stores/workActivityStore.ts@@ -0,0 +1,17 @@+import { create } from "zustand";++interface WorkActivityState {+ open: boolean;+ setOpen: (open: boolean) => void;+ toggle: () => void;+}++export const useWorkActivityStore = create<WorkActivityState>()((set) => ({+ open: false,+ setOpen: (open) => set({ open }),+ toggle: () => set((state) => ({ open: !state.open })),+}));++export function closeWorkActivity(): void {+ useWorkActivityStore.getState().setOpen(false);+}diff --git a/products/desktop/packages/ui/src/features/navigation/useReviewInRightPanel.test.ts b/products/desktop/packages/ui/src/features/navigation/useReviewInRightPanel.test.tsindex 4f0eb997dd6c..4088641c10b9 100644--- a/products/desktop/packages/ui/src/features/navigation/useReviewInRightPanel.test.ts+++ b/products/desktop/packages/ui/src/features/navigation/useReviewInRightPanel.test.ts@@ -9,6 +9,9 @@ const mocks = vi.hoisted(() => ({search: {} as Record<string, unknown>,}));+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({useChannelsLayout: () => mocks.channelsLayout,}));diff --git a/products/desktop/packages/ui/src/features/sidebar/components/EditListItemAppearanceDialog.tsx b/products/desktop/packages/ui/src/features/sidebar/components/EditListItemAppearanceDialog.tsxindex 4f56b5581dbf..7fb10a2e0247 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/EditListItemAppearanceDialog.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/EditListItemAppearanceDialog.tsx@@ -38,6 +38,7 @@ interface PreviewTaskid: string;title: string;creatorName: string;+ spaceName: string;}/** Ages that read as a list someone is actually working in. */@@ -63,6 +64,7 @@ const PREVIEW_TASKS: Omit<PreviewTask, "lastActivityAt">[] = [branchName: "posthog/session-list",linkedBranch: "posthog/session-list",creatorName: "Ada Lovelace",+ spaceName: "session-list",},{id: "preview-replay",@@ -75,6 +77,7 @@ const PREVIEW_TASKS: Omit<PreviewTask, "lastActivityAt">[] = [branchName: "fix/replay-loading",linkedBranch: "fix/replay-loading",creatorName: "Grace Hopper",+ spaceName: "replay",},{id: "preview-docs",@@ -87,6 +90,7 @@ const PREVIEW_TASKS: Omit<PreviewTask, "lastActivityAt">[] = [branchName: "docs/sdk-installation",linkedBranch: null,creatorName: "Katherine Johnson",+ spaceName: "docs",},];@@ -219,7 +223,12 @@ export function EditListItemAppearanceDialog({// list, so the preview reads as the list it stands for.icon={<TaskStatusDot dot={taskDot({})} />}label={task.title}- subtitle={taskMetadata(task, task.creatorName, visibleFields)}+ subtitle={taskMetadata(+ task,+ task.creatorName,+ visibleFields,+ task.spaceName,+ )}tabIndex={-1}/>))}diff --git a/products/desktop/packages/ui/src/features/sidebar/components/ListItemMetadata.tsx b/products/desktop/packages/ui/src/features/sidebar/components/ListItemMetadata.tsxindex d049a68edb3b..eacc774b0b99 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/ListItemMetadata.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/ListItemMetadata.tsx@@ -40,8 +40,11 @@ export function taskMetadata(>,creatorName: string | undefined,fields: readonly ListItemMetadataField[],+ spaceName?: string,): ReactNode | undefined {- return listItemMetadata(taskMetadataSegments(task, creatorName, fields));+ return listItemMetadata(+ taskMetadataSegments(task, creatorName, fields, spaceName),+ );}/** A surface that resolved the values itself, like a space's session list. */diff --git a/products/desktop/packages/ui/src/features/sidebar/components/SortableListItemMetadataField.tsx b/products/desktop/packages/ui/src/features/sidebar/components/SortableListItemMetadataField.tsxindex 7a8f797c30ee..2c1a2ef48187 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/SortableListItemMetadataField.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/SortableListItemMetadataField.tsx@@ -4,6 +4,7 @@ import {DotsSixVertical,GitBranch,GitFork,+ Hash,User,} from "@phosphor-icons/react";import { Checkbox, cn, Label } from "@posthog/quill";@@ -17,6 +18,7 @@ const FIELD_ICONS: Record<ListItemMetadataField,ComponentType<{ size?: number | string }>> = {+ space: Hash,repository: GitFork,branch: GitBranch,creator: User,diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsxindex 1bc344b545e2..fe1691a11f8d 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx@@ -1,3 +1,4 @@+import type { IconProps } from "@phosphor-icons/react";import {Binoculars,Broadcast,@@ -14,7 +15,6 @@ import {MagnifyingGlass,Pause,PushPin,- SlackLogo,WarningCircle,} from "@phosphor-icons/react";import type { RunMode } from "@posthog/core/sidebar/buildSidebarData";@@ -24,8 +24,10 @@ import {isTerminalStatus,type TaskRunStatus,} from "@posthog/shared/domain-types";+import type { ComponentType } from "react";import { DotsCircleSpinner } from "../../../../primitives/DotsCircleSpinner";import { NestedButton } from "../../../../primitives/NestedButton";+import { SlackMarkIcon } from "../../../../primitives/SlackMarkIcon";import { Tooltip } from "../../../../primitives/Tooltip";import { openExternalUrl } from "../../../../shell/openExternal";import type { SidebarPrState } from "../../useTaskPrStatus";@@ -42,9 +44,14 @@ export const ICON_SIZE = 12;// status icon, so every non-`user_created` origin is distinguishable at a// glance in the list. `user_created` is intentionally absent — those tasks get// the default status icon. Extend this when a new origin needs its own badge.-type OriginProductMeta = { Icon: typeof SlackLogo; label: string };+type OriginProductMeta = {+ Icon: ComponentType<IconProps>;+ label: string;+ color?: string;+ brandMark?: boolean;+};const ORIGIN_PRODUCT_META: Record<string, OriginProductMeta> = {- slack: { Icon: SlackLogo, label: "Slack" },+ slack: { Icon: SlackMarkIcon, label: "Slack", brandMark: true },signal_report: { Icon: Broadcast, label: "Signals" },signals_scout: { Icon: Binoculars, label: "Signals scout" },support_queue: { Icon: Lifebuoy, label: "Support" },@@ -114,6 +121,9 @@ function CloudStatusIcon({const meta = getOriginProductMeta(originProduct);const Icon = meta?.Icon ?? CloudIcon;const sourceLabel = meta?.label ?? "Cloud";+ const brand = meta?.brandMark ?? false;+ const settledColor = brand ? undefined : "var(--green-11)";+ const runningColor = brand ? undefined : "var(--accent-11)";const link = meta && threadUrl ? threadUrl : undefined;const ariaLabel = link ? `Open ${sourceLabel} thread` : undefined;@@ -142,7 +152,7 @@ function CloudStatusIcon({side="right"><IconSpan- icon={<Icon size={size} weight="fill" color="var(--accent-11)" />}+ icon={<Icon size={size} weight="fill" color={runningColor} />}link={link}ariaLabel={ariaLabel}/>@@ -158,7 +168,7 @@ function CloudStatusIcon({side="right"><IconSpan- icon={<Icon size={size} weight="fill" color="var(--green-11)" />}+ icon={<Icon size={size} weight="fill" color={settledColor} />}link={link}ariaLabel={ariaLabel}/>@@ -174,7 +184,7 @@ function CloudStatusIcon({side="right"><IconSpan- icon={<Icon size={size} weight="fill" color="var(--green-11)" />}+ icon={<Icon size={size} weight="fill" color={settledColor} />}link={link}ariaLabel={link@@ -194,7 +204,13 @@ function CloudStatusIcon({side="right"><IconSpan- icon={<Icon size={size} weight="fill" color="var(--red-11)" />}+ icon={+ <Icon+ size={size}+ weight="fill"+ color={brand ? undefined : "var(--red-11)"}+ />+ }link={link}ariaLabel={ariaLabel}/>@@ -389,7 +405,7 @@ export function TaskIcon({);}if (originProductMeta) {- const { Icon, label } = originProductMeta;+ const { Icon, label, brandMark } = originProductMeta;const link = slackThreadUrl;return (<Tooltip@@ -397,7 +413,12 @@ export function TaskIcon({side="right"><IconSpan- icon={<Icon size={size} color="var(--gray-10)" />}+ icon={+ <Icon+ size={size}+ color={brandMark ? undefined : "var(--gray-10)"}+ />+ }link={link}ariaLabel={`Open ${label} thread`}/>diff --git a/products/desktop/packages/ui/src/features/sidebar/listItemAppearance.ts b/products/desktop/packages/ui/src/features/sidebar/listItemAppearance.tsindex 162846ceada4..0f23b61f6359 100644--- a/products/desktop/packages/ui/src/features/sidebar/listItemAppearance.ts+++ b/products/desktop/packages/ui/src/features/sidebar/listItemAppearance.ts@@ -3,6 +3,7 @@ import type { TaskData } from "@posthog/core/sidebar/sidebarData.types";import { formatAbsoluteDateTime, formatRelativeAge } from "@posthog/shared";export const LIST_ITEM_METADATA_FIELDS = [+ "space","repository","branch","creator",@@ -13,6 +14,7 @@ export type ListItemMetadataField = (typeof LIST_ITEM_METADATA_FIELDS)[number];export const LIST_ITEM_METADATA_LABELS: Record<ListItemMetadataField, string> ={+ space: "Space",repository: "Repository",branch: "Branch",creator: "Creator",@@ -111,9 +113,11 @@ export function taskMetadataSegments(>,creatorName: string | undefined,fields: readonly ListItemMetadataField[],+ spaceName?: string,): ListItemMetadataSegment[] {return listItemMetadataSegments({+ space: spaceName,repository: repositoryLabel(task.repository),branch: task.linkedBranch ?? task.branchName,creator: creatorName,diff --git a/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.test.tsx b/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.test.tsxindex 8dea34544a46..b21ab3f5dc2b 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.test.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.test.tsx@@ -5,6 +5,9 @@ const { routeState } = vi.hoisted(() => ({routeState: { tabId: undefined as string | undefined },}));+vi.mock("@posthog/ui/features/canvas/hooks/useWorkLayout", () => ({+ useWorkLayout: () => false,+}));vi.mock("@tanstack/react-router", () => ({useRouterState: ({ select }: { select: (state: unknown) => unknown }) =>select({ location: { state: routeState } }),diff --git a/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.tsx b/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.tsxindex 7ff8a2b8dfaf..c2fb59f236c1 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/NewTaskScreen.tsx@@ -1,7 +1,11 @@import { CHANNEL_TASK_SUGGESTIONS } from "@posthog/ui/features/canvas/channelTaskSuggestions";+import { NewSessionHeading } from "@posthog/ui/features/canvas/components/work/NewSessionHeading";import { useChannelsWorld } from "@posthog/ui/features/canvas/hooks/useChannelsWorld";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { TaskInput } from "@posthog/ui/features/task-detail/components/TaskInput";import { getTaskInputSessionId } from "@posthog/ui/features/task-detail/taskInputSession";+import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";+import { navigateToChannelNewTask } from "@posthog/ui/router/navigationBridge";import { useAppView } from "@posthog/ui/router/useAppView";import { useRouterState } from "@tanstack/react-router";@@ -13,10 +17,12 @@ import { useRouterState } from "@tanstack/react-router";export function NewTaskScreen() {const view = useAppView();const channelsWorld = useChannelsWorld();+ const workLayout = useWorkLayout();const tabId = useRouterState({select: (state) => state.location.state.tabId,});const sessionId = getTaskInputSessionId(tabId);+ useSetHeaderContent(null, workLayout);if (!tabId) return null;@@ -33,6 +39,14 @@ export function NewTaskScreen() {initialMode={view.initialMode}reportAssociation={view.reportAssociation}suggestions={channelsWorld ? CHANNEL_TASK_SUGGESTIONS : undefined}+ heading={+ workLayout ? (+ <NewSessionHeading+ channelId={null}+ onChangeSpace={navigateToChannelNewTask}+ />+ ) : undefined+ }/>);}diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsxindex 5ad94b57e2fd..a3873f662b1e 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx@@ -212,6 +212,7 @@ interface TaskInputProps {* picker can hold shut mid-submit, like every other chip in the row.*/spaceSelector?: (props: { disabled: boolean }) => ReactNode;+ heading?: ReactNode;}export function TaskInput({@@ -243,6 +244,7 @@ export function TaskInput({onSuggestionSelect,onContextChipClick,spaceSelector,+ heading,}: TaskInputProps = {}) {const cloudRegion = useAuthStateValue((s) => s.cloudRegion);const trpc = useHostTRPC();@@ -1428,15 +1430,24 @@ export function TaskInput({// Note: this is NOT tied to `editorIsEmpty` — the input keeps its// position as the user types so the box doesn't jump down when the// suggestions fade out (and back in when the prompt is cleared).- top: suggestions && suggestions.length > 0 ? "38%" : "50%",+ top: heading+ ? "34%"+ : suggestions && suggestions.length > 0+ ? "38%"+ : "50%",transform: "translate(-50%, -50%)",}}className="absolute left-1/2 z-1 flex w-[calc(100%-2rem)] max-w-[600px] flex-col gap-2">+ {heading}<Flexgap="2"align="center"- className="absolute bottom-full left-0 mb-2 min-w-0 gap-1"+ className={+ heading+ ? "min-w-0 gap-1"+ : "absolute bottom-full left-0 mb-2 min-w-0 gap-1"+ }>{spaceSelector?.({ disabled: isCreatingTask })}{/* One group, so changing the location does not unmount thediff --git a/products/desktop/packages/ui/src/primitives/SlackMarkIcon.tsx b/products/desktop/packages/ui/src/primitives/SlackMarkIcon.tsxnew file mode 100644index 000000000000..652330694312--- /dev/null+++ b/products/desktop/packages/ui/src/primitives/SlackMarkIcon.tsx@@ -0,0 +1,31 @@+import type { IconProps } from "@phosphor-icons/react";++export function SlackMarkIcon({ size = 16, className }: IconProps) {+ return (+ <svg+ width={size}+ height={size}+ viewBox="0 0 122.8 122.8"+ className={className}+ role="img"+ aria-label="Slack"+ >+ <path+ d="M25.8 77.6c0 7.1-5.8 12.9-12.9 12.9S0 84.7 0 77.6s5.8-12.9 12.9-12.9h12.9v12.9zm6.5 0c0-7.1 5.8-12.9 12.9-12.9s12.9 5.8 12.9 12.9v32.3c0 7.1-5.8 12.9-12.9 12.9s-12.9-5.8-12.9-12.9V77.6z"+ fill="#E01E5A"+ />+ <path+ d="M45.2 25.8c-7.1 0-12.9-5.8-12.9-12.9S38.1 0 45.2 0s12.9 5.8 12.9 12.9v12.9H45.2zm0 6.5c7.1 0 12.9 5.8 12.9 12.9s-5.8 12.9-12.9 12.9H12.9C5.8 58.1 0 52.3 0 45.2s5.8-12.9 12.9-12.9h32.3z"+ fill="#36C5F0"+ />+ <path+ d="M97 45.2c0-7.1 5.8-12.9 12.9-12.9s12.9 5.8 12.9 12.9-5.8 12.9-12.9 12.9H97V45.2zm-6.5 0c0 7.1-5.8 12.9-12.9 12.9s-12.9-5.8-12.9-12.9V12.9C64.7 5.8 70.5 0 77.6 0s12.9 5.8 12.9 12.9v32.3z"+ fill="#2EB67D"+ />+ <path+ d="M77.6 97c7.1 0 12.9 5.8 12.9 12.9s-5.8 12.9-12.9 12.9-12.9-5.8-12.9-12.9V97h12.9zm0-6.5c-7.1 0-12.9-5.8-12.9-12.9s5.8-12.9 12.9-12.9h32.3c7.1 0 12.9 5.8 12.9 12.9s-5.8 12.9-12.9 12.9H77.6z"+ fill="#ECB22E"+ />+ </svg>+ );+}diff --git a/products/desktop/packages/ui/src/router/routeSkeletons.tsx b/products/desktop/packages/ui/src/router/routeSkeletons.tsxindex 36c9fd013484..20cc409ad04b 100644--- a/products/desktop/packages/ui/src/router/routeSkeletons.tsx+++ b/products/desktop/packages/ui/src/router/routeSkeletons.tsx@@ -1,4 +1,5 @@import { Skeleton } from "@posthog/quill";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import type { ReactElement } from "react";import { yieldToPaint } from "./yieldToPaint";@@ -139,3 +140,117 @@ export function AppPageSkeleton() {/>);}++function SpaceTabsFrame({ children }: { children: ReactElement }) {+ return (+ <div className="flex h-full min-h-0 w-full flex-col">+ <div className="flex shrink-0 items-end gap-4 border-border border-b px-6 pt-2 pb-2">+ <Skeleton className="h-4 w-14" />+ <Skeleton className="h-4 w-14" />+ <Skeleton className="h-4 w-16" />+ <Skeleton className="h-4 w-14" />+ </div>+ {children}+ </div>+ );+}++export function SpaceActivitySkeleton() {+ return (+ <SpaceTabsFrame>+ <div className="flex min-h-0 flex-1">+ <div className="flex min-w-0 flex-1 flex-col gap-3 px-6 pt-5">+ <div className="flex w-full max-w-[900px] flex-col gap-2 border-border border-b pb-4">+ <Skeleton className="h-6 w-40" />+ <Skeleton className="h-10 w-full" />+ <Skeleton className="h-4 w-44" />+ </div>+ <Skeleton className="h-3 w-14" />+ {Array.from({ length: 6 }).map((_, i) => (+ // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton row+ <Skeleton key={i} className="h-7 w-full max-w-[900px]" />+ ))}+ </div>++ <div className="flex w-[276px] shrink-0 flex-col gap-1 border-border border-l px-3.5 pt-4">+ <Skeleton className="h-2.5 w-24" />+ {Array.from({ length: 5 }).map((_, i) => (+ // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton row+ <Skeleton key={i} className="h-6 w-full" />+ ))}+ </div>+ </div>+ </SpaceTabsFrame>+ );+}++export function SpaceContextSkeleton() {+ return (+ <SpaceTabsFrame>+ <div className="flex min-h-0 flex-1 flex-col">+ <div className="flex h-11 shrink-0 items-center gap-2 border-border border-b px-6">+ <Skeleton className="h-3.5 w-40" />+ <div className="flex-1" />+ <Skeleton className="h-7 w-28" />+ <Skeleton className="h-7 w-36" />+ </div>+ <div className="flex flex-col gap-6 px-6 pt-6">+ <Skeleton className="h-4 w-16" />+ <Skeleton className="h-20 w-full max-w-md" />+ <Skeleton className="h-4 w-24" />+ <Skeleton className="h-12 w-full" />+ </div>+ </div>+ </SpaceTabsFrame>+ );+}++export function SpaceCanvasesSkeleton() {+ return (+ <SpaceTabsFrame>+ <div className="flex min-h-0 flex-1 flex-col gap-3 px-6 py-5">+ <div className="flex items-center">+ <Skeleton className="h-3.5 w-20" />+ <div className="flex-1" />+ <Skeleton className="h-7 w-28" />+ </div>+ <div className="grid grid-cols-3 content-start gap-4">+ {Array.from({ length: 6 }).map((_, i) => (+ // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton card+ <Skeleton key={i} className="h-56 w-full" />+ ))}+ </div>+ </div>+ </SpaceTabsFrame>+ );+}++export function SpaceSettingsSkeleton() {+ return (+ <SpaceTabsFrame>+ <div className="flex min-h-0 flex-1 flex-col">+ <div className="flex h-11 shrink-0 items-center border-border border-b px-6">+ <Skeleton className="h-3.5 w-80" />+ </div>+ <div className="flex max-w-[800px] flex-col gap-7 px-6 pt-6">+ {Array.from({ length: 2 }).map((_, i) => (+ // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton section+ <div key={i} className="flex flex-col gap-2">+ <Skeleton className="h-4 w-28" />+ <Skeleton className="h-3 w-72" />+ <Skeleton className="h-16 w-full" />+ </div>+ ))}+ </div>+ </div>+ </SpaceTabsFrame>+ );+}++export function spaceRouteSkeleton(+ tabbed: () => ReactElement,+): () => ReactElement {+ return function SpaceRouteSkeleton() {+ return useWorkLayout() ? tabbed() : <ChannelSkeleton />;+ };+}diff --git a/products/desktop/packages/ui/src/router/routeTree.gen.ts b/products/desktop/packages/ui/src/router/routeTree.gen.tsindex 0d1f630c7c59..250e8ff2b815 100644--- a/products/desktop/packages/ui/src/router/routeTree.gen.ts+++ b/products/desktop/packages/ui/src/router/routeTree.gen.ts@@ -65,6 +65,7 @@ import { Route as ShellSpacesChannelIdHistoryRouteImport } from './routes/_shellimport { Route as ShellSpacesChannelIdContextRouteImport } from './routes/_shell/spaces/$channelId/context'import { Route as ShellSpacesChannelIdCanvasesRouteImport } from './routes/_shell/spaces/$channelId/canvases'import { Route as ShellSpacesChannelIdArtifactsRouteImport } from './routes/_shell/spaces/$channelId/artifacts'+import { Route as ShellSpacesChannelIdActivityRouteImport } from './routes/_shell/spaces/$channelId/activity'import { Route as ShellSpacesChannelIdTasksTaskIdRouteImport } from './routes/_shell/spaces/$channelId/tasks/$taskId'import { Route as ShellSpacesChannelIdReportsReportIdRouteImport } from './routes/_shell/spaces/$channelId/reports/$reportId'import { Route as ShellSpacesChannelIdDashboardsDashboardIdRouteImport } from './routes/_shell/spaces/$channelId/dashboards/$dashboardId'@@ -355,6 +356,12 @@ const ShellSpacesChannelIdArtifactsRoute =path: '/spaces/$channelId/artifacts',getParentRoute: () => ShellRoute,} as any)+const ShellSpacesChannelIdActivityRoute =+ ShellSpacesChannelIdActivityRouteImport.update({+ id: '/spaces/$channelId/activity',+ path: '/spaces/$channelId/activity',+ getParentRoute: () => ShellRoute,+ } as any)const ShellSpacesChannelIdTasksTaskIdRoute =ShellSpacesChannelIdTasksTaskIdRouteImport.update({id: '/spaces/$channelId/tasks/$taskId',@@ -422,6 +429,7 @@ export interface FileRoutesByFullPath {'/inbox/reports/': typeof InboxReportsIndexRoute'/inbox/runs/': typeof InboxRunsIndexRoute'/loops/$loopId/': typeof LoopsLoopIdIndexRoute+ '/spaces/$channelId/activity': typeof ShellSpacesChannelIdActivityRoute'/spaces/$channelId/artifacts': typeof ShellSpacesChannelIdArtifactsRoute'/spaces/$channelId/canvases': typeof ShellSpacesChannelIdCanvasesRoute'/spaces/$channelId/context': typeof ShellSpacesChannelIdContextRoute@@ -476,6 +484,7 @@ export interface FileRoutesByTo {'/inbox/reports': typeof InboxReportsIndexRoute'/inbox/runs': typeof InboxRunsIndexRoute'/loops/$loopId': typeof LoopsLoopIdIndexRoute+ '/spaces/$channelId/activity': typeof ShellSpacesChannelIdActivityRoute'/spaces/$channelId/artifacts': typeof ShellSpacesChannelIdArtifactsRoute'/spaces/$channelId/canvases': typeof ShellSpacesChannelIdCanvasesRoute'/spaces/$channelId/context': typeof ShellSpacesChannelIdContextRoute@@ -538,6 +547,7 @@ export interface FileRoutesById {'/inbox/reports/': typeof InboxReportsIndexRoute'/inbox/runs/': typeof InboxRunsIndexRoute'/loops/$loopId/': typeof LoopsLoopIdIndexRoute+ '/_shell/spaces/$channelId/activity': typeof ShellSpacesChannelIdActivityRoute'/_shell/spaces/$channelId/artifacts': typeof ShellSpacesChannelIdArtifactsRoute'/_shell/spaces/$channelId/canvases': typeof ShellSpacesChannelIdCanvasesRoute'/_shell/spaces/$channelId/context': typeof ShellSpacesChannelIdContextRoute@@ -600,6 +610,7 @@ export interface FileRouteTypes {| '/inbox/reports/'| '/inbox/runs/'| '/loops/$loopId/'+ | '/spaces/$channelId/activity'| '/spaces/$channelId/artifacts'| '/spaces/$channelId/canvases'| '/spaces/$channelId/context'@@ -654,6 +665,7 @@ export interface FileRouteTypes {| '/inbox/reports'| '/inbox/runs'| '/loops/$loopId'+ | '/spaces/$channelId/activity'| '/spaces/$channelId/artifacts'| '/spaces/$channelId/canvases'| '/spaces/$channelId/context'@@ -715,6 +727,7 @@ export interface FileRouteTypes {| '/inbox/reports/'| '/inbox/runs/'| '/loops/$loopId/'+ | '/_shell/spaces/$channelId/activity'| '/_shell/spaces/$channelId/artifacts'| '/_shell/spaces/$channelId/canvases'| '/_shell/spaces/$channelId/context'@@ -1143,6 +1156,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ShellSpacesChannelIdArtifactsRouteImportparentRoute: typeof ShellRoute}+ '/_shell/spaces/$channelId/activity': {+ id: '/_shell/spaces/$channelId/activity'+ path: '/spaces/$channelId/activity'+ fullPath: '/spaces/$channelId/activity'+ preLoaderRoute: typeof ShellSpacesChannelIdActivityRouteImport+ parentRoute: typeof ShellRoute+ }'/_shell/spaces/$channelId/tasks/$taskId': {id: '/_shell/spaces/$channelId/tasks/$taskId'path: '/spaces/$channelId/tasks/$taskId'@@ -1181,6 +1201,7 @@ interface ShellRouteChildren {ShellFeedsIndexRoute: typeof ShellFeedsIndexRouteShellSettingsIndexRoute: typeof ShellSettingsIndexRouteShellSpacesIndexRoute: typeof ShellSpacesIndexRoute+ ShellSpacesChannelIdActivityRoute: typeof ShellSpacesChannelIdActivityRouteShellSpacesChannelIdArtifactsRoute: typeof ShellSpacesChannelIdArtifactsRouteShellSpacesChannelIdCanvasesRoute: typeof ShellSpacesChannelIdCanvasesRouteShellSpacesChannelIdContextRoute: typeof ShellSpacesChannelIdContextRoute@@ -1208,6 +1229,7 @@ const ShellRouteChildren: ShellRouteChildren = {ShellFeedsIndexRoute: ShellFeedsIndexRoute,ShellSettingsIndexRoute: ShellSettingsIndexRoute,ShellSpacesIndexRoute: ShellSpacesIndexRoute,+ ShellSpacesChannelIdActivityRoute: ShellSpacesChannelIdActivityRoute,ShellSpacesChannelIdArtifactsRoute: ShellSpacesChannelIdArtifactsRoute,ShellSpacesChannelIdCanvasesRoute: ShellSpacesChannelIdCanvasesRoute,ShellSpacesChannelIdContextRoute: ShellSpacesChannelIdContextRoute,diff --git a/products/desktop/packages/ui/src/router/routes/_shell/index.tsx b/products/desktop/packages/ui/src/router/routes/_shell/index.tsxindex aa103d0b1a14..1bb3978f5d81 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/index.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/index.tsx@@ -1,5 +1,6 @@import { HomeView } from "@posthog/ui/features/canvas/grid/HomeView";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import { NewTaskScreen } from "@posthog/ui/features/task-detail/components/NewTaskScreen";import { createFileRoute } from "@tanstack/react-router";@@ -9,6 +10,7 @@ export const Route = createFileRoute("/_shell/")({function RootRoute() {// Home is the spaces layout's landing screen. Without that layout there is no- // Home, and the app opens on a new task the way it always did.- return useChannelsLayout() ? <HomeView /> : <NewTaskScreen />;+ const channelsLayout = useChannelsLayout();+ const workLayout = useWorkLayout();+ return channelsLayout && !workLayout ? <HomeView /> : <NewTaskScreen />;}diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/activity.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/activity.tsxnew file mode 100644index 000000000000..e7e36bb2e39e--- /dev/null+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/activity.tsx@@ -0,0 +1,7 @@+import { createFileRoute, redirect } from "@tanstack/react-router";++export const Route = createFileRoute("/_shell/spaces/$channelId/activity")({+ beforeLoad: ({ params }) => {+ throw redirect({ to: "/spaces/$channelId", params });+ },+});diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/canvases.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/canvases.tsxindex 2457ffa49b25..f236163ddc19 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/canvases.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/canvases.tsx@@ -1,11 +1,26 @@import { WebsiteDashboardsIndex } from "@posthog/ui/features/canvas/components/WebsiteDashboardsIndex";+import { SpaceTabbedPage } from "@posthog/ui/features/canvas/components/work/SpaceTabbedPage";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";+import {+ SpaceCanvasesSkeleton,+ spaceRouteSkeleton,+ withRouteSkeleton,+} from "@posthog/ui/router/routeSkeletons";import { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/_shell/spaces/$channelId/canvases")({component: ChannelCanvasesRoute,+ ...withRouteSkeleton(spaceRouteSkeleton(SpaceCanvasesSkeleton)),});function ChannelCanvasesRoute() {const { channelId } = Route.useParams();+ if (useWorkLayout()) {+ return (+ <SpaceTabbedPage channelId={channelId} tab="canvases">+ <WebsiteDashboardsIndex channelId={channelId} variant="work" />+ </SpaceTabbedPage>+ );+ }return <WebsiteDashboardsIndex channelId={channelId} />;}diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/context.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/context.tsxindex e057a18b0800..189f8f5bbe82 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/context.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/context.tsx@@ -1,16 +1,26 @@import { WebsiteContext } from "@posthog/ui/features/canvas/components/WebsiteContext";+import { SpaceTabbedPage } from "@posthog/ui/features/canvas/components/work/SpaceTabbedPage";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import {- ChannelSkeleton,+ SpaceContextSkeleton,+ spaceRouteSkeleton,withRouteSkeleton,} from "@posthog/ui/router/routeSkeletons";import { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/_shell/spaces/$channelId/context")({component: ContextRoute,- ...withRouteSkeleton(ChannelSkeleton),+ ...withRouteSkeleton(spaceRouteSkeleton(SpaceContextSkeleton)),});function ContextRoute() {const { channelId } = Route.useParams();+ if (useWorkLayout()) {+ return (+ <SpaceTabbedPage channelId={channelId} tab="context">+ <WebsiteContext channelId={channelId} />+ </SpaceTabbedPage>+ );+ }return <WebsiteContext channelId={channelId} />;}diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/index.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/index.tsxindex 0a7c50952a03..746922e3f308 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/index.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/index.tsx@@ -1,16 +1,26 @@import { WebsiteChannelHome } from "@posthog/ui/features/canvas/components/WebsiteChannelHome";+import { SpaceTabbedPage } from "@posthog/ui/features/canvas/components/work/SpaceTabbedPage";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import {- ChannelSkeleton,+ SpaceActivitySkeleton,+ spaceRouteSkeleton,withRouteSkeleton,} from "@posthog/ui/router/routeSkeletons";import { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/_shell/spaces/$channelId/")({component: ChannelHomeRoute,- ...withRouteSkeleton(ChannelSkeleton),+ ...withRouteSkeleton(spaceRouteSkeleton(SpaceActivitySkeleton)),});function ChannelHomeRoute() {const { channelId } = Route.useParams();+ if (useWorkLayout()) {+ return (+ <SpaceTabbedPage channelId={channelId} tab="activity">+ <WebsiteChannelHome channelId={channelId} variant="work" />+ </SpaceTabbedPage>+ );+ }return <WebsiteChannelHome channelId={channelId} />;}diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/loops.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/loops.tsxindex a7d7a0ecbc04..0c86def12b2d 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/loops.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/loops.tsx@@ -1,16 +1,26 @@import { WebsiteChannelLoops } from "@posthog/ui/features/canvas/components/WebsiteChannelLoops";+import { SpaceTabbedPage } from "@posthog/ui/features/canvas/components/work/SpaceTabbedPage";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";import {- ChannelSkeleton,+ SpaceContextSkeleton,+ spaceRouteSkeleton,withRouteSkeleton,} from "@posthog/ui/router/routeSkeletons";import { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/_shell/spaces/$channelId/loops")({component: ChannelLoopsRoute,- ...withRouteSkeleton(ChannelSkeleton),+ ...withRouteSkeleton(spaceRouteSkeleton(SpaceContextSkeleton)),});function ChannelLoopsRoute() {const { channelId } = Route.useParams();+ if (useWorkLayout()) {+ return (+ <SpaceTabbedPage channelId={channelId} tab="loops">+ <WebsiteChannelLoops channelId={channelId} />+ </SpaceTabbedPage>+ );+ }return <WebsiteChannelLoops channelId={channelId} />;}diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsxindex c3685603fe73..03f309590f6c 100644--- a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx@@ -1,11 +1,26 @@import { SpaceSettings } from "@posthog/ui/features/canvas/components/SpaceSettings";+import { SpaceTabbedPage } from "@posthog/ui/features/canvas/components/work/SpaceTabbedPage";+import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";+import {+ SpaceSettingsSkeleton,+ spaceRouteSkeleton,+ withRouteSkeleton,+} from "@posthog/ui/router/routeSkeletons";import { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/_shell/spaces/$channelId/settings")({component: SettingsRoute,+ ...withRouteSkeleton(spaceRouteSkeleton(SpaceSettingsSkeleton)),});function SettingsRoute() {const { channelId } = Route.useParams();+ if (useWorkLayout()) {+ return (+ <SpaceTabbedPage channelId={channelId} tab="settings">+ <SpaceSettings channelId={channelId} />+ </SpaceTabbedPage>+ );+ }return <SpaceSettings channelId={channelId} />;}