Merge pull request #10461 from makecindy/fix/restore-all-pooled-subscriptions-20261114

fix(subscriptions): 将旧账号池中的账号全部拆回独立供应商
This commit is contained in:
Lizi
2026-11-14 11:18:35 +08:00
committed by GitHub
10 changed files with 276 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import { createCanvas, loadImage } from '@napi-rs/canvas';
import { describe, expect, it, vi } from 'vitest';
import { fileURLToPath } from 'node:url';
import { createCanvas, GlobalFonts, loadImage } from '@napi-rs/canvas';
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
const { addRepresentation, icon } = vi.hoisted(() => {
const addRepresentation = vi.fn();
@@ -10,6 +11,21 @@ vi.mock('electron', () => ({ nativeImage: { createEmpty: () => icon } }));
import { createWindowsBadgeIcon, renderWindowsBadgePng } from '../windowsBadgeIcon';
describe('Windows numeric taskbar badge', () => {
let fixtureFont: ReturnType<typeof GlobalFonts.registerFromPath> = null;
beforeAll(() => {
// Keep the PNG assertions independent of the runner's system-font fallback.
// This checks real badge rendering, not the Windows Segoe UI glyph shapes.
fixtureFont = GlobalFonts.registerFromPath(
fileURLToPath(new URL('../../../native/menubar/BarlowCondensed-SemiBold.ttf', import.meta.url)),
'Segoe UI',
);
expect(fixtureFont).not.toBeNull();
});
afterAll(() => {
// The native font collection is process-wide, including Vitest threads.
if (fixtureFont) GlobalFonts.remove(fixtureFont);
});
it.each([1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 8])(
'renders exact physical dimensions at %s scale for the native Shell bridge',
(scale) => {

View File

@@ -48,6 +48,7 @@ const h = vi.hoisted(() => ({
/** `${kind}:${accountId}` -> provider the account belongs to (placement.ts); absent = built-in. */
placement: {} as Record<string, string>,
restoreLegacy: vi.fn<(...args: unknown[]) => Promise<boolean>>(async () => false),
copyAccountOverrides: vi.fn(),
/** Providers Cindy created for subscription accounts, and the providers whose accounts were read. */
created: {} as Record<string, { kind: 'openai' | 'anthropic'; name: string; account: string }>,
refreshed: new Set<string>(),
@@ -83,6 +84,8 @@ vi.mock('../../subscription-accounts/placement.js', async (importOriginal) => {
readMergedLegacyCodexAccountId: merged,
readMergedProviderAccount: merged,
restoreAutoMergedLegacyCodexAccounts: h.restoreLegacy,
restoreUnplacedSubscriptionAccounts: (options: Parameters<typeof actual.restoreUnplacedSubscriptionAccounts>[0]) =>
h.actualPlacement ? actual.restoreUnplacedSubscriptionAccounts(options) : Promise.resolve(false),
readCreatedSubscriptionProviders: () => {
if (h.placementError) throw h.placementError;
return h.actualPlacement ? actual.readCreatedSubscriptionProviders() : h.created;
@@ -116,6 +119,7 @@ vi.mock('../codex-account-auth.desktop.js', async (importOriginal) => {
vi.mock('../model-disable-store.js', async (importOriginal) => ({
...await importOriginal<typeof import('../model-disable-store.js')>(),
readModelDisableOverrides: () => ({ disabledModels: h.disabledModels, disabledProviders: {} }),
copyProviderDisableOverrides: h.copyAccountOverrides,
}));
vi.mock('../../userDataPath.js', () => ({ getUserDataDir: () => os.tmpdir(), userDataPath: (...parts: string[]) => path.join(os.tmpdir(), ...parts) }));
@@ -749,6 +753,38 @@ describe('provider catalog realm reload', () => {
}
});
// 2026-11-14 user correction: old wizard/pool additions must also become separate providers.
// Unit, real catalog refresh + placement file; prior restoration covered only legacy connections.
// Minimal failure: default + one unplaced account, no custom-provider connection to restore.
it('publishes a separate provider for an old pooled account on catalog refresh and keeps it on reload', async () => {
const root = await fsp.mkdtemp(path.join(os.tmpdir(), 'cindy-pooled-account-restore-'));
const previous = getActiveCatalog();
const previousOwner = h.owner;
const accountId = 'cindy-123456789abc-12345678-1234-1234-1234-123456789abc';
h.profileRoot = root; h.owner = randomUUID(); h.actualPlacement = true;
h.pool = { strategy: 'least', accounts: ['default', accountId].map(id => ({ id, paused: false, limit: 4, weight: 1 })) };
h.customProviderRead.mockResolvedValue([]);
h.copyAccountOverrides.mockClear();
try {
setActiveCatalog(BUNDLED_CATALOG);
await refreshCustomProvidersIntoCatalog();
const created = getActiveCatalog().providers.filter(p => p.id.startsWith('openai-sub-'));
expect(created).toHaveLength(1);
expect(h.copyAccountOverrides).toHaveBeenCalledExactlyOnceWith('openai', created[0].id);
const file = path.join(root, h.owner, 'subscription-account-placement.json');
const persisted = await fsp.readFile(file, 'utf8');
expect(JSON.parse(persisted).accounts).toEqual({ [`openai:${accountId}`]: created[0].id });
await refreshCustomProvidersIntoCatalog();
expect(getActiveCatalog().providers.filter(p => p.id.startsWith('openai-sub-')).map(p => p.id)).toEqual([created[0].id]);
expect(await fsp.readFile(file, 'utf8')).toBe(persisted);
} finally {
setCustomProviders([]); setActiveCatalog(previous);
h.pool = null; h.profileRoot = null; h.owner = previousOwner;
h.actualPlacement = false; h.customProviderRead.mockReset();
await fsp.rm(root, { recursive: true, force: true });
}
});
it('retains the published list in both launchers when the placement read port throws', async () => {
const config = createHostProviderConfig({ profileDir: os.tmpdir(), ownerId: h.owner, openExternal: async () => {},
credentials: { decrypt: () => '', read: () => null, write: () => {}, remove: () => {} } });

View File

@@ -38,6 +38,7 @@ import {
readCreatedSubscriptionProviders,
readMergedProviderAccount,
restoreAutoMergedLegacyCodexAccounts,
restoreUnplacedSubscriptionAccounts,
resolveSubscriptionPoolProvider,
} from '../subscription-accounts/placement.js';
import {
@@ -103,7 +104,7 @@ import {
refreshXaiModelsFromHttp,
} from './model-discovery/xai.js';
import { createProviderService, type ProviderService } from './provider-service.js';
import { readModelDisableOverrides, setProviderDisabled } from './model-disable-store.js';
import { copyProviderDisableOverrides, readModelDisableOverrides, setProviderDisabled } from './model-disable-store.js';
import { listCustomProvidersWithSecureHeaders } from './custom-provider-header-secrets.js';
import { updateCustomProviderIfUnchanged } from './custom-provider-store.js';
import { migrateManagedOllamaProvider } from '../local-model-runtime/managedOllamaProvider.js';
@@ -720,9 +721,14 @@ export async function refreshCustomProvidersIntoCatalog(
isCurrent,
},
);
await restoreUnplacedSubscriptionAccounts({
prepare: copyProviderDisableOverrides,
disable: providerId => setProviderDisabled(providerId, true),
isCurrent,
});
} catch {
// The merged view stays as it was; the next refresh retries.
log.warn('restoring merged legacy Codex connections did not complete');
log.warn('restoring pooled subscription accounts did not complete');
}
if (!isCurrent()) return;
publishSubscriptionPoolProviders();

View File

@@ -23,7 +23,10 @@ const h = vi.hoisted(() => ({
ownComputers: false,
remoteModels: null as string[] | null,
placement: {} as Record<string, string>,
created: {} as Record<string, import('../placement.js').CreatedSubscriptionProvider>,
placementUnreadable: false,
poolUnreadable: false,
placementWriteFails: false,
}));
vi.mock('electron', () => ({
ipcMain: {
@@ -52,15 +55,18 @@ vi.mock('../../maker-host/override-settings-file.js', () => ({
? {
invalidateIfChanged: () => {},
isUnreadable: () => h.placementUnreadable,
read: () => ({ accounts: h.placement }),
updateAtomic: async (edit: (input: { value: { accounts: Record<string, string> } }) => { accounts: Record<string, string> }) => {
read: () => ({ accounts: h.placement, providers: h.created, strategies: {} }),
updateAtomic: async (edit: (input: { value: { accounts: typeof h.placement; providers: typeof h.created; strategies: Record<string, never> } }) => { accounts?: typeof h.placement; providers?: typeof h.created }) => {
h.beforeWrite?.();
h.placement = edit({ value: { accounts: h.placement } }).accounts;
const next = edit({ value: { accounts: h.placement, providers: h.created, strategies: {} } });
if (h.placementWriteFails) throw new Error('placement write unavailable');
if (next.accounts) h.placement = next.accounts;
if (next.providers) h.created = next.providers;
},
}
: {
invalidateIfChanged: () => {},
isUnreadable: () => false,
isUnreadable: () => h.poolUnreadable,
read: () => ({ bindings: h.bindings, pools: h.pools }),
updateAtomic: async (edit: (input: { value: { pools: typeof h.pools; bindings: typeof h.bindings } }) => { pools?: typeof h.pools; bindings?: typeof h.bindings }) => {
h.beforeWrite?.();
@@ -109,6 +115,7 @@ import {
readMergedLegacyCodexAccountId,
readOpenAiMergedLegacyAccountsIfReadable,
restoreAutoMergedLegacyCodexAccounts,
restoreUnplacedSubscriptionAccounts,
} from '../placement.js';
registerSubscriptionAccountsIpc();
const invoke = (command: unknown) => h.handlers.get(SUBSCRIPTION_ACCOUNTS_CHANNEL)!({}, command);
@@ -135,7 +142,10 @@ beforeEach(() => {
h.ownComputers = false;
h.remoteModels = null;
h.placement = {};
h.created = {};
h.placementUnreadable = false;
h.poolUnreadable = false;
h.placementWriteFails = false;
h.execute.mockReset().mockResolvedValue({ accounts: [] });
h.availability.mockReset().mockResolvedValue(true);
h.sessionRead.mockReset().mockResolvedValue({ providerId: 'anthropic', state: 'legacy' });
@@ -314,6 +324,109 @@ describe('legacy Codex account upgrade', () => {
} })).toEqual({ accounts: { [`anthropic:${ids.a}`]: 'claude-work' }, providers: {}, strategies: {} });
});
});
describe('old automatically pooled account restoration', () => {
const account = (id: string) => ({ id, paused: false, limit: 4, weight: 1 });
const pooledId = () => `cindy-${accountOwnerPrefix()}-12345678-1234-1234-1234-123456789abc`;
const options = () => ({ prepare: vi.fn(), disable: vi.fn() });
// 2026-11-14 user correction, unit: real restoration/path/binding entries. Prior coverage only
// restored old independent Codex connections, leaving wizard/pool additions merged forever.
// Minimal input: one unplaced non-default account; both kinds must split without moving homes,
// changing bindings/settings, re-enabling a disconnected pool or undoing a recorded user merge.
it.each(['openai', 'anthropic'] as const)('splits old %s additions while preserving explicit merges, bindings and account settings', async kind => {
const id = pooledId();
const chosen = id.replace('123456789abc', '123456789abd');
const legacy = id.replace('123456789abc', '123456789abe');
h.pools[kind] = { strategy: 'round', disconnected: true, accounts: [account('default'),
{ ...account(id), paused: true, limit: 2, weight: 3 }, account(chosen)],
};
if (kind === 'openai') {
h.pools.openai!.accounts.push(account(legacy));
h.pools.openai!.legacyCodexAccounts = { 'openai-missing-connection': legacy };
}
h.placement[`${kind}:${chosen}`] = kind;
await writeAccountBindings(['task:saved', 'native:saved'], kind, id);
const before = JSON.stringify([h.pools, h.bindings]);
const directory = accountDirectory(kind, id);
const callbacks = options();
expect(await restoreUnplacedSubscriptionAccounts(callbacks)).toBe(true);
const providerId = h.placement[`${kind}:${id}`];
expect(providerId).toMatch(new RegExp(`^${kind}-sub-[a-f0-9]{8}$`));
expect(h.created[providerId]).toMatchObject({ kind, account: id });
expect(Object.keys(h.created)).toEqual([providerId]);
expect(h.placement[`${kind}:${chosen}`]).toBe(kind);
expect(h.placement[`${kind}:default`]).toBeUndefined();
expect(callbacks.prepare).toHaveBeenCalledExactlyOnceWith(kind, providerId);
expect(callbacks.disable).toHaveBeenCalledExactlyOnceWith(providerId);
expect(JSON.stringify([h.pools, h.bindings])).toBe(before);
expect(accountDirectory(kind, id)).toBe(directory);
const settled = JSON.stringify([h.placement, h.created]);
expect(await restoreUnplacedSubscriptionAccounts(callbacks)).toBe(false);
expect(JSON.stringify([h.placement, h.created])).toBe(settled);
});
it.each(['placement', 'pool'] as const)('leaves accounts untouched while the %s file is unreadable and retries later', async file => {
h.pools.openai = { strategy: 'least', accounts: [account(pooledId())] };
if (file === 'placement') h.placementUnreadable = true; else h.poolUnreadable = true;
const callbacks = options();
expect(await restoreUnplacedSubscriptionAccounts(callbacks)).toBe(false);
expect(callbacks.prepare).not.toHaveBeenCalled();
expect(h.placement).toEqual({});
h.placementUnreadable = false; h.poolUnreadable = false;
expect(await restoreUnplacedSubscriptionAccounts(callbacks)).toBe(true);
});
// PR #10461 review, unit: a failed batch previously retried with random target IDs, so persisted
// model settings accumulated under orphan IDs. Two accounts, two failed attempts, then success
// must reuse the prepared targets, for both second-account preparation and placement-write errors.
it.each(['prepare', 'write'] as const)('reuses prepared provider settings after repeated %s failures', async failure => {
const first = pooledId();
const second = first.replace('123456789abc', '123456789abd');
h.pools.openai = { strategy: 'least', accounts: [account(first), account(second)] };
const prepared = new Set<string>();
let fail = true;
let inAttempt = 0;
const prepare = vi.fn((_kind: string, providerId: string) => {
if (fail && failure === 'prepare' && ++inAttempt === 2) throw new Error('settings unavailable');
prepared.add(providerId);
});
for (let attempt = 0; attempt < 2; attempt++) {
inAttempt = 0;
h.placementWriteFails = failure === 'write';
await expect(restoreUnplacedSubscriptionAccounts({ prepare, disable: vi.fn() })).rejects.toThrow('unavailable');
expect(prepared.size).toBe(failure === 'prepare' ? 1 : 2);
expect(h.created).toEqual({});
expect(h.placement).toEqual({});
// Pool enumeration order cannot change targets between failed attempts.
h.pools.openai!.accounts.reverse();
}
fail = false; h.placementWriteFails = false;
expect(await restoreUnplacedSubscriptionAccounts({ prepare, disable: vi.fn() })).toBe(true);
expect([...prepared].sort()).toEqual(Object.keys(h.created).sort());
expect(prepared.size).toBe(2);
});
it.each(['owner', 'generation', 'move', 'remove', 'settings'] as const)('does not publish a stale or incomplete restoration after %s changes', async change => {
const id = pooledId();
h.pools.openai = { strategy: 'least', accounts: [account(id)] };
const callbacks = options();
let current = true;
h.beforeWrite = () => {
if (change === 'owner') h.owner = 'owner-b';
if (change === 'generation') current = false;
if (change === 'move') h.placement[`openai:${id}`] = 'openai';
if (change === 'remove') h.pools.openai!.accounts = [];
};
if (change === 'settings') callbacks.prepare.mockImplementation(() => { throw Error('settings unavailable'); });
const pending = restoreUnplacedSubscriptionAccounts({ ...callbacks, isCurrent: () => current });
if (change === 'move' || change === 'remove') expect(await pending).toBe(false);
else await expect(pending).rejects.toThrow();
expect(h.created).toEqual({});
expect(h.placement).toEqual(change === 'move' ? { [`openai:${id}`]: 'openai' } : {});
});
});
describe('subscription management boundary', () => {
// #9833, unit: new optional model query keeps old caller shape and the
// owner-only boundary. An aggregate/guest reply cannot authorize recovery.

View File

@@ -63,8 +63,7 @@ vi.mock('../placement.js', () => {
&& h.pools[ref.kind]?.accounts.some((a) => a.id === ref.ownAccount)
? ref.ownAccount : undefined;
const place = (kind: string, accountId: string, providerId: string) => {
if (providerId === kind) delete h.placement[`${kind}:${accountId}`];
else h.placement[`${kind}:${accountId}`] = providerId;
h.placement[`${kind}:${accountId}`] = providerId;
};
return {
accountProviderId: owner,
@@ -1828,6 +1827,7 @@ describe('native account assignment on the executing computer', () => {
});
const ids = h.pools[providerId]!.accounts.map((a) => a.id);
expect(ids).toEqual(['default', expect.stringMatching(/^cindy-/)]);
expect(h.placement[`${providerId}:${ids[1]}`]).toBe(providerId);
expect(h.login).toHaveBeenCalledExactlyOnceWith(
providerId,
`${providerId}/${ids[1]}`,
@@ -2371,6 +2371,7 @@ describe('native account assignment on the executing computer', () => {
}),
).rejects.toThrow('login_cancelled');
expect(h.pools.openai?.legacyCodexDefault).toBe(true);
expect(h.placement).toEqual({});
const after = await readSubscriptionPool('openai');
expect(after.accounts.map((a) => a.status)).toEqual(['ready']);
const original = await acquireSubscriptionAccount('openai', undefined, []);
@@ -2385,6 +2386,8 @@ describe('native account assignment on the executing computer', () => {
loginKey: 'retry-second',
});
const addedId = h.pools.openai!.accounts[1].id;
// Explicit additions to the built-in provider must survive the old-pool restoration.
expect(h.placement[`openai:${addedId}`]).toBe('openai');
await runSubscriptionAccountCommand({
action: 'configure',
providerId: 'openai',

View File

@@ -10,6 +10,7 @@
* An account without an entry belongs to its built-in provider (`openai` / `anthropic`), which is
* exactly what every older client assumes. The CLI default account always stays there.
*/
import { createHash } from 'node:crypto';
import { activeOwnerScopeKey, ownerScopedUserDataPath } from '../appSessionState.js';
import { createOverrideSettingsFile } from '../maker-host/override-settings-file.js';
import { desktopMakerLogger } from '../maker-host/logger-adapter.js';
@@ -396,3 +397,76 @@ export async function restoreAutoMergedLegacyCodexAccounts(
}
return true;
}
/**
* Split old wizard/pool additions too (2026-11-14 user correction): an unplaced non-default
* account was pooled before users could choose. Explicit additions/merges have a placement and
* stay where chosen. Legacy Codex aliases are restored by the preceding legacy restoration;
* an alias whose original connection is missing must not become a different provider here.
* Only placement metadata changes; directories, task bindings, pauses and limits stay intact.
*/
export async function restoreUnplacedSubscriptionAccounts(options: {
prepare(kind: SubscriptionProvider, providerId: string): void;
disable(providerId: string): void;
isCurrent?: () => boolean;
}): Promise<boolean> {
if (options.isCurrent?.() === false) return false;
file.invalidateIfChanged();
// Both kinds share the same pool file; this also checks that it is readable before any write.
const aliases = readOpenAiLegacyAccountsIfReadable();
if (!aliases || file.isUnreadable()) return false;
const legacy = new Set(Object.values(aliases));
const placed = file.read().accounts;
const candidates = (['openai', 'anthropic'] as const).flatMap(kind =>
(readPool(kind)?.accounts ?? []).filter(account => account.id !== 'default'
&& !Object.hasOwn(placed, keyOf(kind, account.id))
&& !(kind === 'openai' && legacy.has(account.id))).map(account => ({ kind, account })),
);
// Keep collision reservations and partially prepared settings stable even if the pool order changes.
candidates.sort((a, b) => {
const left = keyOf(a.kind, a.account.id);
const right = keyOf(b.kind, b.account.id);
return left < right ? -1 : left > right ? 1 : 0;
});
if (!candidates.length) return false;
const owner = activeOwnerScopeKey();
let changed = false;
await file.updateAtomic(({ value }) => {
assertOwner(owner);
if (options.isCurrent?.() === false) throw new Error('Subscription accounts changed');
const currentAliases = readOpenAiLegacyAccountsIfReadable();
if (!currentAliases) throw new Error('Subscription accounts are unreadable');
const accounts = { ...value.accounts };
const providers = { ...value.providers };
for (const { kind, account } of candidates) {
const key = keyOf(kind, account.id);
const pool = readPool(kind);
// Recheck inside the write lock: a concurrent move, removal or legacy registration wins.
if (Object.hasOwn(accounts, key) || !pool?.accounts.some(entry => entry.id === account.id)
|| (kind === 'openai' && Object.values(currentAliases).includes(account.id))) continue;
let providerId = Object.entries(providers)
.find(([, entry]) => entry.kind === kind && entry.account === account.id)?.[0];
if (!providerId) {
// Preparing settings writes a separate file before placement commits. Retry the same IDs
// after either write fails, instead of accumulating orphan overrides under random IDs.
let collision = 0;
do {
const suffix = createHash('sha256').update(`${key}:${collision++}`).digest('hex').slice(0, 8);
providerId = `${kind}-sub-${suffix}`;
} while (providers[providerId]);
}
options.prepare(kind, providerId);
// Splitting a disconnected pool must not turn its accounts back on.
if (pool.disconnected) options.disable(providerId);
const brand = kind === 'openai' ? 'OpenAI' : 'Claude';
providers[providerId] ??= { kind, name: account.lastConfirmedIdentity
? `${brand} · ${account.lastConfirmedIdentity}` : brand, account: account.id };
accounts[key] = providerId;
changed = true;
}
assertOwner(owner);
if (options.isCurrent?.() === false) throw new Error('Subscription accounts changed');
return { accounts, providers };
});
return changed;
}

View File

@@ -1979,7 +1979,9 @@ export async function runSubscriptionAccountCommand(
provider, accountId, providerBrandName(provider), () => randomUUID().replaceAll('-', '').slice(0, 8),
);
assertOwner(state);
} else if (command.action === 'add' && owned !== provider) {
} else if (adding && accountId !== 'default') {
// Adding inside a provider is an explicit merge, including into the built-in provider.
// Without this record an upgrade would mistake it for an old automatically pooled account.
await placeSubscriptionAccount(provider, accountId, owned);
assertOwner(state);
}

View File

@@ -147,7 +147,7 @@
| 项 | 桌面 | Host | 后果与归属 |
|---|---|---|---|
| 升级自动合并的旧连接还原(M2,迁移前必须对齐) | 刷新普通供应商配置后、发布订阅名单前,经 `restoreAutoMergedLegacyCodexAccounts` 把 11 月 11 日升级自动并入 OpenAI 的账号还给原连接;这是写操作,由窗口进程完成 | Host 的 `list` 只读,不执行还原。客户端模式下窗口的数据库 `onReady` 在 `hostClientMode` 分支提前返回,不启动包含此刷新步骤的供应商就绪流程;`registerMakerIpcsAfterSplash` 也提前返回,不装配桌面运行时的刷新入口 | 在普通桌面窗口完成还原之前,Host 读到的仍是自动合并后的状态,可选目录按那份状态投影;客户端模式启动本身不会补做这次还原,不能依赖它完成迁移。须在迁移前明确接好还原的执行入口与完成顺序,Host 不另写一份迁移逻辑 |
| 升级自动合并的旧连接还原(M2,迁移前必须对齐) | 刷新普通供应商配置后、发布订阅名单前,经 `restoreAutoMergedLegacyCodexAccounts` 把 11 月 11 日升级自动并入 OpenAI 的账号还给原连接,再经 `restoreUnplacedSubscriptionAccounts` 把旧版直接加入 OpenAI/Anthropic 池、没有明确归属的非默认账号拆成独立供应商(11 月 14 日裁决);这是写操作,由窗口进程完成 | Host 的 `list` 只读,不执行还原。客户端模式下窗口的数据库 `onReady` 在 `hostClientMode` 分支提前返回,不启动包含此刷新步骤的供应商就绪流程;`registerMakerIpcsAfterSplash` 也提前返回,不装配桌面运行时的刷新入口 | 在普通桌面窗口完成还原之前,Host 读到的仍是自动合并后的状态,可选目录按那份状态投影;客户端模式启动本身不会补做这次还原,不能依赖它完成迁移。须在迁移前明确接好还原的执行入口与完成顺序,Host 不另写一份迁移逻辑 |
| 订阅账号放置(main caf1429fc9、a11646d4cb、78efab80b8) | 用户决定创建、合并或拿出账号;发布创建的订阅供应商,按放置归属投影可选目录 | 在 `provider-config.list` 的普通配置读取成功后调用与桌面同一个名单发布函数,读取 Host profile 下当前账号的放置记录;可选目录使用同一份投影、`routingCatalog=false`,不写放置文件。创建、合并、拿出入口仍在窗口;池内发现见前表 | Host 读取放置记录并按同一份投影给出可选目录;连接态、刷新与路由视图未对齐,见以下三行。不能据此开放个人版迁移 |
| 订阅供应商连接态与刷新(M2,迁移前必须对齐) | `subscriptionPoolConnected` 读取内置、创建和旧连接的账号池;连接检查经 `refreshSubscriptionPoolsOfKind` 刷新对应来源 | `publicViews` 没有 `subscriptionPoolConnected` 端口,仍缺少账号池刷新;不以固定 true 代替,也不导入带 Electron 的池运行时 | 创建的订阅供应商虽已进入活动目录,Host 返回的供应商视图仍显示未连接;选择或依赖 connected 的模型准入不能沿用桌面的结果,账号发现与连接状态也不会按桌面时机刷新 |
| 窗口写放置记录后的列表同步(M2,迁移前必须对齐) | 账号命令成功后重新发布名单、刷新可选模型并广播 | 仅在下一次 `list` / `publicViews` / 目录加载的读取边界重读名单;没有跨进程命令完成推送,也未新增轮询 | 客户端窗口创建、改名、合并或拿出后,Host 侧可选列表要等下一次读取才反映新名单;窗口命令完成不代表 Host 列表已经刷新 |

View File

@@ -12,7 +12,8 @@ API 接入、Cindy AI 与本地模型服务。本文定义统一合同;当前
供应商品牌与连接实例分开:同品牌的多个连接使用同一品牌图标,允许不同显示名。
2026-11-07 起,Anthropic / OpenAI 的新订阅账号保存在同一个内置供应商的账号池中,
不再为每次登录创建供应商;旧独立 OpenAI 连接保留。2026-11-13 起改为由用户决定:新登录的账号默认作为单独供应商,
用户可以把账号并入同类供应商或拿出来单独使用(Desktop 已实现,尚未随正式版发布)。账号列表、合并与调度规则见
用户可以把账号并入同类供应商或拿出来单独使用(Desktop 已实现,尚未随正式版发布)。2026-11-14 补充:
旧版未经明确归属选择而留在账号池里的非默认账号也自动拆成独立供应商,不再只恢复旧 Codex 独立连接。账号列表、合并与调度规则见
[供应商内的订阅账号](subscription-account-pools.md)。
改名不改变品牌、模型目录、凭证、限额或调用目标;绑定仍遵守
[多连接的身份与隔离](./model-metadata-precedence.md#多连接的身份与隔离)。

View File

@@ -13,6 +13,8 @@
已归并的旧 Codex 连接、任务跟着账号走、每个供应商只分配和统计自己的账号;添加时选择放在哪里、主动并入/移动/拿出、
任意同类供应商作为合并目标、Cindy 新建的 GPT 与 Claude 单独供应商,以及 Helper 的同等操作。下文标注
「已被 2026-11-13 裁决取代」的条目只作历史说明。未做:真实双账号端到端登录,以及新旧版本两台电脑混用的实机互通。
2026-11-14 用户补充:之前被合在一起的账号都要拆回独立供应商,包含旧版经添加向导或账号区直接加入内置池的账号;
这部分按下文「旧版直接加入账号池的账号也拆开」执行。
**账号归属的存放**:账号属于哪个供应商单独记在 owner 本机的 `subscription-account-placement.json`,不写进
`subscription-accounts.json`——本裁决之前的客户端每次写账号池文件(任务启动写绑定即会写)都会丢掉它不认识的字段,
@@ -51,8 +53,16 @@
回到还原后的供应商;已交接到 OpenAI 其他账号的任务留在 OpenAI。只还原升级时自动归并的账号,用户主动的合并不还原。
降级到旧版时,旧版会按它自己的规则再次自动归并;再升级回来仍会还原,用户的主动选择不丢。还原写入失败时保持原状、
下次加载再试;任何时候一个账号只属于一个供应商。
- **11-07 起经添加向导加入内置供应商的账号保持原样**:它们当时同样没有选择,但现有记录分不出来自添加向导还是账号区的
「添加账号」,因此升级时不拆分,留在内置供应商里,用户需要时自己拿出来。
- **旧版直接加入账号池的账号也拆开(2026-11-14 用户更正)**:此前「保持原样、用户自己拿出」的例外取消。
OpenAI 与 Anthropic 池里没有明确归属记录的非默认账号,不论来自旧添加向导还是账号区的「添加账号」,加载供应商时都自动
拆成各自的单独供应商;默认账号仍留在内置供应商。旧 Codex 独立连接优先恢复原 ID,没有原连接的旧池账号生成新 ID,
同一次原子写入保存新供应商及账号归属,后续加载或重启不重复创建。失败重试仍为同一账号复用同一个新 ID,避免准备好的
模型停用设置在重试时不断留下新的孤立记录。账号目录、官方登录、任务/原生历史绑定、暂停、并发上限与权重原样保留,
模型停用设置继承原供应商;原池已断开时新供应商保持停用,分享与逐供应商远程调用不自动打开。
新版主动并入/移动/添加到指定供应商的账号写明归属(包括内置供应商),不被这次恢复再次拆开。
旧记录无法区分两种添加入口,因此统一按本次裁决拆分;账号池或归属文件读不了、切换 owner 或设置复制失败时不发布未完成结果,
下次加载再试。实现与回归见 `subscription-accounts/placement.ts`、`__tests__/ipc.test.ts` 和
`maker-host/__tests__/providerCatalogRealmReload.test.ts`。
- **Claude 单独供应商**:以前单独添加的 Claude 连接用的是 Cindy 自己保存的登录凭证,已于 2026-09-24 停用(只能查看和删除),
不复活、不并入、不迁移凭证。新的 Claude 单独供应商与账号池账号一样只经官方 CLI 登录,每个账号一个独立的
`CLAUDE_CONFIG_DIR` 目录,Cindy 不读取、不复制 Claude 凭证(见[凭证与本地存储](../dev-rules/credentials-and-local-storage.md))。