: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): make saved searches a top-level route with a switcher header (#91228)
Shy Alter9082d5a0ee43
diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.tsindex 79b8c0ca5c96..b5f92128dec4 100644--- a/products/desktop/packages/shared/src/analytics-events.ts+++ b/products/desktop/packages/shared/src/analytics-events.ts@@ -297,18 +297,18 @@ export interface SidebarNavItemClickedProperties {layout?: SidebarLayout;}+export type TaskListSurface = "sidebar" | "space" | "saved_search";+export interface TaskListGroupingChangedProperties {group_by: "repository" | "date";sort_by: "updated" | "created" | "alpha";- /** Which list was regrouped: the app sidebar's, or a space's session list. */- surface: "sidebar" | "space";+ surface: TaskListSurface;}export interface TaskListAppearanceChangedProperties {secondary_fields: ("repository" | "branch" | "creator" | "activity")[];secondary_field_count: number;- /** Which list it was changed from. The setting applies to both. */- surface: "sidebar" | "space";+ surface: TaskListSurface;}export interface BrainrotActivatedProperties {diff --git a/products/desktop/packages/shared/src/flags.ts b/products/desktop/packages/shared/src/flags.tsindex 1ef364860d8d..579b4d783b1c 100644--- a/products/desktop/packages/shared/src/flags.ts+++ b/products/desktop/packages/shared/src/flags.ts@@ -21,6 +21,7 @@ export const CHANNELS_LAYOUT_FLAG = "code-spaces-layout";// Gates the Loops feature: the sidebar Loops space and the per-channel Loops tab.export const LOOPS_FLAG = "loops";export const DESKTOP_HOME_FLAG = "desktop-home-flag";+export const SAVED_SEARCHES_RAIL_FLAG = "posthog-desktop-saved-searches-rail";export const TASKS_PREWARM_SANDBOX_FLAG = "tasks-prewarm-sandbox";export const GLM_MODEL_FLAG = "posthog-code-glm-model";export const GLM53_MODEL_FLAG = "posthog-code-glm-53-model";diff --git a/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md b/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.mdindex b1916c10a8d4..0728e728bfa0 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md+++ b/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md@@ -262,11 +262,13 @@ retarget its originating background tab as described below. `railHistoryStore`still drives the strip's **highlight**, which should flip instantly — that isa render, not a write.- **A session is not always a path param.** Activity reads its picked item out- of `/activity`'s *search*, and a feed does the same. The strip's identity and- label therefore come from `useActiveSession()`, never `params.taskId`, or a- tab sitting on an open session reads "New tab". That selection lives in the- URL precisely so a tab can name it and restore it — don't move it back into a- store.+ of `/activity`'s *search*. The strip's identity and label therefore come from+ `useActiveSession()`, never `params.taskId`, or a tab sitting on an open+ session reads "New tab". That selection lives in the URL precisely so a tab+ can name it and restore it — don't move it back into a store.+- **A saved search names its own tab.** `/feeds/$feedId` is the tab; picking a+ result reads that task into the pane without leaving the search, so the strip+ drops the active session there and labels the tab with the search's name.- **Label resolution is reactive + cached.** Names come from the activerecord's warm fetch, then the channel list / all-tasks list, then amodule-level cache — and the `tabs` memo references those sources directly (sodiff --git a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsxindex 97408b998029..5fcd828f7db0 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx+++ b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx@@ -1,3 +1,4 @@+import { MagnifyingGlassIcon } from "@phosphor-icons/react";import { useService } from "@posthog/di/react";import {closeTab as closeTabLocal,@@ -22,6 +23,7 @@ import {useDashboard,useDashboards,} from "@posthog/ui/features/canvas/hooks/useDashboards";+import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";import { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";import {activityReportIdFromHref,@@ -32,11 +34,12 @@ import {useChannelPaneStore,} from "@posthog/ui/features/canvas/stores/channelPaneStore";import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import { feedIdFromHref } from "@posthog/ui/features/canvas/stores/taskFeedSelectionStore";import { SHORTCUTS } from "@posthog/ui/features/command/keyboard-shortcuts";import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";import { useInboxReportById } from "@posthog/ui/features/inbox/hooks/useInboxReports";import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";-import { useActiveSession } from "@posthog/ui/features/navigation/useActiveSession";+import { useTabSession } from "@posthog/ui/features/navigation/useActiveSession";import { usePanelLayoutStore } from "@posthog/ui/features/panels/panelLayoutStore";import { getLeafPanel } from "@posthog/ui/features/panels/panelStoreHelpers";import { getTaskInputSessionId } from "@posthog/ui/features/task-detail/taskInputSession";@@ -137,7 +140,9 @@ function BrowserTabStripImpl() {channelId?: string;dashboardId?: string;taskId?: string;+ feedId?: string;};+ const routeFeedId = params.feedId ?? null;// The in-flight tag: flips the instant you navigate, so the strip's highlight// and the active tab's name don't lag a navigation behind. Rendering only —// the effect below must not write from it (see settledLocation).@@ -162,9 +167,7 @@ function BrowserTabStripImpl() {// Which rail destination this location belongs to, so the tab can remember// where that destination was when it left.const railPane = useRailPane();- // Which session the content pane is about, wherever it came from: a path- // param, Activity's picked item, or a feed's.- const activeSession = useActiveSession();+ const activeSession = useTabSession();// Top-level app pages are tab targets too. Their typed metadata keeps route// classification, persisted labels, and rendered labels in one vocabulary.const view = useAppView();@@ -230,6 +233,12 @@ function BrowserTabStripImpl() {const activeTabId =(historyTabIsLive ? historyTabId : null) ?? win?.activeTabId ?? null;+ const feeds = useProjectTaskFeeds();+ const feedName = useMemo(() => {+ const map = new Map(feeds.map((f) => [f.id, f.name]));+ return (id: string | null) => (id ? (map.get(id) ?? null) : null);+ }, [feeds]);+const channelName = useMemo(() => {const map = new Map(channels.map((c) => [c.id, c.name]));return (id: string | null) => (id ? (map.get(id) ?? null) : null);@@ -304,6 +313,7 @@ function BrowserTabStripImpl() {]);const routeTitle = useMemo(() => {+ if (routeFeedId) return feedName(routeFeedId);if (activeTitle) return activeTitle;const currentChannelId =params.channelId ?? activeSession.channelId ?? null;@@ -318,6 +328,8 @@ function BrowserTabStripImpl() {return null;}, [activeTitle,+ routeFeedId,+ feedName,params.channelId,activeSession.channelId,activeActivityReportId,@@ -556,6 +568,16 @@ function BrowserTabStripImpl() {const section = isActive ? routeChannelSection : t.channelSection;const appView = isActive ? routeAppView : t.appView;const channel = channelName(channelId);+ const feedId = isActive ? routeFeedId : feedIdFromHref(t.href);+ if (feedId) {+ return {+ id: t.id,+ label: feedName(feedId) ?? t.viewState?.title ?? "Saved search",+ icon: <MagnifyingGlassIcon size={14} />,+ channelName: null,+ pinned,+ };+ }if (taskId) {const task = findTask(taskId);return {@@ -655,6 +677,8 @@ function BrowserTabStripImpl() {activeTitle,routeChannelSection,routeAppView,+ routeFeedId,+ feedName,spacesLayout,]);diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsxindex e01ae0ffd572..6958e9490d91 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.tsx@@ -63,9 +63,8 @@ export interface ChannelItemActions {/** Pins or unpins a whole batch, which a drag over the pinned run applies. */setPinned: (items: ChannelItemModel[], pinned: boolean) => void;archive: (item: ChannelItemModel) => void;- /** Canvases only — a task is archived, not deleted. */- remove: (item: ChannelItemModel) => void;- fileCanvas: (item: ChannelItemModel, channelId: string) => void;+ remove?: (item: ChannelItemModel) => void;+ fileCanvas?: (item: ChannelItemModel, channelId: string) => void;}// The channel sidebar's own chrome. Deliberately not shared with the Code@@ -306,6 +305,7 @@ export function ChannelItemRow({currentUser.data?.id === item.authorUser.id;const canFileCanvas =item.kind === "canvas" &&+ actions.fileCanvas !== undefined &&item.authorUuid != null &¤tUser.data?.uuid === item.authorUuid;const handleDragStart = useCallback(@@ -343,7 +343,7 @@ export function ChannelItemRow({...(canFileCanvas? {onFile: (targetChannelId: string) =>- actions.fileCanvas(item, targetChannelId),+ actions.fileCanvas?.(item, targetChannelId),}: {}),onTogglePin: () => actions.togglePin(item),@@ -448,7 +448,7 @@ export function ChannelItemRow({size="sm"onClick={() => {setConfirmDeleteOpen(false);- actions.remove(item);+ actions.remove?.(item);}}>Deletediff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsxnew file mode 100644index 000000000000..2cea86bb0be5--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx@@ -0,0 +1,448 @@+import { MagnifyingGlass } from "@phosphor-icons/react";+import {+ ANY_SOURCE,+ type ChannelItemFilters,+ type ChannelItemGrouping,+ type ChannelItemModel,+ channelItemSortEvent,+ channelItemSources,+ DEFAULT_CHANNEL_ITEM_FILTERS,+ filterChannelItems,+ groupChannelItems,+ hasActiveChannelItemFilters,+ PINNED_SECTION_KEY,+ sortChannelItems,+} from "@posthog/core/canvas/channelItems";+import { getCanvasCellId } from "@posthog/core/command-center/grid";+import {+ Empty,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,+ MenuLabel,+ Skeleton,+ SkeletonText,+} from "@posthog/quill";+import {+ ANALYTICS_EVENTS,+ type TaskListSurface,+} from "@posthog/shared/analytics-events";+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 { ChannelItemDragPreview } from "@posthog/ui/features/canvas/components/ChannelItemDragPreview";+import type { ChannelItemActions } from "@posthog/ui/features/canvas/components/ChannelItemRow";+import { ChannelItemRow } from "@posthog/ui/features/canvas/components/ChannelItemRow";+import { PinnedRun } from "@posthog/ui/features/canvas/components/PinnedRun";+import { useChannelItemSelection } from "@posthog/ui/features/canvas/hooks/useChannelItemSelection";+import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";+import { useCommandCenterStore } from "@posthog/ui/features/command-center/commandCenterStore";+import {+ placeCanvasInCommandCenter,+ placeTaskInCommandCenter,+} from "@posthog/ui/features/command-center/placeTaskInCommandCenter";+import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";+import { MarqueeOverlay } from "@posthog/ui/features/sidebar/components/MarqueeOverlay";+import { SidebarBulkActionBar } from "@posthog/ui/features/sidebar/components/SidebarBulkActionBar";+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";+import { taskDragSiblings } from "@posthog/ui/features/sidebar/taskDrag";+import { usePinDrag } from "@posthog/ui/features/sidebar/usePinDrag";+import { useRenameTask } from "@posthog/ui/features/tasks/useTaskMutations";+import { track } from "@posthog/ui/shell/analytics";+import { logger } from "@posthog/ui/shell/logger";+import { motion, useReducedMotion } from "framer-motion";+import {+ Fragment,+ type ReactNode,+ useCallback,+ useMemo,+ useState,+} from "react";++const log = logger.scope("channel-items-pane");++function commandCenterAssigner(item: ChannelItemModel): () => void {+ return () => {+ if (item.kind === "canvas") {+ placeCanvasInCommandCenter(item.id, item.title);+ } else {+ placeTaskInCommandCenter(item.id, item.title);+ }+ };+}++function isInCommandCenter(+ item: ChannelItemModel,+ commandCenterCells: readonly (string | null)[],+): boolean {+ return commandCenterCells.some((cell) =>+ item.kind === "canvas"+ ? getCanvasCellId(cell) === item.id+ : cell === item.id,+ );+}++const SKELETON_ROW_WIDTHS = [60, 80, 40, 75, 50, 66] as const;++function ChannelItemsSkeleton() {+ return (+ <div aria-hidden className="flex flex-col gap-px">+ <SkeletonText+ lines={1}+ maxWidth={100}+ className="mx-2 mt-1.5 mb-1 w-12 text-xs"+ />+ {SKELETON_ROW_WIDTHS.map((width) => (+ <div key={width} className="flex items-center gap-2 px-2 py-1.5">+ <Skeleton className="size-4 shrink-0 rounded" />+ <SkeletonText+ lines={1}+ maxWidth={width}+ className="min-w-0 flex-1 text-[13px] leading-snug"+ />+ </div>+ ))}+ </div>+ );+}++type ListState = "loading" | "empty" | "ready";++function listStateOf({+ isLoading,+ itemCount,+ narrowed,+}: {+ isLoading: boolean;+ itemCount: number;+ narrowed: boolean;+}): ListState {+ if (isLoading && itemCount === 0) return "loading";+ if (itemCount === 0 && !narrowed) return "empty";+ return "ready";+}++export function ChannelItemsPane({+ items,+ isLoading,+ actions,+ activeKey,+ surface,+ headerLeft,+ hasMultipleAuthors = true,+ hasRuns = true,+ cap,+ channelIdFor,+ emptyState,+ overlay,+ searchLabel = "Search sessions",+}: {+ items: readonly ChannelItemModel[];+ isLoading: boolean;+ actions: ChannelItemActions;+ activeKey: string | null;+ surface: TaskListSurface;+ headerLeft?: ReactNode;+ hasMultipleAuthors?: boolean;+ hasRuns?: boolean;+ cap?: number;+ channelIdFor?: (item: ChannelItemModel) => string | undefined;+ emptyState: ReactNode;+ overlay?: ReactNode;+ searchLabel?: string;+}) {+ const [editingTaskId, setEditingTaskId] = useState<string | null>(null);+ const { renameTask } = useRenameTask();+ const commandCenterCells = useCommandCenterStore((state) => state.cells);+ const [query, setQuery] = useState("");+ const [appearanceOpen, setAppearanceOpen] = useState(false);++ const rawFilters = useSidebarStore((state) => state.channelItemFilters);+ const setFilters = useSidebarStore((state) => state.setChannelItemFilters);+ const sort = useSidebarStore((state) => state.channelItemSort);+ const setSort = useSidebarStore((state) => state.setChannelItemSort);+ const rawGrouping = useSidebarStore((state) => state.channelItemGrouping);+ const setGrouping = useSidebarStore((state) => state.setChannelItemGrouping);+ const grouping = hasRuns ? rawGrouping : "date";++ const client = useOptionalAuthenticatedClient();+ const { data: currentUser } = useCurrentUser({ client });+ const meUuid = currentUser?.uuid ?? null;+ const me = useMemo(() => ({ uuid: meUuid }), [meUuid]);++ const changeGrouping = (next: ChannelItemGrouping) => {+ if (next === grouping) return;+ setGrouping(next);+ track(ANALYTICS_EVENTS.TASK_LIST_GROUPING_CHANGED, {+ group_by: next,+ sort_by: channelItemSortEvent(sort),+ surface,+ });+ };++ const sources = useMemo(() => channelItemSources(items), [items]);+ const filters = useMemo<ChannelItemFilters>(() => {+ const sourceMissing =+ rawFilters.source !== ANY_SOURCE && !sources.includes(rawFilters.source);+ const scoped: ChannelItemFilters = {+ ...rawFilters,+ ...(hasMultipleAuthors ? {} : { createdBy: "anyone" as const }),+ ...(sourceMissing ? { source: ANY_SOURCE } : {}),+ };+ return hasRuns+ ? scoped+ : { ...scoped, attention: "any", environment: "any", source: ANY_SOURCE };+ }, [rawFilters, hasMultipleAuthors, hasRuns, sources]);+ const filtersActive = hasActiveChannelItemFilters(filters);++ const listItems = useMemo(() => {+ const ordered = sortChannelItems(+ filterChannelItems(items, { query, filters, me }),+ sort,+ );+ return cap === undefined ? ordered : ordered.slice(0, cap);+ }, [items, query, filters, sort, me, cap]);+ const dayStart = useLocalDayStart();+ const sections = useMemo(+ () => groupChannelItems(listItems, sort, new Date(dayStart), grouping),+ [listItems, sort, dayStart, grouping],+ );++ const pinnedItems =+ sections.find((section) => section.key === PINNED_SECTION_KEY)?.items ?? [];+ const datedSections = sections.filter(+ (section) => section.key !== PINNED_SECTION_KEY,+ );+ const showPinnedBadges = datedSections[0]?.label == null;++ const narrowed = filtersActive || query.trim().length > 0;+ const listState = listStateOf({+ isLoading,+ itemCount: items.length,+ narrowed,+ });+ const showHeader = listState === "ready" || listState === "empty";++ const {+ selectedTaskIds,+ clearSelection,+ bulkActions,+ archiveConfirm,+ marquee,+ listAnchorRef,+ onRowClick,+ } = useChannelItemSelection({ listItems, activeKey, open: actions.open });++ const prefersReducedMotion = useReducedMotion();+ const dragSiblingsFor = useCallback(+ (item: ChannelItemModel) =>+ item.kind === "task"+ ? taskDragSiblings(item.id, listItems, (candidate) =>+ candidate.kind === "task" ? candidate.id : null,+ )+ : [],+ [listItems],+ );+ const pinDrag = usePinDrag<ChannelItemModel>({+ isPinned: (item) => item.pinned,+ setPinned: actions.setPinned,+ getDragSiblings: dragSiblingsFor,+ });++ const rowTransition = prefersReducedMotion+ ? { duration: 0 }+ : {+ layout: { type: "spring" as const, stiffness: 520, damping: 42 },+ height: { duration: 0.16, ease: "easeOut" as const },+ opacity: { duration: 0.1 },+ };++ const taskRow = (item: ChannelItemModel, showPinBadge: boolean) => {+ const inSelection =+ item.kind === "task" && selectedTaskIds.includes(item.id);+ return (+ <motion.div+ key={item.key}+ initial={false}+ animate={+ pinDrag.drag?.items.some((dragged) => dragged.key === item.key)+ ? { height: 0, opacity: 0 }+ : { height: "auto", opacity: 1 }+ }+ transition={rowTransition}+ className="overflow-hidden"+ >+ <ChannelItemRow+ item={item}+ channelId={channelIdFor?.(item)}+ isActive={item.key === activeKey}+ isSelected={inSelection}+ showPinBadge={showPinBadge}+ bulk={+ inSelection && selectedTaskIds.length > 1+ ? {+ actions: bulkActions,+ onArchive: archiveConfirm.requestArchive,+ }+ : null+ }+ onContextMenuOpenChange={(open) => {+ if (open && !inSelection) clearSelection();+ }}+ actions={actions}+ onClick={(e) => onRowClick(item, e)}+ isEditing={item.kind === "task" && editingTaskId === item.id}+ onRename={+ item.kind === "task" ? () => setEditingTaskId(item.id) : undefined+ }+ onAddToCommandCenter={+ !isInCommandCenter(item, commandCenterCells)+ ? commandCenterAssigner(item)+ : undefined+ }+ onEditSubmit={+ item.kind === "task"+ ? async (newTitle) => {+ setEditingTaskId(null);+ try {+ await renameTask({+ taskId: item.id,+ currentTitle: item.title,+ newTitle,+ });+ } catch (error) {+ log.error("Failed to rename task", error);+ }+ }+ : undefined+ }+ onEditCancel={() => setEditingTaskId(null)}+ onDragStart={+ item.kind === "task"+ ? (event) => pinDrag.onItemDragStart(item, event)+ : undefined+ }+ onDragEnd={item.kind === "task" ? pinDrag.onItemDragEnd : undefined}+ />+ </motion.div>+ );+ };++ return (+ <div+ ref={listAnchorRef}+ className="relative flex min-h-0 flex-1 flex-col"+ data-testid="channel-items-pane"+ >+ {showHeader && (+ <div className="flex flex-col gap-1 border-border border-b px-2 py-1.5">+ {headerLeft && (+ <div className="flex flex-wrap items-center gap-0.5">+ {headerLeft}+ </div>+ )}+ <InputGroup className="h-7">+ <InputGroupAddon align="inline-start">+ <MagnifyingGlass size={12} className="text-muted-foreground" />+ </InputGroupAddon>+ <InputGroupInput+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ placeholder="Search…"+ aria-label={searchLabel}+ className="text-[12px]"+ />+ <InputGroupAddon align="inline-end">+ <ChannelFilterMenu+ filters={filters}+ onFilterChange={(key, value) =>+ setFilters({ ...rawFilters, [key]: value })+ }+ onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}+ sort={sort}+ onSortChange={setSort}+ grouping={grouping}+ onGroupingChange={changeGrouping}+ onEditAppearance={() => setAppearanceOpen(true)}+ sources={sources}+ showCreatedBy={hasMultipleAuthors}+ showRunFilters={hasRuns}+ active={filtersActive}+ />+ </InputGroupAddon>+ </InputGroup>+ </div>+ )}++ {/* biome-ignore lint/a11y/noStaticElementInteractions: drag-and-drop container */}+ <div+ aria-busy={isLoading}+ className="scroll-mask-4 min-h-0 flex-1 overflow-y-auto px-2 pt-1 pb-2"+ onDragOver={pinDrag.listProps.onDragOver}+ onDrop={pinDrag.listProps.onDrop}+ >+ {listState === "loading" && <ChannelItemsSkeleton />}+ {listState === "empty" && emptyState}+ {listState === "ready" &&+ (sections.length > 0 ? (+ <div className="flex flex-col gap-px">+ <PinnedRun+ dropRef={pinDrag.pinnedZoneRef}+ dragging={pinDrag.drag !== null}+ highlight={Boolean(+ pinDrag.drag?.overPinned && !pinDrag.drag.sourcePinned,+ )}+ hasItems={pinnedItems.length > 0}+ >+ {pinnedItems.map((item) => taskRow(item, showPinnedBadges))}+ </PinnedRun>+ {datedSections.map((section) => (+ <Fragment key={section.key}>+ {section.label && <MenuLabel>{section.label}</MenuLabel>}+ {section.items.map((item) => taskRow(item, true))}+ </Fragment>+ ))}+ </div>+ ) : (+ <Empty className="border-0 py-6">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <MagnifyingGlass size={18} />+ </EmptyMedia>+ <EmptyTitle>No matches</EmptyTitle>+ <EmptyDescription>+ Try a different search or clear the filters.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ ))}+ </div>+ {overlay}+ <MarqueeOverlay rect={marquee} />++ <SidebarBulkActionBar+ actions={bulkActions}+ onClearSelection={clearSelection}+ onArchive={archiveConfirm.requestArchive}+ />+ {archiveConfirm.dialog}++ {pinDrag.drag ? (+ <ChannelItemDragPreview+ drag={pinDrag.drag}+ x={pinDrag.previewX}+ y={pinDrag.previewY}+ />+ ) : null}+ <EditListItemAppearanceDialog+ surface={surface}+ open={appearanceOpen}+ onOpenChange={setAppearanceOpen}+ />+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.test.tsxindex 84abb559ce84..bfd088616db7 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.test.tsx@@ -58,6 +58,9 @@ vi.mock("@posthog/ui/features/canvas/components/ChannelsFab", () => ({vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({useChannels: () => ({ channels: [] }),}));+vi.mock("@posthog/ui/features/auth/authClient", () => ({+ useOptionalAuthenticatedClient: () => null,+}));vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({useCurrentUser: () => ({ data: { id: 1, email: "[email protected]" } }),}));@@ -269,7 +272,10 @@ describe("ChannelSidebar", () => {mocks.items = [item()];const { rerender } = renderSidebar();- await user.click(screen.getByRole("button", { name: "Search" }));+ await user.type(+ screen.getByRole("textbox", { name: "Search sessions" }),+ "no such session",+ );mocks.items = [];rerender(sidebar());diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsxindex f91ec38c70d2..4e7e3e5514ee 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx@@ -1,115 +1,37 @@import {ChatsCircleIcon,- MagnifyingGlass,PackageIcon,ShapesIcon,} from "@phosphor-icons/react";+import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";import {- ANY_SOURCE,- type ChannelItemFilters,- type ChannelItemGrouping,- type ChannelItemModel,- type ChannelItemSort,- channelItemSortEvent,- channelItemSources,- DEFAULT_CHANNEL_ITEM_FILTERS,- filterChannelItems,- groupChannelItems,- hasActiveChannelItemFilters,- PINNED_SECTION_KEY,- sortChannelItems,-} from "@posthog/core/canvas/channelItems";-import { getCanvasCellId } from "@posthog/core/command-center/grid";-import {- Button,- cn,Empty,EmptyDescription,EmptyHeader,EmptyMedia,EmptyTitle,- Input,- MenuLabel,- Skeleton,- SkeletonText,Tabs,TabsList,TabsTrigger,} from "@posthog/quill";import { LOOPS_FLAG } from "@posthog/shared";-import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";-import type { Task } from "@posthog/shared/domain-types";import { ChannelBackRow } from "@posthog/ui/features/canvas/components/ChannelBackRow";-import { ChannelFilterMenu } from "@posthog/ui/features/canvas/components/ChannelFilterMenu";-import { ChannelItemDragPreview } from "@posthog/ui/features/canvas/components/ChannelItemDragPreview";-import { ChannelItemRow } from "@posthog/ui/features/canvas/components/ChannelItemRow";+import { ChannelItemsPane } from "@posthog/ui/features/canvas/components/ChannelItemsPane";import { ChannelsFab } from "@posthog/ui/features/canvas/components/ChannelsFab";-import { cnHeaderButton } from "@posthog/ui/features/canvas/components/channelHeaderButton";import {type ChannelPageKey,channelPageLabel,} from "@posthog/ui/features/canvas/components/channelPages";import { useChannelItems } from "@posthog/ui/features/canvas/hooks/useChannelItems";import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";-import { useChannelTasksRunState } from "@posthog/ui/features/canvas/hooks/useChannelTasksRunState";-import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";import { SHORTCUTS } from "@posthog/ui/features/command/keyboard-shortcuts";-import { useCommandCenterStore } from "@posthog/ui/features/command-center/commandCenterStore";-import {- placeCanvasInCommandCenter,- placeTaskInCommandCenter,-} from "@posthog/ui/features/command-center/placeTaskInCommandCenter";import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";-import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";import { SidebarKbdHint } from "@posthog/ui/features/sidebar/components/items/SidebarKbdHint";-import { MarqueeOverlay } from "@posthog/ui/features/sidebar/components/MarqueeOverlay";-import { SidebarBulkActionBar } from "@posthog/ui/features/sidebar/components/SidebarBulkActionBar";import { SidebarItem } from "@posthog/ui/features/sidebar/components/SidebarItem";-import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";-import { taskDragSiblings } from "@posthog/ui/features/sidebar/taskDrag";-import { useTaskSelectionStore } from "@posthog/ui/features/sidebar/taskSelectionStore";-import { useBulkArchiveConfirm } from "@posthog/ui/features/sidebar/useBulkArchiveConfirm";-import { useClearSelectionOnEscape } from "@posthog/ui/features/sidebar/useClearSelectionOnEscape";-import { useMarqueeSelection } from "@posthog/ui/features/sidebar/useMarqueeSelection";-import { usePinDrag } from "@posthog/ui/features/sidebar/usePinDrag";-import { useSidebarBulkActions } from "@posthog/ui/features/sidebar/useSidebarBulkActions";-import { useRenameTask } from "@posthog/ui/features/tasks/useTaskMutations";-import { track } from "@posthog/ui/shell/analytics";-import { logger } from "@posthog/ui/shell/logger";import { useNavigate, useRouterState } from "@tanstack/react-router";-import { motion, useReducedMotion } from "framer-motion";-import {- Fragment,- useCallback,- useEffect,- useMemo,- useRef,- useState,-} from "react";+import { useMemo, useState } from "react";const RECENTS_CAP = 30;-const log = logger.scope("channel-sidebar");--function commandCenterAssigner(item: ChannelItemModel): () => void {- return () => {- if (item.kind === "canvas") {- placeCanvasInCommandCenter(item.id, item.title);- } else {- placeTaskInCommandCenter(item.id, item.title);- }- };-}--function isInCommandCenter(- item: ChannelItemModel,- commandCenterCells: readonly (string | null)[],-): boolean {- return commandCenterCells.some((cell) =>- item.kind === "canvas"- ? getCanvasCellId(cell) === item.id- : cell === item.id,- );-}/** The list holds two kinds of thing, and shows one of them at a time. */type ChannelTab = ChannelItemModel["kind"];@@ -122,154 +44,38 @@ const CHANNEL_TABS: readonly {{ value: "canvas", label: "Canvases" },];-function RecentSectionHeader({+function ChannelTabs({tab,- tabs,onTabChange,- searchOpen,- onToggleSearch,- query,- onQueryChange,- filters,- onFilterChange,- onClearFilters,- sort,- onSortChange,- grouping,- onGroupingChange,- onEditAppearance,- sources,- showCreatedBy,- showRunFilters,- filtersActive,}: {tab: ChannelTab;- tabs: readonly { value: ChannelTab; label: string }[];onTabChange: (tab: ChannelTab) => void;- searchOpen: boolean;- onToggleSearch: () => void;- query: string;- onQueryChange: (value: string) => void;- filters: ChannelItemFilters;- onFilterChange: <K extends keyof ChannelItemFilters>(- key: K,- value: ChannelItemFilters[K],- ) => void;- onClearFilters: () => void;- sort: ChannelItemSort;- onSortChange: (sort: ChannelItemSort) => void;- grouping: ChannelItemGrouping;- onGroupingChange: (grouping: ChannelItemGrouping) => void;- onEditAppearance: () => void;- 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;- filtersActive: boolean;}) {return (- <>- <div className="flex flex-wrap items-center gap-0.5">- {/* The tabs name the list, so it has no label of its own. Controls- wrap under the tabs when the sidebar is narrow, so tab labels are- never cut off. */}- <Tabs- value={tab}- onValueChange={(value: string) => onTabChange(value as ChannelTab)}- className="shrink-0"- >- {/* text-[13px] is the sidebar's own scale: quill's default tab is- sized for a page header, which reads as a heading over this list. */}- {/* quill-tabs-fill: the active/hover fills, from globals.css — they- can't be utilities here, see the rule's comment. */}- <TabsList- variant="line"- className="quill-tabs-fill h-auto gap-0.5 border-b-0"- >- {tabs.map(({ value, label }) => (- <TabsTrigger- key={value}- value={value}- className="shrink-0 rounded-sm px-2 py-0.5 text-[13px]"- >- <span className="whitespace-nowrap">{label}</span>- </TabsTrigger>- ))}- </TabsList>- </Tabs>- <div className="ml-auto flex items-center gap-0.5">- <Button- variant="default"- size="icon-xs"- aria-label="Search"- aria-pressed={searchOpen}- onClick={onToggleSearch}- className={cnHeaderButton(searchOpen)}+ <Tabs+ value={tab}+ onValueChange={(value: string) => onTabChange(value as ChannelTab)}+ className="shrink-0"+ >+ {/* text-[13px] is the sidebar's own scale: quill's default tab is+ sized for a page header, which reads as a heading over this list. */}+ {/* quill-tabs-fill: the active/hover fills, from globals.css — they+ can't be utilities here, see the rule's comment. */}+ <TabsList+ variant="line"+ className="quill-tabs-fill h-auto gap-0.5 border-b-0"+ >+ {CHANNEL_TABS.map(({ value, label }) => (+ <TabsTrigger+ key={value}+ value={value}+ className="shrink-0 rounded-sm px-2 py-0.5 text-[13px]">- <MagnifyingGlass size={14} />- </Button>- <ChannelFilterMenu- filters={filters}- onFilterChange={onFilterChange}- onClearFilters={onClearFilters}- sort={sort}- onSortChange={onSortChange}- grouping={grouping}- onGroupingChange={onGroupingChange}- onEditAppearance={onEditAppearance}- sources={sources}- showCreatedBy={showCreatedBy}- showRunFilters={showRunFilters}- active={filtersActive}- />- </div>- </div>- {searchOpen && (- <div className="px-1 pb-1">- <Input- autoFocus- value={query}- onChange={(event) => onQueryChange(event.target.value)}- placeholder="Search…"- aria-label={- tab === "canvas" ? "Search canvases" : "Search sessions"- }- className="h-6 text-[12px]"- />- </div>- )}- </>- );-}--// Varied widths, as percentages, so the loading state reads as the list it-// becomes rather than a stack of identical bars.-const SKELETON_ROW_WIDTHS = [60, 80, 40, 75, 50, 66] as const;--function ChannelItemsSkeleton() {- return (- <div aria-hidden className="flex flex-col gap-px">- {/* Stands in for the tabs row, so it carries that row's scale. */}- <SkeletonText- lines={1}- maxWidth={100}- className="mx-2 mt-1.5 mb-1 w-12 text-xs"- />- {SKELETON_ROW_WIDTHS.map((width) => (- <div key={width} className="flex items-center gap-2 px-2 py-1.5">- <Skeleton className="size-4 shrink-0 rounded" />- {/* SkeletonText sizes its bar off the line it stands in — text-[13px]- is a row's own type scale, so the placeholder is the height of the- title it becomes rather than a fixed pill. */}- <SkeletonText- lines={1}- maxWidth={width}- className="min-w-0 flex-1 text-[13px] leading-snug"- />- </div>- ))}- </div>+ <span className="whitespace-nowrap">{label}</span>+ </TabsTrigger>+ ))}+ </TabsList>+ </Tabs>);}@@ -298,34 +104,6 @@ function TabEmptyState({ tab }: { tab: ChannelTab }) {);}-/** `ready` is the list itself, whether or not the filters leave any rows in it. */-type ListState = "unavailable" | "loading" | "empty" | "ready";--/**- * What the list shows, decided in one place. These were four conditions spread- * across the render tree, which let a cold load draw the skeleton and the "No- * matches" empty state at the same time.- *- * `narrowed` — a filter, or an open search box — is what makes no items mean- * "nothing matches" rather than "nothing here".- */-function listStateOf({- channelMissing,- isLoading,- itemCount,- narrowed,-}: {- channelMissing: boolean;- isLoading: boolean;- itemCount: number;- narrowed: boolean;-}): ListState {- if (channelMissing) return "unavailable";- if (isLoading && itemCount === 0) return "loading";- if (itemCount === 0 && !narrowed) return "empty";- return "ready";-}-/*** The channel pane of the sidebar slider: the way back to the channel list,* the channel's sections, then its pinned and recent tasks & canvases.@@ -342,95 +120,27 @@ export function ChannelSidebar({ channelId }: { channelId: string }) {});const loopsEnabled = useFeatureFlag(LOOPS_FLAG);- const { items, actions, me, isLoading, channelMissing } =+ const { items, actions, isLoading, channelMissing } =useChannelItems(channelId);- // Inline rename is the only thing left of the old native-menu hook here: the- // row's menu is a quill one now, so this surface no longer reaches into the- // main process to draw it.- const [editingTaskId, setEditingTaskId] = useState<string | null>(null);- const { renameTask } = useRenameTask();- const commandCenterCells = useCommandCenterStore((state) => state.cells);- // A space opens on its sessions. The pane stays mounted across a space- // switch, so the tab is stored against the space it was chosen in rather than- // carried into the next one; the filters below deliberately do carry over.const [chosenTab, setChosenTab] = useState({channelId,tab: "task" as ChannelTab,});const tab = chosenTab.channelId === channelId ? chosenTab.tab : "task";const setTab = (next: ChannelTab) => setChosenTab({ channelId, tab: next });- const [searchOpen, setSearchOpen] = useState(false);- const [query, setQuery] = useState("");- const rawFilters = useSidebarStore((state) => state.channelItemFilters);- const setFilters = useSidebarStore((state) => state.setChannelItemFilters);- const sort = useSidebarStore((state) => state.channelItemSort);- const setSort = useSidebarStore((state) => state.setChannelItemSort);- const rawGrouping = useSidebarStore((state) => state.channelItemGrouping);- const setGrouping = useSidebarStore((state) => state.setChannelItemGrouping);- // Canvases carry no repository, so grouping by one would file the whole tab- // under a single heading. Neutralised as well as hidden, the way the run- // filters above are.- const grouping = tab === "canvas" ? "date" : rawGrouping;- const [appearanceOpen, setAppearanceOpen] = useState(false);- const changeGrouping = (next: ChannelItemGrouping) => {- if (next === grouping) return;- setGrouping(next);- track(ANALYTICS_EVENTS.TASK_LIST_GROUPING_CHANGED, {- group_by: next,- sort_by: channelItemSortEvent(sort),- surface: "space",- });- };- // Every session in #me is yours, so the author filter has nothing to sort by.- // The state survives a space switch, so the value is neutralised here as well- // as hidden — otherwise "Other people" carried in from a shared space would- // empty this list with no visible control to undo it.+const { channels } = useChannels();// By type, not by name: the list relabels the personal channel on the way in,// so its name is no longer the backend's.const channel = channels.find((c) => c.id === channelId);const isPersonalChannel = channel?.channelType === "personal";- const visibleTabs = CHANNEL_TABS;// The tab is the list, so everything below it — the filters, the empty state,// the sections — is about one kind of thing at a time.const tabItems = useMemo(() => items.filter((item) => item.kind === tab),[items, tab],);- // The menu only offers sources the list holds, so it is built from everything- // in the tab rather than from what the current filters left behind — picking- // one source must not be what removes the others from the menu.- const sources = useMemo(() => channelItemSources(tabItems), [tabItems]);- // A canvas has no run, so the three run filters can only ever empty the- // canvases tab. Same treatment as createdBy above: neutralised as well as- // hidden, or a choice made on the sessions tab would empty this one.- //- // A source the tab has none of goes the same way, and for the same reason: it- // would empty the list while its submenu shows no chosen option, so there'd be- // nothing to switch off. Rows arriving later put the source back, because the- // stored filter is untouched.- const filters = useMemo<ChannelItemFilters>(() => {- const sourceMissing =- rawFilters.source !== ANY_SOURCE && !sources.includes(rawFilters.source);- const scoped =- isPersonalChannel || sourceMissing- ? {- ...rawFilters,- ...(isPersonalChannel ? { createdBy: "anyone" as const } : {}),- ...(sourceMissing ? { source: ANY_SOURCE } : {}),- }- : rawFilters;- return tab === "canvas"- ? {- ...scoped,- attention: "any",- environment: "any",- source: ANY_SOURCE,- }- : scoped;- }, [isPersonalChannel, rawFilters, sources, tab]);- const filtersActive = hasActiveChannelItemFilters(filters);const base = `/spaces/${channelId}`;// Activeness is a key comparison rather than a flag baked into each item, so@@ -442,258 +152,6 @@ export function ChannelSidebar({ channelId }: { channelId: string }) {return task ? `task:${task[1]}` : null;}, [pathname]);- // Pins sort to the top because a pin is a request not to lose the thing:- // below the chosen order it would fall off the end of the cap. The cap is- // applied to the flat list, before the sections, so the number of rows a- // reader gets doesn't depend on how many days they span.- const recentItems = useMemo(- () =>- sortChannelItems(- filterChannelItems(tabItems, { query, filters, me }),- sort,- ).slice(0, RECENTS_CAP),- [tabItems, query, filters, sort, me],- );- // Dated against the day rather than the moment, so the headers follow local- // midnight even when the list itself hasn't changed for hours.- const dayStart = useLocalDayStart();- const sections = useMemo(- () => groupChannelItems(recentItems, sort, new Date(dayStart), grouping),- [recentItems, sort, dayStart, grouping],- );-- const pinnedSection = sections.find(- (section) => section.key === PINNED_SECTION_KEY,- );- const datedSections = sections.filter(- (section) => section.key !== PINNED_SECTION_KEY,- );- // Under "Pinned" every row wears the same badge, so the header says it once- // instead, but only while a header below marks where the pins stop. An- // alphabetical run carries no header, so there the badges stay.- const showPinnedBadges = datedSections[0]?.label == null;-- const narrowed = filtersActive || searchOpen;- const listState = listStateOf({- channelMissing,- isLoading,- itemCount: tabItems.length,- narrowed,- });- // The header stays while the list is narrowed, so you can undo whatever- // emptied it — and while a tab is empty, so you can leave that tab.- const showHeader = listState === "ready" || listState === "empty";-- // Only sessions take part in a bulk selection: a canvas can't be archived,- // filed, or tiled the way a session can, so modifier-clicking one just opens it.- const selectableTaskIds = useMemo(- () => recentItems.filter((i) => i.kind === "task").map((i) => i.id),- [recentItems],- );- const selectedTaskIds = useTaskSelectionStore((s) => s.selectedTaskIds);- const toggleTaskSelection = useTaskSelectionStore(- (s) => s.toggleTaskSelection,- );- const selectRange = useTaskSelectionStore((s) => s.selectRange);- const clearSelection = useTaskSelectionStore((s) => s.clearSelection);- const pruneSelection = useTaskSelectionStore((s) => s.pruneSelection);- useClearSelectionOnEscape();- const listAnchorRef = useRef<HTMLDivElement | null>(null);- const marquee = useMarqueeSelection(listAnchorRef);- const prefersReducedMotion = useReducedMotion();- // A drag that starts on a selected row carries the whole selection, so a pin- // or an unpin applies to every row the user picked, not just the grabbed one.- const dragSiblingsFor = useCallback(- (item: ChannelItemModel) =>- item.kind === "task"- ? taskDragSiblings(item.id, recentItems, (candidate) =>- candidate.kind === "task" ? candidate.id : null,- )- : [],- [recentItems],- );- const pinDrag = usePinDrag<ChannelItemModel>({- isPinned: (item) => item.pinned,- setPinned: actions.setPinned,- getDragSiblings: dragSiblingsFor,- });-- useEffect(() => {- pruneSelection(selectableTaskIds);- }, [selectableTaskIds, pruneSelection]);-- // A bulk action acts on exactly the rows that are highlighted. The open- // session used to be folded in as well, which told you "2 selected" after one- // cmd-click and archived a session you never picked.- const activeTaskId = activeKey?.startsWith("task:")- ? activeKey.slice("task:".length)- : null;-- const selectedTasks = useMemo(() => {- const selected = new Set(selectedTaskIds);- return recentItems- .filter(- (i): i is ChannelItemModel & { task: Task } =>- i.kind === "task" && i.task !== null && selected.has(i.id),- )- .map((i) => i.task);- }, [recentItems, selectedTaskIds]);- const selectedTasksRunState = useChannelTasksRunState(selectedTasks);- const bulkActions = useSidebarBulkActions(- selectedTaskIds,- selectedTasksRunState,- );- const archiveConfirm = useBulkArchiveConfirm(bulkActions);-- const handleRowClick = (item: ChannelItemModel, e: React.MouseEvent) => {- if (item.kind !== "task") {- actions.open(item);- return;- }- if (e.shiftKey) {- e.preventDefault();- selectRange(item.id, selectableTaskIds, activeTaskId);- return;- }- if (e.metaKey || e.ctrlKey) {- e.preventDefault();- toggleTaskSelection(item.id);- return;- }- clearSelection();- actions.open(item);- };-- const rowTransition = prefersReducedMotion- ? { duration: 0 }- : {- layout: { type: "spring" as const, stiffness: 520, damping: 42 },- height: { duration: 0.16, ease: "easeOut" as const },- opacity: { duration: 0.1 },- };-- /**- * The pinned run, doubling as the box that decides pin from unpin. Always- * rendered, empty or not, and it opens on a drag rather than appearing. See- * below for why nothing here may jump into place.- */- const pinnedRun = () => {- const drag = pinDrag.drag;- const pinnedItems = pinnedSection?.items ?? [];- return (- <div- key={PINNED_SECTION_KEY}- ref={pinDrag.pinnedZoneRef}- className={cn(- // `min-h-0` is the resting end of the transition. min-height starts at- // `auto`, which is not interpolable, so without it the run snaps open.- "flex min-h-0 flex-col gap-px rounded-md transition-[min-height,background-color] duration-150 ease-out motion-reduce:transition-none",- // A floor, not a height, so a taller run keeps its own.- drag && "min-h-[100px]",- drag?.overPinned &&- !drag.sourcePinned &&- "bg-accent-2 ring-1 ring-accent-6",- )}- >- {/* Opened by a transition rather than by appearing: a drag dies at- birth if anything above its source jumps in the same frame as- `dragstart`. Grid rows, so the label keeps its own height. */}- <div- className={cn(- "grid transition-[grid-template-rows] duration-150 ease-out motion-reduce:transition-none",- pinnedItems.length > 0 || drag- ? "grid-rows-[1fr]"- : "grid-rows-[0fr]",- )}- >- <div className="overflow-hidden">- <MenuLabel>Pinned</MenuLabel>- </div>- </div>- {pinnedItems.map((item) => taskRow(item, showPinnedBadges))}- </div>- );- };-- // Every row gets the wrapper, not just the dragged one. Swapping a row- // between wrapped and bare remounts it, and Chromium ends a native drag the- // moment its source leaves the DOM.- const taskRow = (item: (typeof items)[number], showPinBadge: boolean) => {- const inSelection =- item.kind === "task" && selectedTaskIds.includes(item.id);- return (- <motion.div- key={item.key}- initial={false}- animate={- pinDrag.drag?.items.some((dragged) => dragged.key === item.key)- ? { height: 0, opacity: 0 }- : { height: "auto", opacity: 1 }- }- transition={rowTransition}- className="overflow-hidden"- >- <ChannelItemRow- item={item}- channelId={channelId}- isActive={item.key === activeKey}- isSelected={inSelection}- showPinBadge={showPinBadge}- // Right-clicking inside a selection acts on the selection; right-clicking- // outside it drops the selection first, so the menu that opens is about- // the row under the pointer and nothing else.- bulk={- inSelection && selectedTaskIds.length > 1- ? {- actions: bulkActions,- onArchive: archiveConfirm.requestArchive,- }- : null- }- onContextMenuOpenChange={(open) => {- if (open && !inSelection) clearSelection();- }}- actions={actions}- onClick={(e) => handleRowClick(item, e)}- isEditing={item.kind === "task" && editingTaskId === item.id}- onRename={- item.kind === "task" ? () => setEditingTaskId(item.id) : undefined- }- // Undefined disables the menu item when this item is already present;- // duplicating the same task or canvas would make the grid ambiguous.- onAddToCommandCenter={- !isInCommandCenter(item, commandCenterCells)- ? commandCenterAssigner(item)- : undefined- }- onEditSubmit={- item.kind === "task"- ? async (newTitle) => {- setEditingTaskId(null);- try {- await renameTask({- taskId: item.id,- currentTitle: item.title,- newTitle,- });- } catch (error) {- log.error("Failed to rename task", error);- }- }- : undefined- }- onEditCancel={() => setEditingTaskId(null)}- onDragStart={- item.kind === "task"- ? (event) => pinDrag.onItemDragStart(item, event)- : undefined- }- onDragEnd={item.kind === "task" ? pinDrag.onItemDragEnd : undefined}- />- </motion.div>- );- };-// Label comes from the shared space-page table, so a sidebar row and the// header breadcrumb for the same page can never disagree. No icon: this is a// short list of words, and glyphs here only compete with the status dots@@ -759,132 +217,39 @@ export function ChannelSidebar({ channelId }: { channelId: string }) {)}</div>- {/* Relative so the FAB and the drag-selection band can float over the- list. The tabs sit above the scroll container rather than in it: they- are how you leave whatever the list is showing, so they can't scroll- away with it. */}- <div- ref={listAnchorRef}- className="relative mt-2 flex min-h-0 flex-1 flex-col"- >- {showHeader && (- <div className="border-border border-b px-2">- <RecentSectionHeader- tab={tab}- tabs={visibleTabs}- onTabChange={setTab}- searchOpen={searchOpen}- onToggleSearch={() => {- if (searchOpen) setQuery("");- setSearchOpen(!searchOpen);- }}- query={query}- onQueryChange={setQuery}- filters={filters}- // Written against the stored filters, not the narrowed ones the- // menu displays: a choice made under one tab has to survive a- // write made under another.- onFilterChange={(key, value) =>- setFilters({ ...rawFilters, [key]: value })- }- onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}- sort={sort}- onSortChange={setSort}- grouping={grouping}- onGroupingChange={changeGrouping}- onEditAppearance={() => setAppearanceOpen(true)}- sources={sources}- showCreatedBy={!isPersonalChannel}- showRunFilters={tab === "task"}- filtersActive={filtersActive}- />- </div>+ <div className="mt-2 flex min-h-0 flex-1 flex-col">+ {channelMissing ? (+ <Empty className="border-0 py-6">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <PackageIcon size={18} />+ </EmptyMedia>+ <EmptyTitle>Space unavailable</EmptyTitle>+ <EmptyDescription>+ It may have been deleted, or belong to another project.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ ) : (+ <ChannelItemsPane+ items={tabItems}+ isLoading={isLoading}+ actions={actions}+ activeKey={activeKey}+ surface="space"+ headerLeft={<ChannelTabs tab={tab} onTabChange={setTab} />}+ hasMultipleAuthors={!isPersonalChannel}+ hasRuns={tab === "task"}+ cap={RECENTS_CAP}+ channelIdFor={() => channelId}+ emptyState={<TabEmptyState tab={tab} />}+ overlay={<ChannelsFab channelId={channelId} />}+ searchLabel={+ tab === "canvas" ? "Search canvases" : "Search sessions"+ }+ />)}- {/* Pin and unpin stay reachable from the row's menu and its context- menu, so the drag adds no keyboard-only path. */}-- {/* biome-ignore lint/a11y/noStaticElementInteractions: drag-and-drop container */}- <div- aria-busy={isLoading}- className="scroll-mask-4 min-h-0 flex-1 overflow-y-auto px-2 pt-1 pb-2"- onDragOver={pinDrag.listProps.onDragOver}- onDrop={pinDrag.listProps.onDrop}- >- {listState === "loading" && <ChannelItemsSkeleton />}-- {listState === "unavailable" && (- <Empty className="border-0 py-6">- <EmptyHeader>- <EmptyMedia variant="icon">- <PackageIcon size={18} />- </EmptyMedia>- <EmptyTitle>Space unavailable</EmptyTitle>- <EmptyDescription>- It may have been deleted, or belong to another project.- </EmptyDescription>- </EmptyHeader>- </Empty>- )}-- {showHeader &&- (listState === "empty" ? (- <TabEmptyState tab={tab} />- ) : sections.length > 0 ? (- <div className="flex flex-col gap-px">- {/* Always mounted, empty or not. Inserting the run on- dragstart restructures the list under the dragged row, and- Chromium ends the drag on the spot: dragstart, then dragend,- before the pointer moves. Growing one already there is- fine. */}- {pinnedRun()}- {datedSections.map((section) => (- <Fragment key={section.key}>- {section.label && <MenuLabel>{section.label}</MenuLabel>}- {section.items.map((item) => taskRow(item, true))}- </Fragment>- ))}- </div>- ) : (- <Empty className="border-0 py-6">- <EmptyHeader>- <EmptyMedia variant="icon">- <MagnifyingGlass size={18} />- </EmptyMedia>- <EmptyTitle>No matches</EmptyTitle>- <EmptyDescription>- Try a different search or clear the filters.- </EmptyDescription>- </EmptyHeader>- </Empty>- ))}- </div>- <ChannelsFab channelId={channelId} />- <MarqueeOverlay rect={marquee} /></div>-- {/* Below the list rather than floating over it: the bottom rows are where- a shift-click range usually ends, and the FAB already sits there. */}- <SidebarBulkActionBar- actions={bulkActions}- onClearSelection={clearSelection}- onArchive={archiveConfirm.requestArchive}- />- {archiveConfirm.dialog}-- {pinDrag.drag ? (- <ChannelItemDragPreview- drag={pinDrag.drag}- x={pinDrag.previewX}- y={pinDrag.previewY}- />- ) : null}- {/* The list owns the dialog, as it owns every other piece of this- surface's state; the menu only asks for it to open. */}- <EditListItemAppearanceDialog- surface="space"- open={appearanceOpen}- onOpenChange={setAppearanceOpen}- /></div>);}diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsxindex 2f80ff15777a..7fa10452d254 100644--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx@@ -72,10 +72,14 @@ vi.mock("@posthog/ui/router/navigationBridge", () => ({navigateToChannel: (...a: unknown[]) => mocks.navigateToChannel(...a),navigateToHome: (...a: unknown[]) => mocks.navigateToHome(...a),navigateToInbox: (...a: unknown[]) => mocks.navigateToInbox(...a),+ navigateToFeeds: vi.fn(),navigateToLoops: vi.fn(),navigateToCommandCenter: vi.fn(),navigateToSpacesContext: vi.fn(),}));+vi.mock("@posthog/ui/features/canvas/hooks/useProjectTaskFeeds", () => ({+ useProjectTaskFeeds: () => [],+}));vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));vi.mock("@posthog/ui/features/canvas/components/ActivityHoverCard", () => ({ActivityHoverCard: () => <div>Recent activity card</div>,diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsxindex f026c7e0853d..491130c5e53c 100644--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx@@ -10,7 +10,11 @@ import {TooltipProvider,TooltipTrigger,} from "@posthog/quill";-import { DESKTOP_HOME_FLAG, LOOPS_FLAG } from "@posthog/shared";+import {+ DESKTOP_HOME_FLAG,+ LOOPS_FLAG,+ SAVED_SEARCHES_RAIL_FLAG,+} from "@posthog/shared";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import { useOpenBrowserTab } from "@posthog/ui/features/browser-tabs/useOpenBrowserTab";import { useSpacesTabs } from "@posthog/ui/features/browser-tabs/useSpacesTabs";@@ -21,6 +25,7 @@ import {type RailDestination,visibleRailDestinations,} 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 { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";@@ -190,12 +195,21 @@ function NavRailImpl() {(state) => state.mentionsEnabled,);+ const savedSearchesRailEnabled = useFeatureFlag(SAVED_SEARCHES_RAIL_FLAG);+ const hasSavedSearches = useProjectTaskFeeds().length > 0;const destinations = visibleRailDestinations({home: homeEnabled,inbox: inboxAvailable,loops: loopsEnabled,context: contextEnabled,+ savedSearches: savedSearchesRailEnabled && hasSavedSearches,});+ const topDestinations = destinations.filter(+ ({ placement }) => placement !== "bottom",+ );+ const bottomDestinations = destinations.filter(+ ({ placement }) => placement === "bottom",+ );const inboxVisible = destinations.some(({ pane }) => pane === "inbox");const inboxDecisionCount = useInboxDecisionCount({enabled: inboxVisible,@@ -231,6 +245,61 @@ function NavRailImpl() {pickRailDestination(destination, railPane);};+ const renderDestination = (destination: RailDestination): ReactNode => {+ const { pane, label, Icon, count, countTone } = destination;+ const isActive = railPane === pane;+ const destinationCount = count?.(counts) ?? 0;+ const usesNotificationDot = pane === "activity" || pane === "inbox";+ let badge: ReactNode;+ if (usesNotificationDot) {+ badge =+ destinationCount > 0 ? (+ <span+ data-slot="dot"+ className={NOTIFICATION_DOT_CLASS}+ aria-hidden+ />+ ) : null;+ } else {+ badge = (+ <CountBadge+ count={destinationCount}+ tone={countTone}+ className={ICON_BADGE_CLASS}+ />+ );+ }+ const onClick = pick(destination);++ if (pane === "activity") {+ return (+ <ActivityNavItem+ key={pane}+ isActive={isActive}+ badge={badge}+ onClick={onClick}+ />+ );+ }+ return (+ <NavIcon+ key={pane}+ icon={+ <Icon+ className={pane === "spaces" ? "size-5" : undefined}+ size={pane === "spaces" ? 20 : 16}+ weight={isActive ? "fill" : "regular"}+ />+ }+ label={label}+ shortcut={destination.shortcut}+ isActive={isActive}+ onClick={onClick}+ badge={badge}+ />+ );+ };+return (// One provider for the whole rail: the tooltip skip window is provider// state, so isolated providers never share it.@@ -240,61 +309,9 @@ function NavRailImpl() {className="relative z-[60] flex h-full shrink-0 flex-col items-center gap-1.5 bg-chrome py-2"style={{ width: NAV_RAIL_WIDTH }}>- {destinations.map((destination) => {- const { pane, label, Icon, count, countTone } = destination;- const isActive = railPane === pane;- const destinationCount = count?.(counts) ?? 0;- const usesNotificationDot = pane === "activity" || pane === "inbox";- let badge: ReactNode;- if (usesNotificationDot) {- badge =- destinationCount > 0 ? (- <span- data-slot="dot"- className={NOTIFICATION_DOT_CLASS}- aria-hidden- />- ) : null;- } else {- badge = (- <CountBadge- count={destinationCount}- tone={countTone}- className={ICON_BADGE_CLASS}- />- );- }- const onClick = pick(destination);-- if (pane === "activity") {- return (- <ActivityNavItem- key={pane}- isActive={isActive}- badge={badge}- onClick={onClick}- />- );- }- return (- <NavIcon- key={pane}- icon={- <Icon- className={pane === "spaces" ? "size-5" : undefined}- size={pane === "spaces" ? 20 : 16}- weight={isActive ? "fill" : "regular"}- />- }- label={label}- shortcut={destination.shortcut}- isActive={isActive}- onClick={onClick}- badge={badge}- />- );- })}+ {topDestinations.map(renderDestination)}<div className="mt-auto flex flex-col items-center gap-1.5">+ {bottomDestinations.map(renderDestination)}<NavIconicon={<MagnifyingGlass size={16} />}label="Search"diff --git a/products/desktop/packages/ui/src/features/canvas/components/PinnedRun.tsx b/products/desktop/packages/ui/src/features/canvas/components/PinnedRun.tsxnew file mode 100644index 000000000000..2557b7f36160--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/PinnedRun.tsx@@ -0,0 +1,39 @@+import { cn, MenuLabel } from "@posthog/quill";+import type { ReactNode, RefObject } from "react";++export function PinnedRun({+ dropRef,+ dragging,+ highlight,+ hasItems,+ children,+}: {+ dropRef: RefObject<HTMLDivElement | null>;+ dragging: boolean;+ highlight: boolean;+ hasItems: boolean;+ children: ReactNode;+}) {+ return (+ <div+ ref={dropRef}+ className={cn(+ "flex min-h-0 flex-col gap-px rounded-md transition-[min-height,background-color] duration-150 ease-out motion-reduce:transition-none",+ dragging && "min-h-[100px]",+ highlight && "bg-accent-2 ring-1 ring-accent-6",+ )}+ >+ <div+ className={cn(+ "grid transition-[grid-template-rows] duration-150 ease-out motion-reduce:transition-none",+ hasItems || dragging ? "grid-rows-[1fr]" : "grid-rows-[0fr]",+ )}+ >+ <div className="overflow-hidden">+ <MenuLabel>Pinned</MenuLabel>+ </div>+ </div>+ {children}+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.test.tsxnew file mode 100644index 000000000000..184e25bd86f0--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.test.tsx@@ -0,0 +1,91 @@+import { Theme } from "@radix-ui/themes";+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { beforeEach, describe, expect, it, vi } from "vitest";++const navigate = vi.fn();+vi.mock("@tanstack/react-router", () => ({ useNavigate: () => navigate }));+vi.mock("@posthog/ui/features/canvas/components/FeedQueryHighlight", () => ({+ FeedQueryHighlight: ({ query }: { query: string }) => <span>{query}</span>,+}));+vi.mock("@posthog/ui/features/canvas/hooks/useProjectTaskFeeds", () => ({+ useProjectTaskFeeds: () => useTaskFeedsStore.getState().feeds,+}));+vi.mock("@posthog/quill", async (importOriginal) => {+ const actual = await importOriginal<typeof import("@posthog/quill")>();+ return {+ ...actual,+ DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,+ DropdownMenuContent: ({ children }: { children: ReactNode }) => (+ <div>{children}</div>+ ),+ DropdownMenuItem: ({+ children,+ onClick,+ }: {+ children: ReactNode;+ onClick?: () => void;+ }) => (+ <button type="button" onClick={onClick}>+ {children}+ </button>+ ),+ DropdownMenuTrigger: ({ render }: { render: ReactElement }) => render,+ };+});++import { useTaskFeedsStore } from "@posthog/ui/features/canvas/stores/taskFeedsStore";+import type { ReactElement, ReactNode } from "react";+import { SavedSearchSwitcher } from "./SavedSearchSwitcher";++describe("SavedSearchSwitcher", () => {+ beforeEach(() => {+ navigate.mockClear();+ useTaskFeedsStore.setState({+ feeds: [+ {+ id: "feed-1",+ projectId: 1,+ ownerId: "user-1",+ name: "Billing work",+ query: "billing",+ createdAt: "2026-08-01T00:00:00Z",+ },+ {+ id: "feed-2",+ projectId: 1,+ ownerId: "user-1",+ name: "Onboarding",+ query: "welcome",+ createdAt: "2026-08-01T00:00:00Z",+ },+ ],+ });+ });++ it("shows the current saved search name as the trigger", () => {+ render(+ <Theme>+ <SavedSearchSwitcher currentFeedId="feed-1" />+ </Theme>,+ );+ const trigger = screen.getByRole("button", { name: "Switch saved search" });+ expect(trigger).toHaveTextContent("Billing work");+ });++ it("switches to another saved search from the dropdown", async () => {+ const user = userEvent.setup();+ render(+ <Theme>+ <SavedSearchSwitcher currentFeedId="feed-1" />+ </Theme>,+ );++ await user.click(screen.getByText("Onboarding"));++ expect(navigate).toHaveBeenCalledWith({+ to: "/feeds/$feedId",+ params: { feedId: "feed-2" },+ });+ });+});diff --git a/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.tsx b/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.tsxnew file mode 100644index 000000000000..0cbb8a788596--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/SavedSearchSwitcher.tsx@@ -0,0 +1,93 @@+import { CaretDownIcon, CheckIcon } from "@phosphor-icons/react";+import {+ Button,+ cn,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+ Text,+} from "@posthog/quill";+import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";+import { useNavigate } from "@tanstack/react-router";+import type { ReactElement } from "react";++export function SavedSearchSwitcher({+ currentFeedId,+ className,+}: {+ currentFeedId: string;+ className?: string;+}): ReactElement {+ const navigate = useNavigate();+ const feeds = useProjectTaskFeeds();+ const current = feeds.find((feed) => feed.id === currentFeedId);++ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ type="button"+ variant="default"+ size="sm"+ aria-label="Switch saved search"+ className={cn("-ml-1.5 min-w-0 shrink gap-1 px-1.5", className)}+ >+ <span className="min-w-0 truncate font-bold text-base">+ {current?.name ?? "Saved search"}+ </span>+ <CaretDownIcon+ size={12}+ weight="bold"+ className="shrink-0 text-muted-foreground"+ />+ </Button>+ }+ />+ <DropdownMenuContent+ align="start"+ side="bottom"+ sideOffset={6}+ className="min-w-64 max-w-80"+ >+ {feeds.length === 0 ? (+ <div className="px-2 py-1.5">+ <Text variant="muted" size="sm">+ No saved searches in this project yet.+ </Text>+ </div>+ ) : (+ feeds.map((feed) => {+ const isCurrent = feed.id === currentFeedId;+ return (+ <DropdownMenuItem+ key={feed.id}+ onClick={() =>+ void navigate({+ to: "/feeds/$feedId",+ params: { feedId: feed.id },+ })+ }+ >+ <CheckIcon+ size={12}+ weight="bold"+ className={cn("shrink-0", !isCurrent && "opacity-0")}+ />+ <span+ className={cn(+ "min-w-0 truncate",+ isCurrent && "font-semibold",+ )}+ >+ {feed.name}+ </span>+ </DropdownMenuItem>+ );+ })+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.test.tsxindex ef7b7d8dc539..4e7de3f9ce4a 100644--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.test.tsx@@ -11,8 +11,8 @@ vi.mock("@tanstack/react-router", () => ({ useNavigate: () => vi.fn() }));vi.mock("@posthog/ui/hooks/useSetHeaderContent", () => ({useSetHeaderContent: vi.fn(),}));-vi.mock("@posthog/ui/features/canvas/components/ChannelBreadcrumb", () => ({- ChannelBreadcrumb: () => null,+vi.mock("@posthog/ui/features/canvas/components/SavedSearchSwitcher", () => ({+ SavedSearchSwitcher: () => null,}));vi.mock("@posthog/ui/features/canvas/components/ChannelFeedView", () => ({ChannelFeedView: ({ intro }: { intro?: ReactNode }) => intro,diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.tsxindex ed88cf638b8c..655edf37c66b 100644--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedHome.tsx@@ -3,41 +3,23 @@ import {PencilSimpleIcon,TrashIcon,} from "@phosphor-icons/react";-import {- AlertDialog,- AlertDialogClose,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,- Button,- Heading,- Skeleton,- Text,-} from "@posthog/quill";+import { Button, Heading, Skeleton, Text } from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import type { Task } from "@posthog/shared/domain-types";-import { ChannelBreadcrumb } from "@posthog/ui/features/canvas/components/ChannelBreadcrumb";import { ChannelFeedView } from "@posthog/ui/features/canvas/components/ChannelFeedView";import { FeedQueryHighlight } from "@posthog/ui/features/canvas/components/FeedQueryInput";-import { TaskFeedModal } from "@posthog/ui/features/canvas/components/TaskFeedModal";+import { SavedSearchSwitcher } from "@posthog/ui/features/canvas/components/SavedSearchSwitcher";import { useProjectTaskFeed } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";+import { useSavedSearchActions } from "@posthog/ui/features/canvas/hooks/useSavedSearchActions";import { useTaskFeedResults } from "@posthog/ui/features/canvas/hooks/useTaskFeedResults";-import { useTaskFeedsStore } from "@posthog/ui/features/canvas/stores/taskFeedsStore";import type { ThreadPanelTab } from "@posthog/ui/features/canvas/stores/threadPanelStore";import { openRightPanelSide } from "@posthog/ui/features/navigation/rightPanelSide";-import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";-import { toast } from "@posthog/ui/primitives/toast";import { openTask } from "@posthog/ui/router/useOpenTask";import { track } from "@posthog/ui/shell/analytics";-import { useNavigate } from "@tanstack/react-router";-import { useCallback, useEffect, useMemo, useState } from "react";+import { useCallback, useEffect } from "react";export function TaskFeedHome({ feedId }: { feedId: string }) {- const navigate = useNavigate();const feed = useProjectTaskFeed(feedId);- const removeFeed = useTaskFeedsStore((s) => s.removeFeed);const {canRetry,error,@@ -49,8 +31,7 @@ export function TaskFeedHome({ feedId }: { feedId: string }) {refetch,tasks,} = useTaskFeedResults(feed?.query);- const [editOpen, setEditOpen] = useState(false);- const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);+ const { openEdit, requestDelete, dialogs } = useSavedSearchActions(feed);const trackedFeedId = feed?.id;useEffect(() => {@@ -62,13 +43,6 @@ export function TaskFeedHome({ feedId }: { feedId: string }) {});}, [trackedFeedId]);- useSetHeaderContent(- useMemo(- () => <ChannelBreadcrumb channelName={feed?.name ?? "Feed"} />,- [feed?.name],- ),- );-const handleOpenTask = useCallback((task: Task) => {void openTask(task, { channelId: task.channel ?? undefined });}, []);@@ -81,18 +55,6 @@ export function TaskFeedHome({ feedId }: { feedId: string }) {[handleOpenTask],);- const handleDelete = useCallback(() => {- if (!feed) return;- removeFeed(feed.id);- track(ANALYTICS_EVENTS.TASK_FEED_ACTION, {- action_type: "delete",- surface: "feed_home",- feed_id: feed.id,- });- toast.success("Saved search deleted");- void navigate({ to: "/spaces" });- }, [feed, removeFeed, navigate]);-if (!feed) {return (<div className="flex h-full min-w-0 flex-col items-center justify-center gap-2 bg-gray-1 px-4 text-center">@@ -159,29 +121,38 @@ export function TaskFeedHome({ feedId }: { feedId: string }) {</span>))}</div>- <Button- variant="outline"- size="xs"- onClick={() => setEditOpen(true)}- aria-label="Edit saved search"- >- <PencilSimpleIcon size={12} />- Edit- </Button>- <Button- variant="outline"- size="xs"- onClick={() => setConfirmDeleteOpen(true)}- aria-label="Delete saved search…"- >- <TrashIcon size={12} />- Delete…- </Button>+ </div>+ );++ const header = (+ <div className="mb-2 flex min-w-0 items-center gap-2">+ <SavedSearchSwitcher currentFeedId={feedId} className="min-w-0 flex-1" />+ <div className="ml-auto flex shrink-0 items-center gap-1">+ <Button+ variant="outline"+ size="xs"+ onClick={openEdit}+ aria-label="Edit saved search"+ >+ <PencilSimpleIcon size={12} />+ Edit+ </Button>+ <Button+ variant="outline"+ size="xs"+ onClick={requestDelete}+ aria-label="Delete saved search…"+ >+ <TrashIcon size={12} />+ Delete…+ </Button>+ </div></div>);const intro = (<div>+ {header}{queryBar}{!isLoading && !error && isComplete && resultCount === 0 && (<div className="flex flex-col items-center gap-1 px-4 py-16 text-center">@@ -206,30 +177,7 @@ export function TaskFeedHome({ feedId }: { feedId: string }) {onOpenThread={handleOpenThread}/></div>- <TaskFeedModal open={editOpen} onOpenChange={setEditOpen} feed={feed} />- <AlertDialog open={confirmDeleteOpen} onOpenChange={setConfirmDeleteOpen}>- <AlertDialogContent className="max-w-md">- <AlertDialogHeader>- <AlertDialogTitle>Delete saved search?</AlertDialogTitle>- <AlertDialogDescription>- Delete <span className="font-medium">{feed.name}</span>? You- cannot undo this action.- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogClose- render={- <Button variant="outline" size="sm">- Cancel- </Button>- }- />- <Button variant="destructive" size="sm" onClick={handleDelete}>- Delete- </Button>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>+ {dialogs}</div>);}diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.test.tsxindex 26cfe8dc235d..85c942d714f9 100644--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.test.tsx@@ -28,17 +28,21 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannelItems", () => ({vi.mock("@posthog/ui/features/command-center/commandCenterStore", () => ({useCommandCenterStore: () => [] as string[],}));-vi.mock("@posthog/ui/features/canvas/components/ChannelItemRow", () => ({- ChannelItemRow: ({- item,+vi.mock("@posthog/ui/features/canvas/components/ChannelItemsPane", () => ({+ ChannelItemsPane: ({+ items,actions,}: {- item: { id: string; title: string };+ items: { key: string; id: string; title: string }[];actions: { open: (item: { id: string; title: string }) => void };}) => (- <button type="button" onClick={() => actions.open(item)}>- {item.title}- </button>+ <div>+ {items.map((item) => (+ <button key={item.key} type="button" onClick={() => actions.open(item)}>+ {item.title}+ </button>+ ))}+ </div>),}));vi.mock("@posthog/ui/features/canvas/components/FeedQueryInput", () => ({@@ -72,6 +76,7 @@ import { useTaskFeedsStore } from "@posthog/ui/features/canvas/stores/taskFeedsSimport { TaskFeedPane } from "./TaskFeedPane";vi.mock("@posthog/ui/features/canvas/hooks/useProjectTaskFeeds", () => ({+ useProjectTaskFeeds: () => useTaskFeedsStore.getState().feeds,useProjectTaskFeed: (feedId: string) =>useTaskFeedsStore.getState().feeds.find((feed) => feed.id === feedId),}));diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsxindex 33984cc8d4b5..0b6980335922 100644--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx@@ -3,18 +3,8 @@ import {PencilSimpleIcon,TrashIcon,} from "@phosphor-icons/react";+import { buildChannelItems } from "@posthog/core/canvas/channelItems";import {- buildChannelItems,- type ChannelItemModel,-} from "@posthog/core/canvas/channelItems";-import {- AlertDialog,- AlertDialogClose,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,Button,cn,Empty,@@ -22,31 +12,27 @@ import {EmptyHeader,EmptyMedia,EmptyTitle,- Spinner,Text,} from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";import { useArchiveTask } from "@posthog/ui/features/archive/useArchiveTask";import type { ChannelItemActions } from "@posthog/ui/features/canvas/components/ChannelItemRow";-import { ChannelItemRow } from "@posthog/ui/features/canvas/components/ChannelItemRow";+import { ChannelItemsPane } from "@posthog/ui/features/canvas/components/ChannelItemsPane";import { FeedQueryHighlight } from "@posthog/ui/features/canvas/components/FeedQueryInput";-import { TaskFeedModal } from "@posthog/ui/features/canvas/components/TaskFeedModal";+import { SavedSearchSwitcher } from "@posthog/ui/features/canvas/components/SavedSearchSwitcher";import { useChannelSessionFacts } from "@posthog/ui/features/canvas/hooks/useChannelItems";import { useProjectTaskFeed } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";+import { useSavedSearchActions } from "@posthog/ui/features/canvas/hooks/useSavedSearchActions";import { useTaskFeedResults } from "@posthog/ui/features/canvas/hooks/useTaskFeedResults";import {useTaskFeedSelection,useTaskFeedSelectionStore,} from "@posthog/ui/features/canvas/stores/taskFeedSelectionStore";-import { useTaskFeedsStore } from "@posthog/ui/features/canvas/stores/taskFeedsStore";-import { useCommandCenterStore } from "@posthog/ui/features/command-center/commandCenterStore";-import { placeTaskInCommandCenter } from "@posthog/ui/features/command-center/placeTaskInCommandCenter";import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";import { toast } from "@posthog/ui/primitives/toast";import { track } from "@posthog/ui/shell/analytics";-import { useNavigate } from "@tanstack/react-router";-import { useEffect, useMemo, useState } from "react";+import { useEffect, useMemo } from "react";export function TaskFeedPane({feedId,@@ -55,20 +41,17 @@ export function TaskFeedPane({feedId: string;className?: string;}) {- const navigate = useNavigate();const feed = useProjectTaskFeed(feedId);- const removeFeed = useTaskFeedsStore((state) => state.removeFeed);const select = useTaskFeedSelectionStore((state) => state.select);const selected = useTaskFeedSelection(feedId);- const { error, errorMessage, isComplete, isLoading, tasks } =- useTaskFeedResults(feed?.query);+ const { error, errorMessage, isLoading, tasks } = useTaskFeedResults(+ feed?.query,+ );const archivedTaskIds = useArchivedTaskIds();const { pinnedTaskIds, togglePin, setPinnedMany } = usePinnedTasks();const { archiveTask } = useArchiveTask();const sessionFacts = useChannelSessionFacts();- const commandCenterCells = useCommandCenterStore((state) => state.cells);- const [editOpen, setEditOpen] = useState(false);- const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);+ const { openEdit, requestDelete, dialogs } = useSavedSearchActions(feed);const items = useMemo(() =>@@ -103,8 +86,6 @@ export function TaskFeedPane({archive: (item) => {void archiveTask({ taskId: item.id });},- remove: () => undefined,- fileCanvas: () => undefined,}),[feedId, select, togglePin, setPinnedMany, archiveTask],);@@ -135,33 +116,19 @@ export function TaskFeedPane({);}- const handleDelete = () => {- removeFeed(feed.id);- select(null);- track(ANALYTICS_EVENTS.TASK_FEED_ACTION, {- action_type: "delete",- surface: "feed_home",- feed_id: feed.id,- });- toast.success("Saved search deleted");- void navigate({ to: "/spaces" });- };-return (<div className={cn("flex min-h-0 flex-col", className)}><div className="flex h-10 shrink-0 items-center gap-2 border-border border-b pr-2 pl-3">- <span className="truncate font-bold text-base">{feed.name}</span>- {!isLoading && !error && (- <span className="shrink-0 text-muted-foreground text-xs tabular-nums">- {isComplete ? items.length : `${items.length}+`}- </span>- )}+ <SavedSearchSwitcher+ currentFeedId={feedId}+ className="min-w-0 flex-1"+ /><div className="ml-auto flex shrink-0 items-center gap-1"><Buttonvariant="default"size="icon-xs"aria-label="Edit saved search"- onClick={() => setEditOpen(true)}+ onClick={openEdit}><PencilSimpleIcon size={14} /></Button>@@ -169,7 +136,7 @@ export function TaskFeedPane({variant="default"size="icon-xs"aria-label="Delete saved search…"- onClick={() => setConfirmDeleteOpen(true)}+ onClick={requestDelete}><TrashIcon size={14} /></Button>@@ -180,77 +147,40 @@ export function TaskFeedPane({variant="default"leftclassName="h-auto shrink-0 gap-2 rounded-none border-border border-b px-3 py-2"- onClick={() => setEditOpen(true)}+ onClick={openEdit}>- <MagnifyingGlassIcon size={12} className="shrink-0 text-(--gray-9)" /><FeedQueryHighlight query={feed.query} className="min-w-0 truncate" /></Button>- <div className="min-h-0 flex-1 overflow-y-auto p-1.5">- {isLoading && items.length === 0 ? (- <div className="flex justify-center py-10">- <Spinner />- </div>- ) : error ? (- <Text className="block px-2 py-6 text-center text-(--red-11) text-xs">- {errorMessage}- </Text>- ) : items.length === 0 ? (- <Empty className="border-0 py-8">- <EmptyHeader>- <EmptyMedia variant="icon">- <MagnifyingGlassIcon />- </EmptyMedia>- <EmptyTitle>No tasks match</EmptyTitle>- <EmptyDescription>- Tasks appear here as they start matching the query.- </EmptyDescription>- </EmptyHeader>- </Empty>- ) : (- <div className="flex flex-col gap-px">- {items.map((item: ChannelItemModel) => (- <ChannelItemRow- key={item.key}- item={item}- channelId={item.task?.channel ?? undefined}- isActive={selected?.taskId === item.id}- actions={actions}- onAddToCommandCenter={- commandCenterCells.includes(item.id)- ? undefined- : () => placeTaskInCommandCenter(item.id, item.title)- }- />- ))}- </div>- )}- </div>+ {error ? (+ <Text className="block px-2 py-6 text-center text-(--red-11) text-xs">+ {errorMessage}+ </Text>+ ) : (+ <ChannelItemsPane+ items={items}+ isLoading={isLoading}+ actions={actions}+ activeKey={selected?.taskId ? `task:${selected.taskId}` : null}+ surface="saved_search"+ channelIdFor={(item) => item.task?.channel ?? undefined}+ emptyState={+ <Empty className="border-0 py-8">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <MagnifyingGlassIcon />+ </EmptyMedia>+ <EmptyTitle>No tasks match</EmptyTitle>+ <EmptyDescription>+ Tasks appear here as they start matching the query.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ }+ />+ )}- <TaskFeedModal open={editOpen} onOpenChange={setEditOpen} feed={feed} />- <AlertDialog open={confirmDeleteOpen} onOpenChange={setConfirmDeleteOpen}>- <AlertDialogContent className="max-w-md">- <AlertDialogHeader>- <AlertDialogTitle>Delete saved search?</AlertDialogTitle>- <AlertDialogDescription>- Delete <span className="font-medium">{feed.name}</span>? You- cannot undo this action.- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogClose- render={- <Button variant="outline" size="sm">- Cancel- </Button>- }- />- <Button variant="destructive" size="sm" onClick={handleDelete}>- Delete- </Button>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>+ {dialogs}</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 761059a83692..8b01e6f7c3e8 100644--- a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts@@ -5,6 +5,7 @@ import {HouseSimple,type IconProps,Lightning,+ ListMagnifyingGlassIcon,ShapesIcon,} from "@phosphor-icons/react";import type { RailVisit } from "@posthog/shared";@@ -28,6 +29,7 @@ import {navigateToCanvases,navigateToChannel,navigateToCommandCenter,+ navigateToFeeds,navigateToHome,navigateToInbox,navigateToLoops,@@ -57,15 +59,19 @@ export interface RailDestination {* from landing on its root. Defaults to `onPick`.*/onReclick?: () => void;+ placement?: "top" | "bottom";shortcut?: string;count?: (counts: RailCounts) => number;countTone?: CountBadgeTone;- enabled?: (flags: {- home: boolean;- inbox: boolean;- loops: boolean;- context: boolean;- }) => boolean;+ enabled?: (flags: RailFlags) => boolean;+}++export interface RailFlags {+ home: boolean;+ inbox: boolean;+ loops: boolean;+ context: boolean;+ savedSearches: boolean;}/**@@ -204,6 +210,16 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [onPick: () => navigateToLoops(),enabled: (flags) => flags.loops,},+ {+ pane: "feeds",+ label: "Saved searches",+ analyticsId: "search",+ Icon: ListMagnifyingGlassIcon,+ href: "/feeds",+ onPick: navigateToFeeds,+ placement: "bottom",+ enabled: (flags) => flags.savedSearches,+ },{pane: "context",label: "Context",@@ -215,11 +231,8 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [},];-export function visibleRailDestinations(flags: {- home: boolean;- inbox: boolean;- loops: boolean;- context: boolean;-}): readonly RailDestination[] {+export function visibleRailDestinations(+ flags: RailFlags,+): readonly RailDestination[] {return RAIL_DESTINATIONS.filter(({ enabled }) => enabled?.(flags) ?? true);}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemSelection.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemSelection.tsnew file mode 100644index 000000000000..029faa652016--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItemSelection.ts@@ -0,0 +1,98 @@+import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import type { Task } from "@posthog/shared/domain-types";+import { useChannelTasksRunState } from "@posthog/ui/features/canvas/hooks/useChannelTasksRunState";+import { useTaskSelectionStore } from "@posthog/ui/features/sidebar/taskSelectionStore";+import { useBulkArchiveConfirm } from "@posthog/ui/features/sidebar/useBulkArchiveConfirm";+import { useClearSelectionOnEscape } from "@posthog/ui/features/sidebar/useClearSelectionOnEscape";+import { useMarqueeSelection } from "@posthog/ui/features/sidebar/useMarqueeSelection";+import { useSidebarBulkActions } from "@posthog/ui/features/sidebar/useSidebarBulkActions";+import type { MouseEvent, RefObject } from "react";+import { useEffect, useMemo, useRef } from "react";++export interface ChannelItemSelection {+ selectedTaskIds: string[];+ clearSelection: () => void;+ bulkActions: ReturnType<typeof useSidebarBulkActions>;+ archiveConfirm: ReturnType<typeof useBulkArchiveConfirm>;+ marquee: ReturnType<typeof useMarqueeSelection>;+ listAnchorRef: RefObject<HTMLDivElement | null>;+ onRowClick: (item: ChannelItemModel, event: MouseEvent) => void;+}++export function useChannelItemSelection({+ listItems,+ activeKey,+ open,+}: {+ listItems: readonly ChannelItemModel[];+ activeKey: string | null;+ open: (item: ChannelItemModel) => void;+}): ChannelItemSelection {+ const selectableTaskIds = useMemo(+ () => listItems.filter((i) => i.kind === "task").map((i) => i.id),+ [listItems],+ );+ const selectedTaskIds = useTaskSelectionStore((s) => s.selectedTaskIds);+ const toggleTaskSelection = useTaskSelectionStore(+ (s) => s.toggleTaskSelection,+ );+ const selectRange = useTaskSelectionStore((s) => s.selectRange);+ const clearSelection = useTaskSelectionStore((s) => s.clearSelection);+ const pruneSelection = useTaskSelectionStore((s) => s.pruneSelection);+ useClearSelectionOnEscape();+ const listAnchorRef = useRef<HTMLDivElement | null>(null);+ const marquee = useMarqueeSelection(listAnchorRef);++ useEffect(() => {+ pruneSelection(selectableTaskIds);+ }, [selectableTaskIds, pruneSelection]);++ const activeTaskId = activeKey?.startsWith("task:")+ ? activeKey.slice("task:".length)+ : null;++ const selectedTasks = useMemo(() => {+ const selected = new Set(selectedTaskIds);+ return listItems+ .filter(+ (i): i is ChannelItemModel & { task: Task } =>+ i.kind === "task" && i.task !== null && selected.has(i.id),+ )+ .map((i) => i.task);+ }, [listItems, selectedTaskIds]);+ const selectedTasksRunState = useChannelTasksRunState(selectedTasks);+ const bulkActions = useSidebarBulkActions(+ selectedTaskIds,+ selectedTasksRunState,+ );+ const archiveConfirm = useBulkArchiveConfirm(bulkActions);++ const onRowClick = (item: ChannelItemModel, event: MouseEvent) => {+ if (item.kind !== "task") {+ open(item);+ return;+ }+ if (event.shiftKey) {+ event.preventDefault();+ selectRange(item.id, selectableTaskIds, activeTaskId);+ return;+ }+ if (event.metaKey || event.ctrlKey) {+ event.preventDefault();+ toggleTaskSelection(item.id);+ return;+ }+ clearSelection();+ open(item);+ };++ return {+ selectedTaskIds,+ clearSelection,+ bulkActions,+ archiveConfirm,+ marquee,+ listAnchorRef,+ onRowClick,+ };+}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useProjectTaskFeeds.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useProjectTaskFeeds.tsindex dbc34d300e21..d8504bed61a2 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useProjectTaskFeeds.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useProjectTaskFeeds.ts@@ -2,6 +2,7 @@ import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClimport { useAuthStateValue } from "@posthog/ui/features/auth/store";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";import {+ ownedProjectFeeds,type TaskFeed,useTaskFeedsStore,} from "@posthog/ui/features/canvas/stores/taskFeedsStore";@@ -14,12 +15,7 @@ export function useProjectTaskFeeds(): TaskFeed[] {const ownerId = currentUser?.uuid;const feeds = useTaskFeedsStore((state) => state.feeds);return useMemo(- () =>- projectId === null || ownerId === undefined- ? []- : feeds.filter(- (feed) => feed.projectId === projectId && feed.ownerId === ownerId,- ),+ () => ownedProjectFeeds(feeds, projectId, ownerId),[feeds, ownerId, projectId],);}@@ -28,3 +24,10 @@ export function useProjectTaskFeed(feedId: string): TaskFeed | undefined {const feeds = useProjectTaskFeeds();return feeds.find((feed) => feed.id === feedId);}++export function useProjectTaskFeedsReady(): boolean {+ const client = useOptionalAuthenticatedClient();+ const { isLoading } = useCurrentUser({ client });+ const hasHydrated = useTaskFeedsStore((state) => state.hasHydrated);+ return hasHydrated && !isLoading;+}diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useSavedSearchActions.tsx b/products/desktop/packages/ui/src/features/canvas/hooks/useSavedSearchActions.tsxnew file mode 100644index 000000000000..89f6b5adb451--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useSavedSearchActions.tsx@@ -0,0 +1,81 @@+import {+ AlertDialog,+ AlertDialogClose,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ Button,+} from "@posthog/quill";+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import { TaskFeedModal } from "@posthog/ui/features/canvas/components/TaskFeedModal";+import { useTaskFeedSelectionStore } from "@posthog/ui/features/canvas/stores/taskFeedSelectionStore";+import {+ type TaskFeed,+ useTaskFeedsStore,+} from "@posthog/ui/features/canvas/stores/taskFeedsStore";+import { toast } from "@posthog/ui/primitives/toast";+import { track } from "@posthog/ui/shell/analytics";+import { useNavigate } from "@tanstack/react-router";+import { type ReactNode, useState } from "react";++export function useSavedSearchActions(feed: TaskFeed | undefined): {+ openEdit: () => void;+ requestDelete: () => void;+ dialogs: ReactNode;+} {+ const navigate = useNavigate();+ const removeFeed = useTaskFeedsStore((state) => state.removeFeed);+ const select = useTaskFeedSelectionStore((state) => state.select);+ const [editOpen, setEditOpen] = useState(false);+ const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);++ const remove = () => {+ if (!feed) return;+ removeFeed(feed.id);+ select(null);+ track(ANALYTICS_EVENTS.TASK_FEED_ACTION, {+ action_type: "delete",+ surface: "feed_home",+ feed_id: feed.id,+ });+ toast.success("Saved search deleted");+ void navigate({ to: "/spaces" });+ };++ const dialogs = !feed ? null : (+ <>+ <TaskFeedModal open={editOpen} onOpenChange={setEditOpen} feed={feed} />+ <AlertDialog open={confirmDeleteOpen} onOpenChange={setConfirmDeleteOpen}>+ <AlertDialogContent className="max-w-md">+ <AlertDialogHeader>+ <AlertDialogTitle>Delete saved search?</AlertDialogTitle>+ <AlertDialogDescription>+ Delete <span className="font-medium">{feed.name}</span>? You+ cannot undo this action.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogClose+ render={+ <Button variant="outline" size="sm">+ Cancel+ </Button>+ }+ />+ <Button variant="destructive" size="sm" onClick={remove}>+ Delete+ </Button>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </>+ );++ return {+ openEdit: () => setEditOpen(true),+ requestDelete: () => setConfirmDeleteOpen(true),+ dialogs,+ };+}diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts b/products/desktop/packages/ui/src/features/canvas/railPane.test.tsindex ddc5259ff86f..26a161bf1f80 100644--- a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts+++ b/products/desktop/packages/ui/src/features/canvas/railPane.test.ts@@ -14,6 +14,8 @@ describe("railPaneForPath", () => {["/inbox/pulls/$reportId", "inbox"],["/loops", "loops"],["/loops/$loopId/edit", "loops"],+ ["/feeds/", "feeds"],+ ["/feeds/$feedId", "feeds"],] as const)("puts %s on %s", (path, pane) => {expect(railPaneForPath(path)).toBe(pane);});@@ -37,7 +39,6 @@ describe("railPaneForPath", () => {"/spaces/$channelId/history","/spaces/$channelId/canvases","/spaces/$channelId/tasks/$taskId",- "/feeds/$feedId","/tasks/$taskId","/new",])("leaves %s with Spaces", (path) => {@@ -53,9 +54,12 @@ describe("railPaneHasSidebar", () => {},);- it.each(["spaces", "activity"] as const)("gives %s a column", (pane) => {- expect(railPaneHasSidebar(pane)).toBe(true);- });+ it.each(["spaces", "activity", "feeds"] as const)(+ "gives %s a column",+ (pane) => {+ expect(railPaneHasSidebar(pane)).toBe(true);+ },+ );});describe("RAIL_PANE_ROOT", () => {diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.ts b/products/desktop/packages/ui/src/features/canvas/railPane.tsindex 0927e8abba53..4f93f9371928 100644--- a/products/desktop/packages/ui/src/features/canvas/railPane.ts+++ b/products/desktop/packages/ui/src/features/canvas/railPane.ts@@ -16,7 +16,8 @@ export type NavRailPane =| "inbox"| "command-center"| "loops"- | "context";+ | "context"+ | "feeds";/*** The root path of each destination.@@ -34,6 +35,7 @@ export const RAIL_PANE_ROOT: Readonly<Record<NavRailPane, string>> = {"command-center": "/command-center",loops: "/loops",context: "/spaces/context",+ feeds: "/feeds",};// Spaces is absent: it takes everything nothing else claims, so listing it@@ -46,6 +48,7 @@ const CLAIMED: readonly NavRailPane[] = ["command-center","loops","context",+ "feeds",];export function railPaneForPath(fullPath: string): NavRailPane {@@ -72,13 +75,11 @@ export function getRailPane(): NavRailPane {return railPaneForMatches(getCurrentMatches());}-// Home, Inbox, Command Center and Loops are whole-screen destinations: no-// route under them may put a second nav on the screen. Spaces owns the space-// tree, Activity owns the feed.const PANES_WITH_SIDEBAR = new Set<NavRailPane>(["spaces","activity","canvases",+ "feeds",]);export function railPaneHasSidebar(pane: NavRailPane): boolean {diff --git a/products/desktop/packages/ui/src/features/canvas/stores/taskFeedSelectionStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/taskFeedSelectionStore.tsindex b73abb0db52f..1f015fbedd0c 100644--- a/products/desktop/packages/ui/src/features/canvas/stores/taskFeedSelectionStore.ts+++ b/products/desktop/packages/ui/src/features/canvas/stores/taskFeedSelectionStore.ts@@ -22,3 +22,7 @@ export function useTaskFeedSelection(feedId: string): TaskFeedSelection | null {const selected = useTaskFeedSelectionStore((state) => state.selected);return selected?.feedId === feedId ? selected : null;}++export function feedIdFromHref(href: string | null): string | null {+ return href ? (/^\/feeds\/([^/?#]+)/.exec(href)?.[1] ?? null) : null;+}diff --git a/products/desktop/packages/ui/src/features/canvas/stores/taskFeedsStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/taskFeedsStore.tsindex a2eadaa36b7e..283df23b60a4 100644--- a/products/desktop/packages/ui/src/features/canvas/stores/taskFeedsStore.ts+++ b/products/desktop/packages/ui/src/features/canvas/stores/taskFeedsStore.ts@@ -13,6 +13,8 @@ export interface TaskFeed {interface TaskFeedsState {feeds: TaskFeed[];+ hasHydrated: boolean;+ setHasHydrated: (hydrated: boolean) => void;addFeed: (input: {name: string;query: string;@@ -28,6 +30,8 @@ export const useTaskFeedsStore = create<TaskFeedsState>()(persist((set) => ({feeds: [],+ hasHydrated: false,+ setHasHydrated: (hydrated) => set({ hasHydrated: hydrated }),addFeed: ({ name, query, projectId, ownerId }) => {const feed: TaskFeed = {id: crypto.randomUUID(),@@ -64,6 +68,25 @@ export const useTaskFeedsStore = create<TaskFeedsState>()({name: "task-feeds-storage",storage: electronStorage,+ partialize: ({ feeds }) => ({ feeds }),+ onRehydrateStorage: () => (state, error) => {+ if (error) {+ useTaskFeedsStore.getState().setHasHydrated(true);+ } else {+ state?.setHasHydrated(true);+ }+ },},),);++export function ownedProjectFeeds(+ feeds: readonly TaskFeed[],+ projectId: number | null,+ ownerId: string | undefined,+): TaskFeed[] {+ if (projectId === null || ownerId === undefined) return [];+ return feeds.filter(+ (feed) => feed.projectId === projectId && feed.ownerId === ownerId,+ );+}diff --git a/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts b/products/desktop/packages/ui/src/features/navigation/useActiveSession.tsindex 55078881ad3a..5d4add2c7950 100644--- a/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts+++ b/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts@@ -39,3 +39,11 @@ export function useActiveSession(): ActiveSession {}return { taskId, channelId };}++const NO_SESSION: ActiveSession = { taskId: undefined, channelId: undefined };++export function useTabSession(): ActiveSession {+ const params = useParams({ strict: false });+ const session = useActiveSession();+ return params.feedId ? NO_SESSION : session;+}diff --git a/products/desktop/packages/ui/src/router/navigationBridge.ts b/products/desktop/packages/ui/src/router/navigationBridge.tsindex 165e9672aa73..f86b98d0d56d 100644--- a/products/desktop/packages/ui/src/router/navigationBridge.ts+++ b/products/desktop/packages/ui/src/router/navigationBridge.ts@@ -60,6 +60,10 @@ export function navigateToFeed(feedId: string): void {});}+export function navigateToFeeds(): void {+ void getRouterOrNull()?.navigate({ to: "/feeds" });+}+export function navigateToChannel(channelId: string): void {void getRouterOrNull()?.navigate({to: "/spaces/$channelId",diff --git a/products/desktop/packages/ui/src/router/routeTree.gen.ts b/products/desktop/packages/ui/src/router/routeTree.gen.tsindex b07949c1df7f..93fd4dd7a77a 100644--- a/products/desktop/packages/ui/src/router/routeTree.gen.ts+++ b/products/desktop/packages/ui/src/router/routeTree.gen.ts@@ -48,6 +48,7 @@ import { Route as InboxDismissedIndexRouteImport } from './routes/inbox/dismisseimport { Route as AgentsScoutsIndexRouteImport } from './routes/agents/scouts.index'import { Route as ShellSpacesIndexRouteImport } from './routes/_shell/spaces/index'import { Route as ShellSettingsIndexRouteImport } from './routes/_shell/settings/index'+import { Route as ShellFeedsIndexRouteImport } from './routes/_shell/feeds/index'import { Route as TasksPendingKeyRouteImport } from './routes/tasks/pending.$key'import { Route as LoopsLoopIdEditRouteImport } from './routes/loops/$loopId/edit'import { Route as InboxRunsReportIdRouteImport } from './routes/inbox/runs.$reportId'@@ -266,6 +267,11 @@ const ShellSettingsIndexRoute = ShellSettingsIndexRouteImport.update({path: '/settings/',getParentRoute: () => ShellRoute,} as any)+const ShellFeedsIndexRoute = ShellFeedsIndexRouteImport.update({+ id: '/feeds/',+ path: '/feeds/',+ getParentRoute: () => ShellRoute,+} as any)const TasksPendingKeyRoute = TasksPendingKeyRouteImport.update({id: '/tasks/pending/$key',path: '/tasks/pending/$key',@@ -435,6 +441,7 @@ export interface FileRoutesByFullPath {'/inbox/runs/$reportId': typeof InboxRunsReportIdRoute'/loops/$loopId/edit': typeof LoopsLoopIdEditRoute'/tasks/pending/$key': typeof TasksPendingKeyRoute+ '/feeds/': typeof ShellFeedsIndexRoute'/settings/': typeof ShellSettingsIndexRoute'/spaces/': typeof ShellSpacesIndexRoute'/agents/scouts/': typeof AgentsScoutsIndexRoute@@ -489,6 +496,7 @@ export interface FileRoutesByTo {'/inbox/runs/$reportId': typeof InboxRunsReportIdRoute'/loops/$loopId/edit': typeof LoopsLoopIdEditRoute'/tasks/pending/$key': typeof TasksPendingKeyRoute+ '/feeds': typeof ShellFeedsIndexRoute'/settings': typeof ShellSettingsIndexRoute'/spaces': typeof ShellSpacesIndexRoute'/agents/scouts': typeof AgentsScoutsIndexRoute@@ -554,6 +562,7 @@ export interface FileRoutesById {'/inbox/runs/$reportId': typeof InboxRunsReportIdRoute'/loops/$loopId/edit': typeof LoopsLoopIdEditRoute'/tasks/pending/$key': typeof TasksPendingKeyRoute+ '/_shell/feeds/': typeof ShellFeedsIndexRoute'/_shell/settings/': typeof ShellSettingsIndexRoute'/_shell/spaces/': typeof ShellSpacesIndexRoute'/agents/scouts/': typeof AgentsScoutsIndexRoute@@ -619,6 +628,7 @@ export interface FileRouteTypes {| '/inbox/runs/$reportId'| '/loops/$loopId/edit'| '/tasks/pending/$key'+ | '/feeds/'| '/settings/'| '/spaces/'| '/agents/scouts/'@@ -673,6 +683,7 @@ export interface FileRouteTypes {| '/inbox/runs/$reportId'| '/loops/$loopId/edit'| '/tasks/pending/$key'+ | '/feeds'| '/settings'| '/spaces'| '/agents/scouts'@@ -737,6 +748,7 @@ export interface FileRouteTypes {| '/inbox/runs/$reportId'| '/loops/$loopId/edit'| '/tasks/pending/$key'+ | '/_shell/feeds/'| '/_shell/settings/'| '/_shell/spaces/'| '/agents/scouts/'@@ -1053,6 +1065,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ShellSettingsIndexRouteImportparentRoute: typeof ShellRoute}+ '/_shell/feeds/': {+ id: '/_shell/feeds/'+ path: '/feeds'+ fullPath: '/feeds/'+ preLoaderRoute: typeof ShellFeedsIndexRouteImport+ parentRoute: typeof ShellRoute+ }'/tasks/pending/$key': {id: '/tasks/pending/$key'path: '/tasks/pending/$key'@@ -1228,6 +1247,7 @@ interface ShellRouteChildren {ShellFeedsFeedIdRoute: typeof ShellFeedsFeedIdRouteShellSettingsCategoryRoute: typeof ShellSettingsCategoryRouteShellSpacesContextRoute: typeof ShellSpacesContextRoute+ ShellFeedsIndexRoute: typeof ShellFeedsIndexRouteShellSettingsIndexRoute: typeof ShellSettingsIndexRouteShellSpacesIndexRoute: typeof ShellSpacesIndexRouteShellSpacesChannelIdArtifactsRoute: typeof ShellSpacesChannelIdArtifactsRoute@@ -1253,6 +1273,7 @@ const ShellRouteChildren: ShellRouteChildren = {ShellFeedsFeedIdRoute: ShellFeedsFeedIdRoute,ShellSettingsCategoryRoute: ShellSettingsCategoryRoute,ShellSpacesContextRoute: ShellSpacesContextRoute,+ ShellFeedsIndexRoute: ShellFeedsIndexRoute,ShellSettingsIndexRoute: ShellSettingsIndexRoute,ShellSpacesIndexRoute: ShellSpacesIndexRoute,ShellSpacesChannelIdArtifactsRoute: ShellSpacesChannelIdArtifactsRoute,diff --git a/products/desktop/packages/ui/src/router/routes/_shell/feeds/index.tsx b/products/desktop/packages/ui/src/router/routes/_shell/feeds/index.tsxnew file mode 100644index 000000000000..594df8bf692c--- /dev/null+++ b/products/desktop/packages/ui/src/router/routes/_shell/feeds/index.tsx@@ -0,0 +1,27 @@+import {+ useProjectTaskFeeds,+ useProjectTaskFeedsReady,+} from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";+import {+ ChannelSkeleton,+ withRouteSkeleton,+} from "@posthog/ui/router/routeSkeletons";+import { createFileRoute, Navigate } from "@tanstack/react-router";++export const Route = createFileRoute("/_shell/feeds/")({+ component: SavedSearchesIndexRoute,+ ...withRouteSkeleton(ChannelSkeleton),+});++function SavedSearchesIndexRoute() {+ const feeds = useProjectTaskFeeds();+ const ready = useProjectTaskFeedsReady();+ const firstFeedId = feeds[0]?.id;+ if (!ready) return <ChannelSkeleton />;+ if (firstFeedId) {+ return (+ <Navigate replace to="/feeds/$feedId" params={{ feedId: firstFeedId }} />+ );+ }+ return <Navigate replace to="/spaces" />;+}