Skip to content
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

fix(project-reload): execution order is fix, this fixes the inconsistency on project reload #308

Conversation

thecodacus
Copy link
Collaborator

@thecodacus thecodacus commented Nov 17, 2024

Fix Action Execution Order and Command Synchronization

Overview

This PR implements a global execution queue to ensure proper synchronization of file operations and shell commands, particularly during project reloads and code streaming. It addresses issues with command execution order and eliminates UI flickering during code streaming operations.

Key Changes

1. Global Execution Queue

  • Added #globalExecutionQueue to WorkbenchStore to manage sequential execution
  • Implemented queue management methods to ensure operations run in correct order
  • Modified action handling to respect queue ordering

2. Action Runner Updates

  • Made start actions non-blocking while maintaining execution order
  • Added delay between start actions to prevent race conditions
  • Improved promise chain handling in action execution

3. Workbench Store Improvements

  • Split action handling into public and private methods for better control
  • Modified file operations to properly integrate with execution queue
  • Updated document reset timing to prevent UI flickering

Technical Details

The core improvement revolves around the introduction of a Promise-based execution queue:

#globalExecutionQueue = Promise.resolve();

addToExecutionQueue(callback: () => Promise<void>) {
  this.#globalExecutionQueue = this.#globalExecutionQueue.then(() => callback());
}

This ensures that:

  • File operations complete before related shell commands execute
  • Commands execute in the exact order they were triggered
  • UI updates happen at appropriate times without race conditions

Benefits

  1. Consistent command execution order during project reloads
  2. Eliminated UI flickering during code streaming
  3. More reliable file system synchronization
  4. Better handling of rapid sequential operations

Testing

  • Verified correct operation order in new chat sessions
  • Confirmed proper behavior in restored chat sessions
  • Tested multiple rapid file operations and shell commands
  • Verified proper handling of code streaming scenarios

Migration Impact

  • No breaking changes to existing functionality
  • No API changes required for consumers
  • Fully backward compatible with existing implementations

Preview

demo2.mov

@thecodacus thecodacus changed the title fix(project-reload): execution order is fixed, fix inconsistency on on project reload fix(project-reload): execution order is fix, this fixes the inconsistency on project reload Nov 17, 2024
@thecodacus thecodacus closed this Nov 17, 2024
@thecodacus thecodacus deleted the fix-project-reload-execution-order branch November 17, 2024 07:15
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