Skip to content

Commit e118e60

Browse files
committed
fix: apply server preference deltas after read-only edits
1 parent 54e2ab5 commit e118e60

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎ui/src/app/server-prefs.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,35 @@ describe("pushServerUiPrefs", () => {
670670
expect(request).not.toHaveBeenCalled();
671671
});
672672

673+
it("applies the first server delta after a post-snapshot read-only edit", () => {
674+
const scope = "ws://read-only";
675+
const initial = configWithPrefs({ theme: "claw" });
676+
applyServerUiPrefs(initial, { scope, onApplied: vi.fn() });
677+
patchSettings({ theme: "knot" });
678+
679+
pushServerUiPrefs(
680+
createClient(vi.fn(), scope, true, { ok: true }, false),
681+
{ theme: "knot" },
682+
{
683+
afterCommit: ({ retainedLocal }) => {
684+
expect(retainedLocal).toBe(true);
685+
expect(applyServerUiPrefs(initial, { scope, onApplied: vi.fn() })).toBe(false);
686+
},
687+
},
688+
);
689+
690+
expect(
691+
localStorage.getItem(`openclaw.control.serverPrefs.retained-local.v1:${scope}`),
692+
).toBeNull();
693+
expect(
694+
applyServerUiPrefs(configWithPrefs({ theme: "dash" }), {
695+
scope,
696+
onApplied: vi.fn(),
697+
}),
698+
).toBe(true);
699+
expect(loadSettings().theme).toBe("dash");
700+
});
701+
673702
it("keeps offline intent through read-only reconnect and replays it after authorization", async () => {
674703
const scope = "ws://read-only";
675704
const request = vi.fn<(method: string, params?: unknown) => Promise<unknown>>(async () => ({}));

‎ui/src/app/server-prefs.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ export function applyServerUiPrefs(
504504
const key = JSON.stringify(prefs);
505505
const lastSeenRaw = readStorage(LAST_SEEN_KEY, scope);
506506
if (key === lastSeenRaw) {
507+
if (retainedLocalKeys.size) {
508+
updateRetainedLocalKeys(scope, [...retainedLocalKeys], false);
509+
}
507510
recordReconciledObject();
508511
return false;
509512
}

0 commit comments

Comments
 (0)