Skip to content

Commit 667ff21

Browse files
committed
fix(chat): correct scroll-back types and drop orphaned recent-messages reader
1 parent e3adff9 commit 667ff21

6 files changed

Lines changed: 10 additions & 37 deletions

File tree

‎scripts/deadcode-exports.baseline.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
37343734
"src/gateway/chat-tool-titles.ts: ToolTitleRequestItem",
37353735
"src/gateway/cli-session-history.ts: mergeImportedChatHistoryMessages",
37363736
"src/gateway/cli-session-history.ts: readClaudeCliSessionMessages",
3737-
"src/gateway/cli-session-history.ts: resolveClaudeCliBindingSessionId",
37383737
"src/gateway/cli-session-history.ts: resolveClaudeCliSessionFilePath",
37393738
"src/gateway/client-bootstrap.ts: resolveGatewayUrlOverrideSource",
37403739
"src/gateway/client-start-readiness.ts: GatewayClientStartable",
@@ -3984,7 +3983,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
39843983
"src/gateway/session-utils.ts: readFirstUserMessageFromTranscript",
39853984
"src/gateway/session-utils.ts: readLatestRecentSessionUsageFromTranscriptAsync",
39863985
"src/gateway/session-utils.ts: readLatestSessionUsageFromTranscriptAsync",
3987-
"src/gateway/session-utils.ts: readRecentSessionMessagesAsync",
39883986
"src/gateway/session-utils.ts: readRecentSessionMessagesWithStatsAsync",
39893987
"src/gateway/session-utils.ts: readRecentSessionTranscriptLines",
39903988
"src/gateway/session-utils.ts: readRecentSessionUsageFromTranscript",

‎src/gateway/cli-session-history.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ describe("cli session history", () => {
240240
"utf-8",
241241
);
242242

243+
const importedId = (message: Record<string, unknown> | undefined) =>
244+
(message?.["__openclaw"] as { id?: string } | undefined)?.id;
243245
const first = readClaudeCliSessionMessages({ cliSessionId: sessionId, homeDir });
244246
const second = readClaudeCliSessionMessages({ cliSessionId: sessionId, homeDir });
245-
expect(first[0]?.["__openclaw"]?.id).toBe(`claude-cli:${sessionId}:line:1`);
246-
expect(second[0]?.["__openclaw"]?.id).toBe(first[0]?.["__openclaw"]?.id);
247+
expect(importedId(first[0])).toBe(`claude-cli:${sessionId}:line:1`);
248+
expect(importedId(second[0])).toBe(importedId(first[0]));
247249
});
248250
});
249251

‎src/gateway/server.chat.gateway-server-chat-b.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5380,9 +5380,9 @@ describe("gateway server chat", () => {
53805380
expect(firstPage.payload?.messages?.map(readOpenClawSeq)).toEqual([3]);
53815381
expect(firstPage.payload?.hasMore).toBe(true);
53825382
expect(firstPage.payload?.nextOffset).toBeGreaterThan(0);
5383-
expect(captured.some((event) => event.action === "truncated" && event.count > 0)).toBe(
5384-
true,
5385-
);
5383+
expect(
5384+
captured.some((event) => event.action === "truncated" && (event.count ?? 0) > 0),
5385+
).toBe(true);
53865386

53875387
let offset = expectDefined(firstPage.payload?.nextOffset, "second page offset");
53885388
const olderMessages: unknown[] = [];

‎src/gateway/session-transcript-readers.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -612,34 +612,6 @@ export async function readSessionMessagesWithSourceAsync(
612612
);
613613
}
614614

615-
/** Reads recent display messages asynchronously through the reader seam. */
616-
export async function readRecentSessionMessagesAsync(
617-
scope: SessionTranscriptReadScope,
618-
opts?: ReadRecentSessionMessagesOptions,
619-
): Promise<unknown[]> {
620-
const target = resolveTranscriptReadTarget(scope);
621-
if (isSqliteReadTarget(target)) {
622-
const records = await readRecentSqliteMessageRecords(target, opts);
623-
if (records.length === 0 && opts?.allowResetArchiveFallback === true) {
624-
return await readRecentSessionMessagesAsyncFile(
625-
target.sessionId,
626-
target.storePath,
627-
undefined,
628-
{ ...opts, resetArchiveOnly: true },
629-
target.agentId,
630-
);
631-
}
632-
return records.map(sqliteRecordMessageWithSeq);
633-
}
634-
return await readRecentSessionMessagesAsyncFile(
635-
target.sessionId,
636-
target.storePath,
637-
target.sessionFile,
638-
opts,
639-
target.agentId,
640-
);
641-
}
642-
643615
/** Finds one display message by transcript id through the reader seam. */
644616
export async function readSessionMessageByIdAsync(
645617
scope: SessionTranscriptReadScope,

‎src/gateway/session-utils.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export {
134134
readLatestSessionUsageFromTranscriptAsync,
135135
readLatestRecentSessionUsageFromTranscriptAsync,
136136
readRecentSessionUsageFromTranscriptAsync,
137-
readRecentSessionMessagesAsync,
138137
readRecentSessionMessagesWithStatsAsync,
139138
readRecentSessionTranscriptLines,
140139
readRecentSessionUsageFromTranscript,

‎ui/src/pages/chat/chat-pane.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,9 @@ class ChatPane extends OpenClawLightDomElement {
18951895
messages: catalogKey ? this.catalogMessages : state.chatMessages,
18961896
renderAllLoadedHistory:
18971897
!catalogKey &&
1898-
(this.nativeHistoryExpanded || state.chatHistoryPagination?.completeSnapshot === true),
1898+
(this.nativeHistoryExpanded ||
1899+
(state.chatHistoryPagination?.hasMore === false &&
1900+
state.chatHistoryPagination.completeSnapshot === true)),
18991901
historyPagination:
19001902
catalogKey || state.chatHistoryPagination?.hasMore || this.loadingOlder
19011903
? {

0 commit comments

Comments
 (0)