Skip to content

Keep relative update times advancing while the panel is open - #1006

Open
Finesssee wants to merge 1 commit into
mainfrom
fix/relative-time-tick
Open

Finesssee wants to merge 1 commit into
mainfrom
fix/relative-time-tick

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

"Updated N ago" labels were computed once per render. They used Date.now() as a default argument and only re-rendered when data changed, so a panel left open kept saying "Updated just now" (or an old minute count) until something else updated.

This change adds a small hook, useNow() (apps/desktop-tauri/src/hooks/useNow.ts). It returns the current time and re-reads it every 15 seconds (NOW_TICK_MS). Each interval is cleared on unmount. The hook is used where relative times are shown:

  • components/card/CardHeader.tsx: the card subtitle ("Updated N ago").
  • surfaces/settings/providers/ProviderDetailPane.tsx: the provider detail "Updated" line.
  • hooks/useTrayPanelController.ts: the service-status line under the tray provider actions (" — updated N ago").
  • components/QuotaBurndownChart.tsx: the capture-age caption. The hook is called above the component's early returns. The nowMs prop is now optional: an explicit value still wins (tests and callers that pass it are unchanged), otherwise the live clock is used.

No backend or locale changes. Files changed: 5 modified, 2 new (useNow.ts, useNow.test.ts).

Checks

  • pnpm test -- --maxWorkers=4 (apps/desktop-tauri): 165 files, 1621 tests passed, 0 failed.
  • Focused: useNow.test.ts 3 passed; CardHeader.test.tsx 13 passed (includes the new tick test); QuotaBurndownChart.test.tsx 3 passed; serviceStatus.test.ts 3 passed; ProviderDetailPane.test.tsx 9 passed.
  • pnpm run build: passed. The chunk-size warning is pre-existing.
  • pnpm proof:check: 45/45 scenarios passed (Chromium, mocked IPC). Screenshots under apps/desktop-tauri/.proof/screens.
  • Rust: not changed on this branch, so no cargo run.

New tests

  • src/hooks/useNow.test.ts:
    • starts at the current time and re-reads it after one tick (fake timers);
    • does not re-render before the first tick;
    • clears its interval on unmount.
  • src/components/card/CardHeader.test.tsx: "advances the update subtitle while the data stays unchanged". The subtitle goes from "Updated just now" to "Updated 1m ago" after 60 fake seconds, with no prop change.

Proof

  • Automated: the fake-timer tests above (jsdom) and the existing proof scenarios (no regressions).
  • No proof scenario was added for the tick itself. A scenario would need to wait real time or drive timers inside the proof page, and the 15-second cadence is not practical to assert in a headless run.

Not done

  • No desktop proof. The real panel should be left open for a few minutes with data that stops updating, then the subtitle and the detail "Updated" line should move from "just now" to "1m ago" and onward, without any click or refresh. This needs a CUA loop on a rebuilt desktop binary.
  • Other relative-time displays were left as they were: the CardMetricRow countdown (useCountdownNow, already ticks) and useFormattedResetTime (already ticks every 30 seconds). FloatBar's own timestamp was not reviewed.
  • Each card mounts its own 15-second interval. That is a handful of timers and was judged fine; a shared clock store could replace them if the provider count grows.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 96d5531 and 5191c01.

📒 Files selected for processing: 7
  • apps/desktop-tauri/src/components/QuotaBurndownChart.tsx
  • apps/desktop-tauri/src/components/card/CardHeader.test.tsx
  • apps/desktop-tauri/src/components/card/CardHeader.tsx
  • apps/desktop-tauri/src/hooks/useNow.test.ts
  • apps/desktop-tauri/src/hooks/useNow.ts
  • apps/desktop-tauri/src/hooks/useTrayPanelController.ts
  • apps/desktop-tauri/src/surfaces/settings/providers/ProviderDetailPane.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant