Skip to content

feat(PlexImportModal): add user details sync functionality#2977

Open
0xSysR3ll wants to merge 2 commits intodevelopfrom
0xsysr3ll/feat/plex-users-sync
Open

feat(PlexImportModal): add user details sync functionality#2977
0xSysR3ll wants to merge 2 commits intodevelopfrom
0xsysr3ll/feat/plex-users-sync

Conversation

@0xSysR3ll
Copy link
Copy Markdown
Contributor

@0xSysR3ll 0xSysR3ll commented Apr 29, 2026

Description

This PR improves the Plex user import flow by allowing it to act as a sync when no new users are available.

This avoids the previous dead-end where admins couldn't do anything if no new users were found, even when they just needed to refresh existing ones.

How Has This Been Tested?

  • Imported a user
  • Changed its username
  • Clicked the "Sync" button
  • User updated
    Did the same for the email address

Screenshots / Logs (if applicable)

image

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Summary by CodeRabbit

  • New Features

    • Plex import now supports a sync-only outcome (refreshes existing users without creating accounts) with dedicated success messaging.
    • UI labels and button text dynamically switch between import vs. sync states, including loading text.
  • Improvements

    • Empty-state guidance and success toasts added to clarify sync behavior and next steps.

@0xSysR3ll 0xSysR3ll requested a review from a team as a code owner April 29, 2026 18:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 258cc10b-ab14-4fc4-af84-c8f579257a1d

📥 Commits

Reviewing files that changed from the base of the PR and between 4a0e197 and 92a8e45.

📒 Files selected for processing (1)
  • src/components/UserList/PlexImportModal.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/components/UserList/PlexImportModal.tsx

📝 Walkthrough

Walkthrough

Treats an empty createdUsers array from Plex import as a valid "sync-only" result: adds sync-specific i18n strings, shows a dedicated sync success toast for sync-only results, updates modal OK button text/enablement for sync vs import modes, and surfaces sync guidance in the empty-state alert.

Changes

Cohort / File(s) Summary
Plex Import Modal Logic
src/components/UserList/PlexImportModal.tsx
Detects isSyncOnly when SWR data loads with length 0; only throws on non-array createdUsers; shows importfromplexsynced toast for sync-only, preserves import-success toast and missing-password warning when createdUsers.length > 0; updates okDisabled to allow OK during sync-only and okText to switch between sync/import labels; adds syncnotice to empty-state alert.
Internationalization
src/i18n/globalMessages.ts, src/i18n/locale/en.json
Adds i18n keys sync and syncing and English translations for sync success and sync guidance messages used by the modal and buttons.

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant Modal as PlexImportModal
  participant API as PlexImportAPI
  participant Toast as ToastService

  User->>Modal: Click "Import"/"Sync"
  Modal->>API: call import endpoint
  API-->>Modal: return { createdUsers: [...] } or []
  alt createdUsers is array with length > 0
    Modal->>Toast: show import-success toast + missing-password warning (if any)
  else createdUsers is empty array (sync-only)
    Modal->>Toast: show "Plex users synced successfully" toast
  else createdUsers is not array
    Modal->>User: surface error / throw
  end
  Modal-->>User: update OK button label/state and show empty-state `syncnotice` if applicable
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • fallenbagel
  • gauthier-th

Poem

"🐇
I hopped into code with a twitchy nose,
Synced Plex users where the cool wind blows.
A toast for the clean, a hint for the sly,
Click Sync, watch names and emails comply.
Hop on — all is updated, bye-bye!"

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding sync functionality to the PlexImportModal component, which is the primary focus of all modifications in this PR.
Linked Issues check ✅ Passed The PR directly addresses issue #2907 by implementing the requested sync functionality. The changes enable users to manually sync Plex account details (email, username) to their Seerr accounts without requiring new user imports.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the sync feature: i18n messages for sync UI labels, modal logic to handle sync-only mode, and button state management. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/UserList/PlexImportModal.tsx`:
- Around line 62-92: The code currently treats createdUsers.length === 0 as a
successful sync and shows messages.importfromplexsynced; instead change the
logic to rely on an explicit success indicator returned by the API (e.g.,
response.syncedCount, response.refreshedUsers, or response.importResult.status)
rather than an empty array. In PlexImportModal, inspect the response object for
a dedicated "synced" or "refreshed" field (or a numeric syncedCount) and only
show messages.importfromplexsynced when that explicit field indicates work was
performed; if no explicit indicator exists, show a neutral/info toast (or no
success toast) indicating nothing was created/refreshed and log the full
response for debugging. Update usage sites around createdUsers, addToast, and
the success/empty-branch logic accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34084fdb-24c9-4dde-bbd2-bf3cd1106874

📥 Commits

Reviewing files that changed from the base of the PR and between b32ab02 and 4a0e197.

📒 Files selected for processing (3)
  • src/components/UserList/PlexImportModal.tsx
  • src/i18n/globalMessages.ts
  • src/i18n/locale/en.json

Comment thread src/components/UserList/PlexImportModal.tsx
@cloudstad
Copy link
Copy Markdown

Possible remaining edge case after commit 92a8e45 (fix: sync only toast notif):

In src/components/UserList/PlexImportModal.tsx, the new branching handles isSyncOnly and createdUsers.length > 0, but there does not appear to be an else branch for normal import mode when createdUsers.length === 0.

That means an import-mode POST returning [] — for example, if the selected Plex user became unavailable or was already imported between fetch and POST — looks like it would fall through to onComplete() with no toast.

CodeRabbit’s earlier comment correctly flagged the old empty-array sync toast as misleading in import mode. The follow-up commit removed that misleading success toast, but I think the import-mode empty-array case may still need an error/info toast so the modal does not close silently.

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.

Sync User's Plex.tv Account Changes Manually

2 participants