Skip to content

Commit 1872b29

Browse files
committed
debug mode progress
1 parent c4180cd commit 1872b29

9 files changed

Lines changed: 516 additions & 21 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# bun specific
1010
bun-debug.log*
1111

12+
# cursor debug logs
13+
.cursor/debug-*.log
14+
1215
# this repo uses bun.lock; package-lock.json files are accidental
1316
package-lock.json
1417

@@ -44,6 +47,11 @@ dump.rdb
4447
.env.test
4548
.env.production
4649

50+
# editor swap files
51+
*.swp
52+
*.swo
53+
*.swn
54+
4755
# vercel
4856
.vercel
4957

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,100 @@ const MarkdownPreview = memo(function MarkdownPreview({
913913
revealedContent
914914
)
915915

916+
// #region agent log
917+
const mpUidRef = useRef(Math.random().toString(36).slice(2, 8))
918+
const revealedAtMountRef = useRef(revealedContent.length)
919+
useEffect(() => {
920+
const uid = mpUidRef.current
921+
const scroller = spacerRef.current?.parentElement ?? null
922+
if (!scroller || !isStreaming || content.length <= 60) return
923+
// Frame 2 after a resume mount: does the freshly mounted DOM have running CSS
924+
// animations? If so the visible "animate the whole file" is the markdown
925+
// (re)entering with a fade on every remount, independent of Streamdown props.
926+
let f = 0
927+
let raf = 0
928+
const tick = () => {
929+
if (f >= 2) {
930+
const el = scroller as Element & {
931+
getAnimations?: (o?: { subtree?: boolean }) => Animation[]
932+
}
933+
const anims = el.getAnimations ? el.getAnimations({ subtree: true }) : []
934+
const running = anims.filter((a) => a.playState === 'running')
935+
const names = running.slice(0, 6).map((a) => {
936+
const eff = a.effect as KeyframeEffect | null
937+
const target = eff?.target as Element | null
938+
const nm =
939+
(a as unknown as { animationName?: string; transitionProperty?: string })
940+
.animationName ??
941+
(a as unknown as { transitionProperty?: string }).transitionProperty ??
942+
a.constructor.name
943+
return `${nm}@${target?.tagName ?? '?'}`
944+
})
945+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
946+
method: 'POST',
947+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
948+
body: JSON.stringify({
949+
sessionId: '3dc406',
950+
hypothesisId: 'F3',
951+
location: 'preview-panel.tsx:MarkdownPreview:anim-probe',
952+
message: 'CSS animations on resume mount (running>0 = re-animate is mount fade)',
953+
data: {
954+
uid,
955+
contentLen: content.length,
956+
scrollTop: Math.round(scroller.scrollTop),
957+
scrollHeight: Math.round(scroller.scrollHeight),
958+
clientHeight: Math.round(scroller.clientHeight),
959+
animTotal: anims.length,
960+
animRunning: running.length,
961+
names,
962+
},
963+
timestamp: Date.now(),
964+
}),
965+
}).catch(() => {})
966+
return
967+
}
968+
f++
969+
raf = requestAnimationFrame(tick)
970+
}
971+
raf = requestAnimationFrame(tick)
972+
return () => cancelAnimationFrame(raf)
973+
}, [])
974+
// #endregion
975+
976+
// #region agent log
977+
// Render-time: catch the reveal jumping BACKWARD (re-reveal "from the
978+
// beginning") or the content prop resetting, the only remaining way the file
979+
// could appear to re-animate without a CSS animation/scroll.
980+
const prevRevealedLenRef = useRef(revealedContent.length)
981+
const prevContentLenRef = useRef(content.length)
982+
if (
983+
revealedContent.length < prevRevealedLenRef.current - 40 ||
984+
content.length < prevContentLenRef.current - 40
985+
) {
986+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
987+
method: 'POST',
988+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
989+
body: JSON.stringify({
990+
sessionId: '3dc406',
991+
hypothesisId: 'F6',
992+
location: 'preview-panel.tsx:reveal-drop',
993+
message: 'reveal/content dropped backward (re-reveal from beginning)',
994+
data: {
995+
uid: mpUidRef.current,
996+
revealedFrom: prevRevealedLenRef.current,
997+
revealedTo: revealedContent.length,
998+
contentFrom: prevContentLenRef.current,
999+
contentTo: content.length,
1000+
isStreaming,
1001+
},
1002+
timestamp: Date.now(),
1003+
}),
1004+
}).catch(() => {})
1005+
}
1006+
prevRevealedLenRef.current = revealedContent.length
1007+
prevContentLenRef.current = content.length
1008+
// #endregion
1009+
9161010
const contentRef = useRef(content)
9171011
contentRef.current = content
9181012

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/agent-group.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,38 @@ export function AgentGroup({
5858
defaultExpanded = false,
5959
}: AgentGroupProps) {
6060
const AgentIcon = getAgentIcon(agentName)
61+
// #region agent log
62+
useEffect(() => {
63+
if (!isStreaming) return
64+
const uid = Math.random().toString(36).slice(2, 8)
65+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
66+
method: 'POST',
67+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
68+
body: JSON.stringify({
69+
sessionId: '3dc406',
70+
hypothesisId: 'A12',
71+
location: 'agent-group.tsx:mount',
72+
message: 'AgentGroup MOUNT (parallel subagent flash)',
73+
data: { uid, agentName },
74+
timestamp: Date.now(),
75+
}),
76+
}).catch(() => {})
77+
return () => {
78+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
79+
method: 'POST',
80+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
81+
body: JSON.stringify({
82+
sessionId: '3dc406',
83+
hypothesisId: 'A12',
84+
location: 'agent-group.tsx:unmount',
85+
message: 'AgentGroup UNMOUNT',
86+
data: { uid, agentName },
87+
timestamp: Date.now(),
88+
}),
89+
}).catch(() => {})
90+
}
91+
}, [])
92+
// #endregion
6193
const hasItems = items.length > 0
6294
const resolved = isAgentGroupResolved(items)
6395
// Pure projection of the run's own state: a subagent header spins while it is

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,39 @@ function ChatContentInner({
299299
const streamedContent = useSmoothText(displayContent, isStreaming)
300300
const isRevealing = isStreaming || streamedContent.length < displayContent.length
301301

302+
// #region agent log
303+
useEffect(() => {
304+
if (!isStreaming) return
305+
const uid = Math.random().toString(36).slice(2, 8)
306+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
307+
method: 'POST',
308+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
309+
body: JSON.stringify({
310+
sessionId: '3dc406',
311+
hypothesisId: 'A5',
312+
location: 'chat-content.tsx:mount',
313+
message: 'streaming ChatContent MOUNT (reveal resets to 0 here)',
314+
data: { uid, initialLen: displayContent.length },
315+
timestamp: Date.now(),
316+
}),
317+
}).catch(() => {})
318+
return () => {
319+
fetch('http://127.0.0.1:1025/ingest/85045d0a-92f7-4ee2-9de1-e2f99930c6bc', {
320+
method: 'POST',
321+
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '3dc406' },
322+
body: JSON.stringify({
323+
sessionId: '3dc406',
324+
hypothesisId: 'A5',
325+
location: 'chat-content.tsx:unmount',
326+
message: 'streaming ChatContent UNMOUNT',
327+
data: { uid },
328+
timestamp: Date.now(),
329+
}),
330+
}).catch(() => {})
331+
}
332+
}, [])
333+
// #endregion
334+
302335
useEffect(() => {
303336
onRevealStateChangeRef.current?.(isRevealing)
304337
}, [isRevealing])

0 commit comments

Comments
 (0)