fix(web): restore the goal card after a page refresh - #1606
Conversation
🦋 Changeset detectedLatest commit: e5b5b9c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c314744e1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb3d8a5301
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb3d8a5301
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…the recovery race
Related Issue
None — the problem is described below.
Problem
On the web UI, when a session has an active goal, the goal card above the composer disappears after a full page refresh and only reappears when the next live
goal.updatedWebSocket event happens to arrive.Root cause: the web keeps goal state only in memory, populated exclusively by live
goal.updatedevents. The refresh recovery path — fetch the session snapshot, then subscribe to the WS from the snapshot'sas_of_seqwatermark — never replays the historical goal event, and no REST endpoint exposed the current goal.What changed
GET /api/v1/sessions/{id}/goal, returning the current goal snapshot (same camelCase shape as thegoal.updatedevent payload) ornullwhen no goal is active. Implemented on the v2 engine (kap-server) throughISessionLegacyService, with the response schema shared in@moonshot-ai/protocol. The v1 engine intentionally does not implement it; the web treats a missing endpoint as "no recovery data" and keeps its live-event behavior there.getSessionGoalAPI method, plusrefreshSessionGoal, which folds the result into the goal store with the same semantics as the live-event reducer (null/complete clears the card, otherwise replace). It runs fromrefreshSessionSidecars, so a page refresh or session switch recovers the card without any new request path.goal_objective), web client mapping tests (snapshot / null / request URL), updated API surface snapshots, and the workspace-state deps mock.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update (bug fix restoring expected behavior; no user-facing doc changes).