mishig HF Staff commited on
Commit
a3f9d6a
·
verified ·
1 Parent(s): d3f8ba8

Tail-follow scroll in source

Browse files
Files changed (1) hide show
  1. src/lib/TraceViewer.svelte +17 -1
src/lib/TraceViewer.svelte CHANGED
@@ -93,17 +93,20 @@
93
  msg._visible = true;
94
  focusedIdx = mi;
95
  await tick();
96
- scrollToFocused('smooth');
97
  await wait(40);
98
 
99
  for (let bi = 0; bi < msg.blocks.length; bi++) {
100
  if (skipFlag) break;
101
  msg._visibleBlocks = bi + 1;
 
 
102
  const block = msg.blocks[bi];
103
  if (block.kind === 'text' || block.kind === 'thinking') {
104
  await typeBlock(block);
105
  } else {
106
  await wait(90);
 
107
  }
108
  }
109
  if (skipFlag) break;
@@ -128,9 +131,22 @@
128
  if (skipFlag) break;
129
  block._typedText = full.slice(0, c);
130
  await wait(tickMs);
 
131
  }
132
  block._typedText = full;
133
  block._typing = false;
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
136
  function revealAll() {
 
93
  msg._visible = true;
94
  focusedIdx = mi;
95
  await tick();
96
+ followTail();
97
  await wait(40);
98
 
99
  for (let bi = 0; bi < msg.blocks.length; bi++) {
100
  if (skipFlag) break;
101
  msg._visibleBlocks = bi + 1;
102
+ await tick();
103
+ followTail();
104
  const block = msg.blocks[bi];
105
  if (block.kind === 'text' || block.kind === 'thinking') {
106
  await typeBlock(block);
107
  } else {
108
  await wait(90);
109
+ followTail();
110
  }
111
  }
112
  if (skipFlag) break;
 
131
  if (skipFlag) break;
132
  block._typedText = full.slice(0, c);
133
  await wait(tickMs);
134
+ followTail();
135
  }
136
  block._typedText = full;
137
  block._typing = false;
138
+ followTail();
139
+ }
140
+
141
+ // Terminal-style tail: while content is streaming, keep the bottom of the
142
+ // scroll container pinned — but only if the user hasn't scrolled away.
143
+ function followTail() {
144
+ if (!listEl) return;
145
+ const distanceFromBottom =
146
+ listEl.scrollHeight - listEl.scrollTop - listEl.clientHeight;
147
+ if (distanceFromBottom < 240) {
148
+ listEl.scrollTop = listEl.scrollHeight;
149
+ }
150
  }
151
 
152
  function revealAll() {