You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(kimi): open a Kimi terminal session in the chat from /resume and Session History - #50245
Typing /resume in a Kimi chat and clicking a Kimi session you started in a terminal only expanded the row. Now it opens that session in the chat, with its history, and Kimi carries on from it.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$231
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$231
Prod
11
$\color{#1a7f37}{\Huge{\mathbf{+}}}$308
$\color{#cf222e}{\Huge{\mathbf{−}}}$4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$304
What Changed
Before: in a Kimi chat, /resume opened Agent Session History as a picker, but clicking a Kimi terminal session (or pressing Enter on it) just expanded the row's details. Session History also offered no Resume in New Chat for Kimi rows, and a Kimi terminal had no Continue in Chat UI.
After: the click replaces the chat with the picked session, the same way it works for Claude and Codex. The session's earlier messages show in the chat, and the next prompt goes to the same Kimi session. Resume in New Chat and Continue in Chat UI work for Kimi too.
How: Kimi becomes a chat agent that can take over a terminal session, like Antigravity, Hermes and Droid:
KIMI_TRANSCRIPT_IMPORT finds a session's transcript at sessions/<workspace folder>/<session id>/agents/<primary agent>/wire.jsonl. It reads the session's work directory from Kimi's session_index.jsonl, through the cached reader Session History already uses, and goes straight to that folder by Kimi's own naming (wd_<slug>_<sha256[:12]>, the same in Kimi 2.5.0 and 2.7.2). It never lists or scans folders.
A wire decoder turns the person's messages (keyed by Kimi's msg_… ids) and each text block of a reply (keyed by its block uuid) into chat history. A pasted image shows as [image], as in Hermes imports. Injected reminders, thinking and tool runs stay in Kimi's own session, which the chat resumes.
Turns undone with Kimi's /undo stay out of the history. Kimi records an undo as an agent.switched record that starts a new branch, and the undone records stay in the file. A first pass over the file reads only those records and works out the conversation's branch the way Kimi does. The bounded import then takes only that branch's records. It goes through the shared prepareRecordIdTranscriptImport from feat(droid): open Droid sessions from Session History in a chat #50162.
The adoption folder check reads the session's folder from Kimi's session_index.jsonl, through the same reader Session History uses for the row. So a session from a sub-folder resumes in that folder, and a session from another folder is refused before anything closes.
kimi is added to CLI_CONVERSATION_ADOPTING_AGENTS and to the agents whose session must resume in its own folder.
Why
Root cause: Kimi's chat launch spec had transcriptImport: null and no adoption-map entry. So resumeAiVaultSessionHere refused every Kimi terminal row, and the list fell back to expanding the row. Chats of the same agent already open fine, which is why only terminal sessions were affected.
Kimi chat shipped in #41661 without adoption, as Antigravity and Droid did before their importers.
Checked against Kimi Code 2.7.2:
kimi acp advertises loadSession, lists terminal sessions, and keeps their context on session/load.
kimi -S refuses a session made in another folder, but kimi acp silently loads it there. That's why the folder check is needed.
/compact appends a context.apply_compaction record and never rewrites earlier records, so the record ids stay stable.
Alternative considered: let any ACP agent that can load a session take over terminal sessions from its replay, with no importer. That was ruled out for this fix. The replay only arrives after the agent starts, so the pre-start refusals (wrong folder, deleted chat, unsaved session) would turn into blank or wrong chats. Replay catch-up is also capped and needs stable message ids, which most agents don't send.
Hidden dev build with Kimi Code 2.7.2 and a local fake model server. Same chat, /resume, then a click on a Kimi terminal session.
Before (shipped behaviour): the click only expands the row; the chat is unchanged.
After: the click replaces the chat with the terminal session; a follow-up prompt continues it.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Live run (macOS, folder workspace, dev build):
Before: with the map entry removed, the click expanded the row and left the chat as it was, which is the reported symptom.
After: the click replaced the chat with the terminal session's history. A follow-up prompt reached the model with the terminal turns in context, and Kimi appended it to the same session's wire.jsonl.
Also checked: the transcript lookup returns the wire file for real sessions, and returns null for a missing id or a traversal-shaped id.
Automated:
transcript-line-decoders-kimi.test.ts runs the decoder on records Kimi 2.7.2 actually wrote: a user message, an injected reminder, a thinking block, a reply text block and an image-only prompt.
journal-kimi-import.test.ts imports a wire with two nested /undos, one where every turn was undone, and one where undone turns alone would fill the history budget. It fails if the branch filter is removed.
kimi-transcript-import.test.ts checks the lookup against folder names Kimi 2.7.2 actually created, including a non-Latin folder name. It fails when the folder-name rule is broken.
pnpm check:changed (against the Droid base) passes. The tests that load the changed modules pass, and tc:node and tc:web are clean.
Not run: Windows, Linux and SSH hosts. Transcript admission already refuses WSL/UNC and SSH paths for every importer, and the path handling is node:path only.
Performance
The new work runs only when someone takes over a Kimi session: the /resume click, Resume in New Chat, Continue in Chat UI, or the pre-close folder check. Each takeover costs:
one session-index lookup, through Session History's cached reader (it re-parses only when the index changes);
two stats and one state.json read in the session's own folder, with no directory listing;
two reads of the session's wire.jsonl, through the same import reader Antigravity and Droid use. The first only numbers lines and parses agent.switched records. The second decodes only the conversation's own records, so a session without undos parses the same number of records as before.
Nothing is polled or subscribed to. Kimi terminal panes and chats now also run the same takeover offer gate and writer-admission check that Claude, Codex and Droid already do, which is a few in-memory lookups. A perf pass graded this at fleet scale. Every finding it accepted was the lookup scanning Kimi's workspace folders. The index lookup above fixes it by removing the scan entirely.
Risk
Level: Low
The change only adds Kimi to an existing takeover path. Other agents are unaffected, and Orca only reads Kimi's files.
The riskiest part is a newer desktop paired to an older remote Orca server. Continue in Chat UI could close a Kimi terminal, and then the old server would refuse the chat. The session stays on disk and can be resumed in a terminal. Droid has the same gap. A per-agent host capability would close it for both, so it's left as a follow-up.
Back out with a plain revert.
AI Disclosure
Review
Six rounds of Codex and Claude review against the release-readiness checklist, plus a fleet-scale perf pass each time the code changed. The last round returned no findings from any of the three, after the branch walk was fuzzed against Kimi's own code. against the release-readiness checklist No P0 or P1 is open.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Security: session ids are validated, and transcript paths are admitted inside the selected Kimi home's sessions folder.
Mobile: no mobile surface reads the adoption map.
Follow-ups: Cline, CodeBuddy, Copilot, Cursor, Devin and Kiro have the same picker fallback for their terminal sessions, because none has a transcript importer yet.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Kimi now has transcript discovery and decoding for journal import. Journal imports validate session identity and include only lines on the reconstructed active branch. The changes also register Kimi transcript import in its launch specification and add Kimi to conversation adoption and workspace checks.
Severity of issue fixed: Medium
Merge Risk: Low · up to 32458
Kimi takeover can adopt a session from another folder when the session index is unavailable, and imported history can be stale if the terminal is still writing. Both are narrow edge cases, so the change is mergeable with owner awareness.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(kimi): open a Kimi terminal session in the chat from /resume and Session History" matches the main change. The PR adds a Kimi transcript importer and registers Kimi as a chat agent that…
Linked Issues check
Issue #47535 requires that selecting or pressing Enter on a Kimi terminal session in /resume resumes it in the current Kimi chat, as Claude and Codex do. The reviewed head implements this path: - `k…
Out of Scope Changes check
The whole-PR diff from merge base 20f3a16 includes the stacked base work below this PR's own commits, including the Droid transcript importer and its adoption-map entries. The PR description scopes r…
Description check
The description follows the repository template closely. It has an ELI5, a detailed What Changed section with before and after behavior, a Why section with root cause and alternatives considered, a li…
Full details: Title check
Explanation
The title "fix(kimi): open a Kimi terminal session in the chat from /resume and Session History" matches the main change. The PR adds a Kimi transcript importer and registers Kimi as a chat agent that can take over terminal sessions from /resume, Resume in New Chat, and Continue in Chat UI. The title is specific, uses a conventional prefix, and names the primary behavior. Its length (84 characters) is at the upper end of concise, but it remains a single clear sentence.
Full details: Linked Issues check
Explanation
Issue #47535 requires that selecting or pressing Enter on a Kimi terminal session in /resume resumes it in the current Kimi chat, as Claude and Codex do. The reviewed head implements this path:
kimi is added to CLI_CONVERSATION_ADOPTING_AGENTS (structured-agent-cli-conversation-adoption.ts). This removes the adoptsCliConversations refusal that caused the row fallback.
KIMI_LAUNCH_SPEC uses KIMI_TRANSCRIPT_IMPORT in place of transcriptImport: null.
KIMI_TRANSCRIPT_IMPORT (kimi-transcript-import.ts) locates wire.jsonl from the session index work directory and the wd_<slug>_<sha256[:12]> folder name. It validates session IDs and does not scan folders.
decodeKimiWireLine (transcript-line-decoders-kimi.ts) and prepareKimiImport (journal-kimi-import.ts) import user, reply text, and image-only history. Undone /undo turns are excluded by the active-branch logic in kimi-wire-active-branch.ts.
The adopted-source folder check (adopted-transcript-source.ts) reads the work directory through readKimiWireSessionWorkDir, so a session from another folder is refused before the chat closes.
Tests cover the decoder, the lookup including a non-Latin folder name, and the /undo branch filter.
The author reports a manual macOS run in which the click replaced the chat and a follow-up prompt continued the Kimi session. Source summaries support the implementation. I did not run the tests.
Secondary expectation: the issue asks that a row which cannot be taken over explain why (disabled state or tooltip). The diff adds no picker-level reason display. This affects only refusal cases, and the primary reported behavior is fixed. The change since the previous review (active-branch handling and its tests) supports the /undo part of the import objective and does not alter this conclusion.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff from merge base 20f3a16 includes the stacked base work below this PR's own commits, including the Droid transcript importer and its adoption-map entries. The PR description scopes review to commits after aac82ec. These Droid changes are stacked base work and are not classified as out of scope for this PR.
The Kimi-specific changes map to the linked objective:
Importer, lookup, decoder, and adoption-map entry for kimi: implement takeover.
readKimiWireSessionWorkDir and the Kimi folder check in adopted-transcript-source.ts: implement the issue's folder/worktree scenario and the refusal of cross-folder sessions.
aiVaultSessionResumeInChatWorkspaceMatters treating Kimi as workspace-sensitive: supports the same takeover path.
createKimiActiveBranch and its tests: implement exclusion of /undo turns from imported history, which the PR describes as part of the takeover.
The shared prepareRecordIdTranscriptImport change to accept kimi, and the prepareLegacyTranscriptImport dispatch: connect the Kimi importer to existing import infrastructure.
Test files: support the Kimi changes.
No change was found that lacks a connection to takeover of Kimi terminal sessions. I did not inspect the diff hunks directly, so this result relies on the change summaries.
Full details: Description check
Explanation
The description follows the repository template closely. It has an ELI5, a detailed What Changed section with before and after behavior, a Why section with root cause and alternatives considered, a linked issue (Fixes #47535), before and after visual proof, Testing with checkboxes and automated test details, a Performance section with a completed line, a Risk section with level Low and a back-out plan, and a Notes and Checklist section. The AI Disclosure section is empty, but the template marks it as applicable only to non-StablyAI contributors, so the gap is not critical. The Review section contains an unclear sentence that repeats the phrase 'against the release-readiness checklist'. The Testing section lists Windows, Linux, and SSH as not run, which is disclosed.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Keep the raw indexed workDir for Kimi folder lookup.
extractString trims the workDir value that parseKimiSessionIndex stores. kimiWorkspaceFolder then hashes the trimmed value, and findTranscript uses that hash to locate the Kimi session folder. The repository comment says Kimi maps the index's work directory to its folder the same way. If Kimi hashes the untrimmed value, a workDir with leading or trailing whitespace yields a different folder name. The lookup then returns null and the session is not imported. The trimmed value also reaches the folder check in resolveAdoptedTranscriptFolder through readKimiWireSessionWorkDir.
The fix should keep the raw indexed value for filesystem lookup and folder validation. Reject an empty value after trimming, but do not trim the path itself. Check the display consumers of readKimiWorkDirBySessionId before changing the shared parse, so the display value and the lookup value are chosen deliberately.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 9b52a10a-2051-4eb9-97cb-300121521ec2
Commits
Reviewing files that changed from the base of the PR and between 4b7c4d4 and 3f78115.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Require the Kimi import to read one consistent version of the wire file.
prepareKimiImport reads the transcript twice. The first pass numbers the records and builds the switch chain. The second pass decodes the lines that the chain keeps. The chain predicate is fixed after the first pass and is not updated by later records. If a Kimi writer appends a /undo switch between the passes, the second pass can keep turns that the switch undoes. The chat history then contains turns that the resumed Kimi session no longer has. Records numbered after the first pass are always accepted, so they are not checked against the switch either.
This can happen while a Kimi terminal remains live during adoption. The import does not prevent or detect that append.
Make the imported chain match the bytes that the import reads. If the wire file changes between the passes, the adoption must fail or re-read the file until both passes see the same content. The caller must receive that failure and must not import a partial or mismatched chain.
A Kimi chat's /resume picker, Resume in New Chat and Continue in Chat UI now take over
a Kimi terminal session: Kimi gets a transcript importer for its wire.jsonl (user
messages and reply text under Kimi's own ids), a folder check from Kimi's session
index, and an entry in the adopting-agents map.
Fixes#47535
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Refuse Kimi takeover when the session index cannot confirm the session's folder.
For Kimi, the folder comes only from the session index. If the index cannot be read, a session is missing from it, or a line is malformed, readKimiWireSessionWorkDir returns null. resolveAdoptedTranscriptFolder then returns source.workspaceCwd, and assertStructuredAdoptionFolder raises no error. A session saved in another folder can therefore pass this check and be adopted into the current workspace.
The existing other-folder refusal runs only when the cwd is known and differs. Kimi needs a path that does not treat an unknown folder as the workspace folder. The check must refuse before the terminal closes. The fallback for other agents does not change.
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
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.
ELI5
Typing
/resumein a Kimi chat and clicking a Kimi session you started in a terminal only expanded the row. Now it opens that session in the chat, with its history, and Kimi carries on from it.What Changed
Before: in a Kimi chat,
/resumeopened Agent Session History as a picker, but clicking a Kimi terminal session (or pressing Enter on it) just expanded the row's details. Session History also offered no Resume in New Chat for Kimi rows, and a Kimi terminal had no Continue in Chat UI.After: the click replaces the chat with the picked session, the same way it works for Claude and Codex. The session's earlier messages show in the chat, and the next prompt goes to the same Kimi session. Resume in New Chat and Continue in Chat UI work for Kimi too.
How: Kimi becomes a chat agent that can take over a terminal session, like Antigravity, Hermes and Droid:
KIMI_TRANSCRIPT_IMPORTfinds a session's transcript atsessions/<workspace folder>/<session id>/agents/<primary agent>/wire.jsonl. It reads the session's work directory from Kimi'ssession_index.jsonl, through the cached reader Session History already uses, and goes straight to that folder by Kimi's own naming (wd_<slug>_<sha256[:12]>, the same in Kimi 2.5.0 and 2.7.2). It never lists or scans folders.msg_…ids) and each text block of a reply (keyed by its block uuid) into chat history. A pasted image shows as[image], as in Hermes imports. Injected reminders, thinking and tool runs stay in Kimi's own session, which the chat resumes./undostay out of the history. Kimi records an undo as anagent.switchedrecord that starts a new branch, and the undone records stay in the file. A first pass over the file reads only those records and works out the conversation's branch the way Kimi does. The bounded import then takes only that branch's records. It goes through the sharedprepareRecordIdTranscriptImportfrom feat(droid): open Droid sessions from Session History in a chat #50162.session_index.jsonl, through the same reader Session History uses for the row. So a session from a sub-folder resumes in that folder, and a session from another folder is refused before anything closes.kimiis added toCLI_CONVERSATION_ADOPTING_AGENTSand to the agents whose session must resume in its own folder.Why
Root cause: Kimi's chat launch spec had
transcriptImport: nulland no adoption-map entry. SoresumeAiVaultSessionHererefused every Kimi terminal row, and the list fell back to expanding the row. Chats of the same agent already open fine, which is why only terminal sessions were affected.Kimi chat shipped in #41661 without adoption, as Antigravity and Droid did before their importers.
Checked against Kimi Code 2.7.2:
kimi acpadvertisesloadSession, lists terminal sessions, and keeps their context onsession/load.kimi -Srefuses a session made in another folder, butkimi acpsilently loads it there. That's why the folder check is needed./compactappends acontext.apply_compactionrecord and never rewrites earlier records, so the record ids stay stable.Alternative considered: let any ACP agent that can load a session take over terminal sessions from its replay, with no importer. That was ruled out for this fix. The replay only arrives after the agent starts, so the pre-start refusals (wrong folder, deleted chat, unsaved session) would turn into blank or wrong chats. Replay catch-up is also capped and needs stable message ids, which most agents don't send.
Linked Issue
Fixes #47535
Linear: STA-17516
Visual Proof
Hidden dev build with Kimi Code 2.7.2 and a local fake model server. Same chat,
/resume, then a click on a Kimi terminal session.Before (shipped behaviour): the click only expands the row; the chat is unchanged.
After: the click replaces the chat with the terminal session; a follow-up prompt continues it.
Testing
Live run (macOS, folder workspace, dev build):
wire.jsonl.Automated:
transcript-line-decoders-kimi.test.tsruns the decoder on records Kimi 2.7.2 actually wrote: a user message, an injected reminder, a thinking block, a reply text block and an image-only prompt.journal-kimi-import.test.tsimports a wire with two nested/undos, one where every turn was undone, and one where undone turns alone would fill the history budget. It fails if the branch filter is removed.kimi-transcript-import.test.tschecks the lookup against folder names Kimi 2.7.2 actually created, including a non-Latin folder name. It fails when the folder-name rule is broken.pnpm check:changed(against the Droid base) passes. The tests that load the changed modules pass, andtc:nodeandtc:webare clean.Not run: Windows, Linux and SSH hosts. Transcript admission already refuses WSL/UNC and SSH paths for every importer, and the path handling is
node:pathonly.Performance
The new work runs only when someone takes over a Kimi session: the
/resumeclick, Resume in New Chat, Continue in Chat UI, or the pre-close folder check. Each takeover costs:state.jsonread in the session's own folder, with no directory listing;wire.jsonl, through the same import reader Antigravity and Droid use. The first only numbers lines and parsesagent.switchedrecords. The second decodes only the conversation's own records, so a session without undos parses the same number of records as before.Nothing is polled or subscribed to. Kimi terminal panes and chats now also run the same takeover offer gate and writer-admission check that Claude, Codex and Droid already do, which is a few in-memory lookups. A perf pass graded this at fleet scale. Every finding it accepted was the lookup scanning Kimi's workspace folders. The index lookup above fixes it by removing the scan entirely.
Risk
Level: Low
The change only adds Kimi to an existing takeover path. Other agents are unaffected, and Orca only reads Kimi's files.
The riskiest part is a newer desktop paired to an older remote Orca server. Continue in Chat UI could close a Kimi terminal, and then the old server would refuse the chat. The session stays on disk and can be resumed in a terminal. Droid has the same gap. A per-agent host capability would close it for both, so it's left as a follow-up.
Back out with a plain revert.
AI Disclosure
Review
Six rounds of Codex and Claude review against the release-readiness checklist, plus a fleet-scale perf pass each time the code changed. The last round returned no findings from any of the three, after the branch walk was fuzzed against Kimi's own code. against the release-readiness checklist No P0 or P1 is open.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
sessionsfolder.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)