pi-cc-extensions 0.9.0 → 0.9.1
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.
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { getSettingsListTheme } from "@earendil-works/pi-coding-agent";
|
|
8
8
|
import { Input, SettingsList, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
9
9
|
import type { CompactThinkingController } from "../feature/compact-thinking.ts";
|
|
10
|
-
import { applyCustomFooter } from "../feature/shell/footer.ts";
|
|
11
|
-
import { applyStartupHeader } from "../feature/shell/startup-header.ts";
|
|
10
|
+
import { applyCustomFooter, clearCustomFooter } from "../feature/shell/footer.ts";
|
|
11
|
+
import { applyStartupHeader, clearStartupHeader } from "../feature/shell/startup-header.ts";
|
|
12
12
|
import type { ToolGroupingHooks } from "../renderer/tool/grouping.ts";
|
|
13
13
|
import {
|
|
14
14
|
config,
|
|
@@ -474,9 +474,11 @@ export async function showCcstylePanel(
|
|
|
474
474
|
|
|
475
475
|
const onSettingChange = (id: string, value: string) => {
|
|
476
476
|
if (id === "enableCustomFooter") {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
const enabled = value === "on";
|
|
478
|
+
updateConfig({ enableCustomFooter: enabled });
|
|
479
|
+
customFooterToggle.apply(enabled);
|
|
480
|
+
if (enabled) applyCustomFooter(ctx);
|
|
481
|
+
else clearCustomFooter(ctx);
|
|
480
482
|
ctx.ui.notify(`Updated ${id}: ${value}`, "info");
|
|
481
483
|
return;
|
|
482
484
|
}
|
|
@@ -601,14 +603,16 @@ export async function showCcstylePanel(
|
|
|
601
603
|
? "Thinking text uses the theme's dim color."
|
|
602
604
|
: "Keep the default thinking text color.";
|
|
603
605
|
break;
|
|
604
|
-
case "showStartupHeader":
|
|
605
|
-
|
|
606
|
+
case "showStartupHeader": {
|
|
607
|
+
const enabled = value === "on";
|
|
608
|
+
updateConfig({ showStartupHeader: enabled });
|
|
606
609
|
startupHeaderSetting.description = config.showStartupHeader
|
|
607
610
|
? "Show the custom startup header (logo + tips) on new sessions."
|
|
608
611
|
: "Use Pi's native startup header instead.";
|
|
609
|
-
|
|
610
|
-
|
|
612
|
+
if (enabled) applyStartupHeader(ctx);
|
|
613
|
+
else clearStartupHeader(ctx);
|
|
611
614
|
break;
|
|
615
|
+
}
|
|
612
616
|
case "scrollStepLines":
|
|
613
617
|
updateConfig({
|
|
614
618
|
scrollStepLines: pickPositiveInt(value, DEFAULT_CONFIG.scrollStepLines, 1, 50),
|
|
@@ -395,16 +395,9 @@ const createCustomFooterFactory =
|
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
397
|
|
|
398
|
-
/**
|
|
399
|
-
* 按配置应用底栏:on → 自定义 footer;off → 恢复官方默认 footer。
|
|
400
|
-
* 导出供 /ccstyle 面板在切换开关时实时重应用。
|
|
401
|
-
*/
|
|
398
|
+
/** Apply the configured custom footer without disturbing another extension's footer when disabled. */
|
|
402
399
|
export function applyCustomFooter(ctx: ExtensionContext): void {
|
|
403
|
-
if (!ctx?.hasUI || typeof ctx.ui?.setFooter !== "function") return;
|
|
404
|
-
if (!config.enableCustomFooter) {
|
|
405
|
-
ctx.ui.setFooter(undefined);
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
400
|
+
if (!ctx?.hasUI || typeof ctx.ui?.setFooter !== "function" || !config.enableCustomFooter) return;
|
|
408
401
|
try {
|
|
409
402
|
ctx.ui.setFooter(createCustomFooterFactory(ctx));
|
|
410
403
|
} catch (err) {
|
|
@@ -412,6 +405,12 @@ export function applyCustomFooter(ctx: ExtensionContext): void {
|
|
|
412
405
|
}
|
|
413
406
|
}
|
|
414
407
|
|
|
408
|
+
/** Restore Pi's native footer when the user explicitly disables this extension's active footer. */
|
|
409
|
+
export function clearCustomFooter(ctx: ExtensionContext): void {
|
|
410
|
+
if (!ctx?.hasUI || typeof ctx.ui?.setFooter !== "function") return;
|
|
411
|
+
ctx.ui.setFooter(undefined);
|
|
412
|
+
}
|
|
413
|
+
|
|
415
414
|
export default function (pi: ExtensionAPI) {
|
|
416
415
|
// 模型/思考级别变化时强制重渲染(自定义 footer 不会被内置 invalidate() 触达)
|
|
417
416
|
pi.on("model_select", () => {
|
|
@@ -279,15 +279,9 @@ export function renderHeaderLines(
|
|
|
279
279
|
);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
/**
|
|
283
|
-
* 按配置应用启动头:on → 自定义 header;off → 恢复官方默认 header。
|
|
284
|
-
* 导出供 /ccstyle 面板在切换开关时实时重应用。
|
|
285
|
-
*/
|
|
282
|
+
/** 按配置安装启动头。禁用时不碰槽位,避免清掉其他扩展的 header。 */
|
|
286
283
|
export function applyStartupHeader(ctx: any): void {
|
|
287
|
-
if (!ctx?.hasUI || typeof ctx.ui?.setHeader !== "function")
|
|
288
|
-
if (!config.showStartupHeader) {
|
|
289
|
-
// 恢复官方内置 header(logo + 快捷键提示 + onboarding)。
|
|
290
|
-
ctx.ui.setHeader(undefined);
|
|
284
|
+
if (!ctx?.hasUI || typeof ctx.ui?.setHeader !== "function" || !config.showStartupHeader) {
|
|
291
285
|
return;
|
|
292
286
|
}
|
|
293
287
|
ctx.ui.setHeader((_tui: unknown, theme: any) => ({
|
|
@@ -298,6 +292,12 @@ export function applyStartupHeader(ctx: any): void {
|
|
|
298
292
|
}));
|
|
299
293
|
}
|
|
300
294
|
|
|
295
|
+
/** 用户从 /ccstyle 关掉本扩展启动头时,恢复官方 header。 */
|
|
296
|
+
export function clearStartupHeader(ctx: any): void {
|
|
297
|
+
if (!ctx?.hasUI || typeof ctx.ui?.setHeader !== "function") return;
|
|
298
|
+
ctx.ui.setHeader(undefined);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
301
|
export default function piStartupHeader(pi: ExtensionAPI) {
|
|
302
302
|
pi.on("session_start", async (_event, ctx) => {
|
|
303
303
|
applyStartupHeader(ctx);
|