@each1024/pi-mini-mode 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,7 @@ An everyday refinement for [Pi](https://pi.dev), not just a footer. Preview imag
16
16
  pi install npm:@each1024/pi-mini-mode
17
17
  ```
18
18
 
19
- Run `/reload` in Pi. On the first interactive TUI session, choose **Apply recommended setup** to select `cc-dark` or `cc-light` and save the theme plus `tuiMode=fullscreen` globally; restart Pi for fullscreen to take effect. Project settings and CLI flags may override global settings. You can retry later with `/pi-mini-mode-setup`, or configure only Pi Mini Mode with `/pi-mini-mode-settings`.
19
+ Run `/reload` in Pi. On the first interactive TUI session, choose **Apply recommended setup** to select `cc-dark` or `cc-light` and save the theme plus `tuiMode=fullscreen` globally; restart Pi for fullscreen to take effect. Project settings and CLI flags may override global settings. You can configure Pi Mini Mode any time with `/pi-mini-mode-settings`.
20
20
 
21
21
  **Pi ≥ 0.84.0.** Input enhancements and minimal output are on by default. Minimal mode uses a private **Pi 0.85.x** layout adapter—see [compatibility](#compatibility) before enabling it.
22
22
 
@@ -75,7 +75,7 @@ This earlier screenshot and recording show footer configuration, not the newer i
75
75
  | Command / shortcut | Purpose |
76
76
  | --- | --- |
77
77
  | `/pi-mini-mode-settings` | Configure fields, input enhancements and minimal output |
78
- | `/pi-mini-mode-setup` | Choose the bundled theme and save global fullscreen mode; restart Pi afterward |
78
+ | `/pi-mini-mode-setup` | Show the first-run setup prompt again |
79
79
  | `/pi-mini-mode-minimal on` / `off` | Enable minimal output / restore native history |
80
80
  | `Ctrl+O` | Expand or collapse the complete process tree |
81
81
  | `Ctrl+S` | Expand or collapse completed subagent rows; yields to Pi `/model`, `/thinking`, and other selectors |
@@ -99,10 +99,10 @@ This earlier screenshot and recording show footer configuration, not the newer i
99
99
  <details>
100
100
  <summary><strong>First run & configuration</strong> — defaults, controls, and settings file</summary>
101
101
 
102
- On the first interactive TUI session, Pi Mini Mode shows a preview. Footer metrics are on by default except MCP count; the dot-matrix style is off; minimal output is on:
102
+ On the first interactive TUI session, Pi Mini Mode shows a preview. Almost every feature is on by default; only **branch-only** is off (it is mutually exclusive with **project & branch**). Change anything later with `/pi-mini-mode-settings`.
103
103
 
104
104
  ```text
105
- deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
105
+ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500/1.0M ⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀ 1% 120 tok/s
106
106
  ```
107
107
 
108
108
  The first-run picker offers **Keep defaults**, **Configure now**, and **Apply recommended setup**. Keeping defaults saves the default field selection, leaves minimal output on, and prevents the prompt from appearing again; configuring opens the same settings list immediately. Applying the recommendation asks you to choose the bundled `cc-dark` or `cc-light` theme, saves that theme and global `tuiMode=fullscreen` through Pi's settings API, applies the theme immediately, and asks you to restart Pi because the fullscreen renderer is chosen at startup. Project settings and CLI flags may override these global values. Escape/cancel leaves onboarding incomplete; retry with `/pi-mini-mode-setup`. Print, JSON, and other non-interactive modes never prompt.
@@ -127,9 +127,9 @@ Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/pi-m
127
127
  "pi-mini-mode-session-tokens-show": true,
128
128
  "pi-mini-mode-cache-tokens-show": true,
129
129
  "pi-mini-mode-cost-show": true,
130
- "pi-mini-mode-mcp-show": false,
130
+ "pi-mini-mode-mcp-show": true,
131
131
  "pi-mini-mode-context-show": true,
132
- "pi-mini-mode-context-dots-show": false,
132
+ "pi-mini-mode-context-dots-show": true,
133
133
  "pi-mini-mode-context-percent-show": true,
134
134
  "pi-mini-mode-speed-show": true,
135
135
  "pi-mini-mode-speed-unit-show": true,
@@ -147,9 +147,9 @@ Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/pi-m
147
147
  | `pi-mini-mode-session-tokens-show` | `true` | Accumulated session tokens (`Total`) |
148
148
  | `pi-mini-mode-cache-tokens-show` | `true` | Accumulated cache read + cache write tokens |
149
149
  | `pi-mini-mode-cost-show` | `true` | Estimated session list price |
150
- | `pi-mini-mode-mcp-show` | `false` | Enabled MCP server count |
150
+ | `pi-mini-mode-mcp-show` | `true` | Enabled MCP server count |
151
151
  | `pi-mini-mode-context-show` | `true` | Used/total context tokens and progress bar |
152
- | `pi-mini-mode-context-dots-show` | `false` | Use a single-line dot-matrix bar instead of the default solid bar |
152
+ | `pi-mini-mode-context-dots-show` | `true` | Use a single-line dot-matrix bar instead of the solid bar |
153
153
  | `pi-mini-mode-context-percent-show` | `true` | Context-use percentage |
154
154
  | `pi-mini-mode-speed-show` | `true` | Generation speed at the far right |
155
155
  | `pi-mini-mode-speed-unit-show` | `true` | Generation-speed sub-setting: append `tok/s` to the numeric value |
package/README.zh-CN.md CHANGED
@@ -6,17 +6,22 @@
6
6
 
7
7
  # Pi Mini Mode
8
8
 
9
+
9
10
  **少一点干扰。多一点专注。**
10
11
 
11
12
  为 [Pi](https://pi.dev) 的日常工作做一点精细的改进,不止于页脚。光标处预览图片,折叠长消息和过程详情,展开子代理工作,让重要的会话状态始终清晰。
12
13
 
14
+ <img width="1259" height="1020" alt="file-5ec414a82040ac062f4cda734fc10769" src="https://github.com/user-attachments/assets/0a894706-9ae6-46e5-bf85-3c7f85cf0273" />
15
+
16
+
17
+
13
18
  ## 安装
14
19
 
15
20
  ```bash
16
21
  pi install npm:@each1024/pi-mini-mode
17
22
  ```
18
23
 
19
- 在 Pi 中运行 `/reload`。首次进入交互式 TUI 时,选择 **应用推荐配置**,再选择 `cc-dark` 或 `cc-light`;它会通过 Pi 官方设置 API 保存主题与全局 `tuiMode=fullscreen`,重启 Pi 后全屏模式才会生效。项目设置和命令行参数可能覆盖全局设置。之后可用 `/pi-mini-mode-setup` 重试,或用 `/pi-mini-mode-settings` 只配置 Pi Mini Mode。
24
+ 在 Pi 中运行 `/reload`。首次进入交互式 TUI 时,选择 **应用推荐配置**,再选择 `cc-dark` 或 `cc-light`;它会通过 Pi 官方设置 API 保存主题与全局 `tuiMode=fullscreen`,重启 Pi 后全屏模式才会生效。项目设置和命令行参数可能覆盖全局设置。之后可用 `/pi-mini-mode-settings` 随时配置 Pi Mini Mode。
20
25
 
21
26
  **需要 Pi ≥ 0.84.0。** 输入增强和极简输出默认开启。极简模式使用私有 **Pi 0.85.x** 布局适配器,启用前请查看[兼容性](#兼容性)。
22
27
 
@@ -41,6 +46,9 @@ pi install git:github.com/eachann1024/pi-mini-mode
41
46
 
42
47
  使用 `Ctrl+V` 粘贴图片,Windows/WSL 使用 `Alt+V`。关闭输入增强不会关闭 Pi 原生剪贴板功能。
43
48
 
49
+ <img width="1225" height="918" alt="image" src="https://github.com/user-attachments/assets/4cde0f64-35c9-4b15-9650-d8ba48863e6a" />
50
+
51
+
44
52
  ### 02 / 过程,更安静
45
53
 
46
54
  在设置中开启 **极简输出**,或运行 `/pi-mini-mode-minimal on`。
@@ -75,7 +83,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
75
83
  | 命令/快捷键 | 用途 |
76
84
  | --- | --- |
77
85
  | `/pi-mini-mode-settings` | 配置字段、输入增强和极简输出 |
78
- | `/pi-mini-mode-setup` | 选择内置主题并保存全局全屏模式;之后需重启 Pi |
86
+ | `/pi-mini-mode-setup` | 再次显示首次设置提示 |
79
87
  | `/pi-mini-mode-minimal on` / `off` | 开启极简输出/恢复原生历史 |
80
88
  | `Ctrl+O` | 展开/收起完整过程树 |
81
89
  | `Ctrl+S` | 展开/收起已完成的子代理行;打开 `/model`、`/thinking` 等选择器时交给 Pi |
@@ -99,10 +107,10 @@ pi install git:github.com/eachann1024/pi-mini-mode
99
107
  <details>
100
108
  <summary><strong>首次使用与配置</strong></summary>
101
109
 
102
- 首次进入交互式 TUI 会话时,Pi Mini Mode 显示设置预览。页脚指标除 MCP 数量外默认开启,点阵样式默认关闭,极简输出默认开启,例如:
110
+ 首次进入交互式 TUI 会话时,Pi Mini Mode 显示设置预览。几乎全部功能默认开启;仅「仅显示分支」默认关,与「项目与分支」互斥。之后可用 `/pi-mini-mode-settings` 再改。
103
111
 
104
112
  ```text
105
- deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
113
+ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500/1.0M ⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀ 1% 120 tok/s
106
114
  ```
107
115
 
108
116
  首次设置会提供 **Keep defaults(保留默认值)**、**Configure now(立即配置)** 和 **Apply recommended setup(应用推荐配置)**。保留默认值会保存默认字段选择、保持极简输出开启,并且不再显示首次设置提示;立即配置会直接打开同一设置列表。应用推荐配置会让你选择内置的 `cc-dark` 或 `cc-light` 主题,通过 Pi 官方设置 API 保存该主题和全局 `tuiMode=fullscreen`,立即应用主题,并提示重启 Pi(全屏渲染器在启动时决定)。项目设置和命令行参数可能覆盖全局设置。按 Esc/取消不会完成首次设置,可稍后用 `/pi-mini-mode-setup` 重试。Print、JSON 等非交互模式不会显示提示。
@@ -117,9 +125,9 @@ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █
117
125
  "pi-mini-mode-session-tokens-show": true,
118
126
  "pi-mini-mode-cache-tokens-show": true,
119
127
  "pi-mini-mode-cost-show": true,
120
- "pi-mini-mode-mcp-show": false,
128
+ "pi-mini-mode-mcp-show": true,
121
129
  "pi-mini-mode-context-show": true,
122
- "pi-mini-mode-context-dots-show": false,
130
+ "pi-mini-mode-context-dots-show": true,
123
131
  "pi-mini-mode-context-percent-show": true,
124
132
  "pi-mini-mode-speed-show": true,
125
133
  "pi-mini-mode-speed-unit-show": true,
@@ -137,9 +145,9 @@ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █
137
145
  | `pi-mini-mode-session-tokens-show` | `true` | 显示会话累计令牌(`Total`) |
138
146
  | `pi-mini-mode-cache-tokens-show` | `true` | 显示缓存读取与写入令牌(已包含在 Total 中) |
139
147
  | `pi-mini-mode-cost-show` | `true` | 显示会话费用估算 |
140
- | `pi-mini-mode-mcp-show` | `false` | 显示已启用的 MCP 服务器数量 |
148
+ | `pi-mini-mode-mcp-show` | `true` | 显示已启用的 MCP 服务器数量 |
141
149
  | `pi-mini-mode-context-show` | `true` | 显示已用/总上下文令牌和进度条 |
142
- | `pi-mini-mode-context-dots-show` | `false` | 使用单行点阵进度条替代默认实心进度条 |
150
+ | `pi-mini-mode-context-dots-show` | `true` | 使用单行点阵进度条替代实心进度条 |
143
151
  | `pi-mini-mode-context-percent-show` | `true` | 显示上下文使用百分比 |
144
152
  | `pi-mini-mode-speed-show` | `true` | 显示最新生成速度 |
145
153
  | `pi-mini-mode-speed-unit-show` | `true` | 速度子设置:在数字后追加 `tok/s` |
@@ -51,9 +51,9 @@ export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
51
51
  "pi-mini-mode-session-tokens-show": true,
52
52
  "pi-mini-mode-cache-tokens-show": true,
53
53
  "pi-mini-mode-cost-show": true,
54
- "pi-mini-mode-mcp-show": false,
54
+ "pi-mini-mode-mcp-show": true,
55
55
  "pi-mini-mode-context-show": true,
56
- "pi-mini-mode-context-dots-show": false,
56
+ "pi-mini-mode-context-dots-show": true,
57
57
  "pi-mini-mode-context-percent-show": true,
58
58
  "pi-mini-mode-speed-show": true,
59
59
  "pi-mini-mode-speed-unit-show": true,
@@ -70,6 +70,7 @@ export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
70
70
 
71
71
  const SETTING_IDS = Object.keys(DEFAULT_SETTINGS) as Array<Exclude<keyof MiniLensSettings, "footerOrder">>;
72
72
  export const FOOTER_FIELDS = ["project-branch", "model", "thinking", "branch", "session-tokens", "cache-tokens", "ch", "cost", "mcp", "context", "context-percent", "speed"] as const;
73
+ export const FOOTER_STYLE_OPTIONS = ["context-dots", "speed-unit"] as const;
73
74
 
74
75
  const COPY = {
75
76
  title: "Pi Mini Mode 设置", preview: "预览(示例数据)", lens: "设置", minimal: "极简输出",
@@ -77,7 +78,7 @@ const COPY = {
77
78
  totalDescription: "Total:当前会话分支上的全部 token,含工具上报的 LLM 用量。", cachedDescription: "Cached:累计 cache-read + cache-write token(包含在 Total 中)。", cacheHitDescription: "CH(cache hit):cache-read / (input + cache-read)。Cache write 不计入此比率。",
78
79
  enableMinimalDescription: "开启统一折叠思考、工具和技能过程;关闭恢复 Pi 默认会话历史。",
79
80
  inputEnhancementsDescription: "原生 Ctrl+V 粘贴图片(Windows/WSL:Alt+V);图片显示为 [image1] 标签,光标移入或全屏悬停可预览。空白后 / 选择技能并在光标处插入。Cmd+点击带下划线的图片标签或消息文件路径,用系统默认应用打开;预览及点击需终端支持。关闭仅恢复原生行为。",
80
- tuiRequired: "/pi-mini-mode-settings 需要 TUI 模式", saveFailed: "无法保存 Pi Mini Mode 设置", minimalRequired: "/pi-mini-mode-minimal 需要 TUI 模式", minimalUsage: "用法:/pi-mini-mode-minimal [on|off]", minimalState: "Pi Mini Mode 极简输出:", onboarding: "MCP 数量、点阵样式和仅显示分支默认关闭;项目名称和分支默认开启,与仅显示分支互斥。", keepDefaults: "保留默认", configureNow: "立即配置", applyRecommended: "应用推荐配置", chooseTheme: "选择 Pi Mini Mode 主题(将保存全局主题和全屏模式;重启后生效)", themeSaved: "已保存推荐主题和全屏模式。请重启 Pi;项目设置或命令行参数可能覆盖全局设置。", themeSaveFailed: "无法保存推荐的 Pi 主题和全屏模式;未完成首次配置。", themeApplyFailed: "推荐设置已保存,但当前主题未能立即应用;请重启 Pi。",
81
+ tuiRequired: "/pi-mini-mode-settings 需要 TUI 模式", saveFailed: "无法保存 Pi Mini Mode 设置", minimalRequired: "/pi-mini-mode-minimal 需要 TUI 模式", minimalUsage: "用法:/pi-mini-mode-minimal [on|off]", minimalState: "Pi Mini Mode 极简输出:", onboarding: "几乎全部功能默认开启;仅「仅显示分支」默认关,与「项目与分支」互斥。可用 /pi-mini-mode-settings 再改。", keepDefaults: "保留默认", configureNow: "立即配置", applyRecommended: "应用推荐配置", chooseTheme: "选择 Pi Mini Mode 主题(将保存全局主题和全屏模式;重启后生效)", themeSaved: "已保存推荐主题和全屏模式。请重启 Pi;项目设置或命令行参数可能覆盖全局设置。", themeSaveFailed: "无法保存推荐的 Pi 主题和全屏模式;未完成首次配置。", themeApplyFailed: "推荐设置已保存,但当前主题未能立即应用;请重启 Pi。",
81
82
  } as const;
82
83
 
83
84
  const RECOMMENDED_THEMES = ["cc-dark", "cc-light"] as const;
@@ -108,17 +109,31 @@ export function parseSettings(value: unknown): MiniLensSettings {
108
109
  return settings;
109
110
  }
110
111
 
112
+ /** True when saved JSON is missing a boolean key or a footer field, so defaults can be written back. */
113
+ export function settingsNeedBackfill(raw: unknown, parsed: MiniLensSettings): boolean {
114
+ if (!raw || typeof raw !== "object") return true;
115
+ const candidate = raw as Record<string, unknown>;
116
+ for (const id of SETTING_IDS) {
117
+ if (!Object.hasOwn(candidate, id)) return true;
118
+ }
119
+ if (!Array.isArray(candidate.footerOrder)) return false;
120
+ const order = parsed.footerOrder ?? [];
121
+ return FOOTER_FIELDS.some(id => !order.includes(id));
122
+ }
123
+
111
124
  /** Pi /model and other selectors own Ctrl+S; the editor exposes getText. */
112
125
  export function focusedSelectorOwnsKeys(tui?: { getFocusedComponent?(): unknown } | null): boolean {
113
126
  const focused = tui?.getFocusedComponent?.();
114
127
  return !!focused && typeof focused === "object" && typeof (focused as { getText?: unknown }).getText !== "function";
115
128
  }
116
129
 
117
- export async function loadSettings(path = settingsPath()): Promise<{ settings: MiniLensSettings; exists: boolean }> {
130
+ export async function loadSettings(path = settingsPath()): Promise<{ settings: MiniLensSettings; exists: boolean; backfilled: boolean }> {
118
131
  try {
119
- return { settings: parseSettings(JSON.parse(await readFile(path, "utf8"))), exists: true };
132
+ const raw: unknown = JSON.parse(await readFile(path, "utf8"));
133
+ const settings = parseSettings(raw);
134
+ return { settings, exists: true, backfilled: settingsNeedBackfill(raw, settings) };
120
135
  } catch {
121
- return { settings: { ...DEFAULT_SETTINGS }, exists: false };
136
+ return { settings: { ...DEFAULT_SETTINGS }, exists: false, backfilled: false };
122
137
  }
123
138
  }
124
139
 
@@ -484,10 +499,17 @@ export interface MinimalTurn {
484
499
  /** Wall-clock start of this user-request execution; retained across tool and thinking turns. */
485
500
  startedAt?: number;
486
501
  thinking?: number;
502
+ /** Per-process-index Thinking clocks. Live rows count; completed rows keep endedAt. */
503
+ thinkingClocks?: Array<ThinkingClock | undefined>;
487
504
  awaitingResponse?: boolean;
488
505
  waitingTools?: Array<{ id: string; name: string; startedAt: number }>;
489
506
  }
490
507
 
508
+ export interface ThinkingClock {
509
+ startedAt: number;
510
+ endedAt?: number;
511
+ }
512
+
491
513
  const PROCESS_PREVIEW_LIMIT = 180;
492
514
  const THINKING_SCROLL_INTERVAL_MS = 80;
493
515
 
@@ -524,6 +546,37 @@ export function formatElapsed(startedAt: number | undefined, now = Date.now()):
524
546
  return minutes >= 60 ? `${Math.floor(minutes / 60)}:${String(minutes % 60).padStart(2, "0")}:${remainder}` : `${minutes}:${remainder}`;
525
547
  }
526
548
 
549
+ function ensureThinkingClock(turn: MinimalTurn, index: number, startedAt = Date.now()): ThinkingClock {
550
+ const clocks = turn.thinkingClocks ??= [];
551
+ return clocks[index] ??= { startedAt: turn.startedAt ?? startedAt };
552
+ }
553
+
554
+ function freezeThinkingClock(turn: MinimalTurn | undefined, index: number | undefined, endedAt = Date.now()): void {
555
+ if (!turn || index === undefined) return;
556
+ const clock = turn.thinkingClocks?.[index];
557
+ if (clock && clock.endedAt === undefined) clock.endedAt = endedAt;
558
+ }
559
+
560
+ function freezeOpenThinkingClocks(turn: MinimalTurn | undefined, endedAt = Date.now()): void {
561
+ if (!turn?.thinkingClocks) return;
562
+ for (const clock of turn.thinkingClocks) {
563
+ if (clock && clock.endedAt === undefined) clock.endedAt = endedAt;
564
+ }
565
+ }
566
+
567
+ /** Active Thinking counts from the turn start; completed Thinking keeps the frozen stop time. */
568
+ export function formatThinkingElapsed(
569
+ turn: Pick<MinimalTurn, "startedAt" | "thinkingClocks">,
570
+ processIndex: number,
571
+ active: boolean,
572
+ now = Date.now(),
573
+ ): string {
574
+ const clock = turn.thinkingClocks?.[processIndex];
575
+ if (active) return formatElapsed(clock?.startedAt ?? turn.startedAt, now);
576
+ if (clock?.endedAt != null) return formatElapsed(clock.startedAt, clock.endedAt);
577
+ return "";
578
+ }
579
+
527
580
  function pushProcess(turn: MinimalTurn | undefined, kind: string, value: unknown): void {
528
581
  if (!turn) return;
529
582
  const text = processText(value);
@@ -611,12 +664,14 @@ function visibleMinimalTurns(settings: MiniLensSettings, turns: MinimalTurn[]):
611
664
  return turns.map((turn) => {
612
665
  let thinking: number | undefined;
613
666
  let visibleCount = 0;
667
+ const thinkingClocks: Array<ThinkingClock | undefined> = [];
614
668
  const process = turn.process.filter((line, index) => {
615
669
  const visible = line.startsWith("thinking ") ? settings["pi-mini-mode-minimal-thinking-show"]
616
670
  : /^(tool|call) /.test(line) ? settings["pi-mini-mode-minimal-tools-show"]
617
671
  : line.startsWith("output ") ? settings["pi-mini-mode-minimal-output-show"]
618
672
  : line.startsWith("skill ") ? settings["pi-mini-mode-minimal-skills-show"] : true;
619
673
  if (visible) {
674
+ if (turn.thinkingClocks?.[index]) thinkingClocks[visibleCount] = turn.thinkingClocks[index];
620
675
  if (index === turn.thinking) thinking = visibleCount;
621
676
  visibleCount++;
622
677
  }
@@ -628,6 +683,7 @@ function visibleMinimalTurns(settings: MiniLensSettings, turns: MinimalTurn[]):
628
683
  awaitingResponse: turn.awaitingResponse && settings["pi-mini-mode-minimal-thinking-show"],
629
684
  agentCalls: settings["pi-mini-mode-minimal-tools-show"] ? turn.agentCalls : [],
630
685
  process,
686
+ thinkingClocks: turn.thinkingClocks ? thinkingClocks : undefined,
631
687
  };
632
688
  });
633
689
  }
@@ -793,19 +849,19 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
793
849
  const call = turn.agentCalls?.find(call => call.id === entry.slice(5));
794
850
  if (call && isAgentTool(call.tool ?? call.name) && !isExpanded()) return [];
795
851
  const display = call && agentCallDisplay(call);
796
- return call && display ? [{ title: `${isAgentTool(call.tool ?? call.name) ? "Control" : call.name} ${display.summary}`.trim(), detail: display.detail, state: call.state, id: call.id, thinking: false }] : [];
852
+ return call && display ? [{ title: `${isAgentTool(call.tool ?? call.name) ? "Control" : call.name} ${display.summary}`.trim(), detail: display.detail, state: call.state, id: call.id, thinking: false, processIndex, activeThinking: false }] : [];
797
853
  }
798
854
  const part = entry.match(/^(tool|output|thinking|skill)(?:\s+|$)([\s\S]*)/);
799
855
  const thinking = part?.[1] === "thinking";
800
856
  const activeThinking = thinking && turn.running && turn.thinking === processIndex;
801
857
  const label = ({ tool: "Tool", output: "Output", thinking: "Thinking", skill: "Skill" } as Record<string, string>)[part?.[1] ?? ""] ?? "Process";
802
- return [{ title: `${label} ${part?.[2] ?? entry}`, detail: part?.[2] ?? entry, state: activeThinking ? "running" : "done", id: thinking ? `thinking:${index}:${processIndex}` : "", thinking }];
858
+ return [{ title: `${label} ${part?.[2] ?? entry}`, detail: part?.[2] ?? entry, state: activeThinking ? "running" : "done", id: thinking ? `thinking:${index}:${processIndex}` : "", thinking, processIndex, activeThinking }];
803
859
  });
804
860
  // Older in-memory turns may predate call markers.
805
861
  for (const call of turn.agentCalls ?? []) {
806
862
  if (isAgentTool(call.tool ?? call.name) && !isExpanded()) continue;
807
863
  const display = agentCallDisplay(call);
808
- 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 });
864
+ 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 });
809
865
  }
810
866
  const agentTurnControls: Array<{ runId: string; y: number; width: number; line: string }> = [];
811
867
  const agents = liveAgentView(turn.subAgents ?? [], theme, width, subAgentsExpanded(), true, agentDeadlines, Date.now(), expandedSubagents, agentTurnControls);
@@ -841,8 +897,9 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
841
897
  const split = text.indexOf(" ");
842
898
  const label = split < 0 ? text : text.slice(0, split);
843
899
  const body = split < 0 ? "" : text.slice(split + 1);
844
- const activeThinking = entry.thinking && entry.state === "running";
845
- const thinkingElapsed = entry.thinking ? theme.fg(activeThinking ? "success" : "muted", ` ${formatElapsed(turn.startedAt)}`) : "";
900
+ const activeThinking = !!entry.activeThinking;
901
+ const elapsed = entry.thinking ? formatThinkingElapsed(turn, entry.processIndex, activeThinking) : "";
902
+ const thinkingElapsed = elapsed ? theme.fg(activeThinking ? "success" : "muted", ` ${elapsed}`) : "";
846
903
  const call = turn.agentCalls?.find(call => call.id === entry.id && !isAgentTool(call.tool ?? call.name));
847
904
  const controlId = call?.id ?? (entry.thinking ? entry.id : "");
848
905
  const open = call ? expandedTools.has(call.id) : !!(entry.thinking && expandedThinking.has(entry.id));
@@ -1191,7 +1248,7 @@ export default function (pi: ExtensionAPI) {
1191
1248
  else settingsWebOpening ??= (async () => {
1192
1249
  const { startSettingsWeb } = await import("../lib/settings-web.ts");
1193
1250
  const server = await startSettingsWeb(() => ({
1194
- settings, defaults: DEFAULT_SETTINGS, order: FOOTER_FIELDS,
1251
+ settings, defaults: DEFAULT_SETTINGS, order: FOOTER_FIELDS, options: FOOTER_STYLE_OPTIONS,
1195
1252
  items: settingsItems(settings).filter(item => !isCollapsedReplyChildSetting(item.id)),
1196
1253
  // "regular" means minimal output is saved but cannot mount; the page offers a Pi prompt.
1197
1254
  tuiMode: lastAttachMode ?? null,
@@ -1200,8 +1257,8 @@ export default function (pi: ExtensionAPI) {
1200
1257
  const input = value as Record<string, unknown>;
1201
1258
  for (const [key, entry] of Object.entries(input)) {
1202
1259
  if (key === "footerOrder") {
1203
- if (!Array.isArray(entry) || entry.length !== FOOTER_FIELDS.length || new Set(entry).size !== entry.length
1204
- || entry.some(id => !(FOOTER_FIELDS as readonly unknown[]).includes(id))) throw new TypeError("Invalid order");
1260
+ if (!Array.isArray(entry) || new Set(entry).size !== entry.length
1261
+ || entry.some(id => typeof id !== "string" || !(FOOTER_FIELDS as readonly string[]).includes(id))) throw new TypeError("Invalid order");
1205
1262
  } else if (!SETTING_IDS.includes(key as typeof SETTING_IDS[number]) || typeof entry !== "boolean") throw new TypeError("Invalid setting");
1206
1263
  }
1207
1264
  const next = parseSettings({ ...settings, ...input, onboardingCompleted: true });
@@ -1233,7 +1290,7 @@ export default function (pi: ExtensionAPI) {
1233
1290
  let choice: string | undefined;
1234
1291
  try {
1235
1292
  choice = await ctx.ui.select(
1236
- `Pi Mini Mode ${COPY.preview}\n\n deepseek-v4-flash high ${COPY.totalLabel} 45K ${COPY.cachedLabel} 25K ${COPY.cacheHitLabel} 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s\n\n${COPY.onboarding}`,
1293
+ `Pi Mini Mode ${COPY.preview}\n\n deepseek-v4-flash high ${COPY.totalLabel} 45K ${COPY.cachedLabel} 25K ${COPY.cacheHitLabel} 40.0% $0.012 ◇ MCP 3 500/1.0M ⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀ 1% 120 tok/s\n\n${COPY.onboarding}`,
1237
1294
  [COPY.keepDefaults, COPY.configureNow, COPY.applyRecommended],
1238
1295
  );
1239
1296
  } catch (error) {
@@ -1322,12 +1379,14 @@ export default function (pi: ExtensionAPI) {
1322
1379
  handler: async (_args, ctx) => openSettings(ctx),
1323
1380
  });
1324
1381
  pi.registerCommand("pi-mini-mode-setup", {
1325
- description: "Set up Pi Mini Mode theme and fullscreen mode",
1382
+ description: "Show the first-run setup prompt again",
1326
1383
  handler: async (_args, ctx) => runOnboarding(ctx),
1327
1384
  });
1385
+
1328
1386
  pi.on("session_start", async (_event, ctx) => {
1329
1387
  const loaded = await loadSettings(configPath);
1330
1388
  settings = loaded.settings;
1389
+ if (loaded.exists && loaded.backfilled) await persistSettings(ctx);
1331
1390
  messageCwd = ctx.cwd;
1332
1391
  // 输入增强只在会话中生效,会话开始时再加载;传 getter 让开关变更即时生效,重复调用是幂等的。
1333
1392
  const { installInputEnhancements } = await import("../lib/input-enhancements.ts");
@@ -1357,7 +1416,7 @@ export default function (pi: ExtensionAPI) {
1357
1416
  };
1358
1417
  });
1359
1418
  refresh();
1360
- if (!loaded.exists && ctx.mode === "tui" && ctx.hasUI) await runOnboarding(ctx);
1419
+ if (!settings.onboardingCompleted && ctx.mode === "tui" && ctx.hasUI) await runOnboarding(ctx);
1361
1420
  });
1362
1421
  const syncMinimalBranch = (_event: unknown, ctx: ExtensionContext) => {
1363
1422
  minimalTurns = minimalTurnsFromBranch(ctx.sessionManager.getBranch());
@@ -1390,9 +1449,23 @@ export default function (pi: ExtensionAPI) {
1390
1449
  });
1391
1450
  pi.on("model_select", refresh);
1392
1451
  pi.on("thinking_level_select", refresh);
1452
+ const writeThinkingLine = (turn: MinimalTurn, blockIndex: number, line: string): number => {
1453
+ const existing = minimalMessageIndices.get(blockIndex);
1454
+ if (existing === undefined) {
1455
+ const index = turn.process.length;
1456
+ minimalMessageIndices.set(blockIndex, index);
1457
+ turn.process.push(line);
1458
+ ensureThinkingClock(turn, index);
1459
+ return index;
1460
+ }
1461
+ turn.process[existing] = line;
1462
+ ensureThinkingClock(turn, existing);
1463
+ return existing;
1464
+ };
1393
1465
  pi.on("message_start", (event) => {
1394
1466
  if (event.message.role === "user") {
1395
1467
  if (activeMinimalTurn) {
1468
+ freezeOpenThinkingClocks(activeMinimalTurn);
1396
1469
  activeMinimalTurn.final = pendingMinimalFinal;
1397
1470
  activeMinimalTurn.running = false;
1398
1471
  activeMinimalTurn.thinking = undefined;
@@ -1414,6 +1487,7 @@ export default function (pi: ExtensionAPI) {
1414
1487
  // Background completions can start a new assistant turn without a user message.
1415
1488
  activeMinimalTurn ??= minimalTurns.at(-1);
1416
1489
  if (activeMinimalTurn) {
1490
+ freezeThinkingClock(activeMinimalTurn, activeMinimalTurn.thinking);
1417
1491
  if (activeMinimalTurn.final) (activeMinimalTurn.replies ??= []).push(activeMinimalTurn.final);
1418
1492
  activeMinimalTurn.final = undefined;
1419
1493
  activeMinimalTurn.running = true;
@@ -1432,17 +1506,21 @@ export default function (pi: ExtensionAPI) {
1432
1506
  pi.on("message_update", (event) => {
1433
1507
  const partial = (event.assistantMessageEvent as { partial?: { usage?: UsageLike; content?: Array<Record<string, unknown>> } }).partial;
1434
1508
  if (activeMinimalTurn && partial?.content) {
1509
+ const previousThinking = activeMinimalTurn.thinking;
1435
1510
  activeMinimalTurn.thinking = undefined;
1436
1511
  if (partial.content.length) activeMinimalTurn.awaitingResponse = false;
1437
1512
  for (const [blockIndex, item] of partial.content.entries()) {
1438
1513
  if (item.type !== "thinking") continue;
1439
- const line = `${item.type === "thinking" ? "thinking" : "output"} ${processText(item.thinking ?? item.text)}`;
1440
- const index = minimalMessageIndices.get(blockIndex);
1441
- if (index === undefined) {
1442
- minimalMessageIndices.set(blockIndex, activeMinimalTurn.process.length);
1443
- activeMinimalTurn.process.push(line);
1444
- } else activeMinimalTurn.process[index] = line;
1445
- if (blockIndex === partial.content.length - 1 && event.assistantMessageEvent.type !== "thinking_end") activeMinimalTurn.thinking = minimalMessageIndices.get(blockIndex);
1514
+ const line = `thinking ${processText(item.thinking ?? item.text)}`;
1515
+ const index = writeThinkingLine(activeMinimalTurn, blockIndex, line);
1516
+ if (blockIndex === partial.content.length - 1 && event.assistantMessageEvent.type !== "thinking_end") {
1517
+ activeMinimalTurn.thinking = index;
1518
+ } else {
1519
+ freezeThinkingClock(activeMinimalTurn, index);
1520
+ }
1521
+ }
1522
+ if (previousThinking !== undefined && previousThinking !== activeMinimalTurn.thinking) {
1523
+ freezeThinkingClock(activeMinimalTurn, previousThinking);
1446
1524
  }
1447
1525
  activeMinimalTurn.final = contentText(partial.content) || undefined;
1448
1526
  refreshMinimalOutput();
@@ -1469,6 +1547,8 @@ export default function (pi: ExtensionAPI) {
1469
1547
  pi.on("message_end", (event) => {
1470
1548
  if (event.message.role === "assistant") {
1471
1549
  if (activeMinimalTurn) {
1550
+ freezeThinkingClock(activeMinimalTurn, activeMinimalTurn.thinking);
1551
+ freezeOpenThinkingClocks(activeMinimalTurn);
1472
1552
  activeMinimalTurn.thinking = undefined;
1473
1553
  activeMinimalTurn.awaitingResponse = false;
1474
1554
  activeMinimalTurn.usage = addUsage(activeMinimalTurn.usage ?? EMPTY_USAGE, event.message.usage as UsageLike | undefined);
@@ -1485,6 +1565,10 @@ export default function (pi: ExtensionAPI) {
1485
1565
  for (const [blockIndex, item] of (content as Array<Record<string, unknown>>).entries()) {
1486
1566
  if (item.type !== "thinking" && !(item.type === "text" && content.some((block) => block.type === "toolCall"))) continue;
1487
1567
  const line = `${item.type === "thinking" ? "thinking" : "output"} ${processText(item.thinking ?? item.text)}`;
1568
+ if (item.type === "thinking") {
1569
+ freezeThinkingClock(activeMinimalTurn, writeThinkingLine(activeMinimalTurn, blockIndex, line));
1570
+ continue;
1571
+ }
1488
1572
  const index = minimalMessageIndices.get(blockIndex);
1489
1573
  if (index === undefined) activeMinimalTurn.process.push(line);
1490
1574
  else activeMinimalTurn.process[index] = line;
@@ -1505,6 +1589,7 @@ export default function (pi: ExtensionAPI) {
1505
1589
  pi.on("tool_execution_start", (event) => {
1506
1590
  toolStarts.set(event.toolCallId, Date.now());
1507
1591
  if (activeMinimalTurn) {
1592
+ freezeThinkingClock(activeMinimalTurn, activeMinimalTurn.thinking);
1508
1593
  activeMinimalTurn.thinking = undefined;
1509
1594
  activeMinimalTurn.awaitingResponse = false;
1510
1595
  (activeMinimalTurn.agentCalls ??= []).push(agentCall(event.toolCallId, event.toolName, event.args));
@@ -1571,7 +1656,11 @@ export default function (pi: ExtensionAPI) {
1571
1656
  pi.on("agent_end", refresh);
1572
1657
  pi.on("agent_settled", () => {
1573
1658
  if (!activeMinimalTurn) return;
1574
- for (const turn of minimalTurns) { turn.running = false; turn.thinking = undefined; }
1659
+ for (const turn of minimalTurns) {
1660
+ freezeOpenThinkingClocks(turn);
1661
+ turn.running = false;
1662
+ turn.thinking = undefined;
1663
+ }
1575
1664
  activeMinimalTurn.final = pendingMinimalFinal;
1576
1665
  activeMinimalTurn = undefined;
1577
1666
  pendingMinimalFinal = "";
package/lib/settings.html CHANGED
@@ -20,9 +20,9 @@
20
20
  <div><code id="noticePrompt"></code><button type="button" id="copyPrompt"></button></div>
21
21
  </div>
22
22
  <div role="status" aria-live="polite"><span id="status"></span><button id="retry" hidden></button></div>
23
- <section><h2 id="featuresHeading"></h2><div class="features" id="features"></div></section>
24
23
  <section><h2 id="fieldsHeading"></h2><p class="hint" id="dragHint"></p><div id="preview" role="group" tabindex="0"></div><div class="grid" id="fields"></div></section>
25
24
  <section><h2 id="optionsHeading"></h2><div class="grid" id="options"></div></section>
25
+ <section><h2 id="featuresHeading"></h2><div class="features" id="features"></div></section>
26
26
  </main>
27
27
  <script>
28
28
  const $=id=>document.getElementById(id),token=location.hash.slice(1);
@@ -41,13 +41,13 @@ const I18N={
41
41
  {id:'status',title:'状态栏指标',body:'一行看清会话状态,随终端宽度自动取舍,不换行。',points:['模型与思考等级,会话与缓存 Token、缓存命中率、费用估算','上下文用量进度条与百分比','生成速度 tok/s,从第一个输出 token 起算,不含等待首字'],hint:'勾选需要的字段,拖拽预览中的条目即可排序。'},
42
42
  {id:'minimal',setting:'pi-mini-mode-minimal-show',title:'极简输出',body:'把对话收成结论:思考、工具与技能汇成一棵按时间排序的可折叠过程树。',points:['长用户消息默认保留前四行,点击折叠控件展开全文','子代理行可展开活动记录与最终输出','Ctrl+O 展开或收起完整过程树,新问题默认收起','最终 Markdown 流畅呈现,失败与中断明确标记'],hint:'/pi-mini-mode-minimal on|off · /pi-mini-mode-prompts · /pi-mini-mode-history'},
43
43
  {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'输入增强',body:'让输入框和消息里的图片、技能与文件路径直接可用。',points:['光标移入图片路径即可预览,全屏编辑器也支持悬停','图片路径收纳为 [image1] 标签,提交时保留原图','空白后输入 / 就地搜索技能,并在光标处插入','点击图片标签或消息中的文件路径,用系统默认应用打开'],hint:'Ctrl+V 粘贴图片(Windows/WSL 使用 Alt+V)'},
44
- {id:'themes',title:'明暗主题',body:'内置 cc-dark 与 cc-light 两套主题,Markdown、代码高亮、表格与 Mermaid 图表一并适配明暗。',points:['用户消息使用主题的用户背景色,与正文清晰区分','不支持、不完整或过宽的图表保留源文本'],hint:'/pi-mini-mode-setup 重新选择主题与全局全屏模式'}
44
+ {id:'themes',title:'明暗主题',body:'内置 cc-dark 与 cc-light 两套主题,Markdown、代码高亮、表格与 Mermaid 图表一并适配明暗。',points:['用户消息使用主题的用户背景色,与正文清晰区分','不支持、不完整或过宽的图表保留源文本'],hint:'/pi-mini-mode-settings 配置所有选项'}
45
45
  ],
46
46
  en:[
47
47
  {id:'status',title:'Status bar metrics',body:'The whole session state on one line, trimmed to fit narrow terminals instead of wrapping.',points:['Model and thinking level, session and cache tokens, cache hit rate, cost estimate','Context usage bar with percentage','Speed in tok/s, measured from the first output token, excluding time to first token'],hint:'Enable the items you need, then drag entries in the preview to reorder.'},
48
48
  {id:'minimal',setting:'pi-mini-mode-minimal-show',title:'Minimal transcript',body:'Turns the conversation into conclusions: thinking, tools and skills collapse into one chronological, foldable tree.',points:['Long user messages keep four lines; click the fold control to expand','Subagent rows expand to activity and final output','Ctrl+O expands or collapses the full process tree; new questions start collapsed','Final Markdown streams plainly; failures and interrupts are marked'],hint:'/pi-mini-mode-minimal on|off · /pi-mini-mode-prompts · /pi-mini-mode-history'},
49
49
  {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:['Preview an image as soon as the cursor enters its path; hovering works in fullscreen','Image paths collapse to [image1] labels while keeping the original path on submit','Type / after a space to search skills and insert one at the cursor','Click image labels or file paths in messages to open them in the default app'],hint:'Ctrl+V pastes images (Windows/WSL: Alt+V)'},
50
- {id:'themes',title:'Light and dark themes',body:'Built-in cc-dark and cc-light adapt Markdown, code highlighting, tables and Mermaid diagrams to the color scheme.',points:['User messages use the theme user background to stand apart from the body','Unsupported, incomplete or overly wide diagrams keep their source text'],hint:'/pi-mini-mode-setup to pick a theme and global fullscreen mode again'}
50
+ {id:'themes',title:'Light and dark themes',body:'Built-in cc-dark and cc-light adapt Markdown, code highlighting, tables and Mermaid diagrams to the color scheme.',points:['User messages use the theme user background to stand apart from the body','Unsupported, incomplete or overly wide diagrams keep their source text'],hint:'/pi-mini-mode-settings to configure all options'}
51
51
  ]
52
52
  },
53
53
  reset:{zh:'恢复默认',en:'Reset defaults'},
@@ -173,7 +173,7 @@ function render(){
173
173
  renderNotice();
174
174
  $('fields').replaceChildren(...order.map(id=>checkbox(id,key(id))));
175
175
  $('features').replaceChildren(...t('featureList').map(feature));
176
- $('options').replaceChildren(...['context-dots','speed-unit'].map(id=>checkbox(id,FIELD_KEY[id])));
176
+ $('options').replaceChildren(...(data.options||[]).map(id=>checkbox(id,FIELD_KEY[id]||key(id))));
177
177
  preview();
178
178
  }
179
179
  function renderNotice(){
@@ -201,9 +201,10 @@ function setLang(next){lang=next;localStorage.piMiniModeLang=lang;render()}
201
201
  $('lang-zh').onclick=()=>setLang('zh');
202
202
  $('lang-en').onclick=()=>setLang('en');
203
203
  $('retry').onclick=save;
204
- $('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=[...data.order];render();change()};
204
+ function mergeOrder(base,all){const next=[...new Set((base||[]).filter(id=>(all||[]).includes(id)))];for(const id of all||[])if(!next.includes(id))next.push(id);return next}
205
+ $('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=mergeOrder(data.order,data.order);render();change()};
205
206
  window.addEventListener('beforeunload',event=>{if(dirty||saving){event.preventDefault();event.returnValue=''}});
206
207
  applyLang();status(t('connecting'));
207
- request('GET').then(value=>{data=value;state={...data.settings};order=[...(state.footerOrder||data.order)];render();$('reset').disabled=false;status(t('connected'))}).catch(()=>status(t('reconnect'),true));
208
+ request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);render();$('reset').disabled=false;status(t('connected'))}).catch(()=>status(t('reconnect'),true));
208
209
  </script>
209
210
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@each1024/pi-mini-mode",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
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": {