(
chatKey: string,
state: AIChatSessionState,
targetBuffer: AIChatBuffer,
editIndex: number,
originalMessage: ChatMessage,
content: string
)
| 1465 | } |
| 1466 | |
| 1467 | async function editAndOverwriteAll( |
| 1468 | chatKey: string, |
| 1469 | state: AIChatSessionState, |
| 1470 | targetBuffer: AIChatBuffer, |
| 1471 | editIndex: number, |
| 1472 | originalMessage: ChatMessage, |
| 1473 | content: string |
| 1474 | ): Promise<SendMessageResult> { |
| 1475 | try { |
| 1476 | const hasConfig = await useLLMService().hasConfig() |
| 1477 | if (!hasConfig) { |
| 1478 | return { success: false, reason: 'no_config' } |
| 1479 | } |
| 1480 | if (state.isAborted) { |
| 1481 | return { success: false, reason: 'aborted' } |
| 1482 | } |
| 1483 | if (state.isAIThinking || activeTask.value) { |
| 1484 | return { success: false, reason: 'busy', activeTask: activeTask.value } |
| 1485 | } |
| 1486 | |
| 1487 | await useAIService().deleteMessagesFrom(state.currentAIChatId!, originalMessage.id) |
| 1488 | targetBuffer.messages.splice(editIndex, targetBuffer.messages.length - editIndex) |
| 1489 | return sendMessage(chatKey, content) |
| 1490 | } catch (error) { |
| 1491 | console.error('[AI] edit and overwrite failed:', error) |
| 1492 | return { success: false, reason: 'error' } |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | async function editCurrentRoundOnly( |
| 1497 | chatKey: string, |
no test coverage detected