Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): default work sidebar to desktop (#106019)

Shy Alter72227e93bc92
diff --git a/products/desktop/packages/core/src/canvas/channelItems.test.ts b/products/desktop/packages/core/src/canvas/channelItems.test.ts
index a901e03e2c70..6b1c49b3d9f3 100644
--- a/products/desktop/packages/core/src/canvas/channelItems.test.ts
+++ b/products/desktop/packages/core/src/canvas/channelItems.test.ts
@@ -7,6 +7,7 @@ import {
type ChannelItemSort,
channelItemSources,
DEFAULT_CHANNEL_ITEM_FILTERS,
+ DESKTOP_SOURCE,
filterChannelItems,
groupChannelItems,
sortChannelItems,
@@ -219,14 +220,14 @@ describe("buildChannelItems", () => {
expect(item.repository).toBeNull();
});
- it("reads a filed session's source, and none for one started here", () => {
+ it("reads the source for filed and Desktop sessions", () => {
const items = build({
feedTasks: [
task({ id: "filed", origin_product: "slack" }),
task({ id: "own", origin_product: "user_created" }),
],
});
- expect(items.map((i) => i.source)).toEqual(["slack", null]);
+ expect(items.map((i) => i.source)).toEqual(["slack", DESKTOP_SOURCE]);
});
it("marks the sessions asking for input and the ones you haven't read", () => {
@@ -325,7 +326,7 @@ function model(over: Partial<ChannelItemModel> = {}): ChannelItemModel {
pinned: false,
rawStatus: null,
environment: null,
- source: null,
+ source: DESKTOP_SOURCE,
needsInput: false,
unread: false,
authorUser: ME,
@@ -436,14 +437,19 @@ describe("filterChannelItems", () => {
});
describe("channelItemSources", () => {
- it("offers each source once, and nothing for sessions started here", () => {
+ it("offers each source once", () => {
const items = [
model({ id: "a", source: "slack" }),
model({ id: "b", source: "slack" }),
model({ id: "c", source: "error_tracking" }),
+ model({ id: "desktop", source: DESKTOP_SOURCE }),
model({ id: "d", source: null }),
];
- expect(channelItemSources(items)).toEqual(["error_tracking", "slack"]);
+ expect(channelItemSources(items)).toEqual([
+ "error_tracking",
+ "slack",
+ DESKTOP_SOURCE,
+ ]);
});
});
diff --git a/products/desktop/packages/core/src/canvas/channelItems.ts b/products/desktop/packages/core/src/canvas/channelItems.ts
index 3a5d3072634f..384f5141c710 100644
--- a/products/desktop/packages/core/src/canvas/channelItems.ts
+++ b/products/desktop/packages/core/src/canvas/channelItems.ts
@@ -34,7 +34,7 @@ export interface ChannelItemModel {
* names one.
*/
environment: ChannelItemEnvironment | null;
- /** The product that filed it (`origin_product`), or null if it started here. */
+ /** The product that filed it (`origin_product`), or Desktop for a canvas. */
source: string | null;
/** The agent is blocked on an answer from you. */
needsInput: boolean;
@@ -134,16 +134,8 @@ function environmentOf(
return mode === "cloud" ? "cloud" : "local";
}
-/**
- * `origin_product` for a session someone started here rather than one filed by
- * another product. It is the default the backend stamps on, so it is an absence
- * of a source, not one of the sources to choose between.
- */
-const SELF_ORIGIN = "user_created";
-
function sourceOf(task: Task): string | null {
- const origin = task.origin_product;
- return origin && origin !== SELF_ORIGIN ? origin : null;
+ return task.origin_product || null;
}
export function buildChannelItems({
@@ -171,7 +163,7 @@ export function buildChannelItems({
pinned: d.pinnedAt != null,
rawStatus: null,
environment: null,
- source: null,
+ source: DESKTOP_SOURCE,
needsInput: false,
unread: false,
authorUser: d.createdByUser ?? null,
@@ -239,6 +231,7 @@ export type ChannelItemSort = "recent" | "created" | "alpha";
export type KindFilter = "any" | "task" | "canvas";
export const ANY_SOURCE = "any";
+export const DESKTOP_SOURCE = "user_created";
export interface ChannelItemFilters {
kind: KindFilter;
@@ -285,14 +278,15 @@ export const DEFAULT_CHANNEL_ITEM_GROUPING: ChannelItemGrouping = "date";
*/
export function hasActiveChannelItemFilters(
filters: ChannelItemFilters,
+ defaults: ChannelItemFilters = DEFAULT_CHANNEL_ITEM_FILTERS,
): boolean {
return (
- filters.kind !== "any" ||
- filters.createdBy !== "anyone" ||
- filters.attention !== "any" ||
- filters.pinned !== "any" ||
- filters.environment !== "any" ||
- filters.source !== ANY_SOURCE
+ filters.kind !== defaults.kind ||
+ filters.createdBy !== defaults.createdBy ||
+ filters.attention !== defaults.attention ||
+ filters.pinned !== defaults.pinned ||
+ filters.environment !== defaults.environment ||
+ filters.source !== defaults.source
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
index 5b888579ff96..b6679b1def38 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.stories.tsx
@@ -5,6 +5,7 @@ import {
DEFAULT_CHANNEL_ITEM_FILTERS,
DEFAULT_CHANNEL_ITEM_GROUPING,
DEFAULT_CHANNEL_ITEM_SORT,
+ DESKTOP_SOURCE,
hasActiveChannelItemFilters,
} from "@posthog/core/canvas/channelItems";
import { EditListItemAppearanceDialog } from "@posthog/ui/features/sidebar/components/EditListItemAppearanceDialog";
@@ -19,12 +20,14 @@ import { ChannelFilterMenu } from "./ChannelFilterMenu";
*/
function Harness({
initialFilters,
+ defaultFilters,
initialSort,
sources,
showCreatedBy,
showRunFilters,
}: {
initialFilters: ChannelItemFilters;
+ defaultFilters: ChannelItemFilters;
initialSort: ChannelItemSort;
sources: string[];
showCreatedBy: boolean;
@@ -43,7 +46,8 @@ function Harness({
onFilterChange={(key, value) =>
setFilters((current) => ({ ...current, [key]: value }))
}
- onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}
+ onClearFilters={() => setFilters(defaultFilters)}
+ defaultFilters={defaultFilters}
sort={sort}
onSortChange={setSort}
grouping={grouping}
@@ -52,7 +56,7 @@ function Harness({
sources={sources}
showCreatedBy={showCreatedBy}
showRunFilters={showRunFilters}
- active={hasActiveChannelItemFilters(filters)}
+ active={hasActiveChannelItemFilters(filters, defaultFilters)}
/>
{/* The list owns the dialog and the menu only asks for it — so the
harness renders it too, the way the sidebar does. */}
@@ -70,8 +74,9 @@ const meta: Meta<typeof Harness> = {
component: Harness,
args: {
initialFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
+ defaultFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
initialSort: DEFAULT_CHANNEL_ITEM_SORT,
- sources: ["slack", "error_tracking", "support_queue"],
+ sources: ["posthog_ai", "slack", "error_tracking", "support_queue"],
showCreatedBy: true,
showRunFilters: true,
},
@@ -89,6 +94,19 @@ type Story = StoryObj<typeof Harness>;
export const Default: Story = {};
+export const DesktopDefault: Story = {
+ args: {
+ initialFilters: {
+ ...DEFAULT_CHANNEL_ITEM_FILTERS,
+ source: DESKTOP_SOURCE,
+ },
+ defaultFilters: {
+ ...DEFAULT_CHANNEL_ITEM_FILTERS,
+ source: DESKTOP_SOURCE,
+ },
+ },
+};
+
/** A filter is on, so the button is lit and the menu offers a way out. */
export const Filtered: Story = {
args: {
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
index 56d043907f37..28213d95295b 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFilterMenu.tsx
@@ -6,6 +6,8 @@ import {
type ChannelItemGrouping,
type ChannelItemSort,
type CreatedByFilter,
+ DEFAULT_CHANNEL_ITEM_FILTERS,
+ DESKTOP_SOURCE,
type EnvironmentFilter,
type KindFilter,
type PinnedFilter,
@@ -87,6 +89,23 @@ const SORT_OPTIONS: readonly Option<ChannelItemSort>[] = [
{ value: "alpha", label: "Name" },
];
+const SOURCE_LABELS: Record<string, string> = {
+ [DESKTOP_SOURCE]: "Desktop",
+ hogdesk: "HogDesk",
+ mcp_analytics: "MCP analytics",
+ posthog_ai: "PostHog AI",
+ posthog_code: "PostHog Desktop",
+ review_hog: "ReviewHog",
+};
+
+function sourceLabel(source: string): string {
+ const known = getOriginProductMeta(source)?.label ?? SOURCE_LABELS[source];
+ if (known) return known;
+
+ const words = source.replaceAll("_", " ");
+ return words.charAt(0).toUpperCase() + words.slice(1);
+}
+
function labelOf<T extends string>(
options: readonly Option<T>[],
value: T,
@@ -118,16 +137,19 @@ function FilterSubmenu<T extends string>({
label,
options,
value,
+ defaultValue = options[0]?.value,
onChange,
}: {
label: string;
options: readonly Option<T>[];
value: T;
+ /** The value the list starts with. The trigger highlights any other value. */
+ defaultValue?: T;
onChange: (value: T) => void;
}) {
- // Every list leads with its own "everything" option, so a value that isn't the
- // first one is a choice someone made, and the trigger says so.
- const narrowed = value !== options[0]?.value;
+ // A list can start narrowed, so its first option is not always its default.
+ // A highlighted default looks like a filter the person set and must clear.
+ const narrowed = value !== defaultValue;
return (
<DropdownMenuSub>
@@ -169,6 +191,7 @@ export function ChannelFilterMenu({
filters,
onFilterChange,
onClearFilters,
+ defaultFilters = DEFAULT_CHANNEL_ITEM_FILTERS,
sort,
onSortChange,
grouping,
@@ -195,6 +218,8 @@ export function ChannelFilterMenu({
value: ChannelItemFilters[K],
) => void;
onClearFilters: () => void;
+ /** What "Clear filters" restores. A value that matches it is not highlighted. */
+ defaultFilters?: ChannelItemFilters;
sort: ChannelItemSort;
onSortChange: (sort: ChannelItemSort) => void;
/** What the list's section headers stand for. */
@@ -219,11 +244,9 @@ export function ChannelFilterMenu({
const sourceOptions: Option<string>[] = [
{ value: ANY_SOURCE, label: "Any source" },
- ...sources.map((source) => ({
+ ...Array.from(new Set([DESKTOP_SOURCE, ...sources])).map((source) => ({
value: source,
- // A source we have no name for still filters — the raw key is a worse
- // label than "Slack", but a missing option would be a worse answer.
- label: getOriginProductMeta(source)?.label ?? source,
+ label: sourceLabel(source),
})),
];
@@ -274,6 +297,7 @@ export function ChannelFilterMenu({
label="Type"
options={KIND_OPTIONS}
value={filters.kind}
+ defaultValue={defaultFilters.kind}
onChange={(value) => onFilterChange("kind", value)}
/>
)}
@@ -282,6 +306,7 @@ export function ChannelFilterMenu({
label="Status"
options={ATTENTION_OPTIONS}
value={filters.attention}
+ defaultValue={defaultFilters.attention}
onChange={(value) => onFilterChange("attention", value)}
/>
)}
@@ -293,6 +318,7 @@ export function ChannelFilterMenu({
label="Created by"
options={CREATED_BY_OPTIONS}
value={filters.createdBy}
+ defaultValue={defaultFilters.createdBy}
onChange={(value) => onFilterChange("createdBy", value)}
/>
)}
@@ -300,6 +326,7 @@ export function ChannelFilterMenu({
label="Pinned"
options={PINNED_OPTIONS}
value={filters.pinned}
+ defaultValue={defaultFilters.pinned}
onChange={(value) => onFilterChange("pinned", value)}
/>
{showRunFilters && (
@@ -308,12 +335,14 @@ export function ChannelFilterMenu({
label="Environment"
options={ENVIRONMENT_OPTIONS}
value={filters.environment}
+ defaultValue={defaultFilters.environment}
onChange={(value) => onFilterChange("environment", value)}
/>
<FilterSubmenu
label="Source"
options={sourceOptions}
value={filters.source}
+ defaultValue={defaultFilters.source}
onChange={(value) => onFilterChange("source", value)}
/>
</>
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
index 30d0252b2209..f57c13006996 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemsPane.tsx
@@ -6,7 +6,7 @@ import {
type ChannelItemModel,
channelItemSortEvent,
channelItemSources,
- DEFAULT_CHANNEL_ITEM_FILTERS,
+ DESKTOP_SOURCE,
filterChannelItems,
groupChannelItems,
hasActiveChannelItemFilters,
@@ -47,7 +47,10 @@ import { useCommandCenterStore } from "@posthog/ui/features/command-center/comma
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 {
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ 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";
@@ -158,7 +161,9 @@ export function ChannelItemsPane({
const sources = useMemo(() => channelItemSources(items), [items]);
const filters = useMemo<ChannelItemFilters>(() => {
const sourceMissing =
- rawFilters.source !== ANY_SOURCE && !sources.includes(rawFilters.source);
+ rawFilters.source !== ANY_SOURCE &&
+ rawFilters.source !== DESKTOP_SOURCE &&
+ !sources.includes(rawFilters.source);
const scoped: ChannelItemFilters = {
...rawFilters,
...(hasMultipleAuthors ? {} : { createdBy: "anyone" as const }),
@@ -168,7 +173,10 @@ export function ChannelItemsPane({
? scoped
: { ...scoped, attention: "any", environment: "any", source: ANY_SOURCE };
}, [rawFilters, hasMultipleAuthors, hasRuns, sources]);
- const filtersActive = hasActiveChannelItemFilters(filters);
+ const filtersActive = hasActiveChannelItemFilters(
+ filters,
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ );
const listItems = useMemo(() => {
const ordered = sortChannelItems(
@@ -333,7 +341,10 @@ export function ChannelItemsPane({
onFilterChange={(key, value) =>
setFilters({ ...rawFilters, [key]: value })
}
- onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}
+ onClearFilters={() =>
+ setFilters(DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS)
+ }
+ defaultFilters={DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS}
sort={sort}
onSortChange={setSort}
grouping={grouping}
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.tsx
index 5daf850142d5..6deffc0ce571 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
@@ -1,11 +1,14 @@
import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";
import {
- DEFAULT_CHANNEL_ITEM_FILTERS,
DEFAULT_CHANNEL_ITEM_GROUPING,
DEFAULT_CHANNEL_ITEM_SORT,
+ DESKTOP_SOURCE,
} from "@posthog/core/canvas/channelItems";
import { useAuthStore } from "@posthog/ui/features/auth/store";
-import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
+import {
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ useSidebarStore,
+} from "@posthog/ui/features/sidebar/sidebarStore";
import { Theme } from "@radix-ui/themes";
import { fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -103,7 +106,7 @@ function item(overrides: Partial<ChannelItemModel> = {}): ChannelItemModel {
pinned: false,
rawStatus: null,
environment: null,
- source: null,
+ source: DESKTOP_SOURCE,
needsInput: false,
unread: false,
authorUser: null,
@@ -133,7 +136,7 @@ function renderSidebar() {
beforeEach(() => {
useSidebarStore.setState({
- channelItemFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
+ channelItemFilters: DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
channelItemSort: DEFAULT_CHANNEL_ITEM_SORT,
channelItemGrouping: DEFAULT_CHANNEL_ITEM_GROUPING,
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx
index 4bb564009907..28271847b84e 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.test.tsx
@@ -1,4 +1,7 @@
-import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";
+import {
+ type ChannelItemModel,
+ DESKTOP_SOURCE,
+} from "@posthog/core/canvas/channelItems";
import { ChannelItemPreviewCardProvider } from "@posthog/ui/features/canvas/components/ChannelItemHoverCard";
import { Theme } from "@radix-ui/themes";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
@@ -128,7 +131,7 @@ function entry(index: number): {
pinned: false,
rawStatus: null,
environment: null,
- source: null,
+ source: DESKTOP_SOURCE,
needsInput: false,
unread: false,
authorUser: null,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx
index f8d8b6974a6b..10f8ed1f6640 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/work/WorkColumn.tsx
@@ -6,7 +6,6 @@ import {
import {
type ChannelItemModel,
channelItemSources,
- DEFAULT_CHANNEL_ITEM_FILTERS,
filterChannelItems,
groupChannelItems,
hasActiveChannelItemFilters,
@@ -76,7 +75,10 @@ import { useCommandCenterStore } from "@posthog/ui/features/command-center/comma
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 {
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ useSidebarStore,
+} from "@posthog/ui/features/sidebar/sidebarStore";
import { useRenameTask } from "@posthog/ui/features/tasks/useTaskMutations";
import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import {
@@ -554,7 +556,11 @@ export function WorkColumn() {
if (recentItems.length === 0) {
return (
<p className="px-2 py-1 text-[12px] text-muted-foreground">
- {needle || hasActiveChannelItemFilters(filters)
+ {needle ||
+ hasActiveChannelItemFilters(
+ filters,
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ )
? "Nothing here matches."
: "Sessions and canvases you open show up here."}
</p>
@@ -609,7 +615,8 @@ export function WorkColumn() {
<ChannelFilterMenu
filters={filters}
onFilterChange={(key, value) => setFilters({ ...filters, [key]: value })}
- onClearFilters={() => setFilters(DEFAULT_CHANNEL_ITEM_FILTERS)}
+ onClearFilters={() => setFilters(DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS)}
+ defaultFilters={DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS}
sort={sort}
onSortChange={setSort}
grouping={grouping}
@@ -620,7 +627,10 @@ export function WorkColumn() {
showRunFilters
showKindFilter
groupings={["date", "space", "repository"]}
- active={hasActiveChannelItemFilters(filters)}
+ active={hasActiveChannelItemFilters(
+ filters,
+ DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
+ )}
/>
);
diff --git a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
index 758a7d2e72ad..2f142272e57d 100644
--- a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.test.ts
@@ -1,3 +1,8 @@
+import {
+ ANY_SOURCE,
+ DEFAULT_CHANNEL_ITEM_FILTERS,
+ DESKTOP_SOURCE,
+} from "@posthog/core/canvas/channelItems";
import { describe, expect, it } from "vitest";
import { useSidebarStore } from "./sidebarStore";
@@ -21,4 +26,43 @@ describe("sidebarStore", () => {
]);
localStorage.removeItem("sidebar-storage");
});
+
+ it.each([
+ {
+ label: "the old default",
+ version: 0,
+ source: ANY_SOURCE,
+ expected: DESKTOP_SOURCE,
+ },
+ {
+ label: "an old explicit source",
+ version: 0,
+ source: "slack",
+ expected: "slack",
+ },
+ {
+ label: "the new Any source choice",
+ version: 1,
+ source: ANY_SOURCE,
+ expected: ANY_SOURCE,
+ },
+ ])("rehydration preserves $label", async ({ version, source, expected }) => {
+ localStorage.setItem(
+ "sidebar-storage",
+ JSON.stringify({
+ state: {
+ channelItemFilters: {
+ ...DEFAULT_CHANNEL_ITEM_FILTERS,
+ source,
+ },
+ },
+ version,
+ }),
+ );
+
+ await useSidebarStore.persist.rehydrate();
+
+ expect(useSidebarStore.getState().channelItemFilters.source).toBe(expected);
+ localStorage.removeItem("sidebar-storage");
+ });
});
diff --git a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
index 11ffca493f77..baba6299b052 100644
--- a/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/sidebarStore.ts
@@ -1,10 +1,12 @@
import {
+ ANY_SOURCE,
type ChannelItemFilters,
type ChannelItemGrouping,
type ChannelItemSort,
DEFAULT_CHANNEL_ITEM_FILTERS,
DEFAULT_CHANNEL_ITEM_GROUPING,
DEFAULT_CHANNEL_ITEM_SORT,
+ DESKTOP_SOURCE,
} from "@posthog/core/canvas/channelItems";
import { ALL_WORKSPACE_MODES } from "@posthog/core/sidebar/buildSidebarData";
import type { WorkspaceMode } from "@posthog/shared";
@@ -70,6 +72,11 @@ interface SidebarStoreActions {
type SidebarStore = SidebarStoreState & SidebarStoreActions;
+export const DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS: ChannelItemFilters = {
+ ...DEFAULT_CHANNEL_ITEM_FILTERS,
+ source: DESKTOP_SOURCE,
+};
+
export const useSidebarStore = create<SidebarStore>()(
persist(
(set) => ({
@@ -86,7 +93,7 @@ export const useSidebarStore = create<SidebarStore>()(
showAllUsers: false,
showInternal: false,
taskTypeFilter: [...ALL_WORKSPACE_MODES],
- channelItemFilters: DEFAULT_CHANNEL_ITEM_FILTERS,
+ channelItemFilters: DEFAULT_SIDEBAR_CHANNEL_ITEM_FILTERS,
channelItemSort: DEFAULT_CHANNEL_ITEM_SORT,
channelItemGrouping: DEFAULT_CHANNEL_ITEM_GROUPING,
workSectionHeights: {},
@@ -160,6 +167,23 @@ export const useSidebarStore = create<SidebarStore>()(
}),
{
name: "sidebar-storage",
+ version: 1,
+ migrate: (persisted, version) => {
+ const state = persisted as {
+ channelItemFilters?: Partial<ChannelItemFilters>;
+ };
+ const source = state.channelItemFilters?.source;
+ if (version >= 1 || (source !== undefined && source !== ANY_SOURCE)) {
+ return state;
+ }
+ return {
+ ...state,
+ channelItemFilters: {
+ ...state.channelItemFilters,
+ source: DESKTOP_SOURCE,
+ },
+ };
+ },
partialize: (state) => ({
open: state.open,
hasUserSetOpen: state.hasUserSetOpen,