Skip to content

Self-heal Nuxt UserProfile popup on open, fix schemas/userSchema mismatch - #84

Merged
brionmario merged 1 commit into
thunder-id:mainfrom
janithjay:fix-nuxt-native-profile-not-rendering
Aug 18, 2026
Merged

Self-heal Nuxt UserProfile popup on open, fix schemas/userSchema mismatch#84
brionmario merged 1 commit into
thunder-id:mainfrom
janithjay:fix-nuxt-native-profile-not-rendering

Conversation

@janithjay

Copy link
Copy Markdown
Contributor

Purpose

The Nuxt UserProfile popup (<UserDropdown> → "Profile") renders blank after a native/embedded sign-in until the page is manually refreshed. Redirect-flow sign-in doesn't show this.

Approach

  • userProfileState/userSchemaState are populated only during SSR, by the thunderid-ssr.ts Nitro plugin - nothing re-fetches them client-side after sign-in. Native sign-in does trigger a full page reload on completion, which should re-run SSR, but the very first SSR pass right after a fresh session is issued can still come back empty.

  • UserDropdown.ts already had a revalidateProfile() function available from useUser() - built for refreshing state after a profile update - but never called it when the popup opens. It called useUser() for its side effect only and discarded the result, so the popup just displayed whatever SSR happened to seed, with no way to recover from an empty first pass short of a full page refresh.

Changes

  • components/user/UserDropdown.ts - onProfileClick now calls revalidateProfile() on every open, making the popup self-healing regardless of SSR timing.
  • server/routes/auth/user/profile.get.ts - extended to also fetch and return userSchema (previously profile-only), so revalidation restores schema-driven fields too, not just raw profile data. Schema-fetch failure doesn't fail the whole
    response.
  • components/ThunderIDRoot.ts - revalidateProfile() now updates userSchemaState from the extended response, not just userProfileState.
  • components/user/UserProfile.ts - separate, related bug found while tracing this, destructured a schemas field from useUser() that doesn't exist onUserContextValue (real field is userSchema), passed to BaseUserProfile's wrong prop. Not the cause of the reported issue (UserDropdown renders @thunderid/vue's UserProfile directly, not this file), but a real break for anyone using nuxt's standalone <UserProfile> component directly. Also added the missing profile prop (only flattenedProfile was being passed).

After fix

Screen.Recording.2026-08-18.at.1.14.43.PM.mov

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Copilot AI lite review requested due to automatic review settings August 18, 2026 07:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c2d548f9-d896-4749-8e52-a00fb7f215ef


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: janithjay <janithjayashan018@gmail.com>
@janithjay
janithjay force-pushed the fix-nuxt-native-profile-not-rendering branch from 3b316bc to 31964e9 Compare August 18, 2026 07:46
if (res) userProfileState.value = res;
const res: (UserProfile & {userSchema?: Record<string, AttributeSchema> | null}) | null = await $fetch<
UserProfile & {userSchema?: Record<string, AttributeSchema> | null}
>('/api/auth/user/profile');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to move these paths to constants. @coderabbitai can you create an issue for this on https://github.com/thunder-id/thunderid

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

gh issue list \
  --repo thunder-id/thunderid \
  --state open \
  --search 'Nuxt API route paths constants in:title,body' \
  --limit 20 \
  --json number,title,url,body

Length of output: 343


🏁 Script executed:

#!/bin/bash
set -euo pipefail

body=$(cat <<'EOF'
## Summary

Extract the Nuxt SDK API route paths into shared constants.

## Rationale

`ThunderIDRoot` uses route string literals for the profile endpoint. Shared constants reduce repeated route strings and prevent route updates from becoming inconsistent across Nuxt runtime modules.

## Affected areas

- `packages/nuxt/src/runtime/components/ThunderIDRoot.ts`
- Other Nuxt runtime components, plugins, middleware, and Nitro handlers that use the same `/api/auth/*` route paths

## Required changes

1. Define and export shared constants for Nuxt SDK API route paths.
2. Replace repeated route string literals with the shared constants.
3. Keep the constants in the appropriate Nuxt package layer. Do not duplicate them across runtime modules.
4. Preserve the current request methods and route behavior.

## Acceptance criteria

- Nuxt API route paths used by more than one runtime module resolve through shared constants.
- `ThunderIDRoot` uses the shared constants for profile fetch and profile update requests.
- No duplicate or inconsistent route path literals remain in the affected Nuxt runtime modules.
- The changes meet the repository ESLint and Prettier requirements.

## Backlinks

- Source pull request: https://github.com/thunder-id/javascript-sdks/pull/84
- Source review comment: https://github.com/thunder-id/javascript-sdks/pull/84#discussion_r3802082276
- Requested by: `@brionmario`
EOF
)

gh issue create \
  --repo thunder-id/thunderid \
  --title 'Extract Nuxt SDK API route paths into shared constants' \
  --body "$body" \
  --assignee brionmario

Length of output: 1811


@brionmario, created and assigned thunder-id/thunderid#5060: “Extract Nuxt SDK API route paths into shared constants.”

You are interacting with an AI system.

@brionmario
brionmario merged commit 57ce237 into thunder-id:main Aug 18, 2026
6 checks passed
@janithjay
janithjay deleted the fix-nuxt-native-profile-not-rendering branch August 18, 2026 07:56
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.

UserProfile component doesn't render at first after native sign-in in Nuxt

3 participants