Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 去掉加号菜单打开时底部闪现的横线

Dash6e073e574454
diff --git a/apps/desktop/src/renderer/__tests__/composerMorphScope.test.ts b/apps/desktop/src/renderer/__tests__/composerMorphScope.test.ts
index 2d06a50775..a39d52b5f3 100644
--- a/apps/desktop/src/renderer/__tests__/composerMorphScope.test.ts
+++ b/apps/desktop/src/renderer/__tests__/composerMorphScope.test.ts
@@ -69,3 +69,16 @@ describe('设置字段里的 AgentSelect 宽度契约', () => {
expect(morph).toContain('desiredW = chipRect.width;');
});
});
+
+// + 菜单嵌在 480 宽、1px 边框的 Morph 壳里。内层再写死 480 会横向溢出 2px,
+// 打开瞬间 scrollIntoView 点亮 .is-scrolling,底部闪 2 秒横向滚动条。
+describe('+ 菜单 embedded 宽度契约', () => {
+ it('embedded AtMentionPanel 跟 Morph 壳等宽,横轴 overflow 显式 hidden', () => {
+ const atMention = read('components/new-chat/AtMentionPanel.tsx');
+ const morph = read('components/ui/morph-popover.tsx');
+ expect(atMention).toContain("embedded ? 'w-full min-w-0' : 'w-[480px]'");
+ expect(atMention).toContain('overflow-x-hidden overflow-y-auto');
+ expect(morph).toContain('overflow-x-hidden overflow-y-hidden');
+ expect(morph).toContain("content.style.overflowX = 'hidden'");
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx b/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
index 11f54f781c..483e3f76e3 100644
--- a/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
@@ -375,4 +375,15 @@ describe('MorphPopover interaction contract', () => {
const panel = await screen.findByRole('group', { name: 'Morph panel' });
expect(panel.querySelector('[data-morph-ghost]')).toBeNull();
});
+
+ it('内容区 overflow-x 保持 hidden,避免 1px border-box 偏差闪出横向滚动条', async () => {
+ render(<Harness />);
+ fireEvent.click(screen.getByRole('button', { name: 'Toggle' }));
+ const panel = await screen.findByRole('group', { name: 'Morph panel' });
+ const content = panel.firstElementChild as HTMLElement;
+ expect(content.className).toContain('overflow-x-hidden');
+ await waitFor(() => {
+ expect(content.style.overflowX).toBe('hidden');
+ });
+ });
});
diff --git a/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts b/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
index ffb1757349..2cd80ab1ea 100644
--- a/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
+++ b/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
@@ -303,6 +303,39 @@ describe('统一 composer 建议入口', () => {
);
expect(screen.getByText('extraDirs.pluginAgentInvoked')).toBeTruthy();
});
+
+ it('embedded 面板跟 Morph 壳等宽且锁死横向滚动;独立 @ 面板仍是 480',
+ () => {
+ const entries = buildComposerSuggestionEntries({
+ query: '',
+ actions: [{ id: 'new-goal', label: 'goal', run: vi.fn() }],
+ resources: [],
+ plugins: [],
+ });
+ const props = {
+ query: '',
+ state: { kind: 'ready' as const, items: [], truncated: false },
+ entries,
+ focusedIndex: 0,
+ onFocusedIndexChange: vi.fn(),
+ onSelect: vi.fn(),
+ onClose: vi.fn(),
+ onRetry: vi.fn(),
+ };
+ const { container, rerender } = render(
+ createElement(AtMentionPanel, { ...props, embedded: true }),
+ );
+ const embeddedScroller = container.querySelector('.overflow-y-auto');
+ expect(embeddedScroller).toBeTruthy();
+ expect(embeddedScroller?.className).toContain('w-full');
+ expect(embeddedScroller?.className).toContain('overflow-x-hidden');
+ expect(embeddedScroller?.className).not.toContain('w-[480px]');
+
+ rerender(createElement(AtMentionPanel, props));
+ const standaloneScroller = container.querySelector('.overflow-y-auto');
+ expect(standaloneScroller?.className).toContain('w-[480px]');
+ expect(standaloneScroller?.className).toContain('overflow-x-hidden');
+ });
});
describe('PlanModeIndicator 激活 chip', () => {
diff --git a/apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx b/apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx
index 9234e6521c..e311a518f0 100644
--- a/apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx
@@ -18,7 +18,10 @@
* - root-query sections (Add / Plugins / Reference directories)
* - click-outside close (ignoring the `+` trigger button)
*
- * Per F2 spec: 480px width and 44px row height.
+ * Per F2 spec: 480px width and 44px row height. The 480px is owned by the
+ * standalone `@` popover, or by MorphPopover's `panelWidth` when `embedded`.
+ * Embedded content must be `w-full` — a second 480px inside the 1px-bordered
+ * Morph shell overflows by 2px and flashes a 2s horizontal scrollbar.
*/
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -453,7 +456,11 @@ export function AtMentionPanel({
ref={panelRef}
onScroll={(e) => setPanelScroll(e.currentTarget.scrollTop)}
className={cn(
- 'w-[480px] overflow-y-auto',
+ // embedded: fill the Morph shell. A nested w-[480px] is 2px wider
+ // than the border-box panel and paints a horizontal scrollbar thumb
+ // for ~2s via the global .is-scrolling auto-hide.
+ embedded ? 'w-full min-w-0' : 'w-[480px]',
+ 'overflow-x-hidden overflow-y-auto',
'p-[6px]',
!embedded && [
'rounded-[12px] border',
diff --git a/apps/desktop/src/renderer/components/ui/morph-popover.tsx b/apps/desktop/src/renderer/components/ui/morph-popover.tsx
index 1fc382e2cc..5786165a55 100644
--- a/apps/desktop/src/renderer/components/ui/morph-popover.tsx
+++ b/apps/desktop/src/renderer/components/ui/morph-popover.tsx
@@ -122,6 +122,16 @@ function prefersReducedMotion(): boolean {
);
}
+/** overflow-y:auto/hidden 会把 visible 的 overflow-x 算成 auto;横轴必须显式 hidden。 */
+function setContentOverflowY(
+ content: HTMLDivElement | null,
+ overflowY: 'auto' | 'hidden',
+): void {
+ if (!content) return;
+ content.style.overflowY = overflowY;
+ content.style.overflowX = 'hidden';
+}
+
export function MorphPopover({
open,
onOpenChange,
@@ -283,7 +293,7 @@ export function MorphPopover({
// 形变期间内容区禁滚:高度未长够时滚动条短暂出现会把行宽压窄 ~10px,
// 高度到位后又弹回 —— 行尾元素(对勾/选中条)看起来往右抖一下
// (2026-07-22 用户反馈)。动画完成(settle)后再开自滚。
- if (contentRef.current) contentRef.current.style.overflowY = 'hidden';
+ setContentOverflowY(contentRef.current, 'hidden');
panel.dataset.state = 'closed';
// 开场解除 inert(收合分支置上):closed 态面板必须整体退出 tab order,见 else 分支。
panel.inert = false;
@@ -319,7 +329,7 @@ export function MorphPopover({
const focusDelay = reduced ? 0 : MORPH_MS;
closeTimerRef.current = setTimeout(() => {
settledRef.current = true;
- if (contentRef.current) contentRef.current.style.overflowY = 'auto';
+ setContentOverflowY(contentRef.current, 'auto');
// RO 在 opening 期间收到的尺寸变化不会在 settled 后自动重发,这里补量一次
// (异步 capability / provider 列表在开场动画内返回时防面板卡旧尺寸)。
syncPanelToContent();
@@ -350,7 +360,7 @@ export function MorphPopover({
if (rect) chipRectRef.current = rect;
const reducedClose = reduced || !rect;
panel.dataset.state = 'closed';
- if (contentRef.current) contentRef.current.style.overflowY = 'hidden';
+ setContentOverflowY(contentRef.current, 'hidden');
if (rect) applyChipGeometry(panel, rect);
panel.style.opacity = '0';
// 焦点归还判定(§14.2)延迟一拍快照,不在本 layout effect 里同步做:outside
@@ -535,7 +545,10 @@ export function MorphPopover({
<div
ref={contentRef}
className={cn(
- 'max-h-full overflow-y-hidden',
+ // overflow-x must stay hidden: overflow-y:auto/hidden otherwise
+ // computes overflow-x to auto (CSS overflow pairing), and a 1px
+ // border-box mismatch flashes a 2s horizontal scrollbar thumb.
+ 'max-h-full overflow-x-hidden overflow-y-hidden',
side === 'top' ? 'translate-y-[5px]' : 'translate-y-[-5px]',
'opacity-0 transition-[opacity,transform] delay-[50ms] duration-[140ms] ease-out',
'group-data-[state=open]:translate-y-0 group-data-[state=open]:opacity-100',