Skip to content

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

fix(chat): hoist the Edit gate so coverage can see it\n\n`PR CI Gate` failed at 75% diff coverage, naming `thread.tsx:872` — the\n`{canEdit && (` gate — as the one uncovered changed line, while vitest's own\nreport showed the surrounding function exercised. Both agreed on the facts and\ndisagreed on the verdict: CI's v8 summary listed uncovered lines ending\n`...30,745,884,920`, and 872 was not among them.\n\nThe cause is instrumentation, not coverage. A bare JSX logical expression emits\nno `DA:` record on its own line, so `diff-cover` — which reads lcov, not the v8\nsummary — sees a changed line with no record and counts it missing. No test can\nfix that; the line has to become a statement.\n\n`const editAction = canEdit ? (…) : null`, rendered as `{editAction}`. Behaviour\nis identical. Verified in the lcov: the hoisted line now carries `DA:867,144`,\ni.e. 144 executions, where the JSX conditional carried no record at all.\n\nRevert-proofed after the change: forcing the ternary true fails\n`UserActionBar.test.tsx` at `toHaveLength(0)` with "expected <button …> to have\na length of +0 but got 1", and the sibling control keeps passing.\n

M3gA-Minddaad449d318c
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index 9331bedd22..1789f1c099 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -859,6 +859,19 @@ const UserActionBar: FC = () => {
// appears by itself the day the adapter grows `onEdit`.
const { canEdit } = useAuiEditCapabilities();
+ // Hoisted out of the JSX rather than written as `{canEdit && (…)}` inline: a
+ // bare JSX logical expression emits no coverage record on its own line, so
+ // `diff-cover` reported the gate as an uncovered changed line even while the
+ // v8 report showed the surrounding function fully exercised. As a `const` it
+ // is an ordinary statement, instrumented like any other.
+ const editAction = canEdit ? (
+ <ActionBarPrimitive.Edit asChild>
+ <TooltipIconButton tooltip="Edit" className="aui-user-action-edit">
+ <PencilIcon />
+ </TooltipIconButton>
+ </ActionBarPrimitive.Edit>
+ ) : null;
+
return (
<ActionBarPrimitive.Root
hideWhenRunning
@@ -869,13 +882,7 @@ const UserActionBar: FC = () => {
<CopyIcon />
</TooltipIconButton>
</ActionBarPrimitive.Copy>
- {canEdit && (
- <ActionBarPrimitive.Edit asChild>
- <TooltipIconButton tooltip="Edit" className="aui-user-action-edit">
- <PencilIcon />
- </TooltipIconButton>
- </ActionBarPrimitive.Edit>
- )}
+ {editAction}
</ActionBarPrimitive.Root>
);
};