fix(history): hybrid data — trajectory(truncated) + cascades(latest) for complete conversation view
This commit is contained in:
@@ -149,16 +149,65 @@
|
|||||||
|
|
||||||
async function refreshTrajectory(sessionId, scrollToBottom = true) {
|
async function refreshTrajectory(sessionId, scrollToBottom = true) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/bridge/trajectory/${sessionId}`);
|
// 1) trajectory (앞부분 ~336개)
|
||||||
if (!res.ok) return;
|
// 2) cascades (최신 상태: latestNotifyUserStep + latestTaskBoundaryStep)
|
||||||
const data = await res.json();
|
const [trajRes, cascRes] = await Promise.all([
|
||||||
if (data.trajectory?.steps) {
|
fetch(`/api/bridge/trajectory/${sessionId}`),
|
||||||
const messages = parseTrajectoryToMessages(data.trajectory.steps);
|
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);
|
chatPanel.updateChat(messages);
|
||||||
if (scrollToBottom) {
|
if (scrollToBottom) {
|
||||||
const el = document.getElementById('chatMessages');
|
const el = document.getElementById('chatMessages');
|
||||||
if (el) setTimeout(() => el.scrollTop = el.scrollHeight, 50);
|
if (el) setTimeout(() => el.scrollTop = el.scrollHeight, 100);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[Bridge] trajectory 로드 실패:', e);
|
console.warn('[Bridge] trajectory 로드 실패:', e);
|
||||||
|
|||||||
Reference in New Issue
Block a user