Skip to content

fix(web): keep saved custom instruction pending until the list loads - #312

Merged
hydropix merged 1 commit into
mainfrom
fix/284-custom-instruction-race
Oct 23, 2026
Merged

hydropix merged 1 commit into
mainfrom
fix/284-custom-instruction-race

Conversation

@hydropix

Copy link
Copy Markdown
Owner

Closes #284.

Problem

On page load, the saved custom instruction preset could be applied from the server-preferences path before loadCustomInstructions() had filled the dropdown. The select is never empty (the template ships with "None" and "Auto"), so the preset was reported as not found and the pending value was dropped. The next preference save then synced the default back to the server, so other devices lost the preset too.

Fix

  • A pending preset is only dropped once the instruction list has actually loaded. FormManager sets window.__customInstructionsLoaded before dispatching customInstructionsLoaded.
  • While a preset is pending, preference saves store the pending value instead of the select's default option, so it is never synced away.
  • An explicit user change of the select clears the pending value, so the user's choice wins.

Testing

Exercised in the browser by calling the apply and save functions directly: an early apply keeps the preset pending and it is applied when the list arrives; a preset missing from a loaded list is dropped; a save while pending keeps the preset; a manual change clears it. I did not reproduce the race through a real reload, since no presets exist in my local setup.

🤖 Generated with Claude Code

…284)

The server-preferences path applied the saved preset immediately. The
select is never empty (the template ships "None" and "Auto"), so when the
synced preferences arrived before loadCustomInstructions() finished, the
preset was reported as not found and the pending value was dropped. The
next preference save then synced the default back to the server, which
spread the loss to other devices.

- Only give up on a pending preset once the instruction list has loaded
  (FormManager sets window.__customInstructionsLoaded before dispatching
  customInstructionsLoaded).
- While a preset is pending, save it instead of the select's placeholder
  value so it is never synced away.
- An explicit user change of the select clears the pending value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hydropix
hydropix merged commit 48cbb8f into main Oct 23, 2026
1 check passed
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.

Web UI: selected custom instruction is sometimes dropped on page load (race with synced preferences)

1 participant