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): stop composer toolbar clipping in narrow panels (#103179)

ruby childs4d7db2d76028
diff --git a/products/desktop/packages/ui/src/features/message-editor/components/ModeSelector.tsx b/products/desktop/packages/ui/src/features/message-editor/components/ModeSelector.tsx
index 4fbdaa4fa124..1c4048bcf862 100644
--- a/products/desktop/packages/ui/src/features/message-editor/components/ModeSelector.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/components/ModeSelector.tsx
@@ -9,6 +9,9 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
MenuLabel,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from "@posthog/quill";
import { flattenSelectOptions } from "@posthog/ui/features/sessions/sessionStore";
import { useRetainedConfigOption } from "@posthog/ui/features/sessions/useRetainedConfigOption";
@@ -105,7 +108,27 @@ export function ModeSelector({
disabled={isDisabled}
aria-label="Mode"
>
- <span>{currentLabel}</span>
+ {/* A mode name as long as "Bypass Permissions" is the widest
+ control on the row, so it gives up its tail once the composer
+ is narrower than the shorter model name and the icon-only
+ queue toggle can answer for. The tooltip keeps the whole name
+ reachable. A harness can name a mode anything, so the label is
+ cut by width rather than by a table of short names we would
+ have to guess. */}
+ <Tooltip>
+ {/* The label rather than the button, which the menu focuses
+ again as it closes. A tooltip on a focused trigger opens by
+ itself and then swallows the next Escape, so the approval
+ dialog behind this one never sees it. */}
+ <TooltipTrigger
+ render={
+ <span className="@max-[400px]/composer:max-w-20 truncate">
+ {currentLabel}
+ </span>
+ }
+ />
+ <TooltipContent side="top">{currentLabel}</TooltipContent>
+ </Tooltip>
</Button>
}
/>
diff --git a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
index 9e3717d47d4f..de63342f02e8 100644
--- a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
@@ -547,6 +547,39 @@ export const NoToolbar: Story = {
},
};
+// The canvas side panel opens at 420px and carries the widest realistic
+// toolbar: a long model name, a long permission mode, and the trailing status
+// group. Everything has to stay inside the panel, which clips its overflow.
+export const NarrowPanel: Story = {
+ name: "Toolbar: narrow panel (canvas side panel width)",
+ args: {
+ sessionId: "sb-narrow",
+ modeOption: {
+ ...mockModeOption,
+ currentValue: "bypassPermissions",
+ options: [
+ ...mockModeOption.options,
+ { value: "bypassPermissions", name: "Bypass Permissions" },
+ ],
+ },
+ reasoningSelector: (
+ <ReasoningLevelSelector
+ thoughtOption={mockReasoningOption}
+ modelOption={{ ...mockModelOption, currentValue: "claude-sonnet-5" }}
+ adapter="claude"
+ onChange={() => {}}
+ />
+ ),
+ },
+ decorators: [
+ (Story) => (
+ <div className="w-[420px]">
+ <Story />
+ </div>
+ ),
+ ],
+};
+
export const WithHeaderAddon: Story = {
name: "Header addon above the editor",
args: {
diff --git a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.tsx b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.tsx
index 00d7a1820451..dc636e74b031 100644
--- a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.tsx
@@ -480,10 +480,14 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
// only what you are writing plus the send button. Mirrors the addons' own
// flex/gap/padding so the row keeps their spacing and left inset, and
// carries the muted colour the addons would have supplied.
+ // `@container/composer` lets the controls shorten their own labels when a
+ // narrow host such as the canvas side panel cannot fit them whole. Wrapping
+ // is what happens after that, because the host clips the overflow instead
+ // of scrolling it, so a clipped control would be unreachable.
const toolbar = (!hideDefaultToolbar ||
toolbarEndSlot ||
messagingModeToggle) && (
- <div className="flex select-none items-center gap-1 whitespace-nowrap px-1 text-muted-foreground">
+ <div className="@container/composer flex select-none flex-wrap items-center gap-1 whitespace-nowrap px-1 text-muted-foreground">
{!hideDefaultToolbar && (
<>
<AttachmentMenu
@@ -524,7 +528,7 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
)}
</>
)}
- <span className="ml-auto flex items-center gap-1">
+ <span className="ml-auto flex flex-wrap items-center justify-end gap-1">
{toolbarEndSlot}
{!hideDefaultToolbar && historyButton}
{messagingModeToggle}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/ContextUsageIndicator.tsx b/products/desktop/packages/ui/src/features/sessions/components/ContextUsageIndicator.tsx
index f6ee54f00d56..49cee83bbd9a 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/ContextUsageIndicator.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/ContextUsageIndicator.tsx
@@ -48,7 +48,7 @@ export function ContextUsageIndicator({
const showCost = taskUsage !== undefined;
const showCostText = showCost && costVisible;
const costText = showCostText ? (
- <Text className="select-none font-medium text-[13px] text-gray-11 tabular-nums">
+ <Text className="select-none font-medium text-[13px] text-muted-foreground tabular-nums">
{formatCostUsd(taskUsage.total_cost_usd)}
</Text>
) : null;
diff --git a/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx b/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx
index 784d9045b1b7..83eec0486dbc 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx
@@ -15,6 +15,9 @@ import {
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from "@posthog/quill";
import {
adapterForModelId,
@@ -37,6 +40,7 @@ import {
} from "@posthog/ui/features/sessions/components/HarnessSubmenu";
import { ModelSelectList } from "@posthog/ui/features/sessions/components/ModelSelectList";
import { SubscriptionSubmenu } from "@posthog/ui/features/sessions/components/SubscriptionSubmenu";
+import { shortModelLabel } from "@posthog/ui/features/sessions/components/shortModelLabel";
import type { WorkspaceModeForAccess } from "@posthog/ui/features/settings/adapterSubscription";
import type { AgentAdapter } from "@posthog/ui/features/settings/settingsStore";
import { AnimatedHeight } from "@posthog/ui/primitives/AnimatedHeight";
@@ -286,6 +290,7 @@ export function ReasoningLevelSelector({
? (modelEntries.find((entry) => entry.value === currentModel)?.name ??
currentModel)
: undefined;
+ const shortLabel = modelLabel ? shortModelLabel(modelLabel) : undefined;
const changeModel = (value: string) => {
if (onModelChange) {
@@ -481,7 +486,7 @@ export function ReasoningLevelSelector({
// "Reasoning: undefined".
const triggerAriaLabel =
modelLabel && effortLabel
- ? `Model and reasoning: ${modelLabel} ${effortLabel}`
+ ? `Model and reasoning: ${modelLabel}, ${effortLabel}`
: modelLabel
? `Model: ${modelLabel}`
: effortLabel
@@ -529,9 +534,35 @@ export function ReasoningLevelSelector({
</span>
)}
{modelLabel && (
- <span className="font-medium text-foreground">
- {isDefaultSelection ? `Default · ${modelLabel}` : modelLabel}
- </span>
+ <Tooltip>
+ {/* The name rather than the button, which the menu focuses
+ again as it closes. A tooltip on a focused trigger opens
+ by itself and then swallows the next Escape. */}
+ <TooltipTrigger
+ render={
+ <span className="font-medium text-foreground">
+ {/* A container query cannot swap text, so a narrow
+ composer hides the full name and shows the short one
+ instead. The button carries its own aria-label, so
+ the copy that is hidden never reaches the accessible
+ name. */}
+ <span className="@max-[480px]/composer:hidden">
+ {isDefaultSelection
+ ? `Default · ${modelLabel}`
+ : modelLabel}
+ </span>
+ <span className="@max-[480px]/composer:inline hidden">
+ {isDefaultSelection
+ ? `Default · ${shortLabel}`
+ : shortLabel}
+ </span>
+ </span>
+ }
+ />
+ {/* The full model name, which the trigger shortens when the
+ composer is narrow. */}
+ <TooltipContent side="top">{triggerAriaLabel}</TooltipContent>
+ </Tooltip>
)}
{effortLabel && (
<span
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.test.tsx b/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.test.tsx
index 86ed7a6ae5e5..31d0cabe311d 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.test.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.test.tsx
@@ -28,7 +28,7 @@ function seedSession(overrides: Partial<AgentSession>): void {
});
}
-describe("steer tooltip copy follows the session's native-steer capability", () => {
+describe("steer/queue tooltip copy", () => {
beforeEach(() => {
useSessionStore.setState((state) => {
state.sessions = {};
@@ -36,6 +36,21 @@ describe("steer tooltip copy follows the session's native-steer capability", ()
});
});
+ // A narrow composer drops the button's "Queue (3)" label for the icon alone,
+ // so the tooltip is the only place the count is still readable.
+ it.each([
+ { queuedCount: 0, expected: "holds messages until the current turn ends." },
+ { queuedCount: 1, expected: "1 message waiting." },
+ { queuedCount: 3, expected: "3 messages waiting." },
+ ])(
+ "queue tooltip names $queuedCount waiting message(s)",
+ ({ queuedCount, expected }) => {
+ expect(steerQueueTooltip(false, false, "Cmd+S", queuedCount)).toContain(
+ expected,
+ );
+ },
+ );
+
it.each([
{
name: "codex (local): interrupts and resends",
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.tsx b/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.tsx
index 9f78dec62c35..0050077a940f 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/SteerQueueToggle.tsx
@@ -1,5 +1,11 @@
import { Lightning, Stack } from "@phosphor-icons/react";
-import { Button, cn } from "@posthog/quill";
+import {
+ Button,
+ cn,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
import {
formatHotkey,
SHORTCUTS,
@@ -10,7 +16,6 @@ import {
} from "@posthog/ui/features/sessions/hooks/useMessagingMode";
import { useToggleMessagingMode } from "@posthog/ui/features/sessions/hooks/useToggleMessagingMode";
import { useQueuedMessagesForTask } from "@posthog/ui/features/sessions/useSession";
-import { Tooltip } from "@radix-ui/themes";
interface SteerQueueToggleProps {
taskId: string;
@@ -20,9 +25,16 @@ export function steerQueueTooltip(
isSteer: boolean,
supportsNativeSteer: boolean,
shortcut: string,
+ queuedCount = 0,
): string {
if (!isSteer) {
- return `Queue: holds messages until the current turn ends. ${shortcut} to switch to Steer.`;
+ // The button drops its "Queue" label in a narrow composer, so the count of
+ // waiting messages has nowhere else to be read.
+ const waiting =
+ queuedCount > 0
+ ? ` ${queuedCount} message${queuedCount === 1 ? "" : "s"} waiting.`
+ : "";
+ return `Queue: holds messages until the current turn ends.${waiting} ${shortcut} to switch to Steer.`;
}
return supportsNativeSteer
? `Steer: applies your message at the next safe boundary. The current command may keep running until then. ${shortcut} to switch to Queue.`
@@ -43,41 +55,63 @@ export function SteerQueueToggle({ taskId }: SteerQueueToggleProps) {
? `Queue (${queuedCount})`
: "Queue";
- const tooltip = steerQueueTooltip(isSteer, supportsNativeSteer, shortcut);
+ const tooltip = steerQueueTooltip(
+ isSteer,
+ supportsNativeSteer,
+ shortcut,
+ queuedCount,
+ );
- const colorClass = isSteer ? "text-purple-11" : "text-gray-11";
+ const colorClass = isSteer ? "text-purple-11" : "text-muted-foreground";
return (
- <Tooltip content={tooltip}>
- <Button
- type="button"
- variant="default"
- size="sm"
- aria-label={`Messaging mode: ${label}`}
- onClick={toggle}
- >
- <span className={colorClass}>
- {isSteer ? (
- <Lightning size={12} weight="fill" />
- ) : (
- <Stack size={12} />
- )}
- </span>
- {/* Both labels stack in one grid cell, so the button is always as wide
- as the longer of them. Sized by the label alone, toggling modes
- would shove the rest of the toolbar sideways. */}
- <span className="grid">
- <span aria-hidden className="invisible col-start-1 row-start-1">
- Steer
- </span>
- <span aria-hidden className="invisible col-start-1 row-start-1">
- Queue
- </span>
- <span className={cn("col-start-1 row-start-1", colorClass)}>
- {label}
- </span>
- </span>
- </Button>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="default"
+ size="sm"
+ aria-label={`Messaging mode: ${label}`}
+ onClick={toggle}
+ >
+ <span className={colorClass}>
+ {isSteer ? (
+ <Lightning size={12} weight="fill" />
+ ) : (
+ <Stack size={12} />
+ )}
+ </span>
+ {/* Both labels stack in one grid cell, so the button is always as
+ wide as the longer of them. Sized by the label alone, toggling
+ modes would shove the rest of the toolbar sideways. */}
+ <span className="grid @max-[480px]/composer:hidden">
+ <span aria-hidden className="invisible col-start-1 row-start-1">
+ Steer
+ </span>
+ <span aria-hidden className="invisible col-start-1 row-start-1">
+ Queue
+ </span>
+ <span className={cn("col-start-1 row-start-1", colorClass)}>
+ {label}
+ </span>
+ </span>
+ {/* The icon still names the mode once the label is gone, but the
+ number of waiting messages has no other place on the row. */}
+ {queuedCount > 0 && (
+ <span
+ className={cn(
+ "@max-[480px]/composer:inline hidden",
+ colorClass,
+ )}
+ >
+ {queuedCount}
+ </span>
+ )}
+ </Button>
+ }
+ />
+ <TooltipContent side="top">{tooltip}</TooltipContent>
</Tooltip>
);
}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.test.ts b/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.test.ts
new file mode 100644
index 000000000000..c6fd7b73d520
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.test.ts
@@ -0,0 +1,17 @@
+import { describe, expect, it } from "vitest";
+import { shortModelLabel } from "./shortModelLabel";
+
+describe("shortModelLabel drops the vendor word only where a family follows it", () => {
+ it.each([
+ { label: "Claude Sonnet 5", expected: "Sonnet 5" },
+ { label: "Claude Opus 4.8", expected: "Opus 4.8" },
+ { label: "Claude Fable 5.1", expected: "Fable 5.1" },
+ // A harness, not a model. "Code" alone would name nothing.
+ { label: "Claude Code", expected: "Claude Code" },
+ { label: "GPT-5.6 Sol", expected: "GPT-5.6 Sol" },
+ { label: "GLM-5.3 Flash", expected: "GLM-5.3 Flash" },
+ { label: "Kimi K3", expected: "Kimi K3" },
+ ])("$label reads as $expected", ({ label, expected }) => {
+ expect(shortModelLabel(label)).toBe(expected);
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.ts b/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.ts
new file mode 100644
index 000000000000..2f9bbe173858
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/shortModelLabel.ts
@@ -0,0 +1,17 @@
+/**
+ * A model's name without the vendor word that every Claude model repeats.
+ *
+ * The composer toolbar holds the model, the reasoning effort, the permission mode and
+ * the run's status on one line, so the seven characters in "Claude " cost more room
+ * than they carry: "Sonnet 5" and "Opus 5" name the model on their own.
+ *
+ * Only the model families are stripped. "Claude Code" names a harness rather than a
+ * model, and "Code" alone would not say that. Labels reach a picker from the agent at
+ * runtime rather than from the catalog, so a name this does not recognize is returned
+ * as it came in.
+ */
+const CLAUDE_MODEL_FAMILY = /^Claude (?=(?:Opus|Sonnet|Haiku|Fable)\b)/;
+
+export function shortModelLabel(label: string): string {
+ return label.replace(CLAUDE_MODEL_FAMILY, "");
+}