From a196a68d38ab639b88e3e4210f87d25639c49d2b Mon Sep 17 00:00:00 2001 From: Melody Ruch <396921921@qq.com> Date: Sat, 5 Sep 2026 13:17:56 +0800 Subject: [PATCH] fix(redis): sync detail pane size badge on auto refresh --- .../src/components/redis/RedisValueViewer.expiry.spec.ts | 7 +++++-- apps/desktop/src/components/redis/RedisValueViewer.vue | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/components/redis/RedisValueViewer.expiry.spec.ts b/apps/desktop/src/components/redis/RedisValueViewer.expiry.spec.ts index 8db77633c9..81ea1bf070 100644 --- a/apps/desktop/src/components/redis/RedisValueViewer.expiry.spec.ts +++ b/apps/desktop/src/components/redis/RedisValueViewer.expiry.spec.ts @@ -314,7 +314,7 @@ describe("RedisValueViewer expiry saving", () => { expect(document.querySelector("[data-slot='badge'][aria-label='redis.expiry']")?.textContent).toContain("50s"); }); - it("polls the full value at the configured interval without refreshing the parent key tree", async () => { + it("polls the full value at the configured interval and reports it to the parent", async () => { vi.useFakeTimers(); localStorage.setItem("dbx-redis-auto-refresh-enabled-v2", "true"); localStorage.setItem("dbx-redis-auto-refresh-interval-seconds-v2", "5"); @@ -328,7 +328,10 @@ describe("RedisValueViewer expiry saving", () => { expect(mocks.redisGetValue).toHaveBeenCalledTimes(2); expect(mocks.redisGetTtl).not.toHaveBeenCalled(); - expect(loaded).toHaveBeenCalledOnce(); + // The parent holds the key record the detail header's size badge reads, so + // a poll has to report the refreshed value for the badge to follow it. + expect(loaded).toHaveBeenCalledTimes(2); + expect(loaded.mock.calls[1][0]).toMatchObject({ ttl: 45 }); expect(document.querySelector("textarea")?.value).toBe("refreshed"); expect(document.querySelector("[data-slot='badge'][aria-label='redis.expiry']")?.textContent).toContain("45s"); }); diff --git a/apps/desktop/src/components/redis/RedisValueViewer.vue b/apps/desktop/src/components/redis/RedisValueViewer.vue index 8ac915d29b..abfd71b954 100644 --- a/apps/desktop/src/components/redis/RedisValueViewer.vue +++ b/apps/desktop/src/components/redis/RedisValueViewer.vue @@ -334,10 +334,13 @@ async function refreshAutoValue() { const requestId = ++autoRefreshRequestId; refreshingValue.value = true; try { + // The parent owns the key record this panel's header reads its size badge + // from, so a poll that skipped notifying it left the badge frozen at the + // value the key had when it was opened. Notifying is cheap: the parent + // refreshes that one record's metadata in place. const applied = await load({ background: true, preserveDraft: true, - notifyParent: false, shouldApply: () => requestId === autoRefreshRequestId && !hasUnsavedRedisDraft.value && !shouldPauseAutoValueRefresh() && autoRefreshEnabled.value && canRunAutoRefresh(), }); if (requestId !== autoRefreshRequestId || !applied || !data.value) return;