@adecore/agents-react 0.40.3 → 0.40.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -398,7 +398,8 @@ export class ChatClient {
398
398
  const page = result.history === undefined ? undefined : {
399
399
  history: result.history,
400
400
  pending: result.pending ?? [],
401
- subagents: result.subagents ?? []
401
+ subagents: result.subagents ?? [],
402
+ outline: result.outline ?? []
402
403
  };
403
404
  this.sink.reset(chatId, result.info, result.items, page);
404
405
  }
@@ -1,5 +1,5 @@
1
- import type { ChatBookmark } from '@adecore/agent-contracts';
2
- import type { TimelineRow } from './timeline.js';
1
+ import type { ChatBookmark, ChatItem } from '@adecore/agent-contracts';
2
+ import { type TimelineRow } from './timeline.js';
3
3
  export type TickKind = 'person' | 'wake' | 'bookmark';
4
4
  export interface ScrubberTick {
5
5
  id: string;
@@ -15,7 +15,8 @@ export declare const TICK_HEIGHT_PX = 2;
15
15
  export declare const STRIP_WIDTH_PX = 24;
16
16
  export declare const STRIP_INSET_PX = 8;
17
17
  export declare const STRIP_CLEARANCE_PX: number;
18
- export declare function ticksOf(rows: readonly TimelineRow[], marks?: ReadonlyMap<string, ChatBookmark>): ScrubberTick[];
18
+ export declare const EARLIER_ROW = -1;
19
+ export declare function ticksOf(rows: readonly TimelineRow[], marks?: ReadonlyMap<string, ChatBookmark>, earlier?: readonly ChatItem[], bookmarks?: readonly ChatBookmark[]): ScrubberTick[];
19
20
  export interface TickSlot {
20
21
  first: number;
21
22
  last: number;
@@ -1,3 +1,4 @@
1
+ import { agentTurnLabel } from './timeline.js';
1
2
  import { DEFAULT_READING_WIDTH, readingMeasure } from '../reading-width.js';
2
3
  /* With fewer messages than this the thread is short enough to scroll through, and the strip is noise. */
3
4
  export const SCRUBBER_MIN_TICKS = 3;
@@ -15,9 +16,56 @@ const WIDTH_NEAR_PERSON_PX = 12;
15
16
  const WIDTH_NEAR_WAKE_PX = 8;
16
17
  const WIDTH_PERSON_PX = 8;
17
18
  const WIDTH_WAKE_PX = 5;
18
- /* `marks` is what `bookmarkRows` answers: the bookmark drawn at a row, by row id. */
19
- export function ticksOf(rows, marks = new Map()) {
20
- return rows.flatMap((row, rowIndex) => {
19
+ /* Below every row, so a tick before the rows this client holds sorts first and its stretch reaches the first row of the thread. */
20
+ export const EARLIER_ROW = -1;
21
+ /* A message before the rows this client holds, as the outline (`outlineItems`) has it; its row id is the one the thread will draw it with. */
22
+ function earlierTick(item, bookmarks) {
23
+ const bookmark = bookmarks.get(item.id) ?? null;
24
+ const rowIndex = EARLIER_ROW;
25
+ if (item.kind === 'user') {
26
+ const text = item.text !== '' ? item.text : (item.attachments ?? []).map(attachment => attachment.name).join(', ');
27
+ return {
28
+ id: item.id,
29
+ rowIndex,
30
+ kind: 'person',
31
+ text,
32
+ createdAt: item.createdAt,
33
+ turnId: item.turnId,
34
+ bookmark
35
+ };
36
+ }
37
+ if (item.kind === 'turn' && ((item.taskIds?.length ?? 0) > 0 || (item.messageFrom?.length ?? 0) > 0)) {
38
+ return {
39
+ id: `start-${item.id}`,
40
+ rowIndex,
41
+ kind: 'wake',
42
+ text: agentTurnLabel(item),
43
+ createdAt: item.createdAt,
44
+ turnId: item.id,
45
+ bookmark: null
46
+ };
47
+ }
48
+ if (item.kind === 'assistant' && bookmark !== null) {
49
+ return {
50
+ id: item.id,
51
+ rowIndex,
52
+ kind: 'bookmark',
53
+ text: item.text,
54
+ createdAt: item.createdAt,
55
+ turnId: item.turnId,
56
+ bookmark
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ /*
62
+ * `marks` is what `bookmarkRows` answers: the bookmark drawn at a row, by row id. `earlier` is the
63
+ * outline of the thread before `rows`, and `bookmarks` the chat's, which mark the ticks of that part.
64
+ */
65
+ export function ticksOf(rows, marks = new Map(), earlier = [], bookmarks = []) {
66
+ const byItem = new Map(bookmarks.map(bookmark => [bookmark.itemId, bookmark]));
67
+ const before = earlier.flatMap(item => earlierTick(item, byItem) ?? []);
68
+ const held = rows.flatMap((row, rowIndex) => {
21
69
  const bookmark = marks.get(row.id) ?? null;
22
70
  if (row.kind === 'user') {
23
71
  // A message of only attachments still has a place in the thread; its names stand in for the text.
@@ -70,6 +118,7 @@ export function ticksOf(rows, marks = new Map()) {
70
118
  bookmark
71
119
  }];
72
120
  });
121
+ return before.length === 0 ? held : [...before, ...held];
73
122
  }
74
123
  /* `marked` and `found` say per message whether it has a bookmark and whether a find hit falls under it; absent, none has. */
75
124
  export function layoutTicks(kinds, height, marked = [], found = []) {
@@ -13,7 +13,7 @@ import { registerItemJumper, registerMessageStepper, registerTimeline, registerT
13
13
  import { useTimelineFlash } from '../timeline-flash.js';
14
14
  import { useChatPreferences } from '../preferences.js';
15
15
  import { readingMeasure, readingWidthStyle } from '../reading-width.js';
16
- import { SCRUBBER_MIN_TICKS, STRIP_INSET_PX, STRIP_WIDTH_PX, messagesInView, stepMessage, threadPaddingLeft, STRIP_CLEARANCE_PX, tickOfRow, ticksOf, ticksWithHits } from '../logic/scrubber.js';
16
+ import { SCRUBBER_MIN_TICKS, STRIP_INSET_PX, STRIP_WIDTH_PX, messagesInView, stepMessage, threadPaddingLeft, STRIP_CLEARANCE_PX, tickOfRow, ticksOf, ticksWithHits, EARLIER_ROW } from '../logic/scrubber.js';
17
17
  import { EMPTY_TARGET, readTimelineTarget, revealUiReplyBlock, uiReplyJump, withCurrentText } from '../logic/timeline-target.js';
18
18
  import { forkRefusal } from '../logic/fork.js';
19
19
  import { UiReplyNavigationContext } from './reply-context.js';
@@ -410,11 +410,12 @@ export function Timeline({
410
410
  const items = useChatRow(chatId, row_0 => row_0?.structure);
411
411
  const activeTurnId = useChatRow(chatId, row_1 => row_1?.info.activeTurnId ?? null);
412
412
  const bookmarks = useChatRow(chatId, row_2 => row_2?.bookmarks);
413
- const visuals = useChatRow(chatId, row_3 => row_3?.visuals);
413
+ const outlineBefore = useChatRow(chatId, row_3 => row_3?.outlineBefore);
414
+ const visuals = useChatRow(chatId, row_4 => row_4?.visuals);
414
415
  const forkedTurns = useForkedTurns(chatId);
415
- const info = useChatRow(chatId, row_4 => row_4?.info ?? null);
416
- const historyPending = useChatRow(chatId, row_5 => row_5?.historyPending === true);
417
- const cursor = useChatRow(chatId, row_6 => row_6?.history?.cursor ?? null);
416
+ const info = useChatRow(chatId, row_5 => row_5?.info ?? null);
417
+ const historyPending = useChatRow(chatId, row_6 => row_6?.historyPending === true);
418
+ const cursor = useChatRow(chatId, row_7 => row_7?.history?.cursor ?? null);
418
419
  const scope = useChatScope();
419
420
  const {
420
421
  id: scopeId,
@@ -499,7 +500,7 @@ export function Timeline({
499
500
  // A chat that took a turn before is one whose thread has not come in yet, not one to greet.
500
501
  const welcome = !loadingHistory && welcomes && empty && (info === null || info.usage.turns === 0 && info.activeTurnId === null);
501
502
  const marks = useMemo(() => bookmarkRows(rows, bookmarks ?? [], items ?? {}), [rows, bookmarks, items]);
502
- const ticks = useMemo(() => ticksOf(rows, marks), [rows, marks]);
503
+ const ticks = useMemo(() => ticksOf(rows, marks, outlineBefore, bookmarks), [rows, marks, outlineBefore, bookmarks]);
503
504
  // A message a jump is on its way to; it may first have to open the turn its reply folded into.
504
505
  const [seeking, setSeeking] = useState(null);
505
506
  const [landing, setLanding] = useState(null);
@@ -601,7 +602,7 @@ export function Timeline({
601
602
  }
602
603
  // Ref measurements can change offsets after render. Commit those offsets before the first paint.
603
604
  const measured = virtualizer.getVirtualItems();
604
- if (virtualRows.length !== measured.length || virtualRows.some((row_7, index_1) => row_7.key !== measured[index_1]?.key || row_7.start !== measured[index_1]?.start || row_7.size !== measured[index_1]?.size)) {
605
+ if (virtualRows.length !== measured.length || virtualRows.some((row_8, index_1) => row_8.key !== measured[index_1]?.key || row_8.start !== measured[index_1]?.start || row_8.size !== measured[index_1]?.size)) {
605
606
  settleLayout();
606
607
  return;
607
608
  }
@@ -640,16 +641,16 @@ export function Timeline({
640
641
  return;
641
642
  }
642
643
  const anchor = anchorRef.current;
643
- const index_2 = moved && anchor !== null && !followRef.current ? rows.findIndex(row_8 => row_8.id === anchor.id) : -1;
644
+ const index_2 = moved && anchor !== null && !followRef.current ? rows.findIndex(row_9 => row_9.id === anchor.id) : -1;
644
645
  if (anchor !== null && index_2 !== -1) {
645
646
  virtualizer.getTotalSize();
646
647
  element_3.scrollTop = virtualizer.measurementsCache[index_2].start - anchor.offset;
647
648
  return;
648
649
  }
649
- const row_9 = virtualizer.getVirtualItemForOffset(element_3.scrollTop);
650
- anchorRef.current = row_9 === undefined ? null : {
651
- id: String(row_9.key),
652
- offset: row_9.start - element_3.scrollTop
650
+ const row_10 = virtualizer.getVirtualItemForOffset(element_3.scrollTop);
651
+ anchorRef.current = row_10 === undefined ? null : {
652
+ id: String(row_10.key),
653
+ offset: row_10.start - element_3.scrollTop
653
654
  };
654
655
  });
655
656
  // Close to the top, the page before goes in; again after each page that left too little above the reader.
@@ -759,10 +760,11 @@ export function Timeline({
759
760
  if (!tick_0) {
760
761
  return;
761
762
  }
762
- if (tick_0.bookmark !== null) {
763
+ // A message before the rows this client holds comes in page by page until its row is there.
764
+ if (tick_0.bookmark !== null || tick_0.rowIndex === EARLIER_ROW) {
763
765
  setLanding(null);
764
766
  setSeeking({
765
- itemId: tick_0.bookmark.itemId,
767
+ itemId: tick_0.bookmark?.itemId ?? tick_0.id,
766
768
  key: keyOf(chatId)
767
769
  });
768
770
  return;
@@ -798,7 +800,7 @@ export function Timeline({
798
800
  }
799
801
  return;
800
802
  }
801
- const index_6 = rows.findIndex(row_10 => row_10.id === seeking.itemId);
803
+ const index_6 = rows.findIndex(row_11 => row_11.id === seeking.itemId);
802
804
  if (index_6 !== -1) {
803
805
  setSeeking(null);
804
806
  showRowAtTop(virtualizer, followRef, index_6);
@@ -872,9 +874,9 @@ export function Timeline({
872
874
  turnId: turnId_0,
873
875
  target: target_0
874
876
  } = revealing;
875
- const changes = target_0 === 'changes' ? rows.findIndex(row_11 => row_11.kind === 'changed-files' && row_11.turnId === turnId_0) : -1;
877
+ const changes = target_0 === 'changes' ? rows.findIndex(row_12 => row_12.kind === 'changed-files' && row_12.turnId === turnId_0) : -1;
876
878
  const opening = order?.map(id_0 => items?.[id_0]).find(item_0 => item_0?.kind === 'user' && item_0.turnId === turnId_0);
877
- const found_0 = changes !== -1 ? changes : rows.findIndex(row_12 => row_12.id === opening?.id || row_12.id === `start-${turnId_0}` || row_12.id === `fold-${turnId_0}`);
879
+ const found_0 = changes !== -1 ? changes : rows.findIndex(row_13 => row_13.id === opening?.id || row_13.id === `start-${turnId_0}` || row_13.id === `fold-${turnId_0}`);
878
880
  if (found_0 !== -1) {
879
881
  setRevealing(null);
880
882
  showRowAtTop(virtualizer, followRef, found_0);
@@ -903,8 +905,8 @@ export function Timeline({
903
905
  if (fork === null) {
904
906
  return false;
905
907
  }
906
- const row_13 = useChats.getState().byKey[keyOf(chatId)];
907
- return forkRefusal(row_13?.info ?? null, row_13?.structure[turnId_2]) === null;
908
+ const row_14 = useChats.getState().byKey[keyOf(chatId)];
909
+ return forkRefusal(row_14?.info ?? null, row_14?.structure[turnId_2]) === null;
908
910
  },
909
911
  fork: turnId_3 => fork?.(chatId, turnId_3)
910
912
  }), [keyOf, chatId, fork]);
@@ -1028,22 +1030,22 @@ export function Timeline({
1028
1030
  children: /*#__PURE__*/_jsx(FindRevealContext.Provider, {
1029
1031
  value: chatFind.reveal,
1030
1032
  children: virtualRows.map(virtualRow_1 => {
1031
- const row_14 = rows[virtualRow_1.index];
1033
+ const row_15 = rows[virtualRow_1.index];
1032
1034
  return /*#__PURE__*/_jsx(ThreadRow, {
1033
- row: row_14,
1035
+ row: row_15,
1034
1036
  previous: virtualRow_1.index > 0 ? rows[virtualRow_1.index - 1] : null,
1035
1037
  index: virtualRow_1.index,
1036
1038
  top: virtualRow_1.start,
1037
1039
  measure: virtualizer.measureElement,
1038
1040
  chatId: chatId,
1039
- flashNonce: flash !== null && flashedRow === row_14.id ? flash.nonce : null,
1040
- bookmark: marks.get(row_14.id) ?? null,
1041
+ flashNonce: flash !== null && flashedRow === row_15.id ? flash.nonce : null,
1042
+ bookmark: marks.get(row_15.id) ?? null,
1041
1043
  toggleGroup: groups.toggle,
1042
1044
  toggleTurn: turns.toggle,
1043
1045
  toggleSubagent: subagents.toggle,
1044
1046
  openSubagent: openSubagent,
1045
1047
  openConversation: openConversation
1046
- }, row_14.id);
1048
+ }, row_15.id);
1047
1049
  })
1048
1050
  })
1049
1051
  })
@@ -8,6 +8,7 @@ export interface ChatState {
8
8
  history?: ChatHistoryPage;
9
9
  waitingBefore?: string[];
10
10
  subagentsBefore?: string[];
11
+ outlineBefore?: ChatItem[];
11
12
  bookmarks?: ChatBookmark[];
12
13
  visuals?: ChatVisual[];
13
14
  }
@@ -16,6 +17,7 @@ export interface ChatPage {
16
17
  history: ChatHistoryPage;
17
18
  pending: ChatItem[];
18
19
  subagents?: ChatSubagentItem[];
20
+ outline?: ChatItem[];
19
21
  }
20
22
  export type ChatsById = Record<string, ChatState>;
21
23
  export type ChatStatuses = Record<string, Pick<ChatState, 'info'>>;
@@ -29,7 +29,8 @@ function stateOf(info, items, page) {
29
29
  order,
30
30
  history: page.history,
31
31
  waitingBefore: before.map(item => item.id),
32
- subagentsBefore: subagents.map(item => item.id)
32
+ subagentsBefore: subagents.map(item => item.id),
33
+ outlineBefore: (page.outline ?? []).filter(item => !(item.id in byId))
33
34
  };
34
35
  }
35
36
  /* An older host names no place in the thread, and it always hands over the whole of it. */
@@ -83,6 +84,7 @@ export function prependPage(state, cursor, page) {
83
84
  history: _history,
84
85
  waitingBefore: _waitingBefore,
85
86
  subagentsBefore: _subagentsBefore,
87
+ outlineBefore: _outlineBefore,
86
88
  ...rest
87
89
  } = loaded;
88
90
  return {
@@ -94,6 +96,7 @@ export function prependPage(state, cursor, page) {
94
96
  }
95
97
  const waitingBefore = (state.waitingBefore ?? []).filter(id => !olderIds.has(id));
96
98
  const subagentsBefore = (state.subagentsBefore ?? []).filter(id => !olderIds.has(id));
99
+ const outlineBefore = (state.outlineBefore ?? []).filter(item => !olderIds.has(item.id));
97
100
  return {
98
101
  ...loaded,
99
102
  items,
@@ -101,7 +104,8 @@ export function prependPage(state, cursor, page) {
101
104
  order,
102
105
  history: page.history,
103
106
  waitingBefore,
104
- subagentsBefore
107
+ subagentsBefore,
108
+ outlineBefore
105
109
  };
106
110
  }
107
111
  /* The requests that still wait, oldest first: those from before the page this client holds, then the thread's own. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.40.3",
3
+ "version": "0.40.4",
4
4
  "description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -67,11 +67,11 @@
67
67
  "test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
68
68
  },
69
69
  "dependencies": {
70
- "@adecore/agent-contracts": "0.40.3",
71
- "@adecore/editor": "0.40.3",
72
- "@adecore/editor-react": "0.40.3",
73
- "@adecore/intelligent-ui": "0.40.3",
74
- "@adecore/merge": "0.40.3",
70
+ "@adecore/agent-contracts": "0.40.4",
71
+ "@adecore/editor": "0.40.4",
72
+ "@adecore/editor-react": "0.40.4",
73
+ "@adecore/intelligent-ui": "0.40.4",
74
+ "@adecore/merge": "0.40.4",
75
75
  "@codemirror/commands": "^6.11.1",
76
76
  "@codemirror/language": "^6.13.1",
77
77
  "@codemirror/state": "^6.7.6",
@@ -94,14 +94,14 @@
94
94
  "zustand": "^5.0.16"
95
95
  },
96
96
  "peerDependencies": {
97
- "@adecore/ui": "^0.40.3",
97
+ "@adecore/ui": "^0.40.4",
98
98
  "i18next": "^26.4.2",
99
99
  "react": "^19.3.0",
100
100
  "react-dom": "^19.3.0",
101
101
  "react-i18next": "^17.0.15"
102
102
  },
103
103
  "devDependencies": {
104
- "@adecore/ui": "0.40.3",
104
+ "@adecore/ui": "0.40.4",
105
105
  "@types/bun": "^1.4.4",
106
106
  "@types/react": "^19.3.0",
107
107
  "@types/react-dom": "^19.3.0",
@@ -443,7 +443,9 @@ export class ChatClient {
443
443
  }
444
444
  } else {
445
445
  const page =
446
- result.history === undefined ? undefined : { history: result.history, pending: result.pending ?? [], subagents: result.subagents ?? [] };
446
+ result.history === undefined
447
+ ? undefined
448
+ : { history: result.history, pending: result.pending ?? [], subagents: result.subagents ?? [], outline: result.outline ?? [] };
447
449
 
448
450
  this.sink.reset(chatId, result.info, result.items, page);
449
451
  }
@@ -1,5 +1,5 @@
1
- import type { ChatBookmark } from '@adecore/agent-contracts';
2
- import type { TimelineRow } from './timeline';
1
+ import type { ChatBookmark, ChatItem } from '@adecore/agent-contracts';
2
+ import { agentTurnLabel, type TimelineRow } from './timeline';
3
3
  import { DEFAULT_READING_WIDTH, readingMeasure } from '../reading-width';
4
4
 
5
5
  // The strip of ticks at the left edge of a chat view, as numbers; the component only draws what comes out of here.
@@ -9,7 +9,7 @@ export type TickKind = 'person' | 'wake' | 'bookmark';
9
9
 
10
10
  export interface ScrubberTick {
11
11
  id: string;
12
- /* The row of the timeline the tick jumps to. */
12
+ /* The row of the timeline the tick jumps to; `EARLIER_ROW` for a message before the part of the thread this client holds. */
13
13
  rowIndex: number;
14
14
  kind: TickKind;
15
15
  text: string;
@@ -41,9 +41,45 @@ const WIDTH_NEAR_WAKE_PX = 8;
41
41
  const WIDTH_PERSON_PX = 8;
42
42
  const WIDTH_WAKE_PX = 5;
43
43
 
44
- /* `marks` is what `bookmarkRows` answers: the bookmark drawn at a row, by row id. */
45
- export function ticksOf(rows: readonly TimelineRow[], marks: ReadonlyMap<string, ChatBookmark> = new Map()): ScrubberTick[] {
46
- return rows.flatMap((row, rowIndex): ScrubberTick[] => {
44
+ /* Below every row, so a tick before the rows this client holds sorts first and its stretch reaches the first row of the thread. */
45
+ export const EARLIER_ROW = -1;
46
+
47
+ /* A message before the rows this client holds, as the outline (`outlineItems`) has it; its row id is the one the thread will draw it with. */
48
+ function earlierTick(item: ChatItem, bookmarks: ReadonlyMap<string, ChatBookmark>): ScrubberTick | null {
49
+ const bookmark = bookmarks.get(item.id) ?? null;
50
+ const rowIndex = EARLIER_ROW;
51
+
52
+ if (item.kind === 'user') {
53
+ const text = item.text !== '' ? item.text : (item.attachments ?? []).map((attachment) => attachment.name).join(', ');
54
+
55
+ return { id: item.id, rowIndex, kind: 'person', text, createdAt: item.createdAt, turnId: item.turnId, bookmark };
56
+ }
57
+
58
+ if (item.kind === 'turn' && ((item.taskIds?.length ?? 0) > 0 || (item.messageFrom?.length ?? 0) > 0)) {
59
+ return { id: `start-${item.id}`, rowIndex, kind: 'wake', text: agentTurnLabel(item), createdAt: item.createdAt, turnId: item.id, bookmark: null };
60
+ }
61
+
62
+ if (item.kind === 'assistant' && bookmark !== null) {
63
+ return { id: item.id, rowIndex, kind: 'bookmark', text: item.text, createdAt: item.createdAt, turnId: item.turnId, bookmark };
64
+ }
65
+
66
+ return null;
67
+ }
68
+
69
+ /*
70
+ * `marks` is what `bookmarkRows` answers: the bookmark drawn at a row, by row id. `earlier` is the
71
+ * outline of the thread before `rows`, and `bookmarks` the chat's, which mark the ticks of that part.
72
+ */
73
+ export function ticksOf(
74
+ rows: readonly TimelineRow[],
75
+ marks: ReadonlyMap<string, ChatBookmark> = new Map(),
76
+ earlier: readonly ChatItem[] = [],
77
+ bookmarks: readonly ChatBookmark[] = []
78
+ ): ScrubberTick[] {
79
+ const byItem = new Map(bookmarks.map((bookmark) => [bookmark.itemId, bookmark]));
80
+ const before = earlier.flatMap((item) => earlierTick(item, byItem) ?? []);
81
+
82
+ const held = rows.flatMap((row, rowIndex): ScrubberTick[] => {
47
83
  const bookmark = marks.get(row.id) ?? null;
48
84
 
49
85
  if (row.kind === 'user') {
@@ -71,6 +107,8 @@ export function ticksOf(rows: readonly TimelineRow[], marks: ReadonlyMap<string,
71
107
 
72
108
  return [{ id: row.id, rowIndex, kind: 'bookmark', text: bookmark.excerpt, createdAt: bookmark.createdAt, turnId, bookmark }];
73
109
  });
110
+
111
+ return before.length === 0 ? held : [...before, ...held];
74
112
  }
75
113
 
76
114
  /* One drawn tick: a message, or a run of messages merged once the height has fewer pixels than they need. */
@@ -45,7 +45,8 @@ import {
45
45
  STRIP_CLEARANCE_PX,
46
46
  tickOfRow,
47
47
  ticksOf,
48
- ticksWithHits
48
+ ticksWithHits,
49
+ EARLIER_ROW
49
50
  } from '../logic/scrubber';
50
51
  import {
51
52
  EMPTY_TARGET,
@@ -206,6 +207,7 @@ export function Timeline({
206
207
  const items = useChatRow(chatId, (row) => row?.structure);
207
208
  const activeTurnId = useChatRow(chatId, (row) => row?.info.activeTurnId ?? null);
208
209
  const bookmarks = useChatRow(chatId, (row) => row?.bookmarks);
210
+ const outlineBefore = useChatRow(chatId, (row) => row?.outlineBefore);
209
211
  const visuals = useChatRow(chatId, (row) => row?.visuals);
210
212
  const forkedTurns = useForkedTurns(chatId);
211
213
  const info = useChatRow(chatId, (row) => row?.info ?? null);
@@ -306,7 +308,7 @@ export function Timeline({
306
308
  // A chat that took a turn before is one whose thread has not come in yet, not one to greet.
307
309
  const welcome = !loadingHistory && welcomes && empty && (info === null || (info.usage.turns === 0 && info.activeTurnId === null));
308
310
  const marks = useMemo(() => bookmarkRows(rows, bookmarks ?? [], items ?? {}), [rows, bookmarks, items]);
309
- const ticks = useMemo(() => ticksOf(rows, marks), [rows, marks]);
311
+ const ticks = useMemo(() => ticksOf(rows, marks, outlineBefore, bookmarks), [rows, marks, outlineBefore, bookmarks]);
310
312
  // A message a jump is on its way to; it may first have to open the turn its reply folded into.
311
313
  const [seeking, setSeeking] = useState<{ itemId: string; block?: UiReplyTarget; key: string; options?: ItemJumpOptions } | null>(null);
312
314
  const [landing, setLanding] = useState<{ target: UiReplyTarget; key: string } | null>(null);
@@ -613,9 +615,10 @@ export function Timeline({
613
615
  return;
614
616
  }
615
617
 
616
- if (tick.bookmark !== null) {
618
+ // A message before the rows this client holds comes in page by page until its row is there.
619
+ if (tick.bookmark !== null || tick.rowIndex === EARLIER_ROW) {
617
620
  setLanding(null);
618
- setSeeking({ itemId: tick.bookmark.itemId, key: keyOf(chatId) });
621
+ setSeeking({ itemId: tick.bookmark?.itemId ?? tick.id, key: keyOf(chatId) });
619
622
 
620
623
  return;
621
624
  }
@@ -38,6 +38,11 @@ export interface ChatState {
38
38
  * that a message woke again without a scroll reaching back to its row.
39
39
  */
40
40
  subagentsBefore?: string[];
41
+ /*
42
+ * The outline of the thread before that part (`outlineItems`), cut down and kept apart from
43
+ * `items`, so the scrubber has a tick for every message before a scroll reaches it.
44
+ */
45
+ outlineBefore?: ChatItem[];
41
46
  /* The messages marked to come back to, as the host last said; absent until it said anything. */
42
47
  bookmarks?: ChatBookmark[];
43
48
  /* The pages agents published in the chat, as the host last said; absent until it said anything. */
@@ -53,6 +58,8 @@ export interface ChatPage {
53
58
  pending: ChatItem[];
54
59
  /* The active sub-agents from before the page; absent from a host that sends none. */
55
60
  subagents?: ChatSubagentItem[];
61
+ /* The outline of the thread before the page; absent from a host that sends none. */
62
+ outline?: ChatItem[];
56
63
  }
57
64
 
58
65
  /* Rows keyed with the scope's `keyOf`, so a thread says which host it runs on. */
@@ -124,7 +131,8 @@ function stateOf(info: ChatInfo, items: ChatItem[], page?: ChatPage): ChatState
124
131
  order,
125
132
  history: page.history,
126
133
  waitingBefore: before.map((item) => item.id),
127
- subagentsBefore: subagents.map((item) => item.id)
134
+ subagentsBefore: subagents.map((item) => item.id),
135
+ outlineBefore: (page.outline ?? []).filter((item) => !(item.id in byId))
128
136
  };
129
137
  }
130
138
 
@@ -173,15 +181,16 @@ export function prependPage(state: ChatState, cursor: string, page: ChatHistoryR
173
181
  const order = [...olderIds, ...state.order];
174
182
 
175
183
  if (page.history.cursor === null) {
176
- const { history: _history, waitingBefore: _waitingBefore, subagentsBefore: _subagentsBefore, ...rest } = loaded;
184
+ const { history: _history, waitingBefore: _waitingBefore, subagentsBefore: _subagentsBefore, outlineBefore: _outlineBefore, ...rest } = loaded;
177
185
 
178
186
  return { ...rest, items, structure: items, order };
179
187
  }
180
188
 
181
189
  const waitingBefore = (state.waitingBefore ?? []).filter((id) => !olderIds.has(id));
182
190
  const subagentsBefore = (state.subagentsBefore ?? []).filter((id) => !olderIds.has(id));
191
+ const outlineBefore = (state.outlineBefore ?? []).filter((item) => !olderIds.has(item.id));
183
192
 
184
- return { ...loaded, items, structure: items, order, history: page.history, waitingBefore, subagentsBefore };
193
+ return { ...loaded, items, structure: items, order, history: page.history, waitingBefore, subagentsBefore, outlineBefore };
185
194
  }
186
195
 
187
196
  /* The requests that still wait, oldest first: those from before the page this client holds, then the thread's own. */