1+ /// <reference path="../../../types/electron.d.ts" />
12import type { SessionNotification } from "@agentclientprotocol/sdk" ;
23
34export interface StoredLogEntry {
@@ -26,14 +27,16 @@ export interface ParsedSessionLogs {
2627export async function fetchSessionLogs (
2728 logUrl : string ,
2829) : Promise < ParsedSessionLogs > {
29- if ( ! logUrl ) return { notifications : [ ] , rawEntries : [ ] } ;
30+ if ( ! logUrl ) {
31+ return { notifications : [ ] , rawEntries : [ ] } ;
32+ }
3033
3134 try {
32- const response = await fetch ( logUrl ) ;
33- if ( ! response . ok ) return { notifications : [ ] , rawEntries : [ ] } ;
35+ const content = await window . electronAPI . fetchS3Logs ( logUrl ) ;
3436
35- const content = await response . text ( ) ;
36- if ( ! content . trim ( ) ) return { notifications : [ ] , rawEntries : [ ] } ;
37+ if ( ! content ?. trim ( ) ) {
38+ return { notifications : [ ] , rawEntries : [ ] } ;
39+ }
3740
3841 const notifications : SessionNotification [ ] = [ ] ;
3942 const rawEntries : StoredLogEntry [ ] = [ ] ;
@@ -47,7 +50,6 @@ export async function fetchSessionLogs(
4750 // - Request (has id + method) = client → agent
4851 // - Response (has id + result/error) = agent → client
4952 // - Notification (has method, no id) = agent → client
50- // TODO: Check if this is correct.
5153 const msg = stored . notification ;
5254 if ( msg ) {
5355 const hasId = msg . id !== undefined ;
@@ -94,7 +96,6 @@ export async function fetchSessionLogs(
9496
9597 return { notifications, rawEntries, sdkSessionId } ;
9698 } catch {
97- // Network error or other failure
9899 return { notifications : [ ] , rawEntries : [ ] } ;
99100 }
100101}
0 commit comments