Feat(heuristics): Add optional weights feature toggle in settings#1833
Feat(heuristics): Add optional weights feature toggle in settings#1833rakshityadav1868 wants to merge 1 commit intoruxailab:developfrom
Conversation
Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
|
There was a problem hiding this comment.
Pull request overview
Adds a per-heuristic-study useWeights flag and exposes it in the Edit Test “Settings” tab so admins can toggle visibility/access to the Weights tab.
Changes:
- Extend
HeuristicStudyto persist a new booleanuseWeightsfield to Firestore. - Add a new “Enable Weights Feature” toggle to
HeuristicsSettings.vueand conditionally render the Weights tab/content inEditTest.vue. - Add i18n strings for the new toggle across supported locales.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ux/Heuristic/views/EditTest.vue | Conditionally renders the Weights tab and adjusts tab indices when visibility changes. |
| src/ux/Heuristic/models/HeuristicStudy.js | Adds useWeights to the heuristic study model and persistence. |
| src/ux/Heuristic/components/HeuristicsSettings.vue | Adds settings UI toggle and commits useWeights into Vuex. |
| src/app/plugins/locales/en.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/es.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/fr.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/de.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/pt_br.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/ru.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/hi.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/ar.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/zh.json | Adds i18n keys for the toggle label/description. |
| src/app/plugins/locales/ja.json | Adds i18n keys for the toggle label/description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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 | ||
| } | ||
| } | ||
| }) |
There was a problem hiding this comment.
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 | |
| } | |
| } | |
| ) |
| const windowWidth = ref(window.innerWidth) | ||
| const showSettingsTab = computed(() => !props.isTemplate) | ||
| const test = computed(() => store.getters.test) | ||
| const showWeightsTab = computed(() => test.value.useWeights ?? false) |
There was a problem hiding this comment.
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 | |
| }) |
| <HeuristicsSettings | ||
| v-if="showSettingsTab && index == 3" | ||
| v-if="showSettingsTab && (showWeightsTab ? index == 3 : index == 2)" | ||
| :is-template="isTemplate" |
There was a problem hiding this comment.
Changes made inside HeuristicsSettings (like toggling useWeights) currently won’t make the Save button appear because this component doesn’t emit a change event and the parent only sets change = true for other tabs. Consider emitting a change event from HeuristicsSettings when useWeights changes and wiring it up here so the user can persist the toggle.
| :is-template="isTemplate" | |
| :is-template="isTemplate" | |
| @change="change = true" |
| set: (value) => { | ||
| store.commit('SET_TEST', { | ||
| ...test.value, | ||
| useWeights: value, | ||
| }) |
There was a problem hiding this comment.
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 change event (or otherwise setting the parent’s change flag) from this setter / switch update handler.



fixes #1830
Overview
Add an optional "Enable Weights Feature" toggle in the Settings tab of the Edit Test page, allowing admins to control whether the Weights tab is visible and accessible for heuristic studies.
Changes Made
1. Data Model Update
HeuristicStudy.jsto includeuseWeightsboolean field (default: false)useWeightstotoFirestore()method for persistence2. Settings UI Enhancement
HeuristicsSettings.vueto enable/disable weights feature3. Frontend Logic
EditTest.vueto conditionally show/hide Weights tab based onuseWeightsflag4. Internationalization
HeuristicsSettings.titles.enableWeights: Label for toggleHeuristicsSettings.messages.enableWeightsDescription: Description textScreen.Recording.2026-03-08.at.12.46.23.AM.mp4