diff --git a/.changeset/fix-web-fallback-line-numbers.md b/.changeset/fix-web-fallback-line-numbers.md new file mode 100644 index 0000000000..0acd3293b3 --- /dev/null +++ b/.changeset/fix-web-fallback-line-numbers.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +web: Fix line numbers overlapping or drifting out of alignment in fallback-rendered code blocks. diff --git a/apps/kimi-web/src/components/chat/Markdown.vue b/apps/kimi-web/src/components/chat/Markdown.vue index 42535be66b..9249a0eca2 100644 --- a/apps/kimi-web/src/components/chat/Markdown.vue +++ b/apps/kimi-web/src/components/chat/Markdown.vue @@ -672,6 +672,39 @@ function copyDiff(code: string, idx: number) { .md :deep(.code-block-content pre:not(.shiki) code) { color: var(--color-text); } +/* markstream-vue 1.0.7 renders its standalone fallback as the component root, + but scopes the corresponding styles as though the
 were a descendant.
+   Restore that fallback layout here; loading fallbacks already receive the
+   equivalent global markstream rule. */
+.md :deep(pre.code-pre-fallback:not(.markstream-pre--diff-preview):not([data-markstream-code-loading='1'])) {
+  box-sizing: border-box;
+  width: 100%;
+  margin: 0.6em 0;
+  padding: var(--markstream-code-padding-y, 8px) var(--markstream-code-padding-x, 12px);
+  padding-left: var(--markstream-code-padding-left, 52px);
+  overflow: auto;
+  border: 1px solid var(--color-line);
+  border-radius: var(--radius-md);
+  background: var(--color-surface-sunken);
+  box-shadow: var(--shadow-xs);
+  color: var(--color-text);
+  font-family: var(--markstream-code-font-family, var(--font-mono));
+  font-size: var(--vscode-editor-font-size, var(--text-sm));
+  font-weight: var(--weight-regular);
+  line-height: var(--vscode-editor-line-height, calc(var(--text-sm) * 1.65));
+}
+.md :deep(pre.code-pre-fallback.is-wrap:not(.markstream-pre--diff-preview)) {
+  white-space: pre-wrap;
+  overflow-wrap: anywhere;
+}
+.md :deep(pre.code-pre-fallback:not(.markstream-pre--diff-preview) > .markstream-pre__code) {
+  min-width: 100%;
+  padding: 0;
+  border: 0;
+  background: none;
+  color: inherit;
+  font: inherit;
+}
 
 /* Links — open in a new tab (markstream handles target/rel) */
 .md :deep(a) {