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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [v1.0.13] - 2026-11-09

- fix(ui): 全屏查看器在 iOS 状态栏下让开 safe-area (94b15f3d)
- fix(models): 模型列表未使用模型按名称首字母排序 (4f55ed0a)
- fix(slash-command): 斜杠命令匹配改为打分式模糊排序 (0deb01cb)
- fix(attachment): 路径引用在时间线可见,文本/图片预览修复 (f1bc065c)
- feat(attachment): 按类型和大小分流,二进制只给路径 (0aceff7a)
- feat(mention): @ 菜单兼容反斜杠路径 (b4147a97)
- fix(attachment): @ 提及回到 files[],对齐官方 file/path 两种部件 (f6e902f0)
- fix(sidebar): 连接状态点改用服务器健康状态,与设置页同源 (08cb1f71)

## [v1.0.12] - 2026-11-07

- perf(react): 稳定 useSyncExternalStore 订阅引用,避免每次渲染重绑 (64a77cd7)
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.12",
"version": "1.0.13",
"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.12"
version = "1.0.13"
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.12",
"version": "1.0.13",
"identifier": "com.opencodeui.app",
"build": {
"frontendDist": "../dist",
Expand Down
28 changes: 5 additions & 23 deletions src/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ function getOrCreateConnection(serverId: string): ServerConnection {
function updateConnectionState(serverId: string, update: Partial<ConnectionInfo>): void {
const conn = connections.get(serverId)
if (!conn) return
const becameConnected = update.state === 'connected' && conn.info.state !== 'connected'
const wasConnected = conn.info.state === 'connected'
const becameConnected = update.state === 'connected' && !wasConnected
conn.info = { ...conn.info, ...update }
// 设置页的健康灯和侧边栏的 SSE 状态必须收敛:连上了就把健康快照提升为
// 在线,否则启动期失败的探测结果会一直红着(健康轮询已跳过已连接服务器)
if (becameConnected) serverStore.noteServerConnected(serverId)
else if (wasConnected && update.state !== undefined && update.state !== 'connected') {
serverStore.noteServerDisconnected(serverId)
}
connectionListeners.get(serverId)?.forEach(fn => {
fn(conn.info)
})
Expand Down Expand Up @@ -946,28 +950,6 @@ export function subscribeToServerConnectionState(serverId: string, fn: (info: Co
}
}

/**
* 订阅活动服务器的连接状态变化(兼容旧 API)。
* 跟随 active server:切换服务器时自动迁移订阅,
* 否则状态栏会一直显示旧服务器的连接状态。
*/
export function subscribeToConnectionState(fn: (info: ConnectionInfo) => void): () => void {
let currentServerId = serverStore.getActiveServerId()
let unsubscribe = subscribeToServerConnectionState(currentServerId, fn)

const offServerChange = serverStore.onServerChange(newServerId => {
if (newServerId === currentServerId) return
unsubscribe()
currentServerId = newServerId
unsubscribe = subscribeToServerConnectionState(currentServerId, fn)
})

return () => {
offServerChange()
unsubscribe()
}
}

/**
* 订阅指定服务器的事件(每服务器独立连接)。
*/
Expand Down
123 changes: 120 additions & 3 deletions src/api/message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ describe('sendMessage — prompt 载荷(官方 request.ts + submit.ts:395-411
})

it('mention 区间随 files/agents 一起发出', async () => {
const text = '看下 @foo.ts 用 @build 跑'
await sendMessage({
...baseParams(),
text,
attachments: [
{
id: 'a1',
Expand All @@ -171,15 +173,24 @@ describe('sendMessage — prompt 载荷(官方 request.ts + submit.ts:395-411
})

const payload = lastPromptPayload()
const fileStart = text.indexOf('@foo.ts')
expect(payload.files).toEqual([
{ uri: 'file:///proj/src/foo.ts', name: 'foo.ts', mention: { start: 5, end: 12, text: '@foo.ts' } },
{
uri: 'file:///proj/src/foo.ts',
name: 'foo.ts',
mention: { start: fileStart, end: fileStart + '@foo.ts'.length, text: '@foo.ts' },
},
])
const agentStart = text.indexOf('@build')
expect(payload.agents).toEqual([
{ name: 'build', mention: { start: agentStart, end: agentStart + '@build'.length, text: '@build' } },
])
expect(payload.agents).toEqual([{ name: 'build', mention: { start: 20, end: 26, text: '@build' } }])
})

it('skill 附件进 skills 数组(id + mention)', async () => {
await sendMessage({
...baseParams(),
text: '@commit 提交',
attachments: [
{
id: 's1',
Expand Down Expand Up @@ -279,7 +290,7 @@ describe('sendMessage — 路径型附件的文本引用', () => {
expect(payload.metadata?.attachments).toHaveLength(1)
})

it('带 mention 的附件(@ 引用)不额外注入路径', async () => {
it('带 mention 的附件(@ 引用)进 files[],不额外注入路径', async () => {
await sendMessage({
...baseParams(),
text: '@src/foo.ts 看下',
Expand All @@ -295,10 +306,38 @@ describe('sendMessage — 路径型附件的文本引用', () => {
})

const payload = lastPromptPayload()
expect(payload.files).toEqual([
{
uri: 'file:///proj/src/foo.ts',
name: 'foo.ts',
mention: { start: 0, end: 11, text: '@src/foo.ts' },
},
])
expect(payload.text).toBe('@src/foo.ts 看下')
expect(payload.metadata?.attachments).toBeUndefined()
})

it('提及前面改过字后,mention 区间按当前文本重新定位', async () => {
await sendMessage({
...baseParams(),
text: '先加一句 @src/foo.ts 看下',
attachments: [
{
id: 'a1',
type: 'file',
displayName: 'foo.ts',
url: 'file:///proj/src/foo.ts',
// 插入时记下的旧偏移(在开头),用户后来在前面补了字
textRange: { value: '@src/foo.ts', start: 0, end: 11 },
},
] as never,
})

const payload = lastPromptPayload()
const start = '先加一句 '.length
expect(payload.files?.[0].mention).toEqual({ start, end: start + 11, text: '@src/foo.ts' })
})

it('带 mention 的附件被从文本删掉后仍补路径(pathOnly 只能靠文本可见)', async () => {
await sendMessage({
...baseParams(),
Expand All @@ -320,6 +359,34 @@ describe('sendMessage — 路径型附件的文本引用', () => {
expect(payload.text).toBe('看下这个\nAttached file: `/proj/src/foo.ts`')
})

it('二进制的 path 引用即使正文里有 @path 也补绝对路径(官方 path 部件无条件补)', async () => {
await sendMessage({
...baseParams(),
text: '@E:/Downloads/tool.exe 看下',
attachments: [
{
id: 'a1',
type: 'file',
displayName: 'tool.exe',
url: 'file:///E:/Downloads/tool.exe',
mime: 'application/x-msdownload',
pathOnly: true,
// 拖入时插入的芯片文本仍在正文里
textRange: { value: '@E:/Downloads/tool.exe', start: 0, end: 22 },
},
] as never,
})

const payload = lastPromptPayload()
// 不进 files[],不受服务端 20MB 读取上限影响
expect(payload.files).toBeUndefined()
// 但绝对路径必须给到模型(@ 相对路径不能保证模型读得到)
expect(payload.text).toBe('@E:/Downloads/tool.exe 看下\nAttached file: `E:/Downloads/tool.exe`')
expect(payload.metadata?.attachments).toEqual([
{ name: 'tool.exe', mime: 'application/x-msdownload', path: 'E:/Downloads/tool.exe' },
])
})

it('revert 回填的文本里已有同一引用时不重复追加', async () => {
const path = '/tmp/opencode/uploads/u1/report.zip'
await sendMessage({
Expand Down Expand Up @@ -403,6 +470,56 @@ describe('extractUserMessageContent — 路径附件回填', () => {
})
})

it('@ 提及文件回填 mention 区间,再次发送仍按附件处理', async () => {
const { extractUserMessageContent } = await import('./message')
const restored = extractUserMessageContent(
userMessage({
files: [
{
data: 'QQ==',
mime: 'text/plain',
source: { type: 'uri', uri: 'file:///repo/a.ts' },
name: 'a.ts',
mention: { start: 3, end: 9, text: '@a.ts' },
},
],
}),
)

expect(restored.attachments[0]).toMatchObject({
type: 'file',
displayName: 'a.ts',
url: 'file:///repo/a.ts',
mime: 'text/plain',
textRange: { value: '@a.ts', start: 3, end: 9 },
})
expect(restored.attachments[0]?.pathOnly).toBeUndefined()
})

it('inline 附件从 data 还原成 data URL,回退重发不丢内容', async () => {
const { extractUserMessageContent } = await import('./message')
const restored = extractUserMessageContent(
userMessage({
metadata: undefined,
files: [
{
data: 'aW1n',
mime: 'image/png',
source: { type: 'inline' },
name: 'shot.png',
},
],
}),
)

expect(restored.attachments[0]).toMatchObject({
type: 'file',
displayName: 'shot.png',
url: 'data:image/png;base64,aW1n',
mime: 'image/png',
})
})

it('已在 files[] 里的附件不会因为 metadata 再重复一次', async () => {
const { extractUserMessageContent } = await import('./message')
const restored = extractUserMessageContent(
Expand Down
Loading
Loading