发布

  • [OPIK-6036] [FE] fix: namespace v2 agent-onboarding key by user (#6372)

    frostbyte_neo 发布于 2026-04-20 14:04:26 +00:00

    • [OPIK-6036] [FE] fix: namespace v2 agent-onboarding key by user

    The agent-onboarding localStorage key was shared across all accounts in the
    same browser. When a user logged out and a different person signed up, the
    previous user's "done" flag silently skipped onboarding for the new account.
    Key the entry by username so every account keeps its own completion state.
    A one-time migration moves any existing unscoped value into the current
    user's slot so returning users are not re-onboarded.

    Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

    • [OPIK-6036] [FE] fix: derive scoped key reactively on userName resolution

    The useState initializer froze the scoped key to agent-onboarding:default
    on first render because setAppUser runs inside a useEffect, so every
    logged-in user's onboarding state still collapsed into a shared bucket.
    Switch to useMemo so the key follows userName through the
    DEFAULT_USERNAME → real user transition, and gate legacy migration on a
    resolved user so the un-namespaced value is only moved into the correct
    slot. Migration stays synchronous inside the memo so the consumer's
    use-local-storage-state sees the migrated value on the same render that
    flips the key.

    • [OPIK-6036] [FE] fix: drop speculative legacy migration and gate onboarding gate on resolved user

    Addresses PR review feedback:

    1. The old migration copied the un-namespaced agent-onboarding blob into
      whichever user logged in first post-deploy. On a shared browser where
      user A had pre-PR {step: done}, a brand-new user B logging in first
      would inherit that done state and wrongly skip onboarding — the exact
      cross-account leak the hook was written to close. Drop the migration
      and let pre-PR users re-onboard once; the orphaned legacy key is
      removed in a useEffect so it doesn't linger.

    2. NewQuickstart rendered against DEFAULT_USERNAME on its first mount
      because WorkspacePreloader sets the real user inside a useEffect. For
      returning accounts with {step: done}, that produced a one-paint flash
      of the onboarding overlay before the key flipped to :.
      Return null while the user is still the default sentinel so the
      overlay only mounts once the scoped key is correct.

    • [OPIK-6036] [FE] fix: scope agent-onboarding localStorage key by workspace

    Replaces the userName-scoped hook and its loading gate with the existing
    inline workspace-suffix pattern used by ProjectDashboardsPage and
    InsightsTab. activeWorkspaceName is set synchronously by both
    WorkspacePreloader variants before children mount, so the key is stable
    from the first render — no hook, no gate, no store changes. Each Comet
    SaaS account lands in its own workspace, so this still fixes the A->B->A
    shared-browser leak the PR was opened for.

    • [OPIK-6036] [FE] fix: scope DemoProjectBanner onboarding reads by workspace

    After the agent-onboarding key is namespaced by workspace, the two
    consumers added in PR #6346 (DemoProjectBanner, useAutoCompleteAgentOnboarding)
    kept reading/writing the unscoped 'agent-onboarding' key. That broke both
    features: the banner never saw an active onboarding so it never showed,
    and the auto-complete effect wrote DONE to a slot nobody else reads.


    Co-authored-by: Claude Opus 4.7 noreply@anthropic.com

    下载附件