Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(ui): 保留行内字段校验与崩溃弹窗样式
Dashefaf72b5c839
diff --git a/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx b/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsxindex ad6580a243..5f839e4671 100644--- a/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx+++ b/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx@@ -1,6 +1,6 @@import { ErrorNotice } from '@/components/ui/error-notice';import { Button } from '@/components/ui/button';-import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';+import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';import { useSettingsSearchNavigation } from './SettingsSearchNavigation';import { DefaultOverrideControls } from './DefaultOverrideControls';import { VoiceSpeakerFilterCard } from './VoiceSpeakerFilterCard';@@ -374,6 +374,7 @@ function VoiceInputInlineSettingRow({*/function VoiceInputServiceSourceCard() {const { t } = useTranslation();+ const customAsrUrlErrorId = useId();const { mode: appMode } = useAuth();const [searchParams, setSearchParams] = useSearchParams();const {@@ -707,6 +708,8 @@ function VoiceInputServiceSourceCard() {<inputtype="url"value={customAsrWebsocketUrl}+ aria-invalid={customAsrUrlInvalid || undefined}+ aria-describedby={customAsrUrlInvalid ? customAsrUrlErrorId : undefined}onChange={(event) => {customAsrFormDirtyRef.current = true;setCustomAsrWebsocketUrl(event.target.value);@@ -724,10 +727,13 @@ function VoiceInputServiceSourceCard() {/></VoiceInputInlineSettingRow>{customAsrUrlInvalid ? (- <ErrorNotice+ <p+ id={customAsrUrlErrorId}role="alert"- message={t('settings.voiceInput.serviceSource.customAsr.websocketUrl.invalid')}- />+ className="text-12 text-[var(--error-fg)]"+ >+ {t('settings.voiceInput.serviceSource.customAsr.websocketUrl.invalid')}+ </p>) : null}<VoiceInputInlineSettingRowdiff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsxindex 75d2e7f884..5d20921e71 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx@@ -631,7 +631,7 @@ function BrowserCrashBanner({: 'rightSidebar.browser.crash.crashedDesc';return (<div className="modal-scrim absolute inset-0 flex items-center justify-center">- <ErrorNotice className="max-w-xs" message={t(titleKey)} description={t(descKey)} actions={<>+ <ErrorNotice className="modal-panel max-w-xs" message={t(titleKey)} description={t(descKey)} actions={<><Button size="sm" compact type="button" onClick={onRecover}><RotateCw size={12} strokeWidth={2.5} />{t('rightSidebar.browser.crash.reload')}diff --git a/apps/desktop/src/renderer/voice-input/__tests__/VoiceInputSection.overrideReset.test.tsx b/apps/desktop/src/renderer/voice-input/__tests__/VoiceInputSection.overrideReset.test.tsxindex c0fc19ed0d..2fe0c28eb1 100644--- a/apps/desktop/src/renderer/voice-input/__tests__/VoiceInputSection.overrideReset.test.tsx+++ b/apps/desktop/src/renderer/voice-input/__tests__/VoiceInputSection.overrideReset.test.tsx@@ -18,9 +18,12 @@ vi.mock('@/components/ui/tooltip', () => ({ Tip: ({ children }: { children: Reacvi.mock('@/lib/logger', () => ({ createLogger: () => ({ warn: vi.fn(), debug: vi.fn() }) }));vi.mock('@/lib/toast', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));vi.mock('../../components/settings/VoiceSpeakerFilterCard', () => ({ VoiceSpeakerFilterCard: () => null }));-// Service credentials are a separate card; keep the reset controls and settings hook real.+const serviceModel = vi.hoisted(() => ({ current: {+ ready: false, selection: null, asrProfiles: [],+} as Record<string, unknown> }));+// Keep the page and settings hook real; supply only the service-selection snapshot.vi.mock('@/hooks/useVoiceInputModelSelection', () => ({- useVoiceInputModelSelection: () => ({ ready: false, selection: null, asrProfiles: [] }),+ useVoiceInputModelSelection: () => serviceModel.current,}));const defaults = getDefaultVoiceInputSettings('win32');@@ -30,6 +33,7 @@ const updateSettings = vi.fn();beforeEach(() => {vi.clearAllMocks();+ serviceModel.current = { ready: false, selection: null, asrProfiles: [] };settings = {...defaults,composerLongPressEnabled: !defaults.composerLongPressEnabled,@@ -53,6 +57,38 @@ beforeEach(() => {});afterEach(cleanup);+/**+ * Review #6347/r4303186814 and DESIGN ErrorNotice exclusions: field validation must remain+ * associated with the input on desktop as well as mobile. Invalid → valid → invalid catches+ * the desktop half missed by the earlier mobile-only fix, including stale accessibility links.+ * Extend the existing component harness; this is a unit interaction, not a voice-service E2E.+ */+it('keeps custom ASR URL validation inline and associated through repeated edits', async () => {+ serviceModel.current = {+ ready: true,+ asrProfiles: [],+ selection: {+ serviceMode: 'byok', asrProvider: 'custom-realtime-asr',+ customAsr: { protocol: 'openai-realtime', websocketUrl: 'wss://voice.example/realtime', model: 'test' },+ },+ };+ render(<MemoryRouter><VoiceInputSection /></MemoryRouter>);+ const input = screen.getByPlaceholderText('settings.voiceInput.serviceSource.customAsr.websocketUrl.placeholder');+ await waitFor(() => expect((input as HTMLInputElement).value).toBe('wss://voice.example/realtime'));+ const errorText = 'settings.voiceInput.serviceSource.customAsr.websocketUrl.invalid';+ for (const invalidUrl of ['https://voice.example', 'not a URL']) {+ fireEvent.change(input, { target: { value: invalidUrl } });+ const error = screen.getByRole('alert');+ expect(error.textContent).toBe(errorText);+ expect(input.getAttribute('aria-invalid')).toBe('true');+ expect(document.getElementById(input.getAttribute('aria-describedby')!)).toBe(error);+ fireEvent.change(input, { target: { value: 'wss://voice.example/realtime' } });+ expect(screen.queryByText(errorText)).toBeNull();+ expect(input.getAttribute('aria-invalid')).not.toBe('true');+ expect(input.hasAttribute('aria-describedby')).toBe(false);+ }+});+const cases = [{ field: 'composerLongPressEnabled', override: 'composerLongPressEnabledOverride',label: 'settings.voiceInput.composerLongPress.ariaLabel' },