From df46b91fc88a9407177802f537d06a7ecb9570f8 Mon Sep 17 00:00:00 2001 From: Variet Date: Sun, 8 Mar 2026 01:08:01 +0900 Subject: [PATCH] =?UTF-8?q?fix(history):=20hybrid=20data=20=E2=80=94=20tra?= =?UTF-8?q?jectory(truncated)=20+=20cascades(latest)=20for=20complete=20co?= =?UTF-8?q?nversation=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 67 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index e4e3a1f..93d2816 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -149,17 +149,66 @@ async function refreshTrajectory(sessionId, scrollToBottom = true) { try { - const res = await fetch(`/api/bridge/trajectory/${sessionId}`); - if (!res.ok) return; - const data = await res.json(); - if (data.trajectory?.steps) { - const messages = parseTrajectoryToMessages(data.trajectory.steps); - chatPanel.updateChat(messages); - if (scrollToBottom) { - const el = document.getElementById('chatMessages'); - if (el) setTimeout(() => el.scrollTop = el.scrollHeight, 50); + // 1) trajectory (앞부분 ~336개) + // 2) cascades (최신 상태: latestNotifyUserStep + latestTaskBoundaryStep) + const [trajRes, cascRes] = await Promise.all([ + fetch(`/api/bridge/trajectory/${sessionId}`), + fetch('/api/bridge/cascades'), + ]); + + let messages = []; + + // trajectory 파싱 + if (trajRes.ok) { + const trajData = await trajRes.json(); + if (trajData.trajectory?.steps) { + messages = parseTrajectoryToMessages(trajData.trajectory.steps); + + // trajectory가 전체가 아닌 경우 (numTotalSteps > steps.length) + const total = trajData.numTotalSteps || 0; + const got = trajData.trajectory.steps.length; + if (total > got) { + messages.push({ + type: 'status', + text: `⋯ ${total - got}개 스텝 생략 ⋯`, + }); + } } } + + // cascades에서 최신 상태 보강 + if (cascRes.ok) { + const cascData = await cascRes.json(); + const cascade = (cascData.cascades || cascData)[sessionId]; + if (cascade) { + // latestTaskBoundaryStep → 현재 작업 상태 + if (cascade.latestTaskBoundaryStep?.step?.taskBoundary) { + const tb = cascade.latestTaskBoundaryStep.step.taskBoundary; + messages.push({ + type: 'task', + title: tb.taskName || '', + summary: tb.taskSummary || '', + status: tb.taskStatus || '', + mode: tb.mode || '', + tools: [], + }); + } + // latestNotifyUserStep → 마지막 AI 응답 + if (cascade.latestNotifyUserStep?.step?.notifyUser?.notificationContent) { + const content = cascade.latestNotifyUserStep.step.notifyUser.notificationContent; + messages.push({ + type: 'text', + html: simpleMarkdown(content), + }); + } + } + } + + chatPanel.updateChat(messages); + if (scrollToBottom) { + const el = document.getElementById('chatMessages'); + if (el) setTimeout(() => el.scrollTop = el.scrollHeight, 100); + } } catch (e) { console.warn('[Bridge] trajectory 로드 실패:', e); }