|
1 | 1 | <script lang="ts"> |
2 | | - import type { createFlowState } from '$lib/stores/pgflow-state-improved.svelte'; |
| 2 | + import type { createFlowState } from '$lib/stores/pgflow-state.svelte'; |
3 | 3 | import { codeToHtml } from 'shiki'; |
4 | 4 | import { SvelteMap } from 'svelte/reactivity'; |
5 | 5 |
|
|
45 | 45 | // Clear cache when flow resets (events list becomes empty or significantly changes) |
46 | 46 | let lastEventCount = $state(0); |
47 | 47 | $effect(() => { |
48 | | - const currentEventCount = flowState.events.length; |
| 48 | + const currentEventCount = flowState.timeline.length; |
49 | 49 | // If events list was cleared or reduced significantly, clear the cache |
50 | 50 | if (currentEventCount === 0 || currentEventCount < lastEventCount - 5) { |
51 | 51 | highlightedEvents = new SvelteMap(); |
|
54 | 54 | lastEventCount = currentEventCount; |
55 | 55 | }); |
56 | 56 |
|
57 | | - // Get relative time from flow start |
58 | | - function formatRelativeTime(timestamp: Date, firstEventTimestamp: Date): string { |
59 | | - const diffMs = timestamp.getTime() - firstEventTimestamp.getTime(); |
60 | | - const seconds = (diffMs / 1000).toFixed(3); |
61 | | - return `+${seconds}s`; |
62 | | - } |
63 | | -
|
64 | 57 | // Get display status from event_type (use the status part for badge coloring) |
65 | 58 | function getEventStatus(eventType: string): string { |
66 | 59 | return eventType.split(':')[1] || 'unknown'; |
67 | 60 | } |
68 | 61 |
|
69 | | - // Get full event name for display |
70 | | - function getEventDisplayName(eventType: string): string { |
71 | | - return eventType; |
72 | | - } |
73 | | -
|
74 | 62 | // Get color class for event name based on status |
75 | 63 | function getEventColor(eventType: string): string { |
76 | 64 | const status = getEventStatus(eventType); |
|
87 | 75 | return 'text-muted-foreground'; |
88 | 76 | } |
89 | 77 | } |
| 78 | +
|
90 | 79 | </script> |
91 | 80 |
|
92 | 81 | <div class="flex flex-col h-full min-w-0"> |
93 | | - {#if flowState.events.length > 0} |
| 82 | + {#if flowState.timeline.length > 0} |
94 | 83 | <!-- Table-like headers --> |
95 | 84 | <div |
96 | 85 | class="flex items-center gap-2 px-3 py-1 border-b border-muted text-xs font-semibold text-muted-foreground" |
97 | 86 | > |
98 | | - <div class="w-[80px] text-left">TIME</div> |
| 87 | + <div class="w-[120px] text-left">TIME</div> |
99 | 88 | <div class="w-[140px] text-left">EVENT</div> |
100 | 89 | <div class="flex-1 text-left">STEP</div> |
101 | 90 | <div class="w-[32px]"></div> |
|
104 | 93 | {/if} |
105 | 94 |
|
106 | 95 | <div class="flex-1 overflow-y-auto overflow-x-hidden space-y-1 min-w-0"> |
107 | | - {#if flowState.events.length === 0} |
| 96 | + {#if flowState.timeline.length === 0} |
108 | 97 | <p class="text-sm text-muted-foreground text-center py-8"> |
109 | 98 | No events yet. Start a flow to see events. |
110 | 99 | </p> |
111 | 100 | {:else} |
112 | | - {@const firstEventTimestamp = flowState.events[0]?.timestamp} |
113 | | - {#each flowState.events as event, index (index)} |
| 101 | + {#each flowState.timeline as event, index (index)} |
114 | 102 | {@const eventType = event.event_type} |
115 | | - {@const stepSlug = event.data?.step_slug} |
116 | | - {@const eventDisplayName = getEventDisplayName(eventType)} |
| 103 | + {@const stepSlug = event.step_slug} |
117 | 104 | {@const eventColor = getEventColor(eventType)} |
118 | 105 | {@const isExpanded = expandedEventIndices.has(index)} |
119 | 106 | {@const isHighlighted = stepSlug && hoveredStep === stepSlug} |
|
127 | 114 | class="flex items-center gap-2 w-full text-left px-1 rounded transition-colors hover:bg-muted/20" |
128 | 115 | onclick={(e) => toggleEvent(index, e)} |
129 | 116 | > |
130 | | - <code class="w-[80px] text-base text-muted-foreground font-mono text-left" |
131 | | - >{formatRelativeTime(event.timestamp, firstEventTimestamp)}</code |
132 | | - > |
| 117 | + <div class="w-[120px] flex flex-col text-left"> |
| 118 | + <code class="text-base text-muted-foreground font-mono" |
| 119 | + >{event.cumulativeDisplay}</code |
| 120 | + > |
| 121 | + {#if event.deltaMs > 0} |
| 122 | + <code class="text-xs text-muted-foreground/70 font-mono" |
| 123 | + >{event.deltaDisplay}</code |
| 124 | + > |
| 125 | + {/if} |
| 126 | + </div> |
133 | 127 | <code class="w-[140px] text-base font-semibold font-mono {eventColor}"> |
134 | | - {eventDisplayName} |
| 128 | + {eventType} |
135 | 129 | </code> |
136 | 130 | {#if stepSlug} |
137 | 131 | <code |
|
0 commit comments