Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions openless-all/app/crates/openless-core/src/provider_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,19 @@ mod tests {
}
}

#[test]
fn browser_provider_descriptor_fixture_matches_core() {
let fixture: Vec<ProviderDescriptor> = serde_json::from_str(include_str!(
"../../../src/lib/ipc/mock-provider-descriptors.json"
))
.unwrap();
let actual = [ProviderKind::Llm, ProviderKind::Asr, ProviderKind::Omni]
.into_iter()
.flat_map(provider_descriptors)
.collect::<Vec<_>>();
assert_eq!(fixture, actual);
}

#[test]
fn secret_like_volc_resource_ids_are_not_attributed() {
assert_eq!(
Expand Down
15 changes: 10 additions & 5 deletions openless-all/app/src/components/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//
// 设计原则:每个可见控件都必须可用。

import { ProviderLeaveContext, useProviderForm } from '../pages/settings/ProviderForm';
import { useLayoutEffect, useRef, useState, type CSSProperties } from 'react';
import { useTranslation } from 'react-i18next';
import { Icon } from './Icon';
Expand Down Expand Up @@ -57,6 +58,8 @@ const LINK_ITEMS: ModalNavItem[] = [
];

export function SettingsModal({ os: _os, onClose, initialSettingsSection }: SettingsModalProps) {
const providerForm = useProviderForm();
const close = () => { void providerForm.finish(onClose); };
const { t } = useTranslation();
const mobile = useMobileLayout();
const conservative = useConservativeLayout();
Expand All @@ -78,8 +81,9 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
}, [section, mobile]);

return (
<ProviderLeaveContext.Provider value={providerForm.register}>
<div
onClick={mobile ? undefined : onClose}
onClick={mobile ? undefined : close}
style={{
position: mobile ? 'fixed' : 'absolute',
inset: 0,
Expand Down Expand Up @@ -124,7 +128,7 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
}}>
<button
type="button"
onClick={onClose}
onClick={close}
aria-label={t('common.close')}
style={mobileHeaderBtnStyle}
>
Expand All @@ -140,7 +144,7 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
<button
key={it.id}
type="button"
onClick={() => setSection(it.id as SettingsSectionId)}
onClick={() => void providerForm.finish(() => setSection(it.id as SettingsSectionId))}
className={active ? 'ol-nav-btn ol-nav-btn-active' : 'ol-nav-btn'}
style={mobileTabChipStyle(active)}
>
Expand Down Expand Up @@ -186,7 +190,7 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
<button
key={it.id}
ref={el => { tabRefs.current[idx] = el; }}
onClick={() => setSection(it.id as SettingsSectionId)}
onClick={() => void providerForm.finish(() => setSection(it.id as SettingsSectionId))}
className={active ? 'ol-nav-btn ol-nav-btn-active' : 'ol-nav-btn'}
style={navBtnStyle}>
<Icon name={it.icon} size={14} />
Expand Down Expand Up @@ -223,7 +227,7 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
/>
{!mobile && (
<button
onClick={onClose}
onClick={close}
style={{
position: 'absolute', top: 14, right: 14, zIndex: 2,
width: 28, height: 28, border: 0, borderRadius: 999,
Expand Down Expand Up @@ -288,6 +292,7 @@ export function SettingsModal({ os: _os, onClose, initialSettingsSection }: Sett
</div>
</div>
</div>
</ProviderLeaveContext.Provider>
);
}

Expand Down
8 changes: 6 additions & 2 deletions openless-all/app/src/components/ui/SelectLite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface SelectOption {
value: string;
label: string;
disabled?: boolean;
/** 搜索期间仍保留操作项,例如自定义输入入口。 */
alwaysVisible?: boolean;
/** 可选:渲染在选项标签右侧、勾选标记左侧(如麦克风音量条)。 */
trailing?: ReactNode;
}
Expand Down Expand Up @@ -111,7 +113,7 @@ export function SelectLite({
const needle = query.trim().toLocaleLowerCase();
if (!needle) return options;
return options.filter(option => (
option.label.toLocaleLowerCase().includes(needle)
option.alwaysVisible || option.label.toLocaleLowerCase().includes(needle)
|| option.value.toLocaleLowerCase().includes(needle)
));
}, [options, query]);
Expand Down Expand Up @@ -263,6 +265,7 @@ export function SelectLite({
};

const selectIndex = (index: number) => {
if (disabled) return;
const option = filteredOptions[index];
if (!option || option.disabled) return;
onChange(option.value);
Expand Down Expand Up @@ -319,6 +322,7 @@ export function SelectLite({
};

const handleSearchKeyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {
if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
if (event.key === 'Escape') {
event.preventDefault();
closeMenu();
Expand Down Expand Up @@ -459,7 +463,7 @@ export function SelectLite({
role="listbox"
style={{ maxHeight: searchable ? 274 : 272, overflowY: 'auto' }}
>
{filteredOptions.length === 0 && (
{!filteredOptions.some(option => !option.alwaysVisible) && (
<div
style={{
padding: '18px 10px',
Expand Down
8 changes: 6 additions & 2 deletions openless-all/app/src/lib/ipc/asr-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CredentialsStatus } from "../types"
import { invokeOrMock, isTauri } from "./shared"
import { mockCredentialsStatus, mockCredentialValues } from "./mock-data"
import { invalidateMockChannelTest } from "./channels"
import type { LlmRequestFormat } from "./providers"
import { listProviderDescriptors, type LlmRequestFormat } from "./providers"

export interface ProviderCheckResult {
ok: boolean
Expand Down Expand Up @@ -104,6 +104,10 @@ export async function listProviderModels(
channelId?: string,
providerType?: string,
): Promise<ProviderModelsResult> {
if (!isTauri) {
const descriptor = (await listProviderDescriptors(kind)).find(item => item.providerType === providerType)
if (descriptor?.staticModels.length) return { models: descriptor.staticModels }
}
if (!isTauri && providerType === "orcarouter" && (kind === "llm" || kind === "asr")) {
const endpointAccount = kind === "llm" ? "ark.endpoint" : "asr.endpoint"
const endpoint = mockCredentialValues.get(`${channelId ?? ''}:${endpointAccount}`)
Expand All @@ -124,6 +128,6 @@ export async function listProviderModels(
models:
kind === "llm"
? ["gpt-4o", "deepseek-v4-flash", "deepseek-v4-pro"]
: ["whisper-1"],
: kind === "omni" ? ["gpt-4o-audio-preview", "qwen3-omni-flash"] : ["whisper-1"],
}))
}
Loading
Loading