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
1 change: 1 addition & 0 deletions changelog.d/3114-remote-file-chip-zh.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A remote file chip in a chat now explains its download in a zh window: the hover title says the file comes from a remote Bot and is untrusted, while the file name stays exactly as the sender sent it ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)).
6 changes: 5 additions & 1 deletion core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ var ZH = {
Reactions: "表情",
"Message actions": "消息操作",
Download: "下载",
// #3114 cut 32: the remote file chip's hover title. The name is the sender's data and is filled
// in untranslated; the two words that make the chip safe to click — untrusted, and a remote Bot —
// stay in the sentence.
"Download {name} (untrusted file from a remote Bot)": "下载 {name}(来自远程 Bot 的不可信文件)",
"Clipboard unavailable": "剪贴板不可用,请手动选择文字复制",
"Could not copy message": "未能复制消息,请重试或手动选择文字复制",
"Could not download message": "未能下载消息,请重试或复制正文",
Expand Down Expand Up @@ -8238,7 +8242,7 @@ function RemoteFiles({ files, plugin, botId }) {
{ className: "bt-file-chips" },
files.map((file) => (0, import_react12.createElement)(
"button",
{ key: file.id, type: "button", className: "bt-file-chip", disabled: busy === file.id, title: `Download ${file.name} (untrusted file from a remote Bot)`, onClick: () => download2(file) },
{ key: file.id, type: "button", className: "bt-file-chip", disabled: busy === file.id, title: t("Download {name} (untrusted file from a remote Bot)", { name: file.name }), onClick: () => download2(file) },
`📎 ${file.name} · ${fileSize(file.size)}`
)),
error ? (0, import_react12.createElement)("span", { className: "bt-file-error", role: "alert" }, error) : null
Expand Down
2 changes: 1 addition & 1 deletion core/src/client/cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function RemoteFiles({ files, plugin, botId }) {
}
}
return h('div', { className: 'bt-file-chips' },
files.map(file => h('button', { key: file.id, type: 'button', className: 'bt-file-chip', disabled: busy === file.id, title: `Download ${file.name} (untrusted file from a remote Bot)`, onClick: () => download(file) },
files.map(file => h('button', { key: file.id, type: 'button', className: 'bt-file-chip', disabled: busy === file.id, title: t('Download {name} (untrusted file from a remote Bot)', { name: file.name }), onClick: () => download(file) },
`📎 ${file.name} · ${fileSize(file.size)}`)),
error ? h('span', { className: 'bt-file-error', role: 'alert' }, error) : null)
}
Expand Down
4 changes: 4 additions & 0 deletions core/src/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,10 @@ const ZH = {
Reactions: '表情',
'Message actions': '消息操作',
Download: '下载',
// #3114 cut 32: the remote file chip's hover title. The name is the sender's data and is filled
// in untranslated; the two words that make the chip safe to click — untrusted, and a remote Bot —
// stay in the sentence.
'Download {name} (untrusted file from a remote Bot)': '下载 {name}(来自远程 Bot 的不可信文件)',
'Clipboard unavailable': '剪贴板不可用,请手动选择文字复制',
'Could not copy message': '未能复制消息,请重试或手动选择文字复制',
'Could not download message': '未能下载消息,请重试或复制正文',
Expand Down
43 changes: 41 additions & 2 deletions core/test/empty-message-cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import { build } from 'esbuild'
// with nothing in it, under the trace row of the turn that produced it. The draw is checked where a
// person reads it: the bubbles of one message (a Bot's own chat) and a group chat's reply rows.
async function load(entry) {
// #3114 cut 32: one entry exports the cells and the dictionary they read, so `installLocale` binds
// the copy `t` reaches. Two separate bundles would bind a dictionary no cell ever looks at.
const bundle = await build({
entryPoints: [fileURLToPath(new URL(`../src/client/${entry}`, import.meta.url))],
stdin: {
contents: `export * from ${JSON.stringify(fileURLToPath(new URL(`../src/client/${entry}`, import.meta.url)))}\nexport { DICTIONARY, installLocale } from ${JSON.stringify(fileURLToPath(new URL('../src/client/i18n.js', import.meta.url)))}`,
resolveDir: fileURLToPath(new URL('../src/client', import.meta.url)),
sourcefile: 'cells-and-dictionary.js',
loader: 'js',
},
bundle: true, format: 'cjs', platform: 'node', write: false,
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
Expand Down Expand Up @@ -46,7 +53,7 @@ const find = (node, match) => {
}
const count = (node, cls) => find(node, item => String(item.props?.className ?? '').split(/\s+/).includes(cls)).length

const { Bubbles, GroupReplies, RemoteMessage } = await load('cells.js')
const { Bubbles, GroupReplies, RemoteMessage, DICTIONARY, installLocale } = await load('cells.js')

const chief = { id: 'chief', name: 'Chief', color: 'green' }
const writer = { id: 'writer', name: 'Writer', color: 'blue' }
Expand Down Expand Up @@ -91,3 +98,35 @@ test("#2123: a friend's line with no text keeps its files and draws no empty bub
assert.equal(count(attached, 'bt-bubble'), 0, 'the attachment stays, the empty bubble does not')
assert.equal(count(attached, 'bt-remote-msg'), 1)
})

// #3114 cut 32: the chips' hover title is a sentence, so the window's language decides it; the file
// name is the sender's data and rides through `{name}` untranslated.
const CHIP_FILES = [
{ id: 'f1', name: 'log.txt', size: 12, mime: 'text/plain' },
{ id: 'f2', name: '报告 2026.pdf', size: 2048, mime: 'application/pdf' },
]
const fill = (text, params) => text.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match))
const inLang = (active, draw) => {
const zh = key => active.startsWith('zh') ? DICTIONARY.zh[key] ?? key : key
const off = installLocale({ register: () => () => {}, bind: () => (key, params) => fill(zh(key), params ?? {}), getLocale: () => ({ active }) })
try { return draw() } finally { off() }
}
const chipTitles = files => find(expand(RemoteMessage({
source: { remote: { handle: '@coder.bob.home', senderName: 'Bob’s Coder' }, senderName: 'Bob’s Coder', attachments: files },
text: '', roster, actions, sessionId: 'chat', msgKey: 'chat:turn:3',
}), ['RemoteFiles']), node => node.props?.className === 'bt-file-chip').map(node => node.props.title)

test('#3114 cut 32: a zh window reads the remote file chip as an untrusted file from a remote Bot', () => {
assert.deepEqual(inLang('zh-CN', () => chipTitles(CHIP_FILES)), [
'下载 log.txt(来自远程 Bot 的不可信文件)',
'下载 报告 2026.pdf(来自远程 Bot 的不可信文件)',
])
})

test('#3114 cut 32: an English window keeps the chip title exactly as it reads today', () => {
assert.deepEqual(inLang('en', () => chipTitles(CHIP_FILES)), [
'Download log.txt (untrusted file from a remote Bot)',
'Download 报告 2026.pdf (untrusted file from a remote Bot)',
])
assert.equal(DICTIONARY.zh['Download {name} (untrusted file from a remote Bot)'], '下载 {name}(来自远程 Bot 的不可信文件)')
})
6 changes: 5 additions & 1 deletion patches/ds-bot/0001-core-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1587,14 +1587,18 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js

// Bot exchange
'Bot exchange': 'Bot 间对话',
@@ -390,11 +390,18 @@ const ZH = {
@@ -390,11 +390,22 @@ const ZH = {
Reply: '回复',
'More message actions': '更多操作',
More: '更多',
+ Sharing: '分享',
Reactions: '表情',
'Message actions': '消息操作',
Download: '下载',
+ // #3114 cut 32: the remote file chip's hover title. The name is the sender's data and is filled
+ // in untranslated; the two words that make the chip safe to click — untrusted, and a remote Bot —
+ // stay in the sentence.
+ 'Download {name} (untrusted file from a remote Bot)': '下载 {name}(来自远程 Bot 的不可信文件)',
+ 'Clipboard unavailable': '剪贴板不可用,请手动选择文字复制',
+ 'Could not copy message': '未能复制消息,请重试或手动选择文字复制',
+ 'Could not download message': '未能下载消息,请重试或复制正文',
Expand Down
2 changes: 1 addition & 1 deletion patches/ds-bot/0003-flybot-api-client.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ diff --git a/src/client/cells.js b/src/client/cells.js
+ }
+ }
+ return h('div', { className: 'bt-file-chips' },
+ files.map(file => h('button', { key: file.id, type: 'button', className: 'bt-file-chip', disabled: busy === file.id, title: `Download ${file.name} (untrusted file from a remote Bot)`, onClick: () => download(file) },
+ files.map(file => h('button', { key: file.id, type: 'button', className: 'bt-file-chip', disabled: busy === file.id, title: t('Download {name} (untrusted file from a remote Bot)', { name: file.name }), onClick: () => download(file) },
+ `📎 ${file.name} · ${fileSize(file.size)}`)),
+ error ? h('span', { className: 'bt-file-error', role: 'alert' }, error) : null)
+}
Expand Down
8 changes: 6 additions & 2 deletions patches/ds-bot/0008-client-bundle.patch
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,18 @@ diff --git a/client.js b/client.js
// Bot exchange
"Bot exchange": "Bot 间对话",
"Bot exchange transcript": "Bot 间对话记录",
@@ -446,11 +446,18 @@ var ZH = {
@@ -446,11 +446,22 @@ var ZH = {
Reply: "回复",
"More message actions": "更多操作",
More: "更多",
+ Sharing: "分享",
Reactions: "表情",
"Message actions": "消息操作",
Download: "下载",
+ // #3114 cut 32: the remote file chip's hover title. The name is the sender's data and is filled
+ // in untranslated; the two words that make the chip safe to click — untrusted, and a remote Bot —
+ // stay in the sentence.
+ "Download {name} (untrusted file from a remote Bot)": "下载 {name}(来自远程 Bot 的不可信文件)",
+ "Clipboard unavailable": "剪贴板不可用,请手动选择文字复制",
+ "Could not copy message": "未能复制消息,请重试或手动选择文字复制",
+ "Could not download message": "未能下载消息,请重试或复制正文",
Expand Down Expand Up @@ -9255,7 +9259,7 @@ diff --git a/client.js b/client.js
+ { className: "bt-file-chips" },
+ files.map((file) => (0, import_react12.createElement)(
+ "button",
+ { key: file.id, type: "button", className: "bt-file-chip", disabled: busy === file.id, title: `Download ${file.name} (untrusted file from a remote Bot)`, onClick: () => download2(file) },
+ { key: file.id, type: "button", className: "bt-file-chip", disabled: busy === file.id, title: t("Download {name} (untrusted file from a remote Bot)", { name: file.name }), onClick: () => download2(file) },
+ `📎 ${file.name} · ${fileSize(file.size)}`
+ )),
+ error ? (0, import_react12.createElement)("span", { className: "bt-file-error", role: "alert" }, error) : null
Expand Down
43 changes: 41 additions & 2 deletions patches/ds-bot/files/test/empty-message-cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import { build } from 'esbuild'
// with nothing in it, under the trace row of the turn that produced it. The draw is checked where a
// person reads it: the bubbles of one message (a Bot's own chat) and a group chat's reply rows.
async function load(entry) {
// #3114 cut 32: one entry exports the cells and the dictionary they read, so `installLocale` binds
// the copy `t` reaches. Two separate bundles would bind a dictionary no cell ever looks at.
const bundle = await build({
entryPoints: [fileURLToPath(new URL(`../src/client/${entry}`, import.meta.url))],
stdin: {
contents: `export * from ${JSON.stringify(fileURLToPath(new URL(`../src/client/${entry}`, import.meta.url)))}\nexport { DICTIONARY, installLocale } from ${JSON.stringify(fileURLToPath(new URL('../src/client/i18n.js', import.meta.url)))}`,
resolveDir: fileURLToPath(new URL('../src/client', import.meta.url)),
sourcefile: 'cells-and-dictionary.js',
loader: 'js',
},
bundle: true, format: 'cjs', platform: 'node', write: false,
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
Expand Down Expand Up @@ -46,7 +53,7 @@ const find = (node, match) => {
}
const count = (node, cls) => find(node, item => String(item.props?.className ?? '').split(/\s+/).includes(cls)).length

const { Bubbles, GroupReplies, RemoteMessage } = await load('cells.js')
const { Bubbles, GroupReplies, RemoteMessage, DICTIONARY, installLocale } = await load('cells.js')

const chief = { id: 'chief', name: 'Chief', color: 'green' }
const writer = { id: 'writer', name: 'Writer', color: 'blue' }
Expand Down Expand Up @@ -91,3 +98,35 @@ test("#2123: a friend's line with no text keeps its files and draws no empty bub
assert.equal(count(attached, 'bt-bubble'), 0, 'the attachment stays, the empty bubble does not')
assert.equal(count(attached, 'bt-remote-msg'), 1)
})

// #3114 cut 32: the chips' hover title is a sentence, so the window's language decides it; the file
// name is the sender's data and rides through `{name}` untranslated.
const CHIP_FILES = [
{ id: 'f1', name: 'log.txt', size: 12, mime: 'text/plain' },
{ id: 'f2', name: '报告 2026.pdf', size: 2048, mime: 'application/pdf' },
]
const fill = (text, params) => text.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match))
const inLang = (active, draw) => {
const zh = key => active.startsWith('zh') ? DICTIONARY.zh[key] ?? key : key
const off = installLocale({ register: () => () => {}, bind: () => (key, params) => fill(zh(key), params ?? {}), getLocale: () => ({ active }) })
try { return draw() } finally { off() }
}
const chipTitles = files => find(expand(RemoteMessage({
source: { remote: { handle: '@coder.bob.home', senderName: 'Bob’s Coder' }, senderName: 'Bob’s Coder', attachments: files },
text: '', roster, actions, sessionId: 'chat', msgKey: 'chat:turn:3',
}), ['RemoteFiles']), node => node.props?.className === 'bt-file-chip').map(node => node.props.title)

test('#3114 cut 32: a zh window reads the remote file chip as an untrusted file from a remote Bot', () => {
assert.deepEqual(inLang('zh-CN', () => chipTitles(CHIP_FILES)), [
'下载 log.txt(来自远程 Bot 的不可信文件)',
'下载 报告 2026.pdf(来自远程 Bot 的不可信文件)',
])
})

test('#3114 cut 32: an English window keeps the chip title exactly as it reads today', () => {
assert.deepEqual(inLang('en', () => chipTitles(CHIP_FILES)), [
'Download log.txt (untrusted file from a remote Bot)',
'Download 报告 2026.pdf (untrusted file from a remote Bot)',
])
assert.equal(DICTIONARY.zh['Download {name} (untrusted file from a remote Bot)'], '下载 {name}(来自远程 Bot 的不可信文件)')
})
Loading