@each1024/pi-mini-mode 2.0.15 → 2.0.17

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
@@ -102,6 +102,7 @@ This earlier screenshot shows footer configuration, not the newer image, folding
102
102
 
103
103
  ## Compatibility
104
104
 
105
+ - **Links and hover:** files and directories use standard OSC 8, respecting Pi's effective terminal capabilities and user overrides instead of a terminal-specific bare-path detector. Tool, skill, and thinking rows in fullscreen minimal output highlight across the row on hover; links elsewhere highlight locally. Links gain an underline when the terminal reports Ctrl. macOS Cmd underlining belongs to the terminal; Ghostty fullscreen mouse capture usually requires `Shift+Cmd`. Standard mouse reports do not include Cmd, so identical Cmd-only behavior across terminals cannot be guaranteed. Paths remain visible when OSC 8 is unavailable.
105
106
  - **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
107
  - **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
108
  - **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.
package/README.zh-CN.md CHANGED
@@ -101,6 +101,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
101
101
 
102
102
  ## 兼容性
103
103
 
104
+ - **链接与悬停:** 文件、目录统一使用标准 OSC 8,遵循 Pi 检测到的终端能力和用户开关,不依赖某个终端识别裸路径。全屏极简模式中的工具、技能和思考记录悬停时整行高亮,其他位置的链接局部高亮;终端报告 Ctrl 状态时增加链接下划线。macOS 的 Cmd 下划线由终端处理,Ghostty 全屏鼠标捕获下通常需要 `Shift+Cmd`。标准鼠标协议不报告 Cmd 状态,因此无法保证各终端仅按 Cmd 的行为完全一致。不支持 OSC 8 时保留路径文字。
104
105
  - **图片:** 预览依赖终端图片协议,不支持时显示提示。大图仅对终端预览副本缩放(不超过 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
106
  - **极简输出:** 使用私有 Pi 0.85.x 布局适配器,不修改 Pi 安装目录。未知布局会拒绝启用并保留原生输出;升级 Pi 后需重新检查,其他替换 transcript 的扩展可能冲突。
106
107
  - **子代理:** pi-subagents 小组件适配仅在极简模式启用,关闭后恢复原状,未知格式原样交给原生处理。可用详情取决于集成提供的状态/输出数据,不是完整子代理会话查看器。
@@ -8,7 +8,7 @@ import { installTerminalCapabilities } from "../lib/terminal-capabilities.ts";
8
8
  import { linkMessageFiles } from "../lib/file-links.ts";
9
9
  import attachFooterTidy from "../lib/footer-tidy.ts";
10
10
  import attachTitlePlain from "../lib/title-plain.ts";
11
- import { COPY, DEFAULT_SETTINGS, FOOTER_FIELDS, FOOTER_STYLE_OPTIONS, RECOMMENDED_THEMES, SETTING_IDS, isLegacyMinimalSetting, isRecordLimit, loadSettings, parseSettings, saveSettings, settingsItems, settingsPath, type MiniLensSettings, type RecommendedTheme } from "../lib/settings.ts";
11
+ import { COPY, DEFAULT_SETTINGS, FOOTER_FIELDS, FOOTER_STYLE_OPTIONS, RECOMMENDED_THEMES, SETTING_IDS, isLegacyMinimalSetting, isRecordLimit, isUiLanguage, loadSettings, parseSettings, saveSettings, settingsItems, settingsPath, uiLanguage, type MiniLensSettings, type RecommendedTheme } from "../lib/settings.ts";
12
12
  import { attachSpeedHover, speedHit, type SpeedHover } from "../lib/speed-popup.ts";
13
13
  import { createTokenSpeedTracker, SPEED_REFRESH_MS } from "../lib/token-speed.ts";
14
14
  import { addUsage, cacheWaste, EMPTY_USAGE, finiteNumber, formatSpeed, sessionUsage, type UsageLike } from "../lib/usage.ts";
@@ -178,7 +178,7 @@ export default function (pi: ExtensionAPI) {
178
178
  cwd: () => ctx.cwd,
179
179
  requestRender: () => tui.requestRender(),
180
180
  write: data => tui.terminal.write(data),
181
- }, () => settings["pi-mini-mode-minimal-record-limit"]);
181
+ }, () => settings["pi-mini-mode-minimal-record-limit"], () => uiLanguage(settings));
182
182
  // Native info notifications use dim; warning/error notifications retain
183
183
  // their position in the transcript. No plugin names or message matching.
184
184
  const dimPrefix = theme.fg("dim", "\u0000").split("\u0000")[0];
@@ -347,6 +347,8 @@ export default function (pi: ExtensionAPI) {
347
347
  if (entry !== "hover" && entry !== "inline") throw new TypeError("Invalid preview mode");
348
348
  } else if (key === "pi-mini-mode-minimal-record-limit") {
349
349
  if (!isRecordLimit(entry)) throw new TypeError("Invalid record limit");
350
+ } else if (key === "pi-mini-mode-language") {
351
+ if (!isUiLanguage(entry)) throw new TypeError("Invalid language");
350
352
  } else if (isLegacyMinimalSetting(key) && typeof entry === "boolean") {
351
353
  // Accept stale settings pages; these former child switches no longer gate output.
352
354
  continue;
package/lib/file-links.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
- import { dirname, isAbsolute, relative, resolve } from "node:path";
3
+ import { dirname, isAbsolute, resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { Marked, getCapabilities, sliceByColumn, stripTerminalSequences, visibleWidth } from "@earendil-works/pi-tui";
6
6
 
@@ -23,21 +23,6 @@ export function localPath(path: string, cwd: string): string {
23
23
  return path.startsWith("~/") ? resolve(homedir(), path.slice(2)) : isAbsolute(path) ? path : resolve(cwd, path);
24
24
  }
25
25
 
26
- /** Otty always underlines OSC 8; ordinary paths use its Cmd-only detection instead. */
27
- function nativePathLinks(): boolean {
28
- return process.env.TERM_PROGRAM?.toLowerCase() === "otty"
29
- && !process.env.TMUX && !process.env.STY && !/^(tmux|screen)/i.test(process.env.TERM ?? "");
30
- }
31
-
32
- /** Short forms must remain real paths that Otty can resolve from the pane's cwd. */
33
- function nativePathLabel(path: string, cwd: string): string {
34
- const fromCwd = relative(cwd, path);
35
- if (fromCwd && fromCwd !== ".." && !fromCwd.startsWith("../") && !isAbsolute(fromCwd)) return `./${fromCwd}`;
36
- const fromHome = relative(homedir(), path);
37
- if (fromHome && fromHome !== ".." && !fromHome.startsWith("../") && !isAbsolute(fromHome)) return `~/${fromHome}`;
38
- return path;
39
- }
40
-
41
26
  /** Opening/closing fences must stay intact; quoted paths inside them are not links. */
42
27
  function fenceRanges(text: string): Array<[number, number]> {
43
28
  const ranges: Array<[number, number]> = [];
@@ -82,15 +67,14 @@ export const fileLink = (text: string, path: string, underline = true) => `\x1b]
82
67
 
83
68
  /** Shorten only visible tool labels; OSC 8 targets retain the complete original path. */
84
69
  export function linkToolFiles(text: string, cwd: string, compact: boolean): string {
85
- const native = nativePathLinks();
86
- const shorten = (label: string) => compact && !native ? label
70
+ const shorten = (label: string) => compact ? label
87
71
  .replace(/\/var\/folders\/[^\s]*\/otty-paste\//g, "…/otty-paste/")
88
72
  .replace(/node_modules\/@earendil-works\//g, "…/") : label;
89
73
  const hyperlinks = inputCapabilities().hyperlinks;
90
74
  // Image chips already carry a complete target; never shorten or relink it.
91
75
  return text.split(/(\x1b\]8;[^\x07]*\x07[\s\S]*?\x1b\]8;;\x07)/g).map((part, index) => {
92
76
  if (index % 2) return part;
93
- if (!hyperlinks && !native) return shorten(part);
77
+ if (!hyperlinks) return shorten(part);
94
78
  // A path tool's entire argument can contain spaces or punctuation without quotes.
95
79
  const matches = part && !/[\x00-\x1f\x7f]/.test(part) && existsSync(localPath(part, cwd))
96
80
  ? [{ path: part, start: 0, end: part.length }] : filePaths(part);
@@ -99,8 +83,8 @@ export function linkToolFiles(text: string, cwd: string, compact: boolean): stri
99
83
  const path = localPath(match.path, cwd);
100
84
  result += shorten(part.slice(offset, match.start));
101
85
  const exists = existsSync(path);
102
- const label = native && compact && exists ? nativePathLabel(path, cwd) : shorten(part.slice(match.start, match.end));
103
- result += exists && !native ? fileLink(label, path, false) : label;
86
+ const label = shorten(part.slice(match.start, match.end));
87
+ result += exists ? fileLink(label, path, false) : label;
104
88
  offset = match.end;
105
89
  }
106
90
  return result + shorten(part.slice(offset));
@@ -110,7 +94,6 @@ export function linkToolFiles(text: string, cwd: string, compact: boolean): stri
110
94
  /** Display-only: normalize local targets without changing persisted messages or remote URLs. */
111
95
  export function linkMessageFiles(text: string, cwd: string): string {
112
96
  if (!inputCapabilities().hyperlinks) return text;
113
- const native = nativePathLinks();
114
97
  let imageNumber = 0;
115
98
  return text.split(/(\x1b\]8;[^\x07]*(?:\x07)[\s\S]*?\x1b\]8;;\x07|\[[^\]\n]*\]\([^\n]*?\))/g).map((part, index) => {
116
99
  if (index % 2) {
@@ -126,8 +109,7 @@ export function linkMessageFiles(text: string, cwd: string): string {
126
109
  for (const match of matches.reverse()) {
127
110
  const path = localPath(match.path, cwd);
128
111
  if (!existsSync(path)) continue;
129
- const label = native && !match.image ? part.slice(match.start, match.end)
130
- : fileLink(match.image ? ` #${match.number}` : match.path, path, !match.image);
112
+ const label = fileLink(match.image ? ` #${match.number}` : match.path, path, false);
131
113
  part = part.slice(0, match.start) + label + part.slice(match.end);
132
114
  }
133
115
  return part;
@@ -0,0 +1,54 @@
1
+ import { getOsc8LinkAtColumn, sliceByColumn, visibleWidth, type TuiMouseEvent } from "@earendil-works/pi-tui";
2
+
3
+ /** OSC 8 identifies targets; standard mouse events and SGR supply hover feedback.
4
+ * Cmd is not a modifier in SGR mouse reports. The terminal owns Cmd underlining;
5
+ * Ctrl reports can provide the same feedback inside a mouse-capturing TUI.
6
+ */
7
+ export function createLinkHover(highlight: (text: string) => string) {
8
+ let rows: string[] = [];
9
+ let width = 0;
10
+ let hovered: { row: number; start: number; end: number; source: string; underline: boolean } | undefined;
11
+ const clear = () => { const changed = !!hovered; hovered = undefined; return changed; };
12
+ return {
13
+ clear,
14
+ handleMouse(event: TuiMouseEvent): boolean {
15
+ if (event.type !== "move") return clear();
16
+ const source = rows[event.y];
17
+ if (!source || event.x < 0 || event.x >= visibleWidth(source)) return clear();
18
+ const underline = event.ctrl;
19
+ if (hovered?.row === event.y && hovered.source === source
20
+ && event.x >= hovered.start && event.x < hovered.end) {
21
+ const changed = hovered.underline !== underline;
22
+ hovered.underline = underline;
23
+ return changed;
24
+ }
25
+ const url = getOsc8LinkAtColumn(source, event.x);
26
+ if (!url) return clear();
27
+ let start = event.x, end = event.x + 1;
28
+ while (start > 0 && getOsc8LinkAtColumn(source, start - 1) === url) start--;
29
+ while (end < visibleWidth(source) && getOsc8LinkAtColumn(source, end) === url) end++;
30
+ hovered = { row: event.y, start, end, source, underline };
31
+ return true;
32
+ },
33
+ render(lines: string[], columns: number): string[] {
34
+ if (columns !== width || hovered && lines[hovered.row] !== hovered.source) clear();
35
+ rows = lines;
36
+ width = columns;
37
+ if (!hovered) return lines;
38
+ const { row, start, end, underline } = hovered;
39
+ const line = lines[row];
40
+ // A slice replays preceding ANSI state. Remove its old background so
41
+ // user-message/code surfaces cannot cover the hover background.
42
+ let label = highlight(sliceByColumn(line, start, end - start)
43
+ .replace(/\x1b\[(?:4[0-9]|10[0-7]|48;(?:2;\d+;\d+;\d+|5;\d+))m/g, ""));
44
+ if (underline) label = "\x1b[4m" + label.replace(/\x1b\[(?:0|24)?m/g, reset => reset + "\x1b[4m") + "\x1b[24m";
45
+ const result = [...lines];
46
+ // Column slicing omits zero-width sequences after the final cell.
47
+ // Retain them (including image placement), then isolate the row's state.
48
+ const trailing = line.match(/(?:\x1b\[[0-?]*[ -/]*[@-~]|\x1b[\]_][^\x07\x1b]*(?:\x07|\x1b\\))+$/)?.[0] ?? "";
49
+ result[row] = sliceByColumn(line, 0, start) + label + sliceByColumn(line, end, Math.max(0, visibleWidth(line) - end))
50
+ + trailing + "\x1b]8;;\x07\x1b[0m";
51
+ return result;
52
+ },
53
+ };
54
+ }
@@ -4,15 +4,22 @@ import { stripVTControlCharacters } from "node:util";
4
4
  import { agentCallDisplay, isAgentTool, liveAgentView, runningGlyph } from "./agent-view.ts";
5
5
  import { createAssistantImages, imagePlaceholders } from "./assistant-images.ts";
6
6
  import { linkToolFiles } from "./file-links.ts";
7
+ import { createLinkHover } from "./link-hover.ts";
7
8
  import { diagramMarkdown, isFencedMarkdown, renderMinimalMarkdown } from "./minimal-markdown.ts";
8
9
  import { minimalSurface, paintExpandedHeading } from "./minimal-theme.ts";
9
10
  import { formatElapsed, formatThinkingElapsed, formatToolElapsed, piLoopSummary, type MinimalTurn } from "./minimal-turns.ts";
10
- import { DEFAULT_SETTINGS } from "./settings.ts";
11
+ import { DEFAULT_SETTINGS, uiLanguage, type UiLanguage } from "./settings.ts";
11
12
  import { thinkingPreview } from "./thinking-preview.ts";
12
13
  import type { NoticeRows, TurnNotices } from "./transcript-adapter.ts";
13
14
  import { addUsage, EMPTY_USAGE, formatTokens } from "./usage.ts";
14
15
 
15
- export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], getTurns: () => MinimalTurn[], isExpanded: () => boolean = () => false, showUsage: () => boolean = () => true, subAgentsExpanded: () => boolean = () => false, agentDeadlines = new Map<string, number>(), transformText: (text: string) => string = text => text, imageOptions?: { cwd(): string; requestRender(): void; write?(data: string): void }, getRecordLimit: () => number = () => DEFAULT_SETTINGS["pi-mini-mode-minimal-record-limit"]) {
16
+ /** Shown when a thinking block has no displayable summary. */
17
+ const THINKING_FALLBACK: Record<UiLanguage, Record<"active" | "aborted" | "error" | "ended", string>> = {
18
+ zh: { active: "正在思考,等待可显示摘要", aborted: "思考已中断,未返回可显示摘要", error: "思考失败,未返回可显示摘要", ended: "思考已结束,未返回可显示摘要" },
19
+ en: { active: "Waiting for a displayable summary", aborted: "Interrupted, no displayable summary returned", error: "Failed, no displayable summary returned", ended: "Finished, no displayable summary returned" },
20
+ };
21
+
22
+ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], getTurns: () => MinimalTurn[], isExpanded: () => boolean = () => false, showUsage: () => boolean = () => true, subAgentsExpanded: () => boolean = () => false, agentDeadlines = new Map<string, number>(), transformText: (text: string) => string = text => text, imageOptions?: { cwd(): string; requestRender(): void; write?(data: string): void }, getRecordLimit: () => number = () => DEFAULT_SETTINGS["pi-mini-mode-minimal-record-limit"], getLanguage: () => UiLanguage = () => uiLanguage({})) {
16
23
  const placeholderText = (text: string) => imageOptions ? imagePlaceholders(text, imageOptions.cwd()) : text;
17
24
  const markdown = (text: string, width: number, process = false) => renderMinimalMarkdown(text, width, getMarkdownTheme(), theme.getBgAnsi?.("userMessageBg") ?? "",
18
25
  { color: (value) => theme.fg(process ? "muted" : "text", value) }, (source, available) => transformText(placeholderText(diagramMarkdown(source, available))));
@@ -40,9 +47,13 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
40
47
  let pinnedSubagentId: string | undefined;
41
48
  let pinnedSubagent: { id: string; y: number; line: string; autoScroll?: boolean } | undefined;
42
49
  let toolControls: Array<{ id: string; y: number; width: number; title: string }> = [];
50
+ let processRows: Array<{ key: string; y: number }> = [];
51
+ let hoveredProcess: { key: string; y: number } | undefined;
52
+ let hoverWidth = 0;
43
53
  let agentControls: Array<{ index: number; y: number; width: number }> = [];
44
54
  let hoveredTool: typeof toolControls[number] | undefined;
45
- const clearHover = () => { const changed = !!hoveredTool; hoveredTool = undefined; return changed; };
55
+ const linkHover = createLinkHover(text => paintExpandedHeading(theme, text));
56
+ const clearHover = () => { const changed = !!hoveredTool || hoveredProcess !== undefined; hoveredTool = undefined; hoveredProcess = undefined; return linkHover.clear() || changed; };
46
57
  const toggleTool = (id: string) => {
47
58
  if (id.startsWith("thinking:")) {
48
59
  const present = getTurns().some((turn, turnIndex) => turn.process.some((entry, processIndex) =>
@@ -117,9 +128,12 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
117
128
  handleMouse(event: TuiMouseEvent) {
118
129
  const tool = toolControls.find(control => event.y === control.y && event.x >= 2 && event.x < Math.min(5, control.width));
119
130
  if (event.type === "move") {
131
+ const linkChanged = linkHover.handleMouse(event);
120
132
  const next = !event.shift && !event.ctrl && !event.alt ? tool : undefined;
121
- if (hoveredTool?.id !== next?.id) {
133
+ const record = processRows.find(row => row.y === event.y);
134
+ if (hoveredTool?.id !== next?.id || hoveredProcess?.key !== record?.key || hoveredProcess?.y !== record?.y || linkChanged) {
122
135
  hoveredTool = next;
136
+ hoveredProcess = record;
123
137
  return { handled: true, render: true };
124
138
  }
125
139
  return;
@@ -165,8 +179,11 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
165
179
  return region?.rows.handleMouse?.({ ...event, y: event.y - region.y });
166
180
  },
167
181
  render(width: number, notices?: TurnNotices): string[] {
182
+ if (width !== hoverWidth) clearHover();
183
+ hoverWidth = width;
168
184
  promptControls = [];
169
185
  toolControls = [];
186
+ processRows = [];
170
187
  agentControls = [];
171
188
  pinnedTool = undefined;
172
189
  pinnedAgent = undefined;
@@ -174,7 +191,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
174
191
  subagentControls = [];
175
192
  noticeRegions = [];
176
193
  agentExpiry = Infinity;
177
- if (width <= 0) { clearHover(); return []; }
194
+ if (width <= 0) { clearHover(); return linkHover.render([], width); }
178
195
  const turns = getTurns();
179
196
  const toolIds = new Set(turns.flatMap(turn => (turn.agentCalls ?? []).map(call => call.id)));
180
197
  for (const id of expandedTools) if (!toolIds.has(id)) expandedTools.delete(id);
@@ -273,6 +290,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
273
290
  ? left + " ".repeat(width - visibleWidth(left) - visibleWidth(totals)) + totals
274
291
  : truncateToWidth(left, width));
275
292
  shown.forEach((entry, row) => {
293
+ processRows.push({ key: entry.id || `${index}:${entry.processIndex}`, y: lines.length });
276
294
  const title = entry.title;
277
295
  const text = title.split(/\r?\n/).find(line => line.trim())?.replace(/\s+/g, " ").trim() ?? "";
278
296
  const split = text.indexOf(" ");
@@ -316,9 +334,10 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
316
334
  const display = reuse ? cached.text : thinkingPreview(entry.detail, available, previewRows, activeThinking);
317
335
  if (!reuse) thinkingPreviews.set(entry.id, { text: display, source: entry.detail, width: available, rows: previewRows, live: activeThinking });
318
336
  const outcome = turn.thinkingOutcomes?.[entry.processIndex];
319
- const fallback = activeThinking ? "正在思考,等待可显示摘要"
320
- : outcome === "aborted" ? "思考已中断,未返回可显示摘要"
321
- : outcome === "error" ? "思考失败,未返回可显示摘要" : "思考已结束,未返回可显示摘要";
337
+ const fallbackCopy = THINKING_FALLBACK[getLanguage()];
338
+ const fallback = activeThinking ? fallbackCopy.active
339
+ : outcome === "aborted" ? fallbackCopy.aborted
340
+ : outcome === "error" ? fallbackCopy.error : fallbackCopy.ended;
322
341
  const color = entry.state === "error" ? "error" : activeThinking ? "accent" : "muted";
323
342
  const rows = available > 0
324
343
  ? renderMinimalMarkdown(display || fallback, available, getMarkdownTheme(), theme.getBgAnsi?.("userMessageBg") ?? "",
@@ -377,8 +396,16 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
377
396
  lines.push(...noticeRows);
378
397
  }
379
398
  if (hoveredTool && !toolControls.some(control => control.id === hoveredTool!.id)) clearHover();
399
+ if (hoveredProcess && !processRows.some(row => row.key === hoveredProcess!.key && row.y === hoveredProcess!.y)) clearHover();
380
400
  for (const deadline of agentDeadlines.values()) if (deadline > Date.now()) agentExpiry = Math.min(agentExpiry, deadline);
381
- return lines;
401
+ const linkedRows = linkHover.render(lines, width);
402
+ const hovered = hoveredProcess;
403
+ const hoveredRow = hovered && processRows.find(row => row.key === hovered.key && row.y === hovered.y);
404
+ if (!hoveredRow) return linkedRows;
405
+ const result = [...linkedRows];
406
+ const line = result[hoveredRow.y];
407
+ result[hoveredRow.y] = paintExpandedHeading(theme, line + " ".repeat(Math.max(0, width - visibleWidth(line))));
408
+ return result;
382
409
  },
383
410
  };
384
411
  }
package/lib/settings.html CHANGED
@@ -275,7 +275,7 @@ $('copyPrompt').onclick=async()=>{
275
275
  clearTimeout(copyTimer);
276
276
  copyTimer=setTimeout(()=>button.textContent=t('copyPrompt'),1600);
277
277
  };
278
- function setLang(next){lang=next;localStorage.piMiniModeLang=lang;render()}
278
+ function setLang(next){lang=next;localStorage.piMiniModeLang=lang;if(state){state['pi-mini-mode-language']=lang;render();change()}else render()}
279
279
  $('lang-zh').onclick=()=>setLang('zh');
280
280
  $('lang-en').onclick=()=>setLang('en');
281
281
  $('retry').onclick=save;
@@ -283,6 +283,11 @@ function mergeOrder(base,all){const next=[...new Set((base||[]).filter(id=>(all|
283
283
  $('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=mergeOrder(data.order,data.order);render();change()};
284
284
  window.addEventListener('beforeunload',event=>{if(dirty||saving){event.preventDefault();event.returnValue=''}});
285
285
  applyLang();status(t('connecting'));
286
- request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);render();$('reset').disabled=false;status('')}).catch(error=>status(error instanceof TypeError?t('reconnect'):error.message||t('reconnect'),true));
286
+ request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);
287
+ // The saved choice drives Pi's transcript copy; a page-only choice from older versions is saved once.
288
+ const saved=state['pi-mini-mode-language'],local=localStorage.piMiniModeLang;
289
+ if(saved==='en'||saved==='zh'){lang=saved;localStorage.piMiniModeLang=lang}
290
+ render();$('reset').disabled=false;status('');
291
+ if(!saved&&(local==='en'||local==='zh')){state['pi-mini-mode-language']=local;change()}}).catch(error=>status(error instanceof TypeError?t('reconnect'):error.message||t('reconnect'),true));
287
292
  </script>
288
293
  </html>
package/lib/settings.ts CHANGED
@@ -28,6 +28,22 @@ export interface MiniLensSettings {
28
28
  "pi-mini-mode-image-preview": "hover" | "inline";
29
29
  onboardingCompleted: boolean;
30
30
  footerOrder?: string[];
31
+ /** Language picked in the settings page; unset follows the system locale. */
32
+ "pi-mini-mode-language"?: UiLanguage;
33
+ }
34
+
35
+ export type UiLanguage = "en" | "zh";
36
+
37
+ export function isUiLanguage(value: unknown): value is UiLanguage {
38
+ return value === "en" || value === "zh";
39
+ }
40
+
41
+ /** The saved choice wins; otherwise a zh* system locale keeps Chinese and everything else is English. */
42
+ export function uiLanguage(settings: Pick<MiniLensSettings, "pi-mini-mode-language">, env: NodeJS.ProcessEnv = process.env): UiLanguage {
43
+ const saved = settings["pi-mini-mode-language"];
44
+ if (saved) return saved;
45
+ const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || Intl.DateTimeFormat().resolvedOptions().locale;
46
+ return /^zh/i.test(locale) ? "zh" : "en";
31
47
  }
32
48
 
33
49
  export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
@@ -53,7 +69,7 @@ export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
53
69
  onboardingCompleted: false,
54
70
  };
55
71
 
56
- export const SETTING_IDS = Object.keys(DEFAULT_SETTINGS) as Array<Exclude<keyof MiniLensSettings, "footerOrder">>;
72
+ export const SETTING_IDS = Object.keys(DEFAULT_SETTINGS) as Array<Exclude<keyof MiniLensSettings, "footerOrder" | "pi-mini-mode-language">>;
57
73
  export const FOOTER_FIELDS = ["project-branch", "model", "thinking", "branch", "session-tokens", "cache-tokens", "cache-miss", "ch", "cost", "mcp", "context", "context-percent", "speed"] as const;
58
74
  export const FOOTER_STYLE_OPTIONS = ["context-dots", "speed-unit"] as const;
59
75
 
@@ -96,6 +112,7 @@ export function parseSettings(value: unknown): MiniLensSettings {
96
112
  typeof id === "string" && (FOOTER_FIELDS as readonly string[]).includes(id)))];
97
113
  for (const id of FOOTER_FIELDS) if (!settings.footerOrder.includes(id)) settings.footerOrder.push(id);
98
114
  }
115
+ if (isUiLanguage(candidate["pi-mini-mode-language"])) settings["pi-mini-mode-language"] = candidate["pi-mini-mode-language"];
99
116
  if (settings["pi-mini-mode-branch-show"]) settings["pi-mini-mode-project-branch-show"] = false;
100
117
  return settings;
101
118
  }
@@ -140,7 +157,7 @@ export function isLegacyMinimalSetting(id: string): boolean {
140
157
 
141
158
  export function settingsItems(settings: MiniLensSettings): SettingItem[] {
142
159
  const values = ["on", "off"];
143
- const labels: Record<Exclude<keyof MiniLensSettings, "onboardingCompleted" | "footerOrder" | "pi-mini-mode-image-preview" | "pi-mini-mode-minimal-record-limit">, string> = {
160
+ const labels: Record<Exclude<keyof MiniLensSettings, "onboardingCompleted" | "footerOrder" | "pi-mini-mode-language" | "pi-mini-mode-image-preview" | "pi-mini-mode-minimal-record-limit">, string> = {
144
161
  "pi-mini-mode-project-branch-show": "显示项目名称和分支(互斥)",
145
162
  "pi-mini-mode-branch-show": "仅显示分支(思考等级后,互斥)",
146
163
  "pi-mini-mode-model-show": COPY.model, "pi-mini-mode-thinking-show": COPY.thinking, "pi-mini-mode-session-tokens-show": COPY.total, "pi-mini-mode-cache-tokens-show": COPY.cached, "pi-mini-mode-cache-miss-show": COPY.miss, "pi-mini-mode-ch-show": COPY.cacheHit, "pi-mini-mode-cost-show": COPY.price, "pi-mini-mode-mcp-show": COPY.mcp, "pi-mini-mode-context-show": COPY.context, "pi-mini-mode-context-dots-show": COPY.dots, "pi-mini-mode-context-percent-show": COPY.percent, "pi-mini-mode-speed-show": COPY.speed, "pi-mini-mode-speed-unit-show": COPY.speedUnit, "pi-mini-mode-minimal-show": COPY.minimal, "pi-mini-mode-input-enhancements": COPY.inputEnhancements,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@each1024/pi-mini-mode",
3
- "version": "2.0.15",
3
+ "version": "2.0.17",
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": {
7
- "check": "tsc --noEmit -p tsconfig.json",
7
+ "check": "node scripts/typecheck.mjs --noEmit -p tsconfig.json",
8
8
  "test": "node scripts/check-focused.mjs",
9
9
  "check:focused": "node scripts/check-focused.mjs",
10
10
  "check:syntax": "node scripts/check-syntax.mjs",
@@ -57,6 +57,7 @@
57
57
  "@earendil-works/pi-server": "0.85.0",
58
58
  "@earendil-works/pi-tui": "^0.85.0",
59
59
  "@types/node": "^26.4.1",
60
+ "tsrs": "0.18.0-ts7.1.0-dev.20260929",
60
61
  "typescript": "^5.9.3"
61
62
  },
62
63
  "dependencies": {