-
Notifications
You must be signed in to change notification settings - Fork 352
Feat(heuristics): Add optional weights feature toggle in settings #1833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <v-tab>{{ $t('HeuristicsEditTest.titles.heuristics') }}</v-tab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <v-tab>{{ $t('HeuristicsEditTest.titles.options') }}</v-tab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <v-tab>{{ $t('HeuristicsEditTest.titles.weights') }}</v-tab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <v-tab v-if="showWeightsTab">{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $t('HeuristicsEditTest.titles.weights') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }}</v-tab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <v-tab v-if="showSettingsTab">{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $t('HeuristicsEditTest.titles.settings') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }}</v-tab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -57,12 +59,12 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @change="change = true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <WeightTable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="index == 2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="showWeightsTab && index == 2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :is-template="isTemplate" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @change="change = true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HeuristicsSettings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="showSettingsTab && index == 3" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="showSettingsTab && (showWeightsTab ? index == 3 : index == 2)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :is-template="isTemplate" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :is-template="isTemplate" | |
| :is-template="isTemplate" | |
| @change="change = true" |
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In template preview mode, showWeightsTab is derived solely from test.useWeights. The template preview payload currently provides testWeights but not useWeights, so weights will never be shown in the preview even if the template contains weights. Either include useWeights in the template payload or derive the preview visibility from existing data (e.g., non-empty testWeights) / default to showing weights for templates.
| const showWeightsTab = computed(() => test.value.useWeights ?? false) | |
| const showWeightsTab = computed(() => { | |
| if (props.isTemplate) { | |
| const weights = props.templateTest?.testWeights | |
| if (Array.isArray(weights)) { | |
| return weights.length > 0 | |
| } | |
| return !!weights | |
| } | |
| return test.value?.useWeights ?? false | |
| }) |
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The watcher only corrects the active tab when weights are disabled. If weights are enabled while the user is on Settings (index 2 when weights are hidden), the current index will now point to the Weights tab and the UI will unexpectedly jump away from Settings. Consider updating the watcher to also handle the false→true transition (and generally clamp index to the highest available tab based on showWeightsTab/showSettingsTab).
| // Watch for changes in showWeightsTab to fix index | |
| watch(showWeightsTab, (newVal, oldVal) => { | |
| // If weights tab visibility changed and we're currently on or past the weights tab | |
| if (newVal !== oldVal) { | |
| if (!newVal && index.value > 1) { | |
| // Weights tab is now hidden and index is on Settings (was 3, should be 2) | |
| index.value = 2 | |
| } | |
| } | |
| }) | |
| // Watch for changes in tab visibility to keep the active index valid | |
| watch( | |
| [showWeightsTab, showSettingsTab], | |
| ([weightsVisible, settingsVisible], [oldWeightsVisible]) => { | |
| // Handle the case where weights are enabled while the user is on Settings. | |
| // When weights are hidden, SETTINGS has index 2; when weights are shown, | |
| // WEIGHTS becomes 2 and SETTINGS moves to 3. If we don't adjust here, | |
| // the user would unexpectedly jump from SETTINGS to WEIGHTS. | |
| if (!oldWeightsVisible && weightsVisible && settingsVisible && index.value === 2) { | |
| index.value = 3 | |
| return | |
| } | |
| // In all cases, clamp the index to the highest available tab based on visibility. | |
| let maxIndex = 1 // HEURISTICS (0) and OPTIONS (1) are always present | |
| if (weightsVisible) { | |
| maxIndex = 2 | |
| } | |
| if (settingsVisible) { | |
| maxIndex = weightsVisible ? 3 : 2 | |
| } | |
| if (index.value > maxIndex) { | |
| index.value = maxIndex | |
| } | |
| } | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toggling useWeights commits to Vuex but doesn’t notify the parent view that there are unsaved changes, so the toggle can’t be persisted unless the user edits something else first. Consider emitting a
changeevent (or otherwise setting the parent’schangeflag) from this setter / switch update handler.