@firstpick/pi-package-webui 0.7.3 → 0.7.5
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 +34 -20
- package/bin/pi-webui.mjs +332 -39
- package/index.ts +10 -1
- package/lib/git-workflow-preferences.mjs +91 -22
- package/lib/subagent-launch-slots.mjs +304 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/lib/webui-output-mode.mjs +97 -0
- package/package.json +22 -22
- package/public/app.js +1629 -69
- package/public/fast-output-live.mjs +179 -0
- package/public/index.html +86 -12
- package/public/service-worker.js +3 -1
- package/public/styles.css +769 -37
- package/public/subagent-launch-slot-state.mjs +64 -0
- package/tests/chat-scroll-intent-static.test.mjs +59 -0
- package/tests/custom-message-markdown-static.test.mjs +15 -0
- package/tests/fast-mode-client-static.test.mjs +169 -0
- package/tests/fast-mode-output-work.test.mjs +69 -0
- package/tests/fast-mode-sse-harness.test.mjs +204 -0
- package/tests/fast-output-live.test.mjs +106 -0
- package/tests/fixtures/fake-pi.mjs +58 -0
- package/tests/fixtures/fast-mode-output-events.mjs +50 -0
- package/tests/footer-middle-truncation.test.mjs +2 -2
- package/tests/git-workflow-preferences.test.mjs +8 -2
- package/tests/http-endpoints-harness.test.mjs +74 -0
- package/tests/mobile-static.test.mjs +86 -15
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +43 -0
- package/tests/subagent-launch-slot-state.test.mjs +36 -0
- package/tests/subagent-launch-slots-static.test.mjs +34 -0
- package/tests/subagent-launch-slots.test.mjs +143 -0
- package/tests/subagents-helper.test.mjs +46 -0
- package/tests/webui-output-mode.test.mjs +73 -0
- package/webui-rpc-helper.mjs +37 -9
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
export const FAST_OUTPUT_FLUSH_INTERVAL_MS = 100;
|
|
2
|
+
|
|
3
|
+
function text(value) {
|
|
4
|
+
return typeof value === "string" ? value : "";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function toolCallName(update = {}) {
|
|
8
|
+
const value = update.name || update.toolName || update.toolCall?.name || "";
|
|
9
|
+
return text(value).trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function toolCallId(update = {}) {
|
|
13
|
+
const value = update.toolCallId || update.toolCall?.id || update.id || "";
|
|
14
|
+
return text(value).trim();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function toolCallArguments(update = {}) {
|
|
18
|
+
const value = update.toolCall?.arguments ?? update.arguments ?? update.args;
|
|
19
|
+
if (typeof value === "string") return value;
|
|
20
|
+
if (value === undefined || value === null) return "";
|
|
21
|
+
try {
|
|
22
|
+
return JSON.stringify(value);
|
|
23
|
+
} catch {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createFastOutputLiveState() {
|
|
29
|
+
return {
|
|
30
|
+
text: "",
|
|
31
|
+
thinking: "",
|
|
32
|
+
toolCall: { id: "", name: "", arguments: "", complete: false },
|
|
33
|
+
changed: false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function seedFastOutputLiveState({ text: seededText = "", thinking: seededThinking = "" } = {}) {
|
|
38
|
+
return {
|
|
39
|
+
...createFastOutputLiveState(),
|
|
40
|
+
text: text(seededText),
|
|
41
|
+
thinking: text(seededThinking),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function fastOutputLiveTextAndThinking(state = {}) {
|
|
46
|
+
return {
|
|
47
|
+
text: text(state.text),
|
|
48
|
+
thinking: text(state.thinking),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function shouldConsumeFastOutputLiveEvent(reduction = {}) {
|
|
53
|
+
return reduction.changed === true || ["text-end", "thinking-end", "toolcall-end"].includes(reduction.kind);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Pure compact-v1 reducer. It consumes only the direct compact fields: no
|
|
58
|
+
* accumulated message or partial snapshot is read, so raw Unicode deltas stay
|
|
59
|
+
* intact until final transcript reconciliation.
|
|
60
|
+
*/
|
|
61
|
+
export function reduceFastOutputLiveEvent(state = createFastOutputLiveState(), event = {}) {
|
|
62
|
+
const update = event?.type === "message_update" && event.assistantMessageEvent && typeof event.assistantMessageEvent === "object"
|
|
63
|
+
? event.assistantMessageEvent
|
|
64
|
+
: null;
|
|
65
|
+
if (!update) return { state, changed: false, kind: "ignored" };
|
|
66
|
+
|
|
67
|
+
const current = {
|
|
68
|
+
text: text(state.text),
|
|
69
|
+
thinking: text(state.thinking),
|
|
70
|
+
toolCall: { ...createFastOutputLiveState().toolCall, ...(state.toolCall || {}) },
|
|
71
|
+
changed: false,
|
|
72
|
+
};
|
|
73
|
+
const delta = text(update.delta);
|
|
74
|
+
let changed = false;
|
|
75
|
+
let kind = "ignored";
|
|
76
|
+
|
|
77
|
+
if (update.type === "text_delta") {
|
|
78
|
+
current.text += delta;
|
|
79
|
+
changed = true;
|
|
80
|
+
kind = "text";
|
|
81
|
+
} else if (update.type === "thinking_delta") {
|
|
82
|
+
current.thinking += delta;
|
|
83
|
+
changed = true;
|
|
84
|
+
kind = "thinking";
|
|
85
|
+
} else if (update.type === "toolcall_delta") {
|
|
86
|
+
current.toolCall = {
|
|
87
|
+
...current.toolCall,
|
|
88
|
+
id: toolCallId(update) || current.toolCall.id,
|
|
89
|
+
name: toolCallName(update) || current.toolCall.name,
|
|
90
|
+
arguments: current.toolCall.arguments + delta,
|
|
91
|
+
complete: false,
|
|
92
|
+
};
|
|
93
|
+
changed = true;
|
|
94
|
+
kind = "toolcall";
|
|
95
|
+
} else if (update.type === "text_end") {
|
|
96
|
+
const finalText = text(update.content) || text(update.text) || delta;
|
|
97
|
+
if (finalText) current.text = finalText;
|
|
98
|
+
changed = Boolean(finalText);
|
|
99
|
+
kind = "text-end";
|
|
100
|
+
} else if (update.type === "thinking_end") {
|
|
101
|
+
const finalThinking = text(update.content) || text(update.thinking) || delta;
|
|
102
|
+
if (finalThinking) current.thinking = finalThinking;
|
|
103
|
+
changed = Boolean(finalThinking);
|
|
104
|
+
kind = "thinking-end";
|
|
105
|
+
} else if (update.type === "toolcall_end" || update.type === "tool_call_end") {
|
|
106
|
+
const argumentsText = toolCallArguments(update) || delta || current.toolCall.arguments;
|
|
107
|
+
current.toolCall = {
|
|
108
|
+
...current.toolCall,
|
|
109
|
+
id: toolCallId(update) || current.toolCall.id,
|
|
110
|
+
name: toolCallName(update) || current.toolCall.name,
|
|
111
|
+
arguments: argumentsText,
|
|
112
|
+
complete: true,
|
|
113
|
+
};
|
|
114
|
+
changed = true;
|
|
115
|
+
kind = "toolcall-end";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!changed) return { state, changed: false, kind };
|
|
119
|
+
current.changed = true;
|
|
120
|
+
return { state: current, changed: true, kind };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* First output flushes immediately. Later writes coalesce to a maximum of one
|
|
125
|
+
* flush per interval. The clock and timer hooks make this deterministic in
|
|
126
|
+
* Node tests as well as browsers.
|
|
127
|
+
*/
|
|
128
|
+
export function createSustainedFlushScheduler({
|
|
129
|
+
flush,
|
|
130
|
+
now = () => Date.now(),
|
|
131
|
+
setTimer = (callback, delay) => setTimeout(callback, delay),
|
|
132
|
+
clearTimer = (timer) => clearTimeout(timer),
|
|
133
|
+
intervalMs = FAST_OUTPUT_FLUSH_INTERVAL_MS,
|
|
134
|
+
} = {}) {
|
|
135
|
+
if (typeof flush !== "function") throw new TypeError("flush is required");
|
|
136
|
+
let timer = null;
|
|
137
|
+
let pending = false;
|
|
138
|
+
let lastFlushAt = null;
|
|
139
|
+
|
|
140
|
+
const run = () => {
|
|
141
|
+
timer = null;
|
|
142
|
+
if (!pending) return false;
|
|
143
|
+
pending = false;
|
|
144
|
+
lastFlushAt = now();
|
|
145
|
+
flush();
|
|
146
|
+
return true;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const schedule = () => {
|
|
150
|
+
if (timer !== null || !pending) return;
|
|
151
|
+
const elapsed = lastFlushAt === null ? intervalMs : Math.max(0, now() - lastFlushAt);
|
|
152
|
+
timer = setTimer(run, Math.max(0, intervalMs - elapsed));
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
request() {
|
|
157
|
+
pending = true;
|
|
158
|
+
if (lastFlushAt === null) return run();
|
|
159
|
+
schedule();
|
|
160
|
+
return false;
|
|
161
|
+
},
|
|
162
|
+
flushNow() {
|
|
163
|
+
if (timer !== null) {
|
|
164
|
+
clearTimer(timer);
|
|
165
|
+
timer = null;
|
|
166
|
+
}
|
|
167
|
+
return run();
|
|
168
|
+
},
|
|
169
|
+
cancel() {
|
|
170
|
+
if (timer !== null) clearTimer(timer);
|
|
171
|
+
timer = null;
|
|
172
|
+
pending = false;
|
|
173
|
+
lastFlushAt = null;
|
|
174
|
+
},
|
|
175
|
+
pending() {
|
|
176
|
+
return pending;
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
package/public/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
14
14
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
15
|
-
<link rel="stylesheet" href="/styles.css?v=
|
|
15
|
+
<link rel="stylesheet" href="/styles.css?v=83" />
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
18
|
<button id="sidePanelExpandButton" class="side-panel-expand-button" type="button" aria-controls="sidePanel" aria-expanded="false" aria-label="Expand side panel" title="Expand side panel">
|
|
@@ -147,6 +147,7 @@
|
|
|
147
147
|
aria-live="polite"
|
|
148
148
|
>Follow-up</button>
|
|
149
149
|
<div id="sessionSkillTags" class="composer-skill-tags" aria-live="polite" hidden></div>
|
|
150
|
+
<span id="featureCategoryTag" class="composer-feature-category-tag" aria-live="polite" aria-atomic="true" hidden></span>
|
|
150
151
|
<button id="conversationModeChip" class="composer-conversation-mode-chip" type="button" aria-live="polite" hidden>Voice: off</button>
|
|
151
152
|
<button id="workflowModeChip" class="composer-workflow-mode-chip" type="button" aria-live="polite" aria-pressed="true" hidden>Workflow: on</button>
|
|
152
153
|
</div>
|
|
@@ -177,14 +178,26 @@
|
|
|
177
178
|
<div id="composerActionsPanel" class="composer-actions-panel" aria-label="Composer actions">
|
|
178
179
|
<button id="newSessionButton" class="composer-new-button" type="button">New</button>
|
|
179
180
|
<button id="compactButton" class="composer-compact-button" type="button" title="Compact the current Pi session context">Compact</button>
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
<div id="workflowModeControls" class="composer-publish-menu composer-workflow-mode-controls" hidden>
|
|
182
|
+
<button
|
|
183
|
+
id="workflowOverlayOpenButton"
|
|
184
|
+
class="composer-icon-button composer-workflow-overlay-open-button"
|
|
185
|
+
type="button"
|
|
186
|
+
aria-label="Open workflow overlay"
|
|
187
|
+
aria-controls="widgetArea"
|
|
188
|
+
aria-expanded="false"
|
|
189
|
+
data-tooltip="Open the minimized workflow overlay."
|
|
190
|
+
hidden
|
|
191
|
+
><svg class="composer-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 12h14M13 6l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
|
|
192
|
+
<button
|
|
193
|
+
id="workflowModeButton"
|
|
194
|
+
class="composer-workflow-mode-button"
|
|
195
|
+
type="button"
|
|
196
|
+
aria-pressed="false"
|
|
197
|
+
data-tooltip="Workflow Mode: generate and run reusable JavaScript orchestration for substantive prompts."
|
|
198
|
+
hidden
|
|
199
|
+
><span>Workflow</span></button>
|
|
200
|
+
</div>
|
|
188
201
|
<button
|
|
189
202
|
id="gitWorkflowButton"
|
|
190
203
|
class="composer-icon-button composer-git-button"
|
|
@@ -407,6 +420,7 @@
|
|
|
407
420
|
|
|
408
421
|
<button id="sidePanelBackdrop" class="side-panel-backdrop" type="button" aria-label="Close side panel" hidden></button>
|
|
409
422
|
<aside id="sidePanel" class="side-panel" role="dialog" aria-label="Control Deck">
|
|
423
|
+
<div id="sidePanelResizeHandle" class="side-panel-resize-handle" role="separator" aria-orientation="vertical" aria-label="Resize Control Deck width" tabindex="0" title="Drag to resize Control Deck"></div>
|
|
410
424
|
<div class="side-panel-header">
|
|
411
425
|
<div class="side-panel-heading">
|
|
412
426
|
<div class="side-panel-brand-row">
|
|
@@ -437,7 +451,7 @@
|
|
|
437
451
|
</h2>
|
|
438
452
|
<div id="sidePanelSectionControls" class="side-panel-section-content" hidden>
|
|
439
453
|
<div class="side-panel-controls">
|
|
440
|
-
<p class="controls-intro">Session controls affect the active Pi tab. Interface preferences are saved in this browser.</p>
|
|
454
|
+
<p class="controls-intro">Session controls affect the active Pi tab. Interface preferences are saved in this browser. Output processing is a shared server default.</p>
|
|
441
455
|
|
|
442
456
|
<section class="control-group" aria-labelledby="sessionControlsTitle">
|
|
443
457
|
<div class="control-group-header">
|
|
@@ -547,6 +561,30 @@
|
|
|
547
561
|
</div>
|
|
548
562
|
</section>
|
|
549
563
|
|
|
564
|
+
<section class="control-group output-processing-control-group" aria-labelledby="outputProcessingControlsTitle">
|
|
565
|
+
<div class="control-group-header">
|
|
566
|
+
<div class="control-group-heading">
|
|
567
|
+
<h3 id="outputProcessingControlsTitle">Output processing</h3>
|
|
568
|
+
<p>Choose the default live-output path for auto-negotiated Web UI connections.</p>
|
|
569
|
+
</div>
|
|
570
|
+
<span class="control-scope-badge">Server</span>
|
|
571
|
+
</div>
|
|
572
|
+
<div class="control-field">
|
|
573
|
+
<div class="control-field-header">
|
|
574
|
+
<label for="fastOutputModeSelect">Fast mode (Experimental)</label>
|
|
575
|
+
<span class="control-field-context">Markdown final output; live thinking expanded; stored thinking grouped and collapsed</span>
|
|
576
|
+
</div>
|
|
577
|
+
<div class="control-action-row">
|
|
578
|
+
<select id="fastOutputModeSelect" title="Output processing mode" aria-describedby="fastOutputModeStatus">
|
|
579
|
+
<option value="normal">Normal</option>
|
|
580
|
+
<option value="compact-v1">Fast</option>
|
|
581
|
+
</select>
|
|
582
|
+
<button id="setFastOutputModeButton" class="control-apply-button" type="button" aria-label="Apply selected output processing mode" disabled>Apply</button>
|
|
583
|
+
</div>
|
|
584
|
+
<div id="fastOutputModeStatus" class="toggle-control-hint" role="status" aria-live="polite">Loading server default…</div>
|
|
585
|
+
</div>
|
|
586
|
+
</section>
|
|
587
|
+
|
|
550
588
|
<section id="networkControlField" class="control-group network-control-field" aria-labelledby="remoteAccessControlsTitle" hidden>
|
|
551
589
|
<div class="control-group-header">
|
|
552
590
|
<div class="control-group-heading">
|
|
@@ -650,7 +688,7 @@
|
|
|
650
688
|
<div id="sidePanelSectionOptionalFeatures" class="side-panel-section-content" hidden>
|
|
651
689
|
<p class="optional-features-description muted">
|
|
652
690
|
For additional WebUI feature requests, please
|
|
653
|
-
<a href="https://github.com/Firstp1ck/
|
|
691
|
+
<a href="https://github.com/Firstp1ck/pi-coding-agent-forge/issues/new" target="_blank" rel="noopener noreferrer">open a GitHub issue</a>
|
|
654
692
|
so they can be reviewed and considered for implementation.
|
|
655
693
|
</p>
|
|
656
694
|
<div id="optionalFeaturesBox" class="optional-features-box muted">Checking optional features…</div>
|
|
@@ -707,6 +745,42 @@
|
|
|
707
745
|
</h2>
|
|
708
746
|
<div id="sidePanelSectionSubagents" class="side-panel-section-content" hidden>
|
|
709
747
|
<p class="subagents-help"><strong>How to use:</strong> Ask Pi to call <code>subagent</code> for ordinary delegation or <code>subagent_gate</code> when failed calls need bounded retries or a success quorum. Active children and retained gate attempts appear here.</p>
|
|
748
|
+
<details id="subagentLaunchSlots" class="subagent-launch-slots">
|
|
749
|
+
<summary class="subagent-launch-slots-summary">
|
|
750
|
+
<span class="subagent-launch-slots-summary-heading">
|
|
751
|
+
<strong id="subagentLaunchSlotsTitle">Agent models</strong>
|
|
752
|
+
<span id="subagentLaunchSlotsSummaryStatus">Launch presets for 8 builtin roles</span>
|
|
753
|
+
</span>
|
|
754
|
+
<span class="subagent-launch-slots-summary-chevron" aria-hidden="true">›</span>
|
|
755
|
+
</summary>
|
|
756
|
+
<div class="subagent-launch-slots-body">
|
|
757
|
+
<div class="subagent-launch-slots-intro">
|
|
758
|
+
<p>Choose model and thinking presets for future same-role launches. Running children are not changed.</p>
|
|
759
|
+
<button id="subagentLaunchSlotsRefresh" type="button">Refresh models</button>
|
|
760
|
+
</div>
|
|
761
|
+
<div class="subagent-launch-slot-scope">
|
|
762
|
+
<label for="subagentLaunchSlotScope">Apply to</label>
|
|
763
|
+
<select id="subagentLaunchSlotScope" aria-describedby="subagentLaunchSlotScopeStatus">
|
|
764
|
+
<option value="user">User default</option>
|
|
765
|
+
<option value="project">This project</option>
|
|
766
|
+
</select>
|
|
767
|
+
<button id="subagentLaunchSlotsInherit" type="button" hidden>Use user defaults</button>
|
|
768
|
+
<p id="subagentLaunchSlotScopeStatus" class="muted"></p>
|
|
769
|
+
</div>
|
|
770
|
+
<p id="subagentLaunchSlotsStatus" class="subagent-launch-slots-status muted" role="status" aria-live="polite">Loading agent models…</p>
|
|
771
|
+
<div id="subagentLaunchSlotRoles" class="subagent-launch-slot-roles" aria-busy="true"></div>
|
|
772
|
+
<div class="subagent-launch-slots-actions">
|
|
773
|
+
<button id="subagentLaunchSlotsSave" class="primary" type="button" disabled>Save agent models</button>
|
|
774
|
+
<span id="subagentLaunchSlotsDirty" class="muted">No unsaved changes</span>
|
|
775
|
+
</div>
|
|
776
|
+
<div id="subagentLaunchSlotsReloadActions" class="subagent-launch-slots-reload-actions" hidden>
|
|
777
|
+
<span>Saved changes apply to future launches after this tab reloads.</span>
|
|
778
|
+
<button id="subagentLaunchSlotsReload" class="primary" type="button">Reload active tab</button>
|
|
779
|
+
<button id="subagentLaunchSlotsLater" type="button">Not now</button>
|
|
780
|
+
</div>
|
|
781
|
+
<p id="subagentLaunchSlotsAnnouncer" class="sr-only" aria-live="polite" aria-atomic="true"></p>
|
|
782
|
+
</div>
|
|
783
|
+
</details>
|
|
710
784
|
<div class="subagent-open-mode-field">
|
|
711
785
|
<label for="subagentOpenModeSelect">Open subagents in</label>
|
|
712
786
|
<select id="subagentOpenModeSelect" aria-describedby="subagentOpenModeStatus">
|
|
@@ -1091,6 +1165,6 @@
|
|
|
1091
1165
|
</form>
|
|
1092
1166
|
</dialog>
|
|
1093
1167
|
|
|
1094
|
-
<script type="module" src="/app.js?v=
|
|
1168
|
+
<script type="module" src="/app.js?v=91"></script>
|
|
1095
1169
|
</body>
|
|
1096
1170
|
</html>
|
package/public/service-worker.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
const CACHE_NAME = "pi-webui-pwa-
|
|
1
|
+
const CACHE_NAME = "pi-webui-pwa-v44";
|
|
2
2
|
const APP_SHELL = [
|
|
3
3
|
"/",
|
|
4
4
|
"/index.html",
|
|
5
5
|
"/styles.css",
|
|
6
6
|
"/app.js",
|
|
7
|
+
"/fast-output-live.mjs",
|
|
8
|
+
"/subagent-launch-slot-state.mjs",
|
|
7
9
|
"/voice-conversation.mjs",
|
|
8
10
|
"/favicon.svg",
|
|
9
11
|
"/apple-touch-icon.png",
|