Skip to content

fix(web): restore the goal card after a page refresh - #1606

Merged
liruifengv merged 4 commits into
mainfrom
fix/web-goal-card-refresh
Jul 13, 2026
Merged

fix(web): restore the goal card after a page refresh#1606
liruifengv merged 4 commits into
mainfrom
fix/web-goal-card-refresh

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

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.updated WebSocket event happens to arrive.

Root cause: the web keeps goal state only in memory, populated exclusively by live goal.updated events. The refresh recovery path — fetch the session snapshot, then subscribe to the WS from the snapshot's as_of_seq watermark — never replays the historical goal event, and no REST endpoint exposed the current goal.

What changed

  • Add GET /api/v1/sessions/{id}/goal, returning the current goal snapshot (same camelCase shape as the goal.updated event payload) or null when no goal is active. Implemented on the v2 engine (kap-server) through ISessionLegacyService, 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.
  • Web: new getSessionGoal API method, plus refreshSessionGoal, 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 from refreshSessionSidecars, so a page refresh or session switch recovers the card without any new request path.
  • Tests: kap-server route test (null before, active goal after goal_objective), web client mapping tests (snapshot / null / request URL), updated API surface snapshots, and the workspace-state deps mock.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update (bug fix restoring expected behavior; no user-facing doc changes).

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e5b5b9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@e5b5b9c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@e5b5b9c

commit: e5b5b9c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/kimi-web/src/composables/useKimiWebClient.ts
Comment thread apps/kimi-web/src/composables/useKimiWebClient.ts
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/kimi-web/src/composables/useKimiWebClient.ts
Comment thread packages/agent-core-v2/src/app/sessionLegacy/sessionLegacy.ts
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/kimi-web/src/composables/useKimiWebClient.ts Outdated
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@liruifengv
liruifengv merged commit 2da45fc into main Jul 13, 2026
10 checks passed
@liruifengv
liruifengv deleted the fix/web-goal-card-refresh branch July 13, 2026 11:50
@github-actions github-actions Bot mentioned this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants