Repository navigation
feat(prediction): refine next-prompt interactions - #5180
Conversation
🦋 Changeset detectedLatest commit: 7862b84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f89d4ae5c
ℹ️ 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".
| function handleTurnEnded(sessionId: string, sourceId: string, turnId: number, completed: boolean): void { | ||
| latestTurn.value = undefined; | ||
| dismissForSession('new_turn', sessionId); | ||
| if (!completed) return; | ||
| latestTurn.value = { sessionId, sourceId, turnId }; | ||
| pending.value = latestTurn.value; |
There was a problem hiding this comment.
Keep prediction turn state scoped to the active session
When a subscribed background session starts or ends a turn, these handlers overwrite the single global latestTurn, even though createConversationPool keeps up to three parked sessions subscribed. For an experimental Desktop/Web user who switches away while another session is running, that background event can erase or replace the active session's prediction target; promptPredictionHasTurn may then show “Press Tab to predict” in the active session while accept() targets the background session and canPredict rejects it. Ignore non-active-session events here or maintain prediction targets per session.
Useful? React with 👍 / 👎.
| if (this.suggestion?.accepted === false) { | ||
| return this.suggestion.parked ? 'Type a message… Tab to predict' : this.suggestion.prediction; | ||
| } | ||
| if (this.latestTurn === undefined) return undefined; | ||
| return this.attempted.has(`${this.latestTurn.session.id}:${String(this.latestTurn.turnId)}`) ? undefined : 'Tab to predict'; |
There was a problem hiding this comment.
Show the recall hint for an accepted cached prediction
After an experimental TUI user accepts a prediction and clears the editor, handleEditorChange restores the cached prediction and Tab can insert it again, but this branch only renders suggestions whose accepted flag is false. Because the turn is already in attempted, the fallback also returns undefined, leaving the newly supported repeat-recall action completely invisible. Render the recall placeholder for the accepted cached state as well.
Useful? React with 👍 / 👎.
| predictPromptResponseSchema, | ||
| cancelPromptPredictionResponseSchema, |
There was a problem hiding this comment.
Refresh the pinned API contract after adding responses
Adding these response schemas changes the generated OpenAPI contract for the existing /sessions/{tail} action route, but HOST_CONTRACT in packages/kap-server/test/apiSurface.snapshot.test.ts still pins the previous digest. The pins the host API level to the client-visible contract test canonicalizes response schemas and will therefore fail for every run; keep API level 1 if this additive change is compatible, but regenerate and commit the new digest.
Useful? React with 👍 / 👎.
2125008 to
bee5664
Compare
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bee5664fd2
ℹ️ 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".
| watchEffect(() => { | ||
| promptPredictionController.refresh(); |
There was a problem hiding this comment.
Dismiss predictions when modes become ineligible
When an experimental Desktop/Web user enables Plan or Goal mode from the Add menu while a completed-turn suggestion is cached, canUsePromptPrediction merely hides the suggestion and this effect only calls refresh(). Disabling the mode therefore makes the stale pre-mode suggestion reappear, and an in-flight request is likewise left running rather than cancelled. Watch eligibility transitions and dismiss the prediction when one of these invalidating modes becomes active.
Useful? React with 👍 / 👎.
| predictionSourceId: turn.turn_id, | ||
| predictionTurnId: turn.ordinal, |
There was a problem hiding this comment.
Clear the prediction target when turns are removed
When a Desktop/Web user chooses Edit on an earlier message, the resulting undo emits turns.removed, but onMainTurnsRemoved never clears the target or cached suggestion established here. After the removed prompt is loaded into the composer and then cleared, the prediction derived from the now-undone turn can reappear and be accepted; dismiss predictions whose source turn is among the removed IDs.
AGENTS.md reference: AGENTS.md:L111-L116
Useful? React with 👍 / 👎.
| const promptPredictionIdle = computed(() => | ||
| client.experimentalFlags.value['prompt_prediction'] === true && | ||
| client.promptPredictionHasTurn?.value === true && | ||
| props.placeholderText === undefined && | ||
| !starting.value && | ||
| !isSideChat.value && |
There was a problem hiding this comment.
Hide keyboard-only prediction controls on touch layouts
On a touch-only mobile Web layout, this condition enables the prediction placeholder and can display “Press Tab to predict,” but the only acceptance paths added by this change are the Tab and ArrowRight key handlers; there is no button, click, or touch action that inserts the suggestion. Either exclude isMobile here or provide a touch affordance and mobile-specific copy.
Useful? React with 👍 / 👎.
| | `GET /api/v1/sessions` / `GET /api/v1/sessions/{session_id}` | `baseline` | List sessions across workspaces (`flat` or `by_workspace`, filters incl. `query` over title / last prompt / exact id, pagination) or get one session | | ||
| | `POST /api/v1/sessions/{session_id}:wait` | `session_wait` | Wait until `activity !== "turn"`, a pending interaction appears, or `timeout_ms` (`0..60000`, default `15000`) | | ||
| | `POST /api/v1/sessions/{session_id}:cancel` | `baseline` | Cancel active turn (`agent_id?`, `include_background?`) | | ||
| | `POST /api/v1/sessions/{session_id}:predict-prompt` / `:cancel-prompt-prediction` | `experimental` | Generate or cancel a next-prompt prediction (`prediction_id`, `expected_turn_id`, optional `reason`) | |
There was a problem hiding this comment.
Add a kap-server changeset for the new public actions
These newly documented HTTP actions are externally visible KAP behavior owned by @moonshot-ai/kap-server, but the PR's two changesets only list the CLI and Desktop products. Without an owning-package changeset, the kap-server release and changelog omit the protocol addition; add a technical kap-server entry alongside the product entries.
AGENTS.md reference: AGENTS.md:L128-L135
Useful? React with 👍 / 👎.
| promptId: openerPromptId(turn), | ||
| ratingTurnId: turn.turn_id, | ||
| predictionSourceId: turn.turn_id, | ||
| predictionTurnId: turn.ordinal, |
There was a problem hiding this comment.
Pass the daemon turn number to prediction
When a conversation contains a system or ownerless turn, such as a background-task notification or fork boundary, its ordinal advances even though the agent loop's numeric turn ID does not. The prediction service compares expectedTurnId strictly against that loop ID, so every later request sent from this line is rejected as stale; pass the agent turn's turn_number instead, and skip prediction when it is unavailable.
AGENTS.md reference: AGENTS.md:L111-L116
Useful? React with 👍 / 👎.
3997757 to
7b2d689
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b2d6894e6
ℹ️ 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".
| } | ||
| const current = suggestion.value; | ||
| if (current === null || (sessionId !== undefined && current.sessionId !== sessionId)) return dismissed; | ||
| if (current.accepted && reason === 'escape') return dismissed; |
There was a problem hiding this comment.
Allow Escape to dismiss a recalled prediction
When a Desktop/Web user accepts a prediction, clears the composer, and sees the cached prediction recalled as ghost text, this branch prevents Escape from dismissing it. The suggestion therefore keeps reappearing until a submit, new turn, or session change, unlike an unaccepted suggestion and the equivalent TUI flow; only preserve the accepted cache while it is not being displayed, or let Escape clear it once recalled.
Useful? React with 👍 / 👎.
| content: { | ||
| messages: historyFromContext([...contextSnapshot, createUserMessage(PROMPT_PREDICTION_INSTRUCTION)]), | ||
| }, | ||
| model: { responseFormat: PROMPT_PREDICTION_RESPONSE_FORMAT }, |
There was a problem hiding this comment.
Add the agent-core-v2 changeset
This commit changes @moonshot-ai/agent-core-v2 source behavior by requiring and parsing structured prediction responses, but neither changeset names that library. The repository requires a technical changeset for every non-ignored library source change, so the agent-core-v2 release and changelog would omit this behavior; add a patch entry for that package.
AGENTS.md reference: AGENTS.md:L169-L170
Useful? React with 👍 / 👎.
| content: { | ||
| messages: historyFromContext([...contextSnapshot, createUserMessage(PROMPT_PREDICTION_INSTRUCTION)]), | ||
| }, | ||
| model: { responseFormat: PROMPT_PREDICTION_RESPONSE_FORMAT }, |
There was a problem hiding this comment.
Fall back when the model lacks JSON-schema output
For experimental users whose session uses an OpenAI-compatible gateway or model that does not implement response_format.type=json_schema, this unconditional override turns the previously plain-text prediction call into a rejected request, which predict() catches and silently converts to no suggestion. The model/provider capability is not checked before the OpenAI adapter emits the schema field, so retain a plain-text or JSON-object fallback when structured schema output is unavailable.
Useful? React with 👍 / 👎.
| predictNextPrompt: 'session', | ||
| cancelPromptPrediction: 'session', |
There was a problem hiding this comment.
Gate predictions on the target host's feature support
For a Desktop user viewing a session on an SSH host, these methods are routed to the remote daemon, but prediction eligibility is derived from getMeta() on the local daemon. Consequently, enabling the flag only locally sends requests that the remote flag rejects, enabling it only remotely never attempts prediction, and an older API-level-1 remote can reject the newly added action altogether; read or probe prediction support from the session's target host before exposing the interaction.
Useful? React with 👍 / 👎.
| 'predict-prompt': { | ||
| body: predictPromptRequestSchema, | ||
| handle: predictPromptAction, | ||
| }, |
There was a problem hiding this comment.
Share the one-per-turn result across connected clients
When a TUI and Desktop/Web client are connected to the same session, both request a prediction after the same completion, but this new action reaches one session-scoped service whose first request marks the turn attempted and whose response is returned only to that requester. The other client therefore receives null, and if the winner switches sessions or hides the window, neither client can retry; cache the generated result per turn for later callers or otherwise coordinate ownership across clients.
AGENTS.md reference: AGENTS.md:L111-L116
Useful? React with 👍 / 👎.
7b2d689 to
f63dfc5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f63dfc541d
ℹ️ 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".
|
|
||
| const promptPredictionController = createPromptPrediction({ | ||
| api: getKimiWebApi, | ||
| isActiveSession: (sessionId) => sessionId === rawState.activeSessionId, |
There was a problem hiding this comment.
Clear cached predictions when switching sessions
When a Desktop/Web user switches away after a suggestion has been generated, this predicate only hides the controller state; nothing clears suggestion, active, or predictionTarget. Returning to the session therefore resurrects the old suggestion, despite the declared behavior that switching sessions clears it. Watch activeSessionId and clear the prediction state for the departing session.
AGENTS.md reference: AGENTS.md:L193-L193
Useful? React with 👍 / 👎.
|
|
||
| export const cancelPromptPredictionRequestSchema = z.object({ | ||
| prediction_id: z.string().min(1), | ||
| reason: z.enum([ |
There was a problem hiding this comment.
Reuse the canonical cancellation-reason list
This protocol schema duplicates every value from PROMPT_PREDICTION_CANCEL_REASONS in packages/agent-core-v2/src/features/promptPrediction/promptPrediction.ts; adding a reason to only one list will make the service and KAP validator disagree about valid requests. Since kap-server already depends on agent-core-v2, construct this enum from the exported canonical tuple instead of maintaining a parallel list.
AGENTS.md reference: AGENTS.md:L109-L109
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 192f204777
ℹ️ 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".
| handlePreInput(data: string): boolean { | ||
| if (matchesKey(data, Key.escape)) { | ||
| const hadPrediction = this.active !== undefined || this.suggestion !== undefined; | ||
| const autocomplete = this.host.state.editor.hasAutocompleteActivity(); | ||
| this.dismiss('escape'); | ||
| return hadPrediction && !autocomplete; | ||
| } | ||
| if ( | ||
| (matchesKey(data, Key.tab) || matchesKey(data, Key.right)) && | ||
| this.suggestion?.accepted === false && | ||
| this.host.state.editor.inputMode === 'prompt' && | ||
| !this.host.state.editor.hasAutocompleteActivity() | ||
| ) { | ||
| return this.accept(matchesKey(data, Key.right) ? 'right' : 'tab'); | ||
| if (matchesKey(data, Key.tab) || matchesKey(data, Key.right)) { |
There was a problem hiding this comment.
Restore Escape dismissal for TUI predictions
When an experimental TUI user has a displayed or in-flight prediction and presses Esc, this handler now ignores the key, so a visible suggestion remains cached and a late response can still appear afterward. Fresh evidence in this revision is the TUI-specific removal of the previous Key.escape branch even though the behavior table says Escape remains an invalidation path; restore the clear/cancel behavior for Escape.
AGENTS.md reference: AGENTS.md:L191-L193
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5e384e868
ℹ️ 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".
|
|
||
| private startPrediction(): boolean { | ||
| const target = this.latestTurn; | ||
| if (target === undefined || this.host.session !== target.session || !this.canUsePrediction()) return false; |
There was a problem hiding this comment.
Preserve retries after transient TUI blockers
When a turn completes while a transient blocker such as the session picker, tasks browser, or external editor is active, this one automatic call returns false because canUsePrediction() is false. The same revision removes the later Tab → startPrediction() path, and no eligibility-change callback retries the stored latestTurn; after closing the blocker, the experimental TUI user therefore cannot obtain a prediction for that completed turn. Retain a retry trigger or refresh when prediction becomes eligible again.
AGENTS.md reference: AGENTS.md:L191-L193
Useful? React with 👍 / 👎.
| "kimi-code-app": patch | ||
| --- | ||
|
|
||
| Improve prompt prediction interactions. |
There was a problem hiding this comment.
Name the Desktop behavior in the changeset
This generic sentence does not tell Desktop users what changed, even though the patch visibly changes prediction placeholders, hides progress and failure states, and keeps suggestions cached while users type. Because this entry feeds the Desktop release notes, replace it with a concrete user-facing description of the changed interaction rather than the word “Improve.”
AGENTS.md reference: AGENTS.md:L169-L170
Useful? React with 👍 / 👎.
| suggestion.value = { ...current, text: prediction, accepted: false, acceptedRevision: 0, parked: current.parked || !host.hasEmptyInput(current.sessionId) }; | ||
| track('prediction_shown', { |
There was a problem hiding this comment.
Record shown telemetry only after the suggestion is visible
When the user types while generation is in flight, this caches the response as parked: true but immediately emits prediction_shown; Composer.vue hides the ghost text while the editor is nonempty, so the experiment records an impression the user never saw, and clearing the draft later shows it without recording the real first impression or timing. The TUI has the same unconditional event after caching a parked result, so emit this event once when the suggestion first becomes renderable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
kimi-code/apps/kimi-code/src/tui/controllers/prompt-prediction.ts
Lines 199 to 203 in 2749d7d
When an experimental TUI user already has a generated suggestion and then enables Plan mode, queues a message, or opens an editor-replacing dialog, these eligibility checks merely hide it. This patch also removes the handlePlanModeChanged, handleQueueChange, and notifyDisplaced calls, so closing the blocker makes the stale pre-transition suggestion visible and acceptable again even though these transitions are declared to remain invalidation paths; clear the cached and active prediction on those transitions rather than only gating placeholder().
AGENTS.md reference: AGENTS.md:L191-L193
ℹ️ 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".
2749d7d to
d7d5a40
Compare
6e112ec to
c1fab65
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1fab65a40
ℹ️ 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".
| async function setPromptPredictionEnabled(on: boolean): Promise<boolean> { | ||
| const saved = await updateConfig({ experimental: { prompt_prediction: on } }); | ||
| if (saved) { | ||
| experimentalFlags.value = { ...experimentalFlags.value, prompt_prediction: on }; |
There was a problem hiding this comment.
Preserve environment overrides in the Lab switch
When the daemon starts with KIMI_CODE_EXPERIMENTAL_PROMPT_PREDICTION=0, enabling this switch writes the config but cannot override the environment-controlled server flag; nevertheless, this assignment marks the effective client flag as true. The UI then shows the switch as enabled and sends prediction requests that the server silently answers with no prediction until metadata is refreshed or the app restarts. Re-read the effective flag after saving, or prevent the switch from contradicting an environment override.
AGENTS.md reference: AGENTS.md:L121-L124
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| function handleInput(): void { | ||
| clearPending(); |
There was a problem hiding this comment.
Retain pending prediction after clearing a draft
When a Desktop/Web user has already started typing the next prompt before the current turn finishes, refresh() leaves the completed turn in pending because the composer is nonempty. Clearing that draft then invokes handleInput(), and this unconditional call deletes the pending target without retrying it, so the generic placeholder returns instead of the prediction automatically appearing as promised in docs/en/guides/interaction.md:15. Keep the pending turn while input is nonempty and refresh it once the composer becomes empty, or generate it immediately in the parked state.
Useful? React with 👍 / 👎.
| latestTurn.value = undefined; | ||
| clearForSession(sessionId); |
There was a problem hiding this comment.
Coalesce completed turns before starting prediction
When Desktop/Web reconnects after multiple turns completed, onMainPage() reports each fresh completed turn synchronously, so every call here discards the preceding local request and immediately starts another one. In the normal request order the session service accepts the first request and returns null for the second while the first response is ignored because it no longer matches active; the latest turn therefore receives no suggestion and is already marked attempted locally. Coalesce the page to its latest completed turn, or defer the latest target until the active request settles.
Useful? React with 👍 / 👎.
c1fab65 to
990e812
Compare
- move predictions into input placeholders with manual and repeated recall - preserve in-flight requests and TUI cursor rendering - hide hints before the first turn and after empty predictions
- use structured yes/no responses for next-prompt prediction - keep cached suggestions visible after clearing input - simplify the default placeholder and deduplicate session prediction lookup
990e812 to
7862b84
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7862b84f06
ℹ️ 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".
| setText(text: string, opts?: { entries?: AttachmentEntry[] }): void; | ||
| setWorkMode(spec: WorkModePillSpec | null): void; | ||
| setPlaceholder(text: string): void; | ||
| setPlaceholder(text: string, opts?: { allowWhitespace?: boolean }): void; |
There was a problem hiding this comment.
Add changesets for the modified UI libraries
This commit changes source behavior in both @moonshot-ai/app-composer (including this public editor contract) and @moonshot-ai/app-components, but the three added changesets only name the CLI and Desktop products. Neither library is ignored by .changeset/config.json, so their own versions and technical changelogs will omit these changes; add patch entries for both packages.
AGENTS.md reference: AGENTS.md:L170-L171
Useful? React with 👍 / 👎.
Port upstream 6536e55 (MoonshotAI#5180). Predictions move into the composer placeholder: a finished turn starts one, typing parks it, clearing the input shows it again, and Tab/Right Arrow recalls it (also while the request is still in flight). The engine now asks for a strict yes/no JSON answer instead of plain text, and the desktop stack gains the prediction API, Composer integration, telemetry and a Settings > Lab switch. Fork adaptations: - pi-tui here has no FAKE_CURSOR_START/END, so custom-editor keeps its multi-line ghost renderer and now drives it from a placeholder provider. Its truncation and continuation padding became column-aware (truncateToWidth/visibleWidth); CJK predictions no longer overflow the box and a two-line prediction stays inside the width budget. - The fork had never wired PromptPredictionController: kimi-tui now constructs/disposes/resets it and exposes the turn-ended hook, the editor keyboard calls submit/pre-input/change, and the prediction starts on the fork's real idle transitions (after finalizeTurn and after finishCompaction settles) because this branch carries neither loopLifecycleEvents nor streamingUI.finalizeLoopEnd. Upstream's removed handlePlanModeChanged/notifyDisplaced/handleQueueChange call sites never existed here; plan mode is blocked inside canUsePrediction instead. - kap-server cancels a predict-prompt request on disconnect through reply.raw close plus writableFinished, the fork's existing wait-handler idiom, since SessionActionExtra.req carries no raw request object. - Upstream's new e2e case is dropped: this fork replaced the FakeModel/ testWithProvider e2e fixtures with its own model stubs, and restoring that harness is out of scope for the port. - Tests use the fork's waitForAssertion/mock helpers instead of vi.waitFor, and the sessions test drops upstream's ":abort is unsupported" assertion because the fork still routes abort. Verified: - bun run typecheck: agent-core-v2, kap-server, apps/kimi-code clean; apps/desktop clean except the pre-existing tests/main/browser/ browser-aot.test.ts TsdownHandle error (file untouched). - apps/kimi-code: 103 pass / 0 fail (prompt-prediction + custom-editor). - agent-core-v2 promptPrediction: 1 pass, 52 assertions. - kap-server sessions: 128 pass / 0 fail; the prediction case passes alone (12 assertions). - app-client workspace-state: 212 pass / 13 fail, the 13 identical to HEAD (210 pass / 13 fail); the new setPromptPredictionEnabled cases pass. - app-core daemon-client 89 pass, app-composer placeholder 10 pass, desktop perfTelemetry 5 pass, app-components composerUndoDraft 5 pass. - check:no-comments OK (2415 files); locale key and placeholder checks OK. - app-client conversation-events and two app-components composer suites fail only because this Bun build lacks vi.resetModules; their HEAD versions fail identically, so the committed client-level prediction test could not run here. A throwaway probe exercised createPromptPrediction through 28 assertions (parking, in-flight recall, revisions, submit, failed turns, session isolation) and passed before deletion. - Cross-package typechecking resolves workspace packages through the node_modules junction into the main checkout, so app-components/app-client edits were checked by their tests rather than by tsc.
The last reported source gap for MoonshotAI#5180 was apps/desktop/e2e/composer-writing.spec.ts, an e2e spec. Treat **/e2e/**, **/tests/**, **/*.spec.ts and **/*.spec.tsx as test, then regenerate the baseline. The baseline now reports source-missing 0, source-partial 11, source-adapted 138. MoonshotAI#5180 is already ported as d4f7ca0; its client hook exists and is imported by useKimiWebClient, so the difference is structural, not missing behavior. Verified: scripts suite 276 pass; check:no-comments clean.
Screenshots / Recordings
预测状态机全链路实拍(脚本化 stub 模型):空输入 placeholder → 预测出现 → 输入隐藏 → 清空召回 → Tab / 右方向键采纳 →
show=no回退默认。Desktop 为真实 Electron e2e 截屏,TUI 为真实终端运行。Desktop(Electron e2e)
show=no:回到默认 placeholderTUI(真实终端运行)
show=no:编辑器回到空态Requirement or Bug
实验性提示词预测需要统一的结构化输出和连续可用的输入体验。这个 PR 让 Desktop、Web 和 TUI 使用明确的
yes/no + message预测协议,并在空输入时持续展示已生成的预测,同时去掉预测中、失败和无效默认提示。Bug Reproduction Steps
N/A(交互能力改进,不是单一缺陷修复)。
Root Cause
N/A。
Code Changes
核心结构:
show: "yes" | "no"和message: string,两字段必填且不允许额外字段。无效 JSON、无效字段、空 message 和控制字符不展示;no返回空结果,yes返回校验后的 message。data.prediction: string | null,不改变外部契约。共用 session/service 解析,避免新增重复代码;后台 session 不覆盖当前预测目标。Tab to predict,不显示预测中或失败状态;已有预测在空输入时始终展示。placeholder 保留硬件光标和 fake cursor。Behavior Changes and Affected Users
json_schema的show + message;no和无效响应不展示show=no,其余按 schema 返回 JSONVerification
next-prompt placeholder recall:1/1,覆盖结构化yes/no、默认 placeholder、在途 Tab、重复采纳和右方向键。check:duplication:通过,无新增重复片段。ui-ready。Checklist
gen-changesetsskill(CLI minor / Desktop patch,采用精简文案).gen-docsskill, or this PR needs no doc update(实验性交互无需额外用户文档).