@xynogen/pix-optimizer 1.1.19 → 1.1.20

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/opt.ts +30 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-optimizer",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "Performance optimization suite for Pi Coding Agent - caveman mode + RTK tool rewriting + jq/TOON JSON compression + ponytail lazy-dev mode",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/opt.ts CHANGED
@@ -15,8 +15,13 @@
15
15
  */
16
16
 
17
17
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
18
- import { matchesKey } from "@earendil-works/pi-tui";
19
- import { frameLines } from "@xynogen/pix-pretty/modal-frame";
18
+ import { type KeybindingsManager, matchesKey } from "@earendil-works/pi-tui";
19
+ import {
20
+ frameModal,
21
+ MIN_MODAL_HEIGHT,
22
+ ModalPager,
23
+ terminalModalHeight,
24
+ } from "@xynogen/pix-pretty/modal-frame";
20
25
  import type { OptimizerHandle, OptimizerStatus, OptimizerTool } from "./status.ts";
21
26
  import { toolIcon } from "./status.ts";
22
27
 
@@ -114,12 +119,13 @@ export function registerOptCommand(
114
119
 
115
120
  await ui.custom<null>(
116
121
  (
117
- tui: { requestRender(): void },
122
+ tui: { requestRender(): void; terminal?: { rows?: number } },
118
123
  theme: typeof ui.theme,
119
- _kb: unknown,
124
+ kb: KeybindingsManager,
120
125
  done: (v: null) => void,
121
126
  ) => {
122
127
  let selected = 0;
128
+ const pager = new ModalPager();
123
129
 
124
130
  const cycle = (direction: -1 | 1) => {
125
131
  const tool = TOOL_ORDER[selected] as OptimizerTool;
@@ -131,6 +137,7 @@ export function registerOptCommand(
131
137
 
132
138
  const move = (direction: -1 | 1) => {
133
139
  selected = (selected + direction + TOOL_ORDER.length) % TOOL_ORDER.length;
140
+ pager.followSelection();
134
141
  };
135
142
 
136
143
  return {
@@ -149,24 +156,32 @@ export function registerOptCommand(
149
156
  const bar = theme.fg(on ? "accent" : "dim", levelBar(cur, handles[tool].values));
150
157
  return `${cursor} ${glyph} ${name} ${value} ${bar}`;
151
158
  });
152
- const lines = [
153
- theme.fg("accent", theme.bold("󱎫 Optimizer")),
154
- "",
155
- ...rows,
156
- "",
157
- theme.fg("dim", helpSummary(handles[TOOL_ORDER[selected] as OptimizerTool].help)),
158
- "",
159
- theme.fg("dim", "←→ change · ↑↓ move · esc close"),
160
- ];
161
- return frameLines({
159
+ const result = frameModal({
162
160
  width: boxW,
163
- lines,
161
+ maxHeight: terminalModalHeight(tui.terminal?.rows),
162
+ minHeight: MIN_MODAL_HEIGHT,
163
+ header: [theme.fg("accent", theme.bold("󱎫 Optimizer")), ""],
164
+ body: rows,
165
+ footer: [
166
+ "",
167
+ theme.fg("dim", helpSummary(handles[TOOL_ORDER[selected] as OptimizerTool].help)),
168
+ "",
169
+ theme.fg("dim", "←→ change · ↑↓ move · PgUp/PgDn inspect · esc close"),
170
+ ],
171
+ bodyOffset: pager.bodyOffset,
172
+ selectedBodyLine: pager.selectedLine(selected),
164
173
  color: (s) => theme.fg("accent", s),
165
174
  bg: (s) => theme.bg("customMessageBg", s),
166
175
  });
176
+ pager.sync(result);
177
+ return result.lines;
167
178
  },
168
179
  invalidate: () => {},
169
180
  handleInput: (data: string) => {
181
+ if (pager.handleInput(data, kb)) {
182
+ tui.requestRender();
183
+ return;
184
+ }
170
185
  // matchesKey handles both legacy bytes and Kitty CSI-u encodings
171
186
  // for letters and special keys alike — raw string compares like
172
187
  // `data === "k"` silently fail under the Kitty keyboard protocol.