The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): remove doubled gap under assistant messages
[email protected]884d66db3093
diff --git a/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx b/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsxnew file mode 100644index 0000000000..6d5d6abfa3--- /dev/null+++ b/app/src/components/assistant-ui/thread.actionBarSpacing.test.tsx@@ -0,0 +1,81 @@+import {+ AssistantRuntimeProvider,+ type ThreadMessageLike,+ useExternalStoreRuntime,+} from '@assistant-ui/react';+import { render, screen } from '@testing-library/react';+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 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.+ *+ * 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.+ */++const messages: ThreadMessageLike[] = [+ { role: 'user', content: [{ type: 'text', text: 'hello' }] },+ { role: 'assistant', content: [{ type: 'text', text: 'first reply' }] },+ { role: 'assistant', content: [{ type: 'text', text: 'second reply' }] },+];++function Harness() {+ const runtime = useExternalStoreRuntime({+ messages,+ isRunning: false,+ convertMessage: (m: ThreadMessageLike) => m,+ onNew: async () => {},+ });+ return (+ <AssistantRuntimeProvider runtime={runtime}>+ <Thread />+ </AssistantRuntimeProvider>+ );+}++/** 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;+}++describe('assistant message action bar spacing', () => {+ it('cancels its reserved height on the same element that reserves it', () => {+ render(<Harness />);++ const footers = screen.getAllByTestId('agent-message').map(root => {+ const footer = root.querySelector('[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');++ // Reserving height without compensating it on the same element is the+ // regression this test exists for.+ expect(reserved).not.toBeNull();+ expect(compensated).toBe(reserved);+ }+ });+});diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 852085b1fb..fbf0211663 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -630,8 +630,19 @@ const AssistantMessage: FC = () => {} = useContext(ThreadComponentsContext);const ACTION_BAR_PT = 'pt-1.5';- // Keep the action bar inside the contained root's paint box, then cancel its reserved space in flow.- const ACTION_BAR_HEIGHT = `min-h-7.5 ${ACTION_BAR_PT}`;+ // `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}`;+ // 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.return (<MessagePrimitive.Root