Skip to content

Feat/task scheduling#94

Open
abelfx wants to merge 7 commits into
surafelfikru:interns/devfrom
abelfx:feat/task_scheduling
Open

Feat/task scheduling#94
abelfx wants to merge 7 commits into
surafelfikru:interns/devfrom
abelfx:feat/task_scheduling

Conversation

@abelfx
Copy link
Copy Markdown

@abelfx abelfx commented Apr 14, 2026

This pull request adds a global write lock to the backend to ensure only one write operation (such as CLEAR, UPLOAD, COMPOSITION, etc.) is processed at a time, and updates the frontend to display a "Queued..." status when a command is waiting for the lock. It also improves event messages for more accurate UI updates and user feedback.

Backend: Write Lock Implementation and Integration

  • Introduced a global write lock using tokio::sync::Mutex in the backend, ensuring only one write operation can be processed at a time. The lock is shared via the SseState struct and acquired in all relevant routes before starting a write job (api/src/routes/sse.rs, api/src/lib.rs, api/src/routes/spaces.rs, api/src/scheduler.rs). - When the lock is busy, a log message ("Write queue busy, waiting for turn...") is broadcast to the frontend so the UI can indicate the queued state (api/src/scheduler.rs).

Backend: Event and Broadcast Improvements

  • Enhanced SSE event messages to include the command name for both success and error events, allowing the frontend to accurately track which command completed (api/src/sse_utils.rs, api/src/routes/spaces.rs).

Frontend: Queued State Display

  • Added logic to detect when a command is queued (waiting for the write lock) and display "Queued..." on action buttons in the UI for Clear and Composition pages (frontend/src/lib/sse.ts, frontend/src/pages/clear/Clear.tsx, frontend/src/pages/clear/lib.ts, frontend/src/pages/composition/Composition.tsx, frontend/src/pages/composition/lib.ts).
  • Updated frontend event handling to parse the new event message format and only clear the active command when the correct command completes or fails (frontend/src/lib/sse.ts).

These changes improve consistency, prevent concurrent write issues, and provide clearer feedback to users about the status of their requests.

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