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.

feat(desktop): space picker in the composer, and composer chrome cleanup (#77565)

Adam Leith47c1855c25aa
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelHomeComposer.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelHomeComposer.tsx
index c70143945075..d92522f564e6 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelHomeComposer.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelHomeComposer.tsx
@@ -452,7 +452,6 @@ export const ChannelHomeComposer = forwardRef<
[sessionId, modeOption, setConfigOption],
);
- const hints = ["@ to add files", "/ for skills"].join(", ");
const isBusy = isCreatingTask || isStartingCanvas;
const submitComposer = canvasArmed ? handleCanvasSubmit : submit;
@@ -484,7 +483,7 @@ export const ChannelHomeComposer = forwardRef<
placeholder={
canvasArmed
? "Describe the canvas to build — the agent generates and publishes it"
- : `What do you want to ship? ${hints}`
+ : `What do you want to ship?`
}
editorHeight="large"
disabled={isBusy}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx
new file mode 100644
index 000000000000..1a64b1f0a8da
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx
@@ -0,0 +1,154 @@
+import {
+ Button,
+ Combobox,
+ ComboboxCollection,
+ ComboboxContent,
+ ComboboxEmpty,
+ ComboboxGroup,
+ ComboboxInput,
+ ComboboxItem,
+ ComboboxLabel,
+ ComboboxList,
+ ComboboxSeparator,
+ ComboboxTrigger,
+} from "@posthog/quill";
+import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
+import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
+import { useMemo, useRef } from "react";
+
+interface SpaceGroup {
+ value: string;
+ items: string[];
+}
+
+/**
+ * Which space a new task files into — a chip for the composer's selector row,
+ * drawn like the EnvironmentSelector and WorkspaceModeSelect beside it. A
+ * project can carry hundreds of spaces, so the list is searchable: starred
+ * spaces (with #me leading) sit above the rest, under the same "Starred" /
+ * "Spaces" headings the sidebar list uses.
+ */
+export function SpaceSelect({
+ value,
+ onChange,
+ disabled = false,
+}: {
+ value: string;
+ onChange: (channelId: string) => void;
+ /**
+ * Held shut while a task is being created. Retargeting mid-submit navigates
+ * away from the composer that owns the in-flight request, so the task lands
+ * in the space you left rather than the one you picked.
+ */
+ disabled?: boolean;
+}) {
+ const { channels } = useChannels();
+ const anchorRef = useRef<HTMLDivElement>(null);
+ const current = channels.find((c) => c.id === value) ?? null;
+
+ const byId = useMemo(
+ () => new Map(channels.map((c) => [c.id, c])),
+ [channels],
+ );
+
+ // Ids, not Channel objects: the channels query repolls and rebuilds its
+ // objects, so a selected object stops matching the list by identity and the
+ // combobox silently drops the selection. Ids compare by value.
+ //
+ // `useChannels` already sorts by name, so both groups stay alphabetical
+ // without re-sorting; #me leads because it's where an unfiled task goes.
+ // An empty group is dropped rather than rendered as a bare heading.
+ const groups = useMemo<SpaceGroup[]>(() => {
+ // #me is hoisted rather than left to the name sort, which would drop it
+ // below any starred space alphabetically ahead of it.
+ const personal = channels.filter((c) => c.channelType === "personal");
+ const starred = [
+ ...personal,
+ ...channels.filter((c) => c.channelType !== "personal" && c.starred),
+ ];
+ const rest = channels.filter(
+ (c) => c.channelType !== "personal" && !c.starred,
+ );
+ return [
+ { value: "Starred", items: starred.map((c) => c.id) },
+ { value: "Spaces", items: rest.map((c) => c.id) },
+ ].filter((group) => group.items.length > 0);
+ }, [channels]);
+
+ const triggerGlyph = channelGlyph(current?.name, { size: 14, space: true });
+
+ return (
+ <Combobox<string>
+ items={groups}
+ value={value}
+ onValueChange={(nextId) => {
+ if (nextId && nextId !== value) onChange(nextId);
+ }}
+ itemToStringLabel={(id) => byId.get(id)?.name ?? ""}
+ disabled={disabled}
+ >
+ <div ref={anchorRef} className="inline-flex">
+ <ComboboxTrigger
+ render={
+ <Button
+ type="button"
+ variant="default"
+ size="sm"
+ disabled={disabled}
+ aria-label="Space"
+ title={current?.name}
+ >
+ {triggerGlyph && (
+ <span className="shrink-0 text-muted-foreground">
+ {triggerGlyph}
+ </span>
+ )}
+ <span className="min-w-0 truncate">
+ {current?.name ?? "Space"}
+ </span>
+ </Button>
+ }
+ />
+ </div>
+ <ComboboxContent
+ anchor={anchorRef}
+ side="bottom"
+ sideOffset={6}
+ className="min-w-[220px]"
+ >
+ <ComboboxInput placeholder="Search spaces..." showTrigger={false} />
+ <ComboboxEmpty>No spaces found.</ComboboxEmpty>
+ <ComboboxList className="max-h-[min(18rem,calc(var(--available-height,18rem)-5rem))]">
+ {/* `index` counts the groups Base UI actually renders, which drops
+ any whose items all filter out, so the rule leads each group
+ after the first rather than trailing every group but the last —
+ the trailing form strands a separator when the tail group is
+ filtered away. */}
+ {(group: SpaceGroup, index: number) => (
+ <ComboboxGroup key={group.value} items={group.items}>
+ {index > 0 && <ComboboxSeparator />}
+ <ComboboxLabel>{group.value}</ComboboxLabel>
+ <ComboboxCollection>
+ {(id: string) => {
+ const space = byId.get(id);
+ if (!space) return null;
+ return (
+ <ComboboxItem
+ key={id}
+ value={id}
+ title={space.name}
+ className="relative"
+ >
+ {channelGlyph(space.name, { size: 14, space: true })}
+ {space.name}
+ </ComboboxItem>
+ );
+ }}
+ </ComboboxCollection>
+ </ComboboxGroup>
+ )}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteNewTask.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteNewTask.tsx
index bc2b4b4da90c..6b28e70cc1e2 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteNewTask.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteNewTask.tsx
@@ -3,6 +3,7 @@ import type { Task } from "@posthog/shared/domain-types";
import { CHANNEL_TASK_SUGGESTIONS } from "@posthog/ui/features/canvas/channelTaskSuggestions";
import { ChannelBreadcrumb } from "@posthog/ui/features/canvas/components/ChannelBreadcrumb";
import { ChannelContextPanel } from "@posthog/ui/features/canvas/components/ChannelContextPanel";
+import { SpaceSelect } from "@posthog/ui/features/canvas/components/SpaceSelect";
import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { useChannelTaskMutations } from "@posthog/ui/features/canvas/hooks/useChannelTasks";
@@ -106,10 +107,38 @@ export function WebsiteNewTask({ channelId }: { channelId: string }) {
[channelId, fileTask, navigate, queryClient],
);
+ // Retargeting navigates to that space's own new-task route; the composer's
+ // draft lives in the shared "task-input" draft store, so text typed before
+ // switching survives the navigation.
+ const handleSpaceChange = useCallback(
+ (nextChannelId: string) => {
+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
+ action_type: "new_task_open",
+ surface: "new_task",
+ channel_id: nextChannelId,
+ });
+ void navigate({
+ to: "/website/$channelId/new",
+ params: { channelId: nextChannelId },
+ });
+ },
+ [navigate],
+ );
+
return (
<Flex className="h-full min-w-0 flex-1">
<div className="min-w-0 flex-1">
<TaskInput
+ // Beside the Cloud/Local chip: which space the task files into.
+ // Arriving from a space's own "+" this is pre-filled; the global
+ // new-task entry points land on #me.
+ spaceSelector={({ disabled }) => (
+ <SpaceSelect
+ value={channelId}
+ onChange={handleSpaceChange}
+ disabled={disabled}
+ />
+ )}
onTaskCreated={onTaskCreated}
channelContext={channelContext}
channelName={channelName}
diff --git a/products/desktop/packages/ui/src/features/message-editor/components/AttachmentMenu.tsx b/products/desktop/packages/ui/src/features/message-editor/components/AttachmentMenu.tsx
index d7d291a0d8d5..26773dd6bebb 100644
--- a/products/desktop/packages/ui/src/features/message-editor/components/AttachmentMenu.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/components/AttachmentMenu.tsx
@@ -15,6 +15,7 @@ import { isRasterImageFile } from "@posthog/shared";
import { useAddDirectoryDialogStore } from "@posthog/ui/features/folder-picker/addDirectoryDialogStore";
import { toast } from "@posthog/ui/primitives/toast";
import { useQuery } from "@tanstack/react-query";
+import { SquareSlash } from "lucide-react";
import { useRef, useState } from "react";
import { getGhStatus, selectAttachments } from "../hostApi";
import {
@@ -32,6 +33,12 @@ interface AttachmentMenuProps {
onAttachFiles?: (files: File[]) => void;
onInsertChip: (chip: MentionChip) => void;
onRemoveChip?: (chipId: string) => void;
+ /**
+ * Writes a slash at the start of the composer, opening the command list the
+ * same way typing one does. Omitted where the menu has no editor to write
+ * into, which hides the item.
+ */
+ onInsertSlashCommand?: () => void;
iconSize?: number;
attachTooltip?: string;
}
@@ -56,6 +63,7 @@ export function AttachmentMenu({
onAttachFiles,
onInsertChip,
onRemoveChip,
+ onInsertSlashCommand,
iconSize = 14,
attachTooltip = "Attach",
}: AttachmentMenuProps) {
@@ -162,6 +170,13 @@ export function AttachmentMenu({
setIssuePickerOpen(true);
};
+ // Close first: the command list opens against the composer, and leaving this
+ // menu up would stack one popup over the other.
+ const handleInsertSlashCommand = () => {
+ setMenuOpen(false);
+ onInsertSlashCommand?.();
+ };
+
const handleIssueSelect = (chip: MentionChip) => {
onInsertChip(chip);
setIssuePickerOpen(false);
@@ -201,17 +216,17 @@ export function AttachmentMenu({
{isWindows ? (
<>
<DropdownMenuItem onClick={handleAddFile}>
- <File size={14} weight="bold" />
+ <File size={14} />
Add file
</DropdownMenuItem>
<DropdownMenuItem onClick={handleAddFolder}>
- <FolderSimple size={14} weight="bold" />
+ <FolderSimple size={14} />
Add folder
</DropdownMenuItem>
</>
) : (
<DropdownMenuItem onClick={handleAddFileOrFolder}>
- <File size={14} weight="bold" />
+ <File size={14} />
Add file or folder
</DropdownMenuItem>
)}
@@ -220,9 +235,18 @@ export function AttachmentMenu({
onClick={handleOpenIssuePicker}
title={issueDisabledReason ?? undefined}
>
- <GithubLogo size={14} weight="bold" />
+ <GithubLogo size={14} />
Add issue or pull request
</DropdownMenuItem>
+ {onInsertSlashCommand && (
+ <DropdownMenuItem onClick={handleInsertSlashCommand}>
+ {/* Lucide's default stroke is heavier than Phosphor's regular
+ weight at the same size: 2/24 of the viewBox against 16/256.
+ 1.5 lands on the same rendered thickness as the icons above. */}
+ <SquareSlash size={14} strokeWidth={1.5} />
+ Slash commands
+ </DropdownMenuItem>
+ )}
</DropdownMenuContent>
</DropdownMenu>
<IssuePicker
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 672f0a7e0ddd..960830d7c579 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
@@ -208,7 +208,7 @@ function PromptInputHarness({
<ContextUsageIndicator usage={contextUsage} />
) : undefined
}
- attachmentsPrefix={
+ submitAdornment={
channelContext ? (
<ChannelContextChip channelName="engineering" onRemove={() => {}} />
) : undefined
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 f8511405c50f..4067c76db2d7 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
@@ -16,7 +16,13 @@ import { hasOpenOverlay } from "@posthog/ui/utils/overlay";
import { Flex, Text, Tooltip } from "@radix-ui/themes";
import { EditorContent } from "@tiptap/react";
import clsx from "clsx";
-import { forwardRef, useCallback, useEffect, useImperativeHandle } from "react";
+import {
+ forwardRef,
+ useCallback,
+ useEffect,
+ useImperativeHandle,
+ useState,
+} from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { useSkills } from "../../skills/useSkills";
import { skillToEditorCommand } from "../commands";
@@ -72,11 +78,14 @@ export interface PromptInputProps {
messagingModeToggle?: React.ReactNode;
historyButton?: React.ReactNode;
/**
- * Rendered in the attachments row at the top of the composer, ahead of the
- * attachments themselves — for context the prompt carries that the user did
- * not attach by hand (e.g. a channel's CONTEXT.md).
+ * Pinned inside the composer box beside the send button — for context the
+ * prompt always carries that the user did not attach by hand (e.g. a
+ * channel's CONTEXT.md). It sits apart from the attachments row on purpose:
+ * hand-picked files come and go, this rides along with every send. The
+ * editor reserves its measured width, so keep it a fixed size rather than
+ * one that changes on hover.
*/
- attachmentsPrefix?: React.ReactNode;
+ submitAdornment?: React.ReactNode;
/**
* Pushed to the far end of the composer's toolbar row — for read-only status
* about the session the prompt goes to (e.g. context usage), as opposed to
@@ -149,7 +158,7 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
reasoningSelector,
messagingModeToggle,
historyButton,
- attachmentsPrefix,
+ submitAdornment,
toolbarEndSlot,
headerAddon,
hideDefaultToolbar = false,
@@ -180,6 +189,24 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
const clearFocusRequest = useDraftStore((s) => s.actions.clearFocusRequest);
const slotMachineMode = useSettingsStore((s) => s.slotMachineMode);
const { data: skills } = useSkills();
+ // Seeded at the send button's own width so the first paint already clears
+ // it, rather than laying the text out full-width and reflowing it.
+ const [submitClusterWidth, setSubmitClusterWidth] = useState(40);
+ // The text's right inset has to clear whatever sits over its bottom-right
+ // corner. That used to be the send button alone (a fixed 40px), but an
+ // adornment beside it makes the width depend on its content, so measure.
+ // A callback ref rather than an effect: the cluster mounts and unmounts
+ // with the button, and this re-observes the new node each time.
+ const submitClusterRef = useCallback((el: HTMLSpanElement | null) => {
+ if (!el) return;
+ const observer = new ResizeObserver(([entry]) => {
+ // The cluster is inset by 4px (right-1); the same again keeps the text
+ // from running up against it.
+ setSubmitClusterWidth(entry.contentRect.width + 8);
+ });
+ observer.observe(el);
+ return () => observer.disconnect();
+ }, []);
const {
editor,
@@ -195,6 +222,7 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
setContent,
insertEditorContent,
insertChip,
+ insertSlashCommand,
removeChipById,
replaceChipAttrs,
attachments,
@@ -437,6 +465,11 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
onAttachFiles={onAttachFiles}
onInsertChip={insertChip}
onRemoveChip={removeChipById}
+ // No `/` extension registered means the item would type a bare
+ // slash and open nothing, so it hides instead.
+ onInsertSlashCommand={
+ enableCommands ? insertSlashCommand : undefined
+ }
/>
{onModeChange && (
<ModeSelector
@@ -448,8 +481,11 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
canvas={canvas}
/>
)}
- {modelSelector && <span>{modelSelector}</span>}
- {reasoningSelector && <span>{reasoningSelector}</span>}
+ {/* Direct flex children, not wrapped in a span: an inline wrapper
+ builds a line box whose leading pushes the trigger a pixel below
+ the toolbar's other buttons. */}
+ {modelSelector}
+ {reasoningSelector}
{isBashMode && (
<Text className="font-mono text-(--blue-9) text-[13px]">
! bash
@@ -479,12 +515,11 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
{headerAddon && (
<InputGroupAddon align="block-start">{headerAddon}</InputGroupAddon>
)}
- {(attachmentsPrefix || attachments.length > 0) && (
+ {attachments.length > 0 && (
<InputGroupAddon align="block-start">
{/* One provider for the row: moving between squares reuses the
open delay instead of re-waiting it per attachment. */}
<TooltipProvider>
- {attachmentsPrefix}
<AttachmentsBar
attachments={attachments}
onRemove={removeAttachment}
@@ -497,11 +532,21 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
column beside it. Laid out beside the text, it would push the
scroll container inwards and strand the scrollbar mid-box; over
it, the container runs to the edge and the bar hugs it. The text
- reserves the button's width so a long line never runs underneath. */}
+ reserves the cluster's width so a long line never runs underneath
+ — measured rather than fixed, because an adornment beside the
+ button makes that width depend on what's in it. */}
<div className="relative w-full">
<div
+ // Gated on the cluster existing rather than trusting the last
+ // measurement: the observer's cleanup can't clear the width, so
+ // a cluster that unmounts (slot-machine mode, then the adornment
+ // removed) would otherwise leave its gutter behind for good.
+ style={{
+ paddingRight:
+ submitButton || submitAdornment ? submitClusterWidth : 8,
+ }}
className={clsx(
- "cli-editor-scroll relative min-h-[37px] w-full overflow-y-auto py-2 pr-10 pl-2 text-[14px]",
+ "cli-editor-scroll relative min-h-[37px] w-full overflow-y-auto py-2 pl-2 text-[14px]",
editorHeight === "large" ? "max-h-[45vh]" : "max-h-[200px]",
// A disabled editor still looks editable: the caret is the only
// tell, and it is absent precisely because you cannot focus it.
@@ -513,8 +558,14 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
>
<EditorContent editor={editor} />
</div>
- {submitButton && (
- <span className="absolute right-1 bottom-1">{submitButton}</span>
+ {(submitButton || submitAdornment) && (
+ <span
+ ref={submitClusterRef}
+ className="absolute right-1 bottom-1 flex items-center gap-1"
+ >
+ {submitAdornment}
+ {submitButton}
+ </span>
)}
</div>
</InputGroup>
diff --git a/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx b/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
index 5b0e54226455..ccc3d6b508ee 100644
--- a/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
@@ -10,7 +10,7 @@ import {
WarningIcon,
XIcon,
} from "@phosphor-icons/react";
-import { Chip } from "@posthog/quill";
+import { Chip, cn } from "@posthog/quill";
import { Tooltip } from "@posthog/ui/primitives/Tooltip";
import { type NodeViewProps, NodeViewWrapper } from "@tiptap/react";
import { usePasteUndoStore } from "../pasteUndoStore";
@@ -88,6 +88,28 @@ function DefaultChip({
const isGithubRef = type === "github_issue" || type === "github_pr";
const canOpenUrl = isGithubRef && /^https:\/\//.test(id);
+ // A skill reads as part of the sentence being written, not as an object
+ // attached to it, so it stays plain text rather than taking a chip's border
+ // and remove button. Selecting it — arrowing onto it, or the backspace that
+ // is about to delete it — turns the run destructive, which is the only
+ // warning left once there is no × to aim at.
+ if (isCommand) {
+ return (
+ <span
+ contentEditable={false}
+ className={cn(
+ "cli-slash-command cursor-default select-all bg-fill-hover px-0.5 font-medium",
+ selected
+ ? "rounded-xs bg-destructive text-destructive-foreground"
+ : "text-primary",
+ )}
+ >
+ {prefix}
+ {label}
+ </span>
+ );
+ }
+
const chipContent = (
<Chip
size="xs"
diff --git a/products/desktop/packages/ui/src/features/message-editor/tiptap/SuggestionList.tsx b/products/desktop/packages/ui/src/features/message-editor/tiptap/SuggestionList.tsx
index 96cb74068e5a..8ce904bbad81 100644
--- a/products/desktop/packages/ui/src/features/message-editor/tiptap/SuggestionList.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/tiptap/SuggestionList.tsx
@@ -4,6 +4,7 @@ import {
ItemContent,
ItemDescription,
ItemMedia,
+ ItemMenuItem,
ItemTitle,
Kbd,
} from "@posthog/quill";
@@ -30,8 +31,11 @@ export interface SuggestionListProps {
loading?: boolean;
}
+// The same surface quill's own menu popups draw (see `.quill-autocomplete__content`),
+// expressed in tokens rather than raw Radix vars so it tracks the design system.
+// tippy owns the positioning, so there is no anchor width to inherit.
const CONTAINER_CLASS =
- "flex w-max min-w-[300px] max-w-[440px] flex-col overflow-hidden rounded-md border border-[var(--gray-a6)] bg-[var(--color-panel-solid)] text-[13px] shadow-lg";
+ "flex w-max min-w-[300px] max-w-[440px] flex-col overflow-hidden rounded-md border border-border bg-card text-[13px] text-foreground shadow-md";
function DefaultRow({ item }: { item: SuggestionItem }) {
const isFolder = item.chipType === "folder";
@@ -46,7 +50,7 @@ function DefaultRow({ item }: { item: SuggestionItem }) {
)}
</ItemMedia>
)}
- <ItemContent variant="menuItem">
+ <ItemContent variant="menuItem" className="p-0">
<ItemTitle className="truncate text-left">{item.label}</ItemTitle>
{item.description && (
<ItemDescription className="truncate text-left">
@@ -113,30 +117,31 @@ export const SuggestionList = forwardRef<
<div className={CONTAINER_CLASS}>
<div
role="listbox"
- className="max-h-60 flex-1 overflow-y-auto [&::-webkit-scrollbar]:hidden"
+ className="scroll-mask-4 max-h-60 flex-1 scroll-py-8 overflow-y-auto p-1"
onMouseMove={() => !hasMouseMoved && setHasMouseMoved(true)}
>
- {items.map((item, index) => {
- const isSelected = index === selectedIndex;
- return (
- <button
- type="button"
- key={item.id}
- ref={(el) => {
- itemRefs.current[index] = el;
- }}
- onClick={() => command(item)}
- onMouseEnter={() => hasMouseMoved && setSelectedIndex(index)}
- className={`flex w-full border-none px-2 py-0.5 text-left ${
- isSelected ? "bg-[var(--accent-a4)]" : ""
- }`}
- >
- {renderItem ? renderItem(item) : <DefaultRow item={item} />}
- </button>
- );
- })}
+ {items.map((item, index) => (
+ <ItemMenuItem
+ key={item.id}
+ ref={(el) => {
+ itemRefs.current[index] = el;
+ }}
+ size="xs"
+ // `option` inside the listbox above, not the `menuitem` this
+ // primitive defaults to. Selection is the plugin's, driven by the
+ // keys it forwards, so it rides on aria-selected rather than the
+ // focus these rows never take (the caret stays in the editor).
+ role="option"
+ aria-selected={index === selectedIndex}
+ onClick={() => command(item)}
+ onMouseEnter={() => hasMouseMoved && setSelectedIndex(index)}
+ className="w-full text-left aria-selected:bg-fill-selected"
+ >
+ {renderItem ? renderItem(item) : <DefaultRow item={item} />}
+ </ItemMenuItem>
+ ))}
</div>
- <div className="flex items-center gap-1 border-[var(--gray-a4)] border-t bg-[var(--gray-a2)] px-2 py-1 text-[11px] text-[var(--gray-10)]">
+ <div className="flex items-center gap-1 border-border border-t bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground">
<Kbd>↑</Kbd>
<Kbd>↓</Kbd>
<span>navigate</span>
diff --git a/products/desktop/packages/ui/src/features/message-editor/tiptap/useTiptapEditor.ts b/products/desktop/packages/ui/src/features/message-editor/tiptap/useTiptapEditor.ts
index 088e5ec65687..914160e7ea0d 100644
--- a/products/desktop/packages/ui/src/features/message-editor/tiptap/useTiptapEditor.ts
+++ b/products/desktop/packages/ui/src/features/message-editor/tiptap/useTiptapEditor.ts
@@ -902,6 +902,16 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
[editor, draft, attachments],
);
+ // Position 1 is the start of the first paragraph. Writing the slash there
+ // and dropping the caret after it leaves the editor in exactly the state
+ // typing "/" would, which is what the suggestion plugin watches for, so the
+ // command list opens on its own rather than needing to be opened here.
+ const insertSlashCommand = useCallback(() => {
+ if (!editor) return;
+ editor.chain().insertContentAt(1, "/").focus(2).run();
+ draft.saveDraft(editor, attachments);
+ }, [editor, draft, attachments]);
+
const removeChipById = useCallback(
(chipId: string) => {
if (!editor) return;
@@ -962,6 +972,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
setContent,
insertEditorContent,
insertChip,
+ insertSlashCommand,
removeChipById,
replaceChipAttrs,
attachments,
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.tsx b/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.tsx
index 3c37b3ae2e0c..9a80b3801586 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/ChannelContextChip.tsx
@@ -1,10 +1,18 @@
-import { Attachment } from "@posthog/ui/features/message-editor/components/Attachment";
+import {
+ Chip,
+ ChipClose,
+ cn,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
/**
- * The channel CONTEXT.md riding along with the prompt, shown in the composer's
- * attachments row. Deliberately the same component the user's own attachments
- * use, because that is what it is from the writer's point of view: something
- * extra travelling with the message, which they can inspect or drop.
+ * The channel CONTEXT.md riding along with the prompt, pinned inside the
+ * composer beside the send button rather than sitting in the attachments row.
+ * It isn't an attachment the writer chose: it comes with the space and travels
+ * with every prompt sent from it, so it keeps its own spot and shows its name
+ * instead of collapsing to an extension square like a real attachment does.
*/
export function ChannelContextChip({
channelName,
@@ -15,12 +23,42 @@ export function ChannelContextChip({
onView?: () => void;
onRemove: () => void;
}) {
+ const chip = (
+ <Chip
+ onClick={onView}
+ size="sm"
+ // Chip renders a <div> so ChipClose can nest legally, but the button
+ // behaviour underneath assumes a real <button> unless told otherwise.
+ // Without this it never binds Enter/Space, so the chip is reachable by
+ // keyboard and then does nothing.
+ nativeButton={false}
+ className={cn(
+ "mt-px shrink-0 pr-1 text-[11px]",
+ !onView && "cursor-default",
+ )}
+ >
+ CONTEXT.md
+ {/* Always rendered, not revealed on hover: the chip sets the editor's
+ right padding, so a width that changes under the cursor would reflow
+ the text being typed. */}
+ <ChipClose
+ aria-label={`Remove ${channelName ? `#${channelName} ` : ""}CONTEXT.md`}
+ className="mr-[-2.5px]"
+ onClick={(event) => {
+ // The chip itself opens the file; removing it must not also do that.
+ event.stopPropagation();
+ onRemove();
+ }}
+ />
+ </Chip>
+ );
+
+ if (!onView) return chip;
+
return (
- <Attachment
- label={`${channelName ? `#${channelName} ` : ""}CONTEXT.md`}
- hint={onView ? "Click to view" : undefined}
- onOpen={onView}
- onRemove={onRemove}
- />
+ <Tooltip>
+ <TooltipTrigger render={chip} />
+ <TooltipContent side="top">Click to view CONTEXT.md</TooltipContent>
+ </Tooltip>
);
}
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.tsx
index 5ca149bbbdee..d3da9b9a25b0 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
@@ -24,7 +24,14 @@ import { track } from "@posthog/ui/shell/analytics";
import { Box, Flex, Text, Tooltip } from "@radix-ui/themes";
import { useQuery } from "@tanstack/react-query";
import { AnimatePresence, motion } from "framer-motion";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ type ReactNode,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { useConnectivity } from "../../../hooks/useConnectivity";
import { DotPatternBackground } from "../../../primitives/DotPatternBackground";
import { toast } from "../../../primitives/toast";
@@ -149,6 +156,13 @@ interface TaskInputProps {
* the chip is non-interactive (only dismissable).
*/
onContextChipClick?: () => void;
+ /**
+ * A space picker chip rendered first in the selector row above the composer
+ * (beside the workspace-mode chip). Channels new-task screen only — /code
+ * has no spaces to pick. Called with the composer's in-flight state so the
+ * picker can hold shut mid-submit, like every other chip in the row.
+ */
+ spaceSelector?: (props: { disabled: boolean }) => ReactNode;
}
export function TaskInput({
@@ -168,6 +182,7 @@ export function TaskInput({
suggestions,
onSuggestionSelect,
onContextChipClick,
+ spaceSelector,
}: TaskInputProps = {}) {
const cloudRegion = useAuthStateValue((s) => s.cloudRegion);
const trpc = useHostTRPC();
@@ -1108,7 +1123,6 @@ export function TaskInput({
useDraftStore.getState().actions.clearCommands(promptSessionId);
};
}, [promptSessionId, skills]);
- const hasHistory = useTaskInputHistoryStore((s) => s.entries.length > 0);
const getPromptHistory = useCallback(
() => useTaskInputHistoryStore.getState().entries.map((e) => e.text),
[],
@@ -1121,13 +1135,6 @@ export function TaskInput({
() => !(editorRef.current?.isEmpty() ?? true),
[],
);
- const hints = [
- "@ to add files",
- "/ for skills",
- hasHistory ? "\u2191\u2193 for history" : "",
- ]
- .filter(Boolean)
- .join(", ");
useAutoFocusOnTyping(editorRef, isCreatingTask);
@@ -1215,13 +1222,14 @@ export function TaskInput({
top: suggestions && suggestions.length > 0 ? "38%" : "50%",
transform: "translate(-50%, -50%)",
}}
- className="absolute left-1/2 z-[1] flex w-[calc(100%-2rem)] max-w-[600px] flex-col gap-2"
+ className="absolute left-1/2 z-1 flex w-[calc(100%-2rem)] max-w-[600px] flex-col gap-2"
>
<Flex
gap="2"
align="center"
- className="absolute bottom-full left-0 mb-2 min-w-0"
+ className="absolute bottom-full left-0 mb-1 min-w-0 gap-1"
>
+ {spaceSelector?.({ disabled: isCreatingTask })}
<WorkspaceModeSelect
value={workspaceMode}
onChange={setWorkspaceMode}
@@ -1381,7 +1389,7 @@ export function TaskInput({
placeholder={
autoresearchDraft
? "Example: Reduce memory usage measured by `pnpm bench:memory` without changing behavior."
- : `What do you want to ship? ${hints}`
+ : `What do you want to ship?`
}
editorHeight="large"
disabled={isCreatingTask}
@@ -1396,7 +1404,7 @@ export function TaskInput({
(runtime === "pi" && !currentPiModel)
}
tourTarget="task-input"
- attachmentsPrefix={
+ submitAdornment={
includeChannelContext ? (
<ChannelContextChip
channelName={channelName}
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/WorkspaceModeSelect.tsx b/products/desktop/packages/ui/src/features/task-detail/components/WorkspaceModeSelect.tsx
index d83657245174..1b5a9b263939 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/WorkspaceModeSelect.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/WorkspaceModeSelect.tsx
@@ -1,11 +1,4 @@
-import {
- ArrowsSplit,
- CaretDown,
- Cloud,
- Cube,
- Laptop,
- Plus,
-} from "@phosphor-icons/react";
+import { ArrowsSplit, Cloud, Cube, Laptop, Plus } from "@phosphor-icons/react";
import {
Button,
DropdownMenu,
@@ -139,18 +132,13 @@ export function WorkspaceModeSelect({
render={
<Button
type="button"
- variant="outline"
+ variant="default"
size="sm"
disabled={disabled}
aria-label="Workspace mode"
>
<span className="text-muted-foreground">{triggerIcon}</span>
{triggerLabel}
- <CaretDown
- size={10}
- weight="bold"
- className="text-muted-foreground"
- />
</Button>
}
/>