Skip to content

Guard resync between draft and fetch states #4103

Description

@RichDom2185

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "setAssessmentConfigurations|fetchAssessmentConfigs" src -g '*.ts' -g '*.tsx' -C3

Repository: source-academy/frontend

Length of output: 22003


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='src/new_routes/courses/[courseId]/adminpanel.tsx'
wc -l "$file"
sed -n '1,220p' "$file"

Repository: source-academy/frontend

Length of output: 8511


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='src/features/adminPanel/subcomponents/assessmentConfigPanel/AssessmentConfigPanel.tsx'
wc -l "$file"
sed -n '1,260p' "$file"

Repository: source-academy/frontend

Length of output: 8467


Guard this resync while the panel is dirty. Any backend refresh that updates session.assessmentConfigurations will overwrite local edits, and AssessmentConfigPanel will immediately re-base its diff against the new initialConfigs, clearing the dirty flag and hiding the loss. Skip the sync while there are unsaved changes, or prompt/merge before replacing local state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/new_routes/courses/`[courseId]/adminpanel.tsx around lines 94 - 98, Guard
the assessmentConfigurations resync effect in the admin panel so it does not
replace local state while unsaved changes are present. Use the panel’s existing
dirty-state signal around AssessmentConfigPanel, and only call
setAssessmentConfigs when the panel is clean; preserve synchronization for
initial loads and backend updates when no local edits exist.

Originally posted by @coderabbitai[bot] in #4102 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions