@@ -36,7 +36,7 @@ import (
3636"github.com/coder/quartz"
3737)
3838
39- const workspaceCacheRefreshInterval = 5 * time .Minute
39+ const workspaceCacheRefreshInterval = 1 * time .Minute
4040
4141// API implements the DRPC agent API interface from agent/proto. This struct is
4242// instantiated once per agent connection and kept alive for the duration of the
@@ -69,7 +69,7 @@ type Options struct {
6969WorkspaceID uuid.UUID
7070OrganizationID uuid.UUID
7171
72- Ctx context.Context
72+ AuthenticatedCtx context.Context
7373Log slog.Logger
7474Clock quartz.Clock
7575Database database.Store
@@ -220,7 +220,7 @@ func New(opts Options, workspace database.Workspace) *API {
220220
221221// Start background cache refresh loop to handle workspace changes
222222// like prebuild claims where owner_id and other fields may be modified in the DB.
223- go api .startCacheRefreshLoop (opts .Ctx )
223+ go api .startCacheRefreshLoop (opts .AuthenticatedCtx )
224224
225225return api
226226}
@@ -275,6 +275,7 @@ func (a *API) agent(ctx context.Context) (database.WorkspaceAgent, error) {
275275// This ensures that changes like prebuild claims (which modify owner_id, name, etc.)
276276// are eventually reflected in the cache without requiring agent reconnection.
277277func (a * API )refreshCachedWorkspace (ctx context.Context ) {
278+ a .opts .Log .Debug (ctx ,"refreshing cached workspace" ,slog .F ("test" ,"test" ))
278279ws ,err := a .opts .Database .GetWorkspaceByID (ctx ,a .opts .WorkspaceID )
279280if err != nil {
280281a .opts .Log .Warn (ctx ,"failed to refresh cached workspace fields" ,slog .Error (err ))