Compare commits

...
Author SHA1 Message Date
Thomas Camlong 28a1e8421d fix: handle missing message in assistant generation telemetry
getGenerationTelemetry threw NOT_FOUND when the stored message id did
not match a persisted message (e.g. the assistant message is still
streaming or was just removed), surfacing as a failed tRPC query in the
console. Return an empty complete result instead, matching the existing
graceful handling for providers without OpenRouter telemetry, and only
fire the client query once both threadId and messageId are available.
2026-08-07 14:59:16 +02:00
2 changed files with 2 additions and 2 deletions

No files matched your search

@@ -930,7 +930,7 @@ const RequestTelemetry = () => {
const generationQuery = clientApi.assistant.getGenerationTelemetry.useQuery(
{ threadId: threadId ?? "", messageId },
{
enabled: opened && persistedTelemetry?.provider === "openrouter" && Boolean(threadId),
enabled: opened && persistedTelemetry?.provider === "openrouter" && Boolean(threadId) && Boolean(messageId),
refetchInterval: (query) =>
query.state.data?.complete === false && query.state.dataUpdateCount < 6 ? 1500 : false,
retry: 2,
+1 -1
View File
@@ -738,7 +738,7 @@ export const assistantRouter = createTRPCRouter({
}),
getConfigurationAsync(ctx.db),
]);
if (!message) throw new TRPCError({ code: "NOT_FOUND", message: "Message not found." });
if (!message) return { complete: true, generations: [] };
if (configuration?.provider !== "openrouter" || !configuration.encryptedApiKey) {
return { complete: true, generations: [] };
}