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): contain IM model menu scrolling (#535)

fico-hub7539657f334e
diff --git a/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts b/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts
index 8b6cf74dfc..2586e28f2b 100644
--- a/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts
+++ b/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts
@@ -465,6 +465,70 @@ describe('ModelSelector trigger variants', () => {
expect(trigger.querySelector('[data-model-promotion-badge]')).toBeNull();
});
+ it('keeps a long subscription-backed field menu bounded and wheel-scrollable', () => {
+ const models: VisibleModelFixture[] = Array.from({ length: 40 }, (_, index) => ({
+ id: `subscription-model-${index + 1}`,
+ displayName: `Subscription Model ${index + 1}`,
+ contextWindow: 200000,
+ efforts: ['high'],
+ defaultEffort: 'high',
+ }));
+ const originalCapabilities = agentCapabilitiesRef.capabilities;
+ visibleModelsRef.models = models;
+ agentCapabilitiesRef.capabilities = {
+ availableModels: models,
+ effortLevels: [{ id: 'high', displayName: 'High' }],
+ hasFastMode: false,
+ };
+ providersRef.providers = [
+ {
+ id: 'anthropic',
+ name: 'Anthropic',
+ source: 'builtin',
+ agents: ['claude-code'],
+ auth: { method: 'oauth' },
+ routing: { 'claude-code': {} },
+ connected: true,
+ models: {
+ 'claude-code': models.map((model) => ({
+ ...model,
+ name: model.displayName,
+ })),
+ },
+ },
+ ];
+
+ try {
+ render(
+ React.createElement(ModelSelector, {
+ modelId: models[0].id,
+ effort: 'high',
+ onModelChange: vi.fn(),
+ onEffortChange: vi.fn(),
+ vendorKey: 'cc',
+ triggerVariant: 'field',
+ currentProviderId: 'anthropic',
+ onProviderChange: vi.fn(),
+ }),
+ );
+
+ fireEvent.click(screen.getByRole('button', { name: /Current: Subscription Model 1/ }));
+ const list = screen.getByRole('listbox', { name: 'Model list' });
+
+ expect(list.className).toContain('max-h-[300px]');
+ expect(list.className).toContain('overflow-y-auto');
+ expect(list.className).toContain('overscroll-contain');
+ const options = within(list).getAllByRole('option');
+ expect(options).toHaveLength(40);
+ expect(options[0].textContent).toContain('Subscription Model 1');
+ expect(options[39].textContent).toContain('Subscription Model 40');
+ } finally {
+ visibleModelsRef.models = null;
+ agentCapabilitiesRef.capabilities = originalCapabilities;
+ providersRef.providers = providersRef.DEFAULT_PROVIDERS;
+ }
+ });
+
it('reuses the parent pricing snapshot when the model content opens', () => {
pricingRef.renderCalls = 0;
render(
diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
index 514b6d0a0d..0162f5b5d0 100644
--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
@@ -1443,7 +1443,7 @@ function ModelSelectorContentView({
ref={listRef}
// -mr-2 把滚动条挪进面板右侧 8px 留白;scrollbar-gutter:stable 让无滚动时
// 行宽与有滚动时一致(否则行会比搜索框宽 8px);细滚动条见 globals.css
- className="morph-panel-list-scroll -mr-2 flex max-h-[300px] flex-col gap-0.5 overflow-y-auto [scrollbar-gutter:stable]"
+ className="morph-panel-list-scroll -mr-2 flex max-h-[300px] flex-col gap-0.5 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]"
role="listbox"
aria-label="Model list"
onScroll={() => {