diff --git a/src/ai/acp-transport.ts b/src/ai/acp-transport.ts index d85a320a4..aab99f0e3 100644 --- a/src/ai/acp-transport.ts +++ b/src/ai/acp-transport.ts @@ -56,6 +56,24 @@ export function buildCrashChunks( return { chunks, shouldNullSession: true } } +interface AcpDebugEntry { + ts: number + type: string + data: unknown +} + +export const acpDebugLog: AcpDebugEntry[] = [] + +export function getAcpDebugText(): string { + return acpDebugLog.map((e) => + `[${new Date(e.ts).toISOString()}] ${e.type}\n${JSON.stringify(e.data, null, 2)}` + ).join('\n\n---\n\n') +} + +export function clearAcpDebugLog() { + acpDebugLog.length = 0 +} + export class ACPChatTransport implements ChatTransport { private session: ACPSession | null = null private agentDef: ACPAgentDef @@ -114,7 +132,11 @@ export class ACPChatTransport implements ChatTransport { session.onUpdate = (params) => { if (closed) return - console.debug('[ACP update]', params.update.sessionUpdate, params.update) + acpDebugLog.push({ + ts: Date.now(), + type: params.update.sessionUpdate, + data: params.update + }) const result = mapUpdate(params.update, textId, textStarted) for (const chunk of result.chunks) { controller.enqueue(chunk) diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vue index d4c18f472..67eac88f7 100644 --- a/src/components/ChatPanel.vue +++ b/src/components/ChatPanel.vue @@ -2,6 +2,7 @@ import { ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from 'reka-ui' import { computed, markRaw, nextTick, ref, watch } from 'vue' +import { getAcpDebugText, clearAcpDebugLog } from '@/ai/acp-transport' import { copyChatLog } from '@/ai/chat-debug' import { clearToolLogEntries, didHitStepLimit } from '@/ai/tools' import AcpPermissionDialog from '@/components/chat/AcpPermissionDialog.vue' @@ -24,6 +25,7 @@ ensureChat().then((c) => { }) const messagesEnd = ref() const debugCopied = ref(false) +const acpLogCopied = ref(false) const initError = ref(null) const messages = computed(() => chat.value?.messages ?? []) @@ -86,10 +88,19 @@ async function handleCopyDebug() { }, 1500) } +async function handleCopyAcpLog() { + const text = getAcpDebugText() + if (!text) return + await navigator.clipboard.writeText(text) + acpLogCopied.value = true + setTimeout(() => { acpLogCopied.value = false }, 1500) +} + function handleClearChat() { chat.value = null resetChat() clearToolLogEntries() + clearAcpDebugLog() } @@ -170,6 +181,14 @@ function handleClearChat() { {{ debugCopied ? 'Copied' : 'Copy log' }} +