-
Notifications
You must be signed in to change notification settings - Fork 360
fix: persist transcripts on idle + reconnect idle workers on restart #334
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
58acc81
fix: persist transcript incrementally for interactive workers on idle
jamiepine 14e9b0f
feat: reconnect idle interactive workers on restart
jamiepine 26d578f
fix: enforce interactive-only opencode workers and one-per-directory …
jamiepine b58bca5
fix: address review feedback on idle worker resilience
jamiepine 43c4d03
fix: leave idle workers as idle when resume fails on restart
jamiepine 8409026
fix: persist opencode session metadata and show idle workers in chann…
jamiepine 285e1d6
fix: retire expired idle workers on restart and clean up event routing
jamiepine 987fc0b
fix: persist worker directory for correct idle-worker resume
jamiepine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Persist the working directory for opencode workers so that idle workers | ||
| -- can be resumed into the correct directory after a restart. | ||
| ALTER TABLE worker_runs ADD COLUMN directory TEXT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
claim_directorycall for resumed OpenCode workers.spawn_opencode_worker_from_statecallsserver_pool.claim_directory(&directory)to prevent concurrent workers on the same directory, butresume_idle_worker_into_statedoes not. This creates a race condition at startup:/path/to/projectis resumedAdditionally, there's no corresponding
release_directorycall in the resume path's completion handler.🐛 Proposed fix: Add directory claim/release to resume path
let directory = rc.workspace_dir.clone(); let server_pool = rc.opencode_server_pool.load().clone(); + // Claim directory to prevent concurrent workers (same as spawn path). + server_pool + .claim_directory(&directory) + .await + .map_err(|e| e.to_string())?; + + let release_pool = server_pool.clone(); + let release_directory = directory.clone(); + let result = crate::opencode::OpenCodeWorker::resume_interactive(And in the async worker task (around line 807):
async move { - let result = worker.run().await.map_err(SpacebotError::from)?; + let result = worker.run().await.map_err(SpacebotError::from); + + // Release directory claim regardless of success/failure. + release_pool.release_directory(&release_directory).await; + + let result = result?; // Persist final transcript.🤖 Prompt for AI Agents