Skip to content

feat(web): add window._vellumDebug.flags.impersonateVersion debug helper#32291

Merged
dvargasfuertes merged 1 commit into
mainfrom
apollo/impersonate-assistant-version-debug-flag
May 27, 2026
Merged

feat(web): add window._vellumDebug.flags.impersonateVersion debug helper#32291
dvargasfuertes merged 1 commit into
mainfrom
apollo/impersonate-assistant-version-debug-flag

Conversation

@vellum-apollo-bot
Copy link
Copy Markdown
Contributor

What

Adds a console helper for testing version-gated behavior in the web client without rebuilding the assistant or swapping runtimes:

window._vellumDebug.flags.impersonateVersion("0.8.6")  // set + reload
window._vellumDebug.flags.impersonateVersion(null)     // clear + reload
window._vellumDebug.flags.impersonateVersion()         // inspect-only

Why

Follow-on to #32234. Now that the web client has multiple version-gated paths (pickConversationIdWireField, supportsServerMintedConversation, useFlagQueryFreshness, useAssistantSupports, …) and the 0.8.6 cutover is live, we want a one-liner way to validate each behavior end-to-end against a real assistant build.

How

  • New flag module: apps/web/src/lib/backwards-compat/impersonate-version-flag.ts. localStorage-backed, reloads on change. DX parallels the existing toggleTranscriptScrollController.
  • Assistant identity store's setIdentity consults the override and substitutes its value on every write. Single point of indirection — initial fetch, SSE identity_changed, optimistic onboarding seed all funnel through setIdentity, so every consumer of useAssistantIdentityStore sees the impersonated value with no consumer changes required.
  • Exposed via _vellumDebug.flags.impersonateVersion.

Tests

10 new tests in impersonate-version-flag.test.ts:

  • localStorage round-trip
  • inspect-only mode (no reload, no mutation)
  • explicit null / empty string clears
  • identity store substitutes impersonated version regardless of caller arg
  • pass-through when no override is set
  • restoration after clear

Presence assertion added to debug-api.test.ts.

49/49 pass; tsc + eslint clean on touched files.

Out of scope

  • Visible UI banner when impersonation is active (could add later if it becomes a forgetting hazard; for now impersonateVersion() with no args logs+returns current value).

Adds a dev console helper for testing version-gated behavior in the web
client without rebuilding the assistant or swapping runtimes.

Usage:
  window._vellumDebug.flags.impersonateVersion("0.8.6")  // set + reload
  window._vellumDebug.flags.impersonateVersion(null)     // clear + reload
  window._vellumDebug.flags.impersonateVersion()         // inspect-only

Mechanism: the flag persists to localStorage and reloads. The assistant
identity store's setIdentity action consults
getImpersonatedAssistantVersion() and substitutes its value on every
write — initial identity fetch, SSE identity_changed, and the
optimistic onboarding seed all funnel through setIdentity, so the
override is uniformly applied. Every existing version gate
(useAssistantSupports, pickConversationIdWireField,
supportsServerMintedConversation, useFlagQueryFreshness, …) reads from
the store and gets the impersonated value for free, no consumer changes.

DX parallels the existing toggleTranscriptScrollController flag:
localStorage-backed, reloads on change so the world stays consistent.

Files:
  - apps/web/src/lib/backwards-compat/impersonate-version-flag.ts (new)
  - apps/web/src/lib/backwards-compat/impersonate-version-flag.test.ts (new)
  - apps/web/src/stores/assistant-identity-store.ts (consult flag)
  - apps/web/src/domains/chat/utils/debug-api.ts (expose under .flags)
  - apps/web/src/domains/chat/utils/debug-api.test.ts (presence assertion)

Tests: 49/49 pass (10 new for the flag + identity-store override path).
tsc + eslint clean on touched files.
@dvargasfuertes dvargasfuertes merged commit ef1d5f9 into main May 27, 2026
7 checks passed
@dvargasfuertes dvargasfuertes deleted the apollo/impersonate-assistant-version-debug-flag branch May 27, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant