fix(opencode): write tool causes client to hang indefinitely when creating new files#15684
Open
Owen718 wants to merge 1 commit intoanomalyco:devfrom
Open
fix(opencode): write tool causes client to hang indefinitely when creating new files#15684Owen718 wants to merge 1 commit intoanomalyco:devfrom
Owen718 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
…ating new files The write tool was missing ctx.metadata() call that signals tool completion to the client. This caused clients (like IntelliJ with ACP) to hang indefinitely when creating new files. - Added ctx.metadata() call in write.ts - Added test to verify metadata is called Fixes anomalyco#15675
eb28492 to
cfe2d58
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix:
writetool causes client to hang indefinitely when creating new filesThe write tool was missing ctx.metadata() call that signals tool completion to the client. This caused clients (like IntelliJ with ACP) to hang indefinitely when creating new files.
Fixes #15675
Issue for this PR
Closes #15675
Type of change
What does this PR do?
Problem: When using the
writetool to create a new file via the ACP protocol, the client hangs indefinitely showing a "waiting" indicator. The file is successfully created on disk, but the client never receives a completion signal.Root Cause: The
writetool implementation was missing thectx.metadata()call that signals tool completion to the client. Looking at the codebase,edit.tsandbash.tsboth correctly callctx.metadata()before returning their results, which is why those tools work properly.Fix: Added
ctx.metadata()call inwrite.tsimmediately before returning the result. This signals to the client that the tool execution has completed successfully.Changes:
packages/opencode/src/tool/write.ts: Addedctx.metadata()call with diagnostics, filepath, and exists metadatapackages/opencode/test/tool/write.test.ts: Added test case to verifyctx.metadata()is called during write operationsHow did you verify your code works?
Ran the existing test suite for the write tool:
All 14 tests pass, including the new test that specifically verifies
ctx.metadata()is called.Also verified TypeScript compilation passes.
Screenshots / recordings
N/A - This is a backend/protocol fix, no UI changes.
Checklist