@each1024/pi-mini-mode 1.0.0 → 1.0.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 +28 -35
- package/README.zh-CN.md +28 -33
- package/extensions/footer-status.ts +1 -2
- package/lib/input-enhancements.ts +9 -5
- package/lib/settings.html +19 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
<img src="assets/readme-cover.en.svg" alt="Pi Mini Mode — Less noise. More focus. Image input, foldable conversations, subagents, themes and a live footer." width="100%">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/eachann1024/pi-mini-mode/main/assets/readme-cover.en.svg" alt="Pi Mini Mode — Less noise. More focus. Image input, foldable conversations, subagents, themes and a live footer." width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
[中文](README.zh-CN.md) · [Install](#install) · [Features](#features) · [
|
|
5
|
+
[中文](https://github.com/eachann1024/pi-mini-mode/blob/main/README.zh-CN.md) · [Install](#install) · [Features](#features) · [Reference](#reference)
|
|
6
6
|
|
|
7
7
|
# Pi Mini Mode
|
|
8
8
|
|
|
@@ -10,15 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
An everyday refinement for [Pi](https://pi.dev), not just a footer. Preview images at the cursor, fold long messages and process details, inspect subagent work, and keep your session’s essential signals in view.
|
|
12
12
|
|
|
13
|
+
<details>
|
|
14
|
+
<summary>See the full interface</summary>
|
|
13
15
|
|
|
16
|
+
<img width="1698" height="1588" alt="Pi Mini Mode interface" src="https://github.com/user-attachments/assets/9990b080-f82b-4dd0-bc7b-a0cdded72181" />
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
https://github.com/user-attachments/assets/cd972993-a6f9-4399-81a6-6e0d540dec9a
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
</details>
|
|
22
19
|
|
|
23
20
|
## Install
|
|
24
21
|
|
|
@@ -26,7 +23,7 @@ https://github.com/user-attachments/assets/cd972993-a6f9-4399-81a6-6e0d540dec9a
|
|
|
26
23
|
pi install npm:@each1024/pi-mini-mode
|
|
27
24
|
```
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
In an open Pi session, run Pi's built-in `/reload` command. On first use, choose **Apply recommended setup** for a bundled theme and fullscreen mode, then restart Pi for fullscreen to take effect. Configure this extension any time with `/pi-mini-mode-settings`. Project settings and CLI flags may override global settings.
|
|
30
27
|
|
|
31
28
|
**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.
|
|
32
29
|
|
|
@@ -43,6 +40,8 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
43
40
|
|
|
44
41
|
### 01 / Input, refined
|
|
45
42
|
|
|
43
|
+
<img width="1092" height="764" alt="Image previews and compact labels in Pi Mini Mode" src="https://github.com/user-attachments/assets/2ea6d037-d3f0-423c-8588-17992a49d445" />
|
|
44
|
+
|
|
46
45
|
**Images at your cursor.** Move the editing cursor into an image path or compact label to preview it. Fullscreen also supports editor hover. Press `Esc` to dismiss.
|
|
47
46
|
|
|
48
47
|
**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.
|
|
@@ -55,14 +54,18 @@ Paste images with `Ctrl+V` (`Alt+V` on Windows/WSL). Disabling input enhancement
|
|
|
55
54
|
|
|
56
55
|
Enable **Minimal output** in `/pi-mini-mode-settings`.
|
|
57
56
|
|
|
57
|
+
<img width="1092" height="764" alt="Folded process tree in minimal output" src="https://github.com/user-attachments/assets/eb8c88f6-84af-499e-b105-5395b4f02e66" />
|
|
58
|
+
|
|
58
59
|
- **Long prompts, folded.** In fullscreen minimal mode, long user messages show the first four rendered rows. Click the fold control to reveal the rest. Complete fenced code blocks stay intact.
|
|
59
|
-
- **Subagents, in plain sight.** Click a subagent row to expand its available activity and message/final output. A dispatch receipt or returned tool call is not a completed background task.
|
|
60
|
+
- **Subagents, in plain sight.** Click a subagent row to expand its available activity and message/final output. In minimal mode, this extension uses `Ctrl+S` to expand or collapse completed subagent summaries; Pi's focused selectors keep their own keys. A dispatch receipt or returned tool call is not a completed background task.
|
|
60
61
|
- **A process tree, not a wall of output.** Thinking, tools and skill reads share one chronological tree. The latest summaries stay visible, including the latest thinking; `Ctrl+O` expands or collapses the full process. New questions start collapsed.
|
|
61
62
|
- **Tool details on demand.** Expand a tool or thinking entry, including the latest thinking, using its fold control. Thinking starts collapsed and only expands or collapses manually, including while running. Tool details show saved text, not the original custom renderer or image output.
|
|
62
63
|
- **Room for the answer.** Final Markdown streams without extra headings or backgrounds. Failures and interruptions stay explicit. Folding changes presentation, not stored session messages.
|
|
63
64
|
|
|
64
65
|
Turn **Minimal output** off in settings to restore native Pi history.
|
|
65
66
|
|
|
67
|
+
<img width="1092" height="764" alt="Expanded process details" src="https://github.com/user-attachments/assets/53f5aa28-4b96-45db-b02e-0108aa9e68bc" />
|
|
68
|
+
|
|
66
69
|
### 03 / Session, in focus
|
|
67
70
|
|
|
68
71
|
**Light and dark, considered.** Includes `cc-light` and `cc-dark`, derived from [pi-cc-extensions](https://github.com/minuque/pi-cc-extensions) under MIT. User messages use the theme’s user-message surface; Markdown, highlighted code, tables and supported Mermaid diagrams adapt to the theme. Unsupported, incomplete or over-wide diagrams retain their source.
|
|
@@ -72,7 +75,7 @@ Turn **Minimal output** off in settings to restore native Pi history.
|
|
|
72
75
|
<details>
|
|
73
76
|
<summary>See the footer settings and demo</summary>
|
|
74
77
|
|
|
75
|
-
[](assets/pi-mini-mode-settings.jpg)
|
|
78
|
+
[](https://raw.githubusercontent.com/eachann1024/pi-mini-mode/main/assets/pi-mini-mode-settings.jpg)
|
|
76
79
|
|
|
77
80
|
[Watch the footer settings demo](https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763)
|
|
78
81
|
|
|
@@ -80,17 +83,6 @@ This earlier screenshot and recording show footer configuration, not the newer i
|
|
|
80
83
|
|
|
81
84
|
</details>
|
|
82
85
|
|
|
83
|
-
## Commands
|
|
84
|
-
|
|
85
|
-
| Command / shortcut | Purpose |
|
|
86
|
-
| --- | --- |
|
|
87
|
-
| `/pi-mini-mode-settings` | Configure fields, input enhancements and minimal output |
|
|
88
|
-
| `Ctrl+O` | Expand or collapse the complete process tree |
|
|
89
|
-
| `Ctrl+S` | Expand or collapse completed subagent rows; yields to Pi `/model`, `/thinking`, and other selectors |
|
|
90
|
-
| `/reload` | Reload the extension after installation or source changes |
|
|
91
|
-
|
|
92
|
-
Subagent rows have their own click-to-expand control; supported third-party widgets retain native detail shortcuts.
|
|
93
|
-
|
|
94
86
|
## Compatibility
|
|
95
87
|
|
|
96
88
|
- **Images:** previews require a terminal image protocol; unsupported terminals show a hint. 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).
|
|
@@ -104,7 +96,9 @@ Subagent rows have their own click-to-expand control; supported third-party widg
|
|
|
104
96
|
<details>
|
|
105
97
|
<summary><strong>First run & configuration</strong> — defaults, controls, and settings file</summary>
|
|
106
98
|
|
|
107
|
-
On the first interactive TUI session, Pi Mini Mode shows a preview.
|
|
99
|
+
On the first interactive TUI session, Pi Mini Mode shows a preview. **Branch-only**, **Cached tokens**, and **MCP count** are off by default; branch-only is mutually exclusive with **project & branch**. Change anything later with `/pi-mini-mode-settings`.
|
|
100
|
+
|
|
101
|
+
Example with optional Cached and MCP fields enabled:
|
|
108
102
|
|
|
109
103
|
```text
|
|
110
104
|
deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500/1.0M ⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀ 1% 120 tok/s
|
|
@@ -126,13 +120,16 @@ Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/pi-m
|
|
|
126
120
|
|
|
127
121
|
```json
|
|
128
122
|
{
|
|
123
|
+
"pi-mini-mode-project-branch-show": true,
|
|
124
|
+
"pi-mini-mode-branch-show": false,
|
|
129
125
|
"pi-mini-mode-model-show": true,
|
|
130
126
|
"pi-mini-mode-thinking-show": true,
|
|
131
127
|
"pi-mini-mode-ch-show": true,
|
|
132
128
|
"pi-mini-mode-session-tokens-show": true,
|
|
133
|
-
"pi-mini-mode-cache-tokens-show":
|
|
129
|
+
"pi-mini-mode-cache-tokens-show": false,
|
|
130
|
+
"pi-mini-mode-cache-miss-show": true,
|
|
134
131
|
"pi-mini-mode-cost-show": true,
|
|
135
|
-
"pi-mini-mode-mcp-show":
|
|
132
|
+
"pi-mini-mode-mcp-show": false,
|
|
136
133
|
"pi-mini-mode-context-show": true,
|
|
137
134
|
"pi-mini-mode-context-dots-show": true,
|
|
138
135
|
"pi-mini-mode-context-percent-show": true,
|
|
@@ -146,13 +143,16 @@ Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/pi-m
|
|
|
146
143
|
|
|
147
144
|
| Key | Default | Controls |
|
|
148
145
|
| --- | --- | --- |
|
|
146
|
+
| `pi-mini-mode-project-branch-show` | `true` | Project name and branch |
|
|
147
|
+
| `pi-mini-mode-branch-show` | `false` | Branch only, instead of project and branch |
|
|
149
148
|
| `pi-mini-mode-model-show` | `true` | Model ID without provider prefix |
|
|
150
149
|
| `pi-mini-mode-thinking-show` | `true` | Thinking level |
|
|
151
150
|
| `pi-mini-mode-ch-show` | `true` | Session cache-hit rate (`CH`) |
|
|
152
151
|
| `pi-mini-mode-session-tokens-show` | `true` | Accumulated session tokens (`Total`) |
|
|
153
|
-
| `pi-mini-mode-cache-tokens-show` | `
|
|
152
|
+
| `pi-mini-mode-cache-tokens-show` | `false` | Accumulated cache read + cache write tokens |
|
|
153
|
+
| `pi-mini-mode-cache-miss-show` | `true` | Estimated cache misses when detected |
|
|
154
154
|
| `pi-mini-mode-cost-show` | `true` | Estimated session list price |
|
|
155
|
-
| `pi-mini-mode-mcp-show` | `
|
|
155
|
+
| `pi-mini-mode-mcp-show` | `false` | Enabled MCP server count |
|
|
156
156
|
| `pi-mini-mode-context-show` | `true` | Used/total context tokens and progress bar |
|
|
157
157
|
| `pi-mini-mode-context-dots-show` | `true` | Use a single-line dot-matrix bar instead of the solid bar |
|
|
158
158
|
| `pi-mini-mode-context-percent-show` | `true` | Context-use percentage |
|
|
@@ -207,13 +207,6 @@ The backup workflow needs the package’s npm Trusted Publisher configured for t
|
|
|
207
207
|
|
|
208
208
|
</details>
|
|
209
209
|
|
|
210
|
-
<details>
|
|
211
|
-
<summary><strong>Collaboration guidance</strong></summary>
|
|
212
|
-
|
|
213
|
-
The main session owns requirement alignment, risk research, the complete solution, task scheduling, key decisions, integration, and the final summary. Before implementation, it should investigate the key risks, boundaries, acceptance criteria, and solution. Once authorized, use subagents aggressively and parallelize independent work to save time, while respecting relevance, risk, budget, concurrency, and single-writer constraints. Use the `low` model by default for most tasks and subagents; upgrade only for complex reasoning, key decisions, or risk reviews when necessary.
|
|
214
|
-
|
|
215
|
-
</details>
|
|
216
|
-
|
|
217
210
|
---
|
|
218
211
|
|
|
219
212
|
[MIT License](LICENSE) · Built for [Pi](https://pi.dev)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
<img src="assets/readme-cover.zh-CN.svg" alt="Pi Mini Mode — 少一点干扰,多一点专注。图片输入、可折叠对话、子代理、明暗主题与实时页脚。" width="100%">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/eachann1024/pi-mini-mode/main/assets/readme-cover.zh-CN.svg" alt="Pi Mini Mode — 少一点干扰,多一点专注。图片输入、可折叠对话、子代理、明暗主题与实时页脚。" width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
[English](README.md) · [安装](#安装) · [功能](#功能) · [
|
|
5
|
+
[English](https://github.com/eachann1024/pi-mini-mode/blob/main/README.md) · [安装](#安装) · [功能](#功能) · [参考](#参考)
|
|
6
6
|
|
|
7
7
|
# Pi Mini Mode
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
**少一点干扰。多一点专注。**
|
|
11
10
|
|
|
12
11
|
为 [Pi](https://pi.dev) 的日常工作做一点精细的改进,不止于页脚。光标处预览图片,折叠长消息和过程详情,展开子代理工作,让重要的会话状态始终清晰。
|
|
13
12
|
|
|
14
|
-
<
|
|
13
|
+
<details>
|
|
14
|
+
<summary>查看完整界面</summary>
|
|
15
15
|
|
|
16
|
+
<img width="892" height="797" alt="Pi Mini Mode 完整界面" src="https://github.com/user-attachments/assets/8f7abdc8-646e-4ded-8009-b58d2833c1f4" />
|
|
16
17
|
|
|
18
|
+
</details>
|
|
17
19
|
|
|
18
20
|
## 安装
|
|
19
21
|
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
pi install npm:@each1024/pi-mini-mode
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
已打开的 Pi 会话中,运行 Pi 自带的 `/reload`。首次使用选择 **应用推荐配置**,设置内置主题和全屏模式,重启 Pi 后全屏才会生效。之后可用 `/pi-mini-mode-settings` 随时配置本扩展。项目设置和命令行参数可能覆盖全局设置。
|
|
25
27
|
|
|
26
28
|
**需要 Pi ≥ 0.84.0。** 输入增强和极简输出默认开启。极简模式使用私有 **Pi 0.85.x** 布局适配器,启用前请查看[兼容性](#兼容性)。
|
|
27
29
|
|
|
@@ -38,6 +40,8 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
38
40
|
|
|
39
41
|
### 01 / 输入,更顺手
|
|
40
42
|
|
|
43
|
+
<img width="1092" height="764" alt="图片预览与紧凑标签" src="https://github.com/user-attachments/assets/2ea6d037-d3f0-423c-8588-17992a49d445" />
|
|
44
|
+
|
|
41
45
|
**图片,随光标浮现。** 编辑光标移入图片路径或紧凑标签,即可预览。全屏编辑器也支持悬停,按 `Esc` 关闭。
|
|
42
46
|
|
|
43
47
|
**收起路径,保留原图。** 输入框和消息中的图片路径收纳为带下划线的 `[image1]` 标签,提交时保留原始路径。使用终端的链接点击手势,即可通过系统默认应用打开原图或其他文件。
|
|
@@ -46,21 +50,22 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
46
50
|
|
|
47
51
|
使用 `Ctrl+V` 粘贴图片,Windows/WSL 使用 `Alt+V`。关闭输入增强不会关闭 Pi 原生剪贴板功能。
|
|
48
52
|
|
|
49
|
-
<img width="1225" height="918" alt="image" src="https://github.com/user-attachments/assets/4cde0f64-35c9-4b15-9650-d8ba48863e6a" />
|
|
50
|
-
|
|
51
|
-
|
|
52
53
|
### 02 / 过程,更安静
|
|
53
54
|
|
|
54
55
|
在 `/pi-mini-mode-settings` 中开启 **极简输出**。
|
|
55
56
|
|
|
57
|
+
<img width="1092" height="764" alt="极简输出中的过程树" src="https://github.com/user-attachments/assets/eb8c88f6-84af-499e-b105-5395b4f02e66" />
|
|
58
|
+
|
|
56
59
|
- **长消息,自动折叠。** 全屏极简模式下,长用户消息默认保留前四个显示行。点击折叠控件展开全文。完整代码围栏保持完整。
|
|
57
|
-
- **子代理,清晰可查。**
|
|
60
|
+
- **子代理,清晰可查。** 点击子代理行,展开可用的活动记录与消息/最终输出。极简模式下,本扩展用 `Ctrl+S` 展开/收起已完成的子代理摘要;Pi 当前聚焦的选择器保留自己的快捷键。任务派发回执或工具调用返回,不等于后台任务已完成。
|
|
58
61
|
- **过程是一棵树,而非满屏输出。** 思考、工具与技能读取汇入同一棵时间顺序树,显示最新摘要,包括最新一条思考;`Ctrl+O` 展开/收起完整过程,新问题默认收起。
|
|
59
62
|
- **工具详情,按需展开。** 点击工具或思考条目的折叠控件,最新一条思考也可以展开。思考默认收起,进行中与结束后均只由手动操作展开或收起。工具详情展示保存的文本,不还原原生自定义渲染器或图片输出。
|
|
60
63
|
- **把空间留给答案。** 最终 Markdown 流式呈现,不添加额外标题或背景。失败和中断明确标记;折叠只改变显示,不删除原始会话消息。
|
|
61
64
|
|
|
62
65
|
在设置中关闭 **极简输出** 即恢复 Pi 原生历史。
|
|
63
66
|
|
|
67
|
+
<img width="1092" height="764" alt="展开后的过程详情" src="https://github.com/user-attachments/assets/53f5aa28-4b96-45db-b02e-0108aa9e68bc" />
|
|
68
|
+
|
|
64
69
|
### 03 / 状态,更清晰
|
|
65
70
|
|
|
66
71
|
**明暗,皆有章法。** 自带 `cc-light` 与 `cc-dark`,源自 [pi-cc-extensions](https://github.com/minuque/pi-cc-extensions),采用 MIT 许可。用户消息使用主题的用户背景色;Markdown、代码高亮、表格及支持的 Mermaid 图表适配明暗主题。不支持、不完整或过宽的图表保留源文本。
|
|
@@ -70,7 +75,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
70
75
|
<details>
|
|
71
76
|
<summary>查看页脚设置截图与演示</summary>
|
|
72
77
|
|
|
73
|
-
[](assets/pi-mini-mode-settings.jpg)
|
|
78
|
+
[](https://raw.githubusercontent.com/eachann1024/pi-mini-mode/main/assets/pi-mini-mode-settings.jpg)
|
|
74
79
|
|
|
75
80
|
[观看页脚设置演示](https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763)
|
|
76
81
|
|
|
@@ -78,17 +83,6 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
78
83
|
|
|
79
84
|
</details>
|
|
80
85
|
|
|
81
|
-
## 命令速查
|
|
82
|
-
|
|
83
|
-
| 命令/快捷键 | 用途 |
|
|
84
|
-
| --- | --- |
|
|
85
|
-
| `/pi-mini-mode-settings` | 配置字段、输入增强和极简输出 |
|
|
86
|
-
| `Ctrl+O` | 展开/收起完整过程树 |
|
|
87
|
-
| `Ctrl+S` | 展开/收起已完成的子代理行;打开 `/model`、`/thinking` 等选择器时交给 Pi |
|
|
88
|
-
| `/reload` | 安装或修改源码后重载扩展 |
|
|
89
|
-
|
|
90
|
-
子代理行有独立的点击展开控件;受支持的第三方小组件保留原生详情快捷键。
|
|
91
|
-
|
|
92
86
|
## 兼容性
|
|
93
87
|
|
|
94
88
|
- **图片:** 预览依赖终端图片协议,不支持时显示提示。读取上限 **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)。
|
|
@@ -102,7 +96,9 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
102
96
|
<details>
|
|
103
97
|
<summary><strong>首次使用与配置</strong></summary>
|
|
104
98
|
|
|
105
|
-
首次进入交互式 TUI 会话时,Pi Mini Mode
|
|
99
|
+
首次进入交互式 TUI 会话时,Pi Mini Mode 显示设置预览。「仅显示分支」「缓存 token」「MCP」默认关闭;「仅显示分支」与「项目与分支」互斥。之后可用 `/pi-mini-mode-settings` 再改。
|
|
100
|
+
|
|
101
|
+
以下示例开启了可选的 Cached 和 MCP 字段:
|
|
106
102
|
|
|
107
103
|
```text
|
|
108
104
|
deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500/1.0M ⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀ 1% 120 tok/s
|
|
@@ -114,13 +110,16 @@ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500
|
|
|
114
110
|
|
|
115
111
|
```json
|
|
116
112
|
{
|
|
113
|
+
"pi-mini-mode-project-branch-show": true,
|
|
114
|
+
"pi-mini-mode-branch-show": false,
|
|
117
115
|
"pi-mini-mode-model-show": true,
|
|
118
116
|
"pi-mini-mode-thinking-show": true,
|
|
119
117
|
"pi-mini-mode-ch-show": true,
|
|
120
118
|
"pi-mini-mode-session-tokens-show": true,
|
|
121
|
-
"pi-mini-mode-cache-tokens-show":
|
|
119
|
+
"pi-mini-mode-cache-tokens-show": false,
|
|
120
|
+
"pi-mini-mode-cache-miss-show": true,
|
|
122
121
|
"pi-mini-mode-cost-show": true,
|
|
123
|
-
"pi-mini-mode-mcp-show":
|
|
122
|
+
"pi-mini-mode-mcp-show": false,
|
|
124
123
|
"pi-mini-mode-context-show": true,
|
|
125
124
|
"pi-mini-mode-context-dots-show": true,
|
|
126
125
|
"pi-mini-mode-context-percent-show": true,
|
|
@@ -134,13 +133,16 @@ deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 ◇ MCP 3 500
|
|
|
134
133
|
|
|
135
134
|
| 配置项 | 默认值 | 说明 |
|
|
136
135
|
| --- | --- | --- |
|
|
136
|
+
| `pi-mini-mode-project-branch-show` | `true` | 显示项目名称与分支 |
|
|
137
|
+
| `pi-mini-mode-branch-show` | `false` | 仅显示分支,代替项目与分支 |
|
|
137
138
|
| `pi-mini-mode-model-show` | `true` | 显示不含 provider 前缀的模型 ID |
|
|
138
139
|
| `pi-mini-mode-thinking-show` | `true` | 显示思考级别 |
|
|
139
140
|
| `pi-mini-mode-ch-show` | `true` | 显示会话缓存命中率(`CH`) |
|
|
140
141
|
| `pi-mini-mode-session-tokens-show` | `true` | 显示会话累计令牌(`Total`) |
|
|
141
|
-
| `pi-mini-mode-cache-tokens-show` | `
|
|
142
|
+
| `pi-mini-mode-cache-tokens-show` | `false` | 显示缓存读取与写入令牌(已包含在 Total 中) |
|
|
143
|
+
| `pi-mini-mode-cache-miss-show` | `true` | 检测到缓存 miss 时显示估算量 |
|
|
142
144
|
| `pi-mini-mode-cost-show` | `true` | 显示会话费用估算 |
|
|
143
|
-
| `pi-mini-mode-mcp-show` | `
|
|
145
|
+
| `pi-mini-mode-mcp-show` | `false` | 显示已启用的 MCP 服务器数量 |
|
|
144
146
|
| `pi-mini-mode-context-show` | `true` | 显示已用/总上下文令牌和进度条 |
|
|
145
147
|
| `pi-mini-mode-context-dots-show` | `true` | 使用单行点阵进度条替代实心进度条 |
|
|
146
148
|
| `pi-mini-mode-context-percent-show` | `true` | 显示上下文使用百分比 |
|
|
@@ -198,13 +200,6 @@ python3 test/minimal-pty.py
|
|
|
198
200
|
|
|
199
201
|
</details>
|
|
200
202
|
|
|
201
|
-
<details>
|
|
202
|
-
<summary><strong>协作说明</strong></summary>
|
|
203
|
-
|
|
204
|
-
主会话负责需求对齐、风险调研、完整方案、任务调度、关键决策、整合与总结;执行前应先调查关键风险点、边界、验收标准和解决方案。获得授权后,应积极使用子代理并并行拆分独立任务以节省时间,同时遵守相关性、风险、预算、并发和单一修改负责人约束。绝大部分任务及子代理默认使用 `low` 模型,仅在复杂推理、关键决策或风险审查确有需要时升级。
|
|
205
|
-
|
|
206
|
-
</details>
|
|
207
|
-
|
|
208
203
|
---
|
|
209
204
|
|
|
210
205
|
[MIT License](LICENSE) · 为 [Pi](https://pi.dev) 打造
|
|
@@ -5,7 +5,7 @@ import { diagramMarkdown, isFencedMarkdown, renderMinimalMarkdown } from "../lib
|
|
|
5
5
|
import { minimalSurface, paintExpandedHeading } from "../lib/minimal-theme.ts";
|
|
6
6
|
import { Markdown, matchesKey, isKeyRelease, isKeyRepeat, sliceByColumn, type SettingItem, Text, type TuiMouseEvent, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
7
7
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
8
|
-
import type
|
|
8
|
+
import { installInputEnhancements, type InputEnhancementsCleanup } from "../lib/input-enhancements.ts";
|
|
9
9
|
import { linkMessageFiles } from "../lib/file-links.ts";
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -1367,7 +1367,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1367
1367
|
if (loaded.exists && loaded.backfilled) await persistSettings(ctx);
|
|
1368
1368
|
messageCwd = ctx.cwd;
|
|
1369
1369
|
// 输入增强只在会话中生效,会话开始时再加载;传 getter 让开关变更即时生效,重复调用是幂等的。
|
|
1370
|
-
const { installInputEnhancements } = await import("../lib/input-enhancements.ts");
|
|
1371
1370
|
cleanupInputEnhancements = installInputEnhancements(pi, ctx, () => settings["pi-mini-mode-input-enhancements"]);
|
|
1372
1371
|
minimalTurns = minimalTurnsFromBranch(ctx.sessionManager.getBranch());
|
|
1373
1372
|
activeMinimalTurn = undefined;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { CustomEditor, stripFrontmatter, type ExtensionAPI, type ExtensionContext, type InputEvent, type InputEventResult } from "@earendil-works/pi-coding-agent";
|
|
15
15
|
import {
|
|
16
|
-
allocateImageId, getImageDimensions, renderImage, getCapabilities, setCapabilities, getOsc8LinkAtColumn, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth,
|
|
16
|
+
allocateImageId, getCellDimensions, getImageDimensions, renderImage, getCapabilities, setCapabilities, setCellDimensions, getOsc8LinkAtColumn, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth,
|
|
17
17
|
type AutocompleteItem, type AutocompleteProvider, type EditorComponent, type TuiMouseEvent, type TUI, type OverlayHandle, type OverlayOptions,
|
|
18
18
|
} from "@earendil-works/pi-tui";
|
|
19
19
|
import { filePaths, inputCapabilities, linkRenderedPath, localPath, webPaths } from "./file-links.ts";
|
|
@@ -456,6 +456,7 @@ export function installInputEnhancements(pi: ExtensionAPI, ctx: ExtensionContext
|
|
|
456
456
|
// /reload clears the editor before session_start, so the saved factory can still be current while the live editor is unwrapped.
|
|
457
457
|
const active = ctx.ui.getEditorComponent();
|
|
458
458
|
if (active !== state.editorFactory || !state.editor) installEditor(ctx, state, active === state.editorFactory ? state.baseFactory : active);
|
|
459
|
+
if (getCapabilities().images) state.tui?.terminal.write("\x1b[16t");
|
|
459
460
|
}
|
|
460
461
|
return state.cleanup;
|
|
461
462
|
}
|
|
@@ -557,6 +558,9 @@ function setPointer(state: Enhancements, pointer: boolean): void {
|
|
|
557
558
|
}
|
|
558
559
|
|
|
559
560
|
function handleTerminalInput(state: Enhancements, data: string): { consume?: boolean } | undefined {
|
|
561
|
+
// ponytail: sync this package's cell metrics with Pi's TUI; remove when Pi exposes them directly.
|
|
562
|
+
const cells = /^\x1b\[6;(\d+);(\d+)t$/.exec(data);
|
|
563
|
+
if (cells && +cells[1] > 0 && +cells[2] > 0) setCellDimensions({ widthPx: +cells[2], heightPx: +cells[1] });
|
|
560
564
|
const mouse = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
|
|
561
565
|
if (mouse) {
|
|
562
566
|
const x = Number(mouse[2]) - 1, y = Number(mouse[3]) - 1;
|
|
@@ -592,8 +596,8 @@ async function requestPreview(state: Enhancements, path: string | undefined): Pr
|
|
|
592
596
|
function setPreview(state: Enhancements, preview: Preview | undefined): void {
|
|
593
597
|
const dimensions = preview?.kind === "image" ? getImageDimensions(preview.base64, preview.mimeType) : undefined;
|
|
594
598
|
const graphic = preview?.kind === "image" && dimensions ? renderImage(preview.base64, dimensions, {
|
|
595
|
-
maxWidthCells: Math.max(1, Math.min(
|
|
596
|
-
maxHeightCells: Math.max(1,
|
|
599
|
+
maxWidthCells: Math.max(1, Math.min(Math.floor(dimensions.widthPx / getCellDimensions().widthPx), (state.tui?.terminal.columns ?? 80) - 2)),
|
|
600
|
+
maxHeightCells: Math.max(1, (state.tui?.terminal.rows ?? 24) - 2),
|
|
597
601
|
imageId: allocateImageId(), moveCursor: false,
|
|
598
602
|
}) ?? undefined : undefined;
|
|
599
603
|
state.preview = {
|
|
@@ -608,7 +612,7 @@ function setPreview(state: Enhancements, preview: Preview | undefined): void {
|
|
|
608
612
|
function showOverlay(state: Enhancements): void {
|
|
609
613
|
if (!state.tui || !state.theme) return;
|
|
610
614
|
state.overlayReady = true;
|
|
611
|
-
state.previewOptions = { width: 60, maxHeight: "
|
|
615
|
+
state.previewOptions = { width: 60, maxHeight: "100%", nonCapturing: true, visible: () => state.enabled() && state.preview.path !== undefined };
|
|
612
616
|
state.previewHandle = state.tui.showOverlay({
|
|
613
617
|
render: width => previewLines(state.preview, state.theme!, width, { row: Number(state.previewOptions?.row ?? 0), col: Number(state.previewOptions?.col ?? 0) }),
|
|
614
618
|
invalidate: () => {},
|
|
@@ -619,7 +623,7 @@ function positionPreview(state: Enhancements): void {
|
|
|
619
623
|
if (!state.previewOptions || !state.tui || !state.theme) return;
|
|
620
624
|
const { rows, columns } = state.tui.terminal;
|
|
621
625
|
const width = Math.max(3, Math.min((state.preview.graphic?.columns ?? 26) + 2, columns || 80));
|
|
622
|
-
const height = Math.min(
|
|
626
|
+
const height = Math.min(rows, previewLines(state.preview, state.theme, width, { row: 0, col: 0 }).length);
|
|
623
627
|
const { x, y } = state.previewAnchor ?? { x: 0, y: rows - 2 };
|
|
624
628
|
Object.assign(state.previewOptions, { width, col: Math.max(0, Math.min(x, (columns || 80) - width)),
|
|
625
629
|
row: y + 1 + height <= rows ? y + 1 : Math.max(0, y - height) });
|
package/lib/settings.html
CHANGED
|
@@ -7,14 +7,17 @@
|
|
|
7
7
|
*{box-sizing:border-box}body{margin:0;background:var(--background);color:var(--foreground);font:var(--text-base)/1.5 ui-sans-serif,system-ui,sans-serif}main{max-width:1080px;margin:auto;padding:40px 24px 72px}header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap}h1{font:italic 400 var(--text-lg)/1.05 "Didot","Bodoni 72","Iowan Old Style","Songti SC","STSong",serif;letter-spacing:.04em;margin:0}h2{font-size:var(--text-sm);font-weight:600;margin:0 0 12px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}nav{display:flex;gap:8px;align-items:center}.hint{margin:12px 0 0;color:var(--accent);font-weight:600}section{margin:28px 0}button{font:inherit;color:inherit;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:8px 12px;cursor:pointer}button:disabled{opacity:.4;cursor:default}:focus-visible{outline:2px solid var(--ring);outline-offset:3px}#preview{position:relative;padding:16px 20px;background:var(--preview-bg);color:var(--preview-text);border:1px dashed var(--border);border-radius:var(--radius);font:var(--text-sm)/1.8 ui-monospace,monospace;display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;height:112px;overflow:auto}#preview button{flex:none;font:inherit;padding:4px 2px;border-color:transparent;background:transparent;color:var(--preview-muted);cursor:grab;white-space:nowrap}#preview button:focus-visible{border-color:var(--accent)}#preview button.over{border-left:2px solid var(--accent)}#preview button.preview-exit{opacity:0;pointer-events:none;transition:opacity 280ms ease-in;position:absolute}#preview .tone-accent{color:var(--preview-accent);font-weight:650}#preview .tone-text{color:var(--preview-text)}#preview .tone-warning{color:var(--preview-warning);font-weight:650}#preview .tone-success{color:var(--preview-success);font-weight:650}#preview .tone-error{color:var(--preview-error);font-weight:650}#preview .tone-muted{color:var(--preview-muted)}#preview #preview-context{flex:1 1 180px;display:flex;align-items:center;gap:8px;min-width:180px}.progress{flex:1;overflow:hidden;text-align:left;color:var(--preview-accent);min-width:0}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:2px 6px}label{display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer;-webkit-user-select:none;user-select:none}.grid label{border:1px solid transparent;border-radius:var(--radius);padding:10px}input{accent-color:var(--accent);width:18px;height:18px;flex-shrink:0}.dragging{opacity:.45}#statusbar{position:fixed;top:12px;right:12px;z-index:2;display:flex;align-items:center;gap:10px;max-width:min(520px,calc(100vw - 24px));padding:8px 12px;background:var(--surface);border:1px solid var(--accent);border-radius:var(--radius);box-shadow:0 6px 20px rgb(0 0 0/.12);color:var(--accent);font-size:var(--text-sm);opacity:0;transform:translateY(-6px);transition:opacity 150ms ease-out,transform 150ms ease-out;pointer-events:none}#statusbar.on{opacity:1;transform:none}#statusbar.error{border-color:var(--destructive);color:var(--destructive)}#statusbar #retry{pointer-events:auto}[hidden]{display:none!important}nav button[aria-pressed=true]{border-color:var(--accent);color:var(--accent)}.features{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:12px}.feature{display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 18px}.feature-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.feature-head h3{margin:0;font-size:var(--text-base);font-weight:600}.feature-body{margin:10px 0 0;color:var(--muted);font-size:var(--text-sm);line-height:1.65}.feature-points{margin:10px 0 0;padding-left:1.15em;font-size:var(--text-sm);line-height:1.7}.feature-points li{margin:2px 0}.feature-points li::marker{color:var(--accent)}.feature-hint{margin:auto 0 0;padding-top:12px;color:var(--muted);font:var(--text-sm)/1.6 ui-monospace,monospace;overflow-wrap:anywhere}.feature-hint::before{content:'› ';color:var(--accent)}.switch{display:flex;align-items:center;gap:8px;padding:0;font-size:var(--text-sm);color:var(--muted)}.notice{display:flex;gap:16px;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;margin:20px 0 0;padding:14px 16px;background:var(--surface);border:1px solid var(--accent);border-left-width:4px;border-radius:var(--radius)}.notice strong{font-size:var(--text-sm)}.notice p{margin:6px 0 0;color:var(--muted);font-size:var(--text-sm);line-height:1.6;max-width:640px}.notice code{display:block;margin:0 0 8px;padding:8px 10px;background:var(--background);border:1px solid var(--border);border-radius:var(--radius);font:var(--text-sm)/1.5 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;max-width:520px;color:var(--foreground)}#preview{margin-top:12px;margin-bottom:20px}@media(max-width:450px){h1{font-size:2rem}main{padding:24px 16px}#statusbar{top:8px;right:8px;max-width:calc(100vw - 16px)}}@media(prefers-reduced-motion:reduce){#preview button.preview-exit{transition-duration:80ms}}@media(prefers-reduced-motion:reduce){#statusbar{transform:none;transition:opacity 80ms ease-out}}
|
|
8
8
|
@media(hover:hover) and (pointer:fine){#preview button:hover,.grid label:hover,.feature:hover{border-color:var(--accent)}}
|
|
9
9
|
#preview button.preview-highlight{border-color:var(--accent)}#preview button.preview-placeholder{border-style:dashed;opacity:1}
|
|
10
|
+
|
|
11
|
+
/* Editorial headings; controls and status data retain readable system fonts. */
|
|
12
|
+
body{background:light-dark(#f6f3ed,#141614)}main{max-width:1160px;padding:32px 32px 88px}header{align-items:flex-start;border-bottom:1px solid var(--border);padding-bottom:36px}h1{font:italic 400 clamp(2.625rem,5vw,3.625rem)/1.06 "Didot","Bodoni 72","Songti SC","STSong",serif;letter-spacing:.02em}.subtitle{font:normal 1.625rem/1.4 "Didot","Bodoni 72","Songti SC","STSong",serif;color:var(--accent);margin:16px 0 0}h2{font:normal 2rem/1.25 "Didot","Bodoni 72","Songti SC","STSong",serif;letter-spacing:0;text-transform:none;color:var(--foreground);margin:0 0 16px}section{margin:0;padding-top:24px}.feature-head h3{font:normal 1.625rem/1.25 "Didot","Bodoni 72","Songti SC","STSong",serif}.feature{padding:20px}.feature:first-child{border-top:3px solid var(--accent)}.feature-body,.feature-points{line-height:1.7}#preview{background:var(--surface);border:1px solid var(--border);padding:16px 24px;height:80px;margin-bottom:12px}.grid label{min-height:44px}@media(max-width:760px){main{padding:20px 16px 64px}header{padding-bottom:20px}.features{grid-template-columns:1fr}h2{font-size:1.75rem}.subtitle{font-size:1.375rem}}
|
|
10
13
|
</style>
|
|
11
14
|
<main>
|
|
12
15
|
<div id="statusbar" role="status" aria-live="polite"><span id="status"></span><button type="button" id="retry" hidden></button></div>
|
|
13
16
|
<header>
|
|
14
|
-
<h1 id="title"></h1>
|
|
17
|
+
<div><h1 id="title"></h1><p class="subtitle" id="subtitle"></p></div>
|
|
15
18
|
<nav>
|
|
16
|
-
<button type="button" id="lang-zh" aria-pressed="false">中文</button>
|
|
17
19
|
<button type="button" id="lang-en" aria-pressed="false">EN</button>
|
|
20
|
+
<button type="button" id="lang-zh" aria-pressed="false">中文</button>
|
|
18
21
|
<button type="button" id="reset" disabled></button>
|
|
19
22
|
</nav>
|
|
20
23
|
</header>
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
<div><code id="noticePrompt"></code><button type="button" id="copyPrompt"></button></div>
|
|
24
27
|
</div>
|
|
25
28
|
<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>
|
|
26
|
-
|
|
29
|
+
|
|
27
30
|
<section><h2 id="featuresHeading"></h2><div class="features" id="features"></div></section>
|
|
28
31
|
</main>
|
|
29
32
|
<script>
|
|
@@ -31,6 +34,7 @@ const $=id=>document.getElementById(id),token=location.hash.slice(1);
|
|
|
31
34
|
history.replaceState(null,'',location.pathname);
|
|
32
35
|
const I18N={
|
|
33
36
|
title:{zh:'Pi Mini Mode',en:'Pi Mini Mode'},
|
|
37
|
+
subtitle:{zh:'轻一点,读得更远。',en:'A quieter way to think.'},
|
|
34
38
|
documentTitle:{zh:'Pi Mini Mode 设置',en:'Pi Mini Mode Settings'},
|
|
35
39
|
dragHint:{zh:'拖拽预览中的字段可调整顺序,松手自动保存。',en:'Drag preview items to reorder · saves on drop.'},
|
|
36
40
|
featuresHeading:{zh:'功能说明',en:'Features'},
|
|
@@ -39,13 +43,11 @@ const I18N={
|
|
|
39
43
|
on:{zh:'开启',en:'On'},off:{zh:'关闭',en:'Off'},
|
|
40
44
|
featureList:{
|
|
41
45
|
zh:[
|
|
42
|
-
{id:'status',title:'状态栏指标',body:'一行看清会话状态,按终端宽度取舍。',points:['模型与思考等级,会话与缓存 Token、命中率、费用','上下文进度条与百分比','生成速度 tok/s,从首个输出 token 起算,不含等待首字']},
|
|
43
46
|
{id:'minimal',setting:'pi-mini-mode-minimal-show',title:'极简输出',body:'把对话收成结论:思考、工具与技能汇成一棵按时间排序的可折叠过程树。',points:['长用户消息默认保留前四行,点击展开全文','子代理行可展开活动记录与输出','Ctrl+O 展开或收起过程树,新问题默认收起','最终 Markdown 流畅呈现,失败与中断明确标记']},
|
|
44
47
|
{id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'输入增强',body:'让输入框和消息里的图片、技能与文件路径直接可用。',points:['光标移入图片路径即可预览,全屏编辑器同样支持','图片路径收纳为 [image1] 标签,提交时保留原图','空白后输入 / 就地搜索技能并插入光标处','点击图片标签或文件路径,用系统默认应用打开'],hint:'Ctrl+V 粘贴图片(Windows/WSL 使用 Alt+V)'},
|
|
45
48
|
{id:'themes',title:'明暗主题',body:'主题让 Markdown、代码高亮、表格与 Mermaid 图表跟随明暗切换。',points:['用户消息使用主题用户背景色,与正文区分','不支持、不完整或过宽的图表保留源文本'],hint:'回到 Pi,输入 /settings → Theme,选择 cc-dark / cc-light'}
|
|
46
49
|
],
|
|
47
50
|
en:[
|
|
48
|
-
{id:'status',title:'Status bar metrics',body:'The whole session state on one line, trimmed to fit narrow terminals.',points:['Model and thinking level, session and cache tokens, hit rate, cost','Context usage bar with percentage','Speed in tok/s, measured from the first output token, excluding time to first token']},
|
|
49
51
|
{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 to expand','Subagent rows expand to 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']},
|
|
50
52
|
{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, in fullscreen too','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)'},
|
|
51
53
|
{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'}
|
|
@@ -55,11 +57,13 @@ const I18N={
|
|
|
55
57
|
retry:{zh:'重试',en:'Retry'},
|
|
56
58
|
confirmReset:{zh:'恢复默认排序与显示设置?',en:'Reset layout and visibility to defaults?'},
|
|
57
59
|
connecting:{zh:'正在同步…',en:'Connecting…'},
|
|
58
|
-
saved:{zh:'
|
|
59
|
-
unsaved:{zh:'
|
|
60
|
+
saved:{zh:'已保存',en:'Saved'},
|
|
61
|
+
unsaved:{zh:'未保存的修改',en:'Unsaved changes'},
|
|
60
62
|
saving:{zh:'正在保存…',en:'Saving…'},
|
|
61
|
-
saveFailed:{zh:'保存失败',en:'
|
|
62
|
-
|
|
63
|
+
saveFailed:{zh:'保存失败',en:'Could not save'},
|
|
64
|
+
saveOffline:{zh:'保存失败,连接已断开。请回到终端重新打开设置',en:'Could not save — the connection closed. Reopen settings from the terminal.'},
|
|
65
|
+
saveRejected:{zh:'保存失败,设置无法写入。请检查配置文件权限后重试',en:'Could not save — settings could not be written. Check the config file permissions and retry.'},
|
|
66
|
+
reconnect:{zh:'连接已断开。请回到终端重新打开设置',en:'Connection closed. Reopen settings from the terminal.'},
|
|
63
67
|
noticeTitle:{zh:'极简输出需要全屏渲染器',en:'Minimal transcript needs the fullscreen renderer'},
|
|
64
68
|
noticeBody:{zh:'极简输出已保存,但当前 Pi 运行在普通 TUI 模式,暂不生效。复制下面的提示词发给 Pi,让它帮你把 TUI 模式改为 fullscreen;重启 Pi 后生效(/reload 不会切换渲染器)。',en:'Minimal transcript is saved but inactive: Pi is running in regular TUI mode. Copy the prompt below into Pi to set TUI mode to fullscreen; it takes effect after restarting Pi (/reload does not switch the renderer).'},
|
|
65
69
|
noticePrompt:{zh:'把 Pi 全局设置中的 tuiMode 改为 fullscreen',en:'Set tuiMode to fullscreen in Pi global settings'},
|
|
@@ -88,7 +92,7 @@ const I18N={
|
|
|
88
92
|
}
|
|
89
93
|
};
|
|
90
94
|
const FIELD_KEY={minimal:'pi-mini-mode-minimal-show','input-enhancements':'pi-mini-mode-input-enhancements','context-dots':'pi-mini-mode-context-dots-show','speed-unit':'pi-mini-mode-speed-unit-show'};
|
|
91
|
-
let lang=localStorage.piMiniModeLang||
|
|
95
|
+
let lang=localStorage.piMiniModeLang||'en';
|
|
92
96
|
let data,state,order,dragged,hovered,saving=false,dirty=false,timer,copyTimer,statusTimer;
|
|
93
97
|
const key=id=>'pi-mini-mode-'+id+'-show';
|
|
94
98
|
const t=(id,fallback='')=>(I18N[id]?.[lang]??fallback);
|
|
@@ -106,7 +110,7 @@ function status(text,error=false){
|
|
|
106
110
|
function applyLang(){
|
|
107
111
|
document.documentElement.lang=lang==='zh'?'zh-CN':'en';
|
|
108
112
|
document.title=t('documentTitle');
|
|
109
|
-
for(const id of ['title','
|
|
113
|
+
for(const id of ['title','subtitle','featuresHeading','fieldsHeading','dragHint']) $(id).textContent=t(id);
|
|
110
114
|
$('reset').textContent=t('reset');$('retry').textContent=t('retry');
|
|
111
115
|
$('lang-zh').setAttribute('aria-pressed',String(lang==='zh'));
|
|
112
116
|
$('lang-en').setAttribute('aria-pressed',String(lang==='en'));
|
|
@@ -114,7 +118,7 @@ function applyLang(){
|
|
|
114
118
|
}
|
|
115
119
|
async function request(method,body){
|
|
116
120
|
const response=await fetch('/settings',{method,headers:{Authorization:'Bearer '+token,...(body?{'Content-Type':'application/json'}:{})},body:body?JSON.stringify(body):undefined});
|
|
117
|
-
if(!response.ok)throw Error(
|
|
121
|
+
if(!response.ok)throw Error(response.status===403||response.status===404?t('saveOffline'):t('saveRejected'));
|
|
118
122
|
return response.json();
|
|
119
123
|
}
|
|
120
124
|
const previewFade=280,previewFadeReduced=80;
|
|
@@ -177,7 +181,7 @@ async function save(){
|
|
|
177
181
|
if(saving)return;saving=true;$('retry').hidden=true;
|
|
178
182
|
let wrote=false;
|
|
179
183
|
try{while(dirty){dirty=false;const body=structuredClone(state);status(t('saving'));await request('PUT',body);wrote=true}status(wrote?t('saved'):'')}
|
|
180
|
-
catch(error){dirty=true;status(t('
|
|
184
|
+
catch(error){dirty=true;status(error instanceof TypeError?t('saveOffline'):error.message||t('saveFailed'),true);$('retry').hidden=false}
|
|
181
185
|
finally{saving=false}
|
|
182
186
|
}
|
|
183
187
|
function box(settingId,onToggle){
|
|
@@ -220,7 +224,7 @@ function render(){
|
|
|
220
224
|
renderNotice();
|
|
221
225
|
$('fields').replaceChildren(...order.map(id=>checkbox(id,key(id))),...(data.options||[]).map(id=>checkbox(id,FIELD_KEY[id]||key(id))));
|
|
222
226
|
$('features').replaceChildren(...t('featureList').map(feature));
|
|
223
|
-
|
|
227
|
+
|
|
224
228
|
preview();
|
|
225
229
|
}
|
|
226
230
|
function renderNotice(){
|
|
@@ -252,6 +256,6 @@ function mergeOrder(base,all){const next=[...new Set((base||[]).filter(id=>(all|
|
|
|
252
256
|
$('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=mergeOrder(data.order,data.order);render();change()};
|
|
253
257
|
window.addEventListener('beforeunload',event=>{if(dirty||saving){event.preventDefault();event.returnValue=''}});
|
|
254
258
|
applyLang();status(t('connecting'));
|
|
255
|
-
request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);render();$('reset').disabled=false;status('')}).catch(
|
|
259
|
+
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));
|
|
256
260
|
</script>
|
|
257
261
|
</html>
|
package/package.json
CHANGED