Skip to content

Add periodic timestamp updates to timeline events#7286

Merged
alexr00 merged 6 commits intomainfrom
copilot/fix-7006
Jul 14, 2025
Merged

Add periodic timestamp updates to timeline events#7286
alexr00 merged 6 commits intomainfrom
copilot/fix-7006

Conversation

Copy link
Contributor

Copilot AI commented Jul 14, 2025

Timeline timestamps now update periodically to match GitHub.com behavior. Previously, relative timestamps like "3 weeks ago" or "6 minutes ago" were static and never changed, even as time passed.

Problem

As shown in the issue screenshots, timestamps in the VS Code extension remained static:

  • "3 weeks ago" stayed "3 weeks ago" indefinitely
  • "6 minutes ago" never updated to "seconds ago"

On GitHub.com, these timestamps update automatically over time to reflect the current relative time.

Solution

Modified the Timestamp component to use React hooks with smart update intervals:

// Variable update intervals based on timestamp age
const getUpdateInterval = () => {
  const ageInMinutes = (now - timestamp) / (1000 * 60);
  
  if (ageInMinutes < 60) return 60000;        // 1 minute for recent items
  else if (ageInMinutes < 60 * 24) return 5 * 60000;  // 5 minutes for older items
  else return 15 * 60000;                     // 15 minutes for very old items
};

Key Features

  • Automatic Updates: Timestamps refresh at appropriate intervals using setInterval
  • Performance Optimized:
    • Recent timestamps (< 1 hour) update every minute
    • Older timestamps (< 1 day) update every 5 minutes
    • Very old timestamps (> 1 day) update every 15 minutes
  • Visibility Detection: Updates pause when page is hidden and resume when visible
  • Resource Efficient: Proper cleanup of timers and event listeners

Result

Timeline events now show dynamic timestamps that update automatically:

  • "6 minutes ago" → "seconds ago" (after time passes)
  • "3 weeks ago" → "seconds ago" (when viewing recently)

This provides a more accurate and GitHub.com-like experience for users viewing pull request timelines.

Fixes #7006.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits July 14, 2025 08:35
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
…ection

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Can times in the timeline update periodically? Add periodic timestamp updates to timeline events Jul 14, 2025
Copilot AI requested a review from alexr00 July 14, 2025 08:46
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Great start. A few changes:

Copy link
Member

Choose a reason for hiding this comment

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

Don't touch yarn.lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted yarn.lock changes. Fixed in commit 8e37b7b.

Copy link
Member

Choose a reason for hiding this comment

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

This file seems unneeded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed .eslintcache.browser file. Fixed in commit 8e37b7b.

Comment on lines +24 to +36
// For very recent timestamps (< 1 hour), update every minute
if (ageInMinutes < 60) {
return 60000; // 1 minute
}
// For timestamps < 1 day old, update every 5 minutes
else if (ageInMinutes < 60 * 24) {
return 5 * 60000; // 5 minutes
}
// For older timestamps, update less frequently or not at all
// since they likely show absolute dates
else {
return 15 * 60000; // 15 minutes
}
Copy link
Member

Choose a reason for hiding this comment

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

Please update times less than 1 minute ago every 20 seconds. Times less than an hour, every 2 minutes. If it's older than a day, don't update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated timing intervals as requested:

  • Times < 1 minute: update every 20 seconds
  • Times < 1 hour: update every 2 minutes
  • Times > 1 day: don't update at all

Fixed in commit 8e37b7b.

…, no updates for >1day

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI requested a review from alexr00 July 14, 2025 10:31
@alexr00 alexr00 marked this pull request as ready for review July 14, 2025 10:42
@vs-code-engineering vs-code-engineering bot added this to the July 2025 milestone Jul 14, 2025
@alexr00 alexr00 merged commit a0be54f into main Jul 14, 2025
3 checks passed
@alexr00 alexr00 deleted the copilot/fix-7006 branch July 14, 2025 15:47
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.

Can times in the timeline update periodically?

3 participants