Repository navigation
refactor(core): serve the goal over a plugin RPC instead of session metadata - #59850
Merged
Merged
Conversation
added 2 commits
October 28, 2026 08:47
added 4 commits
October 28, 2026 09:34
# Conflicts: # packages/gui-plugins/src/goal/renderer.tsx
1 task done
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.
Issue for this PR
Stacked on #59437, so it targets
client-done-check. It's a variant for comparison: the/goalstate moves out of Session metadata and behind the goal plugin's own RPC. No new package: the plugin stays in core, and its RPC contract lives in@opencode/schema.Type of change
What does this PR do?
In #59437 the goal lives in Session metadata under
opencode.goal. That has three problems:sessionID.@opencode/schema/session-goal.Here the goal plugin owns its state and serves it over a plugin RPC:
@opencode/schema/goal, replacing@opencode/schema/session-goal):Goal.StatewithoutsessionID, plusGoal.Definition, an RPCopencode.goalwithget({ sessionID })and achangedevent{ sessionID, goal }. It describes the RPC, not storage. Its schemas are wrapped withSchema.toStandardSchemaV1, so the Promise client can call it.core/src/plugin/goal.ts):session:<id>. Plugin storage isn't per Location, so a goal follows its Session when it moves, and children and forks start without one.changedin the Session's Location.session.deletedremoves the entry. The startup sweep pages through every stored goal, pausing goals left by an earlier process and dropping goals of deleted Sessions. Before, it checked the 100 most recent Sessions./goal pause,resumeandclearare unchanged.gui-plugins/src/goal/renderer.tsx):createKeyedrun per routed Session while its server is connected:getfor the current value, thenchanged.changedis ignored.prompt/goal.tsx):createSessionGoal, the same pattern. It fetches on Session change and afterserver.connected, followschanged, and ignores replies older than the last change. The footer owns it and passes it to the status item and the dialog.@opencode/schema/session-goal, withSessionGoal.KEYandfromMetadata. The client store's handling ofsession.metadata.updatedfrom feat(core): add /goal with a client-side done check #59437 stays, since it's a general fix.The client cost is one
getper routed Session, plus one after each reconnect. RPC events ride the client's shared event stream, so there's no extra connection.Trade-offs
changedis published in the Session's Location. The startup sweep runs in whichever Location loads first, so a goal it pauses in another Location is only picked up by that Location's clients on their next fetch: a reconnect, which follows the restart anyway, or a route.How did you verify your code works?
goal-watchdog.test.ts, new "serves the goal over RPC and publishes every change":getreturns null, then the paused goal, then null afterclear.changedcarries active, paused, then null. It fails if writes stop publishing the goal.goal.test.ts: the full-stack scenarios now seed and read goals through the plugin's real storage (PluginHost.storage). The child-Session case now checks that a child created during an active goal has no goal and isn't driven.prompt-footer.test.tsx: the footer shows the goal fromget, followschangedfor its own Session only, and clears ongoal: null. It fails if the Session filter is removed, and passes--rerun-each 10.bun run check,lint:changedand the SDK docs check pass.@opencode/schemapassestypecheck:tsc.plugin-graphandplugin-hostcomponent tests (30) all pass.Checklist