fix(opencode): route session.created through event dispatcher (421)#442
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(opencode): route session.created through event dispatcher (421)#442ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
opencode >= 1.15 dispatches session/lifecycle events through a single `event` handler that switches on `event.type`. The previous direct top-level `'session.created'` key was silently ignored, so the `.caveman-active` flag was never written on session start and the per-prompt reinforcement in `tui.prompt.append` bailed every turn. Extract `handleSessionCreated` and wire it under an `event` dispatcher that filters on `event.type === 'session.created'`. `tui.prompt.append` is unchanged — TUI events still use the direct-key pattern. Co-Authored-By: Claude <noreply@anthropic.com>
Author
Verified RED/GREEN proof (run on
|
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.
Summary
Fixes #421 — opencode plugin's
session.createdhandler never fires on opencode >= 1.15.opencode >= 1.15 dispatches session/lifecycle events through a single
eventhandler that switches onevent.type(plugin docs). The previous direct top-level'session.created'key was silently ignored, so the.caveman-activeflag was never written on session start and the per-prompt reinforcement intui.prompt.appendbailed every turn (it reads the flag and returns when empty). Always-on caveman in opencode kept working only via the separately-installed~/.config/opencode/AGENTS.md; the plugin's dynamic-state layer was silently inert.tui.prompt.appendis unchanged — TUI events still use the direct-key pattern.Fix
handleSessionCreated(single source for session-start logic, reusable from any dispatcher).'session.created'key with aneventhandler that filters onevent.type === 'session.created'.TDD verification
mainwithout prod fix): 2/2 new tests failevent handler missing—typeof handlers.event === 'function'asserts undefinedhandlers.event is not a function— TypeError on the new event-dispatch testVerification
main: 51 total, 47 pass, 4 pre-existing failures (installer command-file copy, unrelated)eventdispatcher ignores unrelated event types + dispatchessession.created); 1 modified to use the v1.15 dispatch shape and assert the direct-key is goneFiles changed
src/plugins/opencode/plugin.jshandleSessionCreated; route througheventdispatchertests/installer/opencode.test.mjseventdispatcher coverage test