From 211398613354f98048d2cabe9161a53238bd06c9 Mon Sep 17 00:00:00 2001 From: Aarav Sharma Date: Fri, 15 May 2026 15:13:31 -0600 Subject: [PATCH 1/4] fix(cli): export all messages from TUI instead of truncated store The TUI's copy and export actions only included ~100 messages because they read from the in-memory sync store which caps at 100 for display performance. Now both actions fetch all messages directly from the server API. --- .../src/cli/cmd/tui/routes/session/index.tsx | 21 +++++++++++++++---- 1 file changed, 17 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 295c16fa82..bf7c54874c 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -979,10 +979,16 @@ export function Session() { try { const sessionData = session() if (!sessionData) return - const sessionMessages = messages() + // 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) => ({ + info: msg.info, + parts: msg.parts, + })) const transcript = formatTranscript( sessionData, - sessionMessages.map((msg) => ({ info: msg, parts: sync.data.part[msg.id] ?? [] })), + sessionMessages, + // kilocode_change end { thinking: showThinking(), toolDetails: showDetails(), @@ -1010,7 +1016,6 @@ export function Session() { try { const sessionData = session() if (!sessionData) return - const sessionMessages = messages() const defaultFilename = `session-${sessionData.id.slice(0, 8)}.md` @@ -1025,9 +1030,17 @@ 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) => ({ + info: msg.info, + parts: msg.parts, + })) + const transcript = formatTranscript( sessionData, - sessionMessages.map((msg) => ({ info: msg, parts: sync.data.part[msg.id] ?? [] })), + sessionMessages, + // kilocode_change end { thinking: options.thinking, toolDetails: options.toolDetails, From 19dc9d04d24c103cce0c2f81d8ee7b3b348eb921 Mon Sep 17 00:00:00 2001 From: Aarav Sharma Date: Fri, 15 May 2026 16:49:02 -0600 Subject: [PATCH 2/4] fix(cli): address PR review issues for TUI transcript handlers - Replace non-null assertions on allMessages.data with nullish coalescing - Move kilocode_change end markers to after sessionMessages declaration --- .../src/cli/cmd/tui/routes/session/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 bf7c54874c..f2b8219074 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -981,14 +981,14 @@ export function 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 sessionMessages = (allMessages.data ?? []).map((msg) => ({ info: msg.info, parts: msg.parts, })) + // kilocode_change end const transcript = formatTranscript( sessionData, - sessionMessages, - // kilocode_change end + sessionMessages, // kilocode_change { thinking: showThinking(), toolDetails: showDetails(), @@ -1032,15 +1032,15 @@ export function Session() { // 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 sessionMessages = (allMessages.data ?? []).map((msg) => ({ info: msg.info, parts: msg.parts, })) + // kilocode_change end const transcript = formatTranscript( sessionData, - sessionMessages, - // kilocode_change end + sessionMessages, // kilocode_change { thinking: options.thinking, toolDetails: options.toolDetails, From 8ba138def73897d7c19208a067f8a2b4be947fd6 Mon Sep 17 00:00:00 2001 From: Aarav Sharma Date: Sat, 16 May 2026 10:21:11 -0600 Subject: [PATCH 3/4] chore: add changeset for TUI export all messages --- .changeset/tui-export-all-messages.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tui-export-all-messages.md diff --git a/.changeset/tui-export-all-messages.md b/.changeset/tui-export-all-messages.md new file mode 100644 index 0000000000..302f995a45 --- /dev/null +++ b/.changeset/tui-export-all-messages.md @@ -0,0 +1,5 @@ +--- +"@kilocode/cli": patch +--- + +Export all messages from TUI instead of truncated store From 27a4137496f8cc75b60e399b0e8b01a1bbdaca04 Mon Sep 17 00:00:00 2001 From: Aarav Sharma Date: Fri, 22 May 2026 16:43:58 -0600 Subject: [PATCH 4/4] 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 f2b8219074..520c34d121 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, }))