fix(redis): sync detail pane size badge on auto refresh

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-09-05 13:17:56 +08:00
1 parent 9e9e20a57b
commit a196a68d38
2 files changed
+9 -3

No files matched your search

@@ -314,7 +314,7 @@ describe("RedisValueViewer expiry saving", () => {
expect(document.querySelector<HTMLElement>("[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<HTMLTextAreaElement>("textarea")?.value).toBe("refreshed");
expect(document.querySelector<HTMLElement>("[data-slot='badge'][aria-label='redis.expiry']")?.textContent).toContain("45s");
});
@@ -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;