@0xkahi/pi-qol 1.0.1 → 1.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/README.md CHANGED
@@ -110,7 +110,8 @@ them (project overrides global):
110
110
  "hide_tabs": { "groups": false, "search": false }
111
111
  },
112
112
  "context_view": {
113
- "enabled": true
113
+ "enabled": true,
114
+ "layout": "inline"
114
115
  },
115
116
  "custom_footer": {
116
117
  "enabled": true,
@@ -174,10 +175,11 @@ Duplicate favourite declarations remain first-entry-wins.
174
175
  | Key | Type | Default | Description |
175
176
  | --------- | --------- | ------- | ----------- |
176
177
  | `enabled` | `boolean` | `false` | Enable the Context View capture and interface. |
178
+ | `layout` | `enum` | `inline` | Context View presentation: `inline` or centered `overlay`. |
177
179
 
178
180
  ### Context View
179
181
 
180
- Context View is a fork of Dmitry Makarov's [pi-context-view](https://github.com/dimk90/pi-context-view), adapted into one unified tabbed interface with Vim-friendly keybindings. Enable it, then run `/context-view` with no arguments. The Usage tab opens first; Tab and Shift+Tab switch between Usage and Injections. Use `j`/`k` or arrows to move, `Ctrl+u`/`Ctrl+d` to move by a page, `gg`/`G` to jump to the beginning/end, Enter to preview, and Esc or `q` to return or close. Other extensions can open the same view by emitting `pi.vimKeys.event:pi-qol.context_view`.
182
+ Context View is a fork of Dmitry Makarov's [pi-context-view](https://github.com/dimk90/pi-context-view), adapted into one unified tabbed interface with Vim-friendly keybindings. Enable it, then run `/context-view` with no arguments. The Usage tab opens first; Tab and Shift+Tab switch between Usage and Injections. Use `j`/`k` or arrows to move, `Ctrl+u`/`Ctrl+d` to move by a page, `gg`/`G` to jump to the beginning/end, Enter to preview, and Esc or `q` to return or close. By default it opens inline; set `context_view.layout` to `overlay` for a centered overlay. Other extensions can open the same view by emitting `pi.vimKeys.event:pi-qol.context_view`.
181
183
 
182
184
  #### `custom_footer`
183
185
 
@@ -257,13 +257,22 @@
257
257
  },
258
258
  "context_view": {
259
259
  "default": {
260
- "enabled": false
260
+ "enabled": false,
261
+ "layout": "inline"
261
262
  },
262
263
  "type": "object",
263
264
  "properties": {
264
265
  "enabled": {
265
266
  "default": false,
266
267
  "type": "boolean"
268
+ },
269
+ "layout": {
270
+ "default": "inline",
271
+ "type": "string",
272
+ "enum": [
273
+ "inline",
274
+ "overlay"
275
+ ]
267
276
  }
268
277
  }
269
278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xkahi/pi-qol",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "quality of life pi extensions",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -43,9 +43,9 @@
43
43
  "@earendil-works/pi-tui": "*"
44
44
  },
45
45
  "devDependencies": {
46
- "@earendil-works/pi-ai": "^0.83.0",
47
- "@earendil-works/pi-coding-agent": "^0.83.0",
48
- "@earendil-works/pi-tui": "^0.83.0",
46
+ "@earendil-works/pi-ai": "^0.84.0",
47
+ "@earendil-works/pi-coding-agent": "^0.84.0",
48
+ "@earendil-works/pi-tui": "^0.84.0",
49
49
  "@biomejs/biome": "^2.4.15",
50
50
  "@changesets/cli": "^2.31.0",
51
51
  "@types/node": "^24.0.0",
package/src/codemap.md CHANGED
@@ -9,9 +9,9 @@ It coordinates four feature modules:
9
9
  - **auto_session_name**: Generates and applies a concise session title from the user's first message before the agent runs.
10
10
  - **model_select**: Registers a `/select-model` command (plus a cross-extension event) for picking or searching available models with favourites, ordered custom groups, provider filtering, and an inline or overlay layout.
11
11
  - **custom_footer**: Replaces the default footer with a richer status bar showing cwd/branch/session, token/cost/cache stats, context-window usage, subscription-rate usage, and the current model/thinking level.
12
- - **context_view**: Lazily captures and inspects the initial provider context, then opens a bounded half-height inline Usage/Injections interface through `/context-view` or `pi.vimKeys.event:pi-qol.context_view`.
12
+ - **context_view**: Lazily captures and inspects the initial provider context, then opens a bounded half-height Usage/Injections interface through `/context-view` or `pi.vimKeys.event:pi-qol.context_view`, with configurable inline or centered overlay presentation.
13
13
 
14
- Shared concerns live here too: extension configuration loading, path resolution, model/auth resolution, Zod schemas for every feature, and shared libraries under `libs/` — `libs/subscription-usage/` (provider usage facade) and `libs/modal/` (the self-contained modal dialog library used by `model_select` and `context_view`).
14
+ Shared concerns live here too: extension configuration loading, path resolution, model/auth resolution, Zod schemas for every feature, and shared libraries under `libs/` — `libs/subscription-usage/` (provider usage facade) and `libs/modal/` (the self-contained modal dialog shell and presenter used by `model_select` and `context_view`).
15
15
 
16
16
  ## Design Patterns
17
17
 
@@ -52,7 +52,7 @@ Shared concerns live here too: extension configuration loading, path resolution,
52
52
  - Lazy-activates once on `session_start` when enabled; restores previously persisted probe message identities from the session manager.
53
53
  - Owns `before_agent_start` prompt options; freezes the first eligible provider context snapshot on the `context` event.
54
54
  - `input` observes extension empty inputs, `message_start`/`message_end` records probe identities, `turn_start` aborts the current probe, and `agent_settled`/`session_shutdown` settle the probe attempt.
55
- - `/context-view` and the Vim event handler both call `prepareContextViewData`, which triggers a silent authenticated probe when no snapshot exists yet, then opens the `ContextViewDialog`.
55
+ - `/context-view` and the Vim event handler both call `prepareContextViewData`, which triggers a silent authenticated probe when no snapshot exists yet, then opens the `ContextViewDialog` through the shared modal presenter using the configured inline or overlay layout.
56
56
 
57
57
  6. **custom_footer** (`extensions/custom-footer/`)
58
58
  - On first enabled `session_start`, installs a footer component via `ctx.ui.setFooter`.
@@ -16,7 +16,23 @@ export class AutoSessionNameGuard {
16
16
 
17
17
  static isUsersFirstTurn(sessionManager: Pick<SessionManagerForGuards, 'getBranch'>): boolean {
18
18
  // Pi emits before_agent_start before appending the current user message, so a fresh opening turn has zero prior user messages.
19
- const userMsgs = sessionManager.getBranch().filter(entry => entry.type === 'message' && entry.message.role === 'user');
19
+ const userMsgs = sessionManager.getBranch().filter(AutoSessionNameGuard.userEntryFilter);
20
20
  return userMsgs.length === 0;
21
21
  }
22
+
23
+ static isFirstCustomExtensionMessage(sessionManager: Pick<SessionManagerForGuards, 'getBranch'>, whitelist: Set<string>): boolean {
24
+ const customMsg = sessionManager.getBranch().filter(entry => entry.type === 'custom_message' && whitelist.has(entry.customType));
25
+ return customMsg.length === 0;
26
+ }
27
+
28
+ private static userEntryFilter(entry: SessionEntry) {
29
+ if (entry.type !== 'message') return false;
30
+ if (entry.message.role !== 'user') return false;
31
+ const { content } = entry.message;
32
+ if (typeof content === 'string') return content !== '';
33
+ if (content.length === 0) return false;
34
+ const onlyContent = content.length === 1 ? content[0] : undefined;
35
+ if (onlyContent?.type === 'text' && onlyContent.text === '') return false;
36
+ return true;
37
+ }
22
38
  }
@@ -1,6 +1,7 @@
1
- import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
1
+ import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';
2
2
  import type { ConfigLoader } from '../../config-loader';
3
3
  import { ModelResolver } from '../../utils/model-resolver.util';
4
+ // import { parseAgentContentToPrompt } from '../../utils/parse-agent-content.util';
4
5
  import { AutoSessionNameGuard } from './guards';
5
6
  import { AutoSessionNameTitleGenerator } from './title-generator';
6
7
 
@@ -17,15 +18,7 @@ export function registerAutoSessionName(pi: ExtensionAPI, deps: { config: Config
17
18
  titleController = undefined;
18
19
  });
19
20
 
20
- pi.on('before_agent_start', (event, ctx) => {
21
- if (!deps.config.isEnabled('auto_session_name')) return;
22
- if (AutoSessionNameGuard.isSessionNameSet(pi)) return;
23
- if (AutoSessionNameGuard.isChildSession({ startReason: lastSessionStartReason, manager: ctx.sessionManager })) return;
24
- if (!AutoSessionNameGuard.isUsersFirstTurn(ctx.sessionManager)) return;
25
-
26
- const userText = event.prompt?.trim();
27
- if (!userText) return;
28
-
21
+ const setAutoSessionName = (ctx: ExtensionContext, text: string) => {
29
22
  const cfg = deps.config.getAutoSessionName();
30
23
  const configModel = cfg.enabled ? cfg.model : undefined;
31
24
 
@@ -42,7 +35,7 @@ export function registerAutoSessionName(pi: ExtensionAPI, deps: { config: Config
42
35
 
43
36
  const result = await AutoSessionNameTitleGenerator.generateAndApplyTitle({
44
37
  pi,
45
- userText,
38
+ userText: text,
46
39
  resolvedModel: {
47
40
  ...resolved.result,
48
41
  reasoning: resolved.result.reasoning ?? 'minimal',
@@ -70,5 +63,43 @@ export function registerAutoSessionName(pi: ExtensionAPI, deps: { config: Config
70
63
  })().catch(err => {
71
64
  ctx.ui.notify(`(pi-qol) auto_session_name: ${JSON.stringify(err)}`, 'error');
72
65
  });
66
+ };
67
+
68
+ pi.on('before_agent_start', (event, ctx) => {
69
+ if (!deps.config.isEnabled('auto_session_name')) return;
70
+ if (AutoSessionNameGuard.isSessionNameSet(pi)) return;
71
+ if (AutoSessionNameGuard.isChildSession({ startReason: lastSessionStartReason, manager: ctx.sessionManager })) return;
72
+ if (!AutoSessionNameGuard.isUsersFirstTurn(ctx.sessionManager)) return;
73
+
74
+ const userText = event.prompt?.trim();
75
+ if (!userText) return;
76
+
77
+ setAutoSessionName(ctx, userText);
73
78
  });
79
+
80
+ // need fixing, currently does not work
81
+ // pi.on('message_start', (event, ctx) => {
82
+ // // ctx.ui.notify('hello0', 'info');
83
+ // if (!deps.config.isEnabled('auto_session_name')) return;
84
+ // const whitelist = new Set(deps.config.getAutoSessionName().customMessageWhitelist);
85
+ // // ctx.ui.notify(JSON.stringify(deps.config.getAutoSessionName()), 'warning');
86
+ // if (whitelist.size === 0) return;
87
+ // // ctx.ui.notify('hello1', 'info');
88
+ // const message = event.message;
89
+ // if (message.role !== 'custom' || !whitelist.has(message.customType)) {
90
+ // return;
91
+ // }
92
+ //
93
+ // ctx.ui.notify('hello2', 'info');
94
+ // if (AutoSessionNameGuard.isSessionNameSet(pi)) return;
95
+ // ctx.ui.notify('hello3', 'info');
96
+ // if (AutoSessionNameGuard.isChildSession({ startReason: lastSessionStartReason, manager: ctx.sessionManager })) return;
97
+ // ctx.ui.notify('hello4', 'info');
98
+ // if (!AutoSessionNameGuard.isFirstCustomExtensionMessage(ctx.sessionManager, whitelist)) return;
99
+ // ctx.ui.notify('hello5', 'info');
100
+ // const prompt = parseAgentContentToPrompt(message.content);
101
+ // ctx.ui.notify(prompt, 'info');
102
+ // if (!prompt) return;
103
+ // setAutoSessionName(ctx, prompt);
104
+ // });
74
105
  }
@@ -8,7 +8,7 @@ Current features:
8
8
 
9
9
  - `auto-session-name` – automatically generates and applies a concise session title from the user’s first message.
10
10
  - `model-select` – provides an interactive `/select-model` command (and cross-extension activation hook) for choosing models from the registry with permanent Favourites, ordered custom groups, fuzzy search, provider filtering, and inline or overlay layout.
11
- - `context-view` – captures model context contributions and displays Usage/Injections in a bounded half-height inline tabbed interface opened by command or Vim event.
11
+ - `context-view` – captures model context contributions and displays Usage/Injections in a bounded half-height tabbed interface with configurable inline or overlay presentation, opened by command or Vim event.
12
12
  - `custom-footer` – replaces the TUI footer with a richer status bar showing cwd, git branch, session name, model, token/cost usage, context-window usage, and subscription usage.
13
13
 
14
14
  ---
@@ -72,7 +72,7 @@ The registration function wires three `ExtensionAPI` events:
72
72
  2. `showModelSelector` waits for idle when available, refreshes `ctx.modelRegistry`, and attempts an exact provider/model match through `findExactModel`.
73
73
  3. If an exact match succeeds, the model is applied immediately via `applySelectedModel` and the dialog is skipped.
74
74
  4. Otherwise, `buildModelLists` prepares Favourites, ordered group subsets, and Search items. Provider filtering is applied only to Search, and favourite auth/registry warnings are collected.
75
- 5. `ctx.ui.custom` creates a `ModelSelectDialog` configured with the current model, lists, tab visibility, warnings, initial search, and layout.
75
+ 5. The shared `presentModal` helper creates a `ModelSelectDialog` configured with the current model, lists, tab visibility, warnings, initial search, and the resolved frame for the configured layout.
76
76
  6. The dialog shares a single query across visible tabs, preserves per-tab selection, cycles tabs, and renders either inline or as a centered overlay at 85% width.
77
77
  7. On selection, `applySelectedModel` calls `pi.setModel` and, if supported, sets the configured default reasoning level via `pi.setThinkingLevel`; missing auth is reported as an error.
78
78
 
@@ -114,7 +114,7 @@ The registration function wires three `ExtensionAPI` events:
114
114
  2. `before_agent_start` prepares the initial capture; the `context` event freezes the first eligible provider snapshot.
115
115
  3. If the view is opened before capture completes, a silent probe runs; synthetic messages are filtered, sanitized, and persisted by identity only.
116
116
  4. `prepareContextViewData` combines the snapshot, current native prompt/tool data, filtered session messages, and reported usage.
117
- 5. `ContextViewDialog` opens as a Usage-first inline component bounded to 50% of the terminal height, retaining state for both the Usage and Injections tabs.
117
+ 5. `ContextViewDialog` opens as a Usage-first component bounded to 50% of the terminal height; the shared presenter selects inline or centered overlay mounting while retaining state for both tabs.
118
118
  6. Shared navigation (`j`/`k`, arrows, `Ctrl+u`/`d`, `gg`/`G`) is routed through `ui/navigation.ts`.
119
119
 
120
120
  #### Integration points
@@ -197,7 +197,7 @@ The registration function wires three `ExtensionAPI` events:
197
197
  4. **context-view flow**
198
198
  - Lazily activates only when `context_view.enabled` is true at session start.
199
199
  - Captures owned prompt/tool/message inputs, freezes the first provider-context snapshot, and filters exact synthetic-probe identities.
200
- - `/context-view` and `pi.vimKeys.event:pi-qol.context_view` share data preparation and open a bounded half-height Usage-first inline interface.
200
+ - `/context-view` and `pi.vimKeys.event:pi-qol.context_view` share data preparation and open a bounded half-height Usage-first interface through the shared presenter using the configured inline or overlay layout.
201
201
  - The dialog retains Usage/Injections child state and routes Tab plus Vim navigation (`j/k`, `Ctrl+u/d`, `gg/G`).
202
202
 
203
203
  5. **custom-footer flow**
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Responsibility
4
4
 
5
- Provides optional, TUI-only inspection of model-context occupancy and Initial-phase context injections. Disabled by default; lazily registered only after a session starts with `context_view` enabled. Two inspection surfaces are exposed:
5
+ Provides optional, TUI-only inspection of model-context occupancy and Initial-phase context injections. Disabled by default; lazily registered only after a session starts with `context_view` enabled. The interface defaults to inline presentation and can be configured as a centered overlay. Two inspection surfaces are exposed:
6
6
 
7
7
  - `/context-view` command (registered as `context-view`).
8
8
  - `pi.vimKeys.event:pi-qol.context_view` Vim event (defined in `constants.ts` and `src/constants.ts`).
@@ -14,7 +14,7 @@ All captured prompt, tool, skill, context-file, and message content remains proc
14
14
  - **Pure semantic model / pure functions**: `model.ts`, `measure.ts`, `usage.ts`, `ui/injections-model.ts`, `ui/usage-map.ts`, `ui/layout.ts`, `ui/skill-preview.ts` contain no pi or TUI API access and are independently unit-testable.
15
15
  - **State machines**: `InitialCaptureState` (capture-once) and `SilentProbeState` (single probe lifecycle) in `capture.ts` own explicit phases and transitions.
16
16
  - **Controller / data preparation**: `context-view-controller.ts` isolates the command/UI data path from the event-driven capture path.
17
- - **Stateful UI shell with stateful child tabs**: `ContextViewDialog` (shell) retains `UsageView` and `InjectionsView` instances; navigation is shared via `VimNavigation`.
17
+ - **Stateful UI shell with stateful child tabs**: `ContextViewDialog` (shell) retains `UsageView` and `InjectionsView` instances; navigation is shared via `VimNavigation`. The shared modal presenter coordinates its semantic layout with the shell frame and host mounting.
18
18
  - **Event-driven registration**: `index.ts` hooks into `ExtensionAPI` events and only performs work when `config.isEnabled('context_view')` returns true.
19
19
  - **Sanitize-before-persist**: `SilentProbeState` records only `role` and `timestamp` for synthetic messages; raw content is discarded.
20
20
 
@@ -95,12 +95,12 @@ Wires the extension into `ExtensionAPI`.
95
95
 
96
96
  ### `ui/context-view-dialog.ts`
97
97
 
98
- Bounded half-height inline shell.
98
+ Bounded half-height shell with configurable inline or overlay presentation.
99
99
 
100
- - `ContextViewDialog`: implements `Component` and `Focusable` by wrapping a `ModalDialog` from the shared modal library (`src/libs/modal/`), configured with the Vim navigation scheme, half-height bound, and the degraded reason as a shell notice.
100
+ - `ContextViewDialog`: implements `Component` and `Focusable` by wrapping a `ModalDialog` from the shared modal library (`src/libs/modal/`), configured with the presenter-resolved inline/bordered frame, Vim navigation scheme, half-height bound, and the degraded reason as a shell notice.
101
101
  - `Tab`/`Shift+Tab` switches between `usage` and `injections`; both tab instances are retained so each preserves its scroll/selection/preview-layer state.
102
102
  - Vim keys (`j/k`, arrows, `Ctrl+u/d`, `gg/G`, Enter, Esc/`q`) are parsed by the library's `VimNavigationScheme`; unhandled input goes to the active tab.
103
- - Height is bounded to half the terminal by the shell.
103
+ - Height is bounded to half the terminal by the shell in both layouts.
104
104
 
105
105
  ### `ui/usage-view.ts`
106
106
 
@@ -164,7 +164,7 @@ Preview-only recognition of pi `<skill name="...">` wrappers.
164
164
  - builds a current native snapshot from live prompt/tool data;
165
165
  - merges context-only messages from the fallback snapshot;
166
166
  - computes the usage snapshot and opens `ContextViewDialog`.
167
- 7. `ContextViewDialog` opens on the Usage tab, bounded to half terminal height, and routes input to the active tab while retaining both tab states.
167
+ 7. The shared modal presenter opens `ContextViewDialog` using `context_view.layout`; the dialog starts on Usage, remains bounded to half terminal height, and routes input to the active tab while retaining both tab states.
168
168
 
169
169
  ## State Transitions
170
170
 
@@ -191,7 +191,7 @@ Preview-only recognition of pi `<skill name="...">` wrappers.
191
191
 
192
192
  ## Integration Points
193
193
 
194
- - **Config**: `config-loader.isEnabled('context_view')` gates activation and command use.
194
+ - **Config**: `config-loader.isEnabled('context_view')` gates activation and command use; `config-loader.getContextView().layout` selects inline or overlay presentation (default `inline`).
195
195
  - **ExtensionAPI**: `pi.on(...)`, `pi.registerCommand(...)`, `pi.events.on(...)`, `pi.appendEntry(...)`, `pi.getAllTools()`, `pi.getActiveTools()`, `pi.sendUserMessage('')`.
196
196
  - **ExtensionContext**: `ctx.ui.custom<void>()`, `ctx.ui.notify()`, `ctx.abort()`, `ctx.getSystemPrompt()`, `ctx.getSystemPromptOptions()`, `ctx.getContextUsage()`, `ctx.waitForIdle()`, `ctx.mode`, `ctx.model`, `ctx.modelRegistry.hasConfiguredAuth()`, `ctx.sessionManager.getEntries()`, `ctx.sessionManager.getLeafId()`.
197
197
  - **TUI**: `TUI`, `Theme`, `KeybindingsManager`, `Component`, `Focusable`, `Key`, `matchesKey`, `visibleWidth`, `wrapTextWithAnsi`.
@@ -1,5 +1,6 @@
1
1
  import { buildSessionContext, type ExtensionAPI, type ExtensionContext } from '@earendil-works/pi-coding-agent';
2
2
  import type { ConfigLoader } from '../../config-loader';
3
+ import { presentModal } from '../../libs/modal';
3
4
  import { InitialCaptureState, PROBE_IDENTITIES_CUSTOM_TYPE, parsePersistedIdentities, SilentProbeState } from './capture';
4
5
  import { COMMAND_NAME, PI_VIM_KEY_EVENT_ID } from './constants';
5
6
  import { prepareContextViewData } from './context-view-controller';
@@ -28,7 +29,12 @@ function activateContextView(pi: ExtensionAPI, deps: { config: ConfigLoader; ini
28
29
  };
29
30
  const openContextView = async (ctx: ExtensionContext) => {
30
31
  const data = await prepareContextViewData(pi, ctx, capture, probe);
31
- await ctx.ui.custom<void>((tui, theme, keybindings, done) => new ContextViewDialog(tui, theme, keybindings, data, done));
32
+ const config = deps.config.getContextView();
33
+ await presentModal(
34
+ ctx.ui,
35
+ config.layout,
36
+ (tui, theme, keybindings, done, frame) => new ContextViewDialog(tui, theme, keybindings, data, done, frame),
37
+ );
32
38
  };
33
39
 
34
40
  restoreProbeIdentities(deps.initialCtx);
@@ -2,13 +2,13 @@
2
2
 
3
3
  ## Responsibility
4
4
 
5
- This folder contains the TUI components for the Context View feature. It renders an inline, half-height modal dialog with two tabs: **Usage** and **Injections**. Usage visualizes the estimated context-window composition with a proportional map, a selectable category legend, and a chronological content preview per category. Injections lists the hierarchical Initial snapshot of prompt/tool/context-file/skills injections with a per-item text preview. The modules are pure UI helpers: they do not call the Pi API directly and only depend on the shared `model.ts` types and the `@earendil-works/pi-tui` / `@earendil-works/pi-coding-agent` theme interfaces.
5
+ This folder contains the TUI components for the Context View feature. It renders a half-height modal dialog, mounted inline by default or as a centered overlay, with two tabs: **Usage** and **Injections**. Usage visualizes the estimated context-window composition with a proportional map, a selectable category legend, and a chronological content preview per category. Injections lists the hierarchical Initial snapshot of prompt/tool/context-file/skills injections with a per-item text preview. The modules are pure UI helpers: they do not call the Pi API directly and only depend on the shared `model.ts` types and the `@earendil-works/pi-tui` / `@earendil-works/pi-coding-agent` theme interfaces.
6
6
 
7
7
  All modal plumbing — frame borders, tab strip, tab cycling, Vim key parsing, preview layers, dismissal ordering, height bounding, and the help footer — is owned by the shared modal library (`src/libs/modal/`). This folder keeps only Context View content: the two tab strategies and their bespoke rendering.
8
8
 
9
9
  ## Component/Model Structure
10
10
 
11
- - `context-view-dialog.ts` — thin wrapper configuring a `ModalDialog` (Vim navigation scheme, half-height bound, degraded-reason notice) with the Usage and Injections tabs. Keeps the `Component`/`Focusable` surface and the `activeTab` accessor.
11
+ - `context-view-dialog.ts` — thin wrapper configuring a `ModalDialog` (presenter-resolved frame, Vim navigation scheme, half-height bound, degraded-reason notice) with the Usage and Injections tabs. Keeps the `Component`/`Focusable` surface and the `activeTab` accessor.
12
12
  - `usage-view.ts` — the Usage tab (`ModalTab`). Stateful class that renders the context map, category legend, and zoom; category previews are pushed as `PreviewLayer`s. Uses `UsageMap`, `LegendRow`, `UsageMapScale`, `ListNavigator`, and `RenderCache` from the modal library.
13
13
  - `injections-view.ts` — the Injections tab (`ModalTab`). Stateful class that renders the hierarchical list of Initial snapshot rows; item previews are pushed as `PreviewLayer`s. Uses `InjectionRow` and the modal library's `ListNavigator`/`RenderCache`.
14
14
  - `injections-model.ts` — pure presentation model for injections: flattens `InitialSnapshot` into `InjectionRow[]`, maps items by id, and normalizes preview text. (`ListNavigator`/`PreviewScroller` moved to the modal library.)
@@ -26,8 +26,8 @@ All modal plumbing — frame borders, tab strip, tab cycling, Vim key parsing, p
26
26
 
27
27
  ## Rendering/Input/Data Flow
28
28
 
29
- 1. Opening: `index.ts` calls `prepareContextViewData`, then `ctx.ui.custom(...)` to create a `ContextViewDialog` with `usage`, `initial`, and optional `degradedReason`.
30
- 2. The dialog configures `ModalDialog` with `height: 'half'`, `VimNavigationScheme`, the degraded reason as a warning notice, and both tabs.
29
+ 1. Opening: `index.ts` calls `prepareContextViewData`, then `presentModal(...)` creates a `ContextViewDialog` with `usage`, `initial`, optional `degradedReason`, and the frame resolved from `context_view.layout`.
30
+ 2. The presenter configures mounting and frame from `context_view.layout`; the dialog configures `ModalDialog` with `height: 'half'`, `VimNavigationScheme`, the degraded reason as a warning notice, and both tabs.
31
31
  3. On each render cycle the shell renders the frame, tab strip, notices, the active tab's content region (exact bounded height), and the help footer composed of scheme hints, active tab/layer hints, and universal hints.
32
32
  4. Input: the shell handles `Tab`/`Shift+Tab` cycling first, then the Vim scheme. `dismiss` pops the active tab's top layer or closes the dialog; other actions go to the top layer, else the active tab; unmapped raw keys go to the layer or tab.
33
33
  5. Tabs handle list navigation, preview opening (confirm action), and view-local keys. After handling, `tui.requestRender()` is called by the shell.
@@ -64,7 +64,7 @@ All modal plumbing — frame borders, tab strip, tab cycling, Vim key parsing, p
64
64
 
65
65
  ## Integration Points
66
66
 
67
- - **Entry**: `index.ts` calls `openContextView`, which uses `ctx.ui.custom<void>` to instantiate `ContextViewDialog`. This attaches the dialog to the Pi TUI.
67
+ - **Entry**: `index.ts` calls `openContextView`, which uses the shared `presentModal` helper to instantiate and mount `ContextViewDialog` in the configured layout.
68
68
  - **Modal library**: `src/libs/modal/` supplies `ModalDialog`, `VimNavigationScheme`, `ModalTab`/`ModalTabContext` contracts, `ListNavigator`, `PreviewLayer`, `RenderCache`, and layout/text helpers (`BODY_INDENT`, `calculateViewport`, `fitLine`, `spreadLine`, `wrapDescriptionLines`).
69
69
  - **Data contract**: `ContextViewData` from `context-view-controller.ts` supplies `{ initial, usage, degradedReason }`; the dialog maps `degradedReason` to the shell notices slot.
70
70
  - **Usage data source**: `usage.ts` produces `ContextUsageSnapshot` via `computeUsage`, which merges the frozen `InitialSnapshot` with live session messages and reported provider usage. `usage.ts` also provides `collectPreviewEntries`, which `UsageView` uses to flatten a category's chronological entries.
@@ -1,6 +1,6 @@
1
1
  import type { KeybindingsManager, Theme } from '@earendil-works/pi-coding-agent';
2
2
  import type { Component, Focusable, TUI } from '@earendil-works/pi-tui';
3
- import { ModalDialog, VimNavigationScheme } from '../../../libs/modal';
3
+ import { ModalDialog, type ModalFrame, VimNavigationScheme } from '../../../libs/modal';
4
4
  import type { ContextUsageSnapshot, InitialSnapshot } from '../model';
5
5
  import { InjectionsView } from './injections-view';
6
6
  import { UsageView } from './usage-view';
@@ -22,10 +22,18 @@ export interface ContextViewDialogInput {
22
22
  export class ContextViewDialog implements Component, Focusable {
23
23
  private readonly dialog: ModalDialog<undefined>;
24
24
 
25
- constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, input: ContextViewDialogInput, done: (result: undefined) => void) {
25
+ constructor(
26
+ tui: TUI,
27
+ theme: Theme,
28
+ keybindings: KeybindingsManager,
29
+ input: ContextViewDialogInput,
30
+ done: (result: undefined) => void,
31
+ frame: ModalFrame = 'inline',
32
+ ) {
26
33
  this.dialog = new ModalDialog<undefined>(tui, theme, keybindings, {
27
34
  tabs: [new UsageView(theme, { usage: input.usage }), new InjectionsView(theme, { snapshot: input.initial })],
28
35
  navigation: new VimNavigationScheme(),
36
+ frame,
29
37
  height: 'half',
30
38
  notices: input.degradedReason === undefined ? [] : [input.degradedReason],
31
39
  cancelValue: undefined,
@@ -13,11 +13,11 @@ This extension implements the `/select-model` command and its interactive picker
13
13
  - `index.ts`: orchestrates activation, command handling, applying the selected model, setting default reasoning, and bridging registry errors into the dialog.
14
14
  - `model-lists.ts`: queries the registry and prepares favourite, grouped favourite, and searchable model lists; validates favourite entries against the registry and configured auth.
15
15
  - `model-formatter.ts`: pure static utilities for labels, descriptions, sorting, token formatting, capability detection, and search-text generation.
16
- - `model-select-dialog.ts`: thin `ModalDialog` (shared modal library) configuration: one `ListTab` per section (permanent Favourites, groups, Search), a shared filter input, notices for config warnings, and per-section row/empty-state/footer hooks.
16
+ - `model-select-dialog.ts`: thin `ModalDialog` (shared modal library) configuration: one `ListTab` per section (permanent Favourites, groups, Search), a shared filter input, notices for config warnings, and per-section row/empty-state/footer hooks. The shared presenter supplies its resolved inline or bordered frame.
17
17
  - `constants.ts`: command name, cross-extension event ID, and dialog rendering limits.
18
18
  - `types.ts`: shared item, list, tab, and dialog option types.
19
19
  - **Modal library delegation**: `ModelSelectDialog` implements `Component` and `Focusable` by delegating to a `ModalDialog` from `src/libs/modal/`; the shell owns the tab strip, tab cycling, keybinding-driven navigation (wrap-around selection via `ListTab`), the shared filter `Input`, and the help footer.
20
- - **Layout-aware rendering**: the dialog uses the shell's `inline` frame or `bordered` frame (centered by host overlay options) depending on the `model_select.layout` config value.
20
+ - **Layout-aware presentation**: `showModelSelector` passes `model_select.layout` to the shared modal presenter, which coordinates the dialog's inline/bordered frame with normal or centered overlay mounting.
21
21
  - **Defensive guards**: checks feature enablement, UI availability, idle state (`waitForIdle`), exact-match short-circuit, and auth availability before applying a model.
22
22
 
23
23
  ## Data & Control Flow
@@ -42,7 +42,7 @@ This extension implements the `/select-model` command and its interactive picker
42
42
  - Favourites must exist in the registry and have configured auth; missing or unauthenticated entries are collected as warnings and omitted from the list.
43
43
  - Accepted favourites retain exact group memberships; the ordered `groups` config defines the visible group tabs. Duplicate favourite models are deduplicated by provider/id, and duplicate group names are collapsed while preserving configured order.
44
44
  - Any model-registry error is added to the dialog's `configWarnings` so it appears inside the picker.
45
- - `ctx.ui.custom` creates a `ModelSelectDialog` with favourite/group/search lists, tab visibility controls, the current model, warnings, `initialSearch`, `layout`, `defaultReasoning`, and an `onDone` callback. The overlay layout is centered at 85% width with a one-cell margin.
45
+ - The shared `presentModal` helper creates a `ModelSelectDialog` with favourite/group/search lists, tab visibility controls, the current model, warnings, `initialSearch`, resolved frame, `defaultReasoning`, and an `onDone` callback. The overlay layout remains centered at 85% width with a one-cell margin.
46
46
  - The dialog always creates a Favourites tab, adds visible group tabs and optional Search, and renders a width-aware tab strip, shared filter input, warnings, and help footer. If `initialSearch` is non-empty and Search is visible, the dialog starts on the Search tab and seeds the input.
47
47
 
48
48
  5. **User interaction**
@@ -1,6 +1,7 @@
1
1
  import { type Api, getSupportedThinkingLevels, type Model } from '@earendil-works/pi-ai';
2
2
  import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from '@earendil-works/pi-coding-agent';
3
3
  import type { ConfigLoader } from '../../config-loader';
4
+ import { presentModal } from '../../libs/modal';
4
5
  import type { ModelSelectConfig } from '../../schemas/model-select.config.schema';
5
6
  import { COMMAND_NAME, PI_VIM_KEY_EVENT_ID } from './constants';
6
7
  import { ModelFormatter } from './model-formatter';
@@ -44,8 +45,10 @@ export async function showModelSelector(pi: ExtensionAPI, args: string, ctx: Ext
44
45
  const modelLists = await buildModelLists(ctx, config);
45
46
  const registryError = ctx.modelRegistry.getError();
46
47
 
47
- const selected = await ctx.ui.custom<DialogResult>(
48
- (tui, theme, keybindings, done) =>
48
+ const selected = await presentModal<DialogResult>(
49
+ ctx.ui,
50
+ config.layout,
51
+ (tui, theme, keybindings, done, frame) =>
49
52
  new ModelSelectDialog(tui, theme, keybindings, {
50
53
  currentModel: ctx.model,
51
54
  favouriteItems: modelLists.favouriteItems,
@@ -59,19 +62,9 @@ export async function showModelSelector(pi: ExtensionAPI, args: string, ctx: Ext
59
62
  defaultReasoning: config.default_reasoning,
60
63
  configWarnings: registryError ? [`models.json: ${registryError}`] : [],
61
64
  initialSearch: args.trim(),
62
- layout: config.layout,
65
+ frame,
63
66
  onDone: done,
64
67
  }),
65
- config.layout === 'overlay'
66
- ? {
67
- overlay: true,
68
- overlayOptions: {
69
- anchor: 'center',
70
- width: '85%',
71
- margin: 1,
72
- },
73
- }
74
- : undefined,
75
68
  );
76
69
 
77
70
  if (selected) {
@@ -42,7 +42,7 @@ export class ModelSelectDialog implements Component, Focusable {
42
42
  notices: options.configWarnings,
43
43
  maxNoticeLines: MAX_CONFIG_WARNING_LINES,
44
44
  filter: { initialQuery: options.initialSearch },
45
- frame: options.layout === 'overlay' ? 'bordered' : 'inline',
45
+ frame: options.frame,
46
46
  cancelValue: null,
47
47
  onComplete: result => options.onDone(result),
48
48
  });
@@ -1,5 +1,5 @@
1
1
  import type { Api, Model } from '@earendil-works/pi-ai';
2
- import type { ModelSelectLayout } from '../../schemas/model-select.config.schema';
2
+ import type { ModalFrame } from '../../libs/modal';
3
3
  import type { ReasoningLevel } from '../../schemas/shared-config.schema';
4
4
 
5
5
  export type ModelItem = {
@@ -37,6 +37,6 @@ export type DialogOptions = {
37
37
  defaultReasoning?: ReasoningLevel;
38
38
  configWarnings: string[];
39
39
  initialSearch: string;
40
- layout: ModelSelectLayout;
40
+ frame: ModalFrame;
41
41
  onDone: (result: DialogResult) => void;
42
42
  };
@@ -4,14 +4,14 @@
4
4
 
5
5
  `src/libs/` hosts shared, domain-specific library modules that are consumed by extensions and features across the project. It is not a generic utilities folder; modules here encapsulate cohesive business capabilities with stable public APIs.
6
6
 
7
- Currently, the folder contains two modules: the `subscription-usage` module, which fetches and normalizes subscription/rate-limit usage data from upstream OAuth providers (Anthropic, OpenAI Codex) so UI code can display a consistent usage indicator without knowing provider-specific API details; and the `modal` module, a self-contained modal dialog library (shell, navigation schemes, tab strategies, preview layers, list navigation, text helpers) consumed by the `model-select` and `context-view` extensions and copy-portable to other Pi plugins.
7
+ Currently, the folder contains two modules: the `subscription-usage` module, which fetches and normalizes subscription/rate-limit usage data from upstream OAuth providers (Anthropic, OpenAI Codex) so UI code can display a consistent usage indicator without knowing provider-specific API details; and the `modal` module, a self-contained modal dialog library (shell, host presenter, navigation schemes, tab strategies, preview layers, list navigation, text helpers) consumed by the `model-select` and `context-view` extensions and copy-portable to other Pi plugins.
8
8
 
9
9
  ## Directory Map
10
10
 
11
11
  | Directory | Responsibility Summary | Detailed Map |
12
12
  | --- | --- | --- |
13
13
  | `subscription-usage/` | Provider-agnostic subscription/rate-limit usage access behind strategies and a facade. | [View Map](subscription-usage/codemap.md) |
14
- | `modal/` | Shared modal dialog shell, navigation schemes, tab strategies, layers, and layout helpers. | [View Map](modal/codemap.md) |
14
+ | `modal/` | Shared modal dialog shell, semantic inline/overlay presenter, navigation schemes, tab strategies, layers, and layout helpers. | [View Map](modal/codemap.md) |
15
15
 
16
16
  ## Design Patterns
17
17
 
@@ -153,16 +153,23 @@ class InspectorTab implements ModalTab {
153
153
 
154
154
  `PreviewLayer` handles scrolling, the `(12/87)` overflow counter, and Esc-pops-itself. It reacts to navigation actions; raw keys are ignored.
155
155
 
156
- ### Centered overlay
156
+ ### Inline or centered overlay
157
+
158
+ Use the host-facing presenter when the modal's semantic layout is configurable. It keeps the renderer frame and host mounting options synchronized:
157
159
 
158
160
  ```ts
159
- // frame 'bordered' draws the rounded border; the HOST centers it:
160
- await ctx.ui.custom(
161
- (tui, theme, keybindings, done) => new ModalDialog(tui, theme, keybindings, { frame: 'bordered', /* ... */ }),
162
- { overlay: true, overlayOptions: { anchor: 'center', width: '85%', margin: 1 } },
161
+ import { ModalDialog, presentModal } from './libs/modal/index.js';
162
+
163
+ await presentModal(ctx.ui, layout, (tui, theme, keybindings, done, frame) =>
164
+ new ModalDialog(tui, theme, keybindings, {
165
+ frame,
166
+ // ...tabs, height, cancelValue, onComplete: done
167
+ }),
163
168
  );
164
169
  ```
165
170
 
171
+ `layout` is `'inline'` or `'overlay'`. Overlay uses the bordered frame and a centered 85%-width host overlay with one-cell margin; inline uses the normal custom-UI flow and inline rules.
172
+
166
173
  ## Behavior contract (what users can rely on)
167
174
 
168
175
  - **Esc/q** closes the top preview layer first, then the dialog (`onComplete(cancelValue)`).
@@ -174,6 +181,10 @@ await ctx.ui.custom(
174
181
 
175
182
  ## API reference
176
183
 
184
+ ### `presentModal<TResult>`
185
+
186
+ `presentModal(ui, layout, factory)` mounts a modal through Pi's custom-UI API. The factory receives the resolved `ModalFrame` (`'inline'` or `'bordered'`); the helper supplies the matching host overlay options for `'overlay'` and no overlay options for `'inline'`.
187
+
177
188
  ### `ModalDialog<TResult>` options
178
189
 
179
190
  | Option | Type | Default | Purpose |
@@ -10,6 +10,7 @@ The library is self-contained: it imports only from Pi host packages (`@earendil
10
10
 
11
11
  - `types.ts` — Contracts: `NavigationAction`/`NavigationResult`/`NavigationScheme` (pure key→action mappers), `ModalTab` (content strategy), `ModalLayer`, `ModalTabContext` (`pushLayer`), `Hint`.
12
12
  - `modal-dialog.ts` — `ModalDialog<TResult>` shell (`Component + Focusable`). Options: tabs, initial tab, navigation scheme (default `PiKeybindingsScheme`), frame (`inline` rules | `bordered` rounded border), height (`auto` | `half` terminal), title, notices (+ cap), filter, cancel value, completion callback. Routes input: tab cycling (`Tab`/`Shift+Tab`, wrapping, scheme reset) → scheme action (`dismiss` pops the active tab's layer stack or completes with the cancel value; other actions go to the top layer, else active tab) → raw keys (top layer, else filter input, else active tab). Renders frame, strip, notices, filter slot, content region (exact height when bounded), and a footer composed of scheme + tab/layer hints + universal hints. `complete(result)` resolves explicit results (for example selections).
13
+ - `presenter.ts` — `presentModal<TResult>` and `ModalLayout`: host-facing presenter that maps semantic inline/overlay layouts to the renderer frame and Pi custom-UI mounting options (centered 85%-width overlay with one-cell margin).
13
14
  - `navigation/pi-scheme.ts` — `PiKeybindingsScheme`: maps host `tui.select.*` keybindings to actions (default scheme; stateless).
14
15
  - `navigation/vim-scheme.ts` — `VimNavigationScheme`: `j/k`/arrows, `Ctrl+u/d`, `gg/G` chord (cleared by `reset()`), Enter confirm, Esc/`q` dismiss; swallows PageUp/PageDown/Home/End. For read-only inspectors; do not combine with a filter input.
15
16
  - `tabs/list-tab.ts` — `ListTab<T>` generic picker tab: items + row renderer + confirm callback, optional fuzzy filtering (`filterText`) wired to the dialog filter, dynamic count labels, filter captions, footer hook (rendered below the list in all states), empty/no-match messages, fixed or height-driven window, clamp (default) or wrap selection.
@@ -22,7 +23,7 @@ The library is self-contained: it imports only from Pi host packages (`@earendil
22
23
 
23
24
  ## Data & Control Flow
24
25
 
25
- 1. An extension builds `ModalTab`s (commonly `ListTab`, or custom tabs using `ListNavigator`/`PreviewLayer`/`RenderCache`) and constructs `ModalDialog` with frame/height/scheme/filter options plus `cancelValue`/`onComplete`.
26
+ 1. An extension builds `ModalTab`s (commonly `ListTab`, or custom tabs using `ListNavigator`/`PreviewLayer`/`RenderCache`) and calls `presentModal` with a semantic layout. The presenter supplies the resolved frame and host mounting options while the extension constructs `ModalDialog` with its own height/scheme/filter options plus `cancelValue`/`onComplete`.
26
27
  2. The shell attaches a `ModalTabContext` to each tab (for `pushLayer`) and applies any initial filter query.
27
28
  3. The host (`ctx.ui.custom`) drives `render(width)` and `handleInput(data)`; the shell routes input per the order above and calls `tui.requestRender()` after input.
28
29
  4. Confirm flows: scheme `confirm` → tab `handleNavigation` → tab's confirm callback → `dialog.complete(value)`. Dismissal pops the active tab's top layer first, then completes with the cancel value.
@@ -30,5 +31,5 @@ The library is self-contained: it imports only from Pi host packages (`@earendil
30
31
  ## Integration Points
31
32
 
32
33
  - **Consumers**: `src/extensions/model-select/model-select-dialog.ts` (three `ListTab` sections, filter slot, both frame styles, wrap selection) and `src/extensions/context-view/ui/context-view-dialog.ts` (Vim scheme, half-height, notices; custom `UsageView`/`InjectionsView` tabs with `PreviewLayer` previews).
33
- - **Host packages**: `pi-tui` (`Component`, `Focusable`, `Input`, `Key`, `matchesKey`, `fuzzyFilter`, width helpers), `pi-coding-agent` types (`Theme`, `KeybindingsManager`).
34
+ - **Host packages**: `pi-tui` (`Component`, `Focusable`, `Input`, `Key`, `matchesKey`, `fuzzyFilter`, width helpers), `pi-coding-agent` types (`ExtensionUIContext`, `Theme`, `KeybindingsManager`).
34
35
  - **Tests**: `test/modal/` (schemes, shell behavior, self-containment audit).
@@ -7,6 +7,7 @@ export { ListNavigator, type ListNavigatorOptions, PreviewScroller } from './lis
7
7
  export { ModalDialog, type ModalDialogOptions, type ModalFrame, type ModalHeight } from './modal-dialog';
8
8
  export { PiKeybindingsScheme } from './navigation/pi-scheme';
9
9
  export { VimNavigationScheme } from './navigation/vim-scheme';
10
+ export { type ModalComponentFactory, type ModalLayout, presentModal } from './presenter';
10
11
  export { PreviewLayer, type PreviewLayerOptions } from './preview-layer';
11
12
  export { RenderCache } from './render-cache';
12
13
  export { renderTabStrip } from './tab-strip';
@@ -0,0 +1,38 @@
1
+ import type { ExtensionUIContext, KeybindingsManager, Theme } from '@earendil-works/pi-coding-agent';
2
+ import type { Component, TUI } from '@earendil-works/pi-tui';
3
+ import type { ModalFrame } from './modal-dialog';
4
+
5
+ /** Semantic presentation choices for host-mounted modal dialogs. */
6
+ export type ModalLayout = 'inline' | 'overlay';
7
+
8
+ export type ModalComponentFactory<TResult> = (
9
+ tui: TUI,
10
+ theme: Theme,
11
+ keybindings: KeybindingsManager,
12
+ done: (result: TResult) => void,
13
+ frame: ModalFrame,
14
+ ) => Component & { dispose?(): void };
15
+
16
+ /**
17
+ * Mount a modal with a coordinated renderer frame and host presentation.
18
+ *
19
+ * The dialog factory receives the resolved frame while this helper owns the
20
+ * host-specific overlay options, preventing consumers from configuring only
21
+ * one half of an inline/overlay layout.
22
+ */
23
+ export function presentModal<TResult>(ui: ExtensionUIContext, layout: ModalLayout, factory: ModalComponentFactory<TResult>): Promise<TResult> {
24
+ const frame: ModalFrame = layout === 'overlay' ? 'bordered' : 'inline';
25
+ const options =
26
+ layout === 'overlay'
27
+ ? {
28
+ overlay: true,
29
+ overlayOptions: {
30
+ anchor: 'center' as const,
31
+ width: '85%' as const,
32
+ margin: 1,
33
+ },
34
+ }
35
+ : undefined;
36
+
37
+ return ui.custom((tui, theme, keybindings, done) => factory(tui, theme, keybindings, done, frame), options);
38
+ }
@@ -4,6 +4,7 @@ import { ModelConfigSchema } from './shared-config.schema';
4
4
  export const AutoSessionNameConfigSchema = z.object({
5
5
  enabled: z.boolean().default(false),
6
6
  model: ModelConfigSchema.optional(),
7
+ // customMessageWhitelist: z.array(z.string()).describe('a list of pi custom_messages, customType to be used to trigger auto session name'),
7
8
  });
8
9
  export type AutoSessionNameConfig = z.infer<typeof AutoSessionNameConfigSchema>;
9
10
 
@@ -12,7 +12,7 @@ This directory defines the Zod-based configuration schemas for the `pi-qol` plug
12
12
  | `auto-session-name.config.schema.ts` | `AutoSessionNameConfigSchema`, `AutoSessionNameConfig`; `PartialAutoSessionNameConfigSchema`, `PartialAutoSessionNameConfig` | Full and partial schemas for the session-naming feature. |
13
13
  | `model-select.config.schema.ts` | `FavouriteModelSchema` (private); `ModelSelectLayoutSchema`, `ModelSelectLayout`; `HideTabsSchema` (private); `ModelSelectConfigSchema`, `ModelSelectConfig`; `PartialModelSelectConfigSchema`, `PartialModelSelectConfig` | Full and partial schemas for the model picker, including favourites, groups, tab visibility, provider filtering, layout, and default reasoning. |
14
14
  | `custom-footer-config.schema.ts` | `CustomFooterConfigSchema`, `CustomFooterConfig`; `DEFAULT_CUSTOM_FOOTER_CONFIG`; `PartialCustomFooterConfigSchema`, `PartialCustomFooterConfig` | Full and partial schemas for the footer, including colors, icons, and display flags. |
15
- | `context-view.config.schema.ts` | `ContextViewConfigSchema`, `ContextViewConfig`; `DEFAULT_CONTEXT_VIEW_CONFIG`; `PartialContextViewConfigSchema`, `PartialContextViewConfig` | Full and partial schemas for the context-view feature (disabled by default). |
15
+ | `context-view.config.schema.ts` | `ContextViewConfigSchema`, `ContextViewConfig`, `ContextViewLayout`; `DEFAULT_CONTEXT_VIEW_CONFIG`; `PartialContextViewConfigSchema`, `PartialContextViewConfig` | Full and partial schemas for the context-view feature, including inline/overlay layout (disabled and inline by default). |
16
16
  | `config.schema.ts` | `ConfigSchema`, `Config`; `PartialConfigSchema`, `PartialConfig` | Top-level schema that composes all feature schemas and exports the canonical full and partial config types. |
17
17
 
18
18
  ## Schema Composition
@@ -37,7 +37,7 @@ This directory defines the Zod-based configuration schemas for the `pi-qol` plug
37
37
  - `colors: { directory?, modelName?, anthropicUsage?: '#D97706', codexUsage?: '#10B981' }`
38
38
  - `icons: { directory?: ' ', refresh?: ' ', cache?: ' ', cacheRead?: ' ', cacheWrite?: ' ' }`
39
39
  - `display: { tokens?: true, cache?: true }`
40
- - `ContextViewConfigSchema` contains only `enabled: boolean`.
40
+ - `ContextViewConfigSchema` contains `enabled: boolean` and `layout: 'inline' | 'overlay'`.
41
41
  - **Top-level composition**: `ConfigSchema` is a `z.object({ $schema?, auto_session_name, model_select, custom_footer, context_view })` where each feature section is a full feature schema. `PartialConfigSchema` is a parallel object where every feature section is the corresponding partial schema and all keys are optional.
42
42
 
43
43
  ## Defaults & Partial Overrides
@@ -47,7 +47,7 @@ This directory defines the Zod-based configuration schemas for the `pi-qol` plug
47
47
  - `auto_session_name`: default object `{ enabled: false }` (model is omitted).
48
48
  - `model_select`: default object `{ enabled: false, favourite: [], favourite_label: 'Favourites', groups: [], hide_tabs: { groups: false, search: false }, provider_filter: [], layout: 'inline' }` (`default_reasoning` is omitted).
49
49
  - `custom_footer`: default object is derived by `CustomFooterConfigSchema.parse({ enabled: false })`, then re-exported as `DEFAULT_CUSTOM_FOOTER_CONFIG`. This yields all nested default colors, icons, and display flags.
50
- - `context_view`: default object is derived by `ContextViewConfigSchema.parse({})`, re-exported as `DEFAULT_CONTEXT_VIEW_CONFIG`.
50
+ - `context_view`: default object is derived by `ContextViewConfigSchema.parse({})`, re-exported as `DEFAULT_CONTEXT_VIEW_CONFIG`, yielding `{ enabled: false, layout: 'inline' }`.
51
51
  - **Partial schemas** are designed for config-layer merging:
52
52
  - `PartialAutoSessionNameConfigSchema` is generated with `AutoSessionNameConfigSchema.partial()`.
53
53
  - `PartialModelSelectConfigSchema`, `PartialCustomFooterConfigSchema`, and `PartialContextViewConfigSchema` are hand-written to make every field optional, so user/project overrides only specify the keys they want to override.
@@ -73,6 +73,7 @@ All schemas derive TypeScript types via `z.infer`:
73
73
  - `ModelConfig` from `ModelConfigSchema`
74
74
  - `ReasoningLevel` from `ReasoningLevelSchema`
75
75
  - `ModelSelectLayout` from `ModelSelectLayoutSchema`
76
+ - `ContextViewLayout` from `ContextViewLayoutSchema`
76
77
 
77
78
  Because the full schemas use `.default()`, a successfully parsed `Config` has every top-level feature section and every required field fully present. The partial types preserve optionality for layered overrides.
78
79
 
@@ -96,7 +97,7 @@ Because the full schemas use `.default()`, a successfully parsed `Config` has ev
96
97
  - **Runtime configuration loading**: `src/config-loader.ts` imports `ConfigSchema`, `PartialConfigSchema`, and their inferred types. It is the only runtime consumer that validates and merges configs.
97
98
  - **Runtime feature consumers**:
98
99
  - `src/extensions/model-select/index.ts` uses `ModelSelectConfig`.
99
- - `src/extensions/model-select/types.ts` uses `ModelSelectLayout` and `ReasoningLevel`.
100
+ - `src/extensions/model-select/index.ts` uses `ModelSelectLayout` for the shared presenter, while `src/extensions/model-select/types.ts` uses `ReasoningLevel` and the resolved modal frame.
100
101
  - `src/extensions/custom-footer/types.ts` re-exports `Config['custom_footer']` as `CustomFooterConfig` and derives `colors`/`display`/`icons` sub-types.
101
102
  - `src/utils/model-resolver.util.ts` uses `ModelConfig` to resolve optional `{ provider, modelId, reasoning }` into runtime Pi models.
102
103
  - **Tests**: `test/model-select/config-schema.test.ts`, `test/custom-footer/config-schema.test.ts`, `test/context-view/config-schema.test.ts`, and `test/model-select/default-reasoning.test.ts` exercise `ConfigSchema`, `PartialConfigSchema`, and `ModelSelectConfigSchema` to verify defaults, partial behavior, and validation errors.
@@ -8,6 +8,7 @@ export const ConfigSchema = z.object({
8
8
  $schema: z.string().optional(),
9
9
  auto_session_name: AutoSessionNameConfigSchema.default({
10
10
  enabled: false,
11
+ // customMessageWhitelist: [],
11
12
  }),
12
13
  model_select: ModelSelectConfigSchema.default({
13
14
  enabled: false,
@@ -1,7 +1,11 @@
1
1
  import z from 'zod';
2
2
 
3
+ const ContextViewLayoutSchema = z.enum(['inline', 'overlay']);
4
+ export type ContextViewLayout = z.infer<typeof ContextViewLayoutSchema>;
5
+
3
6
  export const ContextViewConfigSchema = z.object({
4
7
  enabled: z.boolean().default(false),
8
+ layout: ContextViewLayoutSchema.default('inline'),
5
9
  });
6
10
  export type ContextViewConfig = z.infer<typeof ContextViewConfigSchema>;
7
11
 
@@ -9,5 +13,6 @@ export const DEFAULT_CONTEXT_VIEW_CONFIG = ContextViewConfigSchema.parse({});
9
13
 
10
14
  export const PartialContextViewConfigSchema = z.object({
11
15
  enabled: z.boolean().optional(),
16
+ layout: ContextViewLayoutSchema.optional(),
12
17
  });
13
18
  export type PartialContextViewConfig = z.infer<typeof PartialContextViewConfigSchema>;
@@ -1,11 +1,11 @@
1
- import type { Api, Model } from '@earendil-works/pi-ai';
1
+ import type { Api, Model, ProviderHeaders } from '@earendil-works/pi-ai';
2
2
  import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
3
3
  import type { ModelConfig } from '../schemas/shared-config.schema';
4
4
 
5
5
  export type ResolvedModel = {
6
6
  model: Model<Api>;
7
7
  apiKey?: string;
8
- headers?: Record<string, string>;
8
+ headers?: ProviderHeaders;
9
9
  reasoning?: ModelConfig['reasoning'];
10
10
  isOauth?: boolean;
11
11
  };
@@ -0,0 +1,10 @@
1
+ import type { ImageContent, TextContent } from '@earendil-works/pi-ai';
2
+
3
+ export function parseAgentContentToPrompt(content: string | (TextContent | ImageContent)[]): string {
4
+ if (typeof content === 'string') return content;
5
+
6
+ return content
7
+ .filter((block): block is TextContent => block.type === 'text')
8
+ .map(block => block.text)
9
+ .join('');
10
+ }