Skip to content

feat: implement stub composables + wire VersionPreviewModal to useVersionRestore#368

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

feat: implement stub composables + wire VersionPreviewModal to useVersionRestore#368
leotrs wants to merge 6 commits intomainfrom
std-fku4

Conversation

@leotrs
Copy link
Copy Markdown
Collaborator

@leotrs leotrs commented Apr 3, 2026

Summary

  • Implemented useAwareness, useEditor, useYText, and useCurrentUser composables — previously stubs that threw errors, now real inject-based implementations
  • Provided readOnlyCompartment from Canvas.vue → EditorCodeMirror.vue so useEditor can toggle read-only via the same Compartment
  • Wired VersionPreviewModal.vue to call useVersionRestore().restoreVersion() instead of raw window.__cmView.dispatch(), gaining concurrent editor detection, read-only locking, awareness broadcasting, and atomic Y.js transactions

Test plan

  • 26 unit tests pass (useAwareness, useEditor, useYText, useCurrentUser, useVersionRestore)
  • E2E: version restore flow (owner restores version, content replaced via Y.js)
  • E2E: concurrent editor detection shows confirm dialog
  • E2E: read-only lock during restore

🤖 Generated with Claude Code

…sionRestore

Replace throwing stubs with real inject-based implementations for
useAwareness, useEditor, useYText, and useCurrentUser. Provide
readOnlyCompartment from Canvas.vue so useEditor can toggle read-only
state via the same Compartment that EditorCodeMirror uses.

Wire VersionPreviewModal to call useVersionRestore().restoreVersion()
instead of raw window.__cmView.dispatch(), gaining concurrent editor
detection, read-only locking, awareness broadcasting, and atomic Y.js
transactions with origin tagging.

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

netlify bot commented Apr 3, 2026

Deploy Preview for rsm-studio-frontend canceled.

Name Link
🔨 Latest commit 61c1c9f
🔍 Latest deploy log https://app.netlify.com/projects/rsm-studio-frontend/deploys/69d15347fce4e50008d2089e

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for rsm-studio-site canceled.

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

leotrs and others added 2 commits April 4, 2026 04:16
useVersionRestore called useYText/useAwareness/useEditor at setup time,
which threw when injected shallowRefs were null (editor not yet ready).
This crashed VersionPreviewModal on mount, causing 10 E2E failures.

Now uses lazy inject: inject() at setup (Vue requirement), .value access
deferred to restoreVersion(). Modal mounts safely; restore only needs
the editor when actually triggered.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Raw fetch('/api/...') hit Vite's SPA fallback in CI/Docker, returning
index.html instead of version content. Now uses the injected axios api
client (same as VersionPreviewModal) which has the correct baseURL.

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 useVersionRestore composable instead of raw window.__cmView.dispatch(), adding concurrent editor detection (confirm dialog), read-only editor locking during restore, and Y.js awareness broadcasting.

Review checklist:

  1. Open the deploy preview: https://deploy-preview-368--rsm-studio-frontend.netlify.app
  2. Open a file in the editor as the owner
  3. Click version history and select a previous version to preview
  4. Verify the restore button appears and clicking it shows the confirmation step
  5. Confirm the restore and verify content is replaced correctly
  6. Test cancelling the restore — editor content should remain unchanged
  7. If possible, open the same file in two browser tabs to test concurrent editor detection: the second tab should trigger a confirm dialog warning about other active editors

What to look for:

  • Restore completes without errors and editor content matches the restored version
  • Editor is briefly read-only during restore (no typing possible)
  • Cancelling restore at any step leaves the document untouched
  • Error states (e.g., network failure during restore) show an alert and don't leave the editor locked in read-only
  • No regressions in normal editing flow after a restore completes

@leotrs
Copy link
Copy Markdown
Collaborator Author

leotrs commented Apr 4, 2026

Needs human review

What changed: Version restore now goes through useVersionRestore composable instead of raw window.__cmView.dispatch(), adding concurrent editor detection (confirm dialog), read-only editor locking during restore, and Y.js awareness broadcasting.

Review checklist:

  1. Open the deploy preview: https://deploy-preview-368--rsm-studio-frontend.netlify.app
  2. Log in as the file owner and open a document with version history
  3. Open the version preview modal and click "Restore"
  4. Verify the confirmation flow works (click Restore → see confirmation → confirm or cancel)
  5. After confirming, verify the document content is replaced with the restored version
  6. Test cancelling the restore — content should remain unchanged
  7. If possible, open the same document in two browser tabs to test concurrent editor detection: the restoring user should see a confirm dialog naming the other active user(s)

What to look for:

  • Restore button shows correct version number
  • Confirmation dialog appears before restore executes
  • Content is correctly replaced after restore (no partial content, no duplicates)
  • Modal closes properly after successful restore
  • Error alert appears if restore fails (e.g., simulate by disconnecting network)
  • No regressions in the version preview display (content loads, loading/error states work)
  • If testing with two tabs: concurrent editor warning names the other user correctly

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Preview Deploy

Frontend: https://pr-368--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-368@aris.pub

This preview will be destroyed when the PR is closed.

@leotrs
Copy link
Copy Markdown
Collaborator Author

leotrs commented Apr 4, 2026

Needs human review

What changed: Version restore now goes through Y.js transactions via useVersionRestore composable instead of raw window.__cmView.dispatch(), adding concurrent editor detection (confirm dialog), read-only editor locking during restore, and awareness broadcasting.

Review checklist:

  1. Open two browser tabs logged in as different users on the same file
  2. In Tab A, open the version history panel and select a previous version to preview
  3. Verify the version preview modal loads content correctly
  4. With Tab B's cursor active in the editor, click "Restore" in Tab A
  5. Verify a confirmation dialog appears warning about concurrent editors (Tab B)
  6. Click "Cancel" — verify nothing changes in the editor
  7. Click "Restore" again, then "Confirm" — verify:
    • The editor briefly becomes read-only during restore
    • Content is replaced via Y.js (Tab B sees the change in real-time)
    • The "restored" event fires and modal closes properly
  8. Test restoring with no other editors present — confirm dialog should NOT appear
  9. Test restore when editor is not initialized (e.g., navigate away mid-restore) — should show error gracefully

What to look for:

  • Confirm dialog text is clear and mentions the other user(s) by name
  • Editor unlocks after restore completes (not stuck in read-only)
  • Editor unlocks even if restore fails (error path)
  • No content duplication or loss during Y.js transaction
  • Awareness state clears after restore (no stale "restoring" indicator)

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