X Tutup
Skip to content

Show token expiration date in options#8847

Merged
fregante merged 13 commits intomainfrom
copilot/show-token-expiration-date
Jan 5, 2026
Merged

Show token expiration date in options#8847
fregante merged 13 commits intomainfrom
copilot/show-token-expiration-date

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Displays token expiration inline with the username using Intl.RelativeTimeFormat for natural language formatting. Uses GitHub-Authentication-Token-Expiration header to show days remaining. Expiration info is only shown when token validation succeeds.

Changes:

  • Added getTokenInfo() combining scopes and expiration fetch (eliminates duplicate API call)
  • Extended token validation to calculate and display expiration status
  • Displays expiration inline with username (e.g., @fregante, expires in 40 days)
  • Uses Intl.RelativeTimeFormat with numeric: 'auto' for proper date formatting
  • Automatically handles special cases: "today", "tomorrow", "in X days", "X days ago"
  • Shows "no expiration" for classic tokens without expiration dates
  • Builds status message as a single string only when validation succeeds (prevents expiration text on error/loading states)
  • Simplified date calculation using Date.now() inline
  • Removed redundant getTokenScopes and getTokenExpiration helper functions
  • Optimized RTF instance creation at module level for efficiency

Format examples:

  • @fregante, no expiration (classic tokens)
  • @fregante, expires in 40 days
  • @fregante, expires today (automatic via RTF)
  • @fregante, expired 5 days ago (automatic for past dates)

States handled correctly:

  • Empty/validating: No expiration text appended
  • Error states: Just the error message (e.g., "Bad credentials")
  • Valid tokens: Username with expiration info combined as single string

Test URLs

Extension options page

Screenshot

Before (current state in issue):

After (final implementation):

Original prompt

This section details on the original issue you should resolve

<issue_title>Show token expiration date in options</issue_title>
<issue_description>### Description

We could show a ⚠️ Token expires in x days message here, changing the emoji to ℹ️ when days > 30

Screenshot

Related to:

Example URLs

options page</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 4, 2026 10:27
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copilot AI changed the title [WIP] Show token expiration date in options page Show token expiration date in options Jan 4, 2026
Copilot AI requested a review from fregante January 4, 2026 10:38
Copilot AI and others added 2 commits January 4, 2026 12:43
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copilot AI requested a review from fregante January 4, 2026 12:47
Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

@fregante fregante marked this pull request as ready for review January 5, 2026 08:08
@fregante fregante added the meta Related to Refined GitHub itself label Jan 5, 2026
…message

Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copilot AI requested a review from fregante January 5, 2026 08:14
@fregante
Copy link
Member

fregante commented Jan 5, 2026

@copilot place it inline again.

Use Intl.RelativeTimeFormat to calculate that "in x days" string. It natively switches to "today" if the parameter is is (0, "days")

Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot place it inline again.

Done! Moved expiration back inline with username and using Intl.RelativeTimeFormat with numeric: 'auto' which natively handles "today" when days is 0.

Format examples:

  • @fregante, no expiration
  • @fregante, expires in 40 days
  • @fregante, expires today (automatic via RTF)
  • @fregante, expired

Commit: 013d009

Updated implementation

Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
@fregante
Copy link
Member

fregante commented Jan 5, 2026

@copilot The additional text should be removed when not relevant. I think it should be part of a single string applied once (user + expiration)

But currently I see these states, which don't make sense

  • Bad credentials, no expiration
  • Validating..., no expiration

Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot The additional text should be removed when not relevant. I think it should be part of a single string applied once (user + expiration)

But currently I see these states, which don't make se...

Fixed! The expiration info is now built as a single string and only added when we have valid user data. Error states and loading states no longer show the expiration text.

States now work correctly:

  • Empty/validating: No expiration text
  • Bad credentials: Just the error message
  • Valid token: @username, expires in X days / @username, no expiration

Commit: 56693b3

Fixed states

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Image Image Image Image Image

@fregante fregante merged commit e20eff5 into main Jan 5, 2026
8 checks passed
@FloEdelmann FloEdelmann deleted the copilot/show-token-expiration-date branch January 7, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

Show token expiration date in options

2 participants

X Tutup