From 27a4137496f8cc75b60e399b0e8b01a1bbdaca04 Mon Sep 17 00:00:00 2001 From: Aarav Sharma Date: Fri, 22 May 2026 16:43:58 -0600 Subject: [PATCH] fix(cli): prevent data-loss in TUI transcript copy/export on SDK error Both the copy and export handlers now pass `{ throwOnError: true }` to `sdk.client.session.messages()` and drop the `?? []` fallback, so a failed fetch (404/400/network) throws into the existing catch block and surfaces an error toast instead of silently writing/returning an empty transcript. --- .../opencode/src/cli/cmd/tui/routes/session/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index f2b82190743..520c34d121e 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -980,8 +980,8 @@ export function Session() { const sessionData = session() if (!sessionData) return // kilocode_change start - fetch all messages from server instead of truncated sync store - const allMessages = await sdk.client.session.messages({ sessionID: sessionData.id }) - const sessionMessages = (allMessages.data ?? []).map((msg) => ({ + const allMessages = await sdk.client.session.messages({ sessionID: sessionData.id }, { throwOnError: true }) + const sessionMessages = allMessages.data.map((msg) => ({ info: msg.info, parts: msg.parts, })) @@ -1031,8 +1031,8 @@ export function Session() { if (options === null) return // kilocode_change start - fetch all messages from server instead of truncated sync store - const allMessages = await sdk.client.session.messages({ sessionID: sessionData.id }) - const sessionMessages = (allMessages.data ?? []).map((msg) => ({ + const allMessages = await sdk.client.session.messages({ sessionID: sessionData.id }, { throwOnError: true }) + const sessionMessages = allMessages.data.map((msg) => ({ info: msg.info, parts: msg.parts, }))