fix: resolve segmented controls not appearing due to esbuild enum inlining#1319
Open
SameDesu123 wants to merge 1 commit intokwaroran:mainfrom
Open
fix: resolve segmented controls not appearing due to esbuild enum inlining#1319SameDesu123 wants to merge 1 commit intokwaroran:mainfrom
SameDesu123 wants to merge 1 commit intokwaroran:mainfrom
Conversation
…ining Convert TypeScript enums (LLMFlags, LLMProvider, LLMFormat, LLMTokenizer) to const objects with type aliases to prevent esbuild from inlining enum values during Vite dev mode, which caused inconsistent values across modules. Also simplify SettingSegmented wrapper by removing fragile localValue/$effect sync pattern in favor of direct DB binding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
Segmented controls (e.g., Thinking Mode, Adaptive Thinking Effort) were not appearing in Bot Settings when selecting Claude models in Vite dev mode, despite working correctly in production builds (
pnpm run preview).Related Issues
Regression introduced by #1303 (Component Registry Architecture refactor).
Changes
1. Convert TypeScript enums to const objects (
src/ts/model/types.ts)LLMFlags,LLMProvider,LLMFormat,LLMTokenizerwere all TypeScriptenums. esbuild (used by Vite in dev mode) inlines enum values at each import site during transpilation. When HMR causes modules to be transpiled at different times, inlined values can become stale/inconsistent — e.g.,LLMFlags.claudeThinkingevaluated to12in one module but21in another.Converted all four to
as constobjects with companion type aliases. This preserves full type safety while ensuring values are always resolved at runtime via object property access, not compile-time inlining.2. Simplify SettingSegmented wrapper (
src/lib/Setting/Wrappers/SettingSegmented.svelte)Replaced the fragile 3-
$effectchain (DB→local sync, local→DB write-back, option reset) with directbind:valuetoDBState.db. Also cleaned upprocessedOptionsto only output{ value, label }instead of spreading the full option object (which leakedconditionfunctions).Impact
LLMFlags.claudeThinkingworks identically as a value, andLLMFlagsworks as a type.Additional Notes
The numeric values are explicitly assigned and match the original enum ordinals, so no database migration or stored-value changes are needed.
Footnotes
Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩
Over 80% of the code is AI generated. ↩