: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): put starred spaces first in the file-to menu (#82621)
Thomas Obermüller550d0cac7e25
diff --git a/products/desktop/packages/core/src/context-menu/context-menu.test.ts b/products/desktop/packages/core/src/context-menu/context-menu.test.tsindex 1822f63e58b2..d84bce9707a2 100644--- a/products/desktop/packages/core/src/context-menu/context-menu.test.ts+++ b/products/desktop/packages/core/src/context-menu/context-menu.test.ts@@ -163,6 +163,26 @@ describe("ContextMenuService.showTaskContextMenu", () => {expect(labels(menu.lastItems)).toContain("Archive");});+ it("lists starred channels first under File to…", async () => {+ const menu = new FakeContextMenu();+ const result = makeService(menu).showTaskContextMenu({+ ...baseTask,+ channels: [+ { id: "1", name: "alpha" },+ { id: "2", name: "beta", starred: true },+ { id: "3", name: "gamma" },+ { id: "4", name: "delta", starred: true },+ ],+ });+ await menu.shown;+ const submenu = findItem(menu.lastItems, "File to…").submenu ?? [];+ expect(labels(submenu)).toEqual(["#beta", "#delta", "#alpha", "#gamma"]);+ findSubmenuItem(menu.lastItems, "File to…", "#delta").click();+ expect(await result).toEqual({+ action: { type: "file-to-channel", channelId: "4" },+ });+ });+it("resolves to null when the menu is dismissed", async () => {const menu = new FakeContextMenu();const result = makeService(menu).showTaskContextMenu(baseTask);@@ -244,6 +264,20 @@ describe("ContextMenuService.showBulkTaskContextMenu", () => {});});+ it("lists starred channels first under File to…", async () => {+ const menu = new FakeContextMenu();+ makeService(menu).showBulkTaskContextMenu({+ taskCount: 2,+ channels: [+ { id: "c1", name: "support" },+ { id: "c2", name: "design", starred: true },+ ],+ });+ await menu.shown;+ const submenu = findItem(menu.lastItems, "File to…").submenu ?? [];+ expect(labels(submenu)).toEqual(["#design", "#support"]);+ });+it("gates archive on confirmation", async () => {const menu = new FakeContextMenu();const result = makeService(diff --git a/products/desktop/packages/core/src/context-menu/context-menu.ts b/products/desktop/packages/core/src/context-menu/context-menu.tsindex 8ec79e5bc00f..68564a361c32 100644--- a/products/desktop/packages/core/src/context-menu/context-menu.ts+++ b/products/desktop/packages/core/src/context-menu/context-menu.ts@@ -133,7 +133,7 @@ export class ContextMenuService {{type: "submenu",label: "File to…",- items: channels.map((c) => ({+ items: this.starredFirst(channels).map((c) => ({// Channel names are stored bare; every surface that shows one// adds the hash.label: `#${c.name}`,@@ -226,7 +226,7 @@ export class ContextMenuService {{type: "submenu" as const,label: "File to…",- items: channels.map((c) => ({+ items: this.starredFirst(channels).map((c) => ({// Channel names are stored bare; every surface that shows one// adds the hash.label: `#${c.name}`,@@ -395,6 +395,16 @@ export class ContextMenuService {return { type: "separator" };}+ /**+ * "File to…" targets in the order the sidebar lists them: starred first. The+ * sort is stable, so each group keeps the order the caller sent.+ */+ private starredFirst<C extends { starred?: boolean }>(channels: C[]): C[] {+ return [...channels].sort(+ (a, b) => Number(b.starred ?? false) - Number(a.starred ?? false),+ );+ }+private disabled(label: string): MenuItemDef<never> {return { type: "disabled", label };}diff --git a/products/desktop/packages/core/src/context-menu/schemas.ts b/products/desktop/packages/core/src/context-menu/schemas.tsindex ecf76625a55f..a622968dad12 100644--- a/products/desktop/packages/core/src/context-menu/schemas.ts+++ b/products/desktop/packages/core/src/context-menu/schemas.ts@@ -1,5 +1,12 @@import { z } from "zod";+// A "File to…" target. `starred` floats it to the top of the submenu.+const fileToChannel = z.object({+ id: z.string(),+ name: z.string(),+ starred: z.boolean().optional(),+});+export const taskContextMenuInput = z.object({taskTitle: z.string(),worktreePath: z.string().optional(),@@ -12,7 +19,7 @@ export const taskContextMenuInput = z.object({showArchivePrior: z.boolean().optional(),// The project's channels available as "File to…" targets.// Omit (or pass empty) to hide the submenu entirely.- channels: z.array(z.object({ id: z.string(), name: z.string() })).optional(),+ channels: z.array(fileToChannel).optional(),});export const bulkTaskContextMenuInput = z.object({@@ -24,7 +31,7 @@ export const bulkTaskContextMenuInput = z.object({// Whether archiving would also shut a cloud sandbox down.stopsCloudSandbox: z.boolean().optional(),// "File to…" targets. Omit (or pass empty) to hide the submenu entirely.- channels: z.array(z.object({ id: z.string(), name: z.string() })).optional(),+ channels: z.array(fileToChannel).optional(),});export const archivedTaskContextMenuInput = z.object({diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskRowMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskRowMenu.tsxindex 7ab714070a47..6f37d40c4684 100644--- a/products/desktop/packages/ui/src/features/canvas/components/TaskRowMenu.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskRowMenu.tsx@@ -104,6 +104,7 @@ function TaskRowMenuItems({id: channel.id,label: channel.name,current: channel.id === menu.channelId,+ starred: channel.starred,}));return (diff --git a/products/desktop/packages/ui/src/features/sidebar/components/SidebarMenu.tsx b/products/desktop/packages/ui/src/features/sidebar/components/SidebarMenu.tsxindex 26673bedbbcb..fa30e03932e2 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/SidebarMenu.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/SidebarMenu.tsx@@ -223,9 +223,10 @@ function SidebarMenuComponent() {allPinned,runningCount: bulkActions.runningCount,stopsCloudSandbox: bulkActions.stopsCloudSandbox,- channels: bulkActions.channels.map(({ id, name }) => ({+ channels: bulkActions.channels.map(({ id, name, starred }) => ({id,name,+ starred,})),});if (!result.action) return;diff --git a/products/desktop/packages/ui/src/features/tasks/useTaskContextMenu.ts b/products/desktop/packages/ui/src/features/tasks/useTaskContextMenu.tsindex e567d37a89e8..ff6ec86c26dc 100644--- a/products/desktop/packages/ui/src/features/tasks/useTaskContextMenu.ts+++ b/products/desktop/packages/ui/src/features/tasks/useTaskContextMenu.ts@@ -88,7 +88,11 @@ export function useTaskContextMenu() {isInCommandCenter,hasEmptyCommandCenterCell,showArchivePrior,- channels: channels.map(({ id, name }) => ({ id, name })),+ channels: channels.map(({ id, name, starred }) => ({+ id,+ name,+ starred,+ })),});if (!result.action) return;diff --git a/products/desktop/packages/ui/src/primitives/SearchableMenuFlyout.tsx b/products/desktop/packages/ui/src/primitives/SearchableMenuFlyout.tsxindex c801d00e01b5..c5b5610b113c 100644--- a/products/desktop/packages/ui/src/primitives/SearchableMenuFlyout.tsx+++ b/products/desktop/packages/ui/src/primitives/SearchableMenuFlyout.tsx@@ -1,5 +1,5 @@import { Menu as BaseMenu } from "@base-ui/react/menu";-import { Check } from "@phosphor-icons/react";+import { Check, Star } from "@phosphor-icons/react";import {Autocomplete,AutocompleteCollection,@@ -16,6 +16,8 @@ export type MenuFlyoutItem = {label: string;/** Marks the item with a tick — the one already in effect. */current: boolean;+ /** Sorts the item above the rest and marks it with a star. */+ starred?: boolean;icon?: ReactNode;};@@ -84,22 +86,27 @@ export function SearchableMenuFlyout({onSelect,}: SearchableMenuFlyoutProps) {const [query, setQuery] = useState("");- // Active item first as the anchor when switching; the rest sorted the same way- // the web app orders them (locale-aware, which floats emoji-prefixed names- // above plain ones).- const sections = useMemo<MenuFlyoutSection[]>(- () => [+ // Active item first as the anchor when switching, then the starred ones, the+ // same order the sidebar puts them in. Within each group, sorted the way the+ // web app orders them (locale-aware, which floats emoji-prefixed names above+ // plain ones).+ const sections = useMemo<MenuFlyoutSection[]>(() => {+ const rest = items+ .filter((item) => !item.current)+ .sort((a, b) => a.label.localeCompare(b.label));+ return [{items: [...items.filter((item) => item.current),- ...items- .filter((item) => !item.current)- .sort((a, b) => a.label.localeCompare(b.label)),+ ...rest.filter((item) => item.starred),+ ...rest.filter((item) => !item.starred),],},- ],- [items],- );+ ];+ }, [items]);+ // A star column only where stars exist, and then on every row, so the labels+ // of unstarred items stay on the same line as the starred ones.+ const showStars = items.some((item) => item.starred);return (// Keep keystrokes away from the surrounding menu: its typeahead handler sits@@ -163,6 +170,13 @@ export function SearchableMenuFlyout({<Check size={14} className="text-accent-11" />)}</span>+ {showStars && (+ <span className="flex w-4 shrink-0 items-center justify-center">+ {item.starred && (+ <Star size={13} className="text-gray-9" />+ )}+ </span>+ )}{item.icon && (<span className="flex shrink-0 items-center">{item.icon}