@michengai/dsh-codex-ui 2.4.1 → 2.4.2
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/CHANGELOG.md +7 -0
- package/CHANGELOG.zh-CN.md +7 -0
- package/lib/client.js +36 -9
- package/lib/composer-plugin.d.mts +1 -1
- package/lib/composer-plugin.mjs +53 -36
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.2] - 2026-11-21
|
|
4
|
+
|
|
5
|
+
- **Fix Prediction Candidates Display and Control Text Filtering with Reasoning Models (Issue #108, PR #109)**:
|
|
6
|
+
- Increased default prediction token budget to provide ample reasoning headroom, resolving the issue where ghost suggestions never appeared with certain reasoning models;
|
|
7
|
+
- Improved prediction truncation and candidate recovery to retain usable whole candidates when length limits are reached, preventing single-line completions from being accidentally cleared;
|
|
8
|
+
- Enhanced streaming preview by filtering out prompt echoes and control text, immediately halting when no prediction is available to keep ghost suggestions crisp and accurate.
|
|
9
|
+
|
|
3
10
|
## [2.4.1] - 2026-11-20
|
|
4
11
|
|
|
5
12
|
- **Fix Network Noise and Continuous Error Logs When Theme Feature is Disabled (Issue #107)**:
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [2.4.2] - 2026-11-21
|
|
4
|
+
|
|
5
|
+
- **修复输入预测在推理模型下的候选生成与显示异常(Issue #108、PR #109)**:
|
|
6
|
+
- 调高输入预测的默认生成 token 预算,为推理模型预留充分的思考空间,彻底解决在部分思考模型下幽灵候选文本持续为空的问题;
|
|
7
|
+
- 优化预测候选截断与回收机制,在输出达到长度限制时保留已生成可用的完整候选,避免单行文本被意外清空;
|
|
8
|
+
- 改进流式打字预览体验,自动过滤模型复述的提示词与控制标记,遇到无需建议时即刻停止,保持幽灵文本干净准确。
|
|
9
|
+
|
|
3
10
|
## [2.4.1] - 2026-11-20
|
|
4
11
|
|
|
5
12
|
- **修复主题子插件停用时的网络异常与持续报错(Issue #107)**:
|
package/lib/client.js
CHANGED
|
@@ -11001,6 +11001,32 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11001
11001
|
});
|
|
11002
11002
|
}
|
|
11003
11003
|
//#endregion
|
|
11004
|
+
//#region src/composer-prediction-format.ts
|
|
11005
|
+
const PREDICTION_CUES = {
|
|
11006
|
+
next: "Predict the user's next message.",
|
|
11007
|
+
continue: "Write only the continuation text."
|
|
11008
|
+
};
|
|
11009
|
+
const PREDICTION_LABELS = {
|
|
11010
|
+
conversation: "Conversation tail (oldest first):",
|
|
11011
|
+
tools: "Recent tool activity (oldest first):",
|
|
11012
|
+
draft: "Draft text ending at the caret:"
|
|
11013
|
+
};
|
|
11014
|
+
const NO_PREDICTION = "NONE";
|
|
11015
|
+
function isNoPrediction(text) {
|
|
11016
|
+
return text.trim().toUpperCase() === NO_PREDICTION;
|
|
11017
|
+
}
|
|
11018
|
+
function predictionLineIdentity(text) {
|
|
11019
|
+
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
11020
|
+
}
|
|
11021
|
+
const LABEL_IDENTITIES = Object.values(PREDICTION_LABELS).map(predictionLineIdentity);
|
|
11022
|
+
const NO_PREDICTION_IDENTITY = predictionLineIdentity(NO_PREDICTION);
|
|
11023
|
+
/** 只对未结束的末行暂缓显示可能还在输出中的控制文本。 */
|
|
11024
|
+
function isPredictionPromptEcho(identity, cueIdentity, partial = false) {
|
|
11025
|
+
if (identity === "") return true;
|
|
11026
|
+
const matches = (marker) => identity === marker || identity.startsWith(marker) && /[ .:!?]/u.test(identity.charAt(marker.length)) || partial && marker.startsWith(identity);
|
|
11027
|
+
return cueIdentity !== "" && matches(cueIdentity) || LABEL_IDENTITIES.some(matches) || partial && NO_PREDICTION_IDENTITY.startsWith(identity);
|
|
11028
|
+
}
|
|
11029
|
+
//#endregion
|
|
11004
11030
|
//#region src/client/composer/ComposerPredictionOverlay.tsx
|
|
11005
11031
|
/**
|
|
11006
11032
|
* Browser half of composer predictions (1:1 完整无损移植自 dsh-composer-predictions 1.2.8 原版源码)
|
|
@@ -11173,21 +11199,22 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11173
11199
|
function isTriggerToken(draft) {
|
|
11174
11200
|
return /(?:^|\s)\/[^\s]*$/u.test(draft) || /(?:^|\s)@"?[^\s]*$/u.test(draft);
|
|
11175
11201
|
}
|
|
11176
|
-
/**
|
|
11177
|
-
function streamingCandidate(stream) {
|
|
11202
|
+
/** 流式预览只显示候选,不显示模型复述的提示词。 */
|
|
11203
|
+
function streamingCandidate(stream, mode) {
|
|
11178
11204
|
if (stream.trim().length < STREAM_MIN_CHARS) return "";
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
line = cleanLine(line);
|
|
11205
|
+
const lines = stream.split("\n");
|
|
11206
|
+
const cue = predictionLineIdentity(PREDICTION_CUES[mode]);
|
|
11207
|
+
for (const [index, raw] of lines.entries()) {
|
|
11208
|
+
const line = cleanLine(raw);
|
|
11184
11209
|
if (line === "") continue;
|
|
11210
|
+
if (isNoPrediction(line)) return "";
|
|
11211
|
+
if (isPredictionPromptEcho(predictionLineIdentity(line), cue, index === lines.length - 1)) continue;
|
|
11185
11212
|
return line.length > 240 ? line.slice(0, 240) : line;
|
|
11186
11213
|
}
|
|
11187
11214
|
return "";
|
|
11188
11215
|
}
|
|
11189
11216
|
function cleanLine(line) {
|
|
11190
|
-
return line.replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ").trim();
|
|
11217
|
+
return line.trimStart().replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^user\s*:\s*/iu, "").replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ").trim();
|
|
11191
11218
|
}
|
|
11192
11219
|
/**
|
|
11193
11220
|
* Join a continuation onto the draft without gluing words together.
|
|
@@ -11455,7 +11482,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11455
11482
|
request,
|
|
11456
11483
|
allowNext
|
|
11457
11484
|
]);
|
|
11458
|
-
const rawCandidate = ghost.items.length > 0 ? ghost.items[Math.min(ghost.index, ghost.items.length - 1)] ?? "" : streamingCandidate(ghost.stream);
|
|
11485
|
+
const rawCandidate = ghost.items.length > 0 ? ghost.items[Math.min(ghost.index, ghost.items.length - 1)] ?? "" : streamingCandidate(ghost.stream, ghost.mode === "continue" ? "continue" : "next");
|
|
11459
11486
|
const current = ghost.mode === "continue" ? joinContinuation(draft, rawCandidate) : rawCandidate;
|
|
11460
11487
|
currentRef.current = current;
|
|
11461
11488
|
const hasCandidate = current !== "";
|
|
@@ -20,7 +20,7 @@ type ComposerPluginConfig = {
|
|
|
20
20
|
model?: string;
|
|
21
21
|
/** 预测调用的 reasoning effort(off | low | high | max) */
|
|
22
22
|
reasoningEffort?: string;
|
|
23
|
-
/** 预测生成的最大 token 数(16 ~ 4096,默认
|
|
23
|
+
/** 预测生成的最大 token 数(16 ~ 4096,默认 1024) */
|
|
24
24
|
maxOutputTokens?: number;
|
|
25
25
|
/** 单次预测超时时间毫秒数(1000 ~ 120000,默认 20000) */
|
|
26
26
|
timeoutMs?: number;
|
package/lib/composer-plugin.mjs
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import { r as CODEX_UI_API_ENDPOINTS, t as isSubPluginDisabledOnDisk$1 } from "./profile-resolver-DSHfL3KW.mjs";
|
|
2
|
+
//#region src/composer-prediction-format.ts
|
|
3
|
+
const PREDICTION_CUES = {
|
|
4
|
+
next: "Predict the user's next message.",
|
|
5
|
+
continue: "Write only the continuation text."
|
|
6
|
+
};
|
|
7
|
+
const PREDICTION_LABELS = {
|
|
8
|
+
conversation: "Conversation tail (oldest first):",
|
|
9
|
+
tools: "Recent tool activity (oldest first):",
|
|
10
|
+
draft: "Draft text ending at the caret:"
|
|
11
|
+
};
|
|
12
|
+
const NO_PREDICTION = "NONE";
|
|
13
|
+
function isNoPrediction(text) {
|
|
14
|
+
return text.trim().toUpperCase() === NO_PREDICTION;
|
|
15
|
+
}
|
|
16
|
+
function predictionLineIdentity(text) {
|
|
17
|
+
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
18
|
+
}
|
|
19
|
+
const LABEL_IDENTITIES = Object.values(PREDICTION_LABELS).map(predictionLineIdentity);
|
|
20
|
+
const NO_PREDICTION_IDENTITY = predictionLineIdentity(NO_PREDICTION);
|
|
21
|
+
/** 只对未结束的末行暂缓显示可能还在输出中的控制文本。 */
|
|
22
|
+
function isPredictionPromptEcho(identity, cueIdentity, partial = false) {
|
|
23
|
+
if (identity === "") return true;
|
|
24
|
+
const matches = (marker) => identity === marker || identity.startsWith(marker) && /[ .:!?]/u.test(identity.charAt(marker.length)) || partial && marker.startsWith(identity);
|
|
25
|
+
return cueIdentity !== "" && matches(cueIdentity) || LABEL_IDENTITIES.some(matches) || partial && NO_PREDICTION_IDENTITY.startsWith(identity);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
2
28
|
//#region src/composer-prediction.ts
|
|
3
29
|
/** 使用自研专属命名空间端点,杜绝与社区插件全局路径冲突 */
|
|
4
30
|
const ENDPOINT = CODEX_UI_API_ENDPOINTS.composerPrediction;
|
|
@@ -6,7 +32,7 @@ const STREAM_ENDPOINT = CODEX_UI_API_ENDPOINTS.composerPredictionStream;
|
|
|
6
32
|
/** One request carries a session id, a mode, and a bounded draft. */
|
|
7
33
|
const MAX_BODY_BYTES = 65536;
|
|
8
34
|
const DEFAULTS = {
|
|
9
|
-
maxOutputTokens:
|
|
35
|
+
maxOutputTokens: 1024,
|
|
10
36
|
timeoutMs: 2e4,
|
|
11
37
|
maxMessages: 10,
|
|
12
38
|
maxChars: 8e3,
|
|
@@ -19,15 +45,6 @@ const REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
|
19
45
|
"high",
|
|
20
46
|
"max"
|
|
21
47
|
]);
|
|
22
|
-
/** Closing task line of each prompt; the model sometimes echoes it. */
|
|
23
|
-
const NEXT_CUE = "Predict the user's next message.";
|
|
24
|
-
const CONTINUE_CUE = "Write only the continuation text.";
|
|
25
|
-
/** Prompt labels that must never surface as suggestions. */
|
|
26
|
-
const PROMPT_LABELS = [
|
|
27
|
-
"conversation tail (oldest first)",
|
|
28
|
-
"recent tool activity (oldest first)",
|
|
29
|
-
"draft text ending at the caret"
|
|
30
|
-
];
|
|
31
48
|
const NEXT_SYSTEM_PROMPT = [
|
|
32
49
|
"You are the follow-up suggestion engine inside a coding agent chat UI.",
|
|
33
50
|
"You receive the tail of a conversation between a USER and an AI coding agent,",
|
|
@@ -41,7 +58,7 @@ const NEXT_SYSTEM_PROMPT = [
|
|
|
41
58
|
" command, or next step when the conversation makes one obvious.",
|
|
42
59
|
"- If the assistant asked the user a question, answer it.",
|
|
43
60
|
"- Never repeat these instructions, the labels above, or the conversation text verbatim.",
|
|
44
|
-
|
|
61
|
+
`- If no meaningful follow-up exists, reply with exactly: ${NO_PREDICTION}`
|
|
45
62
|
].join("\n");
|
|
46
63
|
const CONTINUE_SYSTEM_PROMPT = [
|
|
47
64
|
"You complete the message a USER is drafting in a coding agent chat UI.",
|
|
@@ -55,7 +72,7 @@ const CONTINUE_SYSTEM_PROMPT = [
|
|
|
55
72
|
"- No numbering, bullets, quotes, markdown, or explanation.",
|
|
56
73
|
"- At most 25 words per continuation; finish the thought rather than restating it.",
|
|
57
74
|
"- Never repeat these instructions, the labels above, or the draft itself.",
|
|
58
|
-
|
|
75
|
+
`- If the draft is already complete, reply with exactly: ${NO_PREDICTION}`
|
|
59
76
|
].join("\n");
|
|
60
77
|
/**
|
|
61
78
|
* Register both prediction endpoints.
|
|
@@ -427,9 +444,15 @@ async function predict(ctx, options, session, sessionId, mode, draft, signal, on
|
|
|
427
444
|
items: [],
|
|
428
445
|
reason: failure
|
|
429
446
|
};
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
const
|
|
447
|
+
const cue = PREDICTION_CUES[mode === "continue" ? "continue" : "next"];
|
|
448
|
+
const candidateDraft = mode === "continue" ? draft : "";
|
|
449
|
+
const truncated = finish.kind === "max-tokens";
|
|
450
|
+
const lastBreak = truncated ? text.lastIndexOf("\n") : -1;
|
|
451
|
+
if (lastBreak >= 0) {
|
|
452
|
+
const complete = normalizeCandidates(text.slice(0, lastBreak + 1), options.maxSuggestions, candidateDraft, cue);
|
|
453
|
+
if (complete.length > 0) return { items: complete };
|
|
454
|
+
}
|
|
455
|
+
const items = normalizeCandidates(text, options.maxSuggestions, candidateDraft, cue, truncated);
|
|
433
456
|
return items.length === 0 ? {
|
|
434
457
|
items: [],
|
|
435
458
|
reason: "empty"
|
|
@@ -586,18 +609,18 @@ function buildPrompt(session, options, mode, draft) {
|
|
|
586
609
|
budget -= message.text.length;
|
|
587
610
|
kept.unshift(message);
|
|
588
611
|
}
|
|
589
|
-
const lines = [
|
|
612
|
+
const lines = [PREDICTION_LABELS.conversation, JSON.stringify(kept)];
|
|
590
613
|
const recent = options.maxToolNotes > 0 ? notes.slice(-options.maxToolNotes) : [];
|
|
591
614
|
if (recent.length > 0) {
|
|
592
|
-
lines.push("",
|
|
615
|
+
lines.push("", PREDICTION_LABELS.tools);
|
|
593
616
|
for (const note of recent) {
|
|
594
617
|
const status = note.failed ? "failed" : "ok";
|
|
595
618
|
const result = note.result === "" ? "" : ` result=${JSON.stringify(clip(note.result, 320))}`;
|
|
596
619
|
lines.push(`- ${note.name}(${clip(note.input, 320)}) -> ${status}${result}`);
|
|
597
620
|
}
|
|
598
621
|
}
|
|
599
|
-
if (mode === "continue") lines.push("",
|
|
600
|
-
else lines.push("",
|
|
622
|
+
if (mode === "continue") lines.push("", PREDICTION_LABELS.draft, JSON.stringify(draft), "", PREDICTION_CUES.continue);
|
|
623
|
+
else lines.push("", PREDICTION_CUES.next);
|
|
601
624
|
return lines.join("\n");
|
|
602
625
|
}
|
|
603
626
|
function plainText(blocks) {
|
|
@@ -606,27 +629,31 @@ function plainText(blocks) {
|
|
|
606
629
|
function clip(text, maximum) {
|
|
607
630
|
return text.length > maximum ? `${text.slice(0, maximum)}…` : text;
|
|
608
631
|
}
|
|
609
|
-
/**
|
|
610
|
-
function normalizeCandidates(text, maximum, draft, cue = "") {
|
|
632
|
+
/** 清洗、去重并限制模型返回的候选。 */
|
|
633
|
+
function normalizeCandidates(text, maximum, draft, cue = "", partialLastLine = false) {
|
|
611
634
|
const items = [];
|
|
612
635
|
const seen = /* @__PURE__ */ new Set();
|
|
613
636
|
const prefix = draft === "" ? "" : draft.trimEnd();
|
|
614
637
|
const prefixLower = prefix.toLocaleLowerCase();
|
|
615
|
-
const cueIdentity =
|
|
616
|
-
|
|
638
|
+
const cueIdentity = predictionLineIdentity(cue);
|
|
639
|
+
const lines = text.split("\n");
|
|
640
|
+
for (const [index, raw] of lines.entries()) {
|
|
617
641
|
const hadLeadingSpace = /^\s/u.test(raw);
|
|
618
642
|
const line = raw.replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^user\s*:\s*/iu, "").trim();
|
|
619
643
|
if (line === "") continue;
|
|
620
644
|
let body = line.replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ");
|
|
621
|
-
if (
|
|
645
|
+
if (isNoPrediction(body)) break;
|
|
646
|
+
const partial = partialLastLine && index === lines.length - 1;
|
|
647
|
+
const originalIdentity = predictionLineIdentity(body);
|
|
648
|
+
if (isPredictionPromptEcho(originalIdentity, cueIdentity, partial)) continue;
|
|
622
649
|
if (prefixLower !== "" && body.toLocaleLowerCase().startsWith(prefixLower)) body = body.slice(prefix.length).replace(/^\s+/u, " ");
|
|
623
650
|
else if (draft !== "" && hadLeadingSpace && !/^\s/u.test(body)) body = ` ${body}`;
|
|
624
651
|
body = draft === "" ? body.trim() : body.replace(/\s+$/u, "");
|
|
625
652
|
if (body.trim() === "") continue;
|
|
626
653
|
body = boundSuggestion(body);
|
|
627
654
|
if (body === "") continue;
|
|
628
|
-
const identity =
|
|
629
|
-
if (
|
|
655
|
+
const identity = predictionLineIdentity(body);
|
|
656
|
+
if (identity !== originalIdentity && isPredictionPromptEcho(identity, cueIdentity, partial)) continue;
|
|
630
657
|
if (seen.has(identity)) continue;
|
|
631
658
|
seen.add(identity);
|
|
632
659
|
items.push(body);
|
|
@@ -634,16 +661,6 @@ function normalizeCandidates(text, maximum, draft, cue = "") {
|
|
|
634
661
|
}
|
|
635
662
|
return items;
|
|
636
663
|
}
|
|
637
|
-
/** Normalize a line for echo comparison: lowercase, no trailing punctuation. */
|
|
638
|
-
function identityOf(text) {
|
|
639
|
-
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
640
|
-
}
|
|
641
|
-
/** Drop the prompt's own labels and task line when the model echoes them. */
|
|
642
|
-
function isInstructionEcho(identity, cueIdentity) {
|
|
643
|
-
if (identity === "") return true;
|
|
644
|
-
if (cueIdentity !== "" && (identity === cueIdentity || identity.startsWith(`${cueIdentity} `))) return true;
|
|
645
|
-
return PROMPT_LABELS.some((label) => identity === label || identity.startsWith(`${label} `));
|
|
646
|
-
}
|
|
647
664
|
function boundSuggestion(line) {
|
|
648
665
|
if (line.length <= 240) return line;
|
|
649
666
|
const cut = line.slice(0, 240);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-codex-ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "DSH Codex UI — 为 DeepSeek Harness 提供极速历史召回、全屏设置皮肤、原生物理毛玻璃换肤、模块化侧栏与桌面原生窗口菜单 · Input enhancement, settings skin, native glass theme, modular sidebar, and desktop titlebar menu for DSH",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|