Skip to content

fix: replace useFetcher in AISettings with direct async fetch to unblock navigation#9954

Open
jackkav wants to merge 4 commits into
developfrom
fix/settings-modal-fetcher-navigation-block
Open

fix: replace useFetcher in AISettings with direct async fetch to unblock navigation#9954
jackkav wants to merge 4 commits into
developfrom
fix/settings-modal-fetcher-navigation-block

Conversation

@jackkav
Copy link
Copy Markdown
Contributor

@jackkav jackkav commented May 26, 2026

Summary

  • AISettings is rendered inside SettingsModal, which is always mounted via <Modals /> in root.tsx
  • useOrganizationPermissions() internally creates a React Router useFetcher, which participates in the navigation lifecycle even when the modal is closed
  • When navigating to the scratchpad after logout, the fetcher's pending state prevented the navigation from committing — the middleware's await next() never resolved, causing an indefinite hang (~30s timeout in the Windows bundling test)
  • Replaced the hook with a plain useEffect + direct getOrganizationFeatures call, so no fetcher is registered against the router

Test plan

  • Open Settings → AI Settings tab → verify features still gate the toggles correctly (org-enabled features show as enabled)
  • Open Settings modal → close it → navigate to scratchpad (logout flow) → verify navigation completes without hanging
  • npm run lint && npm run type-check

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 26, 2026 06:50
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

✅ Circular References Report

Generated at: 2026-05-28T08:17:47.533Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 18 18 0 (0.00%)
Click to view all circular references in PR (18)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (18)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a navigation hang caused by AISettings (mounted via SettingsModal under <Modals />) registering a React Router fetcher through useOrganizationPermissions(), which could keep navigation from committing during logout → scratchpad flows.

Changes:

  • Removed useOrganizationPermissions() usage from AISettings.
  • Added a useEffect that directly calls getOrganizationFeatures() and stores results in local component state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/insomnia/src/ui/components/settings/ai-settings.tsx
@jackkav jackkav force-pushed the fix/settings-modal-fetcher-navigation-block branch from 25ad0c9 to 52f49b1 Compare May 26, 2026 11:35
Copy link
Copy Markdown
Contributor

@fiosman fiosman left a comment

Choose a reason for hiding this comment

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

Please help me understand if there is something wrong with the below flow:

  • I enabled all AI features for my organization using the website app.
  • On the desktop app, I do not see any of the toggles enabled by default within the AI Settings tab (I have a LLM configured).
  • When I toggle them off via the website app, I can toggle them on and off in the desktop app. I was expecting not to be able to do that.

@jackkav
Copy link
Copy Markdown
Contributor Author

jackkav commented May 26, 2026

Please help me understand if there is something wrong with the below flow:

  • I enabled all AI features for my organization using the website app.
  • On the desktop app, I do not see any of the toggles enabled by default within the AI Settings tab (I have a LLM configured).
  • When I toggle them off via the website app, I can toggle them on and off in the desktop app. I was expecting not to be able to do that.

I'm not clear on the feature, @shelby-moore left the instructions that guided this flake fixing PR. https://kongstrong.slack.com/archives/C04RYC8GSJ0/p1778080551991569?thread_ts=1778062067.454049&cid=C04RYC8GSJ0

@fiosman
Copy link
Copy Markdown
Contributor

fiosman commented May 27, 2026

Please help me understand if there is something wrong with the below flow:

  • I enabled all AI features for my organization using the website app.
  • On the desktop app, I do not see any of the toggles enabled by default within the AI Settings tab (I have a LLM configured).
  • When I toggle them off via the website app, I can toggle them on and off in the desktop app. I was expecting not to be able to do that.

I'm not clear on the feature, @shelby-moore left the instructions that guided this flake fixing PR. https://kongstrong.slack.com/archives/C04RYC8GSJ0/p1778080551991569?thread_ts=1778062067.454049&cid=C04RYC8GSJ0

Thanks @jackkav. I also confirmed that AI features have to be toggled on for both the website app and the desktop app. https://kongstrong.slack.com/archives/C08E26ZEPL2/p1779875331434299?thread_ts=1779828345.613999&cid=C08E26ZEPL2

jackkav and others added 4 commits May 28, 2026 10:12
…rect async fetch

AISettings is rendered inside SettingsModal (always-mounted via <Modals /> in
root.tsx). useOrganizationPermissions internally creates a React Router useFetcher,
which participates in the navigation lifecycle even when the modal is closed.
When navigating to the scratchpad after logout, the fetcher's pending state
prevented navigation from committing, causing a 30s hang in the bundling test.

Replaced with a plain useEffect + getOrganizationFeatures call so no fetcher
is registered against the router.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rect async fetch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reset to fallbackFeatures when fetch condition is not met, and use a
cancelled flag to ignore responses from outdated requests after unmount
or dependency change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ondition

When the user blurs a field immediately after typing (e.g. clicking Add Row),
the 100ms debounce could fire after the subsequent write, overwriting the DB
with stale kvPairs that didn't include the new row. Fix by: adding cancel() to
misc.debounce, merging changes/blur into a single effect registered once via a
ref (eliminating stale closures), and having blur explicitly cancel any pending
debounce before flushing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jackkav jackkav force-pushed the fix/settings-modal-fetcher-navigation-block branch from 52f49b1 to 22a9c79 Compare May 28, 2026 08:12
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.

3 participants