Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: convert workspaceTokenExpiresAt from ref to plain let in workspaceAuthStore

Open
#13,105 1 comment 1 reaction 1 assignee Claimed by @christian-byrne View on GitHub
area:auth
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

`workspaceTokenExpiresAt` in `src/platform/workspace/stores/workspaceAuthStore.ts` is currently declared as a reactive `ref`:

```ts
const workspaceTokenExpiresAt = ref(null)
```

However, it is:
- **Not exported** from the store's public interface.
- **Not used reactively** (no computed/watch depends on it).
- **Only read imperatively** in `scheduleTokenRefreshRetry()` and `hasValidWorkspaceToken()`.

The sibling internal-control variables (`refreshRequestId`, `refreshTimerId`, `inFlightSwitchCount`, `scheduledRefreshRetryCount`) are all plain `let` variables, so making this consistent would reduce unnecessary reactivity overhead and remove noisy `.value` accesses at the call sites.

## Proposed Change

Convert the declaration to a plain module-scoped variable:

```ts
let workspaceTokenExpiresAt: number | null = null
```

Update all `.value` accesses within the store accordingly (e.g., `workspaceTokenExpiresAt.value` → `workspaceTokenExpiresAt`).

## Affected File

- `src/platform/workspace/stores/workspaceAuthStore.ts`

## Acceptance Criteria

- [ ] `workspaceTokenExpiresAt` is a plain `let` variable (not a `ref`).
- [ ] All `.value` accesses are removed.
- [ ] No reactive behaviour is lost (it is not currently reactive).
- [ ] Existing unit tests in `src/platform/workspace/stores/useWorkspaceAuth.test.ts` continue to pass.

## Context

Raised during review of PR #11726 (comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/11726#discussion_r3176260783).
Deferred as a non-blocking cleanup to a follow-up PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.