Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bef6dd6
perf(render): 流式文本按节奏揭示并减轻 Markdown/高亮渲染负担
lehhair Nov 18, 2026
e892dfd
fix(render): 补齐嵌套代码块样式并让自定义动画遵从减少动效
lehhair Nov 18, 2026
cde5248
perf(chat): 长会话下避免逐帧重算与无效重渲染
lehhair Nov 18, 2026
ff49568
perf(cache): 给消息渲染相关缓存加上体积上限
lehhair Nov 18, 2026
a79bd18
perf(markdown): 缓存非流式消息的分块结果
lehhair Nov 18, 2026
2b17bb5
perf(virtual): 会话恢复按 key 取高度,滚动时不再重建 observer
lehhair Nov 18, 2026
5eaf2a9
perf(virtual): 冷启动按消息内容估算行高
lehhair Nov 18, 2026
8c5ee29
fix(markdown): 补齐标题层级、嵌套表格、HTML 注释与列表/链接样式
lehhair Nov 19, 2026
14f317a
perf(markdown): 合并稳定块组并给超大 live 块限频完整解析
lehhair Nov 19, 2026
078a7cd
refactor(render): 统一有上限缓存,补开发期耗时打点
lehhair Nov 19, 2026
35104fc
refactor(chat): 抽出时间线高度估算与会话测量缓存
lehhair Nov 19, 2026
aab42f4
refactor(markdown): 抽出 Mermaid 渲染块
lehhair Nov 19, 2026
aa3effc
feat(stream): 流式文本尾部淡入
lehhair Nov 19, 2026
cd20225
fix(stream): 块结束后立即补齐前面的流式文字
lehhair Nov 19, 2026
41d797f
feat(settings): 流式逐字节奏与尾部淡入可单独开关
lehhair Nov 19, 2026
2f958c0
perf(highlight): 流式高亮改为增量协议
lehhair Nov 19, 2026
806773d
perf(markdown): 大块解析移到 Worker
lehhair Nov 19, 2026
c7836ee
perf(render): 长消息块级窗口化与流式掉帧采样
lehhair Nov 19, 2026
3ab3792
refactor(message): 拆出工具摘要与内容分组
lehhair Nov 19, 2026
f35f899
fix(chat): 翻页锚点让位于用户滚动,跳屏渲染延后到真实布局
lehhair Nov 19, 2026
94cb5d6
feat(memory): 会话持有量统计、按体积分页与闲置回收
lehhair Nov 19, 2026
664af91
perf(chat): 预渲染窗口改为按像素计算,高亮提前到可见之前
lehhair Nov 19, 2026
1182ec4
feat(stream): 工具卡按流式节奏生长入场
lehhair Nov 19, 2026
af45e12
fix(stream): 工具卡入场只做淡入,不再插值高度
lehhair Nov 19, 2026
af5b193
fix(chat): 流式期间每帧兜底贴底
lehhair Nov 19, 2026
ad1e901
style(markdown): 去掉 Mermaid 块文件末尾多余空行
lehhair Nov 19, 2026
fc5a26b
feat(markdown): 行内前瞻与长代码块折叠
lehhair Nov 19, 2026
2b4e25f
perf(highlight): 语法失败按语言冷却
lehhair Nov 19, 2026
50c4541
fix(markdown): 折叠改为限高可滚动,按钮并入操作区
lehhair Nov 19, 2026
3e9531e
fix(markdown): 围栏语言没写完时不做增量追加
lehhair Nov 19, 2026
4c63b19
feat(settings): 长代码块折叠可开关,默认开启
lehhair Nov 19, 2026
e7894e9
fix(markdown): 增量渲染按块边界判断,不再猜后缀
lehhair Nov 19, 2026
bd2cc1a
perf(markdown): 尾部增量解析与诊断补强
lehhair Nov 19, 2026
b50e340
fix(markdown): 图区域不再吞掉触摸滚动
lehhair Nov 19, 2026
5dc5194
fix(input): 手持设备按触摸优先,不再被媒体查询判成桌面
lehhair Nov 19, 2026
dcae2e1
chore: 准备发布 v1.0.15
cursoragent Nov 20, 2026
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
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -125,6 +126,7 @@ function App() {

useViewportHeight()
useWakeLock(wakeLock)
useIdleSessionTrim()

const activeDirectories = useMemo(
() =>
Expand Down
14 changes: 7 additions & 7 deletions src/components/CodeBlock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand All @@ -32,7 +32,7 @@ vi.mock('../hooks/useSyntaxHighlight', () => ({
}))

vi.mock('../hooks/useInView', () => ({
useInView: () => useInViewMock(),
useNearViewport: () => useNearViewportMock(),
}))

vi.mock('../store/themeStore', () => ({
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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(<CodeBlock code="const value = 1" language="ts" />)

Expand All @@ -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 }
Expand All @@ -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(<CodeBlock code="const value = 1" language="ts" />)

Expand Down
57 changes: 49 additions & 8 deletions src/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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({
Expand All @@ -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()
Expand All @@ -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(() => {
Expand All @@ -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, {
Expand Down Expand Up @@ -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 ? (
<button
type="button"
onClick={event => {
event.stopPropagation()
onToggleFold()
}}
title={foldActionLabel}
aria-label={foldActionLabel}
aria-expanded={!folded}
className={
compact
? 'inline-flex h-8 w-8 items-center justify-center rounded-md bg-bg-300/70 p-2 text-text-400 backdrop-blur-md transition-colors hover:bg-bg-300/90 hover:text-text-200'
: 'inline-flex h-8 w-8 items-center justify-center rounded-md p-2 text-text-400 transition-colors hover:bg-bg-300/60 hover:text-text-200'
}
>
{folded ? <ChevronDownIcon size={14} /> : <ChevronUpIcon size={14} />}
</button>
) : null

const content = displayedHighlight ? (
<pre
className={`shiki-wrapper m-0 font-mono select-text ${textColor} ${fontSize} ${lineHeight} ${contentPad} ${
Expand Down Expand Up @@ -258,6 +296,7 @@ export const CodeBlock = memo(function CodeBlock({
<span className="truncate">{language}</span>
</div>
<div className="inline-flex h-8 shrink-0 items-center gap-0.5 pr-2 opacity-0 group-hover/code:opacity-100 group-focus-within/code:opacity-100 [@media(hover:none)]:opacity-100 transition-opacity">
{renderFoldAction(false)}
{headerActions}
<CopyButton text={code} position="static" className="!h-8 !w-8 !p-2" />
</div>
Expand All @@ -266,6 +305,8 @@ export const CodeBlock = memo(function CodeBlock({
<div
className={`absolute top-2 right-2 z-10 opacity-0 group-hover/code:opacity-100 group-focus-within/code:opacity-100 ${requireTapToRevealCopy ? '[@media(hover:none)]:opacity-0' : '[@media(hover:none)]:opacity-100'} transition-opacity`}
>
{renderFoldAction(true)}
{headerActions}
<CopyButton
text={code}
position="static"
Expand All @@ -274,7 +315,7 @@ export const CodeBlock = memo(function CodeBlock({
</div>
)}

{/* Scrollable content */}
{/* Scrollable content:折叠态就是限高滚动,不裁切、不渐隐 */}
<div className={scrollClasses} style={maxHeight ? { maxHeight } : undefined}>
{content}
</div>
Expand Down
Loading
Loading