Skip to content

fix(web): show the webhook URL step when adding the first autoscan source - #1928

Merged
Quick104 merged 4 commits into
Silo-Server:mainfrom
Rhainland:fix/autoscan-first-source-connect-step
Oct 5, 2026
Merged

Quick104 merged 4 commits into
Silo-Server:mainfrom
Rhainland:fix/autoscan-first-source-connect-step

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1230
Validation tasks: changes #1232 C1

On a server with no autoscan sources, Add source → Sonarr/Radarr Webhook → Create and continue creates the source and its webhook endpoint, then resets the dialog to its first step instead of showing Connect it with the URL to paste into Sonarr or Radarr. The admin is left without the URL or the instructions, and this is exactly the first-time setup the user manual walks through. Adding a second source works.

SourcesPanel rendered the add dialog in a different place in its empty-state layout than in its list layout. Creating the first source switches layouts, so React remounted the dialog and dropped its state.

The Connect it step also named the triggers "On Import" and "On Upgrade". Sonarr v4 and Radarr v5+ caption them On File Import and On File Upgrade, so the instructions did not match the boxes the admin has to tick.

Approach

Render one layout with the dialog at a fixed position, and keep that layout with the last loaded list when a refresh of the sources fails, so the dialog is not unmounted that way either. Use the current Sonarr/Radarr captions in the setup step, and build the source row hint from the same per-provider trigger list.

Validation

  • New tests add the first webhook source against a stubbed API, once normally and once with every sources read failing after the create, and expect the Connect it step with the URL; both fail before the fix.
  • On a local Docker build, after deleting every source through the UI, the first new source showed Connect it with the URL and the trigger list. The captions match the localization strings shipped in Sonarr 4.0.20 and Radarr 6.4.4.
  • Full gate from CONTRIBUTING.md on a branch combining all eleven [v1] Autoscan #1230 PRs: build, gofmt, go vet, make lint-changed (0 issues), web lint, format check, build and budget, every verify-* target and the router artifact test pass. DB-backed tests for the touched packages (autoscan, scanqueue, scanner, libraryingest, taskmanager, scantrigger, adminjob) pass against a freshly migrated database.
  • make test-go fails only in playback, jellycompat, transcodenode, api/handlers and apiv2 tests that also fail on unmodified main on this macOS host: hardware-probe tests whose fake ffmpeg is killed, transcode-session timing under full-suite load, and TestAdminResourceCapabilitiesAndScope. None of them exercise changed code. make test-web had one failure under full-suite load (AdminUsers row actions) that passes on its own. Linux CI is the authority for these.
  • Each PR on its own builds and passes go vet and the tests of the packages it changes (apart from TestAdminResourceCapabilitiesAndScope above); web PRs also pass the typecheck and the autoscan web tests. Every pair of the eleven PRs merges cleanly into main in either order.

Risks

None identified.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (running in T3 Code)
  • Tool(s): Claude Code (Bash, Read, Edit, Write, sub-agents, Playwright browser automation, T3 Code device control), OpenAI Codex CLI (review only), GitHub CLI, Docker, Sonarr, Radarr
  • Model(s): claude-opus-5-5; review: gpt-6.1-sol and gpt-6-astra (Codex CLI)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Three independent reviews of the combined [v1] Autoscan #1230 diff against main at medium effort (a Claude Code review agent on claude-opus-5-5, and Codex CLI with gpt-6.1-sol and gpt-6-astra) checked correctness, React state/effect behavior and docs. No findings for this change.

Note

Fix first-source webhook URL step in autoscan SourcesPanel

  • Keeps the add dialog mounted when creating the first autoscan source, so the "Connect it" step with the absolute webhook URL appears as intended. A failed source-list refetch now keeps the last loaded sources and shows an inline refresh warning instead of a fatal error. The delete dialog only opens when its target source still exists.
  • Updates WebhookEndpointSection in SourcesPanel.tsx to show the selected provider's settings path and trigger labels instead of fixed Sonarr/Radarr wording.
  • Renames shared trigger captions to "On File Import" and "On File Upgrade" in webhookSetup.ts to match Sonarr v4 and Radarr v5+ UI.
  • Adds tests in SourceFirstCreate.test.tsx covering successful first webhook-source creation and the failed-refresh case.
  • Behavioral Change: fatal source-load error now applies only when no source data exists; the add and delete dialogs sit at a stable position in the render tree.

Macroscope summarized f968c57.

…urce

On a server with no autoscan sources, Add source → Create and continue
created the source and its webhook endpoint, then reset the dialog to its
first step instead of showing the URL to paste into Sonarr or Radarr. The
panel rendered the add dialog in a different place in the empty layout
than in the list layout, so the first source's arrival remounted the
dialog and dropped its state.

Render one layout with the dialog in a fixed position.
Sonarr v4 and Radarr v5+ caption the import triggers On File Import and
On File Upgrade, not On Import and On Upgrade. Match their captions in the
setup step, and list the same triggers in the source row hint.
@silo-kody

silo-kody Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c9571f8a-6ddf-4a17-90f1-2e2ae5f772fa
📥 Commits

Reviewing files that changed from the base of the PR and between 5b44c0d and f968c57.

📒 Files selected for processing (2)
  • web/src/pages/admin/autoscan/SourceFirstCreate.test.tsx
  • web/src/pages/admin/autoscan/SourcesPanel.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The autoscan admin UI updates webhook setup guidance and source-list behavior. The source panel retains loaded data after refresh errors, shows provider-specific webhook instructions, and keeps the add dialog in a shared layout. Tests cover first-source creation and the connection URL.

Changes

Autoscan source setup and management

Layer / File(s) Summary
Webhook setup labels
web/src/pages/admin/autoscan/SourcesPanel.tsx, web/src/pages/admin/autoscan/webhookSetup.ts, web/src/pages/admin/autoscan/webhookSetup.test.ts
Setup guidance names the Sonarr v4 and Radarr v5-and-later webhook screens. Import and upgrade captions change to “On File Import” and “On File Upgrade.” Tests check the captions and required status.
Source list layout and creation
web/src/pages/admin/autoscan/SourcesPanel.tsx, web/src/pages/admin/autoscan/SourceFirstCreate.test.tsx
The panel displays provider-specific webhook setup instructions, retains loaded source data after refresh errors, and shows a refresh-error notice when cached data exists. Delete confirmation is limited to a source in the current list. The shared layout renders the empty state or responsive source views and mounts the add dialog. Tests cover first-source creation, its connection URL, and the refresh-error case.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to f968c

The first-source connection details remain visible after a source refresh fails. No identified issue prevents merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: keeping the webhook URL step visible when adding the first autoscan source.
Description check ✅ Passed The description explains the first-source dialog reset, the layout change, the updated webhook instructions, and the validation performed.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown

Validation tasks: unblocks #1232 C1 is inaccurate: #1232 C1 is currently Not run, not failed or blocked. This PR changes the first-source setup flow covered by C1, but there is no recorded result to unblock. Please use:

Validation tasks: changes #1232 C1

C1 still needs its initial validation after merge.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Rhainland

Copy link
Copy Markdown
Contributor Author

Right, both cases are still recorded as Not run, so there is nothing to unblock. Updated the line to Validation tasks: changes #1232 C1.

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

Code review of 5b44c0d found three issues, all in SourcesPanel.tsx and all inline. None is a regression from main. The fix works for the path it targets: the add dialog no longer remounts when the first source appears.

  • Medium, rare: a failed sources refetch right after Create and continue still unmounts the dialog and loses the URL. Needs your call: fix it here or in a follow-up.
  • Low: the row hint names a delete checkbox that exists in neither app, and it ignores the source's provider.
  • Low, rare: a stale delete confirmation can reopen over Connect it.

Checked and found no problems:

  • The new "On File Import" and "On File Upgrade" captions match Sonarr and Radarr on develop.
  • The test's stubbed responses match the OpenAPI schemas.
  • The manual's autoscan page names no trigger captions, so no manual issue is needed.

Needs your call: the Validation tasks: line. CLAUDE.md asks it to name the passed cases a change could reach. #1232 C1 is still Not run, so by that rule the line would be Validation tasks: none, with C1 noted separately as reached but not yet run. The earlier bot comment suggested the current wording, so a maintainer should settle which reading applies.

AI disclosure: claude-opus-5-5 wrote this review in Claude Code via T3 Code (/silo code-review). It is not a maintainer review.

Comment on lines +1871 to +1873
// The add dialog stays at one position in the tree whether or not sources
// exist. Creating the first source switches to the list; if the dialog moved
// with it, React would remount it and drop the "Connect it" step.

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.

Medium, rare trigger: the Connect it step can still be lost. This comment holds only while the sources query succeeds. The sources.isError return above (line 1861) renders without {addDialog}.

After Create and continue, the create mutation invalidates the sources list. Suppose that refetch and its one retry fail, or the refetch times out (timeouts aren't retried). TanStack Query 5 then sets isError even though the cached data is still there. The panel shows "Failed to load scan sources", AddSourceDialog unmounts, and its createdWebhookReceipt state goes with it. If this happens before the webhook request resolves, that call's own onSuccess never runs. The source exists, but the admin never sees the URL. That is the bug this PR fixes, reached by another path. A reconnect refetch while the dialog is open can do the same. Window-focus refetch is off, so switching to the Sonarr tab doesn't trigger it.

Repair: take the error and loading returns only when there is no data (for example if (sources.isError && !sources.data)), or render {addDialog} in those states too, so the dialog stays mounted on every path. A test that fails the sources GET twice after the POST and expects the "Almost done — connect your service" dialog would cover it.

I traced this from the code and did not reproduce it. The early return predates this PR. Needs your call: fix it here or in a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f968c57: the error replaces the panel only when no list has loaded, and a failed refetch shows a notice above the last list, so the add dialog stays mounted. A new test fails every sources read after the create and still gets the Connect it step with the URL; it fails without the change.

Comment on lines +708 to +709
Paste into Sonarr/Radarr → Settings → Connect → Webhook (On File Import, On File
Upgrade, On Rename, On Episode/Movie File Delete).

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.

Low: the row hint names a delete checkbox that doesn't exist. This hint asks the admin to tick "On Episode/Movie File Delete". Sonarr's checkbox is "On Episode File Delete" and Radarr's is "On Movie File Delete", so the caption matches neither app. The hint also ignores provider, which this component already receives, so a Radarr source still gets the combined text. Nothing tests this string. This PR had to rename the same captions here and in webhookSetup.ts by hand, and the next caption change can easily miss one of them.

The delete caption was already wrong before this PR ("On File Delete"). Adding "On File Upgrade" is an improvement.

Repair: build the text from webhookSetup.ts, which already handles auto, sonarr, and radarr:

Paste into {settingsPathFor(provider)} (
{triggersFor(provider).map((t) => t.label).join(", ")}).

That also needs settingsPathFor and triggersFor added to the ./webhookSetup import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 82277bb: the hint is built from settingsPathFor(provider) and triggersFor(provider), so a Radarr source shows "On Movie File Delete" and the captions come from one place.

</div>

{/* Delete confirmation */}
<AlertDialog

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.

Low, rare trigger: a stale delete confirmation can reopen over Connect it. This dialog sits inside the non-empty branch, so it unmounts when the list empties. onOpenChange doesn't fire on unmount, so deleteTarget stays set.

Trigger: an admin opens "Delete source?" for the only source, another admin deletes that source, and a refetch returns an empty list. When the first admin adds a new source, this dialog mounts already open for the deleted source, on top of the Connect it step. Confirming sends a DELETE for an id that no longer exists and shows an error toast.

Main does the same, so this isn't a regression. The PR only changes what sits under the stale dialog.

Repair: clear deleteTarget when its source is no longer in list. Separately, rendering this AlertDialog after the conditional, next to {addDialog}, removes the fragment. It only uses component-level state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f968c57: the confirmation now sits next to the add dialog outside the conditional, and it is open only while its source is still in the list.

The row hint named an "On Episode/Movie File Delete" checkbox that exists
in neither app and ignored the source's provider. It now uses the same
settings path and trigger captions as the Connect it step.
…fails

A failed sources refetch replaced the panel with an error even though the
last list was still cached, which unmounted the add dialog and lost its
Connect it step. The error now replaces the panel only when nothing has
loaded; otherwise a notice sits above the last list.

The delete confirmation moves out of the non-empty branch and closes when
its source is no longer listed, so a stale confirmation cannot reopen over
a later dialog.
@silo-kody

silo-kody Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Rhainland added a commit to Rhainland/silo-server that referenced this pull request Oct 5, 2026
…can-sources-lean-list

Carries the Silo-Server#1928 review fixes. The list here already builds the webhook hint from triggersFor and keeps the delete confirmation outside the conditional, so only the failed-refresh handling and the delete-open guard apply.
@Quick104
Quick104 merged commit 626dd0e into Silo-Server:main Oct 5, 2026
21 checks passed
Quick104 added a commit to Rhainland/silo-server that referenced this pull request Oct 5, 2026
Brings in main's fix for the Autoscan tab crash on direct open (Silo-Server#1927).
SourcesPanel.tsx keeps this branch's version: main's copy is Silo-Server#1928's
head, which this branch already contains.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

2 participants