Skip to content

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

fix(chat): keep the action bar inside the inter-message gap\n\nCodex review on the previous commit: compensating the footer's full `min-h-7.5`\npulls the bar 30px into a gap that `gap-y-6` only makes 24px tall, so the bar's\nbottom 6px paint over the next message's first line — at the same left inset\n(`ms-2` on the bar, `px-2` on the content). The bar is `pt-1.5` plus a `size-6`\nbutton, so it is exactly 30px and the overflow is real, not marginal.\n\nHand back the gap rather than the whole reservation: `-mb-6 min-h-7.5`. The bar\nnow fills the 24px gap exactly and consecutive assistant turns sit 30px apart —\nstill well down from the 54px the uncompensated reservation produced, with no\noverlap.\n\nRetargets the regression test at the property that actually matters: the amount\npulled back equals the message group's `gap-y-*`, read off both elements rather\nthan hard-coded. That fails in both directions — pulling back nothing (the\noriginal dead-band bug) and pulling back more than the gap (this overlap) — and\nboth were verified to fail before restoring the fix.\n

[email protected]c25c67dc24e7
diff --git a/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx b/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx
index 6d5d6abfa3..fa03d45574 100644
--- a/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx
+++ b/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx
@@ -9,22 +9,26 @@ import { describe, expect, it } from 'vitest';
import { Thread } from './thread';
/**
- * The assistant action bar reserves its own height (`min-h-*`) so that a bar
- * revealed on hover does not shift the transcript, and immediately cancels that
- * reservation with a matching negative bottom margin (`-mb-*`) so it costs
- * nothing in flow — inter-message spacing stays whatever the message group's
- * `gap-y-*` says.
+ * The assistant action bar reserves its own height (`min-h-*`) so a bar revealed
+ * on hover does not shift the transcript, then hands most of that reservation
+ * back with a negative bottom margin (`-mb-*`) so it is drawn *inside* the gap
+ * the message group already provides rather than stacking on top of it.
*
- * The pair is only self-cancelling while both halves sit on the same element.
- * They were separated once: the `-mb` drifted onto the message root, where it
- * merely cancelled that element's own paint-box `pb`, leaving the footer's
- * reservation uncompensated and adding a dead 30px band under every assistant
- * turn — a doubled gap between consecutive replies.
+ * The amount handed back has to be exactly the message group's `gap-y-*`, and
+ * both failure directions have shipped or been caught in review:
*
- * jsdom does no layout, so the class pair is the only observable for this, and
- * it is asserted as an invariant (reserved === compensated) rather than as a
- * literal value: retuning the bar's height stays free, decoupling the halves
- * does not.
+ * - Give back nothing (the `-mb` had drifted onto the message root, where it
+ * only cancelled that element's own paint-box `pb`) and the full reservation
+ * becomes dead space: a 30px band under every assistant turn, on top of the
+ * gap — consecutive replies ~54px apart instead of 30px.
+ * - Give back the whole reservation and the bar is pulled deeper than the gap
+ * is tall, so its tail paints over the following message's first line, at the
+ * same left inset (`ms-2` on the bar, `px-2` on the content).
+ *
+ * jsdom performs no layout, so the utilities are the only observable here. They
+ * are read as an invariant relating two elements — pulled === available gap —
+ * rather than asserted as literals, so retuning either stays free while
+ * breaking their correspondence does not.
*/
const messages: ThreadMessageLike[] = [
@@ -47,35 +51,48 @@ function Harness() {
);
}
-/** The `n` in `min-h-<n>` / `-mb-<n>`, or `null` when the utility is absent. */
-function spacingStep(classNames: string, prefix: string): string | null {
- const match = classNames
- .split(/\s+/)
- .find(cls => cls.startsWith(`${prefix}-`))
- ?.slice(prefix.length + 1);
- return match ?? null;
+/**
+ * The numeric step of a Tailwind spacing utility — the `6` in `gap-y-6`, the
+ * `7.5` in `min-h-7.5` — or `null` when the element does not carry one.
+ */
+function spacingStep(el: HTMLElement, prefix: string): number | null {
+ const token = el.className.split(/\s+/).find(cls => cls.startsWith(`${prefix}-`));
+ if (!token) return null;
+ const step = Number(token.slice(prefix.length + 1));
+ return Number.isFinite(step) ? step : null;
}
describe('assistant message action bar spacing', () => {
- it('cancels its reserved height on the same element that reserves it', () => {
- render(<Harness />);
+ it('draws the action bar inside the inter-message gap, filling it exactly', () => {
+ const { container } = render(<Harness />);
+
+ const group = container.querySelector<HTMLElement>('[data-slot="aui_message-group"]');
+ expect(group).not.toBeNull();
+ const gap = spacingStep(group as HTMLElement, 'gap-y');
+ expect(gap).not.toBeNull();
const footers = screen.getAllByTestId('agent-message').map(root => {
- const footer = root.querySelector('[data-slot="aui_assistant-message-footer"]');
+ const footer = root.querySelector<HTMLElement>('[data-slot="aui_assistant-message-footer"]');
expect(footer).not.toBeNull();
return footer as HTMLElement;
});
-
expect(footers.length).toBeGreaterThan(0);
for (const footer of footers) {
- const reserved = spacingStep(footer.className, 'min-h');
- const compensated = spacingStep(footer.className, '-mb');
+ const reserved = spacingStep(footer, 'min-h');
+ const pulled = spacingStep(footer, '-mb');
- // Reserving height without compensating it on the same element is the
- // regression this test exists for.
+ // Reserving the bar's height is what keeps a hover-revealed bar from
+ // shifting the transcript, so the reservation itself must be present.
expect(reserved).not.toBeNull();
- expect(compensated).toBe(reserved);
+
+ // Pulling back less than the gap leaves dead space under every turn;
+ // pulling back more paints the bar over the next message's first line.
+ expect(pulled).toBe(gap);
+
+ // The bar is drawn into the gap, so it must not be taller than the space
+ // the pull actually buys it.
+ expect(reserved as number).toBeLessThanOrEqual((pulled as number) + (gap as number));
}
});
});
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index fbf0211663..f1109229f1 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -630,19 +630,25 @@ const AssistantMessage: FC = () => {
} = useContext(ThreadComponentsContext);
const ACTION_BAR_PT = 'pt-1.5';
- // `min-h` reserves the bar's height so an autohidden bar appearing on hover
- // does not shift the transcript; the matching `-mb` immediately compensates
- // it so the reservation costs nothing in flow and message spacing stays the
- // `gap-y-6` the message group sets. The two MUST stay on the same element —
- // separating them (the `-mb` had drifted onto the root, where it merely
- // cancelled that element's own `pb`) leaves the reservation uncompensated and
- // adds a dead 30px band under every assistant turn.
- // For `pt-[n]` use `-mb-[n + 6]` and `min-h-[n + 6]` to preserve compensation.
- const ACTION_BAR_HEIGHT = `-mb-7.5 min-h-7.5 ${ACTION_BAR_PT}`;
+ // `min-h` reserves the bar's height (`pt-1.5` + a `size-6` button = 7.5) so a
+ // bar revealed on hover does not shift the transcript, and `-mb` gives that
+ // reservation back to the flow so it does not stack on top of the spacing the
+ // message group already provides. Both MUST sit on this one element: the `-mb`
+ // had drifted onto the root, where it only cancelled that element's own `pb`,
+ // leaving the reservation uncompensated — a dead 30px band under every turn.
+ //
+ // The `-mb` step is `gap-y-6` from the message group, NOT the full `min-h`.
+ // The bar is pulled into the inter-message gap and must stay inside it: give
+ // back more than the gap and the bar's tail paints over the next message's
+ // first line, which sits at the same left inset (`ms-2` here, `px-2` there).
+ // So the bar occupies the gap exactly and the turns end up 7.5 apart.
+ // Keep this in step with `aui_message-group`'s `gap-y-*`; the pairing is
+ // asserted in `thread.actionBarSpacing.test.tsx`.
+ const ACTION_BAR_HEIGHT = `-mb-6 min-h-7.5 ${ACTION_BAR_PT}`;
// The root's own `-mb-7.5 pb-7.5` pair below is PAINT-ONLY and unrelated to
- // that compensation: `content-visibility:auto` implies `contain: paint`, so
- // `pb` widens the paint box to cover the bar the footer's `-mb` pulls past
- // the content box, and the root's `-mb` cancels that padding in flow.
+ // the above: `content-visibility:auto` implies `contain: paint`, so `pb`
+ // widens the paint box to cover the bar that `-mb` pulls past the content
+ // box, and the root's `-mb` cancels that padding again in flow.
return (
<MessagePrimitive.Root