Skip to content

The agent that grows with you

fix(desktop): pause thinking preview pin while the reader is scrolled up (#109510)

Konstantin Khlopkov741fa6acc154
diff --git a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
index 4c94a1e2b33..8ec340639c2 100644
--- a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
@@ -135,6 +135,9 @@ const ChainToolFallback: FC<TimelineToolCallProps> = props => {
return <ToolFallback {...props} />
}
+// Match the compact terminal/log viewers rather than the full thread's slack.
+const PREVIEW_RELOCK_THRESHOLD_PX = 24
+
type TimelineTextPartProps = TextMessagePartProps & { completedAt?: number; timestamp?: number }
const TimelineMarkdownText: FC<TimelineTextPartProps> = ({ completedAt, timestamp }) => (
@@ -218,7 +221,7 @@ const ThinkingDisclosure: FC<{
let following = true
const trackScroll = () => {
- following = el.scrollHeight - el.scrollTop - el.clientHeight < 24
+ following = el.scrollHeight - el.scrollTop - el.clientHeight < PREVIEW_RELOCK_THRESHOLD_PX
}
const pin = (entries: readonly ResizeObserverEntry[]) => {
diff --git a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
index 844a334fffe..cf6a746e3cb 100644
--- a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
@@ -44,9 +44,10 @@ class TestResizeObserver {
this.callback(
[
{
+ borderBoxSize: [{ blockSize: height, inlineSize: 800 }],
contentRect: { height } as DOMRectReadOnly,
target: this.target
- } as ResizeObserverEntry
+ } as unknown as ResizeObserverEntry
],
this as unknown as ResizeObserver
)
@@ -687,7 +688,7 @@ describe('assistant-ui streaming renderer', () => {
deliverGrowth()
expect(body.scrollTop).toBe(100)
- body.scrollTop = height - body.clientHeight
+ body.scrollTop = height - body.clientHeight - 0.5
fireEvent.scroll(body)
rerender(
<RunningMessageHarness message={assistantReasoningMessage('First thought. More reasoning. Latest thought.', true)} />