[Bug]: VS Code session export corrupts emoji at the topic truncation boundary
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 90/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript, vscode
- Domain
- desktop
Research direction
Start in apps/vscode/src/utils/session-context.ts, especially the topic-shortening helper around lines 216–218 and its use in buildExportMarkdown. Add the focused regression test at apps/vscode/test/session-context.test.ts, then run the provided Vitest command. Done means the test passes and truncation preserves the complete 😀 code point without producing �.
Written by the indexing model from the issue text.
Description
What version of Kimi Code is running?
VS Code extension 0.7.5, main@55685c58b5dbff692e16c66efa65fa6d32222f61
Which open platform/subscription were you using?
Not applicable. This reproduces in the deterministic local session export formatter without a model or API request.
Which model were you using?
Not applicable.
What platform is your computer?
Darwin 25.5.0 arm64 arm
What issue are you seeing?
The VS Code session Markdown exporter can split an emoji's UTF-16 surrogate pair when shortening the overview topic.
If an emoji crosses the 80-character truncation boundary, the exported topic ends with a replacement character:
- **Topic**: aaa�…
instead of preserving the emoji:
- **Topic**: aaa😀…
The full user message remains correct. Only the shortened overview topic is corrupted.
What steps can reproduce the bug?
-
Check out
mainat55685c58b5dbff692e16c66efa65fa6d32222f61. -
Add this focused test as
apps/vscode/test/session-context.test.ts:
import type { ContextMessage } from "@moonshot-ai/kimi-code-sdk";
import { describe, expect, it } from "vitest";
import { buildExportMarkdown } from "../src/utils/session-context";
describe("buildExportMarkdown", () => {
it("keeps surrogate pairs intact when shortening the topic", () => {
const prefix = "a".repeat(79);
const history = [
{
role: "user",
content: [{ type: "text", text: `${prefix}😀 continues` }],
toolCalls: [],
} satisfies ContextMessage,
];
const markdown = buildExportMarkdown({
sessionId: "session-test",
workDir: "/workspace",
history,
tokenCount: 0,
now: new Date("2026-09-07T00:00:00.000Z"),
});
expect(markdown).toContain(`- **Topic**: ${prefix}😀…`);
});
});
- Run:
pnpm --filter kimi-code exec vitest run \
--config vitest.config.ts \
test/session-context.test.ts
- The test fails because the topic contains
�…instead of😀….
What is the expected behavior?
Topic truncation should preserve complete Unicode code points. It should never produce an unpaired surrogate or a replacement character.
For this reproduction, the shortened topic should end with 😀….
Additional information
buildExportMarkdown shortens the first user message to 80 characters:
The helper uses JavaScript string length and slice(), which operate on UTF-16 code units:
The duplicate search covered buildExportMarkdown, session export emoji, surrogate pair, and unpaired surrogate. No matching issue or active pull request was found.
Contribution
- I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 41m
- Merged PRs (30d)
- 345
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MoonshotAI/kimi-code
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
MoonshotAI/kimi-code#3947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3836 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MoonshotAI/kimi-code#3790 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3755 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MoonshotAI/kimi-code#3627 ·
All issues in MoonshotAI/kimi-code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·