Skip to content

Commit bef84be

Browse files
authored
improve: load 800 chat messages with less layout work (#133734)
* perf: load more chat history with less layout work * chore: leave history release notes to release generation
1 parent 62b41fe commit bef84be

16 files changed

Lines changed: 54 additions & 39 deletions

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ select it to open the owning Approvals page.
349349
<AccordionGroup>
350350
<Accordion title="Chat and Talk">
351351
- Chat with the model via Gateway WS (`chat.history`, `chat.send`, `chat.abort`, `chat.inject`). Archived sessions keep the composer disabled and show a banner with an **Unarchive** action before the conversation can continue.
352-
- Chat history opens with up to 400 recent messages. Session prefetches and history refreshes use the same window. Scrolling back requests up to 1,000 older messages per page and prefetches the next page to reduce loading pauses. Per-message text caps and the Gateway response-size limit still apply, so pages can contain fewer messages.
352+
- Chat history opens with up to 800 recent messages. Session prefetches and history refreshes use the same window. Scrolling back requests up to 1,000 older messages per page and prefetches the next page to reduce loading pauses. Per-message text caps and the Gateway response-size limit still apply, so pages can contain fewer messages.
353353
- A previous run's error banner clears when Chat adopts a new run or history confirms a newer successful run. Retiring the banner does not erase recorded diagnostics. A late error from the same run can remain visible beside its delivered answer; reconnecting or refreshing metadata alone does not establish recovery.
354354
- A saved assistant answer replaces its live stream without waiting for the run to finish. Remote workspace reconciliation can keep the working indicator and Stop control active after the answer appears; a later reconciliation failure remains visible beside the answer.
355355
- Scroll up to read earlier messages without following incoming output. Use the down-arrow button to return to the latest message. Scrolling manually interrupts that movement or a restored scroll position; messages continue to reserve their space as full text, images, and tool output load.

‎ui/src/components/tooltip.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ describe("openclaw-tooltip", () => {
210210
expectOpenCount(1);
211211
});
212212

213-
it("suppresses a tooltip that repeats fully visible trigger text", async () => {
213+
it("suppresses repeated trigger text before opening and after content updates", async () => {
214214
const provider = createProvider();
215215
const { tooltip, trigger } = createTooltip("Claude Opus 4.7", "Claude Opus 4.7 Anthropic");
216216
provider.append(tooltip);
@@ -222,6 +222,15 @@ describe("openclaw-tooltip", () => {
222222
hoverTrigger(trigger);
223223
vi.runAllTimers();
224224
expectOpenCount(0);
225+
226+
tooltip.content = "Additional model details";
227+
await tooltip.updateComplete;
228+
focusTrigger(trigger);
229+
expectOpenCount(1);
230+
231+
tooltip.content = "Claude Opus 4.7";
232+
await tooltip.updateComplete;
233+
expectOpenCount(0);
225234
});
226235

227236
it("keeps a repeated-label tooltip when the trigger clips its text", async () => {

‎ui/src/components/tooltip.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ class Tooltip extends OpenClawLitElement {
217217
this.attachTrigger();
218218
this.syncDescription();
219219
this.syncWebAwesomeTooltip();
220-
if (this.disabled || !this.tooltipText || this.isRedundant()) {
220+
// Closed tooltips check redundancy in show(); measuring their triggers here
221+
// forces layout while a new transcript is still rendering.
222+
if (
223+
this.disabled ||
224+
!this.tooltipText ||
225+
(this.webAwesomeTooltip?.open && this.isRedundant())
226+
) {
221227
this.close();
222228
}
223229
}

‎ui/src/e2e/agent-selection-persistence.e2e.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function hasOpenClawStartup(gateway: MockGatewayControls): Promise<boolean
101101
return (
102102
params?.agentId === "openclaw" &&
103103
params.sessionKey === "agent:openclaw:main" &&
104-
params.limit === 400
104+
params.limit === 800
105105
);
106106
});
107107
}

‎ui/src/e2e/dashboard-final-reply-recovery.e2e.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ suite.define(() => {
156156
});
157157

158158
const staleRequest = await gateway.waitForRequest("chat.history", { after: historyCount });
159-
expect(staleRequest.params).toMatchObject({ sessionKey, limit: 400 });
159+
expect(staleRequest.params).toMatchObject({ sessionKey, limit: 800 });
160160
// The first authoritative snapshot can promote the same interim text to
161161
// a durable row before the distinct terminal reply is committed. That
162162
// identity change is not a recovered final; retry until new content lands.

‎ui/src/pages/chat/background-tasks.e2e.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ suite.define(() => {
222222
);
223223
expect(transcriptRequest?.params).toEqual({
224224
sessionKey: runningSubagent.childSessionKey,
225-
limit: 400,
225+
limit: 800,
226226
});
227227
expect(page.url()).toBe(chatUrl);
228228
expect(withoutElapsedLabels(await mainTranscript.textContent())).toBe(mainTranscriptBefore);
@@ -393,7 +393,7 @@ suite.define(() => {
393393
);
394394
expect(childHistoryRequest?.params).toEqual({
395395
sessionKey: first.childSessionKey,
396-
limit: 400,
396+
limit: 800,
397397
});
398398

399399
await gateway.emitGatewayEvent("task", {

‎ui/src/pages/chat/chat-gateway.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,7 @@ describe("loadChatHistory filtering", () => {
28542854
expect(request).toHaveBeenCalledWith("chat.startup", {
28552855
agentId: "research",
28562856
sessionKey: "global",
2857-
limit: 400,
2857+
limit: 800,
28582858
});
28592859
expect(state.chatMessages).toEqual([
28602860
{ role: "assistant", content: [{ type: "text", text: "ready" }] },
@@ -2937,11 +2937,11 @@ describe("loadChatHistory filtering", () => {
29372937
expect(request).toHaveBeenCalledTimes(2);
29382938
expect(request).toHaveBeenCalledWith("chat.startup", {
29392939
sessionKey: "agent:main:first",
2940-
limit: 400,
2940+
limit: 800,
29412941
});
29422942
expect(request).toHaveBeenCalledWith("chat.startup", {
29432943
sessionKey: "agent:main:second",
2944-
limit: 400,
2944+
limit: 800,
29452945
});
29462946
});
29472947

@@ -2991,7 +2991,7 @@ describe("loadChatHistory filtering", () => {
29912991

29922992
expect(request).toHaveBeenCalledWith("chat.startup", {
29932993
sessionKey: "main",
2994-
limit: 400,
2994+
limit: 800,
29952995
});
29962996
});
29972997
});
@@ -3024,7 +3024,7 @@ describe("loadChatHistory retry handling", () => {
30243024

30253025
expect(request).toHaveBeenNthCalledWith(1, "chat.startup", {
30263026
sessionKey: "main",
3027-
limit: 400,
3027+
limit: 800,
30283028
});
30293029
expect(request).toHaveBeenCalledTimes(1);
30303030
expect(getChatHistoryLoadState(state)).toMatchObject({
@@ -3134,7 +3134,7 @@ describe("loadChatHistory retry handling", () => {
31343134

31353135
expect(request).toHaveBeenCalledWith("chat.history", {
31363136
sessionKey: "main",
3137-
limit: 400,
3137+
limit: 800,
31383138
});
31393139
expect(state.chatMessages).toEqual([
31403140
{ role: "assistant", content: [{ type: "text", text: "visible answer" }] },
@@ -3305,7 +3305,7 @@ describe("loadChatHistory retry handling", () => {
33053305

33063306
expect(request).toHaveBeenCalledWith("chat.history", {
33073307
sessionKey: "main",
3308-
limit: 400,
3308+
limit: 800,
33093309
...(inputRunIds ? { inputRunIds } : {}),
33103310
});
33113311
expect(state.chatMessages).toEqual(expected);
@@ -3971,10 +3971,10 @@ describe("loadChatHistory retry handling", () => {
39713971
const thirdLoad = loadChatHistory(state);
39723972

39733973
expect(request.mock.calls).toEqual([
3974-
["chat.history", { sessionKey: "main", limit: 400 }],
3974+
["chat.history", { sessionKey: "main", limit: 800 }],
39753975
[
39763976
"chat.history",
3977-
{ sessionKey: "main", limit: 400, inputRunIds: ["same-session-pending-run"] },
3977+
{ sessionKey: "main", limit: 800, inputRunIds: ["same-session-pending-run"] },
39783978
],
39793979
]);
39803980
expect(state.chatMessages).toEqual([pending]);

‎ui/src/pages/chat/chat-history.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ it.each(["main", "workspace"])(
7979
expect(request).toHaveBeenCalledWith("chat.history", {
8080
sessionKey,
8181
agentId: "main",
82-
limit: 400,
82+
limit: 800,
8383
});
8484
},
8585
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ import { reconcileAuthoritativeTerminalHistory } from "./terminal-message-identi
109109
import { persistedCurrentToolStreamIds } from "./tool-stream-identity.ts";
110110
import { handleAgentEvent } from "./tool-stream.ts";
111111

112-
export const CHAT_HISTORY_REQUEST_LIMIT = 400;
112+
export const CHAT_HISTORY_REQUEST_LIMIT = 800;
113113
// Back-scroll pages are larger than the startup tail: session open stays cheap
114114
// while older-history reads amortize round trips and prepend/re-anchor cycles.
115115
// The gateway independently bounds each response (entry cap + byte budget).

‎ui/src/pages/chat/chat-pane-history-issuance.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe("chat pane history issuance across Gateway connection transitions", ()
6565
await vi.waitFor(() => expect(request).toHaveBeenCalledOnce());
6666
expect(request).toHaveBeenCalledWith("chat.history", {
6767
sessionKey: "agent:main:current",
68-
limit: 400,
68+
limit: 800,
6969
});
7070
await vi.waitFor(() =>
7171
expect(state.chatMessages).toEqual([
@@ -102,7 +102,7 @@ describe("chat pane history issuance across Gateway connection transitions", ()
102102
await vi.waitFor(() => expect(request).toHaveBeenCalledTimes(2));
103103
expect(request).toHaveBeenNthCalledWith(2, "chat.startup", {
104104
sessionKey: state.sessionKey,
105-
limit: 400,
105+
limit: 800,
106106
});
107107
await vi.waitFor(() =>
108108
expect(state.chatMessages).toEqual([

0 commit comments

Comments
 (0)