Skip to content

feat: version restore safety guards (concurrent editor detection + read-only lock)#372

Open
leotrs wants to merge 6 commits intomainfrom
std-n4j5
Open

feat: version restore safety guards (concurrent editor detection + read-only lock)#372
leotrs wants to merge 6 commits intomainfrom
std-n4j5

Conversation

@leotrs
Copy link
Copy Markdown
Collaborator

@leotrs leotrs commented Apr 4, 2026

Summary

  • Implement stub composables (useEditor, useAwareness, useYText, useCurrentUser) with inject-based implementations using lazy proxy patterns for deferred access
  • Wire VersionPreviewModal to use useVersionRestore composable instead of raw window.__cmView.dispatch, enabling concurrent editor detection, read-only lock, awareness broadcasting, and atomic Y.js transactions
  • Lift awareness/cmView/readOnlyCompartment provides from Canvas.vue to View.vue so both Canvas and Sidebar subtrees can inject them
  • Add 17 unit tests for composables + update 27 existing modal tests

Test plan

  • All composable unit tests pass (useEditor: 6, useAwareness: 5, useYText: 6, useVersionRestore: 12)
  • VersionPreviewModal unit tests pass (27 tests)
  • DrawerVersions tests pass (30 tests)
  • Minimap architecture test updated and passing
  • Full frontend test suite: 0 new failures (7 pre-existing on main)
  • E2E: version restore flow (CI)
  • E2E: concurrent editor detection (skipped pending full collab setup)

🤖 Generated with Claude Code

…ction + read-only lock)

Replace stub composables (useEditor, useAwareness, useYText, useCurrentUser) with
inject-based implementations that defer to View.vue-provided refs. Wire
VersionPreviewModal to use useVersionRestore composable instead of raw
window.__cmView.dispatch, enabling concurrent editor detection, read-only lock
during restore, awareness broadcasting, and atomic Y.js transactions with origin
tagging. Lift awareness/cmView/readOnlyCompartment provides from Canvas.vue to
View.vue so both Canvas and Sidebar subtrees can inject them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 4, 2026

Deploy Preview for rsm-studio-frontend ready!

Name Link
🔨 Latest commit fe1b9cd
🔍 Latest deploy log https://app.netlify.com/projects/rsm-studio-frontend/deploys/69d0b40691817400086a02c7
😎 Deploy Preview https://deploy-preview-372--rsm-studio-frontend.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 4, 2026

Deploy Preview for rsm-studio-site canceled.

Name Link
🔨 Latest commit fe1b9cd
🔍 Latest deploy log https://app.netlify.com/projects/rsm-studio-site/deploys/69d0b4067546910008a4bfab

…w fetch

In Docker/CI, raw fetch('/api/...') hits Vite's SPA fallback and returns
index.html HTML instead of version content. This caused the Y.js editor
to be populated with the HTML page, breaking the 2 E2E restore tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leotrs
Copy link
Copy Markdown
Collaborator Author

leotrs commented Apr 4, 2026

Needs human review

What changed: Version restore now goes through a useVersionRestore composable with concurrent editor detection, read-only editor lock during restore, and Y.js awareness broadcasting — replacing the previous raw window.__cmView.dispatch approach.

Review checklist:

  1. Open the deploy preview: https://deploy-preview-372--rsm-studio-frontend.netlify.app
  2. Log in as the file owner and open a file with multiple saved versions
  3. Open the version history drawer (sidebar)
  4. Click a version to open the preview modal
  5. Click "Restore" and confirm — verify the editor content is replaced with the version content
  6. During restore, verify the editor briefly becomes read-only (no typing allowed)
  7. After restore completes, verify you can edit again normally
  8. Test cancelling the restore confirmation — verify nothing changes
  9. If possible, open the same file in a second browser tab to test concurrent editor detection (should show a confirmation warning about other active editors)

What to look for:

  • Restore replaces content correctly (same behavior as before, just via Y.js transaction now)
  • No error alerts during normal restore flow
  • Editor locks during restore and unlocks after
  • Concurrent editor warning appears when multiple tabs are editing
  • Modal close/ESC still works correctly (blocked during restore, allowed after)
  • No regressions in version preview content loading or error states

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Preview Deploy

Frontend: https://pr-372--rsm-studio-frontend.netlify.app
Backend: https://aris-backend-staging.fly.dev (staging)
API docs: https://aris-backend-staging.fly.dev/docs

Test user: preview-pr-372@aris.pub

This preview will be destroyed when the PR is closed.

leotrs and others added 2 commits April 4, 2026 08:47
Now that useAwareness and useEditor composables are fully implemented
(no longer stubs), these e2e tests can exercise the real restore flow:
concurrent editor warning via awareness states and editor read-only
lock during restore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leotrs
Copy link
Copy Markdown
Collaborator Author

leotrs commented Apr 4, 2026

Needs human review

What changed: Version restore now uses Y.js transactions via useVersionRestore composable instead of raw window.__cmView.dispatch. Adds concurrent editor detection (confirm dialog when others are editing) and read-only editor lock during restore.

Review checklist:

  1. Open the deploy preview: https://deploy-preview-372--rsm-studio-frontend.netlify.app
  2. Log in as an owner of a file with at least one named version
  3. Open the file in the editor, navigate to the version history sidebar
  4. Click a version to open the preview modal
  5. Click "Restore" → verify the confirmation dialog appears
  6. Confirm the restore → verify content is replaced and modal closes
  7. Verify the editor is editable again after restore completes
  8. (If possible) Open the same file in a second browser/incognito as a shared editor, then attempt restore from the owner session — verify a warning about concurrent editors appears

What to look for:

  • Restore button shows correct version number (e.g., "Restore v5")
  • Confirmation dialog appears and cancel works (no restore happens)
  • Content is actually replaced after confirming restore
  • Editor is temporarily read-only during restore (cursor should not be placeable)
  • Editor returns to editable state after restore
  • Modal cannot be closed while restore is in progress
  • Error handling: if restore fails, alert is shown and modal stays open
  • No regressions in the version preview display (content renders correctly)

@leotrs
Copy link
Copy Markdown
Collaborator Author

leotrs commented Apr 6, 2026

Needs human review

What changed: Version restore now uses useVersionRestore composable instead of raw window.__cmView.dispatch. This adds concurrent editor detection (confirm dialog when others are editing), read-only editor lock during restore, and atomic Y.js transactions. Shared refs (awareness, cmView, readOnlyCompartment) are lifted from Canvas.vue to View.vue so both Canvas and Sidebar subtrees can access them.

Review checklist:

  1. Open the deploy preview: https://deploy-preview-372--rsm-studio-frontend.netlify.app
  2. Log in as an owner of a file with multiple versions
  3. Open the file in the editor, then open the version history drawer
  4. Click a version to open the preview modal — verify content loads correctly
  5. Click "Restore" → verify the confirmation dialog appears
  6. Click "Cancel" → verify it dismisses without restoring
  7. Click "Restore" again → "Confirm" → verify content is replaced in the editor
  8. After restore completes, verify the editor is editable (not stuck in read-only)
  9. Test with two browser tabs on the same file — restore in one and verify the concurrent editor warning appears (confirm dialog mentioning the other user)
  10. Verify non-owners do NOT see the restore button

What to look for:

  • Restore actually replaces editor content (not silently failing)
  • Editor is briefly read-only during restore, then returns to editable
  • Concurrent editor confirm dialog shows correct user info
  • No console errors during the restore flow
  • Modal closes after successful restore
  • ESC key still closes the modal when not restoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant