: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): turn the session header's marks into controls (#84117)
Adam Leithcc76b98b23de
diff --git a/products/desktop/packages/core/src/git-interaction/prStatus.ts b/products/desktop/packages/core/src/git-interaction/prStatus.tsindex 9d9e99090204..866d885d9fc3 100644--- a/products/desktop/packages/core/src/git-interaction/prStatus.ts+++ b/products/desktop/packages/core/src/git-interaction/prStatus.ts@@ -9,6 +9,12 @@ export interface PrAction {export interface PrVisualConfig {color: "gray" | "green" | "red" | "purple";+ /**+ * Draw the badge as a solid, brand-coloured control rather than a tinted one.+ * Only a draft takes it: every other state reports what happened to the PR,+ * while a draft is the one waiting on someone to press "Ready for review".+ */+ solid?: boolean;icon: PrVisualIcon;label: string;actions: PrAction[];@@ -38,6 +44,7 @@ export function getPrVisualConfig(if (draft) {return {color: "gray",+ solid: true,icon: "pull-request",label: "Draft",actions: [diff --git a/products/desktop/packages/ui/src/features/canvas/AGENTS.md b/products/desktop/packages/ui/src/features/canvas/AGENTS.mdindex 346a0d672f9d..75b56138af0f 100644--- a/products/desktop/packages/ui/src/features/canvas/AGENTS.md+++ b/products/desktop/packages/ui/src/features/canvas/AGENTS.md@@ -133,6 +133,12 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The rootthis window has the session, otherwise the closing prose a cloud run persiststo `latest_run.output.final_message`.Neither costs a request.+- **The open session's header wears the same marks under bluebird.** `TaskHeaderMark` / `TaskHeaderActions` (task-detail) draw `taskDot` and `taskBadges` around the title, from `useTaskStatusInput` — the row hook's task-shaped half, which `useChannelTaskStatus` now delegates to.+ Off the flag the header keeps its workspace-mode glyph, and the PR lookup is skipped with it.+ So the cloud glyph goes: it said where the run lives and nothing about whether the run wants anything, and in this vocabulary cloud is silent — running there is the default, so only the local exception earns a badge.+- **After the title they are controls, not an avatar stack.** The header is one line about one session, sitting beside a live copy-link button, so what it can act on it draws as quill icon buttons: the pin toggles (always shown, filled when pinned), and a badge carrying a `url` opens it.+ Badges with nothing to go to — `Local`, a plain origin — stay marks with a tooltip, sized to the button box so the row doesn't step as badges come and go.+ The PR badge is dropped here: `TaskActionsMenu` sits at the end of the same row and already draws the PR in its lifecycle colour with its actions behind it.- **The card's badges are buttons where they point somewhere; the row's never are.** A row is a `<button>`, so its badges stay spans — the card isn't, so a badge carrying a `url` opens it externally and is underlined, dotted, to say so.`taskBadges` sets the url on the PR badges, and on the origin badge for Slack — the one origin that hands back a place to go (`slack_thread_url` off the run's state), rather than just naming itself.A PR's url reaches the badge by two routes: a cloud run's `pr_url`, or the one the host cached against the task, which `getTaskPrStatus` returns alongside the state so a local PR is clickable too.diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelBreadcrumb.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelBreadcrumb.tsxindex 9941cab26aff..0411d3482f98 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelBreadcrumb.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelBreadcrumb.tsx@@ -136,10 +136,6 @@ export function ChannelBreadcrumb({<><BreadcrumbSeparator />{editing && onRename ? (- // Matches the segment it replaces — same height, padding and type- // scale as a `size="sm"` button — so opening the editor doesn't- // jump the row. It takes the rest of the row, since a long name is- // exactly what you're most likely to be editing.<HeaderTitleEditorinitialTitle={leafLabel}onSubmit={(next) => {@@ -150,24 +146,25 @@ export function ChannelBreadcrumb({className="h-6 px-2 font-normal text-[13px]"/>) : onRename ? (- // Only a renamable leaf gets a tooltip: it carries a user-authored- // name that can be long enough to truncate. Fixed section labels- // never overflow, so a tooltip there is just noise.<Tooltip><TooltipTrigger render={<span className="flex min-w-0" />}>- {/* A renamable leaf is a live control — a click opens the- editor — so it reads as one: full-strength text, pointer- cursor, hover fill. */}<BreadcrumbSegment- icon={leafIcon}+ icon={<span className="mr-0.5">{leafIcon}</span>}label={leafLabel}+ shrinkonClick={() => setEditingScope(currentEditScope)}+ className="pr-1"/></TooltipTrigger><TooltipContent>{leafLabel}</TooltipContent></Tooltip>) : (- <BreadcrumbSegment icon={leafIcon} label={leafLabel} muted />+ <BreadcrumbSegment+ icon={leafIcon}+ label={leafLabel}+ muted+ shrink+ />)}{leafTrailing && (<span className="flex shrink-0 items-center">{leafTrailing}</span>@@ -195,12 +192,16 @@ function BreadcrumbSegment({label,strong,muted,+ shrink,onClick,contextMenu = false,+ className,...rest}: {icon?: ReactNode;label: string;+ /** The leaf gives up width first, since it carries the longest name. */+ shrink?: boolean;/** The root segment carries the space name, which reads heavier. */strong?: boolean;/** The leaf is the current page, so it sits back from the linked segments. */@@ -208,6 +209,7 @@ function BreadcrumbSegment({/** Navigates, or (on a renamable leaf) opens the inline editor. */onClick?: () => void;contextMenu?: boolean;+ className?: string;}) {const interactive = Boolean(onClick);@@ -221,6 +223,11 @@ function BreadcrumbSegment({onClick={onClick}className={cn("no-drag min-w-0",+ // `shrink` beats quill's own `shrink-0`. Only the leaf takes it: a+ // segment that cannot shrink keeps its full width in a row that has+ // run out, and paints its label over the marks after it. The fixed+ // segments stay whole, so a long session name is what gives.+ shrink && "shrink",// Live segments (a link, or a click-to-rename leaf) behave like// any other button: pointer cursor and hover fill. Inert ones read as// plain text — full opacity, ordinary cursor, and no hover (quill's@@ -228,6 +235,7 @@ function BreadcrumbSegment({interactive || contextMenu? "cursor-pointer!": "pointer-events-none cursor-default! opacity-100!",+ className,)}>{icon && (diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsxindex 3a9b9e12ecd5..6e98408a6365 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx@@ -405,7 +405,7 @@ export function WebsiteLayout() {and skipped entirely when there is neither a title nor a session'sactions to carry. */}{!showToolbar && (headerContent || channelTask) && (- <div className="flex h-10 shrink-0 items-center gap-2 border-gray-6 border-b px-3">+ <div className="flex h-10 shrink-0 items-center gap-2 border-gray-6 border-b pr-2 pl-1"><div className="flex h-full min-w-0 flex-1 items-center justify-between overflow-hidden">{headerContent}</div>diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelTaskStatus.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelTaskStatus.tsindex cb89b95d6a51..14c29d99a4d0 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelTaskStatus.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelTaskStatus.ts@@ -1,33 +1,35 @@import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";+import type { Task } from "@posthog/shared/domain-types";import { useChannelTaskData } from "@posthog/ui/features/canvas/hooks/useChannelTaskData";import type { TaskStatusInput } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus";import { useWorkspace } from "@posthog/ui/features/workspace/useWorkspace";+export interface TaskStatusOptions {+ /**+ * Whether to resolve the PR's state. It is a query per row into the host,+ * where it hits git (and GitHub), so a list that only glances at its rows —+ * the space tree in the sidebar — leaves it off and shows the rest. The+ * PR's existence still comes through `prUrl`, which costs nothing.+ */+ withPrStatus?: boolean;+}+/**- * The state behind a channel row's status dot and badges, or `null` for a canvas- * (which has no run to report).+ * The state behind a session's status dot and badges, or `null` for anything+ * with no run to report (a canvas row, a session whose data hasn't landed).*- * Assembled per row, the same way the Code sidebar's `TaskRow` does it, because- * that's the only place the inputs exist together: the derived flags come from- * renderer state (live session, workspace, viewed timestamps) and the PR state- * from a per-task query, so none of it can be baked into the item list in core.- * Keeping the composition in a hook rather than in the row leaves the row a- * component that renders, and gives tests one module to stub.+ * Assembled per surface, the same way the Code sidebar's `TaskRow` does it,+ * because that's the only place the inputs exist together: the derived flags+ * come from renderer state (live session, workspace, viewed timestamps) and the+ * PR state from a per-task query, so none of it can be baked into the item list+ * in core. Keeping the composition in a hook rather than in the row leaves the+ * row a component that renders, and gives tests one module to stub.*/-export function useChannelTaskStatus(- item: ChannelItemModel,- options?: {- /**- * Whether to resolve the PR's state. It is a query per row into the host,- * where it hits git (and GitHub), so a list that only glances at its rows —- * the space tree in the sidebar — leaves it off and shows the rest. The- * PR's existence still comes through `prUrl`, which costs nothing.- */- withPrStatus?: boolean;- },+export function useTaskStatusInput(+ task: Task | undefined,+ options?: TaskStatusOptions,): TaskStatusInput | null {- const task = item.task ?? undefined;const taskData = useChannelTaskData(task);const workspace = useWorkspace(task?.id);const { prState, hasDiff, prUrl } = useTaskPrStatus({@@ -60,3 +62,14 @@ export function useChannelTaskStatus(prUrl: taskData.cloudPrUrl ?? prUrl,};}++/**+ * The same state for a channel row, which holds the whole task on the item so a+ * row doesn't have to look it up again.+ */+export function useChannelTaskStatus(+ item: ChannelItemModel,+ options?: TaskStatusOptions,+): TaskStatusInput | null {+ return useTaskStatusInput(item.task ?? undefined, options);+}diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/CloudGitInteractionHeader.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/CloudGitInteractionHeader.tsxindex 82e08e71671c..564db72b7957 100644--- a/products/desktop/packages/ui/src/features/git-interaction/components/CloudGitInteractionHeader.tsx+++ b/products/desktop/packages/ui/src/features/git-interaction/components/CloudGitInteractionHeader.tsx@@ -118,7 +118,6 @@ export function CloudGitInteractionHeader({<><div className="no-drag flex items-center"><QuillButton- variant="outline"size="sm"disabled={inProgress}onClick={() =>diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsxindex 26154dbce8e2..3c67a59934f2 100644--- a/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx+++ b/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx@@ -3,7 +3,7 @@ import {type PrVisualConfig,parsePrNumber,} from "@posthog/core/git-interaction/prStatus";-import { Button, Flex, Spinner, Text } from "@radix-ui/themes";+import { Button, cn, Spinner } from "@posthog/quill";import { getPrVisualIcon } from "../prIcon";interface PRBadgeLinkProps {@@ -12,15 +12,10 @@ interface PRBadgeLinkProps {merged: boolean;draft: boolean;isPrPending?: boolean;- /**- * When true, flatten the right edge so a dropdown trigger button can sit- * flush against this badge (used by TaskActionsMenu's combined control).- */- attachedRight?: boolean;/*** Compact pill matching the other badges in the command-center cell header* (text-[10px], small padding). Renders as a plain anchor instead of a- * Radix Button.+ * button.*/compact?: boolean;/**@@ -37,6 +32,36 @@ const COMPACT_COLOR_CLASSES: Record<PrVisualConfig["color"], string> = {purple: "bg-(--purple-3) text-(--purple-11) hover:bg-(--purple-4)",};+/**+ * The PR's lifecycle colour, as classes for a quill button. quill's variants+ * are one neutral palette by design, and this badge's whole job is to say+ * merged from closed from open at a glance — so the tint comes from the Radix+ * token layer, which is what the app's colour scales live in anyway.+ */+const PR_BADGE_TONE_CLASSES: Record<PrVisualConfig["color"], string> = {+ gray: "bg-(--gray-3) text-(--gray-11) not-disabled:hover:bg-(--gray-4) not-disabled:hover:text-(--gray-12)",+ green:+ "bg-(--green-3) text-(--green-11) not-disabled:hover:bg-(--green-4) not-disabled:hover:text-(--green-12)",+ red: "bg-(--red-3) text-(--red-11) not-disabled:hover:bg-(--red-4) not-disabled:hover:text-(--red-12)",+ purple:+ "bg-(--purple-3) text-(--purple-11) not-disabled:hover:bg-(--purple-4) not-disabled:hover:text-(--purple-12)",+};++/**+ * How a badge wears its lifecycle state, as props for a quill button. A solid+ * state takes quill's own primary; the rest take their tint.+ *+ * Exported because the dropdown trigger that sits beside the badge in a+ * `ButtonGroup` has to wear the same thing, or the group reads as two controls.+ */+export function prBadgeToneProps(config: PrVisualConfig): {+ variant?: "primary";+ className?: string;+} {+ if (config.solid) return { variant: "primary" };+ return { className: PR_BADGE_TONE_CLASSES[config.color] };+}+// Divider ahead of the PR-count segment, tinted to the badge's own color.const COUNT_DIVIDER_CLASSES: Record<PrVisualConfig["color"], string> = {gray: "border-(--gray-a6)",@@ -57,13 +82,13 @@ export function PRBadgeLink({merged,draft,isPrPending = false,- attachedRight = false,compact = false,otherCount = 0,}: PRBadgeLinkProps) {const config = getPrVisualConfig(prState, merged, draft);const PrIcon = getPrVisualIcon(config.icon);const prNumber = parsePrNumber(prUrl);+ const tone = prBadgeToneProps(config);const totalCount = otherCount + 1;const stackTitle =@@ -80,7 +105,7 @@ export function PRBadgeLink({className={`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] no-underline ${COMPACT_COLOR_CLASSES[config.color]}`}>{isPrPending ? (- <Spinner size="1" />+ <Spinner className="size-2.5" />) : (<PrIcon size={10} weight="bold" />)}@@ -95,43 +120,39 @@ export function PRBadgeLink({return (<Button- size="1"- variant="soft"- color={config.color}- asChild- className={attachedRight ? "rounded-r-none" : undefined}+ size="sm"+ // The anchor is the button, so the badge is one thing to click and one+ // thing to tab to — and inside a `ButtonGroup` it takes the group's own+ // corner treatment instead of a hand-flattened right edge.+ render={+ // biome-ignore lint/a11y/useAnchorContent: the content is the button's children, across a render prop the rule can't follow, and `aria-label` names it anyway+ <a+ href={prUrl}+ target="_blank"+ rel="noopener noreferrer"+ title={stackTitle}+ // The label the button's own children spell out. Named here because+ // the anchor is the rendered element, and its content arrives from+ // the button around it.+ aria-label={`Open ${config.label}${prNumber ? ` #${prNumber}` : ""} on GitHub${stackTitle ? `, ${totalCount} on this task` : ""}`}+ onClick={(e) => e.stopPropagation()}+ />+ }+ variant={tone.variant}+ className={cn("no-underline", tone.className)}>- <a- href={prUrl}- target="_blank"- rel="noopener noreferrer"- onClick={(e) => e.stopPropagation()}- title={stackTitle}- >- <Flex align="center" gap="2">- {isPrPending ? (- <Spinner size="1" />- ) : (- <PrIcon size={12} weight="bold" />- )}- {/* 12px matches the quill size="sm" buttons this badge sits beside- in the task header (the app bumps Radix --font-size-1 to 13px). */}- <Text size="1" className="text-[12px]">- {config.label}- {prNumber && ` #${prNumber}`}- </Text>- {otherCount > 0 && (- <Flex- align="center"- className={`border-l pl-2 ${COUNT_DIVIDER_CLASSES[config.color]}`}- >- <Text size="1" className="text-[12px]">- {totalCount}- </Text>- </Flex>- )}- </Flex>- </a>+ {isPrPending ? <Spinner className="size-3" /> : <PrIcon weight="bold" />}+ <span>+ {config.label}+ {prNumber && ` #${prNumber}`}+ </span>+ {otherCount > 0 && (+ <span+ className={`border-l pl-2 ${COUNT_DIVIDER_CLASSES[config.color]}`}+ >+ {totalCount}+ </span>+ )}</Button>);}diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsxindex 6ebcc47687b5..2e15ecb314cd 100644--- a/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx+++ b/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx@@ -12,17 +12,25 @@ import { getPrVisualConfig } from "@posthog/core/git-interaction/prStatus";import { parseGithubUrl } from "@posthog/git/utils";import {ButtonGroup,+ ButtonGroupSeparator,+ cn,DropdownMenuContent,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,DropdownMenuTrigger,Button as QButton,DropdownMenu as QDropdownMenu,DropdownMenuItem as QDropdownMenuItem,+ Spinner,+ Tooltip,+ TooltipContent,+ TooltipTrigger,} from "@posthog/quill";import type { PrActionType } from "@posthog/shared";-import { ChevronDownIcon } from "@radix-ui/react-icons";-import { Button, DropdownMenu, Flex, Spinner, Text } from "@radix-ui/themes";import { ChevronDown } from "lucide-react";-import { Tooltip } from "../../../primitives/Tooltip";+import type { ReactNode } from "react";import { toast } from "../../../primitives/toast";import { useLocalRepoPath } from "../../workspace/useLocalRepoPath";import { getPrActionIcon, getPrVisualIcon } from "../prIcon";@@ -47,7 +55,7 @@ import {GitCommitDialog,GitPushDialog,} from "./GitInteractionDialogs";-import { PRBadgeLink } from "./PRBadgeLink";+import { PRBadgeLink, prBadgeToneProps } from "./PRBadgeLink";interface TaskActionsMenuProps {taskId: string;@@ -289,6 +297,7 @@ function PrBadgeControl({onOtherPrSelect,}: PrBadgeControlProps) {const config = getPrVisualConfig(prState, merged, draft);+ const tone = prBadgeToneProps(config);const lifecycleItems = config.actions;const hasMenuItems = gitItems.length + lifecycleItems.length > 0;const hasDropdown = hasMenuItems || !!branchName || otherPrs.length > 0;@@ -304,113 +313,103 @@ function PrBadgeControl({};return (- <Flex align="center" gap="0">+ <ButtonGroup><PRBadgeLinkprUrl={prUrl}prState={prState}merged={merged}draft={draft}isPrPending={isPrPending}- attachedRight={hasDropdown}otherCount={otherPrs.length}/>{hasDropdown && (- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <Button- size="1"- variant="soft"- color={config.color}- disabled={isPrPending}- style={{- borderTopLeftRadius: 0,- borderBottomLeftRadius: 0,- borderLeft: `1px solid var(--${config.color}-6)`,- paddingLeft: "6px",- paddingRight: "6px",- }}- >- <ChevronDownIcon />- </Button>- </DropdownMenu.Trigger>- <DropdownMenu.Content size="1" align="end">+ <>+ {/* quill's group only collapses corners, and both halves share one+ fill, so without a seam the trigger disappears into the badge. */}+ <ButtonGroupSeparator />+ <ChevronMenu+ label="Pull request actions"+ disabled={isPrPending}+ // The trigger wears the badge's own lifecycle colour: the group is+ // one control, and a neutral half beside a green one reads as two.+ variant={tone.variant}+ className={tone.className}+ >{gitItems.map((item) => (<GitDropdownItemkey={item.id}action={item}onSelect={onGitSelect}- renderAs="radix"/>))}{gitItems.length > 0 && lifecycleItems.length > 0 && (- <DropdownMenu.Separator />+ <DropdownMenuSeparator />)}{lifecycleItems.map((action) => (- <DropdownMenu.Item+ <QDropdownMenuItemkey={action.id}- onSelect={() => onPrSelect(action.id)}+ onClick={() => onPrSelect(action.id)}>- <Flex align="center" gap="2">- {getPrActionIcon(action.id)}- <Text size="1">{action.label}</Text>- </Flex>- </DropdownMenu.Item>+ {getPrActionIcon(action.id)}+ {action.label}+ </QDropdownMenuItem>))}{otherPrs.length > 0 && (<>- {hasMenuItems && <DropdownMenu.Separator />}- <DropdownMenu.Sub>- <DropdownMenu.SubTrigger>- <Flex align="center" gap="2">- <GitPullRequest size={12} weight="bold" />- <Text size="1">Other PRs</Text>- </Flex>- </DropdownMenu.SubTrigger>- <DropdownMenu.SubContent>+ {hasMenuItems && <DropdownMenuSeparator />}+ <DropdownMenuSub>+ <DropdownMenuSubTrigger>+ <GitPullRequest size={12} weight="bold" />+ Other PRs+ </DropdownMenuSubTrigger>+ <DropdownMenuSubContent>{otherPrs.map((otherPr) => (- <DropdownMenu.Item+ <QDropdownMenuItemkey={otherPr.url}- onSelect={() => onOtherPrSelect(otherPr.url)}+ onClick={() => onOtherPrSelect(otherPr.url)}>- <Flex align="center" gap="2">- <OtherPrStateIcon visual={otherPr.visual} />- <Text size="1">- {otherPr.label}- {otherPr.summary && <Text> {otherPr.summary}</Text>}- {otherPr.visual && (- <Text color={otherPr.visual.color}>- {" "}- · {otherPr.visual.label}- </Text>- )}- {otherPr.repoLabel && (- <Text color="gray"> · {otherPr.repoLabel}</Text>- )}- </Text>- </Flex>- </DropdownMenu.Item>+ <OtherPrStateIcon visual={otherPr.visual} />+ <span>+ {otherPr.label}+ {otherPr.summary && ` ${otherPr.summary}`}+ {otherPr.visual && (+ <span+ style={{+ color: `var(--${otherPr.visual.color}-11)`,+ }}+ >+ {" "}+ · {otherPr.visual.label}+ </span>+ )}+ {otherPr.repoLabel && (+ <span className="text-muted-foreground">+ {" "}+ · {otherPr.repoLabel}+ </span>+ )}+ </span>+ </QDropdownMenuItem>))}- </DropdownMenu.SubContent>- </DropdownMenu.Sub>+ </DropdownMenuSubContent>+ </DropdownMenuSub></>)}{branchName && (<>{(hasMenuItems || otherPrs.length > 0) && (- <DropdownMenu.Separator />+ <DropdownMenuSeparator />)}- <DropdownMenu.Item onSelect={copyBranchName}>- <Flex align="center" gap="2">- <Copy size={12} weight="bold" />- <Text size="1">Copy branch name</Text>- </Flex>- </DropdownMenu.Item>+ <QDropdownMenuItem onClick={copyBranchName}>+ <Copy size={12} weight="bold" />+ Copy branch name+ </QDropdownMenuItem></>)}- </DropdownMenu.Content>- </DropdownMenu.Root>+ </ChevronMenu>+ </>)}- </Flex>+ </ButtonGroup>);}@@ -439,25 +438,38 @@ function GitActionControl({}: GitActionControlProps) {const allDisabled = actions.every((a) => !a.enabled);const showDropdown = actions.length > 1;- const variant = allDisabled ? "default" : "primary";const isPrimaryDisabled = !primaryAction.enabled || isBusy;+ // Outlined rather than solid: the git action is one of several things the+ // header offers, not the header's call to action, and "Continue in cloud"+ // sits right beside it.const primaryButton = (<QButton- variant={variant}+ size="sm"+ variant="outline"disabled={isPrimaryDisabled}onClick={() => onSelect(primaryAction.id)}- className="bg-primary text-primary-foreground not-disabled:hover:bg-primary/80 hover:text-primary-foreground/80">- {isBusy ? <Spinner size="1" /> : getGitActionIcon(primaryAction.id)}+ {isBusy ? (+ <Spinner className="size-3" />+ ) : (+ getGitActionIcon(primaryAction.id)+ )}{primaryAction.label}</QButton>);const wrappedPrimaryButton =!primaryAction.enabled && primaryAction.disabledReason ? (- <Tooltip content={primaryAction.disabledReason} side="bottom">- <span style={{ display: "inline-flex" }}>{primaryButton}</span>+ <Tooltip>+ {/* A disabled button takes no pointer events, so the span is what the+ tooltip listens on. */}+ <TooltipTrigger render={<span className="inline-flex" />}>+ {primaryButton}+ </TooltipTrigger>+ <TooltipContent side="bottom">+ {primaryAction.disabledReason}+ </TooltipContent></Tooltip>) : (primaryButton@@ -470,77 +482,93 @@ function GitActionControl({return (<ButtonGroup>{wrappedPrimaryButton}- <QDropdownMenu>- <DropdownMenuTrigger- render={- <QButton- className="bg-primary not-disabled:hover:bg-primary/80"- variant={variant}- disabled={isBusy}- />- }- >- <ChevronDown size={12} />- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- {actions.map((action) => (- <GitDropdownItem- key={action.id}- action={action}- onSelect={onSelect}- renderAs="quill"- />- ))}- </DropdownMenuContent>- </QDropdownMenu>+ <ChevronMenu+ label={`More ${primaryAction.label.toLowerCase()} actions`}+ disabled={isBusy}+ variant="outline"+ >+ {actions.map((action) => (+ <GitDropdownItem+ key={action.id}+ action={action}+ onSelect={onSelect}+ />+ ))}+ </ChevronMenu></ButtonGroup>);}+/**+ * The second half of a split control: a chevron that opens the rest of what the+ * button beside it can do.+ *+ * `w-auto` because quill pins a menu to its anchor's width, and this anchor is+ * a chevron the width of a glyph — every label came out cut off at the menu's+ * 8rem floor.+ */+function ChevronMenu({+ label,+ disabled,+ variant,+ className,+ children,+}: {+ label: string;+ disabled?: boolean;+ variant?: "outline" | "primary";+ className?: string;+ children: ReactNode;+}) {+ return (+ <QDropdownMenu>+ <DropdownMenuTrigger+ render={+ <QButton+ size="sm"+ aria-label={label}+ variant={variant}+ disabled={disabled}+ // quill keeps a disabled button focusable, so it carries+ // `aria-disabled` rather than `:disabled` and a tint's hover rules+ // still fire. No pointer, no hover.+ className={cn(+ "px-1.5 aria-disabled:pointer-events-none",+ className,+ )}+ />+ }+ >+ <ChevronDown size={12} />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-auto">+ {children}+ </DropdownMenuContent>+ </QDropdownMenu>+ );+}+// --- Shared dropdown item for git actions (rendered in either menu kind) ---function GitDropdownItem({action,onSelect,- renderAs,}: {action: GitMenuAction;onSelect: (id: GitMenuActionId) => void;- renderAs: "quill" | "radix";}) {- const icon = getGitActionIcon(action.id);- const label = action.label;-- if (renderAs === "radix") {- const item = (- <DropdownMenu.Item- disabled={!action.enabled}- onSelect={() => onSelect(action.id)}- >- <Flex align="center" gap="2">- {icon}- <Text size="1">{label}</Text>- </Flex>- </DropdownMenu.Item>- );- return !action.enabled && action.disabledReason ? (- <Tooltip content={action.disabledReason} side="left">- <span>{item}</span>- </Tooltip>- ) : (- item- );- }-const itemContent = (<>- {icon} {label}+ {getGitActionIcon(action.id)} {action.label}</>);if (!action.enabled && action.disabledReason) {return (- <Tooltip content={action.disabledReason} side="left">- <QDropdownMenuItem disabled>{itemContent}</QDropdownMenuItem>+ <Tooltip>+ <TooltipTrigger render={<span className="flex" />}>+ <QDropdownMenuItem disabled>{itemContent}</QDropdownMenuItem>+ </TooltipTrigger>+ <TooltipContent side="left">{action.disabledReason}</TooltipContent></Tooltip>);}diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsxindex 74d6464da76c..a27e7da40bd6 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx@@ -43,13 +43,14 @@ const TOOLTIP_DELAY_MS = 200;* that can't receive the pointer can't be hovered, can't swallow a click meant* for the row underneath, and can't have its text dragged into a selection.*/-function RowTooltip({+export function RowTooltip({label,side,children,}: {label: string;- side: "top" | "right";+ /** Where the row sits: `bottom` for the window header, which has no room above. */+ side: "top" | "right" | "bottom";children: ReactElement;}) {return (diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts b/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.tsindex 304d6c79ef0b..efdaa8c2979f 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts@@ -223,87 +223,124 @@ export interface TaskBadge {}/**- * Identity → badges, widest context first so the stack reads left-to-right as- * "who asked, where it runs, what came out of it".- *- * Only the local case says where it runs. Running in the cloud is what a task- * does by default, and a badge on the majority of rows is a badge nobody reads —- * so cloud is silent and the laptop marks the exception. A cloud row with- * nothing else to say carries no badges at all, which is the honest shape:- * nothing has happened to it yet.- *- * Origins share ONE glyph, with Slack as the exception. Eight product marks at- * avatar size is a vocabulary nobody learns — and the badge's job in a nav row- * is "this didn't come from you", which is the same fact whether Slack or error- * tracking filed it. The tooltip names the actual product for anyone who needs- * it. Slack keeps its own mark because it's the one origin where the row came- * from a person in a thread, and readers already know that logo on sight.- *- * The PR badge is the exception that gets colour: merged / ready / closed is the- * outcome people actually scan a task list for, and it's a three-value- * vocabulary on a glyph that already means "pull request".+ * The PR the task opened, if it has one. Merged / ready / closed is the outcome+ * people actually scan a task list for, and it is a three-value vocabulary on a+ * glyph that already means "pull request", so this is the one badge with+ * colour.*/-export function taskBadges(props: TaskStatusInput): TaskBadge[] {- const badges: TaskBadge[] = [];- const origin = getOriginProductMeta(props.originProduct);- const isSlack = props.originProduct === "slack";- if (origin) {- badges.push({- key: "origin",- Icon: isSlack ? SlackMark : ArrowSquareIn,- label: `Source: ${origin.label}`,- // Slack is the one origin that hands back a place to go: the thread the- // task was filed from. Other products name themselves and stop there.- url: isSlack ? (props.slackThreadUrl ?? undefined) : undefined,- });- }+function pullRequestBadge(+ props: TaskStatusInput,+ hideResolved: boolean,+): TaskBadge | null {const prUrl = props.prUrl ?? undefined;+ // A surface that draws PR state itself only draws it once the state has+ // resolved, so the url-only badge below still has to speak for the window+ // before that — and for the lookups that never resolve at all.+ if (hideResolved && props.prState != null) return null;if (props.prState === "merged") {- badges.push({+ return {key: "pr",Icon: GitMerge,label: "Merged",tone: "purple",url: prUrl,- });- } else if (props.prState === "open") {- badges.push({+ };+ }+ if (props.prState === "open") {+ return {key: "pr",Icon: GitPullRequest,label: "PR ready for review",tone: "green",url: prUrl,- });- } else if (props.prState === "closed") {- badges.push({+ };+ }+ if (props.prState === "closed") {+ return {key: "pr",Icon: GitPullRequest,label: "PR closed unmerged",tone: "red",url: prUrl,- });- } else if (props.prState === "draft") {+ };+ }+ if (props.prState === "draft") {// Mid grey: a draft is a real PR, so it earns a solid glyph, but it isn't// asking for anything yet — grey is the "exists, no verdict" slot.- badges.push({+ return {key: "pr",Icon: GitPullRequest,label: "Draft PR",tone: "gray",url: prUrl,- });- } else if (props.prUrl) {+ };+ }+ if (props.prUrl) {// A PR we know exists but haven't resolved the state of. Uncoloured on// purpose: colour here is a verdict, and inventing one would be worse than// saying "there's a PR, go look". Showing the badge is not optional — a// task that opened a PR and shows no sign of it reads as having done// nothing.- badges.push({+ return {key: "pr",Icon: GitPullRequest,label: "Pull request",url: props.prUrl,+ };+ }+ return null;+}++/**+ * Identity → badges, widest context first so the stack reads left-to-right as+ * "who asked, where it runs, what came out of it".+ *+ * Only the local case says where it runs. Running in the cloud is what a task+ * does by default, and a badge on the majority of rows is a badge nobody reads —+ * so cloud is silent and the laptop marks the exception. A cloud row with+ * nothing else to say carries no badges at all, which is the honest shape:+ * nothing has happened to it yet.+ *+ * Origins share ONE glyph, with Slack as the exception. Eight product marks at+ * avatar size is a vocabulary nobody learns — and the badge's job in a nav row+ * is "this didn't come from you", which is the same fact whether Slack or error+ * tracking filed it. The tooltip names the actual product for anyone who needs+ * it. Slack keeps its own mark because it's the one origin where the row came+ * from a person in a thread, and readers already know that logo on sight.+ *+ * The PR badge is the exception that gets colour, and lives in+ * {@link pullRequestBadge}.+ */+export function taskBadges(+ props: TaskStatusInput,+ {+ /**+ * Off where the surface draws PR state itself — the session header, whose+ * git control sits at the end of the same row. Only the states that+ * control renders are dropped.+ */+ includePr = true,+ }: { includePr?: boolean } = {},+): TaskBadge[] {+ const badges: TaskBadge[] = [];+ const origin = getOriginProductMeta(props.originProduct);+ const isSlack = props.originProduct === "slack";+ if (origin) {+ badges.push({+ key: "origin",+ Icon: isSlack ? SlackMark : ArrowSquareIn,+ label: `Source: ${origin.label}`,+ // Slack is the one origin that hands back a place to go: the thread the+ // task was filed from. Other products name themselves and stop there.+ url: isSlack ? (props.slackThreadUrl ?? undefined) : undefined,});+ }+ // Asking here rather than filtering the result keeps the rest of the stack+ // intact: a filtered list loses the "Local" badge, which only appears when+ // nothing else does.+ const pr = pullRequestBadge(props, !includePr);+ if (pr) {+ badges.push(pr);} else if (props.hasDiff) {badges.push({key: "branch",diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsxindex 169a2eca7df5..312991fea626 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx@@ -38,7 +38,7 @@ import { useWorkspaceEvents } from "../../workspace/useWorkspaceEvents";import { HeaderTitleEditor } from "../HeaderTitleEditor";import { useTaskData } from "../hooks/useTaskData";import { CustomImageBadge } from "./CustomImageBadge";-import { WorkspaceModeBadge } from "./WorkspaceModeBadge";+import { TaskHeaderMark, TaskHeaderMarks } from "./TaskHeaderStatus";const MIN_REVIEW_WIDTH = 300;const log = logger.scope("task-detail");@@ -204,7 +204,8 @@ export function TaskDetail({channelId={channelId}leafIcon={<span className="flex items-center gap-1.5">- <WorkspaceModeBadge+ <TaskHeaderMark+ task={task}mode={workspaceMode}checkoutPath={effectiveRepoPath}/>@@ -214,7 +215,12 @@ export function TaskDetail({leafLabel={task.title}editScopeKey={taskId}onRename={handleTitleEditSubmit}- leafTrailing={trailing}+ leafTrailing={+ <span className="flex shrink-0 items-center gap-0">+ <TaskHeaderMarks task={task} />+ {trailing}+ </span>+ }/>) : (<Flex align="center" justify="between" gap="2" width="100%">@@ -226,7 +232,8 @@ export function TaskDetail({/>) : (<Flex align="center" gap="2" minWidth="0">- <WorkspaceModeBadge+ <TaskHeaderMark+ task={task}mode={workspaceMode}checkoutPath={effectiveRepoPath}/>@@ -240,6 +247,7 @@ export function TaskDetail({{task.title}</Text></Tooltip>+ <TaskHeaderMarks task={task} /></Flex>)}{trailing}diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsxindex 88e8a5919f6f..c9d2dea3b70c 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx@@ -74,7 +74,6 @@ function LocalHandoffButton({ taskId, task }: { taskId: string; task: Task }) {<><div className="no-drag flex items-center"><QuillButton- variant="outline"size="sm"disabled={inProgress}onClick={() =>@@ -164,8 +163,10 @@ export function TaskHeaderActions({ task }: { task: Task }) {<>{isCloudTask ? (<>- <StopCloudRunButton taskId={task.id} />+ {/* Stopping the run comes after the handoff: it ends the session,+ and the last thing in a row reads as the last resort. */}<CloudGitInteractionHeader taskId={task.id} task={task} />+ <StopCloudRunButton taskId={task.id} /></>) : (<LocalHandoffButton taskId={task.id} task={task} />diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.test.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.test.tsxnew file mode 100644index 000000000000..cf18a902d22a--- /dev/null+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.test.tsx@@ -0,0 +1,192 @@+import type { Task } from "@posthog/shared/domain-types";+import type { TaskStatusInput } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";+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";++// The status comes from live session/workspace state and a per-task tRPC query,+// none of which a unit test has. Stubbed at the module boundary, as+// ChannelItemRow.test.tsx does for the same reason.+const mocks = vi.hoisted(() => ({+ bluebird: true,+ status: null as TaskStatusInput | null,+ togglePin: vi.fn(async (_taskId: string) => undefined),+ openExternalUrl: vi.fn(),+ toast: { success: vi.fn(), error: vi.fn() },+}));+vi.mock("@posthog/ui/features/feature-flags/useBluebirdFlag", () => ({+ useBluebirdFlag: () => mocks.bluebird,+}));+vi.mock("@posthog/ui/features/canvas/hooks/useChannelTaskStatus", () => ({+ useTaskStatusInput: () => mocks.status,+}));+vi.mock("@posthog/ui/features/sidebar/usePinnedTasks", () => ({+ usePinnedTasks: () => ({ togglePin: mocks.togglePin }),+}));+vi.mock("@posthog/ui/shell/openExternal", () => ({+ openExternalUrl: mocks.openExternalUrl,+}));+vi.mock("@posthog/ui/primitives/toast", () => ({ toast: mocks.toast }));++import { TaskHeaderMark, TaskHeaderMarks } from "./TaskHeaderStatus";++const task = { id: "task-1" } as Task;++function renderMark() {+ return render(+ <Theme>+ <TaskHeaderMark task={task} mode="cloud" />+ </Theme>,+ );+}++function renderMarks() {+ return render(+ <Theme>+ <TaskHeaderMarks task={task} />+ </Theme>,+ );+}++describe("TaskHeaderStatus", () => {+ beforeEach(() => {+ mocks.bluebird = true;+ mocks.status = { workspaceMode: "cloud" };+ mocks.togglePin.mockClear();+ mocks.togglePin.mockResolvedValue(undefined);+ mocks.openExternalUrl.mockClear();+ mocks.toast.success.mockClear();+ mocks.toast.error.mockClear();+ });++ it.each([+ ["needs your input", { needsPermission: true }, "Needs your input"],+ ["a settled session", {}, "All caught up"],+ ])(+ "names the state under project-bluebird for %s",+ (_case, status: TaskStatusInput, label) => {+ mocks.status = { workspaceMode: "cloud", ...status };+ renderMark();++ expect(screen.getByRole("img", { name: label })).toBeInTheDocument();+ },+ );++ it("keeps the workspace-mode glyph when project-bluebird is off", () => {+ mocks.bluebird = false;+ const { container } = renderMark();++ // The mode glyph carries its name in a tooltip rather than a role, so the+ // dot's absence is what says the old header is still drawn.+ expect(screen.queryByRole("img")).not.toBeInTheDocument();+ expect(container.querySelector("svg")).toBeInTheDocument();+ });++ it("moves where the session runs into a badge, so cloud stays silent", () => {+ mocks.status = { workspaceMode: "local" };+ const { rerender } = renderMarks();++ // A fact about the session, not a control: it names itself and stops there.+ expect(screen.getByRole("img", { name: "Local" })).toBeInTheDocument();+ expect(+ screen.queryByRole("button", { name: "Local" }),+ ).not.toBeInTheDocument();++ mocks.status = { workspaceMode: "cloud" };+ rerender(+ <Theme>+ <TaskHeaderMarks task={task} />+ </Theme>,+ );++ expect(+ screen.queryByRole("img", { name: "Local" }),+ ).not.toBeInTheDocument();+ });++ it.each([+ ["pinned", true, "Unpin", "Unpinned"],+ ["unpinned", false, "Pin", "Pinned"],+ ])(+ "toggles the pin from the header when %s, and says so",+ async (_case, isPinned: boolean, label: string, confirmation: string) => {+ mocks.status = { workspaceMode: "cloud", isPinned };+ renderMarks();++ await userEvent.click(screen.getByRole("button", { name: label }));++ expect(mocks.togglePin).toHaveBeenCalledWith("task-1");+ expect(mocks.toast.success).toHaveBeenCalledWith(confirmation);+ },+ );++ it.each([+ [+ "a resolved PR, which the git control draws",+ {+ prState: "open" as const,+ prUrl: "https://github.com/PostHog/posthog/pull/1",+ },+ false,+ ],+ [+ "a PR whose state hasn't landed, which nothing else draws yet",+ { prUrl: "https://github.com/PostHog/posthog/pull/1" },+ true,+ ],+ ] satisfies [string, TaskStatusInput, boolean][])(+ "shows %s",+ (_case, pr: TaskStatusInput, shown: boolean) => {+ mocks.status = { workspaceMode: "cloud", ...pr };+ renderMarks();++ const badge = screen.queryByRole("button", { name: /pull request/i });+ expect(!!badge).toBe(shown);+ },+ );++ it("keeps the badges a PR used to hide", () => {+ // The header drops the PR badge, and `taskBadges` only falls back to+ // "Local" when nothing else spoke — so dropping it after the fact left a+ // local session with a PR wearing no badge at all.+ mocks.status = {+ workspaceMode: "local",+ prState: "open" as const,+ prUrl: "https://github.com/PostHog/posthog/pull/1",+ };+ renderMarks();++ expect(screen.getByRole("img", { name: "Local" })).toBeInTheDocument();+ });++ it("reports a pin that didn't take, rather than leaving the mark to lie", async () => {+ mocks.status = { workspaceMode: "cloud", isPinned: false };+ mocks.togglePin.mockRejectedValueOnce(new Error("offline"));+ renderMarks();++ await userEvent.click(screen.getByRole("button", { name: "Pin" }));++ expect(mocks.toast.error).toHaveBeenCalledWith(+ "Couldn't pin",+ expect.objectContaining({ description: "offline" }),+ );+ });++ it("opens the thread a session was filed from", async () => {+ mocks.status = {+ workspaceMode: "cloud",+ originProduct: "slack",+ slackThreadUrl: "https://example.slack.com/archives/C1/p1",+ };+ renderMarks();++ await userEvent.click(+ screen.getByRole("button", { name: "Source: Slack" }),+ );++ expect(mocks.openExternalUrl).toHaveBeenCalledWith(+ "https://example.slack.com/archives/C1/p1",+ );+ });+});diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.tsxnew file mode 100644index 000000000000..6aff819e28cd--- /dev/null+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderStatus.tsx@@ -0,0 +1,236 @@+import { PushPin } from "@phosphor-icons/react";+import { Button } from "@posthog/quill";+import type { WorkspaceMode } from "@posthog/shared";+import { getErrorMessage } from "@posthog/shared";+import type { Task } from "@posthog/shared/domain-types";+import { useTaskStatusInput } from "@posthog/ui/features/canvas/hooks/useChannelTaskStatus";+import { useBluebirdFlag } from "@posthog/ui/features/feature-flags/useBluebirdFlag";+import {+ RowTooltip,+ TaskStatusDot,+ TaskStatusTooltips,+} from "@posthog/ui/features/sidebar/components/items/TaskStatusDot";+import {+ type TaskBadge,+ type TaskStatusInput,+ TONE_ICON_VAR,+ taskBadges,+ taskDot,+} from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";+import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";+import { WorkspaceModeBadge } from "@posthog/ui/features/task-detail/components/WorkspaceModeBadge";+import { toast } from "@posthog/ui/primitives/toast";+import { openExternalUrl } from "@posthog/ui/shell/openExternal";+import { type ReactNode, useState } from "react";++// What quill's `icon-sm` button renders a glyph at. The marks that aren't+// buttons take it too, so a row of them doesn't change glyph size halfway.+const ICON_SIZE = 12;++/**+ * The session's state for the window header, or `null` where the header keeps+ * its old workspace-mode glyph — outside project-bluebird, and before the+ * task's state has landed.+ */+function useHeaderStatus(task: Task): TaskStatusInput | null {+ const bluebird = useBluebirdFlag();+ // The PR lookup is the one part that reaches the host, so it goes no further+ // than the surface that draws it.+ const status = useTaskStatusInput(task, { withPrStatus: bluebird });+ return bluebird ? status : null;+}++/**+ * The header's marks are the space list's, so a session reads the same open in+ * front of you as it does in the list you opened it from. `no-drag` because the+ * header is a window drag region, and a mark whose tooltip never opens is a+ * mark that says nothing.+ */+function HeaderMarks({ children }: { children: ReactNode }) {+ return (+ <TaskStatusTooltips>+ <span className="no-drag flex shrink-0 items-center">{children}</span>+ </TaskStatusTooltips>+ );+}++/**+ * A header mark you can press, drawn as the header's own icon button so unpin+ * and "open the thread" look like the copy-link button beside them rather than+ * like the list's avatars.+ */+function HeaderButton({+ label,+ loading,+ onClick,+ children,+}: {+ label: string;+ /** Blocks a second press without taking the button out of reach. */+ loading?: boolean;+ onClick: () => void;+ children: ReactNode;+}) {+ return (+ // Below, because the header is the top of the window.+ <RowTooltip label={label} side="bottom">+ <Button+ size="icon-sm"+ aria-label={label}+ loading={loading}+ onClick={onClick}+ >+ {children}+ </Button>+ </RowTooltip>+ );+}++/**+ * The mark before the session's title in the window header: its state dot,+ * whose tooltip names the state in the same words the space list uses.+ *+ * It replaces the cloud / laptop / worktree glyph, which said where the run+ * lives and nothing about whether it wants anything from you. Where the run+ * lives moves to {@link TaskHeaderMarks}, and in that vocabulary the cloud is+ * silent: running there is what a session does by default, so only the local+ * exception earns a badge.+ */+export function TaskHeaderMark({+ task,+ mode,+ checkoutPath,+}: {+ task: Task;+ mode?: WorkspaceMode;+ /** Directory the task runs in, for the workspace-mode glyph's tooltip. */+ checkoutPath?: string | null;+}) {+ const status = useHeaderStatus(task);+ if (!status) {+ return <WorkspaceModeBadge mode={mode} checkoutPath={checkoutPath} />;+ }+ return (+ <HeaderMarks>+ <TaskStatusDot dot={taskDot(status)} />+ </HeaderMarks>+ );+}++/**+ * The pin, as the control it names. In the space list the pin is a badge on a+ * row that can't hold controls; the header is one line about one session, so+ * the mark that says "you put this here" is also how you put it there and take+ * it back.+ *+ * Drawn whether or not the session is pinned, because a control that vanishes+ * once used can only be undone from somewhere else.+ */+function HeaderPinButton({+ taskId,+ pinned,+}: {+ taskId: string;+ pinned: boolean;+}) {+ const { togglePin } = usePinnedTasks();+ const [toggling, setToggling] = useState(false);+ return (+ <HeaderButton+ label={pinned ? "Unpin" : "Pin"}+ loading={toggling}+ onClick={() => {+ setToggling(true);+ togglePin(taskId)+ .then(() => toast.success(pinned ? "Unpinned" : "Pinned"))+ .catch((error: unknown) =>+ toast.error(pinned ? "Couldn't unpin" : "Couldn't pin", {+ description: getErrorMessage(error),+ }),+ )+ .finally(() => setToggling(false));+ }}+ >+ {/* Amber, the list's own choice for a pin: it says "you put this here"+ without joining the states that are asking for something. Unpinned+ takes the button's colour, so it reads as an offer. */}+ <PushPin+ size={ICON_SIZE}+ weight={pinned ? "fill" : "regular"}+ className={pinned ? "text-primary" : undefined}+ />+ </HeaderButton>+ );+}++/**+ * One of the session's badges. A badge that points somewhere — the Slack thread+ * it was filed from, the PR it opened — is a button that goes there. The rest+ * state a fact about the session, so they stay plain marks with the same+ * tooltip rather than buttons whose hover promises a click that does nothing.+ */+function HeaderBadge({+ badge: { Icon, label, tone, url },+}: {+ badge: TaskBadge;+}) {+ const glyph = (+ // An explicit `color` (an SVG fill) rather than a text-* class where the+ // vocabulary sets a tone, the same way the list's badges are drawn.+ <Icon+ aria-hidden+ size={ICON_SIZE}+ weight={tone ? "fill" : "regular"}+ color={tone ? TONE_ICON_VAR[tone] : undefined}+ className={!tone && !url ? "text-muted-foreground" : undefined}+ />+ );+ if (!url) {+ return (+ <RowTooltip label={label} side="bottom">+ {/* Dimmer than the buttons beside it, and sized to their box so a row of+ marks doesn't step as badges come and go. A mark you can't press+ shouldn't look like one you can. */}+ <span+ aria-label={label}+ role="img"+ className="flex size-6 shrink-0 items-center justify-center"+ >+ {glyph}+ </span>+ </RowTooltip>+ );+ }+ return (+ <HeaderButton label={label} onClick={() => openExternalUrl(url)}>+ {glyph}+ </HeaderButton>+ );+}++/**+ * What rides after the title: unpin, open the Slack thread, open the PR, and+ * the badges that only have something to say.+ *+ * Drawn as the header's own icon buttons rather than the space list's stacked+ * avatars. A list row is a `<button>`, so its badges can only ever be marks; the+ * header is one line about one session sitting next to a live copy-link button,+ * and beside it a stack of overlapping avatars reads as decoration.+ *+ * The pin is always here, even on a session with nothing else to say: a control+ * that disappears once used can only be undone from somewhere else.+ */+export function TaskHeaderMarks({ task }: { task: Task }) {+ const status = useHeaderStatus(task);+ if (!status) return null;+ return (+ <HeaderMarks>+ <HeaderPinButton taskId={task.id} pinned={!!status.isPinned} />+ {/* No PR badge: the git control at the end of the same row already draws+ the PR, in colour, with its actions behind it. */}+ {taskBadges(status, { includePr: false }).map((badge) => (+ <HeaderBadge key={badge.key} badge={badge} />+ ))}+ </HeaderMarks>+ );+}