@herbertgao/pi-extensions 2026.10.9 → 2026.10.11
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/README.md +13 -9
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/README.md +16 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/board.ts +560 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/logo.ts +3 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/metrics.ts +317 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/register.tsx +472 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/band/types.d.ts +35 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-band.json +6 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-band-import.js +274 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +43 -5
- package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +1 -2
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +0 -1
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +10 -5
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +14 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/token-rate.ts +21 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts +23 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +126 -42
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -128
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +24 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +69 -16
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/sol-pi/README.md +7 -1
- package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +28 -4
- package/node_modules/@herbertgao/sol-pi/docs/configuration.md +17 -4
- package/node_modules/@herbertgao/sol-pi/package.json +1 -1
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/index.ts +35 -25
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/then-run.ts +95 -26
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/candidate.ts +39 -2
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/index.ts +24 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/observation-pack/index.ts +12 -7
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/extension.ts +138 -130
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/projection.ts +88 -14
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/tools.ts +9 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/index.ts +14 -5
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/shell-options.ts +22 -0
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/tui.ts +11 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/answer-channel.ts +109 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +117 -71
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +2 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/startup-performance.md +83 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +74 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/events.ts +84 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/index.ts +10 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/reconcile.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +5 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +19 -19
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/i18n-bridge.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +10 -10
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/row-intent.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/contract.ts +6 -6
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/focus.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +9 -9
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +5 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/external-answer.ts +125 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/validate-questionnaire.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/component-binding.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/option-list-view.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/markdown-content-cache.ts +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +5 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-layout-decider.ts +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +10 -10
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/submit-picker.ts +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/tab-bar.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/wrapping-select.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +9 -9
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/props-adapter.ts +8 -8
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-components.ts +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +10 -10
- package/node_modules/@narumitw/pi-btw/dist/index.ts +3 -0
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +6 -0
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +1 -1
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +1 -0
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +1 -0
- package/node_modules/pi-antigravity/README.md +6 -2
- package/node_modules/pi-antigravity/package.json +2 -2
- package/node_modules/pi-antigravity/src/client/client.ts +44 -52
- package/node_modules/pi-antigravity/src/index.ts +13 -0
- package/node_modules/pi-antigravity/src/models/discovery.ts +25 -2
- package/node_modules/pi-antigravity/src/models/grouping.ts +107 -68
- package/node_modules/pi-antigravity/src/models/models.ts +10 -0
- package/node_modules/pi-antigravity/src/search/search.ts +581 -43
- package/node_modules/pi-antigravity/src/stream/stream.ts +53 -13
- package/node_modules/pi-antigravity/src/types/types.ts +13 -0
- package/node_modules/pi-antigravity/src/usage/usage.ts +11 -3
- package/node_modules/pi-web-access/CHANGELOG.md +21 -0
- package/node_modules/pi-web-access/README.md +22 -7
- package/node_modules/pi-web-access/credential-source.ts +54 -4
- package/node_modules/pi-web-access/curator-page.ts +3 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/deepseek.ts +204 -0
- package/node_modules/pi-web-access/dist/index.js +927 -642
- package/node_modules/pi-web-access/dist/mcp-cli.js +877 -615
- package/node_modules/pi-web-access/gemini-adc.ts +48 -1
- package/node_modules/pi-web-access/gemini-search.ts +8 -4
- package/node_modules/pi-web-access/index.ts +16 -1
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/page-query.ts +12 -6
- package/node_modules/pi-web-access/query-rewrite.ts +16 -13
- package/node_modules/pi-web-access/summary-review.ts +16 -6
- package/node_modules/pi-web-access/utils.ts +3 -0
- package/node_modules/pi-web-access/web-tool-core.ts +2 -0
- package/package.json +10 -10
package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts
CHANGED
|
@@ -49,9 +49,9 @@ export default function (pi: ExtensionAPI): void {
|
|
|
49
49
|
return totalTokens();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function updateProviderUsage(message: StreamMessage): void {
|
|
52
|
+
function updateProviderUsage(message: StreamMessage, final = false): void {
|
|
53
53
|
const output = outputUsage(message);
|
|
54
|
-
if (output > 0) recordProviderUsage(output);
|
|
54
|
+
if (output > 0) recordProviderUsage(output, Date.now(), final);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function buildWorkingMessage(): string {
|
|
@@ -171,13 +171,20 @@ export default function (pi: ExtensionAPI): void {
|
|
|
171
171
|
// 分段锚点只在 turn_start 重置。这里再重置会把累计 usage.output 当成新的首报。
|
|
172
172
|
markFirstToken();
|
|
173
173
|
updateProviderUsage(evt.partial);
|
|
174
|
-
} else if (
|
|
174
|
+
} else if (
|
|
175
|
+
evt.type === "thinking_delta" ||
|
|
176
|
+
evt.type === "text_delta" ||
|
|
177
|
+
evt.type === "toolcall_delta"
|
|
178
|
+
) {
|
|
179
|
+
// 工具参数走 toolcall_delta;不计入的话,写长文件这类调用期间 token 一直不涨。
|
|
175
180
|
if (typeof evt.delta === "string") sampleTokenDelta(evt.delta);
|
|
176
181
|
updateProviderUsage(evt.partial);
|
|
177
182
|
} else if (evt.type === "text_end" || evt.type === "thinking_end") {
|
|
178
183
|
updateProviderUsage(evt.partial);
|
|
179
184
|
} else if (evt.type === "done") {
|
|
180
|
-
|
|
185
|
+
// Pi 目前不会把 done/error 转成 message_update,定格在下面的 message_end 里做。
|
|
186
|
+
// 这两个分支只在宿主直接转发 done/error 时生效;同一个值重复定格不改变结果。
|
|
187
|
+
updateProviderUsage(evt.message, true);
|
|
181
188
|
} else if (evt.type === "error") {
|
|
182
189
|
updateProviderUsage(evt.error);
|
|
183
190
|
} else {
|
|
@@ -188,6 +195,18 @@ export default function (pi: ExtensionAPI): void {
|
|
|
188
195
|
scheduleRefreshTick();
|
|
189
196
|
});
|
|
190
197
|
|
|
198
|
+
// message_delta 的累计 usage 只出现在 message_end 上,含未逐字流出的思考 token。
|
|
199
|
+
// message_end 在工具执行和 turn_end 之前,先于 carryTokenRate 结转。
|
|
200
|
+
pi.on("message_end", async (event, ctx) => {
|
|
201
|
+
const message = event?.message;
|
|
202
|
+
if (message?.role !== "assistant") return;
|
|
203
|
+
activeCtx = ctx;
|
|
204
|
+
// 出错/中断时 usage 可能还是 message_start 的占位值,只接受变大的值。
|
|
205
|
+
const failed = message.stopReason === "error" || message.stopReason === "aborted";
|
|
206
|
+
updateProviderUsage(message, !failed);
|
|
207
|
+
syncWorkingMessage();
|
|
208
|
+
});
|
|
209
|
+
|
|
191
210
|
pi.on("tool_execution_start", async () => {
|
|
192
211
|
pauseTokenRate();
|
|
193
212
|
});
|
|
@@ -60,7 +60,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
60
60
|
getThinkingAnimationFrame: () => compactThinking?.getThinkingAnimationFrame?.() ?? 0,
|
|
61
61
|
setCompactSummaryActive: (active) => compactThinking?.setCompactSummaryActive?.(active),
|
|
62
62
|
};
|
|
63
|
-
markdownEnhance(pi);
|
|
63
|
+
if (config.enableMarkdownEnhance) markdownEnhance(pi);
|
|
64
64
|
claudeCodeStyle(pi, undefined, compactThinkingQuery);
|
|
65
65
|
compactThinking = installCompactThinking(pi, getCompactThinkingConfig());
|
|
66
66
|
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* 与 `editDiffCollapsedLines` / `writeDiffCollapsedLines` / `expandedPreviewMaxLines`。
|
|
8
8
|
* Agent/Task 族:调用只进摘要计数,tool 卡始终折叠(避免 pending→完成高度闪动)。
|
|
9
9
|
* edit/write 与 ask_user_question 留在外层:不进摘要计数,折叠态也单独成行。
|
|
10
|
+
* 外层行一旦在消息里出现,当前回合就地完结(不计静默期),后续消息另起回合:
|
|
11
|
+
* 摘要行因此只折叠连续的一段工具调用,展开/收起不再跨外层行搬位置。
|
|
10
12
|
* 用户消息是回合的硬边界:steer 消息插进回合中间、或上一回合没正文就收尾时,回合
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* 就地收口、后续消息另起一回合。custom 通知/summary 类组件既不是成员也不算外来行,
|
|
14
|
+
* 原地留在两段之间,不打断统计也不被挪位。
|
|
13
15
|
* 底部 Agents/Tasks 面板由 pi-subagents/pi-tasks 独立 widget 负责,不经 tool 卡外置。
|
|
14
16
|
*
|
|
15
17
|
* live 围观态(回合进行中 / 收尾静默期):正文跟折叠态同形;摘要行与单一槽位卡
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
*/
|
|
31
33
|
import {
|
|
32
34
|
AssistantMessageComponent,
|
|
35
|
+
CustomMessageComponent,
|
|
33
36
|
SkillInvocationMessageComponent,
|
|
34
37
|
ToolExecutionComponent,
|
|
35
38
|
UserMessageComponent,
|
|
@@ -385,6 +388,9 @@ function layoutExpandedToolCard(
|
|
|
385
388
|
): { lines: string[]; hits: Array<{ child: any; start: number; end: number }> } {
|
|
386
389
|
const slot = aggregateToolCardBgSlot(children.map((child) => child?.__ccTool).filter(Boolean));
|
|
387
390
|
const toolBgAnsi = darkenBgAnsi(theme, slot);
|
|
391
|
+
// 展开面板外卡底色随组内工具状态聚合(与 default 模式分组卡同口径):
|
|
392
|
+
// 有一个失败用失败底色、没有失败但有进行中用进行中底色、全成功用成功底色。
|
|
393
|
+
const outerSlot = slot;
|
|
388
394
|
/** live 每行前面的标记宽度(首行 `↳ `,其余对齐空格)。 */
|
|
389
395
|
const markerWidth = live ? 2 : 0;
|
|
390
396
|
const innerWidth = Math.max(0, width - 2 - markerWidth);
|
|
@@ -399,7 +405,7 @@ function layoutExpandedToolCard(
|
|
|
399
405
|
// 面板 pad 1 是唯一左边距:剥掉子行 collapsed 态自带的 1 格 lead,
|
|
400
406
|
// 否则标题行偏到 2、↳ 行偏到 4,左右不再对称。
|
|
401
407
|
const line = raw.replace(/^((?:\x1b\[[0-?]*[ -/]*[@-~])*) /, "$1");
|
|
402
|
-
lines.push(paddedBackgroundRow(theme,
|
|
408
|
+
lines.push(paddedBackgroundRow(theme, outerSlot, line, width));
|
|
403
409
|
return;
|
|
404
410
|
}
|
|
405
411
|
// 槽位里不重复展开入口(见 SLOT_HINT_PATTERNS)。
|
|
@@ -420,14 +426,13 @@ function layoutExpandedToolCard(
|
|
|
420
426
|
};
|
|
421
427
|
const pushBlank = () => {
|
|
422
428
|
if (live || lastBlank) return;
|
|
423
|
-
lines.push(paddedBackgroundRow(theme,
|
|
429
|
+
lines.push(paddedBackgroundRow(theme, outerSlot, "", width));
|
|
424
430
|
lastBlank = true;
|
|
425
431
|
};
|
|
426
432
|
for (let childIndex = 0; childIndex < children.length; childIndex++) {
|
|
427
433
|
const child = children[childIndex];
|
|
428
434
|
const painted = paints?.[childIndex];
|
|
429
435
|
const childLines = Array.isArray(painted) ? painted : child.render(innerWidth);
|
|
430
|
-
// live 不留空行、也不叠深色内卡:槽位没有边框。
|
|
431
436
|
const innerCard = !live && isThinkingPreview(child) && child.expanded === true;
|
|
432
437
|
let first = -1;
|
|
433
438
|
let last = -1;
|
|
@@ -440,7 +445,7 @@ function layoutExpandedToolCard(
|
|
|
440
445
|
if (first < 0) {
|
|
441
446
|
if (live) continue;
|
|
442
447
|
for (const line of childLines) {
|
|
443
|
-
lines.push(paddedBackgroundRow(theme,
|
|
448
|
+
lines.push(paddedBackgroundRow(theme, outerSlot, line, width));
|
|
444
449
|
lastBlank = !hasVisibleText(line);
|
|
445
450
|
}
|
|
446
451
|
continue;
|
|
@@ -502,6 +507,7 @@ function compactRoundCard(
|
|
|
502
507
|
| undefined;
|
|
503
508
|
const layout = (width: number) => {
|
|
504
509
|
const theme = themeOf();
|
|
510
|
+
// 与 default 模式分组卡同口径:外卡底色随组内工具聚合,子卡状态变了要重绘。
|
|
505
511
|
const bgSlot = aggregateToolCardBgSlot(
|
|
506
512
|
children.map((child) => child?.__ccTool).filter(Boolean),
|
|
507
513
|
);
|
|
@@ -1320,6 +1326,16 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1320
1326
|
}, FOLD_SETTLE_MS);
|
|
1321
1327
|
};
|
|
1322
1328
|
|
|
1329
|
+
/**
|
|
1330
|
+
* 外层行(edit/write/ask)切出的段落封口:跳过静默期直接定稿。
|
|
1331
|
+
* 静默期是为"正文 token 先于 toolCall 到达"的双重转场准备的;外层边界
|
|
1332
|
+
* 出现时摘要段内容已完整,立即收拢让 Ran for 当场落位,槽位卡一并撤走。
|
|
1333
|
+
*/
|
|
1334
|
+
const sealRound = (round: CompactRound, endTimestamp?: number): void => {
|
|
1335
|
+
finalizeRound(round, endTimestamp);
|
|
1336
|
+
renderRound(round);
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1323
1339
|
/** 新回合接替时立即收掉还在静默期的回合,把两次转场并成一次。 */
|
|
1324
1340
|
const flushSettle = (): void => {
|
|
1325
1341
|
for (const round of [...pendingFoldRounds]) {
|
|
@@ -1460,6 +1476,13 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1460
1476
|
const isUserMessageComponent = (value: any): boolean =>
|
|
1461
1477
|
value instanceof UserMessageComponent || value instanceof SkillInvocationMessageComponent;
|
|
1462
1478
|
|
|
1479
|
+
/**
|
|
1480
|
+
* 回合内的透明行:custom 通知(系统提示、extension 注入)既不是成员也不算外来行。
|
|
1481
|
+
* 它落在两个成员之间时原地保留——不打断统计、不被搬到摘要行下方。
|
|
1482
|
+
* 硬边界仍只有用户消息;summary/compaction 块由各自的 message 边界收口。
|
|
1483
|
+
*/
|
|
1484
|
+
const isTransparentComponent = (value: any): boolean => value instanceof CustomMessageComponent;
|
|
1485
|
+
|
|
1463
1486
|
/**
|
|
1464
1487
|
* 新组件与回合已有成员之间是否隔着一条用户消息。隔着就说明这是下一回合的内容:
|
|
1465
1488
|
* steer 消息插进了回合中间,或上一回合没有正文就收尾、用户又问了新问题。
|
|
@@ -1599,7 +1622,14 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1599
1622
|
const intruders: any[] = [];
|
|
1600
1623
|
for (let i = last - 1; i > first; i--) {
|
|
1601
1624
|
// 用户消息永远留在原地:挪走会把别人的消息挪到用户消息下面去。
|
|
1602
|
-
|
|
1625
|
+
// custom 通知同理:它是回合内的透明行,不被统计也不挪位。
|
|
1626
|
+
if (
|
|
1627
|
+
isMember(children[i]) ||
|
|
1628
|
+
isUserMessageComponent(children[i]) ||
|
|
1629
|
+
isTransparentComponent(children[i])
|
|
1630
|
+
) {
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1603
1633
|
intruders.unshift(children.splice(i, 1)[0]);
|
|
1604
1634
|
}
|
|
1605
1635
|
if (lastMember) last = children.indexOf(lastMember);
|
|
@@ -1759,22 +1789,24 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1759
1789
|
|
|
1760
1790
|
const thinkingKids: any[] = [];
|
|
1761
1791
|
for (const [component, message] of round.messages) {
|
|
1762
|
-
if (component
|
|
1792
|
+
if (component === previewComponent) {
|
|
1793
|
+
passThroughAssistant(component, message);
|
|
1794
|
+
const kids = Array.isArray(component.contentContainer?.children)
|
|
1795
|
+
? [...component.contentContainer.children]
|
|
1796
|
+
: [];
|
|
1763
1797
|
component.contentContainer?.clear?.();
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
? [...component.contentContainer.children]
|
|
1769
|
-
: [];
|
|
1770
|
-
component.contentContainer?.clear?.();
|
|
1771
|
-
// 只摘思考预览块进槽位;已收尾的思考回收进摘要行。
|
|
1772
|
-
for (const kid of kids) {
|
|
1773
|
-
if (typeof kid?.setHintHovered === "function") thinkingKids.push(kid);
|
|
1798
|
+
// 只摘思考预览块进槽位;已收尾的思考回收进摘要行。
|
|
1799
|
+
for (const kid of kids) {
|
|
1800
|
+
if (typeof kid?.setHintHovered === "function") thinkingKids.push(kid);
|
|
1801
|
+
}
|
|
1774
1802
|
}
|
|
1803
|
+
// text 在各消息自己的位置渲染,不随回合折叠态;非 anchor 成员的
|
|
1804
|
+
// 中止/错误状态仍汇总在 anchor 外层,不在成员处重复成行。
|
|
1805
|
+
renderAssistantWithoutThinking(
|
|
1806
|
+
component,
|
|
1807
|
+
component === round.anchor ? message : { ...message, stopReason: "stop" },
|
|
1808
|
+
);
|
|
1775
1809
|
}
|
|
1776
|
-
// 正文照折叠态渲染(不含 thinking):live 与收尾后同形,收尾只剩槽位卡消失。
|
|
1777
|
-
renderAssistantWithoutThinking(round.anchor, round.messages.get(round.anchor));
|
|
1778
1810
|
|
|
1779
1811
|
const toolsById = new Map<string, any>();
|
|
1780
1812
|
for (const tool of trackedToolComponents) {
|
|
@@ -1900,10 +1932,14 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1900
1932
|
// 否则消息内容里的 thinking([thinking, text, toolCall])会盖到文本上面。
|
|
1901
1933
|
const anchorChildren: any[] = [];
|
|
1902
1934
|
let cardItems: Array<{ child?: any; tool?: any }> = [];
|
|
1903
|
-
|
|
1935
|
+
// 纯 spacer 串拆不开面板,还给它所在消息的组件(通常是上一个
|
|
1936
|
+
// text 块的前导空行)。
|
|
1937
|
+
const flushPanel = (spacerOwner: any = round.anchor) => {
|
|
1904
1938
|
if (cardItems.length === 0) return;
|
|
1905
1939
|
if (cardItems.every((item) => !item.tool && isSpacerComponent(item.child))) {
|
|
1906
|
-
for (const item of cardItems)
|
|
1940
|
+
for (const item of cardItems) {
|
|
1941
|
+
spacerOwner?.contentContainer?.addChild?.(item.child);
|
|
1942
|
+
}
|
|
1907
1943
|
} else {
|
|
1908
1944
|
// 面板上沿留 1 行卡外空行:面板底色与 userMessage 同色,
|
|
1909
1945
|
// 贴在一起会看成一个块;卡内顶部再加 1 行 padding 保持上下对称。
|
|
@@ -1920,13 +1956,15 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1920
1956
|
}
|
|
1921
1957
|
cardItems = [];
|
|
1922
1958
|
};
|
|
1923
|
-
|
|
1959
|
+
// outside 的块(text 及其前导空行)留在各自组件上原位渲染:展开态下
|
|
1960
|
+
// 助手文本不跨消息搬家;它不切断面板——cardItems 跨消息延续,回合的
|
|
1961
|
+
// thinking/工具统一汇成末尾的一张共享面板,混排 text 不再把卡撕成几段。
|
|
1962
|
+
const takeChild = (component: any, child: any, outside: boolean) => {
|
|
1924
1963
|
if (!outside) {
|
|
1925
1964
|
cardItems.push({ child });
|
|
1926
1965
|
return;
|
|
1927
1966
|
}
|
|
1928
|
-
|
|
1929
|
-
anchorChildren.push(child);
|
|
1967
|
+
component.contentContainer?.addChild?.(child);
|
|
1930
1968
|
};
|
|
1931
1969
|
const placedToolIds = new Set<string>();
|
|
1932
1970
|
const placeTool = (id: string, fallbackName?: string) => {
|
|
@@ -1972,11 +2010,11 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
1972
2010
|
}
|
|
1973
2011
|
}
|
|
1974
2012
|
while (cursor.i < kids.length) local.push({ outside: false, child: kids[cursor.i++] });
|
|
1975
|
-
for (const entry of local) if (entry.outside) takeChild(entry.child, true);
|
|
2013
|
+
for (const entry of local) if (entry.outside) takeChild(component, entry.child, true);
|
|
1976
2014
|
for (const entry of local) {
|
|
1977
2015
|
if (entry.outside) continue;
|
|
1978
2016
|
if (entry.toolId) placeTool(entry.toolId, entry.toolName);
|
|
1979
|
-
else takeChild(entry.child, false);
|
|
2017
|
+
else takeChild(component, entry.child, false);
|
|
1980
2018
|
}
|
|
1981
2019
|
}
|
|
1982
2020
|
for (const message of round.detachedMessages) {
|
|
@@ -2001,15 +2039,10 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2001
2039
|
!explicitRoundToolIds.has(String(tool.toolCallId ?? "")),
|
|
2002
2040
|
);
|
|
2003
2041
|
flushPanel();
|
|
2042
|
+
// anchorChildren 只剩面板件(spacer+panelBoundSpacer 都是 childAtRow 组件):
|
|
2043
|
+
// 面板挂回摘要行原位,text 已在各自组件上。
|
|
2004
2044
|
if (mounted) {
|
|
2005
|
-
|
|
2006
|
-
const outside: any[] = [];
|
|
2007
|
-
const panel: any[] = [];
|
|
2008
|
-
for (const child of anchorChildren) {
|
|
2009
|
-
(typeof child?.childAtRow === "function" ? panel : outside).push(child);
|
|
2010
|
-
}
|
|
2011
|
-
for (const child of outside) round.anchor.contentContainer.addChild(child);
|
|
2012
|
-
if (panel.length > 0) mountRoundTail(round, () => panel);
|
|
2045
|
+
if (anchorChildren.length > 0) mountRoundTail(round, () => anchorChildren);
|
|
2013
2046
|
else unmountRoundTail(round);
|
|
2014
2047
|
} else {
|
|
2015
2048
|
unmountRoundTail(round);
|
|
@@ -2041,7 +2074,8 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2041
2074
|
// 折叠时工具行被隐藏:abort/error/length 必须挂在摘要外层。
|
|
2042
2075
|
appendStopStatus(component, stopStatus);
|
|
2043
2076
|
} else {
|
|
2044
|
-
|
|
2077
|
+
// 成员的 text 同样留在自己组件上;中止状态只在 anchor 外层报一次。
|
|
2078
|
+
renderAssistantWithoutThinking(component, { ...message, stopReason: "stop" });
|
|
2045
2079
|
}
|
|
2046
2080
|
}
|
|
2047
2081
|
};
|
|
@@ -2143,6 +2177,15 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2143
2177
|
|
|
2144
2178
|
const content = Array.isArray(message?.content) ? message.content : [];
|
|
2145
2179
|
const hasToolCalls = content.some((item: any) => item?.type === "toolCall");
|
|
2180
|
+
const hasOuterToolCall = content.some(
|
|
2181
|
+
(item: any) => item?.type === "toolCall" && OUTER_TOOLS.has(String(item?.name ?? "")),
|
|
2182
|
+
);
|
|
2183
|
+
const hasInnerToolCall = content.some(
|
|
2184
|
+
(item: any) => item?.type === "toolCall" && !OUTER_TOOLS.has(String(item?.name ?? "")),
|
|
2185
|
+
);
|
|
2186
|
+
const hasThinkingContent = content.some(
|
|
2187
|
+
(item: any) => item?.type === "thinking" && String(item?.thinking ?? "").trim(),
|
|
2188
|
+
);
|
|
2146
2189
|
const hasText = content.some(
|
|
2147
2190
|
(item: any) => item?.type === "text" && typeof item.text === "string" && item.text.trim(),
|
|
2148
2191
|
);
|
|
@@ -2150,13 +2193,54 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2150
2193
|
|
|
2151
2194
|
if (hasToolCalls) {
|
|
2152
2195
|
let round = roundByComponent.get(this);
|
|
2196
|
+
const previousMessage = round?.messages.get(this);
|
|
2197
|
+
const previousHadOuter = Array.isArray(previousMessage?.content)
|
|
2198
|
+
? previousMessage.content.some(
|
|
2199
|
+
(item: any) => item?.type === "toolCall" && OUTER_TOOLS.has(String(item?.name ?? "")),
|
|
2200
|
+
)
|
|
2201
|
+
: false;
|
|
2153
2202
|
if (!round) {
|
|
2154
|
-
//
|
|
2155
|
-
//
|
|
2156
|
-
//
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2203
|
+
// 外层行打断摘要段:本条消息带外层调用且可并入的活动回合已有内容时,
|
|
2204
|
+
// 旧回合就地完结(不走静默期)。本条消息自己含 inner 调用或思考才另起一段;
|
|
2205
|
+
// 外层独段(edit-only 消息)不建回合——没有可汇总内容,建段只会挂空摘要行。
|
|
2206
|
+
const joinable = joinableActiveRound(this);
|
|
2207
|
+
if (joinable && hasOuterToolCall) {
|
|
2208
|
+
sealRound(joinable, message?.timestamp);
|
|
2209
|
+
if (hasInnerToolCall || hasThinkingContent) {
|
|
2210
|
+
round = createRound(this, message);
|
|
2211
|
+
roundByComponent.set(this, round);
|
|
2212
|
+
round.messages.set(this, message);
|
|
2213
|
+
if (isUsableTimestamp(message.timestamp) && message.timestamp < round.startedAt) {
|
|
2214
|
+
round.startedAt = message.timestamp;
|
|
2215
|
+
}
|
|
2216
|
+
renderRound(round);
|
|
2217
|
+
return undefined;
|
|
2218
|
+
}
|
|
2219
|
+
// 外层独段:text/thinking 照原生渲染,edit 行由 tool render 外置,没有摘要行。
|
|
2220
|
+
return passThroughAssistant(this, message);
|
|
2221
|
+
}
|
|
2222
|
+
if (hasInnerToolCall || hasThinkingContent) {
|
|
2223
|
+
// 本条消息是否带 text 不是回合边界:pi 流式协议里同一条
|
|
2224
|
+
// assistant 消息会以 text+toolCall、toolCall-only 反复到达。
|
|
2225
|
+
// 只在「组件未挂进任何回合」时并入 activeRound;被用户消息
|
|
2226
|
+
// 隔开(steer/上回合没正文)时由 joinOrCreateRound 收尾另起。
|
|
2227
|
+
round = joinOrCreateRound(this, message);
|
|
2228
|
+
roundByComponent.set(this, round);
|
|
2229
|
+
round.messages.set(this, message);
|
|
2230
|
+
if (isUsableTimestamp(message.timestamp) && message.timestamp < round.startedAt) {
|
|
2231
|
+
round.startedAt = message.timestamp;
|
|
2232
|
+
}
|
|
2233
|
+
renderRound(round);
|
|
2234
|
+
return undefined;
|
|
2235
|
+
}
|
|
2236
|
+
// 外层独段、又没有可并入的活动回合:不建回合,text/工具各归其位。
|
|
2237
|
+
if (activeRound) finishRound(activeRound, message?.timestamp);
|
|
2238
|
+
return passThroughAssistant(this, message);
|
|
2239
|
+
}
|
|
2240
|
+
if (hasOuterToolCall && !previousHadOuter && roundLive(round)) {
|
|
2241
|
+
// 消息入段后流式增长才冒出外层调用(先 thinking 后 toolCall):
|
|
2242
|
+
// 就地封口所在段,本条消息按消息级归属留在原段,后续消息另起一段。
|
|
2243
|
+
sealRound(round, message?.timestamp);
|
|
2160
2244
|
}
|
|
2161
2245
|
round.messages.set(this, message);
|
|
2162
2246
|
if (isUsableTimestamp(message.timestamp) && message.timestamp < round.startedAt) {
|
|
@@ -41,99 +41,6 @@ function collectFence(lines: string[], i: number): { diagram: string; next: numb
|
|
|
41
41
|
return null; // 未闭合:放弃转换,保持原文
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// ============================================================================
|
|
45
|
-
// GitHub 风格提示框(admonition)
|
|
46
|
-
// ============================================================================
|
|
47
|
-
|
|
48
|
-
const ADMONITION = /^>\s*\[\s*!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\s*\]\s*(.*)$/i;
|
|
49
|
-
const ADMONITION_STYLE: Record<string, { icon: string; label: string }> = {
|
|
50
|
-
NOTE: { icon: "💡", label: "NOTE" },
|
|
51
|
-
TIP: { icon: "✅", label: "TIP" },
|
|
52
|
-
IMPORTANT: { icon: "❗", label: "IMPORTANT" },
|
|
53
|
-
WARNING: { icon: "⚠️", label: "WARNING" },
|
|
54
|
-
CAUTION: { icon: "⚠️", label: "CAUTION" },
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 把 > [!TYPE] 及其后续 > 行转成带加粗标签的引用块,视觉上成提示框。
|
|
59
|
-
* 多行内容用空格合并为一行。返回 null 表示该行不是提示框。
|
|
60
|
-
*/
|
|
61
|
-
function renderAdmonition(lines: string[], i: number): { output: string[]; next: number } | null {
|
|
62
|
-
const m = lines[i].match(ADMONITION);
|
|
63
|
-
if (!m) return null;
|
|
64
|
-
const style = ADMONITION_STYLE[m[1].toUpperCase()];
|
|
65
|
-
const body: string[] = [m[2]];
|
|
66
|
-
let j = i + 1;
|
|
67
|
-
while (j < lines.length && /^>\s?/.test(lines[j]) && !ADMONITION.test(lines[j])) {
|
|
68
|
-
body.push(lines[j].replace(/^>\s?/, ""));
|
|
69
|
-
j++;
|
|
70
|
-
}
|
|
71
|
-
while (body.length > 0 && body[body.length - 1].trim() === "") body.pop();
|
|
72
|
-
// 内容合并为一行,作为引用块正文
|
|
73
|
-
const content = body.join(" ").trim();
|
|
74
|
-
// 保留引用块形态(pi 渲染为左侧竖线),标签加粗
|
|
75
|
-
return {
|
|
76
|
-
output: [`> **${style.icon} ${style.label}**${content ? ` ${content}` : ""}`, ""],
|
|
77
|
-
next: j,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ============================================================================
|
|
82
|
-
// 裸 URL 转可点击超链接
|
|
83
|
-
// ============================================================================
|
|
84
|
-
|
|
85
|
-
const URL_RE = /(?<!<)(?<!\]\()https?:\/\/[^\s<>'"|,。;:!?、」』】()【】《》『』「」]+/g;
|
|
86
|
-
const TRIM_URL_RE = /[.,;:!?】」』"'》)}]+$/;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 去掉 URL 尾部标点;括号按平衡保留(如 Wikipedia 链接含括号、
|
|
90
|
-
* IPv6 地址含 [::1]),尾部不成对的 ] 与 ) 会截掉。
|
|
91
|
-
*/
|
|
92
|
-
function trimUrl(url: string): string {
|
|
93
|
-
let t = url.replace(TRIM_URL_RE, "");
|
|
94
|
-
for (;;) {
|
|
95
|
-
if (t.endsWith(")") && (t.match(/\(/g)?.length ?? 0) < (t.match(/\)/g)?.length ?? 0)) {
|
|
96
|
-
t = t.slice(0, -1);
|
|
97
|
-
} else if (t.endsWith("]") && (t.match(/\[/g)?.length ?? 0) < (t.match(/\]/g)?.length ?? 0)) {
|
|
98
|
-
t = t.slice(0, -1);
|
|
99
|
-
} else {
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return t;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 把代码块和行内代码外的裸 URL 转成 markdown 链接。
|
|
108
|
-
* 已有的 [text](url) /  / <url> 自动链接用 lookbehind 排除。
|
|
109
|
-
*/
|
|
110
|
-
function linkifyUrls(markdown: string): string {
|
|
111
|
-
const lines = markdown.split("\n");
|
|
112
|
-
const out: string[] = [];
|
|
113
|
-
let fence: MarkdownFence | undefined;
|
|
114
|
-
for (const line of lines) {
|
|
115
|
-
const scanned = scanMarkdownFence(line, fence);
|
|
116
|
-
fence = scanned.fence;
|
|
117
|
-
if (scanned.protected) {
|
|
118
|
-
out.push(line);
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
// 行内代码(`...`)按反引号分片,只处理偶数片(代码外)
|
|
122
|
-
const parts = line.split("`");
|
|
123
|
-
for (let p = 0; p < parts.length; p++) {
|
|
124
|
-
if (p % 2 === 0) {
|
|
125
|
-
parts[p] = parts[p].replace(URL_RE, (url) => {
|
|
126
|
-
const trimmed = trimUrl(url);
|
|
127
|
-
if (trimmed.length === 0) return url;
|
|
128
|
-
return `[${trimmed}](${trimmed})`;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
out.push(parts.join("`"));
|
|
133
|
-
}
|
|
134
|
-
return out.join("\n");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
44
|
// ============================================================================
|
|
138
45
|
// 圈数字 → 半角括号
|
|
139
46
|
// ============================================================================
|
|
@@ -231,7 +138,9 @@ function normalizeMultilineLinks(markdown: string): string {
|
|
|
231
138
|
|
|
232
139
|
export default function (pi: ExtensionAPI): void {
|
|
233
140
|
// 注意:pi 每个扩展只有一个 markdownTransformer 槽位,多次注册会互相覆盖,
|
|
234
|
-
//
|
|
141
|
+
// 所以剩下的转换合并为一次注册,内部按序链式执行。
|
|
142
|
+
// 提示框和裸 URL 不接管:pi 的 marked 已自带裸 URL 链接化(带尾标点回退,
|
|
143
|
+
// 且在链接文本内不再嵌套),提示框交给默认引用块风格。
|
|
235
144
|
pi.registerMarkdownTransformer((markdown, context) => {
|
|
236
145
|
const { messageType, isStreaming = false } = context ?? {};
|
|
237
146
|
// thinking 保持原文;普通回复即使流式中也先关闭跨行链接的空白点击区。
|
|
@@ -241,11 +150,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
241
150
|
// 0. 圈数字转半角括号(Nerd Font 补丁字形缺陷规避)
|
|
242
151
|
markdown = deCircled(markdown);
|
|
243
152
|
// 1. Mermaid 方言渲染
|
|
244
|
-
|
|
245
|
-
// 2. GitHub 风格提示框
|
|
246
|
-
markdown = renderAdmonitions(markdown);
|
|
247
|
-
// 3. 裸 URL 转超链接
|
|
248
|
-
return linkifyUrls(markdown);
|
|
153
|
+
return renderDiagrams(markdown, context);
|
|
249
154
|
});
|
|
250
155
|
}
|
|
251
156
|
|
|
@@ -307,32 +212,3 @@ function renderDiagrams(
|
|
|
307
212
|
}
|
|
308
213
|
return out.join("\n");
|
|
309
214
|
}
|
|
310
|
-
|
|
311
|
-
/** GitHub 风格提示框 → 加粗标签引用块(跳过代码块)。 */
|
|
312
|
-
function renderAdmonitions(markdown: string): string {
|
|
313
|
-
const lines = markdown.split("\n");
|
|
314
|
-
const out: string[] = [];
|
|
315
|
-
let fence: MarkdownFence | undefined;
|
|
316
|
-
let i = 0;
|
|
317
|
-
while (i < lines.length) {
|
|
318
|
-
const line = lines[i];
|
|
319
|
-
const scanned = scanMarkdownFence(line, fence);
|
|
320
|
-
fence = scanned.fence;
|
|
321
|
-
if (scanned.protected) {
|
|
322
|
-
out.push(line);
|
|
323
|
-
i++;
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
if (/^>\s*\[\s*!/i.test(line)) {
|
|
327
|
-
const result = renderAdmonition(lines, i);
|
|
328
|
-
if (result) {
|
|
329
|
-
out.push(...result.output);
|
|
330
|
-
i = result.next;
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
out.push(line);
|
|
335
|
-
i++;
|
|
336
|
-
}
|
|
337
|
-
return out.join("\n");
|
|
338
|
-
}
|
|
@@ -50,8 +50,8 @@ import {
|
|
|
50
50
|
hideScrollButton,
|
|
51
51
|
dockScrollButtonActive,
|
|
52
52
|
restoreOfficialScrollToEnd,
|
|
53
|
+
restoreNativeScrollIndicatorText,
|
|
53
54
|
syncOfficialScrollToEnd,
|
|
54
|
-
isScrollBottomInput,
|
|
55
55
|
renderScrollButton,
|
|
56
56
|
resetScrollButtonState,
|
|
57
57
|
scheduleScrollButtonSync,
|
|
@@ -78,6 +78,7 @@ import {
|
|
|
78
78
|
} from "./hover.ts";
|
|
79
79
|
import {
|
|
80
80
|
handleStickyPromptClick,
|
|
81
|
+
stickyBarHit,
|
|
81
82
|
resetStickyPromptState,
|
|
82
83
|
updateStickyPromptHover,
|
|
83
84
|
} from "./sticky-prompt.ts";
|
|
@@ -613,6 +614,18 @@ function packetInsideOverlay(tui: any, packet: SgrMousePacket): boolean {
|
|
|
613
614
|
return false;
|
|
614
615
|
}
|
|
615
616
|
|
|
617
|
+
/** 原生指示器优先于工具卡;覆盖它的粘性行仍保留原有点击优先级。 */
|
|
618
|
+
function packetOnNativeIndicator(tui: any, packet: SgrMousePacket): boolean {
|
|
619
|
+
const rect = tui.scrollToEndIndicatorRect;
|
|
620
|
+
return Boolean(
|
|
621
|
+
rect &&
|
|
622
|
+
packet.row - 1 === rect.row &&
|
|
623
|
+
packet.col - 1 >= rect.column &&
|
|
624
|
+
packet.col - 1 < rect.column + rect.width &&
|
|
625
|
+
!stickyBarHit(tui, packet),
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
|
|
616
629
|
/**
|
|
617
630
|
* 实例级包装 TuiAltScreen.handleViewportInput(惰性 Proxy 安全):
|
|
618
631
|
* 原型方法取 original(绕开 proxy 函数包装),实例 own property 装 wrapper
|
|
@@ -636,6 +649,13 @@ function patchFullscreenViewportInput(tui: any): void {
|
|
|
636
649
|
// dispatchMouseToOverlay → overlay.handleMouse;overlay 外的包仍
|
|
637
650
|
// 走扩展收起/展开/hover。两条路径各管各的。
|
|
638
651
|
if (packets) {
|
|
652
|
+
const nativePacket = packets.find((packet) => packetOnNativeIndicator(tui, packet));
|
|
653
|
+
if (nativePacket) {
|
|
654
|
+
clearPendingCollapsePress();
|
|
655
|
+
applyFullscreenHover(tui, null);
|
|
656
|
+
updateStickyPromptHover(tui, nativePacket);
|
|
657
|
+
return Reflect.apply(original, this, [data]);
|
|
658
|
+
}
|
|
639
659
|
// 布局还没出来或仍是上一帧:不要把点击收成工具展开。返回 undefined
|
|
640
660
|
// 让焦点 overlay 的 handleInput 拿到原始 SGR;官方链也靠这份布局,调它会消费且打到 transcript。
|
|
641
661
|
if (tui.hasOverlay?.() && !overlayLayoutsCurrent(tui)) return undefined;
|
|
@@ -985,13 +1005,9 @@ function handleToolMouseInput(data: string): { consume: true } | undefined {
|
|
|
985
1005
|
if (!getToolMouseTui()) return undefined;
|
|
986
1006
|
// 惰性 Proxy fullscreen:鼠标由 handleViewportInput 包装消费(官方链之前),
|
|
987
1007
|
// 此处只处理键盘(鼠标事件在官方 listener 已被 consume,到不了这里)。
|
|
1008
|
+
// 回底键归 Pi viewport(tui.altScreen.bottom,overlay 聚焦时让给 overlay),不在此重复处理。
|
|
988
1009
|
if (fullscreenLazyTui(getToolMouseTui())) {
|
|
989
1010
|
scheduleScrollButtonSync(getToolMouseTui(), data);
|
|
990
|
-
if (isScrollBottomInput(data)) {
|
|
991
|
-
getToolMouseTui().scrollToBottom?.();
|
|
992
|
-
hideScrollButton(getToolMouseTui());
|
|
993
|
-
return { consume: true };
|
|
994
|
-
}
|
|
995
1011
|
return undefined;
|
|
996
1012
|
}
|
|
997
1013
|
updateScrollButtonFromInput(getToolMouseTui(), data);
|
|
@@ -1080,6 +1096,7 @@ export function resetToolHoverState(): void {
|
|
|
1080
1096
|
setScrollButtonVisible(false);
|
|
1081
1097
|
setScrollButtonHovered(false);
|
|
1082
1098
|
resetStickyPromptState();
|
|
1099
|
+
restoreNativeScrollIndicatorText();
|
|
1083
1100
|
restoreOfficialScrollToEnd(getToolMouseTui());
|
|
1084
1101
|
releaseFullscreenToolMouseMotion(getToolMouseTui());
|
|
1085
1102
|
}
|
|
@@ -1172,6 +1189,7 @@ export function installToolMouseInteraction(
|
|
|
1172
1189
|
return renderScrollButton(width, theme);
|
|
1173
1190
|
},
|
|
1174
1191
|
invalidate() {},
|
|
1192
|
+
dispose: restoreNativeScrollIndicatorText,
|
|
1175
1193
|
});
|
|
1176
1194
|
return getScrollButtonWidget();
|
|
1177
1195
|
}
|