: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
fix(desktop): hide context chip when context layer is enabled (#90280)
Peter Kirkham5965c2234234
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.test.tsx b/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.test.tsxnew file mode 100644index 000000000000..ba47814c2ed9--- /dev/null+++ b/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.test.tsx@@ -0,0 +1,38 @@+import { render, screen } from "@testing-library/react";+import type { ComponentProps } from "react";+import { describe, expect, it, vi } from "vitest";+import { ChannelContextChip } from "./ChannelContextChip";+import { shouldShowChannelContextChip } from "./channelContext";++function renderChip(props: ComponentProps<typeof ChannelContextChip>): void {+ render(<ChannelContextChip {...props} />);+}++describe("ChannelContextChip", () => {+ it.each([+ ["resolved context-layer page", true, "/spaces/engineering.md", false],+ ["legacy CONTEXT.md fallback", true, undefined, true],+ ["dismissed legacy context", false, undefined, false],+ ] as const)(+ "shows the chip for %s: %s",+ (_case, includeChannelContext, channelContextPath, expected) => {+ expect(+ shouldShowChannelContextChip(includeChannelContext, channelContextPath),+ ).toBe(expected);+ },+ );++ it("keeps legacy CONTEXT.md removable", () => {+ renderChip({+ channelName: "engineering",+ onRemove: vi.fn(),+ });++ expect(screen.getByText("CONTEXT.md")).toBeInTheDocument();+ expect(+ screen.getByRole("button", {+ name: "Remove #engineering CONTEXT.md",+ }),+ ).toBeInTheDocument();+ });+});diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsxindex a2cc2e3a6382..4c19eaa59f03 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx@@ -121,6 +121,7 @@ import { useWarmTask } from "../hooks/useWarmTask";import { ChannelContextChip } from "./ChannelContextChip";import { CloudGithubMissingNotice } from "./CloudGithubMissingNotice";import { NewTaskSuggestions } from "./ContinueCliSessions";+import { shouldShowChannelContextChip } from "./channelContext";import {type SuggestedPrompt,SuggestedPromptCard,@@ -348,9 +349,8 @@ export function TaskInput({reportAssociation ?? null,);- // Channel CONTEXT.md is included by default; the chip lets the user drop it- // from this task's prompt. Re-include whenever the source context changes- // (e.g. switching channels) so a dismissal doesn't stick across channels.+ // Legacy CONTEXT.md is optional. A resolved context-layer page is a pointer+ // into the session-wide mount and stays connected for the whole session.const [channelContextDismissed, setChannelContextDismissed] = useState(false);const channelContextSource = channelContextPath ?? channelContext;const lastChannelContextRef = useRef(channelContextSource);@@ -361,7 +361,7 @@ export function TaskInput({}}, [channelContextSource]);const includeChannelContext =- !!channelContextSource && !channelContextDismissed;+ !!channelContextPath || (!!channelContext && !channelContextDismissed);const adapter = lastUsedAdapter;const codexSubscription = useCodexSubscription();@@ -1498,7 +1498,10 @@ export function TaskInput({</button>) : null}</span>- ) : includeChannelContext ? (+ ) : shouldShowChannelContextChip(+ includeChannelContext,+ channelContextPath,+ ) ? (<ChannelContextChipchannelName={channelName}onView={onContextChipClick}diff --git a/products/desktop/packages/ui/src/features/task-detail/components/channelContext.ts b/products/desktop/packages/ui/src/features/task-detail/components/channelContext.tsnew file mode 100644index 000000000000..4f5c17f3300c--- /dev/null+++ b/products/desktop/packages/ui/src/features/task-detail/components/channelContext.ts@@ -0,0 +1,6 @@+export function shouldShowChannelContextChip(+ includeChannelContext: boolean,+ channelContextPath?: string,+): boolean {+ return includeChannelContext && !channelContextPath;+}