Skip to content

Delete inactive clients/sessions#959

Open
jmattheis wants to merge 6 commits intomasterfrom
expiry
Open

Delete inactive clients/sessions#959
jmattheis wants to merge 6 commits intomasterfrom
expiry

Conversation

@jmattheis
Copy link
Copy Markdown
Member

This MR includes:

  • Add createdAt fields to all models
  • Add expiresAfterInactivitySeconds to client
  • Clean up inactive clients

fixes #943

@jmattheis jmattheis requested a review from a team as a code owner May 9, 2026 20:17
@jmattheis jmattheis changed the title Expiry Delete inactive clients/sessions May 9, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

❌ Patch coverage is 75.90361% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.93%. Comparing base (ec8ce07) to head (81a43a8).

Files with missing lines Patch % Lines
database/client.go 57.89% 4 Missing and 4 partials ⚠️
router/router.go 0.00% 7 Missing ⚠️
database/database.go 71.42% 2 Missing and 2 partials ⚠️
app.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #959      +/-   ##
==========================================
- Coverage   75.01%   74.93%   -0.09%     
==========================================
  Files          61       62       +1     
  Lines        2886     2948      +62     
==========================================
+ Hits         2165     2209      +44     
- Misses        566      578      +12     
- Partials      155      161       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmattheis jmattheis mentioned this pull request May 9, 2026
8 tasks
Comment thread router/router.go
if err := db.UpdateClientTokensLastUsed(connectedTokens, &now); err != nil {
log.Println("Error updating last used", err)
}
if expired, err := db.CleanupExpiredClients(now); err == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think as with last time we shouldn't have significant unusable precision on the schema.

If we can only process this every minute let use expiresAfter...Minutes or hours instead

Comment thread ui/src/client/Clients.tsx
</TableCell>
<TableCell className="expires-in">
{expiresAt ? (
<TimeAgo date={expiresAt} formatter={TimeAgoFormatter.longMinutes} />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same thing, this format should be unified as minutes or hours, minutes.

I think the ability to glance through this column is more important than the exact timestamp represented in a changing formatting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean that the units for all rows are the same, so only hours and minutes are displayed even if the client expires in days or months?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, like all X hours, Y minutes or some other format that makes sense for scanning and glancing I think.

@eternal-flame-AD
Copy link
Copy Markdown
Member

Another option for this to work precisely is to memoize an expiresAt field updated along with lastUsed, and predicate all client selections with a condition.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Periodically delete inactive client sessions

2 participants