Repository navigation
Conversation
🦋 Changeset detectedLatest commit: c78cdd7 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes the semantics of a telemetry metric (user_turn_count) consumed by external analytics dashboards and touches the public SDK export surface, so a maintainer should confirm the downstream contract impact.
1 open finding
What changed in this PR
This PR changes how the user_turn_count field is populated in rating-survey telemetry events (feedback_survey / long_context_survey). Previously it counted only user turns since the current TUI mount, which reset to 0 after resuming an existing multi-turn session. It now reports a session-cumulative count derived from the main agent's full append-only journal, while the survey pop-up gating thresholds continue to use the mount-relative count. This introduces a small additive SDK surface (Session.readMainAgentLog, SessionLogRecord, isUserTurnOrigin) and wires a per-turn log cache into the TUI.
Changes:
- Added
Session.readMainAgentLog(abstract onSDKRpcClientBase, implemented inSDKRpcClientV2by flushing the dispatcher and reading the whole journal) plus theSessionLogRecordtype and theisUserTurnOriginpredicate reusing the engine's undo-anchor rule. - TUI now caches the main-agent log (refreshed on every user-turn end, invalidated by a sequence counter and session identity, cleared on reset) and the survey controller reports the log-derived session count while renaming the mount-relative fields (
userTurnCount→mountUserTurnCount, etc.). - Extracted
sseChunk/sseBodytest helpers and added comprehensive tests across the SDK, TUI wiring, and survey controller.
| File | Description |
|---|---|
packages/node-sdk/src/context.ts |
Adds isUserTurnOrigin wrapping engine isUndoAnchorOrigin. |
packages/node-sdk/src/types.ts |
Adds SessionLogRecord (type + optional origin). |
packages/node-sdk/src/rpc.ts |
Declares abstract readMainAgentLog. |
packages/node-sdk/src/sdk-rpc-client-v2.ts |
Implements readMainAgentLog via flush + readJournal projection. |
packages/node-sdk/src/session.ts |
Passthrough Session.readMainAgentLog. |
packages/node-sdk/src/index.ts |
Exports isUserTurnOrigin. |
apps/kimi-code/src/tui/utils/survey-policy.ts |
Adds countSessionUserTurns. |
apps/kimi-code/src/tui/kimi-tui.ts |
Log cache, per-user-turn refresh, reset clearing. |
apps/kimi-code/src/tui/controllers/survey-controller.ts |
Payload uses session count; renames mount-relative fields; keeps gate on mount count. |
packages/node-sdk/test/*, apps/kimi-code/test/tui/* |
New tests + shared SSE helper extraction. |
.changeset/survey-session-user-turns.md |
Patch changeset describing the behavior change. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c625c7dd46
ℹ️ 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: 2fb6736366
ℹ️ 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".
43c149a to
53913bd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53913bd0b8
ℹ️ 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".
53913bd to
1be2dc2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1be2dc2ed1
ℹ️ 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 |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |

Requirement or Bug
Resume 一个已有多轮对话的 session 后,评分埋点里的
user_turn_count从 0 重新计数,同一段会话多次挂载上报的轮数对不上它实际经过的用户轮。本 PR 把该字段改为按主 agent 整本日志的会话累计口径上报;问卷的弹出轮数门禁保持挂载后口径不变。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
两个计数口径拆开,门禁不动,只换事件负载的来源:
packages/node-sdk/src/ rpc.ts # 抽象 readMainAgentLog(仅 SDKRpcClientV2 一个实现) sdk-rpc-client-v2.ts # 实现:main agent 整本 journal → {type, origin} 投影 session.ts # Session.readMainAgentLog 透传 types.ts # SessionLogRecord context.ts # isUserTurnOrigin(包引擎 isUndoAnchorOrigin,单一来源) apps/kimi-code/src/tui/ controllers/survey-controller.ts # user_turn_count 走会话轮次;挂载计数字段更名 kimi-tui.ts # 日志缓存、用户轮结束触发重读、reset 清零 utils/survey-policy.ts # countSessionUserTurnsBehavior Changes and Affected Users
feedback_survey/long_context_survey事件的user_turn_count/clear前的轮仍计入(append-only 日志的必然结果);取消/失败的已开跑轮计入log.warn留痕packages/node-sdk/src/index.ts)Session.readMainAgentLog、SessionLogRecord、isUserTurnOrigin;无删除、无签名变更log.warn('main agent log read failed')并回退旧口径受影响模块与测试覆盖:
survey-controller.test.ts新增 6 个用例:日志计数口径、来源分类矩阵(普通 prompt / 夹带 skill //skill/ 插件命令各算 1;steer、cron、goal 续跑、系统提醒、shell、注入、压缩摘要不计)、门禁只用挂载轮(日志 20 轮时挂载 4 轮仍不弹)、同一 Appearance 三事件同数、长上下文臂带会话轮次且仍由 token 触发、20 轮会话跨 resume 的 worked example(23 → remount 后 26)。kimi-tui-message-flow.test.ts新增接线用例:假日志 8 轮 → 埋点报 8 而非挂载的 5,钉住"轮结束→重读→缓存→快照"链路。sdk-rpc-client-v2.test.ts新增用例:真引擎 2 个完成轮 + 1 个取消轮后整本日志数为 3;undo、resume 后不变。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.