fix(run): pass directory to event.subscribe for session-scoped SSE events #1783
+57
−15
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.
Problem
oh-my-opencode runfails to receive session-scoped SSE events from the OpenCode server, causing the CLI to either hang indefinitely or exit for unrelated reasons.Root Cause
In
runner.ts, the event stream subscription was missing thedirectoryparameter:Without
directory, the Go-based OpenCode server's SSE endpoint (GET /event) only emits global events:But does NOT emit session-scoped events:
This causes:
hasReceivedMeaningfulWorkstays false forever (no message/tool events)mainSessionIdlenever updates (no session.idle/status events)pollForCompletioneither hangs or exits for unrelated reasonsFix
{ directory }toclient.event.subscribe(), matching the pattern already used byclient.session.promptAsync()Changes
src/cli/run/runner.ts: Add directory parameter to event subscriptionsrc/cli/run/poll-for-completion.ts: Add MIN_STABILIZATION_MS and firstWorkTimestamp trackingsrc/cli/run/poll-for-completion.test.ts: Add stabilization period test + update existing testsTesting
74 tests pass across 10 files in
src/cli/run/Summary by cubic
Fixes missing session-scoped SSE events in
oh-my-opencode runby passing the working directory as a query toevent.subscribe, preventing hangs and premature exits. Adds a 10s stabilization window after first meaningful work to avoid early-exit races.Bug Fixes
Dependencies
Written for commit 9afd0d1. Summary will update on new commits.