diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d9a86d42..b690221f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,56 @@
# Changelog
+## [v1.0.15] - 2026-11-20
+
+同步上游 v0.7.28 之后到 v0.7.30 的功能提交(跳过上游 0.7.29 / 0.7.30 版本号 bump)。
+
+### 流式输出
+
+- perf(render): 流式文本按节奏揭示,并减轻 Markdown / 高亮渲染负担 (bef6dd6f)
+- feat(stream): 流式文本尾部淡入 (aa3effc3)
+- fix(stream): 块结束后立即补齐前面的流式文字 (cd202251)
+- feat(settings): 流式逐字节奏与尾部淡入可单独开关 (41d797f6)
+- feat(stream): 工具卡按流式节奏生长入场 (1182ec4c)
+- fix(stream): 工具卡入场只做淡入,不再插值高度 (af45e12a)
+- fix(chat): 流式期间每帧兜底贴底 (af5b1935)
+
+### Markdown 与高亮
+
+- fix(render): 补齐嵌套代码块样式,自定义动画遵从减少动效 (e892dfd9)
+- fix(markdown): 补齐标题层级、嵌套表格、HTML 注释与列表 / 链接样式 (8c5ee29c)
+- perf(markdown): 缓存非流式消息的分块结果 (a79bd18d)
+- perf(markdown): 合并稳定块组,超大 live 块限频完整解析 (14f317a4)
+- refactor(markdown): 抽出 Mermaid 渲染块 (aab42f47)
+- style(markdown): 去掉 Mermaid 块文件末尾多余空行 (ad1e9011)
+- perf(highlight): 流式高亮改为增量协议 (2f958c0b)
+- perf(markdown): 大块解析移到 Worker (806773d5)
+- feat(markdown): 行内前瞻与长代码块折叠 (fc5a26be)
+- perf(highlight): 语法失败按语言冷却 (2b4e25fc)
+- fix(markdown): 折叠改为限高可滚动,按钮并入操作区 (50c45413)
+- fix(markdown): 围栏语言没写完时不做增量追加 (3e9531e6)
+- feat(settings): 长代码块折叠可开关,默认开启 (4c63b193)
+- fix(markdown): 增量渲染按块边界判断,不再猜后缀 (e7894e9c)
+- perf(markdown): 尾部增量解析与诊断补强 (bd2cc1a8)
+- fix(markdown): 图区域不再吞掉触摸滚动 (b50e3407)
+
+### 长会话、虚拟列表与内存
+
+- perf(chat): 长会话下避免逐帧重算与无效重渲染 (cde5248a)
+- perf(cache): 消息渲染相关缓存加上体积上限 (ff495683)
+- perf(virtual): 会话恢复按 key 取高度,滚动时不再重建 observer (2b17bb58)
+- perf(virtual): 冷启动按消息内容估算行高 (5eaf2a94)
+- refactor(render): 统一有上限缓存,补开发期耗时打点 (078a7cd1)
+- refactor(chat): 抽出时间线高度估算与会话测量缓存 (35104fc1)
+- perf(render): 长消息块级窗口化与流式掉帧采样 (c7836eea)
+- refactor(message): 拆出工具摘要与内容分组 (3ab37925)
+- fix(chat): 翻页锚点让位于用户滚动,跳屏渲染延后到真实布局 (f35f8991)
+- feat(memory): 会话持有量统计、按体积分页与闲置回收 (94cb5d61)
+- perf(chat): 预渲染窗口改为按像素计算,高亮提前到可见之前 (664af913)
+
+### 输入
+
+- fix(input): 手持设备按触摸优先,不再被媒体查询判成桌面 (5dc51948)
+
## [v1.0.14] - 2026-11-18
- fix(chat): 压缩后的续写继续挂过程壳 (1ffc33ac)
diff --git a/package-lock.json b/package-lock.json
index ac4e9b7fa..3c87c61b1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "opencodeui",
- "version": "1.0.14",
+ "version": "1.0.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opencodeui",
- "version": "1.0.14",
+ "version": "1.0.15",
"hasInstallScript": true,
"license": "GPL-3.0-only",
"dependencies": {
diff --git a/package.json b/package.json
index d066b0376..fa9ac3b73 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "opencodeui",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "A third-party web frontend for OpenCode",
"license": "GPL-3.0-only",
"type": "module",
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 7a4982683..435cef517 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2725,7 +2725,7 @@ dependencies = [
[[package]]
name = "opencodeui"
-version = "1.0.14"
+version = "1.0.15"
dependencies = [
"futures-util",
"log",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 931673912..d3b0216a0 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "opencodeui"
-version = "1.0.14"
+version = "1.0.15"
description = "OpenCode UI - Tauri Mobile App"
authors = ["lehhair"]
license = "GPL-3.0-only"
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 32970c50e..78433ee1d 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "OpenCode",
- "version": "1.0.14",
+ "version": "1.0.15",
"identifier": "com.opencodeui.app",
"build": {
"frontendDist": "../dist",
diff --git a/src/App.tsx b/src/App.tsx
index 063756b40..382c6a02e 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -15,6 +15,7 @@ import { useSessionContext } from './contexts/useSessionContext'
import { useViewportHeight } from './hooks/useViewportHeight'
import { useCloseServiceDialog } from './hooks/useCloseServiceDialog'
import { useWakeLock } from './hooks/useWakeLock'
+import { useIdleSessionTrim } from './hooks/useIdleSessionTrim'
import type { KeybindingHandlers } from './hooks/useKeybindings'
import { keybindingStore } from './store/keybindingStore'
import {
@@ -125,6 +126,7 @@ function App() {
useViewportHeight()
useWakeLock(wakeLock)
+ useIdleSessionTrim()
const activeDirectories = useMemo(
() =>
diff --git a/src/components/CodeBlock.test.tsx b/src/components/CodeBlock.test.tsx
index 2d8cf8118..2db93dcc6 100644
--- a/src/components/CodeBlock.test.tsx
+++ b/src/components/CodeBlock.test.tsx
@@ -19,7 +19,7 @@ const useStreamingSyntaxHighlightMock = vi.fn(
output: null,
}),
)
-const useInViewMock = vi.fn(() => ({ ref: vi.fn(), inView: false }))
+const useNearViewportMock = vi.fn(() => ({ ref: vi.fn(), near: false }))
const themeSnapshot = { codeWordWrap: false }
vi.mock('../hooks/useInputCapabilities', () => ({
@@ -32,7 +32,7 @@ vi.mock('../hooks/useSyntaxHighlight', () => ({
}))
vi.mock('../hooks/useInView', () => ({
- useInView: () => useInViewMock(),
+ useNearViewport: () => useNearViewportMock(),
}))
vi.mock('../store/themeStore', () => ({
@@ -63,8 +63,8 @@ describe('CodeBlock', () => {
useSyntaxHighlightMock.mockReturnValue({ output: [[{ content: 'highlighted', color: '#fff' }]] })
useStreamingSyntaxHighlightMock.mockClear()
useStreamingSyntaxHighlightMock.mockReturnValue({ output: null })
- useInViewMock.mockReset()
- useInViewMock.mockReturnValue({ ref: vi.fn(), inView: false })
+ useNearViewportMock.mockReset()
+ useNearViewportMock.mockReturnValue({ ref: vi.fn(), near: false })
})
it('requires tap-to-reveal copy button for unlabeled touch-ui code blocks', () => {
@@ -125,7 +125,7 @@ describe('CodeBlock', () => {
})
it('renders highlighted tokens as selectable plain pre content', () => {
- useInViewMock.mockReturnValue({ ref: vi.fn(), inView: true })
+ useNearViewportMock.mockReturnValue({ ref: vi.fn(), near: true })
const { container } = render()
@@ -140,7 +140,7 @@ describe('CodeBlock', () => {
})
it('keeps highlighted prefix while streaming suffix waits for new tokens', () => {
- useInViewMock.mockReturnValue({ ref: vi.fn(), inView: true })
+ useNearViewportMock.mockReturnValue({ ref: vi.fn(), near: true })
useSyntaxHighlightMock.mockImplementation((highlightCode: string): HighlightMockOutput => {
if (highlightCode === 'const') return { output: [[{ content: 'const', color: '#fff' }]] }
return { output: null }
@@ -156,7 +156,7 @@ describe('CodeBlock', () => {
})
it('enables highlighting when visible', () => {
- useInViewMock.mockReturnValue({ ref: vi.fn(), inView: true })
+ useNearViewportMock.mockReturnValue({ ref: vi.fn(), near: true })
render()
diff --git a/src/components/CodeBlock.tsx b/src/components/CodeBlock.tsx
index 5a46bb8e0..36057bbe1 100644
--- a/src/components/CodeBlock.tsx
+++ b/src/components/CodeBlock.tsx
@@ -3,7 +3,8 @@ import { useInputCapabilities } from '../hooks/useInputCapabilities'
import { useSyntaxHighlight, useStreamingSyntaxHighlight, type HighlightTokens } from '../hooks/useSyntaxHighlight'
import { themeStore } from '../store/themeStore'
import { CopyButton } from './ui'
-import { useInView } from '../hooks/useInView'
+import { ChevronDownIcon, ChevronUpIcon } from './Icons'
+import { useNearViewport } from '../hooks/useInView'
/** Languages that carry no useful information — hide the label */
const HIDDEN_LANGS = new Set(['text', 'plain', 'txt', 'plaintext'])
@@ -46,12 +47,16 @@ function renderIncrementalTokens(tokens: HighlightTokens, suffix: string) {
type FlatHighlightToken = { content: string; color?: string }
+/** 共享换行节点,避免每次重排都给换行新造一个对象 */
+const NEWLINE_TOKEN: FlatHighlightToken = { content: '\n' }
+
function flattenTokens(tokens: HighlightTokens, suffix: string): FlatHighlightToken[] {
const result: FlatHighlightToken[] = []
- tokens.forEach((line, lineIndex) => {
- line.forEach(token => result.push({ content: token.content, color: token.color }))
- if (lineIndex < tokens.length - 1) result.push({ content: '\n' })
- })
+ for (let lineIndex = 0; lineIndex < tokens.length; lineIndex += 1) {
+ const line = tokens[lineIndex]
+ for (let tokenIndex = 0; tokenIndex < line.length; tokenIndex += 1) result.push(line[tokenIndex])
+ if (lineIndex < tokens.length - 1) result.push(NEWLINE_TOKEN)
+ }
if (suffix) result.push({ content: suffix })
return result
}
@@ -107,6 +112,11 @@ interface CodeBlockProps {
streamingHighlight?: boolean
/** Persistent controls rendered beside the copy action. */
headerActions?: ReactNode
+ /** 折叠态:配合 maxHeight 裁剪而不是滚动,用于长代码块 */
+ folded?: boolean
+ /** 展开/收起回调;提供时在 header 或悬浮操作区显示对应按钮 */
+ onToggleFold?: () => void
+ foldLabel?: { expand: string; collapse: string }
}
export const CodeBlock = memo(function CodeBlock({
@@ -121,6 +131,9 @@ export const CodeBlock = memo(function CodeBlock({
forceHighlight = false,
streamingHighlight = false,
headerActions,
+ folded = false,
+ onToggleFold,
+ foldLabel,
}: CodeBlockProps) {
const { codeWordWrap } = useSyncExternalStore(themeStore.subscribe, themeStore.getSnapshot)
const { preferTouchUi } = useInputCapabilities()
@@ -129,7 +142,10 @@ export const CodeBlock = memo(function CodeBlock({
const highlightCode = code
// Lazy load highlighting when close to viewport
- const { ref, inView } = useInView({ triggerOnce: true, rootMargin: '200px' })
+ // 高亮要赶在可见之前做完:2 屏的提前量,和虚拟列表的预渲染窗口对齐。
+ // 用 useNearViewport 而不是 useInView —— 后者 root 取视口,会被聊天滚动容器裁掉,
+ // 提前量实际不生效,滚到才高亮会看到一段纯文本。
+ const { ref, near } = useNearViewport({ rootMargin: '200% 0px', enabled: !deferHighlight, triggerOnce: true })
// Auto-detect tree structure if language is missing or text
const effectiveLanguage = useMemo(() => {
@@ -147,7 +163,7 @@ export const CodeBlock = memo(function CodeBlock({
return language || 'text'
}, [highlightCode, language])
- const shouldHighlight = !deferHighlight && (inView || forceHighlight)
+ const shouldHighlight = !deferHighlight && (near || forceHighlight)
const shouldStreamHighlight = shouldHighlight && streamingHighlight
const { output: highlightedTokens } = useSyntaxHighlight(highlightCode, {
@@ -207,6 +223,28 @@ export const CodeBlock = memo(function CodeBlock({
const lineHeight = isReasoning ? 'leading-5' : 'leading-6'
const textColor = isReasoning ? 'text-text-300' : 'text-text-200'
+ const foldActionLabel = folded ? foldLabel?.collapse : foldLabel?.expand
+ const renderFoldAction = (compact: boolean) =>
+ onToggleFold ? (
+
+ ) : null
+
const content = displayedHighlight ? (
{language}
+ {renderFoldAction(false)}
{headerActions}
@@ -266,6 +305,8 @@ export const CodeBlock = memo(function CodeBlock({
+ {renderFoldAction(true)}
+ {headerActions}
)}
- {/* Scrollable content */}
+ {/* Scrollable content:折叠态就是限高滚动,不裁切、不渐隐 */}
{content}
diff --git a/src/components/MarkdownRenderer.test.tsx b/src/components/MarkdownRenderer.test.tsx
index f8553c406..29ad28fbb 100644
--- a/src/components/MarkdownRenderer.test.tsx
+++ b/src/components/MarkdownRenderer.test.tsx
@@ -27,6 +27,9 @@ vi.mock('./CodeBlock', () => ({
forceHighlight,
streamingHighlight,
headerActions,
+ folded,
+ onToggleFold,
+ foldLabel,
}: {
code: string
language?: string
@@ -35,6 +38,9 @@ vi.mock('./CodeBlock', () => ({
forceHighlight?: boolean
streamingHighlight?: boolean
headerActions?: React.ReactNode
+ folded?: boolean
+ onToggleFold?: () => void
+ foldLabel?: { expand: string; collapse: string }
}) => (
({
{language}
{headerActions}
{`${language ?? 'text'}:${code}`}
+ {onToggleFold ? (
+
+ ) : null}
),
}))
@@ -97,6 +108,21 @@ describe('MarkdownRenderer', () => {
expect(codeEl.tagName).toBe('CODE')
})
+ it('keeps h5/h6 semantics instead of collapsing them to h4', () => {
+ const { container } = render()
+
+ expect(container.querySelector('h5')).toHaveTextContent('Five')
+ expect(container.querySelector('h6')).toHaveTextContent('Six')
+ })
+
+ it('drops raw HTML comments instead of showing them as text when HTML rendering is off', () => {
+ themeStore.setRenderHtmlContent(false)
+ const { container } = render( after'} />)
+
+ expect(container).toHaveTextContent('before after')
+ expect(container.textContent).not.toContain('hidden note')
+ })
+
it('renders inline code as a muted monospace chip (no accent color)', () => {
render()
@@ -260,6 +286,24 @@ $$
expect(container.querySelector('li input[type="checkbox"][checked]')).toBeInTheDocument()
})
+ it('marks GFM task items so the list marker does not double up with the checkbox', () => {
+ const { container } = render()
+
+ const items = Array.from(container.querySelectorAll('li'))
+ expect(items[0]).toHaveClass('task-list-item')
+ expect(items[1]).not.toHaveClass('task-list-item')
+ })
+
+ it('styles code blocks nested inside lists and quotes', () => {
+ const md = '- item\n\n ```ts\n const x = 1\n ```\n'
+ const { container } = render()
+
+ const pre = container.querySelector('pre.markdown-nested-code')
+ expect(pre).toBeInTheDocument()
+ expect(pre).toHaveAttribute('data-language', 'ts')
+ expect(pre).toHaveTextContent('const x = 1')
+ })
+
it('emphasizes CJK runs that close after punctuation right before a CJK character', () => {
const content = '**重点:**正文,**第二点。**继续,*斜体:*结尾,**(括号)**收尾'
const { container } = render()
@@ -795,6 +839,16 @@ $$`
expect(container.querySelector('.katex [style*="top"]')).toBeInTheDocument()
})
+ it('renders tables nested inside blockquotes with the shared table style', () => {
+ const md = '> | A | B |\n> |:---|---:|\n> | 1 | 2 |'
+ const { container } = render()
+
+ const table = container.querySelector('.markdown-html-table')
+ expect(table).toBeInTheDocument()
+ expect(table?.querySelector('th')).toHaveTextContent('A')
+ expect(table?.querySelector('th[align="right"]')).toHaveTextContent('B')
+ })
+
it('styles raw HTML tables without losing merged-cell attributes', () => {
const content = `
| 分类 | 项目 | 描述 |
@@ -1473,6 +1527,22 @@ $$`
expect(diagram).toHaveStyle({ transform: 'translate(-50px, -30px) scale(2)' })
})
+ it('keeps the diagram svg out of hit testing so page scrolling stays native', async () => {
+ useInputCapabilitiesMock.mockReturnValue({
+ canHover: false,
+ hasCoarsePointer: true,
+ hasTouch: true,
+ preferTouchUi: true,
+ })
+
+ render(B\n```'} />)
+
+ const diagram = await screen.findByRole('img', { name: 'Mermaid diagram' })
+ // 触摸落在