程序员阿江(Relakkes) 165cb1777a fix: keep provider sessions on compatible model capabilities
Third-party Anthropic-compatible providers can expose Claude model names without supporting every first-party runtime capability. Desktop sessions now preserve provider-specific capability overrides, keep selected provider runtime state across reconnects and restarts, and keep the provider dialog behavior aligned with the updated presets.

Constraint: Custom ANTHROPIC_BASE_URL endpoints must not be treated as first-party Anthropic for adaptive thinking support.
Rejected: Rename provider default Sonnet models | that would hide the compatibility issue instead of fixing runtime capability detection.
Confidence: high
Scope-risk: moderate
Directive: Do not enable Claude first-party capability defaults for custom Anthropic-compatible base URLs without provider verification.
Tested: bun test src/utils/__tests__/thinking.test.ts src/server/__tests__/conversation-service.test.ts src/server/__tests__/provider-presets.test.ts src/server/__tests__/conversations.test.ts
Tested: cd desktop && bun run lint
Tested: cd desktop && bun run test src/components/shared/Modal.test.tsx --run
Tested: git diff --check
2026-04-28 17:35:56 +08:00

37 lines
1.1 KiB
TypeScript

import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { Modal } from './Modal'
describe('Modal', () => {
it('portals the dialog to body so the scrim covers the full app shell', () => {
const onClose = vi.fn()
const { container } = render(
<div data-testid="stacking-parent" className="relative z-10">
<Modal open onClose={onClose} title="Provider">
<span>Provider form</span>
</Modal>
</div>,
)
const dialog = screen.getByRole('dialog', { name: 'Provider' })
expect(container.contains(dialog)).toBe(false)
expect(document.body.contains(dialog)).toBe(true)
})
it('closes when the backdrop is clicked', () => {
const onClose = vi.fn()
render(
<Modal open onClose={onClose}>
<span>Provider form</span>
</Modal>,
)
const backdrop = screen.getByRole('dialog').previousElementSibling
expect(backdrop).not.toBeNull()
fireEvent.click(backdrop!)
expect(onClose).toHaveBeenCalledTimes(1)
})
})