Repository navigation
fix: [Workflow] - The model should not become unselectable after an error is generated during AI generation - #8204
Merged
Merged
Conversation
…rror is generated during AI generation
shaohuzhang1
commented
Nov 27, 2026
| const started = computed(() => !['idle','done','error','stopped'].includes(status.value)) | ||
|
|
||
| function sendSuggestedRequirement(question: string) { | ||
| if (!modelId.value || busy.value) return |
Contributor
Author
There was a problem hiding this comment.
Here are my observations on this diff:
Irregularities / Potential Issues
-
includes()may cause a TypeScript errorstatus.valueis likely a union type (e.g.,'idle' | 'running' | 'done' | 'error' | 'stopped').- Calling
.includes()on an array whose element type is inferred asstring[]while passing a narrower union is fine, but if the array literal's type is inferred too narrowly (e.g., string literal types), or ifstatusis typed as a string enum, you may get a "Argument of type X is not assignable to parameter of type Y" error. Consider typing the array explicitly:const TERMINAL_STATES: Status[] = ['idle', 'done', 'error', 'stopped'] const started = computed(() => !TERMINAL_STATES.includes(status.value))
-
Behavioral change — verify intent
- Old:
started = status !== 'idle'→ true fordone,error,stopped, and any future non-idle state. - New:
started = falsefordone,error,stopped. This is likely the intended fix (a finished/errored run isn't "started"), but confirm anywherestartedgates UI logic — e.g., showing a Stop button, disabling inputs, highlighting the first message, etc.
- Old:
-
Future state values silently become "started"
- If a new intermediate state (e.g.,
'paused','queued') is introduced later, it will be treated as started by default. That's probably acceptable, but it's an implicit assumption — an exhaustive check or a shared constant would be more robust.
- If a new intermediate state (e.g.,
Optimization / Cleanliness Suggestions
-
Hoist the array out of the computed
- A new array is allocated each time the computed re-evaluates. Negligible perf impact, but hoisting avoids it and improves readability/reuse:
const FINISHED_STATUSES = ['idle', 'done', 'error', 'stopped'] as const const started = computed(() => !FINISHED_STATUSES.includes(status.value as ...))
- A new array is allocated each time the computed re-evaluates. Negligible perf impact, but hoisting avoids it and improves readability/reuse:
-
Consider a positive predicate
- Naming a boolean after a negative set is a bit harder to reason about. Alternatives:
const running = computed(() => status.value === 'running') // if that's all you need const finished = computed(() => [...].includes(status.value)) // then use !finished
- Since you already have
busy = status === 'running', ask whetherstartedneeds distinct semantics at all, or if it can be derived frombusy/ a dedicatedhasStartedflag.
- Naming a boolean after a negative set is a bit harder to reason about. Alternatives:
-
Extract a helper if used elsewhere
- If
['idle','done','error','stopped']appears in multiple components, share it (e.g., in a status util/enum module) to prevent drift.
- If
-
Minor style nit
- Add spaces after commas (
'idle', 'done', 'error', 'stopped') to match the codebase's prevailing formatting (Prettier would enforce this).
- Add spaces after commas (
Summary: The logic change looks reasonable and likely correct, but (a) make sure the type of status.value is compatible with Array.prototype.includes, (b) confirm no downstream consumer relied on started === true for terminal states, and (c) consider hoisting the array into a typed constant and adding a brief comment explaining what "started" means.
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.
fix: [Workflow] - The model should not become unselectable after an error is generated during AI generation