Skip to content

fix: avoid Tauri resource aborts in Auto Suggest#1496

Merged
kwaroran merged 1 commit into
mainfrom
cubicj-fix-auto-suggest-tauri-resource
Jun 21, 2026
Merged

fix: avoid Tauri resource aborts in Auto Suggest#1496
kwaroran merged 1 commit into
mainfrom
cubicj-fix-auto-suggest-tauri-resource

Conversation

@cubicj

@cubicj cubicj commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?
      • We currently do not accept highly AI generated PRs that are large changes.

Summary

Fixes Auto Suggest triggering Tauri HTTP resource errors such as The resource id ... is invalid.

Auto Suggest used an AbortController to cancel in-flight suggestion requests when chat state changed, the chat page changed, or suggestions were re-rolled. On Tauri desktop, that abort signal is passed into @tauri-apps/plugin-http, where aborting around response body reads can race with native resource cleanup and surface an invalid resource id error.

Related Issues

Fixes #1443.

Changes

src/lib/ChatScreens/Suggestion.svelte

  • Replace Auto Suggest's request cancellation state with a request id guard
  • Avoid passing a native abort signal for Auto Suggest requests on Tauri
  • Keep abort behavior for non-Tauri environments
  • Only write suggestion results when the request id, selected character, and chat page still match
  • Stop using doingChat.set(true); doingChat.set(false) to re-roll suggestions
  • Invalidate pending suggestion results when the component is destroyed

src/ts/globalApi.svelte.ts

  • Return a normalized failed fetch result when Tauri HTTP fetch throws

Impact

  • Auto Suggest no longer uses Tauri native HTTP aborts, avoiding the plugin-http resource id race.
  • Stale Auto Suggest responses are discarded instead of being written to the current chat.
  • Re-rolling suggestions no longer toggles the global chat-in-progress state.
  • On Tauri, canceled Auto Suggest requests may still finish on the backend, but their results are ignored if they are no longer current.
  • Existing stored data and database schema are unchanged.
  • Web and non-Tauri abort behavior is preserved.

Additional Notes

Validated with:

  • pnpm check
  • pnpm test
  • pnpm build

git diff --check only reported existing CRLF conversion warnings.

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models.

  2. Over 80% of the code is AI generated.

@cubicj cubicj marked this pull request as ready for review June 21, 2026 08:45
@kwaroran kwaroran merged commit 02ee6d9 into main Jun 21, 2026
4 checks passed
@cubicj cubicj deleted the cubicj-fix-auto-suggest-tauri-resource branch June 21, 2026 10:22
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.

The resource id is invalid

2 participants