Skip to content

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

Open
0xSysR3ll wants to merge 3 commits into
developfrom
0xsysr3ll/feat/plex-users-sync
Open

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

Conversation

@0xSysR3ll

@0xSysR3ll 0xSysR3ll commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

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 was updated with the new username
    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 gains a sync-only mode that refreshes existing users and reports a refreshed count separately from newly created accounts.
    • Button labels and loading text now toggle between “Sync”/“Syncing…” and “Import”/“Importing” based on mode.
  • Improvements

    • Clarified success/info toasts for import vs. sync outcomes and added empty-state sync guidance via updated UI messages and translations.

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

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Treats an empty createdUsers array from Plex import as a valid "sync-only" result: server returns refreshedUsers; client adds i18n strings, shows sync-specific toasts, updates modal OK button text/enablement, and surfaces sync guidance in the empty-state alert.

Changes

Plex Import Sync Flow

Layer / File(s) Summary
Server: return refreshedUsers
server/routes/user/index.ts
Adds refreshedUsers counter and returns { createdUsers, refreshedUsers } from /import-from-plex.
Client: PlexImportModal behavior and types
src/components/UserList/PlexImportModal.tsx
Adds PlexImportResponse typing; detects isSyncOnly; updates importUsers to show sync-specific toasts based on refreshedUsers vs created users; changes okDisabled and okText to switch between sync/import wording and allow OK during sync-only; adds syncnotice to empty-state alert.
Internationalization
src/i18n/globalMessages.ts, src/i18n/locale/en.json
Adds sync/syncing labels and English messages for sync success, no-change result, and empty-state sync guidance used by the modal and buttons.

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant Modal as PlexImportModal
  participant API as /api/v1/user/import-from-plex
  participant Toast as ToastService

  User->>Modal: Click "Import"/"Sync"
  Modal->>API: POST import-from-plex
  API-->>Modal: return { createdUsers, refreshedUsers }
  alt createdUsers length > 0
    Modal->>Toast: show import-success toast + missing-password warning (if any)
  else createdUsers is empty and refreshedUsers > 0
    Modal->>Toast: show "Plex users synced successfully" toast
  else createdUsers is empty and refreshedUsers == 0
    Modal->>Toast: show "no users created or refreshed" info toast
  end
  Modal-->>User: update OK button label/state and render `syncnotice` in empty state when applicable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • seerr-team/seerr#2849: Modifies PlexImportModal.tsx import flow and adds imported-without-password warning; related to how import toasts are shown.

Suggested reviewers

  • M0NsTeRRR
  • gauthier-th
  • fallenbagel

Poem

"🐇
I nibbled through code with a twitch and a wink,
Synced names and emails before you could blink.
A toast for the new, a gentle note for the rest,
Click Sync or Import — I'll do the rest.
Hop, hop — user's info refreshed and blessed."

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main change: adding sync functionality to refresh existing Plex user details like email and username.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from #2907: allowing users to sync changes from Plex.tv accounts, with refactored modal logic to handle both import and sync modes.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Plex user sync functionality: modal UI/logic refactoring, i18n additions for sync messages, and backend response expansion.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 Outdated
@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.

@M0NsTeRRR

Copy link
Copy Markdown
Member

@0xSysR3ll, could you address the comment above?

@0xSysR3ll 0xSysR3ll force-pushed the 0xsysr3ll/feat/plex-users-sync branch from 92a8e45 to 53d47aa Compare June 13, 2026 09:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/UserList/PlexImportModal.tsx`:
- Around line 71-104: When handling the POST result in PlexImportModal.tsx, add
an else branch for the import-mode empty-result case so users always get
feedback: after the existing isSyncOnly check and the createdUsers.length > 0
branch, add an else that checks refreshedUsers and calls addToast accordingly
(e.g., if refreshedUsers > 0 call the same messages.importfromplexsynced success
toast; otherwise call messages.importfromplexnochanges info toast); do not show
the importedPlexUsersNoPassword warning unless createdUsers.length > 0. This
change touches the logic that reads isSyncOnly, createdUsers, refreshedUsers,
addToast and onComplete so place the new else branch alongside those checks to
ensure the modal never closes silently.
🪄 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: aae147fe-5f44-4862-bc67-83fc785d845e

📥 Commits

Reviewing files that changed from the base of the PR and between 92a8e45 and 53d47aa.

📒 Files selected for processing (4)
  • server/routes/user/index.ts
  • src/components/UserList/PlexImportModal.tsx
  • src/i18n/globalMessages.ts
  • src/i18n/locale/en.json
✅ Files skipped from review due to trivial changes (2)
  • src/i18n/locale/en.json
  • src/i18n/globalMessages.ts

Comment thread src/components/UserList/PlexImportModal.tsx
@0xSysR3ll 0xSysR3ll force-pushed the 0xsysr3ll/feat/plex-users-sync branch from 53d47aa to e56a720 Compare June 13, 2026 09:35
@seerr-automation-bot seerr-automation-bot added this to the v3.4.0 milestone Jun 18, 2026
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

5 participants