@each1024/pi-mini-mode 0.9.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.
@@ -0,0 +1,75 @@
1
+ /** Hide noisy footer statuses (LSP / @build / sandbox / write path, etc.). */
2
+
3
+ type StatusUi = {
4
+ setStatus(key: string, text: string | undefined): void;
5
+ };
6
+
7
+ type ExtensionCtx = {
8
+ ui: StatusUi;
9
+ };
10
+
11
+ type ExtensionAPILike = {
12
+ on(event: string, handler: (...args: any[]) => void): void;
13
+ };
14
+
15
+ const HIDDEN_KEYS = ["pi-lens-lsp", "@build", "build", "sandbox"] as const;
16
+
17
+ function stripAnsi(text: string): string {
18
+ return String(text || "").replace(/\x1b\[[0-9;]*m/g, "");
19
+ }
20
+
21
+ function tidyText(text: string): string {
22
+ return stripAnsi(text)
23
+ .replace(/[\r\n\t]/g, " ")
24
+ .replace(/^[ \t·•|●○]+/g, "")
25
+ .replace(/[ \t·•|●○]+$/g, "")
26
+ .replace(/ +/g, " ")
27
+ .trim();
28
+ }
29
+
30
+ export function hideStatus(key: string, text: string): boolean {
31
+ const k = String(key || "").toLowerCase();
32
+ const v = String(text || "").toLowerCase();
33
+ if (k === "pi-lens-lsp" || k.includes("lsp")) return true;
34
+ if (k === "@build" || k === "build" || k.includes("@build")) return true;
35
+ if (k.includes("sandbox")) return true;
36
+ if (v.includes("lsp")) return true;
37
+ if (v.includes("@build")) return true;
38
+ if (v.includes("sandbox")) return true;
39
+ if (v.includes("unrestricted")) return true;
40
+ if (v.includes("write path")) return true;
41
+ if (!tidyText(text)) return true;
42
+ return false;
43
+ }
44
+
45
+ function wrapSetStatus(ctx: ExtensionCtx): StatusUi["setStatus"] {
46
+ const orig = ctx.ui.setStatus.bind(ctx.ui);
47
+ ctx.ui.setStatus = (key: string, text: string | undefined) => {
48
+ if (text === undefined || hideStatus(key, text)) {
49
+ orig(key, undefined);
50
+ return;
51
+ }
52
+ const visible = stripAnsi(text).replace(/[\r\n\t]/g, " ");
53
+ if (/^[ \t·•|●○]+/.test(visible) || /[ \t·•|●○]+$/.test(visible)) {
54
+ orig(key, tidyText(text) || undefined);
55
+ return;
56
+ }
57
+ orig(key, text);
58
+ };
59
+ return orig;
60
+ }
61
+
62
+ function clearKnownNoise(setStatus: StatusUi["setStatus"]): void {
63
+ for (const key of HIDDEN_KEYS) setStatus(key, undefined);
64
+ }
65
+
66
+ /**
67
+ * Filter noisy setStatus writes.
68
+ * Never call setFooter — swapping the 1-line custom footer with Pi's 2–3 line
69
+ * built-in footer changes height and desyncs differential redraw.
70
+ */
71
+ export default function attachFooterTidy(pi: ExtensionAPILike): void {
72
+ pi.on("session_start", (_event: unknown, ctx: ExtensionCtx) => {
73
+ clearKnownNoise(wrapSetStatus(ctx));
74
+ });
75
+ }