@lynn123411/dsh-chat-translate 3.9.3 → 3.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DETAILS.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +20 -20
- package/lib/client.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/client/chat/assistant-step.d.ts +6 -4
- package/lib/types/client/chat/row-plan.d.ts +4 -1
- package/lib/types/client/index.d.ts +12 -1
- package/package.json +11 -11
package/DETAILS.md
CHANGED
|
@@ -103,7 +103,7 @@ refs:
|
|
|
103
103
|
|
|
104
104
|
分组判据是座次传入的 `groupPart`(`response` 分组排除思考块,`reasoning` 分组只渲染思考块,不送译),流式判据是行数据的 `status === "running"`。正文只往后追加:一个新块出现,它之前的块就再也不会变。行进入视口(150px 缓冲)后,**每一块在写定的那一刻**就送去翻译——回答还在生成时,先写定的块已经开始出中文,只有正在长的尾块保持原文。这是每行的首跑,也是唯一自动发生的请求;首跑期间界面不显示任何提示,中文回来直接替换原文。
|
|
105
105
|
|
|
106
|
-
- 不送译的内容:结论步骤的正文、Think 卡的思考链正文、工具调用行、用户消息、代码块(`pre
|
|
106
|
+
- 不送译的内容:结论步骤的正文、Think 卡的思考链正文、工具调用行、用户消息、代码块(`pre`)及其内部、空白块——这些由本包按宿主的分支自己渲染(整行接管,宿主 `conversation.chat.reasoning.body` 与 `conversation.chat.message.images` 两个单槽上的扩展不参与),接管渲染器抛错时按框架退位规则由宿主渲染器自动回位。
|
|
107
107
|
- 译文用宿主基线组件 `MarkdownText` 重新渲染,表格、列表、加粗、行内代码的结构保持原样。
|
|
108
108
|
- 上游模型重试(整次尝试清空从零重来)时按块判断:内容一字未变的块其中文留在原地,真变了的块才重翻。
|
|
109
109
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ DeepSeek Harness Web 界面的**助手回答正文翻译**插件。它接管助
|
|
|
16
16
|
## 特性
|
|
17
17
|
|
|
18
18
|
- **接管助手行渲染**:经 keyed slot `conversation.chat.node`(key `assistant-step`,priority -1)替换宿主的助手行渲染器。正文块从数据层拿原始 markdown(`AssistantBlock.text`),译文同样以 markdown 交给宿主公开的基线组件 `MarkdownText`(micromark + GFM + KaTeX)重渲染——表格、列表、加粗、行内代码、公式的结构由官方渲染器保证,插件不自拼 markup。接管渲染器抛错时按框架退位规则退出该 cell,宿主原渲染器自动回位。
|
|
19
|
-
-
|
|
19
|
+
- **整行接管,宿主两个单槽上的扩展不生效**:本包接管整个助手行的渲染,宿主 `conversation.chat.reasoning.body` 单槽(官方 CoT 翻译注册在那里)与 `conversation.chat.message.images` 单槽(自定义图片画廊注册在那里)上的贡献因此不会被调用。Think 折叠行(含工作细节策略下的摘要预览、Turn-process 折叠隐藏与页内搜索揭示)、连续图片组、工具调用行、未知内容块、中断前缀行尾的「已停止」都由本包自己画:图片经 `conversation.images.content` Factory 渲染,chrome 文案复用宿主 `chat` 词典。
|
|
20
20
|
- **正文排版原生,左缘不画任何东西**:正文没有竖线、没有缩进,文字位置与列表、引用的缩进与宿主默认逐字一致。两个可点物都落在正文之外:成功块是左缘 10px 宽的透明窄带(不占正文一个像素),失败块是一个 ↻ 按钮(`dsh-ct-retry`),失败段不放窄带——一段落只对应一个动作。窄带与 ↻ 都落在宿主正文列左侧的空白里,不压任何宿主元素。
|
|
21
21
|
- **结构重装配,形状问题只修不拒**:宿主先把块按 markdown 结构切段——代码围栏与纯空白段逐字保留、永不送模型——散文段再按输入上限(4096 估算 token)切片、相邻片段打包成一个请求(输出上限 8192 token)。回来的译文过**形状修复**(`repairShape`):按段落块对齐,块内结构行(记号类别、表格竖线数、链接个数、缩进代码缩进)逐一对齐并把行首前缀修回原文同款,散文行自由重排,空行布局一律取原文,`[文字](URL)` 的 URL 按出现序逐字拼回。修不齐的片段自动重掷一次,仍不齐就照收模型的译文——形状问题不否决内容,失败标记只留给「这一段没译出来」。
|
|
22
22
|
- **整段没写回来不算译好**:模型只把开头那段写回来、后面几段整段不写时,那几段正文会被永久丢掉,所以这一份不照收——重掷一次,而且第二问换成带标记的形状(模型因此不再把开头那段当整段),仍然少就整块保持原文并留下 ↻ 等手点重翻。
|
package/lib/client.js
CHANGED
|
@@ -1145,6 +1145,7 @@ function planAssistantRow(input) {
|
|
|
1145
1145
|
entries.push({
|
|
1146
1146
|
type: "prose",
|
|
1147
1147
|
key,
|
|
1148
|
+
textIndex: index,
|
|
1148
1149
|
text: block.text ?? "",
|
|
1149
1150
|
translated: outcome !== null && outcome.ok ? outcome.translated : null,
|
|
1150
1151
|
mark,
|
|
@@ -2009,16 +2010,10 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
|
|
|
2009
2010
|
return next;
|
|
2010
2011
|
});
|
|
2011
2012
|
}, []);
|
|
2012
|
-
const retryBlock = (0, import_react3.useCallback)(() => {
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
for (let index = 0; index < outcomes.length; index++) {
|
|
2017
|
-
const outcome = outcomes[index];
|
|
2018
|
-
if (outcome !== null && outcome !== void 0 && !outcome.ok) failed.push(index);
|
|
2019
|
-
}
|
|
2020
|
-
if (failed.length === 0) return;
|
|
2021
|
-
translate.ensure(rowKey, plan.texts, { frozen: frozenCount, retries: failed });
|
|
2013
|
+
const retryBlock = (0, import_react3.useCallback)((textIndex) => {
|
|
2014
|
+
const outcome = rowState?.outcomes?.[textIndex];
|
|
2015
|
+
if (outcome === null || outcome === void 0 || outcome.ok) return;
|
|
2016
|
+
translate.ensure(rowKey, plan.texts, { frozen: frozenCount, retries: [textIndex] });
|
|
2022
2017
|
}, [frozenCount, plan, rowKey, rowState, translate]);
|
|
2023
2018
|
if (displayed.entries === null) return null;
|
|
2024
2019
|
const last = blocks.length - 1;
|
|
@@ -2038,7 +2033,7 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
|
|
|
2038
2033
|
failKind: entry.failKind,
|
|
2039
2034
|
retryBusy: entry.retryBusy,
|
|
2040
2035
|
onToggle: () => toggleBlock(entry.key),
|
|
2041
|
-
onRetry: retryBlock,
|
|
2036
|
+
onRetry: () => retryBlock(entry.textIndex),
|
|
2042
2037
|
streaming,
|
|
2043
2038
|
labels,
|
|
2044
2039
|
mentions,
|
|
@@ -2187,6 +2182,17 @@ var name = "dsh-chat-translate";
|
|
|
2187
2182
|
var inject = ["slots", "configForms", "remote", "remote.credentials", "locale"];
|
|
2188
2183
|
function apply(ctx) {
|
|
2189
2184
|
ensureAssistantStyles();
|
|
2185
|
+
let fileMentions;
|
|
2186
|
+
ctx.inject(["chatFileMentions"], (scope) => {
|
|
2187
|
+
const service = scope.chatFileMentions;
|
|
2188
|
+
fileMentions = service;
|
|
2189
|
+
scope.effect(
|
|
2190
|
+
() => () => {
|
|
2191
|
+
if (fileMentions === service) fileMentions = void 0;
|
|
2192
|
+
},
|
|
2193
|
+
"dsh-chat-translate: file mentions"
|
|
2194
|
+
);
|
|
2195
|
+
});
|
|
2190
2196
|
ctx.effect(() => {
|
|
2191
2197
|
const slots = ctx.slots;
|
|
2192
2198
|
if (!slots || typeof slots.inject !== "function") return () => {
|
|
@@ -2202,17 +2208,11 @@ function apply(ctx) {
|
|
|
2202
2208
|
locale: "chat",
|
|
2203
2209
|
priority: -1,
|
|
2204
2210
|
// 思考行的 settledReasoningPreview 与 foldedReplies 来自活的工作细节模式;
|
|
2205
|
-
// fileMentions 由这条注册项自己提供(0.2.2 起不再走 owner props
|
|
2211
|
+
// fileMentions 由这条注册项自己提供(0.2.2 起不再走 owner props),
|
|
2212
|
+
// 服务缺席时返回 undefined,正文里的提及链接随之停用。
|
|
2206
2213
|
inject: (sessionId) => ({
|
|
2207
2214
|
hooks: { presentation: chatPresentation },
|
|
2208
|
-
fileMentions: (owner) =>
|
|
2209
|
-
try {
|
|
2210
|
-
const service = ctx.get?.("chatFileMentions");
|
|
2211
|
-
return service?.forClosing?.(owner, sessionId);
|
|
2212
|
-
} catch {
|
|
2213
|
-
return void 0;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2215
|
+
fileMentions: (owner) => fileMentions?.forClosing(owner, sessionId)
|
|
2216
2216
|
})
|
|
2217
2217
|
},
|
|
2218
2218
|
AssistantStepView
|