Skip to content

Commit eb691c5

Browse files
author
Eric Oliver
committed
address reviewer feedback
1 parent 3062a66 commit eb691c5

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/api/streaming/SSEOutputAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export class SSEOutputAdapter implements IUserInterface {
301301
if (!success) {
302302
this.logger.warn(`Failed to emit event ${event.type} for job ${this.jobId}`)
303303
console.log(`[SSE] Failed to send event ${event.type} for job ${this.jobId}`)
304-
console.log(`[SSE] Available streams:`, Object.keys((this.streamManager as any).streams || {}))
304+
console.log(`[SSE] Available streams:`, this.streamManager.getActiveStreamIds())
305305
} else {
306306
console.log(`[SSE] Successfully sent event ${event.type} for job ${this.jobId}`)
307307
}

src/api/streaming/__tests__/SSEOutputAdapter.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,27 @@ describe("SSEOutputAdapter", () => {
300300
expect(new Date(event.timestamp)).toBeInstanceOf(Date)
301301
})
302302
})
303+
304+
describe("error handling", () => {
305+
it("should handle stream failure gracefully", async () => {
306+
// Close the stream to simulate failure
307+
streamManager.closeStream(jobId)
308+
309+
// Spy on console.log to verify error logging
310+
const consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {})
311+
312+
await adapter.showInformation("Test message")
313+
314+
// Verify that error logging uses public API
315+
expect(consoleSpy).toHaveBeenCalledWith(
316+
expect.stringContaining("[SSE] Failed to send event information for job test-job-123"),
317+
)
318+
expect(consoleSpy).toHaveBeenCalledWith(
319+
expect.stringContaining("[SSE] Available streams:"),
320+
expect.any(Array),
321+
)
322+
323+
consoleSpy.mockRestore()
324+
})
325+
})
303326
})

src/shared/paths.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
*/
55

66
import * as os from "os"
7+
import * as path from "path"
78

89
/**
910
* Get the global storage path for the application
1011
* Uses .agentz directory for consistency with CLI config
1112
*/
1213
export function getGlobalStoragePath(): string {
1314
const homeDir = os.homedir()
14-
return `${homeDir}/.agentz`
15+
return path.join(homeDir, ".agentz")
1516
}
1617

1718
/**
1819
* Get the fallback storage path for environments without home directory
1920
*/
2021
export function getFallbackStoragePath(): string {
21-
return "/tmp/.agentz"
22+
return path.join("/tmp", ".agentz")
2223
}
2324

2425
/**

0 commit comments

Comments
 (0)