-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
In coderd/workspaces.go, when a prebuild workspace is claimed, the LastUsedAt field is not updated. The workspace retains its original LastUsedAt timestamp from when the prebuild was created.
Proposed Fix
Update the LastUsedAt field when claiming a prebuild workspace:
// Prebuild found!
workspaceID = claimedWorkspace.ID
initiatorID = prebuildsClaimer.Initiator()
// Update the LastUsedAt field to reflect when the user claimed the prebuild
err = db.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{
ID: workspaceID,
LastUsedAt: now,
})
if err != nil {
return xerrors.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