fix(sync): route question/permission replies by the request's own session directory

Answering a question tool (or a permission prompt) could leave the session
permanently stuck on "asking question": resolveDirectoryForBlockingRequest
returned the containing child-store key, which only proves containment.
For a worktree session (or any session whose record is grouped under a
parent project store), the reply was addressed to the parent directory's
OpenCode instance, where the pending request does not exist - the server
answered QuestionNotFoundError, the local request was removed, and the
trailing question-tool part stayed running with no recovery until Stop.

Resolve the directory from the request's own session record (server-
confirmed ownership: session.directory, then project.worktree) before
falling back to the containing store key. When a reply/reject comes back
not-found, also enqueue the settled-running-tool tail materialization so
the tool part converges to the server's actual state instead of leaving
the UI stuck.

Refs OPE-236
This commit is contained in:
Serhii Dziupin
2026-08-05 11:41:40 +03:00
parent 34c221b07f
commit 0116739111
4 changed files with 256 additions and 4 deletions
+6
View File
@@ -2260,6 +2260,12 @@ export function SyncProvider(props: {
props.sdk,
childStores,
() => opencodeClient.getDirectory() || props.directory,
(directory, sessionID, messageID) => {
enqueueSessionMaterialization(directory, sessionID, childStores, {
reason: "settled-running-tool",
messageID,
})
},
)
return () => {
if (getImperativeSessionMessageLoader() === messageLoader) {