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): 恢复模型选择器按内容展开并保留加载占位 (#4555)

Dashb9a115c9b4ba
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index f77a28af29..7d4a3c6fc0 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -8728,12 +8728,16 @@ export function ChatInput({
{!hideRuntimeControls ? (
<div
data-session-model-slot={sessionId ? '' : undefined}
- // A cold session has no trustworthy label yet. Keep the same geometry before
- // and after hydration without mounting an interactive default-model control.
+ // Reserve space while the model is unknown, keeping the toolbar height and
+ // right-aligned actions stable. Once ready, wide toolbars hug the model label;
+ // only narrow toolbars retain the fixed-width, truncating slot.
className={sessionId
- ? cn('h-[30px] shrink', useUltraCompactToolbar
- ? 'w-[64px] min-w-[64px]'
- : 'w-[148px] min-w-[72px]')
+ ? cn('h-[30px] shrink',
+ useUltraCompactToolbar
+ ? 'w-[64px] min-w-[64px]'
+ : useNarrowToolbar || sessionModelLoading
+ ? 'w-[148px] min-w-[72px]'
+ : 'min-w-0')
: useNarrowToolbar ? 'min-w-0 shrink' : undefined}
>
{!sessionModelLoading && <ModelSelector
diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
index e2e3fc71fd..1a04ff0973 100644
--- a/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
@@ -131,7 +131,14 @@ it.each([320, 480, 800])('preserves the model slot across hydration (width=%s)',
expect(screen.queryByTestId('model-selector')).toBeNull();
view.rerender(<ChatInput {...inputProps} initialModel="gpt-6-astra" />);
expect(view.container.querySelector('[data-session-model-slot]')).toBe(slot);
- expect(slot.className).toBe(geometry);
+ if (narrowToolbar) {
+ expect(slot.className).toBe(geometry);
+ } else {
+ // Loaded wide toolbars must not inherit the loading placeholder's width.
+ expect(slot.classList.contains('w-[148px]')).toBe(false);
+ expect(slot.classList.contains('h-[30px]')).toBe(true);
+ expect(slot.classList.contains('min-w-0')).toBe(true);
+ }
expect(slot.contains(screen.getByTestId('model-selector'))).toBe(true);
view.rerender(<ChatInput {...inputProps} />);
expect(view.container.querySelector('[data-session-model-slot]')).toBe(slot);