MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / editAndOverwriteAll

Function editAndOverwriteAll

src/stores/aiChat.ts:1467–1494  ·  view source on GitHub ↗
(
    chatKey: string,
    state: AIChatSessionState,
    targetBuffer: AIChatBuffer,
    editIndex: number,
    originalMessage: ChatMessage,
    content: string
  )

Source from the content-addressed store, hash-verified

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,

Callers 1

editMessageAndRegenerateFunction · 0.85

Calls 6

useLLMServiceFunction · 0.90
useAIServiceFunction · 0.90
sendMessageFunction · 0.85
hasConfigMethod · 0.65
deleteMessagesFromMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected