- Notifications
You must be signed in to change notification settings - Fork1k
Description
Bug Description
When a user claims a prebuild workspace, the workspace displays when the prebuild was originally created (e.g., "7 hours ago") rather than when the user actually claimed it (e.g., "7 minutes ago"). This is confusing for users who expect to see how recently they started using the workspace.
Steps to Reproduce
- Create a prebuild workspace and wait several hours
- Have a user claim the prebuild workspace
- Check the workspace list UI
- Notice the timestamp shows hours ago instead of minutes ago
Expected Behavior
The workspace should show when the user claimed it (e.g., "7 minutes ago")
Actual Behavior
The workspace shows when the prebuild was originally created (e.g., "7 hours ago")
Root Cause
Incoderd/workspaces.go
, when a prebuild workspace is claimed, theLastUsedAt
field is not updated. The workspace retains its originalLastUsedAt
timestamp from when the prebuild was created.
Proposed Fix
Update theLastUsedAt
field when claiming a prebuild workspace:
// Prebuild found!workspaceID=claimedWorkspace.IDinitiatorID=prebuildsClaimer.Initiator()// Update the LastUsedAt field to reflect when the user claimed the prebuilderr=db.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{ID:workspaceID,LastUsedAt:now,})iferr!=nil {returnxerrors.Errorf("update workspace last used at: %w",err)}
This ensures the timestamp reflects when the user actually started using the workspace, not when it was originally created as a prebuild.
Context:Slack