fix(webui): clear stale restart prompt after reconnect (#5813)
* fix(webui): clear stale restart prompt after reconnect * fix(webui): retry settings refresh after reconnect
This commit is contained in:
1 parent
dc996aba2d
commit
155a6ada02
3 files changed
+104
-6
No files matched your search
@@ -1058,6 +1058,56 @@ describe("App layout", () => {
|
||||
expect(window.location.hash).toBe("#/settings?section=channels");
|
||||
});
|
||||
|
||||
it("refreshes settings after the browser reconnects from a restart", async () => {
|
||||
let restartCompleted = false;
|
||||
let refreshedSettingsRequests = 0;
|
||||
let releaseRefreshedSettings!: () => void;
|
||||
const refreshedSettingsReady = new Promise<void>((resolve) => {
|
||||
releaseRefreshedSettings = resolve;
|
||||
});
|
||||
const pendingSettings = {
|
||||
...baseSettingsPayload(),
|
||||
requires_restart: true,
|
||||
restart_required_sections: ["runtime"],
|
||||
};
|
||||
const refreshedSettings = {
|
||||
...baseSettingsPayload(),
|
||||
requires_restart: false,
|
||||
restart_required_sections: [],
|
||||
};
|
||||
localStorage.setItem("nanobot-webui.restartStartedAt", String(Date.now() - 2_000));
|
||||
window.history.replaceState(null, "", "/#/settings?section=runtime");
|
||||
mockFetchRoutes({
|
||||
"/api/settings": () => {
|
||||
if (!restartCompleted) return pendingSettings;
|
||||
refreshedSettingsRequests += 1;
|
||||
if (refreshedSettingsRequests === 1) throw new Error("gateway is still starting");
|
||||
return refreshedSettingsReady.then(() => refreshedSettings);
|
||||
},
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText("Saved. Restart to apply changes.").length).toBeGreaterThan(0);
|
||||
}, { timeout: 10_000 });
|
||||
|
||||
restartCompleted = true;
|
||||
act(() => {
|
||||
for (const handler of statusHandlers) handler("reconnecting");
|
||||
for (const handler of statusHandlers) handler("open");
|
||||
});
|
||||
|
||||
await waitFor(() => expect(refreshedSettingsRequests).toBeGreaterThan(1));
|
||||
await act(async () => {
|
||||
releaseRefreshedSettings();
|
||||
await refreshedSettingsReady;
|
||||
});
|
||||
fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));
|
||||
await waitFor(() => expect(window.location.hash).toBe("#/new"));
|
||||
expect(await screen.findByText(HERO_GREETING_PATTERN, {}, { timeout: 10_000 })).toBeInTheDocument();
|
||||
}, 30_000);
|
||||
|
||||
it("opens Skills from the main sidebar", async () => {
|
||||
const longSkillDescription = [
|
||||
"Work with GitHub repositories, issues, pull requests, releases, workflows,",
|
||||
|
||||
Reference in new issue
Block a user