Skip to content

fix(ui): stop provider delete from surfacing a false error toast - #844

Merged
skevetter merged 3 commits into
mainfrom
fix/provider-delete-race
Aug 1, 2026
Merged

skevetter merged 3 commits into
mainfrom
fix/provider-delete-race

Conversation

@skevetter

@skevetter skevetter commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Deleting a provider raced the providers store update (from the providers-changed IPC event) against ProviderSheet's post-delete code, so the live provider prop could read as undefined right after deletion succeeded, throwing and getting reported as Failed to delete: Cannot read properties of undefined (reading 'name') even though the delete had worked.
  • Snapshot the provider name before calling providerDelete and use that local copy afterward instead of re-reading the reactive prop.
  • Guard the other reactive reads of provider (versionEntry, the options-loading effect, and the template) so a transient undefined provider renders nothing instead of throwing.

Summary by CodeRabbit

  • Bug Fixes
    • Improved provider settings behavior when no provider is selected.
    • Prevented provider details from appearing without an available provider.
    • Improved deletion handling and success reporting for providers.

Deleting a provider races the providers store update (via the
providers-changed IPC event) against ProviderSheet's own post-delete
code, so provider.name could read as undefined right after the
delete succeeded, throwing and getting reported as a failure. Snapshot
the name before the delete call and guard the reactive prop reads
that can transiently see an undefined provider.
@netlify

netlify Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 55f5948
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a6e3d64e09c670008f45f08

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ee2c6cf-8f71-4f99-a6bc-f1e355e19ee9

📥 Commits

Reviewing files that changed from the base of the PR and between 225120f and 55f5948.

📒 Files selected for processing (1)
  • desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte
📝 Walkthrough

Walkthrough

Changes

Provider sheet safety

Layer / File(s) Summary
Provider presence guards
desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte
Version lookup and loading stop when no provider exists. The sheet and its dialogs render only when a provider exists.
Stable delete name
desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte
handleDelete stores the provider name before deletion and reuses it for the request and success notification.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing a false error toast during provider deletion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@netlify

netlify Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 55f5948
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6e3d64f2904b00081e9e39

@github-actions github-actions Bot added the size/s label Aug 1, 2026
@skevetter
skevetter marked this pull request as ready for review August 1, 2026 18:01

@coderabbitai coderabbitai Bot 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.

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 `@desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte`:
- Around line 96-98: Update the ProviderSheet provider prop type from Provider
to Provider | undefined, then in runUpdate, runSwitch, handleSetDefault, and
handleInitialize capture provider.name in a local variable before each
asynchronous flow and use that snapshot after every await. Guard the initial
access when provider is absent so in-flight handlers cannot dereference the
mutable provider value or trigger incorrect cleanup and error handling.
🪄 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 Plus

Run ID: d6fb48c3-4224-43d2-9f18-5ed4e427503b

📥 Commits

Reviewing files that changed from the base of the PR and between e14e55a and 225120f.

📒 Files selected for processing (1)
  • desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte

Comment on lines +96 to +98
let versionEntry = $derived(
provider ? $providerVersions.byProvider[provider.name] : undefined,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Complete null safety for in-flight handlers.

The component still declares provider: Provider at Line 50, although this PR allows provider to become undefined. The conditional markup does not cancel handlers that started earlier. If the provider disappears during an await, runUpdate, runSwitch, handleSetDefault, and handleInitialize can still dereference provider.name, causing false error toasts or failed cleanup.

Change the prop type to Provider | undefined. Snapshot the provider name before each asynchronous flow and use the local name after every await.

🤖 Prompt for 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.

In `@desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte` around
lines 96 - 98, Update the ProviderSheet provider prop type from Provider to
Provider | undefined, then in runUpdate, runSwitch, handleSetDefault, and
handleInitialize capture provider.name in a local variable before each
asynchronous flow and use that snapshot after every await. Guard the initial
access when provider is absent so in-flight handlers cannot dereference the
mutable provider value or trigger incorrect cleanup and error handling.

handleSetDefault, runUpdate, runSwitch, and handleInitialize read
provider.name after an await, same race as the delete handler: if the
provider is deleted while one of these is in flight, the reactive
prop can go undefined before the post-await read, throwing and
surfacing as a misleading error toast.
# Conflicts:
#	desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte
@skevetter
skevetter enabled auto-merge (squash) August 1, 2026 18:44
@skevetter
skevetter merged commit 4a2db36 into main Aug 1, 2026
27 checks passed
@skevetter
skevetter deleted the fix/provider-delete-race branch August 1, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant