Skip to content

Versioning and history#3659

Merged
RichDom2185 merged 99 commits into
source-academy:masterfrom
Nocaxe:Versioning-and-History
May 6, 2026
Merged

Versioning and history#3659
RichDom2185 merged 99 commits into
source-academy:masterfrom
Nocaxe:Versioning-and-History

Conversation

@Nocaxe

@Nocaxe Nocaxe commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Description

Related Issues and PRs:

Depends on source-academy/backend#1346
to be merged first.

See: #3074

This PR implements versioning and history for the editor in coding assignments, such as missions, quests, and paths. Currently there is no versioning, and the editor only saves and submits the latest version to the server.

This change aims to:
allow students to review or edit previous versions of their code
allow TA’s to understand their student’s coding process to better guide them
allow admins to check for suspicious coding patterns (copy pasting from AI or plagiarism)

Features:
The autosave feature can be enabled and disabled per assessment group in the admin configuration panel, and overridden per assessment in ground control. The XML file uploaded can now include an isAutosaveEnabled flag, if not it will default to true.

Control Bar Changes:
The original save button has been removed, as the code is now autosaved with a 3 second debounce.
A new saving indicator shows the status of the code, between saving, saved, and saving failed. Whenever unsaved changes are detected, the indicator will show “Saving” and once the debounce expires and the code is saved, it shows “Saved” or “Saving failed” based on the response from the backend.
A new history button opens up the version history view explained below.

Saved Saving Failed

Note: The save button is not removed for team assessments as every save will override teammate’s code as well, so we keep the manual save. The saving indicator is removed, but the history button remains, as the version history viewing and restoring still works using manually submitted versions.
This is the same for assessments with autosave disabled

Team

Versions are stored in a linear fashion ordered and named by default by timestamp:
Timestamp 2 ← Current Version
Timestamp 1

When a previous version is restored, it is simply saved as a new version on top of the previous versions:
Timestamp 1 - restored ← Current Version
Timestamp 2
Timestamp 1

When the history button is clicked, a drawer opens up on the right of the screen, showing the versions and a preview of that version’s code. It also displays a diff viewer that shows the diff between their current code and the version they are previewing. The student can restore a version by clicking the “Restore this version” button after selecting and previewing that version.

The versions are also collapsed into groups if the changes are within 15 minutes of each other. This allows for easier viewing of many versions. The number of versions in a group are shown, and the detailed versions can be shown by clicking on the group. The name of the group will be the name of the newest version in that group.

Students can rename the versions or group by clicking on the default timestamp name. A separate timestamp will still remain below the name. If renaming a group, it will rename the latest version in the group to match as well.

Screenshot 2026-04-19 at 10 06 58 PM

Possible improvements:
Saving deltas for small changes and snapshots for major changes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

Backend PR needs to be merged before this PR

How to test

Added tests to WorkspaceSaga.test.ts, WorkspaceReducer.test.ts, and WorkspaceActions.test.ts to test changes.

Manually tested coding in the editor to see if functionality is as expected
Steps taken:
Continuously typed to ensure debounce works
Stop typing to check if debounce runs out and code is submitted and saved
Check version history panel to see if all versions are displayed correctly
Rename a version and check if change is saved correctly
Restore a version and check if code is restored, submitted and renamed correctly
Edited code but made no changes to ensure duplicates are not saved as a new version
Refresh the page to check if the initial population of the editor causes an unwanted extra save

Checklist

  • I have tested this code

@Nocaxe Nocaxe added the Enhancement New feature request label Mar 16, 2026
@Nocaxe Nocaxe marked this pull request as ready for review March 23, 2026 09:41
@RichDom2185

Copy link
Copy Markdown
Member

Please fix the failing tests, thanks!

@RichDom2185

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a versioning and history system for coding assignments, which is a significant and well-implemented feature. The changes include auto-saving with a debounce mechanism, a UI for save status, and a version history panel for viewing, restoring, and renaming versions. The Redux state management and sagas are well-structured to support this new functionality.

My review includes a few suggestions:

  • A fix for a potential issue where the save button is missing for team assessments on mobile devices.
  • A performance improvement for the version history panel by memoizing sorted data.
  • A code quality improvement to enhance type safety in the new sagas.

Comment thread src/commons/assessmentWorkspace/AssessmentWorkspace.tsx Outdated
Comment thread src/commons/controlBar/VersionHistoryPanel.tsx Outdated
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts Outdated
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts Outdated
Comment thread src/commons/assessmentWorkspace/AssessmentWorkspace.tsx Outdated
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts Outdated
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts Outdated
Comment thread src/commons/controlBar/VersionHistoryPanel.tsx Outdated
Comment thread src/commons/workspace/WorkspaceReducer.ts
Comment thread src/commons/sagas/WorkspaceSaga/helpers/versionHistory.ts
@RichDom2185 RichDom2185 enabled auto-merge (squash) May 6, 2026 13:56

@RichDom2185 RichDom2185 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment thread src/commons/controlBar/AceDiffViewer.tsx
@RichDom2185 RichDom2185 removed the blocked Something else needs pass review first label May 6, 2026
@RichDom2185 RichDom2185 merged commit 05b6ed9 into source-academy:master May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versioning and history for student submissions

6 participants