fix: isolate concurrent OpenCode chat runs

This commit is contained in:
brother7 committed 2026-08-17 22:03:37 +08:00
1 parent 7e8d9e3811
commit 65040730ec
29 files changed
+5207 -427

No files matched your search

+12 -3
View File
@@ -38,9 +38,13 @@ interface ProviderState {
refreshProviderSnapshot: () => Promise<void>;
createAccount: (account: ProviderAccount, apiKey?: string) => Promise<void>;
removeAccount: (accountId: string) => Promise<void>;
importUserModelConfig: (accessToken: string) => Promise<{
importUserModelConfig: (
accessToken: string,
options?: { runtimeRefresh?: 'apply' | 'defer' },
) => Promise<{
account: ProviderAccount;
importedModels: string[];
runtimeRefreshRequired: boolean;
}>;
validateAccountApiKey: (
accountId: string,
@@ -218,16 +222,20 @@ export const useProviderStore = create<ProviderState>((set, get) => ({
deleteAccount: async (accountId) => get().removeAccount(accountId),
importUserModelConfig: async (accessToken) => {
importUserModelConfig: async (accessToken, options) => {
try {
const result = await hostApiFetch<{
success: boolean;
error?: string;
account?: ProviderAccount;
importedModels?: string[];
runtimeRefreshRequired?: boolean;
}>('/api/provider-accounts/import-user-model-config', {
method: 'POST',
body: JSON.stringify({ accessToken }),
body: JSON.stringify({
accessToken,
runtimeRefresh: options?.runtimeRefresh ?? 'apply',
}),
});
if (!result.success || !result.account) {
@@ -238,6 +246,7 @@ export const useProviderStore = create<ProviderState>((set, get) => ({
return {
account: result.account,
importedModels: result.importedModels ?? [],
runtimeRefreshRequired: result.runtimeRefreshRequired === true,
};
} catch (error) {
console.error('Failed to import current user model config:', error);