fix: invalidate persisted assistant model state

This commit is contained in:
ajnart committed 2026-08-13 19:56:16 +02:00
1 parent 6da471d24a
commit 073d9ce127
2 files changed
+96 -2

No files matched your search

+4 -2
View File
@@ -271,6 +271,8 @@ export const assistantRouter = createTRPCRouter({
const existing = await getConfigurationAsync(ctx.db);
const destinationChanged =
existing !== undefined && (existing.provider !== input.provider || existing.baseUrl !== baseUrl);
const connectionChanged =
existing !== undefined && (destinationChanged || existing.modelDiscoveryPath !== modelDiscoveryPath);
const encryptedApiKey = input.apiKey
? encryptSecret(input.apiKey)
: input.clearApiKey || destinationChanged
@@ -291,8 +293,8 @@ export const assistantRouter = createTRPCRouter({
modelDiscoveryPath,
encryptedApiKey,
encryptedHeaders,
modelId: destinationChanged ? null : existing.modelId,
enabled: destinationChanged ? false : existing.enabled,
modelId: connectionChanged ? null : existing.modelId,
enabled: connectionChanged ? false : existing.enabled,
updatedAt: new Date(),
})
.where(eq(assistantConfigurations.id, configurationId));