@each1024/pi-mini-mode 1.3.14 → 2.0.0

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.
@@ -26,7 +26,6 @@ function configuredIdleTimeout(override: number | undefined): number {
26
26
  /** On-demand, loopback-only settings bridge; no polling or third-party runtime. */
27
27
  export async function startSettingsWeb(snapshot: () => unknown, update: (value: unknown) => Promise<void>, options: SettingsWebOptions = {}) {
28
28
  const token = randomBytes(24).toString("hex");
29
- const html = await readFile(new URL("./settings.html", import.meta.url));
30
29
  const idleTimeoutMs = configuredIdleTimeout(options.idleTimeoutMs);
31
30
  let origin = "";
32
31
  let queue = Promise.resolve();
@@ -63,7 +62,13 @@ export async function startSettingsWeb(snapshot: () => unknown, update: (value:
63
62
  res.writeHead(403).end(); return;
64
63
  }
65
64
  if (req.url === "/" && req.method === "GET") {
66
- res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html); return;
65
+ try {
66
+ const html = await readFile(new URL("./settings.html", import.meta.url));
67
+ res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html);
68
+ } catch {
69
+ res.writeHead(503).end("Settings page unavailable. Reload Pi and reopen settings.");
70
+ }
71
+ return;
67
72
  }
68
73
  if (req.url !== "/settings" || req.headers.authorization !== `Bearer ${token}`) {
69
74
  res.writeHead(403).end(); return;
package/lib/settings.html CHANGED
@@ -3,15 +3,21 @@
3
3
  <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
4
4
  <title>Pi Mini Mode 设置</title>
5
5
  <style>
6
- :root{color-scheme:light dark;--background:light-dark(#f4f3ef,#141614);--foreground:light-dark(#1f241f,#eceee8);--surface:light-dark(#fffcf7,#1d211d);--muted:light-dark(#667066,#a8b0a4);--border:light-dark(#e2ddd4,#3a4038);--accent:light-dark(#2f5a3e,#b7d4b0);--destructive:light-dark(#a52c26,#ffafa5);--ring:var(--accent);--text-sm:.875rem;--text-base:1rem;--text-lg:2.75rem;--radius:8px}
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)}.tagline{margin:8px 0 0;color:var(--muted);font-size:var(--text-sm)}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{padding:16px 20px;background:var(--surface);border:1px dashed var(--accent);border-radius:var(--radius);font:var(--text-sm)/1.8 ui-monospace,monospace;display:flex;align-items:center;gap:12px;overflow-x:auto;min-height:72px;white-space:nowrap}#preview button{flex:none;font:inherit;padding:4px 2px;border-color:transparent;cursor:grab;white-space:nowrap}#preview button:hover{border-color:var(--border)}#preview button.over{border-left:2px solid var(--accent)}#preview #preview-context{flex:1;display:flex;align-items:center;gap:8px;min-width:180px}.progress{flex:1;overflow:hidden;text-align:left;color:var(--accent);min-width:0}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:4px 16px}label{display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer}input{accent-color:var(--accent);width:18px;height:18px;flex-shrink:0}.dragging{opacity:.45}#status{min-height:24px;color:var(--accent)}#status.error{color:var(--destructive)}#retry{margin-left:12px}[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}@media(max-width:450px){h1{font-size:2rem}main{padding:24px 16px}}
6
+ :root{color-scheme:light dark;--background:light-dark(#f4f3ef,#141614);--foreground:light-dark(#1f241f,#eceee8);--surface:light-dark(#fffcf7,#1d211d);--muted:light-dark(#667066,#a8b0a4);--border:light-dark(#e2ddd4,#3a4038);--accent:light-dark(#2f5a3e,#b7d4b0);--destructive:light-dark(#a52c26,#ffafa5);--ring:var(--accent);--preview-bg:light-dark(#f7f7f8,#131217);--preview-text:light-dark(#242127,#f5f5f5);--preview-muted:light-dark(#625f68,#a1a1aa);--preview-accent:light-dark(#2563eb,#5e9cff);--preview-warning:light-dark(#a16207,#facc15);--preview-success:light-dark(#15803d,#4ade80);--preview-error:light-dark(#dc2626,#fb7185);--text-sm:.875rem;--text-base:1rem;--text-lg:2.75rem;--radius:8px}
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)}.preview-mode{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:14px 0 0;font-size:var(--text-sm)}.preview-mode select{font:inherit;color:var(--foreground);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:8px;min-height:44px}.preview-mode select:disabled{opacity:.5}.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
+ @media(hover:hover) and (pointer:fine){#preview button:hover,.grid label:hover,.feature:hover{border-color:var(--accent)}}
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}}
8
13
  </style>
9
14
  <main>
15
+ <div id="statusbar" role="status" aria-live="polite"><span id="status"></span><button type="button" id="retry" hidden></button></div>
10
16
  <header>
11
- <div><h1 id="title"></h1><p class="tagline" id="tagline"></p></div>
17
+ <div><h1 id="title"></h1><p class="subtitle" id="subtitle"></p></div>
12
18
  <nav>
13
- <button type="button" id="lang-zh" aria-pressed="false">中文</button>
14
19
  <button type="button" id="lang-en" aria-pressed="false">EN</button>
20
+ <button type="button" id="lang-zh" aria-pressed="false">中文</button>
15
21
  <button type="button" id="reset" disabled></button>
16
22
  </nav>
17
23
  </header>
@@ -19,50 +25,48 @@
19
25
  <div><strong id="noticeTitle"></strong><p id="noticeBody"></p></div>
20
26
  <div><code id="noticePrompt"></code><button type="button" id="copyPrompt"></button></div>
21
27
  </div>
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
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>
25
- <section><h2 id="optionsHeading"></h2><div class="grid" id="options"></div></section>
29
+
30
+ <section><h2 id="featuresHeading"></h2><div class="features" id="features"></div></section>
26
31
  </main>
27
32
  <script>
28
33
  const $=id=>document.getElementById(id),token=location.hash.slice(1);
29
34
  history.replaceState(null,'',location.pathname);
30
35
  const I18N={
31
36
  title:{zh:'Pi Mini Mode',en:'Pi Mini Mode'},
37
+ subtitle:{zh:'轻一点,读得更远。',en:'A quieter way to think.'},
32
38
  documentTitle:{zh:'Pi Mini Mode 设置',en:'Pi Mini Mode Settings'},
33
- tagline:{zh:'极简状态栏配置',en:'Minimal status bar setup'},
34
- dragHint:{zh:'拖拽预览中的字段可调整顺序,松手自动保存',en:'Drag items in the preview to reorder · Auto-saves on drop'},
39
+ dragHint:{zh:'拖拽预览中的字段可调整顺序,松手自动保存。',en:'Drag preview items to reorder · saves on drop.'},
35
40
  featuresHeading:{zh:'功能说明',en:'Features'},
36
41
  fieldsHeading:{zh:'状态栏字段与预览',en:'Status bar items & preview'},
37
42
  optionsHeading:{zh:'状态栏样式',en:'Status bar style'},
38
- on:{zh:'开启',en:'On'},off:{zh:'关闭',en:'Off'},
43
+ on:{zh:'开启',en:'On'},off:{zh:'关闭',en:'Off'},previewModeLabel:{zh:'图片预览方式',en:'Image preview mode'},previewHover:{zh:'光标浮窗',en:'Cursor popup'},previewInline:{zh:'内联卡片(多图排列)',en:'Inline cards (multiple images)'},previewModeHint:{zh:'卡片显示在输入框上方;终端不支持图片时显示占位。',en:'Cards appear above the editor; unsupported terminals show placeholders.'},
39
44
  featureList:{
40
45
  zh:[
41
- {id:'status',title:'状态栏指标',body:'一行看清会话状态,随终端宽度自动取舍,不换行。',points:['模型与思考等级,会话与缓存 Token、缓存命中率、费用估算','上下文用量进度条与百分比','生成速度 tok/s,从第一个输出 token 起算,不含等待首字'],hint:'勾选需要的字段,拖拽预览中的条目即可排序。'},
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
- {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 重新选择主题与全局全屏模式'}
46
+ {id:'minimal',setting:'pi-mini-mode-minimal-show',title:'极简输出',body:'把对话收成结论:思考、工具与技能汇成一棵按时间排序的可折叠过程树。',points:['长用户消息默认保留前四行,点击展开全文','子代理行可展开活动记录与输出','Ctrl+O 展开或收起过程树,新问题默认收起','最终 Markdown 流畅呈现,失败与中断明确标记']},
47
+ {id:'input-enhancements',setting:'pi-mini-mode-input-enhancements',title:'输入增强',body:'让输入框和消息里的图片、技能与文件路径直接可用。',points:['光标移入图片路径即可预览,全屏编辑器同样支持','图片路径收纳为 [image1] 标签,提交时保留原图','空白后输入 / 就地搜索技能并插入光标处','点击图片标签或文件路径,用系统默认应用打开'],hint:'Ctrl+V 粘贴图片(Windows/WSL 使用 Alt+V)'},
48
+ {id:'themes',title:'明暗主题',body:'主题让 Markdown、代码高亮、表格与 Mermaid 图表跟随明暗切换。',points:['用户消息使用主题用户背景色,与正文区分','不支持、不完整或过宽的图表保留源文本'],hint:'回到 Pi,输入 /settings → Theme,选择 cc-dark / cc-light'}
45
49
  ],
46
50
  en:[
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
- {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
- {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'}
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']},
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)'},
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'}
51
54
  ]
52
55
  },
53
56
  reset:{zh:'恢复默认',en:'Reset defaults'},
54
57
  retry:{zh:'重试',en:'Retry'},
55
58
  confirmReset:{zh:'恢复默认排序与显示设置?',en:'Reset layout and visibility to defaults?'},
56
59
  connecting:{zh:'正在同步…',en:'Connecting…'},
57
- connected:{zh:'已同步',en:'In sync'},
58
- unsaved:{zh:'未保存修改',en:'Unsaved changes'},
59
- saving:{zh:'正在保存…',en:'Saving…'},
60
60
  saved:{zh:'已保存',en:'Saved'},
61
- saveFailed:{zh:'保存失败',en:'Failed to save'},
62
- reconnect:{zh:'连接已断开,请从终端重新打开',en:'Disconnected. Please reopen from the terminal.'},
61
+ unsaved:{zh:'未保存的修改',en:'Unsaved changes'},
62
+ saving:{zh:'正在保存…',en:'Saving…'},
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
- noticePrompt:{zh:'把 Pi 全局设置中的 tuiMode 改为 fullscreen,然后告诉我怎么重启生效',en:'Set tuiMode to fullscreen in Pi global settings, then tell me how to restart for it to take effect'},
69
+ noticePrompt:{zh:'把 Pi 全局设置中的 tuiMode 改为 fullscreen',en:'Set tuiMode to fullscreen in Pi global settings'},
66
70
  copyPrompt:{zh:'复制提示词',en:'Copy prompt'},
67
71
  copied:{zh:'已复制',en:'Copied'},
68
72
  copyFailed:{zh:'复制失败,请手动选中',en:'Copy failed — select manually'},
@@ -74,6 +78,7 @@ const I18N={
74
78
  branch:{zh:'仅分支',en:'Branch Only'},
75
79
  'session-tokens':{zh:'会话 Token',en:'Session Tokens'},
76
80
  'cache-tokens':{zh:'缓存 Token',en:'Cache Tokens'},
81
+ 'cache-miss':{zh:'缓存 miss',en:'Cache miss'},
77
82
  ch:{zh:'缓存命中率',en:'Cache Hit Rate'},
78
83
  cost:{zh:'累计费用',en:'Cost'},
79
84
  mcp:{zh:'MCP 服务数',en:'MCP Count'},
@@ -87,17 +92,25 @@ const I18N={
87
92
  }
88
93
  };
89
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'};
90
- let lang=localStorage.piMiniModeLang||(navigator.language.startsWith('zh')?'zh':'en');
91
- let data,state,order,dragged,saving=false,dirty=false,timer,copyTimer;
95
+ let lang=localStorage.piMiniModeLang||'en';
96
+ let data,state,order,dragged,hovered,saving=false,dirty=false,timer,copyTimer,statusTimer;
92
97
  const key=id=>'pi-mini-mode-'+id+'-show';
93
98
  const t=(id,fallback='')=>(I18N[id]?.[lang]??fallback);
94
99
  const fieldLabel=id=>I18N.fields[id]?.[lang]||id;
95
- const examples={'project-branch':'pi-mini-mode(main)',model:'deepseek-v4-flash',thinking:'high',branch:'main','session-tokens':'Total 45K','cache-tokens':'Cached 25K',ch:'CH 40.0%',cost:'$0.012',mcp:'◇ MCP 3',context:'500/1.0M','context-percent':'1%',speed:'120 tok/s'};
96
- function status(text,error=false){$('status').textContent=text;$('status').className=error?'error':''}
100
+ const examples={'project-branch':'pi-mini-mode(main)',model:'deepseek-v4-flash',thinking:'high',branch:'main','session-tokens':'Total 45K','cache-tokens':'Cached 25K','cache-miss':'Miss 21K',ch:'CH 40.0%',cost:'$0.012',mcp:'◇ MCP 3',context:'500/1.0M','context-percent':'1%',speed:'120 tok/s'};
101
+ const statusHold=2500;
102
+ function status(text,error=false){
103
+ clearTimeout(statusTimer);
104
+ const bar=$('statusbar');
105
+ bar.classList.toggle('error',!!error);bar.classList.toggle('on',!!text);
106
+ $('status').textContent=text;
107
+ if(!text||error)return; // 连接/保存中短显,错误留在原地等 retry
108
+ statusTimer=setTimeout(()=>{$('status').textContent='';bar.classList.remove('on')},statusHold);
109
+ }
97
110
  function applyLang(){
98
111
  document.documentElement.lang=lang==='zh'?'zh-CN':'en';
99
112
  document.title=t('documentTitle');
100
- for(const id of ['title','tagline','featuresHeading','fieldsHeading','optionsHeading','dragHint']) $(id).textContent=t(id);
113
+ for(const id of ['title','subtitle','featuresHeading','fieldsHeading','dragHint']) $(id).textContent=t(id);
101
114
  $('reset').textContent=t('reset');$('retry').textContent=t('retry');
102
115
  $('lang-zh').setAttribute('aria-pressed',String(lang==='zh'));
103
116
  $('lang-en').setAttribute('aria-pressed',String(lang==='en'));
@@ -105,18 +118,51 @@ function applyLang(){
105
118
  }
106
119
  async function request(method,body){
107
120
  const response=await fetch('/settings',{method,headers:{Authorization:'Bearer '+token,...(body?{'Content-Type':'application/json'}:{})},body:body?JSON.stringify(body):undefined});
108
- if(!response.ok)throw Error(await response.text()||t('saveFailed'));
121
+ if(!response.ok)throw Error(response.status===403||response.status===404?t('saveOffline'):t('saveRejected'));
109
122
  return response.json();
110
123
  }
124
+ const previewFade=280,previewFadeReduced=80;
125
+ function syncPreviewEmpty(){const panel=$('preview');if(!panel.children.length)panel.textContent=t('emptyPreview')}
126
+ function exitPreview(el){
127
+ if(el.classList.contains('preview-exit'))return;
128
+ const fade=matchMedia('(prefers-reduced-motion: reduce)').matches?previewFadeReduced:previewFade;
129
+ el.style.left=el.offsetLeft+'px';el.style.top=el.offsetTop+'px';
130
+ el.classList.add('preview-exit');el.setAttribute('aria-hidden','true');
131
+ el.disabled=true;el.draggable=false;el.tabIndex=-1;
132
+ setTimeout(()=>{el.remove();syncPreviewEmpty()},fade+60);
133
+ }
134
+ // A hidden field fades out in place; its timer removes only that node, so a stale fade can never delete a newer button.
135
+ function nextPreview(el){let node=el.nextSibling;while(node&&!(node.dataset?.field&&!node.classList.contains('preview-exit')))node=node.nextSibling;return node}
136
+ function hoverField(id){return {'context-dots':'context','speed-unit':'speed'}[id]||id}
111
137
  function preview(){
112
138
  const panel=$('preview'),scroll=panel.scrollLeft;
113
- panel.replaceChildren();
114
- const visible=order.filter(id=>state[key(id)]);
115
- const values={...examples,speed:state['pi-mini-mode-speed-unit-show']?'120 tok/s':'120'};
116
- for(const id of visible){
117
- const button=document.createElement('button');
118
- button.id='preview-'+id;button.type='button';button.textContent=values[id];button.draggable=true;
119
- if(id==='context'){const bar=document.createElement('span');bar.className='progress';bar.setAttribute('aria-hidden','true');bar.textContent=state['pi-mini-mode-context-dots-show']?'⣿'+'⣀'.repeat(300):'█'+'░'.repeat(300);button.append(bar)}
139
+ const highlighted=hoverField(hovered);
140
+ const visible=order.filter(id=>state[key(id)]||id===highlighted);
141
+ const sample={...state};
142
+ if(hovered)sample[FIELD_KEY[hovered]||key(hovered)]=true;
143
+ const values=Object.fromEntries(Object.entries(examples).map(([id,value])=>[id,typeof value==='function'?value():value]));
144
+ values.speed=sample['pi-mini-mode-speed-unit-show']?'120 tok/s':'120';
145
+ for(const node of [...panel.childNodes])if(node.nodeType===3)node.remove();
146
+ const live=new Map();
147
+ for(const el of [...panel.children]){
148
+ const field=el.dataset.field;
149
+ if(!field){el.remove();continue}
150
+ if(!visible.includes(field)){if(el.dataset.ghost==='true')el.remove();else exitPreview(el);continue}
151
+ if(el.classList.contains('preview-exit')){el.remove();continue}
152
+ live.set(field,el);
153
+ }
154
+ let next=null;
155
+ for(let index=visible.length-1;index>=0;index--){
156
+ const id=visible[index];
157
+ const button=live.get(id)??document.createElement('button');
158
+ button.id='preview-'+id;button.type='button';button.textContent=values[id];button.draggable=true;button.dataset.field=id;
159
+ const fast=Number.parseFloat(values.speed)>=100;
160
+ button.className='tone-'+(id==='model'||id==='context-percent'?'accent':id==='cache-miss'?'warning':id==='session-tokens'||id==='cache-tokens'||id==='ch'?'text':id==='speed'?(fast?'success':values.speed.startsWith('0')?'error':'warning'):'muted');
161
+ const ghost=!state[key(id)];
162
+ button.dataset.ghost=String(ghost);button.disabled=ghost;button.draggable=!ghost;button.tabIndex=ghost?-1:0;
163
+ if(ghost)button.setAttribute('aria-hidden','true');else button.removeAttribute('aria-hidden');
164
+ if(id===highlighted){button.classList.add('preview-highlight');if(ghost||!state[FIELD_KEY[hovered]||key(hovered)])button.classList.add('preview-placeholder')}
165
+ if(id==='context'){const bar=document.createElement('span');bar.className='progress';bar.setAttribute('aria-hidden','true');bar.textContent=sample['pi-mini-mode-context-dots-show']?'⣿'+'⣀'.repeat(199):'█'+'░'.repeat(199);button.append(bar)}
120
166
  button.setAttribute('aria-label',fieldLabel(id)+' · '+t('dragHint'));
121
167
  button.ondragstart=event=>{dragged=id;event.dataTransfer.setData('text/plain',id);event.dataTransfer.effectAllowed='move';button.classList.add('dragging')};
122
168
  button.ondragend=()=>{dragged=undefined;button.classList.remove('dragging');document.querySelectorAll('.over').forEach(el=>el.classList.remove('over'))};
@@ -124,16 +170,18 @@ function preview(){
124
170
  button.ondragleave=()=>button.classList.remove('over');
125
171
  button.ondrop=event=>{event.preventDefault();const source=dragged;dragged=undefined;if(source){move(order.indexOf(source),order.indexOf(id));$('preview-'+source)?.focus()}};
126
172
  button.onkeydown=event=>{if(event.key!=='ArrowLeft'&&event.key!=='ArrowRight')return;event.preventDefault();const target=visible[visible.indexOf(id)+(event.key==='ArrowLeft'?-1:1)];if(target){move(order.indexOf(id),order.indexOf(target));$('preview-'+id)?.focus()}};
127
- panel.append(button);
173
+ if(button.parentNode!==panel||nextPreview(button)!==next)panel.insertBefore(button,next);
174
+ next=button;
128
175
  }
129
- if(!visible.length)panel.textContent=t('emptyPreview');
176
+ if(!visible.length)syncPreviewEmpty();
130
177
  panel.scrollLeft=scroll;
131
178
  }
132
- function change(){dirty=true;state.footerOrder=[...order];preview();renderNotice();status(t('unsaved'));clearTimeout(timer);timer=setTimeout(save,250)}
179
+ function change(){hovered=undefined;dirty=true;state.footerOrder=[...order];preview();renderNotice();status(t('unsaved'));clearTimeout(timer);timer=setTimeout(save,250)}
133
180
  async function save(){
134
181
  if(saving)return;saving=true;$('retry').hidden=true;
135
- try{while(dirty){dirty=false;const body=structuredClone(state);status(t('saving'));await request('PUT',body)}status(t('saved'))}
136
- catch(error){dirty=true;status(t('saveFailed')+':'+error.message,true);$('retry').hidden=false}
182
+ let wrote=false;
183
+ try{while(dirty){dirty=false;const body=structuredClone(state);status(t('saving'));await request('PUT',body);wrote=true}status(wrote?t('saved'):'')}
184
+ catch(error){dirty=true;status(error instanceof TypeError?t('saveOffline'):error.message||t('saveFailed'),true);$('retry').hidden=false}
137
185
  finally{saving=false}
138
186
  }
139
187
  function box(settingId,onToggle){
@@ -155,8 +203,18 @@ function feature(item){
155
203
  const body=document.createElement('p');body.className='feature-body';body.textContent=item.body;
156
204
  const points=document.createElement('ul');points.className='feature-points';
157
205
  points.append(...item.points.map(point=>{const li=document.createElement('li');li.textContent=point;return li}));
158
- const hint=document.createElement('p');hint.className='feature-hint';hint.textContent=item.hint;
159
- card.append(head,body,points,hint);
206
+ card.append(head,body,points);
207
+ if(item.id==='input-enhancements'){
208
+ const label=document.createElement('label');label.className='preview-mode';label.htmlFor='pi-mini-mode-image-preview';
209
+ const text=document.createElement('span');text.textContent=t('previewModeLabel');
210
+ const select=document.createElement('select');select.id=label.htmlFor;select.disabled=!state[item.setting];
211
+ for(const [value,key] of [['hover','previewHover'],['inline','previewInline']]){const option=document.createElement('option');option.value=value;option.textContent=t(key);select.append(option)}
212
+ select.value=state[select.id]||'inline';select.onchange=()=>{state[select.id]=select.value;change()};
213
+ label.append(text,select);card.append(label);
214
+ const hint=document.createElement('p');hint.className='feature-hint';hint.textContent=t('previewModeHint');card.append(hint);
215
+ head.querySelector('input').addEventListener('change',()=>{select.disabled=!state[item.setting]});
216
+ }
217
+ if(item.hint){const hint=document.createElement('p');hint.className='feature-hint';hint.textContent=item.hint;card.append(hint)}
160
218
  return card;
161
219
  }
162
220
  function checkbox(id,settingId){
@@ -165,15 +223,18 @@ function checkbox(id,settingId){
165
223
  change();
166
224
  });
167
225
  label.append(input,document.createTextNode(fieldLabel(id)));
226
+ label.onmouseenter=()=>{if(matchMedia('(hover: hover) and (pointer: fine)').matches){hovered=id;preview()}};
227
+ label.onmouseleave=()=>{if(hovered===id){hovered=undefined;preview()}};
168
228
  return label;
169
229
  }
170
230
  function move(from,to){if(from===to||from<0||to<0||to>=order.length)return;const [id]=order.splice(from,1);order.splice(to,0,id);preview();change()}
171
231
  function render(){
232
+ hovered=undefined;
172
233
  applyLang();
173
234
  renderNotice();
174
- $('fields').replaceChildren(...order.map(id=>checkbox(id,key(id))));
235
+ $('fields').replaceChildren(...order.map(id=>checkbox(id,key(id))),...(data.options||[]).map(id=>checkbox(id,FIELD_KEY[id]||key(id))));
175
236
  $('features').replaceChildren(...t('featureList').map(feature));
176
- $('options').replaceChildren(...['context-dots','speed-unit'].map(id=>checkbox(id,FIELD_KEY[id])));
237
+
177
238
  preview();
178
239
  }
179
240
  function renderNotice(){
@@ -201,9 +262,10 @@ function setLang(next){lang=next;localStorage.piMiniModeLang=lang;render()}
201
262
  $('lang-zh').onclick=()=>setLang('zh');
202
263
  $('lang-en').onclick=()=>setLang('en');
203
264
  $('retry').onclick=save;
204
- $('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=[...data.order];render();change()};
265
+ 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}
266
+ $('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=mergeOrder(data.order,data.order);render();change()};
205
267
  window.addEventListener('beforeunload',event=>{if(dirty||saving){event.preventDefault();event.returnValue=''}});
206
268
  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));
269
+ 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));
208
270
  </script>
209
271
  </html>
@@ -0,0 +1,45 @@
1
+ import { SettingsManager } from "@earendil-works/pi-coding-agent";
2
+
3
+ type CapabilityGetter = SettingsManager["getTerminalCapabilityOverrides"];
4
+ type CapabilityOverrides = ReturnType<CapabilityGetter>;
5
+ type CapabilityBridge = { original: CapabilityGetter; getter: CapabilityGetter; owners: Set<symbol> };
6
+ const BRIDGE = Symbol.for("@each1024/pi-mini-mode/terminal-capabilities");
7
+
8
+ function terminalDefaults(overrides: CapabilityOverrides): CapabilityOverrides {
9
+ const term = process.env.TERM?.toLowerCase() ?? "";
10
+ if (process.env.TERM_PROGRAM?.toLowerCase() !== "otty" || process.env.TMUX || process.env.STY || /^(tmux|screen)/.test(term)) return overrides;
11
+ const defaults: CapabilityOverrides = {};
12
+ const protocol = process.env.PI_IMAGE_PROTOCOL?.toLowerCase();
13
+ if (overrides.images === undefined && !["kitty", "iterm2", "none", "0"].includes(protocol ?? "")) defaults.images = "kitty";
14
+ if (overrides.hyperlinks === undefined && !["0", "1"].includes(process.env.PI_HYPERLINKS ?? "")) defaults.hyperlinks = true;
15
+ return Object.keys(defaults).length ? { ...overrides, ...defaults } : overrides;
16
+ }
17
+
18
+ /** Temporary bridge: Pi exposes settings overrides but no extension hook for detection defaults.
19
+ * Install in the extension factory, before the host applies settings and starts its renderer.
20
+ * Never infer why getCapabilities().images is null or override the renderer's restrictions.
21
+ */
22
+ export function installTerminalCapabilities(): () => void {
23
+ const prototype = SettingsManager.prototype as SettingsManager & { [BRIDGE]?: CapabilityBridge };
24
+ if (typeof prototype?.getTerminalCapabilityOverrides !== "function") return () => {};
25
+ let bridge = prototype[BRIDGE];
26
+ if (!bridge) {
27
+ const original = prototype.getTerminalCapabilityOverrides;
28
+ const owners = new Set<symbol>();
29
+ const getter: CapabilityGetter = function (this: SettingsManager, ...args: Parameters<CapabilityGetter>) {
30
+ const overrides = original.apply(this, args);
31
+ return owners.size ? terminalDefaults(overrides) : overrides;
32
+ };
33
+ bridge = { original, getter, owners };
34
+ prototype[BRIDGE] = bridge;
35
+ prototype.getTerminalCapabilityOverrides = getter;
36
+ }
37
+ const owner = Symbol();
38
+ bridge.owners.add(owner);
39
+ return () => {
40
+ if (!bridge.owners.delete(owner) || bridge.owners.size) return;
41
+ // A later third-party wrapper may retain ours; leave it installed and ours inactive.
42
+ if (prototype.getTerminalCapabilityOverrides === bridge.getter) prototype.getTerminalCapabilityOverrides = bridge.original;
43
+ if (prototype[BRIDGE] === bridge) delete prototype[BRIDGE];
44
+ };
45
+ }
@@ -304,6 +304,22 @@ function supervisorEnvelope(child: Component): unknown {
304
304
  /** Pi 0.85.x private layout adapter. Never mutates the stored messages or child tree. */
305
305
  export type NoticeRows = string[] & { handleMouse?: Component["handleMouse"] };
306
306
  export type TurnNotices = ReadonlyMap<number, NoticeRows>;
307
+
308
+ /** Pi writes one warning line per miss (`Cache miss…: N tokens re-billed`). */
309
+ export function cacheMissLine(text: string): { label: string; tokens: number } | undefined {
310
+ const plain = stripVTControlCharacters(text).replace(/\s+/g, " ").trim();
311
+ const match = plain.match(/^(Cache miss\b.*?):\s*([\d,.]+)\s*([kKmM])?\s*tokens re-billed\b/);
312
+ if (!match) return;
313
+ const scale = match[3]?.toLowerCase() === "m" ? 1_000_000 : match[3]?.toLowerCase() === "k" ? 1_000 : 1;
314
+ const tokens = Math.round(Number(match[2].replace(/,/g, "")) * scale);
315
+ return Number.isFinite(tokens) ? { label: match[1], tokens } : undefined;
316
+ }
317
+
318
+ function formatCacheTokens(value: number): string {
319
+ if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
320
+ if (value >= 1_000) return `${Math.round(value / 1_000)}k`;
321
+ return String(value);
322
+ }
307
323
  interface TranscriptView extends Component {
308
324
  render(width: number, notices?: TurnNotices): string[];
309
325
  clearHover?(): boolean;
@@ -325,6 +341,8 @@ interface NoticeOptions {
325
341
  /** Blocking extension prompts are native UI, never auto-expiring notices. */
326
342
  isPrompt?: (text: string) => boolean;
327
343
  isTransient?: (text: string) => boolean;
344
+ /** When false, Pi's per-turn cache-miss lines stay in the transcript. Default: fold them. */
345
+ foldCacheMiss?: () => boolean;
328
346
  now?: () => number;
329
347
  schedule?: (callback: () => void, delay: number) => () => void;
330
348
  }
@@ -411,7 +429,21 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
411
429
  let turn = totalTurns - nativeTurns - 1;
412
430
  let nextExpiry = Infinity;
413
431
  const time = now();
432
+ const cacheMisses = new Map<number, { label: string; tokens: number; count: number; rows: string[] }>();
433
+ const flushCache = (index: number) => {
434
+ const miss = cacheMisses.get(index);
435
+ if (!miss) return;
436
+ cacheMisses.delete(index);
437
+ const rows = notices.get(index) ?? [];
438
+ // ponytail: first styled line carries the color; token text is plain digits so one replace is enough.
439
+ const summary = miss.count === 1
440
+ ? miss.rows[0]
441
+ : miss.rows[0].replace(/[\d,.]+\s*[kKmM]?\s*tokens re-billed/, `${miss.count} misses, ${formatCacheTokens(miss.tokens)} tokens re-billed`);
442
+ rows.push(summary);
443
+ notices.set(index, rows);
444
+ };
414
445
  for (const child of chat.children) {
446
+ if (child.constructor.name === "UserMessageComponent") flushCache(turn);
415
447
  if (child.constructor.name === "UserMessageComponent") turn++;
416
448
  // Goal state is stored as a custom entry, not a user message. Adapt only
417
449
  // the known pi-codex-goal envelope so ordinary extension cards stay native.
@@ -468,6 +500,15 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
468
500
  // Pi 0.85 Text stores the unwrapped styled source in text. Width changes
469
501
  // must not restart the timeout; setText updates must restart it.
470
502
  const source = (child as unknown as { text?: unknown }).text;
503
+ const miss = options.foldCacheMiss?.() !== false && typeof source === "string" ? cacheMissLine(source) : undefined;
504
+ if (miss) {
505
+ const current = cacheMisses.get(turn) ?? { label: miss.label, tokens: 0, count: 0, rows: [] as string[] };
506
+ current.tokens += miss.tokens;
507
+ current.count++;
508
+ current.rows.push(...child.render(width));
509
+ cacheMisses.set(turn, current);
510
+ continue;
511
+ }
471
512
  if (typeof source === "string" && !options.isPrompt?.(source) && options.isTransient?.(source)) {
472
513
  let state = noticeTimes.get(child);
473
514
  if (!state || state.text !== source) {
@@ -481,6 +522,7 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
481
522
  rows.push(...child.render(width));
482
523
  notices.set(turn, rows);
483
524
  }
525
+ flushCache(turn);
484
526
  if (Number.isFinite(nextExpiry)) {
485
527
  cancelExpiry = schedule(() => {
486
528
  cancelExpiry = undefined;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@each1024/pi-mini-mode",
3
- "version": "1.3.14",
3
+ "version": "2.0.0",
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
7
  "check": "tsc --noEmit -p tsconfig.json",
8
- "test": "node test/settings-web.mjs && node test/footer-tidy.mjs && node test/footer-status-self-check.mjs && node test/settings-interaction.mjs && node test/transcript-adapter.mjs && node test/prompt-folding.mjs && node test/tool-folding.mjs && node test/sticky-tool.mjs && node test/minimal-markdown.mjs && node test/agent-view.mjs && node test/publish-self-check.mjs && node test/compaction-transcript.mjs && node test/input-enhancements.mjs && node test/user-message-surface.mjs"
8
+ "test": "node test/settings-web.mjs && node test/footer-tidy.mjs && node test/footer-status-self-check.mjs && node test/settings-interaction.mjs && node test/transcript-adapter.mjs && node test/prompt-folding.mjs && node test/tool-folding.mjs && node test/sticky-tool.mjs && node test/minimal-markdown.mjs && node test/agent-view.mjs && node test/publish-self-check.mjs && node test/compaction-transcript.mjs && node test/input-enhancements.mjs && node test/user-message-surface.mjs && node test/settings-package.mjs",
9
+ "prepublishOnly": "node scripts/publish.mjs --check && npm run check && npm test"
9
10
  },
10
11
  "license": "MIT",
11
12
  "author": "eachann1024",