@firstpick/pi-package-webui 0.10.0 → 0.10.2
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/DEVELOPMENT.md +20 -21
- package/README.md +7 -5
- package/TECHNICAL.md +6 -2
- package/bin/pi-webui.mjs +26 -60
- package/index.ts +1 -256
- package/package.json +1 -1
- package/public/app.js +145 -33
- package/public/index.html +10 -7
- package/public/service-worker.js +1 -1
- package/public/styles.css +51 -7
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/interaction-continuity.spec.mjs +9 -3
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/guided-git-activation-static.test.mjs +11 -4
- package/tests/guided-git-fallback-runtime.test.mjs +46 -21
- package/tests/guided-git-fallback-ui-static.test.mjs +3 -3
- package/tests/guided-git-publication-backend-static.test.mjs +10 -5
- package/tests/http-endpoints-harness.test.mjs +5 -9
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +18 -12
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +11 -7
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-prompt-impact-static.test.mjs +67 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/resource-tui-extension.test.mjs +4 -18
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/streaming-ui-coupling.test.mjs +2 -0
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/windows-drive-cwd-picker-static.test.mjs +3 -3
- package/lib/tui-model-profile-selector.mjs +0 -183
- package/lib/tui-resource-selector.mjs +0 -173
- package/tests/tui-model-profile-selector.test.mjs +0 -102
- package/tests/tui-resource-selector.test.mjs +0 -74
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { DynamicBorder } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Container, fuzzyFilter, getKeybindings, Input, Key, matchesKey, Spacer, Text } from "@earendil-works/pi-tui";
|
|
3
|
-
|
|
4
|
-
function keyMatches(data, keybinding, fallback) {
|
|
5
|
-
const keybindings = getKeybindings();
|
|
6
|
-
return keybindings.matches(data, keybinding) || matchesKey(data, fallback);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class TuiResourceSelectorComponent extends Container {
|
|
10
|
-
constructor(config, theme, callbacks) {
|
|
11
|
-
super();
|
|
12
|
-
this.resources = [...new Set(config.resources)];
|
|
13
|
-
this.enabled = new Set(config.enabledResourceNames.filter((name) => this.resources.includes(name)));
|
|
14
|
-
this.theme = theme;
|
|
15
|
-
this.callbacks = callbacks;
|
|
16
|
-
this.filteredResources = [...this.resources];
|
|
17
|
-
this.selectedIndex = 0;
|
|
18
|
-
this.maxVisible = 10;
|
|
19
|
-
this.isDirty = false;
|
|
20
|
-
this._focused = false;
|
|
21
|
-
|
|
22
|
-
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
23
|
-
this.addChild(new Spacer(1));
|
|
24
|
-
this.addChild(new Text(theme.fg("accent", theme.bold(config.title)), 0, 0));
|
|
25
|
-
this.addChild(new Text(theme.fg("muted", config.subtitle), 0, 0));
|
|
26
|
-
this.addChild(new Spacer(1));
|
|
27
|
-
|
|
28
|
-
this.searchInput = new Input();
|
|
29
|
-
this.addChild(this.searchInput);
|
|
30
|
-
this.addChild(new Spacer(1));
|
|
31
|
-
|
|
32
|
-
this.listContainer = new Container();
|
|
33
|
-
this.addChild(this.listContainer);
|
|
34
|
-
this.addChild(new Spacer(1));
|
|
35
|
-
|
|
36
|
-
this.footerText = new Text(this.footer(), 0, 0);
|
|
37
|
-
this.addChild(this.footerText);
|
|
38
|
-
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
39
|
-
this.refresh();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get focused() {
|
|
43
|
-
return this._focused;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
set focused(value) {
|
|
47
|
-
this._focused = value;
|
|
48
|
-
this.searchInput.focused = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
footer() {
|
|
52
|
-
const text = ` Enter toggle · Ctrl+A all · Ctrl+X clear · Ctrl+S save · ${this.enabled.size}/${this.resources.length} enabled`;
|
|
53
|
-
return this.isDirty ? `${this.theme.fg("dim", text)} ${this.theme.fg("warning", "(unsaved)")}` : this.theme.fg("dim", text);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
refresh() {
|
|
57
|
-
const query = this.searchInput.getValue();
|
|
58
|
-
this.filteredResources = query ? fuzzyFilter(this.resources, query, (name) => name) : [...this.resources];
|
|
59
|
-
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredResources.length - 1));
|
|
60
|
-
this.updateList();
|
|
61
|
-
this.footerText.setText(this.footer());
|
|
62
|
-
this.callbacks.onRender?.();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
updateList() {
|
|
66
|
-
this.listContainer.clear();
|
|
67
|
-
if (this.filteredResources.length === 0) {
|
|
68
|
-
this.listContainer.addChild(new Text(this.theme.fg("muted", " No matching resources"), 0, 0));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const startIndex = Math.max(
|
|
73
|
-
0,
|
|
74
|
-
Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredResources.length - this.maxVisible),
|
|
75
|
-
);
|
|
76
|
-
const endIndex = Math.min(startIndex + this.maxVisible, this.filteredResources.length);
|
|
77
|
-
for (let index = startIndex; index < endIndex; index++) {
|
|
78
|
-
const name = this.filteredResources[index];
|
|
79
|
-
const selected = index === this.selectedIndex;
|
|
80
|
-
const prefix = selected ? this.theme.fg("accent", "→ ") : " ";
|
|
81
|
-
const label = selected ? this.theme.fg("accent", name) : name;
|
|
82
|
-
const status = this.enabled.has(name) ? this.theme.fg("success", " ✓") : this.theme.fg("dim", " ✗");
|
|
83
|
-
this.listContainer.addChild(new Text(`${prefix}${label}${status}`, 0, 0));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (startIndex > 0 || endIndex < this.filteredResources.length) {
|
|
87
|
-
this.listContainer.addChild(
|
|
88
|
-
new Text(this.theme.fg("muted", ` (${this.selectedIndex + 1}/${this.filteredResources.length})`), 0, 0),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setFilteredEnabled(enabled) {
|
|
94
|
-
const targets = this.searchInput.getValue() ? this.filteredResources : this.resources;
|
|
95
|
-
for (const name of targets) {
|
|
96
|
-
if (enabled) this.enabled.add(name);
|
|
97
|
-
else this.enabled.delete(name);
|
|
98
|
-
}
|
|
99
|
-
this.isDirty = true;
|
|
100
|
-
this.refresh();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
handleInput(data) {
|
|
104
|
-
const keybindings = getKeybindings();
|
|
105
|
-
|
|
106
|
-
if (keybindings.matches(data, "tui.select.up")) {
|
|
107
|
-
if (this.filteredResources.length > 0) {
|
|
108
|
-
this.selectedIndex = this.selectedIndex === 0 ? this.filteredResources.length - 1 : this.selectedIndex - 1;
|
|
109
|
-
this.updateList();
|
|
110
|
-
this.callbacks.onRender?.();
|
|
111
|
-
}
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (keybindings.matches(data, "tui.select.down")) {
|
|
115
|
-
if (this.filteredResources.length > 0) {
|
|
116
|
-
this.selectedIndex = this.selectedIndex === this.filteredResources.length - 1 ? 0 : this.selectedIndex + 1;
|
|
117
|
-
this.updateList();
|
|
118
|
-
this.callbacks.onRender?.();
|
|
119
|
-
}
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (keybindings.matches(data, "tui.select.confirm")) {
|
|
123
|
-
const name = this.filteredResources[this.selectedIndex];
|
|
124
|
-
if (name) {
|
|
125
|
-
if (this.enabled.has(name)) this.enabled.delete(name);
|
|
126
|
-
else this.enabled.add(name);
|
|
127
|
-
this.isDirty = true;
|
|
128
|
-
this.refresh();
|
|
129
|
-
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (keyMatches(data, "app.models.enableAll", Key.ctrl("a"))) {
|
|
133
|
-
this.setFilteredEnabled(true);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (keyMatches(data, "app.models.clearAll", Key.ctrl("x"))) {
|
|
137
|
-
this.setFilteredEnabled(false);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (keyMatches(data, "app.models.save", Key.ctrl("s"))) {
|
|
141
|
-
this.callbacks.onSave(this.resources.filter((name) => this.enabled.has(name)));
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (matchesKey(data, Key.ctrl("c"))) {
|
|
145
|
-
if (this.searchInput.getValue()) {
|
|
146
|
-
this.searchInput.setValue("");
|
|
147
|
-
this.refresh();
|
|
148
|
-
} else {
|
|
149
|
-
this.callbacks.onCancel();
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (matchesKey(data, Key.escape)) {
|
|
154
|
-
this.callbacks.onCancel();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.searchInput.handleInput(data);
|
|
159
|
-
this.refresh();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
getSearchInput() {
|
|
163
|
-
return this.searchInput;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export async function selectTuiResources(ctx, config) {
|
|
168
|
-
return await ctx.ui.custom((tui, theme, _keybindings, done) => new TuiResourceSelectorComponent(config, theme, {
|
|
169
|
-
onSave: done,
|
|
170
|
-
onCancel: () => done(undefined),
|
|
171
|
-
onRender: () => tui.requestRender(),
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
-
import { TuiModelProfileSelectorComponent } from "../lib/tui-model-profile-selector.mjs";
|
|
4
|
-
|
|
5
|
-
const theme = {
|
|
6
|
-
fg: (_color, text) => text,
|
|
7
|
-
bold: (text) => text,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
function createSelector(config) {
|
|
11
|
-
const selected = [];
|
|
12
|
-
let cancelled = 0;
|
|
13
|
-
const selector = new TuiModelProfileSelectorComponent(
|
|
14
|
-
{
|
|
15
|
-
title: "Tools Model Profile",
|
|
16
|
-
subtitle: "Choose a profile to edit. This does not switch the active model.",
|
|
17
|
-
configuredModelKeys: [],
|
|
18
|
-
...config,
|
|
19
|
-
},
|
|
20
|
-
theme,
|
|
21
|
-
{
|
|
22
|
-
onSelect: (model) => selected.push(model),
|
|
23
|
-
onCancel: () => cancelled++,
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
return { selector, selected, cancelled: () => cancelled };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
33
|
-
provider: index % 2 === 0 ? "alpha" : "beta",
|
|
34
|
-
id: `model-${String(index).padStart(2, "0")}`,
|
|
35
|
-
name: `Model ${index}`,
|
|
36
|
-
}));
|
|
37
|
-
const active = models[12];
|
|
38
|
-
const { selector, selected } = createSelector({
|
|
39
|
-
models,
|
|
40
|
-
activeModelKey: `${active.provider}\0${active.id}`,
|
|
41
|
-
configuredModelKeys: [`${active.provider}\0${active.id}`],
|
|
42
|
-
});
|
|
43
|
-
const rendered = selector.render(120).join("\n");
|
|
44
|
-
assert.match(rendered, /model-12 \[alpha\] \[active\] \[profile\]/, "the picker should open around the active model and mark configured profiles");
|
|
45
|
-
assert.match(rendered, /Model Name: Model 12 · Profile: configured/);
|
|
46
|
-
|
|
47
|
-
selector.handleInput("\x1b[B");
|
|
48
|
-
selector.handleInput("\r");
|
|
49
|
-
assert.equal(selected[0], models[13], "selection should return the exact model object rather than decoding its label");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
54
|
-
provider: "alpha",
|
|
55
|
-
id: `model-${String(index).padStart(2, "0")}`,
|
|
56
|
-
name: `Model ${index}`,
|
|
57
|
-
}));
|
|
58
|
-
const active = models[12];
|
|
59
|
-
const { selector, selected } = createSelector({ models, activeModelKey: `${active.provider}\0${active.id}` });
|
|
60
|
-
for (const character of "model-00") selector.handleInput(character);
|
|
61
|
-
selector.handleInput("\r");
|
|
62
|
-
assert.equal(selected[0], models[0], "a narrowing search should select its first match instead of retaining a stale list index");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
const models = [
|
|
67
|
-
{ provider: "alpha", id: "shared-a", name: "Shared Model" },
|
|
68
|
-
{ provider: "beta", id: "shared-b", name: "Shared Model" },
|
|
69
|
-
{ provider: "gamma", id: "other", name: "Other" },
|
|
70
|
-
];
|
|
71
|
-
const { selector, selected } = createSelector({ models, activeModelKey: "" });
|
|
72
|
-
for (const character of "beta") selector.handleInput(character);
|
|
73
|
-
assert.equal(selector.getSearchInput().getValue(), "beta");
|
|
74
|
-
assert.doesNotMatch(selector.render(100).join("\n"), /\[alpha\]/);
|
|
75
|
-
selector.handleInput("\r");
|
|
76
|
-
assert.equal(selected[0], models[1], "provider search should disambiguate models with the same display name");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
const { selector, cancelled } = createSelector({
|
|
81
|
-
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
82
|
-
activeModelKey: "",
|
|
83
|
-
});
|
|
84
|
-
for (const character of "missing") selector.handleInput(character);
|
|
85
|
-
assert.match(selector.render(100).join("\n"), /No matching models/);
|
|
86
|
-
selector.handleInput("\x03");
|
|
87
|
-
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear search before cancelling");
|
|
88
|
-
assert.equal(cancelled(), 0);
|
|
89
|
-
selector.handleInput("\x03");
|
|
90
|
-
assert.equal(cancelled(), 1);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
const { selector, cancelled } = createSelector({
|
|
95
|
-
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
96
|
-
activeModelKey: "",
|
|
97
|
-
});
|
|
98
|
-
selector.handleInput("\x1b");
|
|
99
|
-
assert.equal(cancelled(), 1, "Escape should cancel model profile selection");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
console.log("tui-model-profile-selector.test.mjs passed");
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
-
import { TuiResourceSelectorComponent } from "../lib/tui-resource-selector.mjs";
|
|
4
|
-
|
|
5
|
-
const theme = {
|
|
6
|
-
fg: (_color, text) => text,
|
|
7
|
-
bold: (text) => text,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
function createSelector(enabledResourceNames = ["alpha", "gamma"]) {
|
|
11
|
-
const saved = [];
|
|
12
|
-
let cancelled = 0;
|
|
13
|
-
const selector = new TuiResourceSelectorComponent(
|
|
14
|
-
{
|
|
15
|
-
title: "Tools Configuration",
|
|
16
|
-
subtitle: "Session only. Changes apply only after Ctrl+S.",
|
|
17
|
-
resources: ["alpha", "beta", "gamma"],
|
|
18
|
-
enabledResourceNames,
|
|
19
|
-
},
|
|
20
|
-
theme,
|
|
21
|
-
{
|
|
22
|
-
onSave: (selection) => saved.push(selection),
|
|
23
|
-
onCancel: () => cancelled++,
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
return { selector, saved, cancelled: () => cancelled };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
const { selector, saved } = createSelector();
|
|
33
|
-
selector.handleInput("\x1b[B");
|
|
34
|
-
selector.handleInput("\r");
|
|
35
|
-
assert.match(selector.render(100).join("\n"), /3\/3 enabled.*\(unsaved\)/);
|
|
36
|
-
selector.handleInput("\x13");
|
|
37
|
-
assert.deepEqual(saved, [["alpha", "beta", "gamma"]], "Ctrl+S should save the current explicit selection");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
const { selector, saved } = createSelector();
|
|
42
|
-
selector.handleInput("b");
|
|
43
|
-
selector.handleInput("e");
|
|
44
|
-
assert.equal(selector.getSearchInput().getValue(), "be");
|
|
45
|
-
assert.doesNotMatch(selector.render(100).join("\n"), /alpha/);
|
|
46
|
-
|
|
47
|
-
selector.handleInput("\x18");
|
|
48
|
-
selector.handleInput("\x13");
|
|
49
|
-
assert.deepEqual(saved.at(-1), ["alpha", "gamma"], "Ctrl+X should clear only resources matching the active search");
|
|
50
|
-
|
|
51
|
-
selector.handleInput("\x01");
|
|
52
|
-
selector.handleInput("\x13");
|
|
53
|
-
assert.deepEqual(saved.at(-1), ["alpha", "beta", "gamma"], "Ctrl+A should enable only resources matching the active search");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
const { selector, cancelled } = createSelector();
|
|
58
|
-
selector.handleInput("z");
|
|
59
|
-
selector.handleInput("z");
|
|
60
|
-
assert.match(selector.render(100).join("\n"), /No matching resources/);
|
|
61
|
-
selector.handleInput("\x03");
|
|
62
|
-
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear a non-empty search before cancelling");
|
|
63
|
-
assert.equal(cancelled(), 0);
|
|
64
|
-
selector.handleInput("\x03");
|
|
65
|
-
assert.equal(cancelled(), 1, "Ctrl+C on an empty search should cancel");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
const { selector, cancelled } = createSelector();
|
|
70
|
-
selector.handleInput("\x1b");
|
|
71
|
-
assert.equal(cancelled(), 1, "Escape should cancel without saving");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log("tui-resource-selector.test.mjs passed");
|