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
15 changes: 15 additions & 0 deletions composables/upstream-providers/exclusion-regression.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect, test } from 'bun:test'
import { flattenV8Groups, v8GroupsFromEntries } from './v8Groups'
import type { ProviderCategory } from './types'
const category: ProviderCategory = { value: 'gemini-api-key', path: '/config/api-keys/gemini', template: { models: [] } }
test('null key exclusions inherit group rules', () => {
const entries = flattenV8Groups([{ 'excluded-models': ['*'], keys: [{ id: 'key', 'excluded-models': null }] }], category)
expect(entries[0]!['excluded-models']).toEqual(['*'])
})
test('editing key exclusions preserves group and sibling inheritance', () => {
const entries = flattenV8Groups([{ 'excluded-models': ['*'], keys: [{ id: 'selected' }, { id: 'sibling' }] }], category)
entries[0]!['excluded-models'] = []
const result = v8GroupsFromEntries(entries, category)
expect(result[0]!['excluded-models']).toEqual(['*'])
expect(result[0]!.keys![1]!['excluded-models']).toBeUndefined()
})
37 changes: 37 additions & 0 deletions composables/upstream-providers/exclusions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { expect, test } from 'bun:test'
import { flattenV8Groups, v8GroupsFromEntries } from './v8Groups'
import type { ProviderCategory } from './types'

const category: ProviderCategory = { value: 'gemini-api-key', path: '/config/api-keys/gemini', template: { models: [] } }

test('null key exclusions inherit the group while empty overrides stay enabled', () => {
const entries = flattenV8Groups([{ 'excluded-models': ['*', 'hidden-*'], keys: [
{ id: 'inherited', 'excluded-models': null }, { id: 'enabled', 'excluded-models': [] }, { id: 'absent' }
] }], category)
expect(entries.map(entry => entry['excluded-models'])).toEqual([['*', 'hidden-*'], [], ['*', 'hidden-*']])
})

test('editing one native exclusion override never changes the group or sibling inheritance', () => {
const groups = [{ 'excluded-models': ['*', 'hidden-*'], 'connection-pool': { enabled: true }, keys: [
{ id: 'selected', weight: 2 }, { id: 'sibling', weight: 5 }
] }]
const entries = flattenV8Groups(groups, category)
entries[0]!['excluded-models'] = ['hidden-*']
const result = v8GroupsFromEntries(entries, category)
expect(result[0]!['excluded-models']).toEqual(['*', 'hidden-*'])
expect(result[0]!.keys![0]!['excluded-models']).toEqual(['hidden-*'])
expect(result[0]!.keys![1]!['excluded-models']).toBeUndefined()
expect(result[0]!.keys![1]!.weight).toBe(5)
expect(result[0]!['connection-pool']).toEqual({ enabled: true })
expect(flattenV8Groups(result, category).map(entry => entry['excluded-models'])).toEqual([['hidden-*'], ['*', 'hidden-*']])
})

test('unchanged rules preserve null, absent and explicit empty override representations', () => {
const entries = flattenV8Groups([{ 'excluded-models': ['*'], keys: [
{ id: 'null', 'excluded-models': null }, { id: 'absent' }, { id: 'empty', 'excluded-models': [] }
] }], category)
const keys = v8GroupsFromEntries(entries, category)[0]!.keys!
expect(keys[0]!['excluded-models']).toBeNull()
expect(Object.hasOwn(keys[1]!, 'excluded-models')).toBe(false)
expect(keys[2]!['excluded-models']).toEqual([])
})
8 changes: 8 additions & 0 deletions composables/upstream-providers/exclusions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { ProviderCredential } from './types'

// Native credentials inherit group exclusions only when their override is absent or null.
// An explicit empty list enables a key even if its group excludes every model.
export function readProviderKeyExclusions(group: ProviderCredential, key?: ProviderCredential): string[] {
const rules = key?.['excluded-models'] ?? group['excluded-models']
return Array.isArray(rules) ? rules.filter((rule): rule is string => typeof rule === 'string') : []
}
2 changes: 1 addition & 1 deletion composables/upstream-providers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface ProviderCredential {
prefix?: string
headers?: Record<string, unknown>
models?: ProviderModel[]
'excluded-models'?: string[]
'excluded-models'?: string[] | null
'request-retry'?: number | null
'request-scoped-errors'?: Array<Record<string, unknown>> | null
'disable-cooling'?: boolean | null
Expand Down
13 changes: 11 additions & 2 deletions composables/upstream-providers/v8Groups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ProviderCategory, ProviderCredential, ProviderEntry, ProviderGroup } from './types'
import { cloneValue } from '~/composables/upstream-providers/categories'
import { readProviderKeyExclusions } from './exclusions'

// Converts between the v8 grouped API shape and the flattened per-key rows shown in the table.
export const v8GroupFields = ['name', 'base-url', 'priority', 'disabled', 'prefix', 'proxy-url', 'headers', 'models', 'excluded-models', 'disable-cooling', 'request-retry', 'request-scoped-errors', 'support-prompt-cache-key']
Expand All @@ -22,6 +23,7 @@ export function flattenV8Groups(groups: unknown, category: ProviderCategory): Pr
? { ...group, id: key.id || key.uuid || key.auth_index || key['auth-index'] || group.id, uuid: key.uuid || group.uuid, auth_index: key.auth_index || key['auth-index'] || group.auth_index, weight: key.weight ?? 1, 'api-key-entries': sourceKey ? [key] : [] }
: { ...group, ...key, weight: key.weight ?? 1 }
if (compat) delete entry['excluded-models']
else entry['excluded-models'] = readProviderKeyExclusions(group, key)
entry.__v8Group = group
entry.__v8GroupIndex = groupIndex
entry.__v8KeyIndex = sourceKey ? keyIndex : -1
Expand Down Expand Up @@ -59,14 +61,21 @@ export function v8GroupsFromEntries(entries: ProviderEntry[], category: Provider
const editedEntry = groupEntries.find(entry => v8GroupFieldsChanged(entry, compat)) || groupEntries[0]!
const group = cloneValue(editedEntry.__v8Group) || {}
// Native cooling is a key override; changing it must not replace the inherited group policy.
copyFields(group, editedEntry, compat ? v8GroupFields : v8GroupFields.filter(field => field !== 'disable-cooling'))
copyFields(group, editedEntry, compat ? v8GroupFields : v8GroupFields.filter(field => field !== 'disable-cooling' && field !== 'excluded-models'))
if (!compat && !editedEntry.__v8Group && Object.hasOwn(editedEntry, 'excluded-models')) {
group['excluded-models'] = cloneValue(editedEntry['excluded-models'])
}
if (compat) delete group['excluded-models']
if (!compat) {
delete group.id
delete group.uuid
group.keys = groupEntries.map((entry) => {
const key: ProviderCredential = cloneValue(entry.__v8Key) || {}
copyFields(key, entry, v8NativeKeyFields)
copyFields(key, entry, v8NativeKeyFields.filter(field => field !== 'excluded-models'))
const inheritedRules = readProviderKeyExclusions(entry.__v8Group || {}, entry.__v8Key || undefined)
if (!entry.__v8Group || JSON.stringify(entry['excluded-models']) !== JSON.stringify(inheritedRules)) {
key['excluded-models'] = cloneValue(entry['excluded-models'])
}
for (const field of v8KeyOverrideFields) {
if (!Object.hasOwn(entry, `__set:${field}`)) continue
const override = entry[`__set:${field}`]
Expand Down
22 changes: 22 additions & 0 deletions docs/maintenance-2026-12-01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Upstream maintenance — 2026-12-01

## Scope

Reviewed upstream range `7351a9d2..737c0806` and adapted the exclusion-inheritance portion of `6aac9cd553eeb13ade3f4923193cf39f70d99dcd` to the existing Vue/Nuxt grouped-provider editor. This is **partial semantic coverage**, not a merge or complete upstream-tip coverage.

Native key exclusions now use the upstream nullish-inheritance rule: null/absent inherits the group; an explicit empty list overrides it. Regrouping edited rows must not promote one key's exclusions onto the shared group or materialize inherited exclusions on sibling keys. Original null/absent/empty representations are preserved on unchanged keys.

No React components, new status toggles, credential-status writes, or whole-source replacements were introduced. Existing shadcn architecture, branding, management URL/security boundaries, key identities, unexposed fields, billing imports, session separation and API routes remain intact. This change does not promise to fix unrelated provider editor concurrency behavior.

## Remaining upstream work

- `6aac9cd`: dedicated latest-snapshot status action and dashboard effective-status counting are not included; the fork currently exposes view/edit/duplicate/delete, not the upstream native status toggle.
- `6f780bc`: upstream React bootstrap placement differs from Nuxt layout-owned refresh. The fork already invokes capability refresh on default-layout mount; no blanket React-to-Vue transplant was attempted. Browser deep-link/session acceptance remains unverified.
- `480ad92`: ACP plugin model pricing needs a separate adaptation through the fork's model catalog, provider editor and billing state. AI48Proxy intentionally rejects plugin-enabled snapshots; exposing ACP as a supported worker feature would misrepresent compatibility. This remains pending, not declared equivalent or implemented.
- Earlier upstream React changes remain only partially adapted; differing histories and cherry output alone are not treated as missing-feature proof.

## Database and verification

No schema change: AI48Home remains version **31 → 31**, upstream **21**. No migration added, renumbered or executed against production.

Exact `origin/main` baseline: `bca25f5c6df773e390e13a81c41204a2f1d0d684`. Separate baseline and maintenance worktrees use identical Bun 1.4.5 dependencies and Nuxt preparation. Routine verification uses `bun run test`; no production build or deployment. Browser visual/focus/live-provider acceptance is not covered by these tests.
Loading