MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / buildTimeline

Function buildTimeline

graph-ui/src/agents/agent-timeline.ts:117–158  ·  view source on GitHub ↗
(input: TimelineInput)

Source from the content-addressed store, hash-verified

115 * eine Pause, weil er die staerkere Aussage ist.
116 */
117export function buildTimeline(input: TimelineInput): Timeline {
118 const mode: TimelineMode = input.replayAt !== undefined
119 ? 'replay'
120 : input.pausedAt !== undefined ? 'paused' : 'live';
121 const to = input.replayAt ?? input.pausedAt ?? input.now;
122 const earliest = input.actors.reduce(
123 (min, actor) => Math.min(min, actor.firstTs),
124 Number.POSITIVE_INFINITY,
125 );
126 const span = input.windowMs > 0
127 ? input.windowMs
128 : Math.max(1000, to - (Number.isFinite(earliest) ? earliest : to - 1000));
129 const from = to - span;
130
131 let ticks = 0;
132 const tracks = input.actors.map((actor) => {
133 const own: TimelineTick[] = [];
134 for (const event of actor.events) {
135 if (event.ts < from || event.ts > to) {
136 continue;
137 }
138 own.push({
139 ts: event.ts,
140 at: span === 0 ? 1 : Number(((event.ts - from) / span).toFixed(6)),
141 kind: event.kind,
142 });
143 }
144 ticks += own.length;
145 return {
146 id: actor.id,
147 name: actor.name,
148 color: actor.color,
149 letter: actor.letter,
150 you: actor.you,
151 idle: actor.idle,
152 ticks: own,
153 count: own.length,
154 };
155 });
156
157 return { mode, from, to, windowMs: span, tracks, ticks };
158}
159
160/** Die Zeit an dieser Stelle des Strahls. `fraction` liegt zwischen 0 und 1. */
161export function timeAtFraction(timeline: Timeline, fraction: number): number {

Callers 2

GalaxyPanelFunction · 0.90

Calls 2

reduceMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected