Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复跳到底部按钮的动态间距
DavidShen57c86d11402f
diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsxindex dd69c25903..7c48b5ec15 100644--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx@@ -207,6 +207,7 @@ import {} from './messageNavRailModel';import { resolveUserDisplayText } from './userMessageDisplayText';import { detectScrollAnchoringApplied } from './scrollAnchoringDetect';+import { resolveMessageStreamIndicatorBottomOffset } from './messageStreamIndicatorPosition';import {decideAutoFillAction,decideUserIntentFillAction,@@ -267,6 +268,8 @@ interface MessageStreamProps {hasMoreMessages?: boolean;/** Dynamic bottom padding (px) to reserve space for the input overlay */bottomPadding?: number;+ /** Distance from the chat viewport bottom to the visible composer card top. */+ composerTopOffset?: number;/** Content width — shared with the input overlay so chat stream + input* box stay horizontally aligned (same width, same center, symmetric* padding when the main area is compressed). */@@ -2536,6 +2539,7 @@ export function MessageStream({isLoadingMore,hasMoreMessages,bottomPadding,+ composerTopOffset,contentWidth,focusMessageClientId,focusMessageRequestId,@@ -4235,13 +4239,13 @@ export function MessageStream({previousLocalFileRefsRef.current = localFileRefs;}, [localFileRefs]);- // chip 垂直位置 — 用户要求贴在"Generating..." RunningStatusBar 那一行。- // overlay 内部从下到上是:input box + 上方 10px gap + RunningStatusBar(约 28px)+- // 32px 渐变蒙层。把 chip 挪进 overlay 内、center 大致对齐 status bar center,- // 经验值 overlayHeight - 56(原 -60,2026-05-13 用户反馈再往上 4px)。- // Math.max 兜底防极小 overlay 时 chip 跑出容器。+ // chip 垂直位置:优先使用父层实测的输入框卡片顶边,避免 RunningStatusBar+ // 出现 / 收起改变 overlay 总高度后,把按钮带进输入框。旧调用方保留历史兜底。const resolvedBottomPadding = bottomPadding ?? 200;- const indicatorBottomOffset = Math.max(resolvedBottomPadding - 56, 12);+ const indicatorBottomOffset = resolveMessageStreamIndicatorBottomOffset({+ bottomPadding,+ composerTopOffset,+ });// 「提及 → 兑现」关联(方案 2):从会话历史现算,软提示卡据此升级为召唤卡。// 引用缓存:内容不变时复用上一个 Map 引用——UserMessage 顶层订阅该@@ -4587,7 +4591,7 @@ export function MessageStream({{/* F1 / F3: 新消息悬浮提示——挂在 scrollRef 的 relative wrapper 内部,与滚动容器平级。visible 由 `!isNearBottom && unreadCount > 0` 双重- 守护;bottomOffset 直接复用 bottomPadding(overlayHeight)+ 12。 */}+ 守护;bottomOffset 让按钮位于输入框上边缘上方约 6px。 */}<NewMessageIndicatorvisible={!isNearBottom && unreadCount > 0}count={unreadCount}diff --git a/apps/desktop/src/renderer/components/chat/__tests__/messageStreamIndicatorPosition.test.ts b/apps/desktop/src/renderer/components/chat/__tests__/messageStreamIndicatorPosition.test.tsnew file mode 100644index 0000000000..3fec5afc20--- /dev/null+++ b/apps/desktop/src/renderer/components/chat/__tests__/messageStreamIndicatorPosition.test.ts@@ -0,0 +1,25 @@+import { describe, expect, it } from 'vitest';++import { resolveMessageStreamIndicatorBottomOffset } from '../messageStreamIndicatorPosition';++describe('resolveMessageStreamIndicatorBottomOffset', () => {+ it('keeps the indicator anchored to the composer when the status row changes overlay height', () => {+ expect(+ resolveMessageStreamIndicatorBottomOffset({+ bottomPadding: 174,+ composerTopOffset: 142,+ }),+ ).toBe(148);+ expect(+ resolveMessageStreamIndicatorBottomOffset({+ bottomPadding: 206,+ composerTopOffset: 142,+ }),+ ).toBe(148);+ });++ it('preserves the legacy offset when the composer card cannot be measured', () => {+ expect(resolveMessageStreamIndicatorBottomOffset({ bottomPadding: 174 })).toBe(118);+ expect(resolveMessageStreamIndicatorBottomOffset({ bottomPadding: 40 })).toBe(12);+ });+});diff --git a/apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.ts b/apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.tsnew file mode 100644index 0000000000..a75f6e9b34--- /dev/null+++ b/apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.ts@@ -0,0 +1,17 @@+const DEFAULT_BOTTOM_PADDING_PX = 200;+const LEGACY_STATUS_ROW_OFFSET_PX = 56;+const MIN_BOTTOM_OFFSET_PX = 12;+const COMPOSER_GAP_PX = 6;++export function resolveMessageStreamIndicatorBottomOffset({+ bottomPadding,+ composerTopOffset,+}: {+ bottomPadding?: number;+ composerTopOffset?: number;+}): number {+ if (composerTopOffset != null) return composerTopOffset + COMPOSER_GAP_PX;++ const resolvedBottomPadding = bottomPadding ?? DEFAULT_BOTTOM_PADDING_PX;+ return Math.max(resolvedBottomPadding - LEGACY_STATUS_ROW_OFFSET_PX, MIN_BOTTOM_OFFSET_PX);+}diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex 794636c46b..969cceda9a 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -6503,7 +6503,7 @@ export function ChatInput({Hence this extra `relative` layer around the wrapper. It also servesas the outside-click boundary for collapsing the expanded queue tail(see paletteAnchorRef) — palette clicks are "inside". */}- <div ref={paletteAnchorRef} className="relative w-full">+ <div ref={paletteAnchorRef} className="relative w-full" data-chat-input-card><divref={mergedCardRef}className={cn(diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 4a5f2459d0..969c7a5240 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -1155,17 +1155,23 @@ export function CCAgentSessionView({setOverlayEl(node);}, []);const [overlayHeight, setOverlayHeight] = useState(200);+ const [composerTopOffset, setComposerTopOffset] = useState<number | undefined>(undefined);useEffect(() => {if (!overlayEl) return;+ const measureOverlay = () => {+ // 状态行会动态出现 / 收起,overlay 总高度不等于输入框卡片顶边。+ // 直接量卡片到 overlay 底边的距离,让消息流悬浮按钮不受状态行高度影响。+ setOverlayHeight(overlayEl.offsetHeight);+ const composerCard = overlayEl.querySelector<HTMLElement>('[data-chat-input-card]');+ setComposerTopOffset(+ composerCard ? overlayEl.getBoundingClientRect().bottom - composerCard.getBoundingClientRect().top : undefined,+ );+ };// Seed with the current height so the first paint after remount uses the// real value (not the stale state from the previous mount).- setOverlayHeight(overlayEl.offsetHeight);- const ro = new ResizeObserver(() => {- // offsetHeight (includes padding) instead of contentRect.height so the- // bottom padding fully covers the overlay.- setOverlayHeight(overlayEl.offsetHeight);- });+ measureOverlay();+ const ro = new ResizeObserver(measureOverlay);ro.observe(overlayEl);return () => ro.disconnect();}, [overlayEl]);@@ -3695,6 +3701,7 @@ export function CCAgentSessionView({isLoadingMore={isLoadingMore}hasMoreMessages={hasMoreMessages}bottomPadding={overlayHeight}+ composerTopOffset={composerTopOffset}contentWidth={messageWidth}focusMessageClientId={focusedMessageTarget?.clientId ?? null}focusMessageRequestId={focusedMessageTarget?.requestId ?? 0}