diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vue index 7a7f64503c..e5c60b928d 100644 --- a/apps/desktop/src/components/editor/AiAssistant.vue +++ b/apps/desktop/src/components/editor/AiAssistant.vue @@ -178,7 +178,7 @@ import { DBX_TABLE_REFERENCE_DROP_EVENT, clearActiveTableReferencePayload } from import { canSubmitAiPrompt, isAiPromptImeCompositionEvent, shouldSubmitAiPromptOnKeydown } from "@/lib/ai/aiPromptKeyboard"; import { isActionableWriteProposalMessage, isActionableWriteSqlProposal, looksLikeActionProposal, looksLikeWriteSqlProposal, shouldGrantWriteSqlOnShortAffirmative } from "@/lib/ai/aiProposalDetect"; import { classifyIntentByLlm, routeIntentByRules, type AiIntentRouteInput } from "@/lib/ai/aiIntentRouter"; -import { visibleToActualIndex } from "@/lib/ai/aiMessageEdit"; +import { retryableUserMessageIndex, visibleToActualIndex } from "@/lib/ai/aiMessageEdit"; import { shouldShowReasoningCharCount, reasoningCharCountClass } from "@/lib/ai/aiReasoningPresentation"; import { saveTextFile } from "@/lib/export/saveTextFile"; import { buildAiAnalysisExport } from "@/lib/export/aiAnalysisExport"; @@ -4285,6 +4285,37 @@ function canCopyMessage(msg: ChatMessage): boolean { return messageCopyText(msg) !== null; } +/** Returns whether a user message can be submitted again. The helper accepts + * the following visible index so the same eligibility rules cover text, + * mentions, and attachment-only requests. */ +function canRetryUserMessage(visibleIndex: number): boolean { + return retryableUserMessageIndex(visibleMessages.value, visibleIndex + 1) === visibleIndex; +} + +/** Re-runs a user request through the existing edit-and-resend path. This + * removes the selected turn and later replies before sending with the current + * AI configuration. */ +function retryUserMessage(visibleIndex: number) { + if (isGenerating.value) return; + if (!canRetryUserMessage(visibleIndex)) return; + startEditMessage(visibleIndex); + submitEdit(visibleIndex); +} + +const retryConfirmMessageIndex = ref(null); + +function cancelRetryUserMessage() { + retryConfirmMessageIndex.value = null; +} + +function confirmRetryUserMessage() { + const visibleIndex = retryConfirmMessageIndex.value; + retryConfirmMessageIndex.value = null; + if (visibleIndex !== null) retryUserMessage(visibleIndex); +} + +watch(conversationId, cancelRetryUserMessage); + function messageCopyKey(index: number): string { return `message:${index}`; } @@ -5620,8 +5651,26 @@ async function openExternalUrl(url: string) { {{ t("ai.routing.chip", { action: actionLabelFor(routedActionOf(msg)) }) }} -
+
+ + + + + +

+ + {{ t("ai.retryConfirmDescription") }} +

+
+ + +
+
+