Skip to content

poc: state machine for file management #2279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spartan-vutrannguyen
Copy link
Contributor

@spartan-vutrannguyen spartan-vutrannguyen commented Jun 25, 2025

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Introduce StateMachineFileSyncManager for file synchronization with state management and integrate it into SandboxManager.

  • State Machine Implementation:
    • Introduces StateMachineFileSyncManager in file-sync-state-machine.ts to manage file states ('clean', 'dirty', 'syncing', 'conflict').
    • Handles file and binary file synchronization with methods like saveFile(), saveBinaryFile(), onRemoteChange(), and conflict resolution methods.
  • Integration:
    • Replaces FileSyncManager with StateMachineFileSyncManager in SandboxManager in index.ts.
    • Updates methods like writeFile(), writeBinaryFile(), and handleFileChange() to use the new state machine.
  • Testing:
    • Adds state-machine-file-sync.test.ts with tests for file operations, state transitions, conflict detection/resolution, and storage persistence.

This description was created by Ellipsis for 1a784a5. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 11:37pm
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 11:37pm

Copy link

supabase bot commented Jun 25, 2025

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

this.pendingWrites.delete(filePath);
this.setState(filePath, 'dirty');
// Schedule another sync for the pending content
this.scheduleRemoteSync(filePath, pendingContent, writeRemote);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider awaiting the recursive call to scheduleRemoteSync so that errors and order are properly propagated instead of fire-and-forget.

Suggested change
this.scheduleRemoteSync(filePath, pendingContent, writeRemote);
await this.scheduleRemoteSync(filePath, pendingContent, writeRemote);

@Kitenite Kitenite changed the title init poc: state machine for file management Jun 25, 2025
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