@each1024/pi-mini-mode 2.0.10 → 2.0.12

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 CHANGED
@@ -62,7 +62,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
62
62
 
63
63
  **Images where you write.** Images appear as inline cards above the editor by default; you can switch to cursor popups in settings. Press `Esc` to dismiss a popup.
64
64
 
65
- **Less path clutter. Same image.** Image paths become underlined `[image1]` labels in the editor and messages, preserving the original path when submitted. Open the original image or another linked file in its default app using your terminal’s link gesture.
65
+ **Less path clutter. Same image.** Image paths become underlined `[image1]` labels in the editor and messages, preserving the original path when submitted. Left-click opens the original image or another linked file in its default app. In fullscreen, right-click reveals the file selected in its folder.
66
66
 
67
67
  **Skills where you type.** Enter `/` at the start or after whitespace to find a skill and insert `/skill:name` at the cursor. Inline skills expand on submission; URLs and paths keep their normal behavior.
68
68
 
@@ -102,7 +102,7 @@ This earlier screenshot shows footer configuration, not the newer image, folding
102
102
 
103
103
  ## Compatibility
104
104
 
105
- - **Images:** previews require a terminal image protocol; unsupported terminals show a hint. Large images are resized for the terminal preview only (up to 1200 × 800 pixels and 1 MB encoded); the original file and submitted path are unchanged. Image reads are limited to **20 MB**, and deleted files cannot be reopened. Link gestures depend on the terminal: usually `Cmd+click` on macOS or `Ctrl+click` on Windows/Linux; Ghostty fullscreen may require `Shift+Cmd` / `Shift+Ctrl`. Pi fullscreen also supports direct link clicks. See [Pi terminal setup](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md).
105
+ - **Images:** previews require a terminal image protocol; unsupported terminals show a hint. Large images are resized for the terminal preview only (up to 1200 × 800 pixels and 1 MB encoded); the original file and submitted path are unchanged. Image reads are limited to **20 MB**, and deleted files cannot be reopened. Link gestures depend on the terminal: usually `Cmd+click` on macOS or `Ctrl+click` on Windows/Linux; Ghostty fullscreen may require `Shift+Cmd` / `Shift+Ctrl`. Pi fullscreen also supports a direct left-click. Right-clicking a file link reveals and selects that file on macOS and Windows, and opens its folder elsewhere. Right-clicking empty space keeps selection or paste behavior. See [Pi terminal setup](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md).
106
106
  - **Minimal output:** uses a private Pi 0.85.x layout adapter without patching Pi’s installation. Unknown layouts refuse activation and keep native output. Recheck after Pi upgrades; other transcript-replacing extensions can conflict.
107
107
  - **Subagents:** the pi-subagents widget adapter runs only in minimal mode, restores on disable, and passes unknown formats through. Available details depend on the integration’s status/output data; this is not a complete subagent transcript viewer.
108
108
  - **History:** `/reload` remounts the transcript, including history created in native mode. Empty progress events do not erase existing content; tools without output show elapsed waiting time. Legacy per-item minimal controls no longer filter content.
package/README.zh-CN.md CHANGED
@@ -62,7 +62,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
62
62
 
63
63
  **图片,就在输入框上方。** 图片默认以内联卡片显示,也可在设置中切换为光标浮窗。按 `Esc` 可关闭浮窗。
64
64
 
65
- **收起路径,保留原图。** 输入框和消息中的图片路径收纳为带下划线的 `[image1]` 标签,提交时保留原始路径。使用终端的链接点击手势,即可通过系统默认应用打开原图或其他文件。
65
+ **收起路径,保留原图。** 输入框和消息中的图片路径收纳为带下划线的 `[image1]` 标签,提交时保留原始路径。左键用系统默认应用打开原图或其他文件;全屏模式右键在文件管理器中打开所在位置并选中该文件。
66
66
 
67
67
  **技能,就在输入处。** 在输入起点或空白后键入 `/` 搜索技能,在当前光标处插入 `/skill:name`,提交时展开。URL 和文件路径中的斜杠保持原有行为。
68
68
 
@@ -101,7 +101,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
101
101
 
102
102
  ## 兼容性
103
103
 
104
- - **图片:** 预览依赖终端图片协议,不支持时显示提示。大图仅对终端预览副本缩放(不超过 1200 × 800 像素、编码后 1 MB);原文件和提交路径不变。读取上限 **20 MB**,文件被清理后无法重新打开。点击手势由终端决定:macOS 通常使用 `Cmd+点击`,Windows/Linux 通常使用 `Ctrl+点击`;Ghostty 全屏可能需要 `Shift+Cmd` / `Shift+Ctrl`。Pi 全屏也支持直接点击链接。参见 [Pi 终端设置](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md)。
104
+ - **图片:** 预览依赖终端图片协议,不支持时显示提示。大图仅对终端预览副本缩放(不超过 1200 × 800 像素、编码后 1 MB);原文件和提交路径不变。读取上限 **20 MB**,文件被清理后无法重新打开。点击手势由终端决定:macOS 通常使用 `Cmd+点击`,Windows/Linux 通常使用 `Ctrl+点击`;Ghostty 全屏可能需要 `Shift+Cmd` / `Shift+Ctrl`。Pi 全屏也支持直接左键打开链接;右键文件链接会在文件管理器中定位并选中该文件(macOS、Windows),其他系统打开所在文件夹。空白处右键仍按原来的选择或粘贴行为。参见 [Pi 终端设置](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md)。
105
105
  - **极简输出:** 使用私有 Pi 0.85.x 布局适配器,不修改 Pi 安装目录。未知布局会拒绝启用并保留原生输出;升级 Pi 后需重新检查,其他替换 transcript 的扩展可能冲突。
106
106
  - **子代理:** pi-subagents 小组件适配仅在极简模式启用,关闭后恢复原状,未知格式原样交给原生处理。可用详情取决于集成提供的状态/输出数据,不是完整子代理会话查看器。
107
107
  - **历史:** `/reload` 会重新挂载 transcript,包含原生模式中产生的历史。空进度事件不覆盖已有内容;无输出的工具显示等待时间。旧的极简输出细项不再单独过滤内容。
@@ -1,3 +1,4 @@
1
+ import type { spawn } from "node:child_process";
1
2
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
3
  import type { EditorComponent, OverlayHandle, OverlayOptions, renderImage, TUI } from "@earendil-works/pi-tui";
3
4
  import type { Preview } from "./input-image-paths.ts";
@@ -43,6 +44,7 @@ export interface Enhancements {
43
44
  baseFactory?: EditorFactoryFunction;
44
45
  editor?: EditorComponent;
45
46
  editorFactory?: EditorFactoryFunction;
47
+ reveal?: typeof spawn;
46
48
  unsubscribeInput?: () => void;
47
49
  restoreViewportInput?: () => void;
48
50
  cleanup: InputEnhancementsCleanup;
@@ -1,5 +1,7 @@
1
1
  import { allocateImageId, deleteKittyImage, getCellDimensions, getImageDimensions, getOsc8LinkAtColumn, matchesKey, renderImage, visibleWidth, type TUI } from "@earendil-works/pi-tui";
2
- import { extname } from "node:path";
2
+ import { spawn } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, extname } from "node:path";
3
5
  import { fileURLToPath, pathToFileURL } from "node:url";
4
6
  import type { Enhancements } from "./input-enhancements-types.ts";
5
7
  import { imageLayoutKey, previewLines } from "./input-image-graphics.ts";
@@ -12,14 +14,39 @@ export function setPointer(state: Enhancements, pointer: boolean): void {
12
14
  state.pointer = pointer;
13
15
  }
14
16
 
17
+ /** Show a local file selected in its folder. Windows paste stays available off a file link. */
18
+ export function revealInFolder(path: string, launch: typeof spawn = spawn): boolean {
19
+ if (!existsSync(path)) return false;
20
+ // macOS and Windows can select the file. Other desktops open its folder.
21
+ const [command, args] = process.platform === "darwin" ? ["open", ["-R", path]]
22
+ : process.platform === "win32" ? ["explorer.exe", [`/select,${path}`]]
23
+ : ["xdg-open", [dirname(path)]];
24
+ launch(command, args, { stdio: "ignore", detached: true }).on("error", () => {}).unref();
25
+ return true;
26
+ }
27
+
28
+ function linkedFile(screen: string[] | undefined, x: number, y: number): string | undefined {
29
+ const url = getOsc8LinkAtColumn(screen?.[y] ?? "", x);
30
+ if (!url?.startsWith("file:")) return;
31
+ try {
32
+ const path = fileURLToPath(url);
33
+ return existsSync(path) ? path : undefined;
34
+ } catch { return; }
35
+ }
36
+
15
37
  export function handleTerminalInput(state: Enhancements, data: string): { consume?: boolean } | undefined {
16
38
  if (data === "\x1b[O") { setPointer(state, false); void requestPreview(state, undefined); }
17
39
  const mouse = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
18
40
  if (mouse) {
19
- const x = Number(mouse[2]) - 1, y = Number(mouse[3]) - 1;
41
+ const button = Number(mouse[1]), x = Number(mouse[2]) - 1, y = Number(mouse[3]) - 1;
20
42
  // ponytail: Pi 0.85 has no public screen hit-test API; inspect its last rendered OSC 8 cells.
21
43
  const screen = (state.tui as TUI & { previousScreen?: string[] } | undefined)?.previousScreen;
22
- const moving = !!(Number(mouse[1]) & 32) && mouse[4] === "M";
44
+ const moving = !!(button & 32) && mouse[4] === "M";
45
+ // Fullscreen treats a secondary press as selection. Reveal the linked file first.
46
+ if (!moving && mouse[4] === "M" && (button & 3) === 2 && state.enabled()) {
47
+ const path = linkedFile(screen, x, y);
48
+ if (path && revealInFolder(path, state.reveal)) return { consume: true };
49
+ }
23
50
  if (!moving) { setPointer(state, false); void requestPreview(state, undefined); return undefined; }
24
51
  const cached = state.hoverLink;
25
52
  const sameTarget = cached?.row === y && x >= cached.start && x < cached.end;
@@ -30,7 +30,8 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
30
30
  const expandedSubagents = new Set<string>();
31
31
  const expandedTools = new Set<string>();
32
32
  const expandedThinking = new Set<string>();
33
- const thinkingPreviews = new Map<string, { text: string; source: string; width: number; rows: number; live: boolean }>();
33
+ const thinkingPreviews = new Map<string, { text: string; source: string; width: number; rows: number; live: boolean; shownAt: number }>();
34
+ const THINKING_SCROLL_MS = 480;
34
35
  const agentModes = new Map<number, "all" | "preview">();
35
36
  const runningTurns = new Set<number>();
36
37
  let pinnedToolId: string | undefined;
@@ -231,7 +232,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
231
232
  if (!entries.some(entry => entry.id === call.id)) entries.push({ title: `${isAgentTool(call.tool ?? call.name) ? "Control" : call.name} ${display.summary}`, detail: display.detail, state: call.state, id: call.id, thinking: false, processIndex: -1, activeThinking: false });
232
233
  }
233
234
  const agentTurnControls: Array<{ runId: string; y: number; width: number; line: string }> = [];
234
- const agents = liveAgentView(turn.subAgents ?? [], theme, width, subAgentsExpanded(), true, agentDeadlines, Date.now(), expandedSubagents, agentTurnControls);
235
+ const agents = liveAgentView(turn.subAgents ?? [], theme, width, false, true, agentDeadlines, Date.now(), expandedSubagents, agentTurnControls);
235
236
  const active = !!turn.running || agents.running > 0 || entries.some(entry => entry.state === "running") || (turn.waitingTools?.length ?? 0) > 0;
236
237
  if (active) runningTurns.add(index);
237
238
  else if (runningTurns.delete(index)) {
@@ -249,8 +250,9 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
249
250
  const expanded = mode === "all";
250
251
  const busy = entries.some(entry => entry.state === "running") || (turn.waitingTools?.length ?? 0) > 0;
251
252
  const working = turn.running && !busy && !turn.final;
253
+ const showAgentRows = (expanded || subAgentsExpanded()) && agents.total > 0;
252
254
  // Every child keeps its heading; process records share the remaining preview budget.
253
- const processLimit = Math.max(0, getRecordLimit() - agents.total);
255
+ const processLimit = Math.max(0, getRecordLimit() - (showAgentRows ? agents.total : 0));
254
256
  const shown = expanded ? entries : processLimit ? entries.slice(-processLimit) : [];
255
257
  const showWorking = working && (turn.awaitingResponse || expanded || (!shown.length && !agents.total));
256
258
  const sparkle = active ? Math.floor(Date.now() / 360) % 2 ? "✧" : "✦" : "✦";
@@ -262,7 +264,6 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
262
264
  : "";
263
265
  const recordCount = entries.length + agents.total;
264
266
  const progressHeader = theme.fg(active ? "accent" : "muted", sparkle + " ") + theme.bold(theme.fg("text", "Agent")) + theme.fg("muted", recordCount ? ` · ${recordCount}` : "");
265
- const showAgentRows = agents.total > 0;
266
267
  const caret = theme.fg("muted", expanded ? " ▾" : " ▸");
267
268
  const elapsedHeader = turn.startedAt == null ? "" : theme.fg("muted", " · ") + theme.fg(active ? "success" : "muted", formatElapsed(turn.startedAt, turn.endedAt ?? Date.now()));
268
269
  const left = progressHeader + elapsedHeader + caret;
@@ -287,18 +288,19 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
287
288
  const open = call ? expandedTools.has(call.id) : entry.thinking && !noThinkingBody && expandedThinking.has(entry.id);
288
289
  const identity = entry.state === "error" ? "error" : open || activeThinking ? "accent" : "text";
289
290
  const duration = call ? formatToolElapsed(call.startedAt,
290
- call.endedAt ?? (call.state === "running" && turn.running ? Date.now() : undefined)) : "";
291
+ call.endedAt ?? (call.state === "running" ? Date.now() : undefined)) : "";
291
292
  const toolElapsed = duration ? theme.fg(entry.state === "error" ? "error" : call?.state === "running" ? "accent" : "muted", ` ${duration}`) : "";
292
293
  const summary = theme.fg(identity, theme.bold(label)) + thinkingElapsed + toolElapsed + " ";
293
294
  if (controlId && width >= 4) toolControls.push({ id: controlId, y: lines.length, width, title: text });
294
295
  if (hoveredTool?.id === controlId && (hoveredTool.y !== lines.length || hoveredTool.width !== width)) clearHover();
295
- const status = entry.state === "running" ? runningGlyph() : "●";
296
+ const status = entry.state === "error" ? "✕" : entry.state === "running" ? runningGlyph() : "●";
296
297
  const arrow = !!controlId && (open || hoveredTool?.id === controlId);
297
- const keepStatus = entry.state === "running";
298
+ const keepStatus = entry.state === "running" || (open && entry.state === "error");
298
299
  const glyph = arrow ? (open ? "▼" : "▶") + (keepStatus ? ` ${status}` : "") : status;
299
300
  const glyphColor = entry.state === "error" ? "error" : entry.state === "running" || arrow ? "accent" : "muted";
300
301
  const last = row === shown.length - 1 && !showWorking && !agents.rows.length;
301
- const prefix = theme.fg(open ? "accent" : "dim", "│ ") + (entry.state === "running" || arrow ? theme.fg(glyphColor, glyph) + " " : "") + summary;
302
+ const showGlyph = entry.state === "running" || entry.state === "error" || arrow;
303
+ const prefix = theme.fg(open ? "accent" : "dim", "│ ") + (showGlyph ? theme.fg(glyphColor, glyph) + " " : "") + summary;
302
304
  if (label === "Output") {
303
305
  // Wrapped output hangs under the body column and keeps the tree rail to the next sibling.
304
306
  const indent = visibleWidth(prefix);
@@ -311,18 +313,23 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
311
313
  if (entry.thinking) {
312
314
  const cached = thinkingPreviews.get(entry.id);
313
315
  const previewRows = open ? 1 : 2;
314
- const reuse = cached?.source === entry.detail && cached.width === available && cached.rows === previewRows && cached.live === activeThinking;
315
- const display = reuse ? cached.text : thinkingPreview(entry.detail, available, previewRows, activeThinking);
316
- if (!reuse) thinkingPreviews.set(entry.id, { text: display, source: entry.detail, width: available, rows: previewRows, live: activeThinking });
316
+ const sameFrame = cached?.source === entry.detail && cached.width === available && cached.rows === previewRows && cached.live === activeThinking;
317
+ const holdTail = activeThinking && cached?.live && cached.width === available && cached.rows === previewRows && Date.now() - cached.shownAt < THINKING_SCROLL_MS;
318
+ const display = sameFrame || holdTail ? cached.text : thinkingPreview(entry.detail, available, previewRows, activeThinking);
319
+ if (!sameFrame && !holdTail) thinkingPreviews.set(entry.id, { text: display, source: entry.detail, width: available, rows: previewRows, live: activeThinking, shownAt: Date.now() });
317
320
  const outcome = turn.thinkingOutcomes?.[entry.processIndex];
318
321
  const fallback = activeThinking ? "正在思考,等待可显示摘要"
319
322
  : outcome === "aborted" ? "思考已中断,未返回可显示摘要"
320
323
  : outcome === "error" ? "思考失败,未返回可显示摘要" : "思考已结束,未返回可显示摘要";
321
- const rows = available > 0 ? new Text(display || fallback, 0, 0).render(available).slice(0, previewRows) : [];
322
324
  const color = entry.state === "error" ? "error" : activeThinking ? "accent" : "muted";
323
- lines.push(bandHeading(truncateToWidth(prefix + theme.fg(color, rows[0] ?? ""), width, ""), open));
325
+ const rows = available > 0
326
+ ? renderMinimalMarkdown(display || fallback, available, getMarkdownTheme(), theme.getBgAnsi?.("userMessageBg") ?? "",
327
+ { color: value => theme.fg(color, value) }, (source, avail) => transformText(placeholderText(diagramMarkdown(source, avail))))
328
+ .slice(0, previewRows)
329
+ : [];
330
+ lines.push(bandHeading(truncateToWidth(prefix + (rows[0] ?? ""), width, ""), open));
324
331
  const rail = theme.fg(last ? color : "dim", last ? " " : "│") + " ".repeat(Math.max(0, visibleWidth(prefix) - 1));
325
- for (const extra of rows.slice(1)) lines.push(truncateToWidth(rail + theme.fg(color, extra), width, ""));
332
+ for (const extra of rows.slice(1)) lines.push(truncateToWidth(rail + extra, width, ""));
326
333
  } else {
327
334
  const displayBody = placeholderText(body);
328
335
  const compactBody = linkToolFiles(displayBody, imageOptions?.cwd() ?? process.cwd(), !open);
@@ -88,13 +88,13 @@ export function freezeOpenThinkingClocks(turn: MinimalTurn | undefined, endedAt
88
88
 
89
89
  /** Each Thinking row counts from its own start and keeps its frozen stop time. */
90
90
  export function formatThinkingElapsed(
91
- turn: Pick<MinimalTurn, "thinkingClocks">,
91
+ turn: Pick<MinimalTurn, "startedAt" | "thinkingClocks">,
92
92
  processIndex: number,
93
93
  active: boolean,
94
94
  now = Date.now(),
95
95
  ): string {
96
96
  const clock = turn.thinkingClocks?.[processIndex];
97
- const startedAt = clock?.startedAt;
97
+ const startedAt = clock?.startedAt ?? (active ? turn.startedAt : undefined);
98
98
  if (clock?.endedAt != null) return `${(Math.max(0, clock.endedAt - clock.startedAt) / 1_000).toFixed(1)}s`;
99
99
  if (active && startedAt != null) return `${(Math.max(0, now - startedAt) / 1_000).toFixed(1)}s`;
100
100
  return "";
package/lib/settings.html CHANGED
@@ -47,12 +47,12 @@ const I18N={
47
47
  featureList:{
48
48
  zh:[
49
49
  {id:'minimal',setting:'pi-mini-mode-minimal-show',title:'极简输出',body:'在全屏模式下,把思考、工具与技能记录收进一棵可折叠过程树,保留完整回复。',points:['长用户消息显示前四行,点击展开全文','子代理始终显示,可展开活动记录与输出','Ctrl+O 展开或收起过程树,新问题默认收起','最终 Markdown 流畅呈现,失败与中断明确标记']},
50
- {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'输入增强',body:'让输入框和消息里的图片、技能与文件路径直接可用。',points:['图片默认以内联卡片陈列于输入框上方,亦可切换光标悬停','图片路径收纳为 [image1] 标签,提交时保留原图','空白后输入 / 就地搜索技能并插入光标处','点击图片标签或文件路径,用系统默认应用打开'],hint:'Ctrl+V 粘贴图片(Windows/WSL 使用 Alt+V)'},
50
+ {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'输入增强',body:'让输入框和消息里的图片、技能与文件路径直接可用。',points:['图片默认以内联卡片陈列于输入框上方,亦可切换光标悬停','图片路径收纳为 [image1] 标签,提交时保留原图','空白后输入 / 就地搜索技能并插入光标处','左键用系统默认应用打开,全屏右键在文件管理器中定位并选中'],hint:'Ctrl+V 粘贴图片(Windows/WSL 使用 Alt+V)'},
51
51
  {id:'themes',title:'明暗主题',body:'主题让 Markdown、代码高亮、表格与 Mermaid 图表跟随明暗切换。',points:['用户消息使用主题用户背景色,与正文区分','不支持、不完整或过宽的图表保留源文本'],hint:'回到 Pi,输入 /settings → Theme,选择 cc-dark / cc-light'}
52
52
  ],
53
53
  en:[
54
54
  {id:'minimal',setting:'pi-mini-mode-minimal-show',title:'Minimal transcript',body:'In fullscreen mode, fold thinking, tools and skill reads into one process tree while keeping the full reply.',points:['Long user messages show four rendered rows; click to expand','Subagents stay visible; click to expand activity and output','Ctrl+O expands or collapses the full process tree; new questions start collapsed','Final Markdown streams plainly; failures and interrupts are marked']},
55
- {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'Input enhancements',body:'Makes images, skills and file paths usable right where you type.',points:['Images appear as inline cards above the editor by default, with optional cursor hover','Image paths collapse to [image1] labels while keeping the original path on submit','Type / after a space to search skills and insert at the cursor','Click image labels or file paths to open them in the default app'],hint:'Ctrl+V pastes images (Windows/WSL: Alt+V)'},
55
+ {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'Input enhancements',body:'Makes images, skills and file paths usable right where you type.',points:['Images appear as inline cards above the editor by default, with optional cursor hover','Image paths collapse to [image1] labels while keeping the original path on submit','Type / after a space to search skills and insert at the cursor','Left-click opens in the default app; fullscreen right-click reveals and selects the file'],hint:'Ctrl+V pastes images (Windows/WSL: Alt+V)'},
56
56
  {id:'themes',title:'Light and dark themes',body:'Themes keep Markdown, code highlighting, tables and Mermaid diagrams in step with light and dark.',points:['User messages use the theme user background to stand out','Unsupported, incomplete or overly wide diagrams keep their source text'],hint:'In Pi, enter /settings → Theme and choose cc-dark or cc-light'}
57
57
  ]
58
58
  },
package/lib/settings.ts CHANGED
@@ -62,7 +62,7 @@ export const COPY = {
62
62
  model: "显示模型", thinking: "显示思考等级", total: "显示会话总 token", cached: "显示会话缓存 token", miss: "显示缓存 miss", totalLabel: "Total", cachedLabel: "Cached", cacheHitLabel: "CH", cacheHit: "显示缓存命中率 (CH)", price: "显示会话价格", mcp: "显示已启用 MCP 服务器", context: "显示上下文 token 与进度条", dots: "↳ 使用点阵进度条", percent: "显示上下文百分比", speed: "显示最近生成速度", speedUnit: "↳ 显示 tok/s 单位", inputEnhancements: "输入增强",
63
63
  totalDescription: "Total:当前会话分支上的全部 token,含工具上报的 LLM 用量。", cachedDescription: "Cached:累计 cache-read + cache-write token(包含在 Total 中)。", cacheHitDescription: "CH(cache hit):cache-read / (input + cache-read)。Cache write 不计入此比率。",
64
64
  enableMinimalDescription: "开启统一折叠思考、工具和技能过程;关闭恢复 Pi 默认会话历史。",
65
- inputEnhancementsDescription: "原生 Ctrl+V 粘贴图片(Windows/WSL:Alt+V);图片显示为 [image1] 标签,默认在输入框上方显示内联卡片(可切换光标悬停模式)。空白后 / 选择技能并在光标处插入。Cmd+点击带下划线的图片标签或消息文件路径,用系统默认应用打开;预览及点击需终端支持。关闭仅恢复原生行为。",
65
+ inputEnhancementsDescription: "原生 Ctrl+V 粘贴图片(Windows/WSL:Alt+V);图片显示为 [image1] 标签,默认在输入框上方显示内联卡片(可切换光标悬停模式)。空白后 / 选择技能并在光标处插入。左键用系统默认应用打开图片标签或文件路径;全屏右键在文件管理器中定位并选中该文件。预览及点击需终端支持。关闭仅恢复原生行为。",
66
66
  tuiRequired: "/pi-mini-mode-settings 需要 TUI 模式", saveFailed: "无法保存 Pi Mini Mode 设置", onboarding: "默认开启输入增强和极简输出;极简输出需要全屏模式。仅显示分支、缓存 token 和 MCP 服务数默认关闭。选择「打开浏览器设置」可调整字段、预览方式和功能开关;推荐配置会保存主题和全屏模式。以后可用 /pi-mini-mode-settings 修改。", keepDefaults: "保留默认", configureNow: "打开浏览器设置", applyRecommended: "应用推荐配置", chooseTheme: "选择主题(主题立即应用;全屏模式需重启 Pi)", themeSaved: "已保存主题和全屏模式。请重启 Pi 以启用全屏;项目设置或命令行参数可能覆盖全局设置。", themeSaveFailed: "无法保存推荐的 Pi 主题和全屏模式;未完成首次配置。", themeApplyFailed: "推荐设置已保存,但当前主题未能立即应用;请重启 Pi。",
67
67
  } as const;
68
68
 
@@ -1,41 +1,34 @@
1
1
  import { Text, visibleWidth } from "@earendil-works/pi-tui";
2
2
  import { stripVTControlCharacters } from "node:util";
3
3
 
4
- const sentences = new Intl.Segmenter(undefined, { granularity: "sentence" });
5
4
  const words = new Intl.Segmenter(undefined, { granularity: "word" });
6
5
  const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
7
6
 
8
- /** Live previews follow coherent sentences; completed previews retain the beginning. */
7
+ /** Live previews follow the tail to fill maxRows stably; completed previews retain the beginning of the first paragraph. */
9
8
  export function thinkingPreview(source: string, columns: number, maxRows = 1, live = false): string {
10
9
  if (columns <= 0 || maxRows <= 0) return "";
11
10
  const paragraphs = stripVTControlCharacters(source).replace(/[\x00-\x08\x0b-\x1f\x7f]/g, " ")
12
11
  .split(/\n+/).map(line => line.replace(/\s+/g, " ").trim()).filter(Boolean);
13
- const full = paragraphs.join(" ");
14
- if (!full) return "";
12
+ if (!paragraphs.length) return "";
13
+ // Completed previews show only the first paragraph to keep multi-paragraph details collapsed.
14
+ // Live previews draw from recent thinking across lines to keep the tail informative.
15
+ const target = live ? paragraphs.join(" ") : (paragraphs[0] ?? "");
16
+ if (!target) return "";
15
17
  const fits = (text: string) => visibleWidth(text) <= columns * maxRows && new Text(text, 0, 0).render(columns).length <= maxRows;
16
- if (fits(full)) return full;
17
- let excerpt = full;
18
- if (live) {
19
- const parts = paragraphs.flatMap(paragraph => [...sentences.segment(paragraph)].map(part => part.segment.trim()).filter(Boolean));
20
- excerpt = parts.at(-1) ?? full;
21
- // Keep context across paragraph boundaries while the next sentence is incomplete.
22
- if (visibleWidth(excerpt) < 12 && parts.length > 1) excerpt = `${parts.at(-2)} ${excerpt}`;
23
- const marked = excerpt === full ? excerpt : `…${excerpt}`;
24
- if (fits(marked)) return marked;
25
- }
18
+ if (fits(target)) return target;
26
19
 
27
- // Only live thinking follows the tail. Tools and completed thinking retain the head.
28
20
  let result = "";
29
21
  const marked = (text: string) => live ? `…${text.trimStart()}` : `${text.trimEnd()}…`;
30
- const segments = [...words.segment(excerpt)];
22
+ const segments = [...words.segment(target)];
31
23
  for (const { segment } of live ? segments.reverse() : segments) {
32
24
  const candidate = live ? segment + result : result + segment;
33
25
  if (!fits(marked(candidate))) break;
34
26
  result = candidate;
35
27
  }
36
- if (!result.trim()) {
37
- // An oversized word/path still respects emoji and combining-character boundaries.
38
- const characters = [...graphemes.segment(excerpt)];
28
+ if (!result.trim() || (live && new Text(marked(result), 0, 0).render(columns).length < maxRows)) {
29
+ // Fill remaining space with graphemes if word boundaries left it short.
30
+ const prefix = live ? target.slice(0, target.length - result.length) : target.slice(result.length);
31
+ const characters = [...graphemes.segment(prefix)];
39
32
  for (const { segment } of live ? characters.reverse() : characters) {
40
33
  const candidate = live ? segment + result : result + segment;
41
34
  if (!fits(marked(candidate))) break;
@@ -21,6 +21,7 @@ export function createThinkingStream() {
21
21
  index = turn.process.length;
22
22
  indices.set(block, index);
23
23
  turn.process.push(`thinking ${body}`);
24
+ if (event) ensureThinkingClock(turn, index);
24
25
  } else if (body) turn.process[index] = `thinking ${body}`;
25
26
  // A terminal empty snapshot must not erase already streamed, readable text.
26
27
  }
@@ -57,7 +58,13 @@ export function createThinkingStream() {
57
58
  }
58
59
  }
59
60
  if (event.type === "thinking_end" && event.contentIndex !== undefined) ended.add(event.contentIndex);
60
- if (/^(text|toolcall)_/.test(event.type)) for (const block of indices.keys()) ended.add(block);
61
+ const last = content.length - 1;
62
+ for (const block of indices.keys()) if (block < last) ended.add(block);
63
+ if (/^(text|toolcall)_/.test(event.type) || (last >= 0 && content[last]?.type !== "thinking")) {
64
+ for (const block of indices.keys()) ended.add(block);
65
+ }
66
+ turn.thinking = content[last]?.type === "thinking" && !ended.has(last) ? indices.get(last) : undefined;
67
+ if (turn.thinking !== undefined) ensureThinkingClock(turn, turn.thinking, now).lastUpdatedAt = now;
61
68
  for (const [block, index] of indices) if (ended.has(block)) {
62
69
  freezeThinkingClock(turn, index);
63
70
  if (turn.thinking === index) turn.thinking = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@each1024/pi-mini-mode",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "A compact Pi footer with live usage metrics, theme-aware settings previews, and configurable progress bars.",
5
5
  "type": "module",
6
6
  "scripts": {