Skip to content

Commit 0c4ead2

Browse files
committed
fix(control-ui): reconcile channel tab refresh replay
1 parent b68693c commit 0c4ead2

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

ui/src/ui/app-gateway-chat-load.node.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ describe("connectGateway chat load startup work", () => {
219219
expect(refreshChatAvatarMock).toHaveBeenCalledWith(host);
220220
});
221221

222-
it("lets the active tab refresh own node and device loading after hello", () => {
222+
it("lets the active tab refresh own node and device loading after hello", async () => {
223223
const { host, client } = connectHost("overview");
224224

225225
client.emitHello();
226226

227-
expect(refreshActiveTabMock).toHaveBeenCalledWith(host);
227+
await vi.waitFor(() => expect(refreshActiveTabMock).toHaveBeenCalledWith(host));
228228
expect(loadNodesMock).not.toHaveBeenCalled();
229229
expect(loadDevicesMock).not.toHaveBeenCalled();
230230
});

ui/src/ui/app-settings.refresh-active-tab.node.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,31 +353,24 @@ describe("refreshActiveTab", () => {
353353
});
354354
});
355355

356-
it("renders channels from the cheap snapshot before starting slow probes", async () => {
356+
it("renders channels from the cheap snapshot without waiting for config schema", async () => {
357357
const host = createHost();
358358
host.tab = "channels";
359359
const schema = createDeferred();
360-
const channelProbe = createDeferred();
361360
mocks.loadConfigSchemaMock.mockReturnValueOnce(schema.promise);
362-
mocks.loadChannelsMock.mockImplementation(async (_host, probe) => {
363-
if (probe) {
364-
await channelProbe.promise;
365-
}
366-
});
367361

368362
const refresh = refreshActiveTab(host as never);
369363
const outcome = await raceWithNextMacrotask(refresh);
370364

371365
expect(outcome).toBe("resolved");
372-
expect(mocks.loadChannelsMock.mock.calls.map(([, probe]) => probe)).toEqual([false, true]);
366+
expect(mocks.loadChannelsMock.mock.calls.map(([, probe]) => probe)).toEqual([false]);
373367
expect(mocks.loadConfigMock).toHaveBeenCalledOnce();
374368
expect(host.requestUpdate).not.toHaveBeenCalled();
375369

376370
schema.resolve();
377-
channelProbe.resolve();
378371

379372
await vi.waitFor(() => {
380-
expect(host.requestUpdate).toHaveBeenCalledTimes(2);
373+
expect(host.requestUpdate).toHaveBeenCalledOnce();
381374
});
382375
});
383376

ui/src/ui/app-settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ function buildAttentionItems(host: SettingsAppHost) {
852852

853853
export async function loadChannelsTab(host: SettingsHost) {
854854
const app = host as unknown as SettingsAppHost;
855-
await Promise.all([loadChannels(app, false), loadConfigSchema(app), loadConfig(app)]);
855+
void loadConfigSchema(app).finally(() => host.requestUpdate?.());
856+
await Promise.all([loadChannels(app, false), loadConfig(app)]);
856857
}
857858

858859
export async function loadCron(host: SettingsHost) {

0 commit comments

Comments
 (0)