@notrico/pi-fold 3.0.2 → 3.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release notes
2
2
 
3
+ ## 3.0.3 — Approval layout
4
+
5
+ - Match approval dialogs to the quieter prompt layout: add spacing around the content and choices, mute keyboard hints, and fill only the selected choice. Keep approval decisions and Details controls unchanged.
6
+
3
7
  ## 3.0.2 — Mixed action groups
4
8
 
5
9
  - Group successful completed codemode calls with adjacent bash and file actions. Count each outer call once and retain nested source, calls, and output on expansion.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notrico/pi-fold",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "type": "module",
5
5
  "description": "Pi Fold: readable agent transcripts with collapsible work, inspectable details, and clear final replies",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import { getKeybindings, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component } from '@earendil-works/pi-tui';
2
2
  import type { DisplayMode } from './display-mode.ts';
3
- import { cardContentWidth, cardRow } from './display-card.ts';
3
+ import { cardContentWidth, activityRow } from './display-card.ts';
4
4
 
5
5
  /** Shared with approval owners. This channel carries presentation, never policy. */
6
6
  export const PERMISSION_PRESENTATION_EVENT = 'pi:permission-presentation:v1';
@@ -198,21 +198,27 @@ export class PermissionDialog implements Component {
198
198
  ...field('Action', this.request.action), ...field('Target', this.request.target), ...field('Reason', this.request.reason)];
199
199
  let selectedRow = -1;
200
200
  if (shortened) rows.push(...lines('Summary shortened; full text in Details.'));
201
+ const hints = lines('↑↓ choose · Enter select · Esc deny · d Details');
202
+ if (this.detailsOpen) hints.push(...lines('←/→ page Details · Home/End'));
203
+ const availableRows = this.availableRows();
204
+ // Leave room for the choices and at least one Details row before adding space.
205
+ const padded = rows.length + 3 + hints.length + (this.detailsOpen ? 2 : 0) + 4 <= availableRows;
206
+ if (padded) { rows.unshift(''); rows.push(''); }
201
207
  for (const [index, title] of ['Allow once', 'Deny', `${this.detailsOpen ? 'Hide' : 'Show'} Details`].entries()) {
202
208
  if (index === this.selected) selectedRow = rows.length;
203
209
  const label = truncateToWidth(`${index === this.selected ? '→' : ' '} ${title}`, width, '');
204
210
  rows.push(fg(index === this.selected ? 'accent' : 'text', index === this.selected && this.theme.bold ? this.theme.bold(label) : label));
205
211
  }
206
- const hints = lines('↑↓ choose · Enter select · Esc deny · d Details');
207
- if (this.detailsOpen) hints.push(...lines('←/→ page Details · Home/End'));
208
- this.pageSize = Math.max(1, Math.min(8, this.availableRows() - rows.length - hints.length - 1));
212
+ this.pageSize = Math.max(1, Math.min(8, availableRows - rows.length - hints.length - 1 - (padded ? 2 : 0)));
209
213
  if (this.detailsOpen) {
210
214
  const body = this.detailsViewport.render(width, this.pageSize);
211
215
  const range = this.detailsViewport.range;
212
216
  rows.push(fg('muted', truncateToWidth(`Details · text offset ${range.start}–${range.end}/${range.total}`, width)), ...body);
213
217
  }
214
- rows.push(...hints);
215
- return rows.map((row, index) => cardRow(fg('text', row), outerWidth, this.theme, index === selectedRow ? 'selectedBg' : 'toolPendingBg'));
218
+ if (padded) rows.push('');
219
+ rows.push(...hints.map(row => fg('muted', row)));
220
+ if (padded) rows.push('');
221
+ return rows.map((row, index) => activityRow(fg('text', row), outerWidth, this.theme, index === selectedRow));
216
222
  }
217
223
  handleInput(data: string) {
218
224
  if (this.settled) return;
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';
3
3
  import { homedir } from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { pathToFileURL } from 'node:url';
6
- import { assertCardBackground, themeModule as nativeTheme, stripAnsi } from './test-runtime.mjs';
6
+ import { assertCardBackground, backgroundCells, themeModule as nativeTheme, stripAnsi } from './test-runtime.mjs';
7
7
 
8
8
  const runtime = process.env.PI_RUNTIME || path.join(homedir(), '.local/state/pi-config/current/runtime');
9
9
  const root = process.env.PI_INSTALL_ROOT || path.join(runtime, 'node_modules/@earendil-works/pi-coding-agent');
@@ -25,9 +25,22 @@ for (const details of [false, true]) {
25
25
  const selected = rows.findIndex(row => stripAnsi(row).includes('→'));
26
26
  assert.ok(selected >= 0, 'native permission selection stays visible at narrow widths');
27
27
  assertCardBackground([rows[selected]], width, 'selectedBg');
28
- assertCardBackground(rows.filter((_, index) => index !== selected), width, 'toolPendingBg');
28
+ assert.ok(rows.filter((_, index) => index !== selected).every(row => backgroundCells(row).every(color => color === '')),
29
+ 'only the selected choice has a filled background');
30
+ if (width === 100) {
31
+ assert.equal(stripAnsi(rows[0]).trim(), '', 'approval has top breathing room');
32
+ assert.equal(stripAnsi(rows.at(-1)).trim(), '', 'approval has bottom breathing room');
33
+ }
29
34
  }
30
35
  }
36
+ const approvalLines = styled.render(100).map(stripAnsi);
37
+ const firstChoice = approvalLines.findIndex(row => row.includes('Allow once'));
38
+ assert.equal(approvalLines[firstChoice - 1].trim(), '', 'summary and choices are separated');
39
+ for (const width of [16, 18, 20, 40, 80]) {
40
+ const shortScreen = new PermissionDialog(description, theme, () => {}, () => {}, () => 24);
41
+ shortScreen.handleInput('d');
42
+ assert.ok(shortScreen.render(width).length <= 24, 'optional spacing yields to approval controls on a narrow screen');
43
+ }
31
44
 
32
45
  // Native keybindings, safe default, single resolution and bounded Details.
33
46
  let resolutions = [];