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 changelog/unreleased/console-provider-views.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### English

- Provider-wide settings now live in a modal on the Models page. Account editing keeps only name, concurrency, and priority; provider policy owns floors, proxy, system-prompt handling, aliases, enabled models, and check-in time. Saving provider settings closes immediately and re-filters the cached catalog in the background instead of waiting for an upstream refresh.
- The Models page groups models into one card per connected provider and region, with a model count in the header. The provider filter lists only connected provider/region pairs, defaults to the first one, and the redundant "Model catalog" intro header is gone. A provider restricted to a selected model list no longer shows `auto`.
- The cross-provider model editor keeps its header and footer visible and scrolls the form body on short screens. Members are configured by provider, region, and model only; the account is chosen automatically from the provider account pool instead of being pinned in the editor. The editor lists only connected provider/region combinations and models enabled by that provider's policy.
- Account cards show the upstream check-in state (`already`, `pending`, `skipped`, or `unknown`) with the last sync time, and scheduled check-in defaults to automatic mode based on the upstream window.

### 中文

- 供应商级设置改为模型页上的统一弹窗。账号编辑只保留名称、并发和优先级;积分/百分比保底、代理、系统提示词处理、别名、可用模型和签到时间由供应商策略统一管理。保存供应商设置后弹窗立即关闭,已缓存目录在后台重新过滤,不再等待上游刷新。
- 模型页按已接入的供应商与区域分组,每个供应商一张卡片,标题显示模型数量。供应商筛选只列出有账号接入的供应商/区域并默认选中第一个,顶部冗余的“模型目录”说明栏已移除。限制为勾选模型的供应商不再显示 `auto`。
- 跨 Provider 模型编辑器在矮屏下固定标题和底部操作区、让表单内容独立滚动。成员只按供应商、区域和模型配置,账号由供应商账号池自动选择,不再在编辑器里指定单个账号;编辑器只列出已接入的供应商/区域和该供应商策略启用的模型。
- 账号卡片显示上游签到状态(已签到、未签到、未开放或状态未知)和最近同步时间;自动签到默认按上游窗口自动排期。
9 changes: 9 additions & 0 deletions frontend/src/api/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ export function fetchModelsCached(accountId?: string, view?: 'regional') {
return pending
}

export function reloadModels(accountId?: string, view?: 'regional') {
const key = modelsMemoryKey(accountId, view)
modelsMemoryCache.delete(key)
return fetchModels(accountId, false, view).then((data) => {
modelsMemoryCache.set(key, { data, at: Date.now() })
return data
})
}

export function refreshModels(accountId?: string, view?: 'regional', options?: ModelFetchOptions) {
const key = modelsMemoryKey(accountId, view)
modelsMemoryCache.delete(key)
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/api/providerSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { api } from './client'

export type ProviderPolicy = {
provider: string
region: string
credit_floor?: number | null
percent_floor?: number | null
proxy_url?: string
drop_system_prompt?: boolean
model_aliases?: Record<string, string>
enabled_models?: string[]
models_restricted?: boolean
checkin_time?: string
checkin_auto?: boolean
}

export type ProviderCatalogEntry = {
id: string
display_name?: string
}

export function fetchProviderPolicies() {
return api<{ data?: ProviderPolicy[] }>('/api/provider-settings')
}

export function updateProviderPolicy(policy: ProviderPolicy) {
return api<{ data?: ProviderPolicy }>('/api/provider-settings', {
method: 'PATCH',
body: JSON.stringify(policy),
})
}

export function fetchProviderCatalog(provider: string, region: string) {
const query = new URLSearchParams({ provider, region })
return api<{ data?: ProviderCatalogEntry[] }>(`/api/provider-settings/catalog?${query.toString()}`)
}
3 changes: 3 additions & 0 deletions frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export type Overview = {
last_checkin_at?: string
last_checkin_msg?: string
last_checkin_status?: string
last_checkin_source?: string
last_checkin_synced_at?: string
checkin_auto_time?: string
quota?: AccountQuota
created_at?: string
updated_at?: string
Expand Down
47 changes: 0 additions & 47 deletions frontend/src/components/AddAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { copyText } from '@/lib/clipboard'
import { BrandMark } from '@/components/BrandMark'
import { CaiaiSoftLink } from '@/components/CaiaiSoftLink'
import { ProviderMark } from '@/components/ProviderMark'
import { CompactSwitch } from '@/components/ui/CompactSwitch'
import { FilterToggle } from '@/components/ui/FilterToggle'
import { FormRow } from '@/components/ui/FormRow'
import { OptionTiles } from '@/components/ui/OptionTiles'
Expand Down Expand Up @@ -152,8 +151,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
const [name, setName] = useState('')
const [maxInFlight, setMaxInFlight] = useState(4)
const [priority, setPriority] = useState(50)
const [dropSystemPrompt, setDropSystemPrompt] = useState(true)
const [proxyUrl, setProxyUrl] = useState('')
const [pat, setPat] = useState('')
const [json, setJson] = useState('')
const [zhipuMode, setZhipuMode] = useState<'payg' | 'coding'>('payg')
Expand Down Expand Up @@ -215,7 +212,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
// Command Code has no browser login (a pasted user_… key is the only auth),
// so the wizard opens on the PAT tab instead of the browser tab.
const hasBrowserLogin = activeOption?.descriptor.capabilities?.browser_login !== false
const showDropSystem = activeOption?.provider === 'workbuddy' || activeOption?.provider === 'trae'
const showCallbackPaste = activeOption?.provider === 'trae' || activeOption?.provider === 'devin' || activeOption?.provider === 'codex' || activeOption?.provider === 'codearts'
const busy = phase === 'busy' || phase === 'polling'
const settingsLocked = Boolean(createdId.current) || busy
Expand Down Expand Up @@ -249,13 +245,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
return {
max_inflight: parsedMaxInFlight(),
priority: parsedPriority(),
// WorkBuddy exposes the switch because upstream content screening rejects
// third-party system prompts. Trae, Kimi and CodeArts keep caller system
// prompts: clients such as MiMo Code put JSON instructions there, and
// those families have no equivalent screening. Every other provider keeps
// the historical drop=true default.
drop_system_prompt: showDropSystem ? dropSystemPrompt : activeOption?.provider !== 'kimi' && activeOption?.provider !== 'codearts',
proxy_url: proxyUrl.trim(),
}
}

Expand All @@ -269,8 +258,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
setName('')
setMaxInFlight(4)
setPriority(50)
setDropSystemPrompt(true)
setProxyUrl('')
setPat('')
setJson('')
setZhipuMode('payg')
Expand Down Expand Up @@ -337,7 +324,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
const option = providerOptions.find((item) => item.id === next)
setAccountType(next)
setTab(option?.provider === 'zhipu' || option?.provider === 'doubaowork' ? 'pat' : 'browser')
setDropSystemPrompt(option?.provider !== 'trae' && option?.provider !== 'kimi' && option?.provider !== 'codearts')
setMessage('')
setStep('login')
}
Expand Down Expand Up @@ -431,8 +417,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
region: activeOption.region,
max_inflight: options.max_inflight,
priority: options.priority,
drop_system_prompt: options.drop_system_prompt,
proxy_url: options.proxy_url,
})
setPhase('done')
setMessage(t('wizardAccountReady'))
Expand Down Expand Up @@ -480,8 +464,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
region: activeOption.region,
max_inflight: options.max_inflight,
priority: options.priority,
drop_system_prompt: options.drop_system_prompt,
proxy_url: options.proxy_url,
})
setPhase('done')
setMessage(t('wizardAccountReady'))
Expand Down Expand Up @@ -541,8 +523,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
accounts,
max_inflight: options.max_inflight,
priority: options.priority,
drop_system_prompt: options.drop_system_prompt,
proxy_url: options.proxy_url,
}
} else if (provider === 'workbuddy') {
// Shared normalize keeps hub workbuddy-accounts packs intact (same as batch import).
Expand All @@ -552,8 +532,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
enabled: true,
max_inflight: options.max_inflight,
priority: options.priority,
drop_system_prompt: options.drop_system_prompt,
proxy_url: options.proxy_url,
})
} else {
if (!bundle.format) {
Expand All @@ -576,7 +554,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
region: detected.region || activeOption.region,
max_inflight: options.max_inflight,
priority: options.priority,
drop_system_prompt: options.drop_system_prompt,
}
}
try {
Expand Down Expand Up @@ -750,30 +727,6 @@ export function AddAccountModal({ isOpen, onClose, onAdded }: Props) {
<Description className="text-caption leading-5 text-muted">{t('priorityHint')}</Description>
</div>
</div>
<div className="flex flex-col gap-1.5">
<Label className="text-body font-medium text-muted">{t('proxyUrl')}</Label>
<Input
fullWidth
value={proxyUrl}
onChange={(event) => setProxyUrl(event.target.value)}
placeholder={t('proxyUrlPlaceholder')}
aria-label={t('proxyUrl')}
disabled={settingsLocked}
/>
<Description className="text-caption leading-5 text-muted">{t('proxyUrlHint')}</Description>
</div>
{showDropSystem ? (
<div className="flex flex-col gap-1.5">
<Label className="text-body font-medium text-muted">{t('dropSystemPrompt')}</Label>
<Description className="text-caption leading-5 text-muted">{t(activeOption?.provider === 'trae' ? 'dropSystemPromptTraeHint' : 'dropSystemPromptCreateHint')}</Description>
<CompactSwitch
isSelected={dropSystemPrompt}
isDisabled={settingsLocked}
ariaLabel={t('dropSystemPrompt')}
onChange={setDropSystemPrompt}
/>
</div>
) : null}
</div>
) : null}
</div>
Expand Down
34 changes: 29 additions & 5 deletions frontend/src/components/account/AccountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ export type AccountBusyKind = 'create' | 'import' | 'device' | 'pat' | 'callback

type Translate = (key: string, vars?: Record<string, string | number>) => string

// Provider check-in timestamps belong to the upstream/server calendar, not the
// browser PC's zone. Format them in the provider zone so a laptop set to
// another region still shows the same server wall clock.
function formatCheckinMoment(value: string, timezone: string) {
const date = new Date(value)
if (Number.isNaN(date.getTime())) return value
try {
return new Intl.DateTimeFormat(undefined, {
dateStyle: 'medium',
timeStyle: 'medium',
timeZone: timezone,
}).format(date)
} catch {
return date.toLocaleString()
}
}

// Transient check-in feedback pushed from the page after a manual check-in.
// `kind` selects the glyph/colour; `message` is the raw upstream error text
// (only present for failures) and may be truncated in the UI with a copy button.
Expand Down Expand Up @@ -169,8 +186,11 @@ export function AccountCard({
const identity = account.remote_uid || account.id
const shortIdentity = identity.length > 12 ? identity.slice(0, 8) : identity
const checkinStatus = account.last_checkin_status
const checkinLabel = checkinStatus === 'success' ? 'checkinRecordSuccess' : checkinStatus === 'already' ? 'checkinRecordAlready' : checkinStatus === 'skipped' ? 'checkinRecordSkipped' : checkinStatus === 'error' ? 'checkinRecordFailed' : 'lastCheckinNone'
const checkinLabel = checkinStatus === 'success' ? 'checkinRecordSuccess' : checkinStatus === 'already' ? 'checkinRecordAlready' : checkinStatus === 'pending' ? 'checkinStatusPending' : checkinStatus === 'unknown' ? 'checkinStatusUnknown' : checkinStatus === 'skipped' ? 'checkinRecordSkipped' : checkinStatus === 'error' ? 'checkinRecordFailed' : 'lastCheckinNone'
const checkedInCurrentDay = checkedInToday(account, checkinTimezone)
const checkinSchedule = account.checkin_time || account.checkin_auto_time || checkinDefaultTime
const checkinTimeZone = checkinTimezone && checkinTimezone !== 'Local' ? checkinTimezone : 'Asia/Shanghai'
const syncedAt = account.last_checkin_synced_at ? formatCheckinMoment(account.last_checkin_synced_at, checkinTimeZone) : ''

useLayoutEffect(() => {
const chip = chipRef.current
Expand Down Expand Up @@ -493,24 +513,28 @@ export function AccountCard({
<span className="flex min-w-0 cursor-help flex-wrap items-center gap-1.5">
<span className="font-medium text-foreground/75">{t('checkinStatus')}</span>
<span className={checkinStatus === 'error' ? 'text-danger' : ''}>{t(checkinLabel)}</span>
{!checkedInCurrentDay ? (
{!checkedInCurrentDay && checkinStatus === 'pending' ? (
<span className="whitespace-nowrap rounded-full bg-warning/15 px-1.5 py-px font-medium text-warning">
{t('checkinPending')}
</span>
) : null}
</span>
</Tooltip.Trigger>
<Tooltip.Content>{account.last_checkin_at ? new Date(account.last_checkin_at).toLocaleString() : t('lastCheckinNone')}{account.last_checkin_msg ? ` · ${account.last_checkin_msg}` : ''}</Tooltip.Content>
<Tooltip.Content>
{account.last_checkin_at ? t('checkinServerTime', { time: formatCheckinMoment(account.last_checkin_at, checkinTimeZone) }) : t('lastCheckinNone')}
{account.last_checkin_msg ? ` · ${account.last_checkin_msg}` : ''}
{syncedAt ? ` · ${t('checkinUpstreamSynced', { time: syncedAt })}` : ''}
</Tooltip.Content>
</Tooltip>
<Tooltip>
<Tooltip.Trigger>
<span className="flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap">
<span>{t('checkinDaily')}</span>
<span className="mono text-caption text-foreground/55">{account.checkin_time || checkinDefaultTime}</span>
<span className="mono text-caption text-foreground/55">{checkinSchedule}</span>
<CompactSwitch isSelected={Boolean(account.auto_checkin)} isDisabled={Boolean(busyKind)} ariaLabel={t('autoCheckin')} onChange={(selected) => onToggleAutoCheckin?.(selected)} />
</span>
</Tooltip.Trigger>
<Tooltip.Content>{account.checkin_time ? t('checkinCustom') : t('checkinInherit')}</Tooltip.Content>
<Tooltip.Content>{t('checkinAutoScheduleHint', { time: checkinSchedule ?? '' })}{` · ${t('checkinServerClock', { timezone: checkinTimeZone })}`}</Tooltip.Content>
</Tooltip>
</div>
) : null}
Expand Down
Loading
Loading