fix(ui): avoid duplicate initial log loads

This commit is contained in:
Peter Steinberger
2026-08-11 17:37:22 -07:00
parent fd25924d50
commit edf04aa491
2 changed files with 21 additions and 4 deletions
+19
View File
@@ -120,6 +120,25 @@ describe("LogsPage lifecycle", () => {
expect(scheduleScroll).toHaveBeenCalledWith(true);
});
it("does not restart a pending initial load for metadata-only gateway snapshots", async () => {
const pending = deferred<{ cursor: number; lines: string[]; reset: boolean }>();
const request = vi.fn(() => pending.promise);
const client = { request } as unknown as GatewayBrowserClient;
const page = document.createElement("openclaw-logs-page") as TestLogsPage;
const context = contextWithClient(client, true);
page.context = context;
document.body.append(page);
await page.updateComplete;
await vi.waitFor(() => expect(request).toHaveBeenCalledOnce());
context.gateway.publish({ client, phase: "connected" } as ApplicationGatewaySnapshot);
await Promise.resolve();
expect(request).toHaveBeenCalledOnce();
pending.resolve({ cursor: 1, lines: ["initial"], reset: true });
await vi.waitFor(() => expect(page.logsEntries).toHaveLength(1));
});
it("discards a log response from a replaced gateway source that reuses its client", async () => {
const pending = deferred<{ cursor: number; lines: string[]; reset: boolean }>();
const client = {
+2 -4
View File
@@ -136,10 +136,8 @@ class LogsPage extends OpenClawLightDomElement {
this.logsTaskQuiet = false;
void this.logsTask.run([null, null, null, false, false]);
},
onSnapshot: () => {
this.syncPolling();
this.ensureInitialLogs();
},
onSnapshot: () => this.syncPolling(),
ensureInitialData: () => this.ensureInitialLogs(),
});
private readonly streamFollow = new StreamAutoFollowController(this, {
selector: ".log-stream",