Skip to content

Conversation

@ellisonbg
Copy link
Collaborator

Summary

Fixes the real-time synchronization issue where clearing cell outputs in a collaborative notebook session only affected the local user. Other connected users would continue to see the outputs until they reloaded the notebook.

Problem

The current implementation in PR #147 clears outputs from disk storage but doesn't update the shared YDoc that powers real-time collaboration between multiple users.

Solution

Reversed the order of operations in the output clearing process:

  1. FIRST: Clear outputs from YDoc immediately → All users see the change instantly
  2. SECOND: Make API call to clear disk storage → Ensures persistence

Key Changes

  • Added sharedCodeCell.setOutputs([]) before the API call
  • Improved error handling with early returns
  • Enhanced logging to distinguish between YDoc and disk operations
  • Maintains backward compatibility with existing API

Testing

  • ✅ Single user: Output clearing works as before
  • ✅ Multiple users: All connected clients see cleared outputs immediately
  • ✅ Network failures: Real-time collaboration works even if disk API fails
  • ✅ Error handling: Graceful degradation with proper error logging

Technical Details

The frontend already observes YDoc outputsChange events (lines 40-75 in notebook-factory.ts), so clearing the shared model automatically triggers UI updates across all connected clients.

This approach follows the same pattern used for adding outputs in real-time and provides better user experience with instant feedback.

3coins and others added 3 commits August 11, 2025 14:18
Improve output clearing to work properly in collaborative environments by:

1. Immediate YDoc clearing: Clear outputs from shared document first for instant real-time sync to all connected clients
2. Async disk cleanup: Make API call to clear disk storage as secondary operation
3. Better error handling: Add early returns and improved error messages
4. Enhanced reliability: Real-time collaboration works even if disk API fails

This fixes the issue where one user clearing outputs wouldn't be visible to other users until they reloaded the notebook.
@ellisonbg
Copy link
Collaborator Author

@Zsailer @3coins revision of #147

@ellisonbg
Copy link
Collaborator Author

Ping @3coins for review

@3coins 3coins added the bug Something isn't working label Oct 14, 2025
Copy link
Collaborator

@3coins 3coins left a comment

Choose a reason for hiding this comment

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

@ellisonbg
Thanks for submitting this fix. Looks good, there is a build error that requires a lint fix, but ok otherwise. I ran lint locally, but wasn't able to push because your fork doesn't exist anymore.

@3coins 3coins merged commit a7d7231 into jupyter-ai-contrib:main Oct 14, 2025
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants