Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): stop offering an Edit button the runtime cannot honour\n\nThe pencil "Edit" affordance on every user message was rendered, hovering,\nclickable — and inert. Clicking it did nothing at all: no edit composer, no\nchange to the message.\n\nThe feature is unbuilt rather than broken. `useOpenHumanExternalStore` supplies\n`onNew` / `onCancel` and implements neither `onEdit` nor `setMessages`, which is\nwhat assistant-ui requires for message editing, so the runtime reports\n`edit: false` and `EditComposer` never renders. `ActionBarPrimitive.Edit` was\nrendered unconditionally regardless.\n\nThe gate already existed and was simply never called. `useAuiEditCapabilities`\n(auiThreadState.ts) was written as "the honest gate for those affordances" and\nhad ZERO production consumers; the same file states the intended contract in\nits own words — "deliberately absent rather than rendered-and-inert: an edit\nbutton that looks supported and silently does nothing is worse than no button".\nThat rule was documented and unenforced. This wires it.\n\nGated on the capability rather than hard-coded off, so the button reappears by\nitself the day the adapter grows `onEdit`.\n\nSame class, fixed at the sibling site: `BranchPicker` is also rendered\nunconditionally, at both of its call sites, and is invisible today only because\n`hideWhenSingleBranch` happens to hold — the adapter implements no\n`setMessages`, so there is never more than one branch. That is assistant-ui's\nguard doing the work this app intended to do itself, and it becomes a second\ndead control if the prop ever goes away. It now returns null unless\n`canSwitchToBranch`.\n\nVerified by reading: thread.tsx:844 (the unconditional render),\nauiThreadState.ts:64-74 (the hook) and :78-97 (the stated contract), plus a\nrepo-wide grep confirming the hook had no production consumer. NOT executed —\nlocal builds and test runs are disabled for this phase, so CI is the check.\n

M3gA-Mindfd665e722edf
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index f1109229f1..9331bedd22 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -28,6 +28,7 @@ import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button
import { Button } from '@/components/assistant-ui/ui/button';
import { Skeleton } from '@/components/assistant-ui/ui/skeleton';
import ModelQualityPill from '@/components/chat/ModelQualityPill';
+import { useAuiEditCapabilities } from '@/features/conversations/components/aui/auiThreadState';
import {
ActionBarMorePrimitive,
ActionBarPrimitive,
@@ -848,6 +849,16 @@ const UserMessage: FC = () => {
};
const UserActionBar: FC = () => {
+ // Edit is offered only when the bound runtime can honour it. The
+ // external-store adapter supplies `onNew` / `onCancel` and neither `onEdit`
+ // nor `setMessages`, so assistant-ui reports `edit: false` and
+ // `EditComposer` below never renders — the button was clickable and did
+ // nothing (#5897).
+ //
+ // Gated on the capability rather than hard-coded off, so the affordance
+ // appears by itself the day the adapter grows `onEdit`.
+ const { canEdit } = useAuiEditCapabilities();
+
return (
<ActionBarPrimitive.Root
hideWhenRunning
@@ -858,11 +869,13 @@ const UserActionBar: FC = () => {
<CopyIcon />
</TooltipIconButton>
</ActionBarPrimitive.Copy>
- <ActionBarPrimitive.Edit asChild>
- <TooltipIconButton tooltip="Edit" className="aui-user-action-edit">
- <PencilIcon />
- </TooltipIconButton>
- </ActionBarPrimitive.Edit>
+ {canEdit && (
+ <ActionBarPrimitive.Edit asChild>
+ <TooltipIconButton tooltip="Edit" className="aui-user-action-edit">
+ <PencilIcon />
+ </TooltipIconButton>
+ </ActionBarPrimitive.Edit>
+ )}
</ActionBarPrimitive.Root>
);
};
@@ -895,6 +908,15 @@ const EditComposer: FC = () => {
};
const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({ className, ...rest }) => {
+ // The same defect class as the Edit button above, one step from biting: this
+ // is rendered unconditionally at both call sites and is invisible today only
+ // because `hideWhenSingleBranch` happens to hold — the adapter implements no
+ // `setMessages`, so there is never more than one branch. That is
+ // assistant-ui's guard doing the work this app intended to do itself, and it
+ // would become a second dead control if the prop ever went away.
+ const { canSwitchToBranch } = useAuiEditCapabilities();
+ if (!canSwitchToBranch) return null;
+
return (
<BranchPickerPrimitive.Root
hideWhenSingleBranch
diff --git a/app/src/features/conversations/components/aui/auiThreadState.ts b/app/src/features/conversations/components/aui/auiThreadState.ts
index a73587d31d..896de8ff2f 100644
--- a/app/src/features/conversations/components/aui/auiThreadState.ts
+++ b/app/src/features/conversations/components/aui/auiThreadState.ts
@@ -58,8 +58,13 @@ export function useAuiThreadRunning(): boolean | undefined {
* that faithfully, so this hook is the honest gate for those affordances rather
* than a hard-coded `false` that would rot the day the adapter grows them.
*
- * Nothing renders behind it today — see `EDIT_AND_BRANCH_SEAM` below for where
- * an edit composer / `BranchPickerPrimitive` would attach.
+ * Both affordances in `components/assistant-ui/thread.tsx` are gated on this
+ * (#5897): `UserActionBar` renders `ActionBarPrimitive.Edit` only when
+ * `canEdit`, and `BranchPicker` returns `null` unless `canSwitchToBranch`.
+ * Neither is reachable today, which is the point — an edit button that looks
+ * supported and silently does nothing is worse than no button. See
+ * `EDIT_AND_BRANCH_SEAM` below for where the edit composer itself attaches when
+ * the adapter grows `onEdit` / `setMessages`.
*/
export function useAuiEditCapabilities(): { canEdit: boolean; canSwitchToBranch: boolean } {
const canEdit = useAuiState(selectCanEdit) ?? false;
@@ -90,6 +95,11 @@ export function useAuiEditCapabilities(): { canEdit: boolean; canSwitchToBranch:
*
* They are deliberately absent rather than rendered-and-inert: an edit button
* that looks supported and silently does nothing is worse than no button.
+ *
+ * That rule was stated here but not enforced anywhere until #5897 — this hook
+ * had zero production consumers while `ActionBarPrimitive.Edit` shipped
+ * unconditionally, so the button was rendered, clickable and inert. The gate is
+ * wired now; keep it wired when the affordances move into `TranscriptRow`.
*/
export const EDIT_AND_BRANCH_SEAM = Object.freeze({
editComposer: 'TranscriptRow — gated on useAuiEditCapabilities().canEdit',