MCPcopy Create free account
hub / github.com/ShipSecAI/studio / load

Function load

frontend/src/components/timeline/AgentTracePanel.tsx:754–818  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

752 }
753
754 const load = async () => {
755 setState((prev) => ({ ...prev, loading: true, error: null }));
756 try {
757 const headers = await getApiAuthHeaders();
758 const response = await fetch(`${API_V1_URL}/agents/${agentRunId}/parts`, {
759 headers,
760 });
761 if (!response.ok) {
762 throw new Error(`Failed to load agent trace for ${agentRunId}`);
763 }
764 const data = await response.json();
765 const parts: AgentTraceChunk[] = Array.isArray(data?.parts)
766 ? data.parts
767 .map(
768 (entry: {
769 sequence?: number | null;
770 timestamp?: string | null;
771 chunk?: UIMessageChunk | null;
772 }) => {
773 if (!entry?.chunk) {
774 return null;
775 }
776 return {
777 sequence: typeof entry.sequence === 'number' ? entry.sequence : 0,
778 timestamp:
779 typeof entry.timestamp === 'string'
780 ? entry.timestamp
781 : new Date().toISOString(),
782 chunk: entry.chunk,
783 };
784 },
785 )
786 .filter((entry: AgentTraceChunk | null): entry is AgentTraceChunk => Boolean(entry))
787 : [];
788 const chunks: UIMessageChunk[] = parts.map((entry) => entry.chunk);
789 const messages = await chunksToMessages(chunks);
790 const steps = deriveAgentSteps(parts);
791 if (!cancelled) {
792 setState({
793 loading: false,
794 error: null,
795 cursor:
796 typeof data?.cursor === 'number'
797 ? data.cursor
798 : parts.length > 0
799 ? parts[parts.length - 1]!.sequence
800 : 0,
801 messages,
802 parts,
803 steps,
804 });
805 }
806 } catch (err) {
807 if (!cancelled) {
808 setState({
809 loading: false,
810 error: err instanceof Error ? err.message : 'Failed to load transcript',
811 cursor: 0,

Callers 1

useAgentTranscriptFunction · 0.85

Calls 4

getApiAuthHeadersFunction · 0.90
fetchFunction · 0.85
chunksToMessagesFunction · 0.85
deriveAgentStepsFunction · 0.85

Tested by

no test coverage detected