Skip to content

last drop time fix#1600

Merged
simo6529 merged 2 commits intomainfrom
last-drop-ts-fix
Nov 6, 2025
Merged

last drop time fix#1600
simo6529 merged 2 commits intomainfrom
last-drop-ts-fix

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Nov 6, 2025

Summary by CodeRabbit

  • Refactor
    • More consistent and accurate time labels across the UI via an updated timestamp update mechanism.
    • Time labels now refresh when the displayed reference time changes, ensuring visible age indicators stay up to date.

Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 6, 2025

Walkthrough

A component's time tracking is refactored from a tick counter to a timestamp state updated via window.setInterval/clearInterval, with an effect to sync on prop changes; the time-format helper now accepts an optional referenceTime parameter so callers can supply the component's tracked timestamp.

Changes

Cohort / File(s) Summary
Time state & interval refactor
components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx
Reorders React imports, replaces local tick state with now timestamp initialized to Date.now(), uses window.setInterval to update now each minute and window.clearInterval on cleanup, adds effect to sync now when time prop changes, computes a label via getTimeAgoShort(time, now) and renders it.
Helper signature change
helpers/Helpers.ts
Changes getTimeAgoShort(milliseconds: number)getTimeAgoShort(milliseconds: number, referenceTime: number = Date.now()) and uses referenceTime - milliseconds for the time difference calculation.

Sequence Diagram

sequenceDiagram
    participant Comp as BrainLeftSidebarWaveDropTime
    participant Timer as window.setInterval
    participant Helper as getTimeAgoShort
    participant Render as React Render

    Comp->>Comp: now = Date.now() (init)
    Comp->>Timer: setInterval(callback, 60000)
    Note right of Timer: Callback runs every minute
    loop every minute
        Timer->>Comp: invoke callback
        Comp->>Comp: now = Date.now() (update)
        Comp->>Helper: getTimeAgoShort(time, now)
        Helper-->>Comp: label (computed with referenceTime)
        Comp->>Render: re-render with label
    end
    alt on prop `time` change
        Component->>Component: effect updates now = Date.now()
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing extra attention:
    • Interval setup/teardown correctness (use of window.setInterval/clearInterval and dependency list).
    • Effect that syncs now on time prop changes to ensure no stale labels.
    • Calls to getTimeAgoShort across the codebase that may rely on the previous single-argument signature (confirm default parameter covers them).

Poem

🐰
From ticks to now I softly hop,
I watch the minutes gently drop,
A timestamp held, a label sings—
Time measured by sure little springs,
The meadow marks each passing hop.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'last drop time fix' is specific and directly reflects the main change: fixing how drop time is calculated by introducing a reference time parameter to getTimeAgoShort and synchronizing it across the component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch last-drop-ts-fix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd1169c and b200271.

📒 Files selected for processing (1)
  • components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c79285 and fd1169c.

📒 Files selected for processing (2)
  • components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx (2 hunks)
  • helpers/Helpers.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Do not include any comments in the code
Use react-query for data fetching
Always add readonly before props

Files:

  • components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx
  • helpers/Helpers.ts
**/*.tsx

📄 CodeRabbit inference engine (.cursorrules)

**/*.tsx: Use FontAwesome for icons
Use TailwindCSS for styling

Files:

  • components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx
🧬 Code graph analysis (1)
components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx (2)
helpers/time.ts (1)
  • now (7-9)
helpers/Helpers.ts (1)
  • getTimeAgoShort (563-589)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
helpers/Helpers.ts (1)

563-567: LGTM! Improved testability and backward compatibility.

The addition of the optional referenceTime parameter enhances testability while maintaining backward compatibility through the default value. This allows callers to pass a consistent reference timestamp for multiple time calculations, which aligns well with the component changes in BrainLeftSidebarWaveDropTime.tsx.

components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx (2)

13-13: Good use of function initializer.

Using () => Date.now() ensures the initial timestamp is computed only once during component mount, which is the correct pattern for expensive or time-sensitive initialization.


25-27: LGTM! Clean time calculation with explicit reference.

Passing the now state to getTimeAgoShort makes the time calculation explicit and enables consistent rendering. The refactor from a tick counter to a timestamp state is semantically clearer while maintaining the same update frequency.

Comment thread components/brain/left-sidebar/waves/BrainLeftSidebarWaveDropTime.tsx Outdated
Signed-off-by: Simo <simo@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Nov 6, 2025

@simo6529 simo6529 merged commit 01b1226 into main Nov 6, 2025
8 checks passed
@simo6529 simo6529 deleted the last-drop-ts-fix branch November 6, 2025 13:58
@coderabbitai coderabbitai Bot mentioned this pull request Jan 9, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 8, 2026
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.

2 participants