Skip to content

studio: keep general settings from restoring stale tokens - #12922

Merged
danielhanchen merged 1 commit into
unslothai:mainfrom
mahiatlinux:fix/studio-general-token-race
Oct 7, 2026
Merged

danielhanchen merged 1 commit into
unslothai:mainfrom
mahiatlinux:fix/studio-general-token-race

Conversation

@mahiatlinux

@mahiatlinux mahiatlinux commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Prevent General Settings from writing its mount-time Hugging Face token over a newer credential saved in another browser tab.

  • Track local edit and submission revisions in GeneralTab, so untouched drafts follow shared credential updates while active edits remain authoritative.
  • Adopt the backend's reconciled token after successful persistence, preserve retryable drafts after failed saves, and guard blur/unmount windows before passive effects run.
  • Add lifecycle regression coverage for cross-tab refreshes, focused-field close, in-flight writes, newer local typing, backend reconciliation, and failed-save retries.

Checks

  • node --experimental-strip-types --test tests/general-settings-token-sync.test.ts (9 passed)
  • npx eslint tests/general-settings-token-sync.test.ts
  • npm run typecheck
  • npm run build

Before / after (two browser tabs)

Merge base 996a03fd5 vs head c2767ee9e, two isolated Studio installs, Chromium. Tab A opens Settings > General with the saved token hf_stale...; tab B (same browser, shared localStorage) saves hf_newer...; then tab A is screenshotted with the token revealed and its dialog closed.

Settings General HF token, tab A after tab B saved a newer token

Before After
Tab A field after tab B saved hf_stale... hf_newer...
Saved token after tab A closes Settings hf_stale... (overwritten) hf_newer... (kept)

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

6 similar comments
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed that on main the General tab's close handler in general-tab.tsx can write its stale draft over a token saved from another tab, and the edit tracking here closes that. Will get this reviewed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants