From 84a07e7683ea51d2a8b68ced9ff1442c794a97ec Mon Sep 17 00:00:00 2001 From: KoNit-K <124019182+KoNit-K@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:50:29 +0800 Subject: [PATCH] fix(desktop): match HUD transcript rows with aui_message-group slot TurnRow roots now carry data-slot="aui_message-group", so the band's *:not([data-slot]) selector measured an empty short session as 0px. Include message-group rows while keeping the slot-less "show earlier" path. Fixes #107050 Co-authored-by: Cursor --- .../src/app/hud/transcript-band.test.tsx | 77 +++++++++++++++++-- apps/desktop/src/app/hud/transcript-band.ts | 4 +- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/app/hud/transcript-band.test.tsx b/apps/desktop/src/app/hud/transcript-band.test.tsx index adbca1f01c..e74ba1c474 100644 --- a/apps/desktop/src/app/hud/transcript-band.test.tsx +++ b/apps/desktop/src/app/hud/transcript-band.test.tsx @@ -1,12 +1,20 @@ import { act, render } from '@testing-library/react' -import { useRef } from 'react' +import { type ReactNode, useRef } from 'react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { stubResizeObserver } from '@/test/jsdom' import { useHudTranscriptBand } from './transcript-band' -function Harness({ withViewport }: { withViewport: boolean }) { +function Harness({ + children, + withThreadContent = true, + withViewport +}: { + children?: ReactNode + withThreadContent?: boolean + withViewport: boolean +}) { const ref = useRef(null) useHudTranscriptBand(ref) @@ -16,15 +24,29 @@ function Harness({ withViewport }: { withViewport: boolean }) {
{withViewport && (
-
-
row
-
+ {withThreadContent &&
{children ??
row
}
}
)}
) } +function bandHeight(container: HTMLElement): number { + const root = container.firstElementChild as HTMLElement + + return Number.parseFloat(root.style.getPropertyValue('--hud-band-height') || '0') +} + +function stubMeasuredRects() { + vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) { + if (this.dataset.slot === 'composer-dock') { + return { bottom: 768, height: 58, top: 710 } as DOMRect + } + + return { bottom: 172, height: 72, top: 100 } as DOMRect + }) +} + beforeEach(() => { stubResizeObserver() vi.useFakeTimers() @@ -32,6 +54,7 @@ beforeEach(() => { afterEach(() => { vi.useRealTimers() + vi.restoreAllMocks() }) describe('useHudTranscriptBand', () => { @@ -61,4 +84,48 @@ describe('useHudTranscriptBand', () => { expect(muchLater).toBe(justAfterFound) }) + + // TurnRow roots now carry data-slot="aui_message-group". The band must still + // treat them as transcript rows; matching only *:not([data-slot]) leaves a + // short session at --hud-band-height: 0px and clips the transcript. + it('measures a TurnRow with data-slot="aui_message-group" as transcript height', () => { + stubMeasuredRects() + const { container } = render( + +
turn
+
+ ) + + expect(bandHeight(container)).toBeGreaterThan(0) + }) + + it('still measures slot-less direct children such as show-earlier', () => { + stubMeasuredRects() + const { container } = render( + + + + ) + + expect(bandHeight(container)).toBeGreaterThan(0) + }) + + it('does not treat clearance or background-resume spacers as message rows', () => { + stubMeasuredRects() + const { container } = render( + +
resume
+
+ + ) + + expect(bandHeight(container)).toBe(0) + }) + + it('keeps an empty band when aui_thread-content is missing', () => { + stubMeasuredRects() + const { container } = render() + + expect(bandHeight(container)).toBe(0) + }) }) diff --git a/apps/desktop/src/app/hud/transcript-band.ts b/apps/desktop/src/app/hud/transcript-band.ts index ddde46a2c6..83d9208126 100644 --- a/apps/desktop/src/app/hud/transcript-band.ts +++ b/apps/desktop/src/app/hud/transcript-band.ts @@ -49,7 +49,9 @@ export function useHudTranscriptBand(rootRef: RefObject): // rows only. Measuring to the viewport edge counted the full-window scroll // container (min-height: 100%) as transcript and painted a empty slab almost // the size of the HUD. - const rows = el?.querySelectorAll('[data-slot="aui_thread-content"] > *:not([data-slot])') + const rows = el?.querySelectorAll( + '[data-slot="aui_thread-content"] > [data-slot="aui_message-group"], [data-slot="aui_thread-content"] > *:not([data-slot])' + ) // Zero-height rows are not a transcript. A fresh thread still renders // scaffolding inside the content box (clearance, empty state), so