mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-28 08:52:45 +00:00
UI: fix redundant applyBorderRadius call and restore session-scope cap test (#49443)
This commit is contained in:
@@ -44,7 +44,6 @@ import {
|
|||||||
setTheme as setThemeInternal,
|
setTheme as setThemeInternal,
|
||||||
setThemeMode as setThemeModeInternal,
|
setThemeMode as setThemeModeInternal,
|
||||||
onPopState as onPopStateInternal,
|
onPopState as onPopStateInternal,
|
||||||
applyBorderRadius,
|
|
||||||
} from "./app-settings.ts";
|
} from "./app-settings.ts";
|
||||||
import {
|
import {
|
||||||
resetToolStream as resetToolStreamInternal,
|
resetToolStream as resetToolStreamInternal,
|
||||||
@@ -564,7 +563,6 @@ export class OpenClawApp extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setBorderRadius(value: number) {
|
setBorderRadius(value: number) {
|
||||||
applyBorderRadius(value);
|
|
||||||
applySettingsInternal(this as unknown as Parameters<typeof applySettingsInternal>[0], {
|
applySettingsInternal(this as unknown as Parameters<typeof applySettingsInternal>[0], {
|
||||||
...this.settings,
|
...this.settings,
|
||||||
borderRadius: value,
|
borderRadius: value,
|
||||||
|
|||||||
@@ -402,33 +402,50 @@ describe("loadSettings default gateway URL derivation", () => {
|
|||||||
|
|
||||||
const { saveSettings } = await import("./storage.ts");
|
const { saveSettings } = await import("./storage.ts");
|
||||||
const gwUrl = expectedGatewayUrl("");
|
const gwUrl = expectedGatewayUrl("");
|
||||||
|
const scopedKey = `openclaw.control.settings.v1:wss://gateway.example:8443`;
|
||||||
|
|
||||||
for (let i = 0; i < 12; i += 1) {
|
// Pre-seed sessionsByGateway with 11 stale gateway entries so the next
|
||||||
saveSettings({
|
// saveSettings call pushes the total to 12 and triggers the cap (10).
|
||||||
gatewayUrl: gwUrl,
|
const staleEntries: Record<string, { sessionKey: string; lastActiveSessionKey: string }> = {};
|
||||||
token: "",
|
for (let i = 0; i < 11; i += 1) {
|
||||||
sessionKey: `agent:test_${i}:main`,
|
staleEntries[`wss://stale-${i}.example:8443`] = {
|
||||||
lastActiveSessionKey: `agent:test_${i}:main`,
|
sessionKey: `agent:stale_${i}:main`,
|
||||||
theme: "claw",
|
lastActiveSessionKey: `agent:stale_${i}:main`,
|
||||||
themeMode: "system",
|
};
|
||||||
chatFocusMode: false,
|
|
||||||
chatShowThinking: true,
|
|
||||||
chatShowToolCalls: true,
|
|
||||||
splitRatio: 0.6,
|
|
||||||
navCollapsed: false,
|
|
||||||
navWidth: 220,
|
|
||||||
navGroupsCollapsed: {},
|
|
||||||
borderRadius: 50,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
localStorage.setItem(scopedKey, JSON.stringify({ sessionsByGateway: staleEntries }));
|
||||||
|
|
||||||
|
saveSettings({
|
||||||
|
gatewayUrl: gwUrl,
|
||||||
|
token: "",
|
||||||
|
sessionKey: "agent:current:main",
|
||||||
|
lastActiveSessionKey: "agent:current:main",
|
||||||
|
theme: "claw",
|
||||||
|
themeMode: "system",
|
||||||
|
chatFocusMode: false,
|
||||||
|
chatShowThinking: true,
|
||||||
|
chatShowToolCalls: true,
|
||||||
|
splitRatio: 0.6,
|
||||||
|
navCollapsed: false,
|
||||||
|
navWidth: 220,
|
||||||
|
navGroupsCollapsed: {},
|
||||||
|
borderRadius: 50,
|
||||||
|
});
|
||||||
|
|
||||||
const scopedKey = `openclaw.control.settings.v1:${gwUrl}`;
|
|
||||||
const persisted = JSON.parse(localStorage.getItem(scopedKey) ?? "{}");
|
const persisted = JSON.parse(localStorage.getItem(scopedKey) ?? "{}");
|
||||||
|
|
||||||
expect(persisted.sessionsByGateway).toBeDefined();
|
expect(persisted.sessionsByGateway).toBeDefined();
|
||||||
expect(persisted.sessionsByGateway[gwUrl]).toEqual({
|
const scopes = Object.keys(persisted.sessionsByGateway);
|
||||||
sessionKey: "agent:test_11:main",
|
expect(scopes).toHaveLength(10);
|
||||||
lastActiveSessionKey: "agent:test_11:main",
|
// oldest stale entries should be evicted
|
||||||
|
expect(scopes).not.toContain("wss://stale-0.example:8443");
|
||||||
|
expect(scopes).not.toContain("wss://stale-1.example:8443");
|
||||||
|
// newest stale entries and the current gateway should be retained
|
||||||
|
expect(scopes).toContain("wss://stale-10.example:8443");
|
||||||
|
expect(scopes).toContain("wss://gateway.example:8443");
|
||||||
|
expect(persisted.sessionsByGateway["wss://gateway.example:8443"]).toEqual({
|
||||||
|
sessionKey: "agent:current:main",
|
||||||
|
lastActiveSessionKey: "agent:current:main",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user