Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-web-code-block-copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

web: Fix code block copy buttons when the web UI is served over plain HTTP.
10 changes: 10 additions & 0 deletions apps/kimi-web/src/components/chat/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ const codeBlockProps = {
loading: false,
};

function copyCodeBlockFallback(code: string): void {
// markstream emits `copy` even when it skipped the write because the
// Clipboard API is unavailable. Reuse our plain-HTTP fallback in that case,
// while avoiding a duplicate write after markstream succeeds on HTTPS.
const clipboard = typeof navigator !== 'undefined' ? navigator.clipboard : undefined;
if (clipboard && typeof clipboard.writeText === 'function') return;
void copyTextToClipboard(code);
}

// Root cause for the "large session turns into code skeletons" failure:
// markstream mounts every code block in the loaded transcript, then shiki has
// to tokenize all of them. `loading: false` removes the visible skeleton gate,
Expand Down Expand Up @@ -437,6 +446,7 @@ function copyDiff(code: string, idx: number) {
:smooth-streaming="streaming"
:batch-rendering="allowBatchRender"
:defer-nodes-until-visible="false"
@copy="copyCodeBlockFallback"
/>

<!-- ```diff fence → local renderer (preserves +/- markers + colours) -->
Expand Down
Loading