@firstpick/pi-package-webui 0.8.5 → 0.8.7
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 +18 -584
- package/bin/pi-webui-launcher.mjs +22 -0
- package/bin/pi-webui-update-supervisor.mjs +86 -0
- package/bin/pi-webui.mjs +933 -554
- package/index.ts +16 -6
- package/lib/component-update-state.mjs +21 -0
- package/lib/git-workflow-preferences.mjs +20 -2
- package/lib/optional-feature-catalog.mjs +1 -0
- package/lib/sampling-parameter-capabilities.mjs +160 -0
- package/lib/session-summary-core.mjs +4 -3
- package/lib/session-summary-preferences.mjs +16 -1
- package/lib/subagent-launch-slots.mjs +14 -2
- package/lib/trust-boundaries.mjs +16 -0
- package/lib/update/executor.mjs +99 -0
- package/lib/update/journal.mjs +175 -0
- package/lib/update/owners.mjs +70 -0
- package/lib/update/plan.mjs +134 -0
- package/lib/update/resolver.mjs +168 -0
- package/lib/update/supervisor.mjs +238 -0
- package/lib/update/verify.mjs +52 -0
- package/lib/update-commands.mjs +25 -13
- package/lib/webui-workspaces.mjs +17 -1
- package/lib/workspace-session-summaries.mjs +400 -0
- package/package.json +4 -4
- package/public/app.js +2487 -349
- package/public/index.html +200 -51
- package/public/middle-button-drag-scroll.mjs +154 -0
- package/public/sampling-parameter-controls.mjs +361 -0
- package/public/service-worker.js +5 -1
- package/public/stream-output-controller.mjs +327 -0
- package/public/styles.css +666 -71
- package/public/theme-contract.mjs +244 -0
- package/session-summary.ts +164 -4
- package/tests/aur-review-widget-static.test.mjs +2 -1
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-component-updates.spec.mjs +20 -22
- package/tests/browser/interaction-continuity.spec.mjs +2 -2
- package/tests/browser/middle-button-drag-scroll.spec.mjs +145 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +68 -23
- package/tests/browser/sampling-tooltip.spec.mjs +228 -0
- package/tests/browser/session-summary.spec.mjs +131 -3
- package/tests/browser/stream-output-isolation.spec.mjs +510 -0
- package/tests/browser/update-reconnect.spec.mjs +92 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/common-options-submenus-interaction-static.test.mjs +172 -0
- package/tests/common-options-submenus-markup-static.test.mjs +152 -0
- package/tests/component-update-api-static.test.mjs +22 -61
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +13 -237
- package/tests/durable-rpc-supervisor-harness.test.mjs +3 -1
- package/tests/fast-mode-client-static.test.mjs +3 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +49 -0
- package/tests/fixtures/fake-pi.mjs +269 -2
- package/tests/fixtures/update/tree-timeout-descendant.mjs +6 -0
- package/tests/fixtures/update/tree-timeout-parent.mjs +11 -0
- package/tests/git-footer-context-menu-static.test.mjs +58 -0
- package/tests/git-workflow-preferences.test.mjs +7 -1
- package/tests/guided-git-aur-review.test.mjs +4 -3
- package/tests/http-endpoints-harness.test.mjs +274 -23
- package/tests/middle-button-drag-scroll-static.test.mjs +24 -0
- package/tests/middle-button-drag-scroll.test.mjs +170 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +5 -6
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +85 -50
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -3
- package/tests/optional-feature-migration-frontend.test.mjs +9 -5
- package/tests/persistent-ui-layout-static.test.mjs +13 -2
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +43 -0
- package/tests/rpc-supervisor-host.test.mjs +11 -2
- package/tests/safety-guard-auto-review-harness.test.mjs +117 -0
- package/tests/safety-guard-auto-review-static.test.mjs +34 -0
- package/tests/sampling-native-controls-user-flow.test.mjs +752 -0
- package/tests/sampling-parameter-capabilities.test.mjs +167 -0
- package/tests/sampling-parameter-controls.test.mjs +241 -0
- package/tests/session-sampling-helper.test.mjs +228 -0
- package/tests/session-sampling-http.test.mjs +168 -0
- package/tests/session-sampling-ui-static.test.mjs +370 -0
- package/tests/session-summary-core.test.mjs +205 -10
- package/tests/side-panel-section-height-removal-static.test.mjs +34 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/staged-content-hash-contract.test.mjs +52 -11
- package/tests/stream-lifecycle-core.test.mjs +134 -0
- package/tests/stream-output-controller.test.mjs +252 -0
- package/tests/stream-output-isolation-static.test.mjs +89 -0
- package/tests/streaming-ui-coupling.test.mjs +50 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-launch-slots.test.mjs +18 -1
- package/tests/theme-contract.test.mjs +104 -0
- package/tests/theme-customizer-static.test.mjs +82 -0
- package/tests/theme-scheme-mode.test.mjs +15 -0
- package/tests/ui-layout-settings.test.mjs +18 -1
- package/tests/update-api-harness.test.mjs +111 -0
- package/tests/update-commands.test.mjs +15 -45
- package/tests/update-executor-process-tree-harness.test.mjs +22 -0
- package/tests/update-journal-harness.test.mjs +59 -0
- package/tests/update-lock-multiprocess-harness.test.mjs +46 -0
- package/tests/update-owners.test.mjs +27 -0
- package/tests/update-plan.test.mjs +58 -0
- package/tests/update-resolver.test.mjs +56 -0
- package/tests/update-supervisor-harness.test.mjs +57 -0
- package/tests/update-tab-restore-harness.test.mjs +24 -0
- package/tests/update-verify.test.mjs +31 -0
- package/tests/workspace-files-live-updates-static.test.mjs +13 -4
- package/tests/workspace-session-summaries.test.mjs +288 -0
- package/webui-rpc-helper.mjs +119 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
const MESSAGE_UPDATE_KINDS = Object.freeze({
|
|
2
|
+
thinking_start: "thinking",
|
|
3
|
+
thinking_delta: "thinking",
|
|
4
|
+
thinking_end: "thinking",
|
|
5
|
+
text_start: "text",
|
|
6
|
+
text_delta: "text",
|
|
7
|
+
text_end: "text",
|
|
8
|
+
toolcall_start: "tool-call",
|
|
9
|
+
toolcall_delta: "tool-call",
|
|
10
|
+
toolcall_end: "tool-call",
|
|
11
|
+
error: "stream-error",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const COALESCIBLE_DELTA_TYPES = new Set(["thinking_delta", "text_delta", "toolcall_delta"]);
|
|
15
|
+
const DIAGNOSTIC_INDEX_LIMIT = 4096;
|
|
16
|
+
export const DEFAULT_STREAM_PENDING_ENTRY_LIMIT = 128;
|
|
17
|
+
export const DEFAULT_STREAM_PENDING_BYTE_LIMIT = 256 * 1024;
|
|
18
|
+
|
|
19
|
+
export const TRANSCRIPT_STREAM_MESSAGE_UPDATE_TYPES = Object.freeze(Object.keys(MESSAGE_UPDATE_KINDS));
|
|
20
|
+
|
|
21
|
+
export function classifyTranscriptStreamEvent(event) {
|
|
22
|
+
if (event?.type === "tool_execution_update") {
|
|
23
|
+
return Object.freeze({ kind: "tool-execution", subtype: "tool_execution_update", recognized: true, barrier: false });
|
|
24
|
+
}
|
|
25
|
+
if (event?.type !== "message_update") return null;
|
|
26
|
+
const subtype = typeof event.assistantMessageEvent?.type === "string" ? event.assistantMessageEvent.type : "";
|
|
27
|
+
const kind = MESSAGE_UPDATE_KINDS[subtype];
|
|
28
|
+
if (!kind) return Object.freeze({ kind: "unknown-message-update", subtype, recognized: false, barrier: false });
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
kind,
|
|
31
|
+
subtype,
|
|
32
|
+
recognized: true,
|
|
33
|
+
barrier: subtype.endsWith("_end") || subtype === "error",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function defaultScheduleFrame(callback) {
|
|
38
|
+
if (typeof globalThis.requestAnimationFrame === "function") return globalThis.requestAnimationFrame(callback);
|
|
39
|
+
return globalThis.setTimeout(callback, 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function defaultCancelFrame(handle) {
|
|
43
|
+
if (typeof globalThis.cancelAnimationFrame === "function") globalThis.cancelAnimationFrame(handle);
|
|
44
|
+
else globalThis.clearTimeout(handle);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function positiveLimit(value, fallback, name) {
|
|
48
|
+
if (value === undefined) return fallback;
|
|
49
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${name} must be a positive safe integer`);
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function eventByteSize(event) {
|
|
54
|
+
try {
|
|
55
|
+
return Math.max(1, JSON.stringify(event).length * 2);
|
|
56
|
+
} catch {
|
|
57
|
+
return DEFAULT_STREAM_PENDING_BYTE_LIMIT;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function eventDebugIndex(event) {
|
|
62
|
+
const value = Number(event?.isolationDeltaIndex ?? event?.streamIsolationIndex);
|
|
63
|
+
return Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function toolCallIdentity(event) {
|
|
67
|
+
const update = event?.assistantMessageEvent || {};
|
|
68
|
+
return String(event?.toolCallId || update.toolCallId || update.toolCall?.id || update.id || "");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function entryCoalesceKey({ event, classification, owner }) {
|
|
72
|
+
if (COALESCIBLE_DELTA_TYPES.has(classification.subtype)) {
|
|
73
|
+
const update = event?.assistantMessageEvent || {};
|
|
74
|
+
if (typeof update.delta !== "string") return "";
|
|
75
|
+
const contentIndex = Number.isInteger(Number(update.contentIndex)) ? Number(update.contentIndex) : "";
|
|
76
|
+
const toolId = classification.subtype === "toolcall_delta" ? toolCallIdentity(event) : "";
|
|
77
|
+
return `${String(owner ?? "")}|${classification.subtype}|${contentIndex}|${toolId}`;
|
|
78
|
+
}
|
|
79
|
+
if (classification.kind === "tool-execution" && event?.partialResult && typeof event.partialResult === "object") {
|
|
80
|
+
const toolId = toolCallIdentity(event);
|
|
81
|
+
return toolId ? `${String(owner ?? "")}|tool-execution|${toolId}` : "";
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function mergedAdjacentEntry(previous, incoming) {
|
|
87
|
+
const previousKey = entryCoalesceKey(previous);
|
|
88
|
+
if (!previousKey || previousKey !== entryCoalesceKey(incoming)) return null;
|
|
89
|
+
if (incoming.classification.kind === "tool-execution") {
|
|
90
|
+
const event = incoming.event;
|
|
91
|
+
return {
|
|
92
|
+
...incoming,
|
|
93
|
+
event,
|
|
94
|
+
bytes: eventByteSize(event),
|
|
95
|
+
sourceCount: previous.sourceCount + incoming.sourceCount,
|
|
96
|
+
sourceIndexes: [...previous.sourceIndexes, ...incoming.sourceIndexes].slice(-DIAGNOSTIC_INDEX_LIMIT),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const previousUpdate = previous.event.assistantMessageEvent || {};
|
|
100
|
+
const incomingUpdate = incoming.event.assistantMessageEvent || {};
|
|
101
|
+
const event = {
|
|
102
|
+
...incoming.event,
|
|
103
|
+
assistantMessageEvent: {
|
|
104
|
+
...incomingUpdate,
|
|
105
|
+
delta: `${typeof previousUpdate.delta === "string" ? previousUpdate.delta : ""}${typeof incomingUpdate.delta === "string" ? incomingUpdate.delta : ""}`,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
...incoming,
|
|
110
|
+
event,
|
|
111
|
+
bytes: eventByteSize(event),
|
|
112
|
+
sourceCount: previous.sourceCount + incoming.sourceCount,
|
|
113
|
+
sourceIndexes: [...previous.sourceIndexes, ...incoming.sourceIndexes].slice(-DIAGNOSTIC_INDEX_LIMIT),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Owns the bounded frame queue for high-frequency transcript stream events.
|
|
119
|
+
* Adjacent compatible deltas are losslessly coalesced while event-kind and
|
|
120
|
+
* semantic barriers retain server order. Overflow synchronously drains the
|
|
121
|
+
* current batch; a single oversize event is applied directly, never dropped.
|
|
122
|
+
* Every injected sink is transcript-specific and the optional diagnostic hook
|
|
123
|
+
* is inert unless explicitly supplied by a test/debug caller.
|
|
124
|
+
*/
|
|
125
|
+
export function createStreamOutputController({
|
|
126
|
+
scheduleFrame = defaultScheduleFrame,
|
|
127
|
+
cancelFrame = defaultCancelFrame,
|
|
128
|
+
isOwnerCurrent = () => true,
|
|
129
|
+
applyTextUpdate = () => {},
|
|
130
|
+
applyThinkingUpdate = () => {},
|
|
131
|
+
applyToolCallUpdate = () => {},
|
|
132
|
+
applyToolExecutionUpdate = () => {},
|
|
133
|
+
applyStreamError = () => {},
|
|
134
|
+
applyFollowScroll = () => {},
|
|
135
|
+
onUnknownStreamEvent = () => {},
|
|
136
|
+
onStaleOwner = () => {},
|
|
137
|
+
onOverflow = () => {},
|
|
138
|
+
onDiagnostic,
|
|
139
|
+
maxPendingEntries,
|
|
140
|
+
maxPendingBytes,
|
|
141
|
+
} = {}) {
|
|
142
|
+
if (typeof scheduleFrame !== "function" || typeof cancelFrame !== "function") {
|
|
143
|
+
throw new TypeError("scheduleFrame and cancelFrame must be functions");
|
|
144
|
+
}
|
|
145
|
+
const entryLimit = positiveLimit(maxPendingEntries, DEFAULT_STREAM_PENDING_ENTRY_LIMIT, "maxPendingEntries");
|
|
146
|
+
const byteLimit = positiveLimit(maxPendingBytes, DEFAULT_STREAM_PENDING_BYTE_LIMIT, "maxPendingBytes");
|
|
147
|
+
const diagnosticsEnabled = typeof onDiagnostic === "function";
|
|
148
|
+
const emitDiagnostic = diagnosticsEnabled
|
|
149
|
+
? (record) => {
|
|
150
|
+
try {
|
|
151
|
+
onDiagnostic(Object.freeze(record));
|
|
152
|
+
} catch {
|
|
153
|
+
// Test/debug instrumentation must never alter stream behavior.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
: () => {};
|
|
157
|
+
|
|
158
|
+
let frameHandle = null;
|
|
159
|
+
let pending = [];
|
|
160
|
+
let pendingBytes = 0;
|
|
161
|
+
|
|
162
|
+
const ownerIsCurrent = (owner) => owner === undefined || isOwnerCurrent(owner) === true;
|
|
163
|
+
|
|
164
|
+
const reportStale = (event, owner, classification, phase) => {
|
|
165
|
+
onStaleOwner(event, owner);
|
|
166
|
+
emitDiagnostic({ type: "stale", phase, owner, kind: classification?.kind || "", subtype: classification?.subtype || "", index: eventDebugIndex(event) });
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const applyEntry = ({ event, classification, owner, sourceCount = 1, sourceIndexes = [] }) => {
|
|
170
|
+
if (!ownerIsCurrent(owner)) {
|
|
171
|
+
reportStale(event, owner, classification, "apply");
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
let applied = true;
|
|
175
|
+
switch (classification.kind) {
|
|
176
|
+
case "text":
|
|
177
|
+
applyTextUpdate(event, classification);
|
|
178
|
+
break;
|
|
179
|
+
case "thinking":
|
|
180
|
+
applyThinkingUpdate(event, classification);
|
|
181
|
+
break;
|
|
182
|
+
case "tool-call":
|
|
183
|
+
applyToolCallUpdate(event, classification);
|
|
184
|
+
break;
|
|
185
|
+
case "tool-execution":
|
|
186
|
+
applyToolExecutionUpdate(event, classification);
|
|
187
|
+
break;
|
|
188
|
+
case "stream-error":
|
|
189
|
+
applyStreamError(event, classification);
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
onUnknownStreamEvent(event, classification, owner);
|
|
193
|
+
applied = false;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
emitDiagnostic({
|
|
197
|
+
type: "apply",
|
|
198
|
+
owner,
|
|
199
|
+
kind: classification.kind,
|
|
200
|
+
subtype: classification.subtype,
|
|
201
|
+
applied,
|
|
202
|
+
sourceCount,
|
|
203
|
+
sourceIndexes: Object.freeze([...sourceIndexes]),
|
|
204
|
+
});
|
|
205
|
+
return applied;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const drain = () => {
|
|
209
|
+
frameHandle = null;
|
|
210
|
+
if (!pending.length) return 0;
|
|
211
|
+
const entries = pending;
|
|
212
|
+
pending = [];
|
|
213
|
+
pendingBytes = 0;
|
|
214
|
+
let applied = 0;
|
|
215
|
+
for (const entry of entries) {
|
|
216
|
+
if (applyEntry(entry)) applied += 1;
|
|
217
|
+
}
|
|
218
|
+
if (applied > 0) applyFollowScroll();
|
|
219
|
+
emitDiagnostic({ type: "batch", entries: entries.length, sourceCount: entries.reduce((total, entry) => total + entry.sourceCount, 0), applied });
|
|
220
|
+
return applied;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const schedule = () => {
|
|
224
|
+
if (frameHandle !== null) return;
|
|
225
|
+
frameHandle = scheduleFrame(drain);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const flush = () => {
|
|
229
|
+
if (frameHandle !== null) {
|
|
230
|
+
cancelFrame(frameHandle);
|
|
231
|
+
frameHandle = null;
|
|
232
|
+
}
|
|
233
|
+
return drain();
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const applyOversize = (entry) => {
|
|
237
|
+
const applied = applyEntry(entry) ? 1 : 0;
|
|
238
|
+
if (applied) applyFollowScroll();
|
|
239
|
+
emitDiagnostic({ type: "batch", entries: 1, sourceCount: entry.sourceCount, applied, direct: true });
|
|
240
|
+
return applied;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const enqueue = (entry) => {
|
|
244
|
+
const last = pending[pending.length - 1];
|
|
245
|
+
const merged = last ? mergedAdjacentEntry(last, entry) : null;
|
|
246
|
+
if (merged && pendingBytes - last.bytes + merged.bytes <= byteLimit) {
|
|
247
|
+
pending[pending.length - 1] = merged;
|
|
248
|
+
pendingBytes = pendingBytes - last.bytes + merged.bytes;
|
|
249
|
+
emitDiagnostic({ type: "queued", coalesced: true, pendingCount: pending.length, pendingBytes, sourceCount: merged.sourceCount });
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (merged || pending.length >= entryLimit || pendingBytes + entry.bytes > byteLimit) {
|
|
254
|
+
const reason = merged ? "coalesced-byte-limit" : pending.length >= entryLimit ? "entry-limit" : "byte-limit";
|
|
255
|
+
onOverflow({ reason, pendingCount: pending.length, pendingBytes, incomingBytes: entry.bytes });
|
|
256
|
+
emitDiagnostic({ type: "overflow", reason, pendingCount: pending.length, pendingBytes, incomingBytes: entry.bytes });
|
|
257
|
+
flush();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (entry.bytes > byteLimit) {
|
|
261
|
+
onOverflow({ reason: "oversize-event", pendingCount: 0, pendingBytes: 0, incomingBytes: entry.bytes });
|
|
262
|
+
emitDiagnostic({ type: "overflow", reason: "oversize-event", pendingCount: 0, pendingBytes: 0, incomingBytes: entry.bytes });
|
|
263
|
+
applyOversize(entry);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
pending.push(entry);
|
|
268
|
+
pendingBytes += entry.bytes;
|
|
269
|
+
emitDiagnostic({ type: "queued", coalesced: false, pendingCount: pending.length, pendingBytes, sourceCount: entry.sourceCount });
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
return Object.freeze({
|
|
273
|
+
dispatch(event, { owner } = {}) {
|
|
274
|
+
const classification = classifyTranscriptStreamEvent(event);
|
|
275
|
+
if (!classification) return false;
|
|
276
|
+
const index = eventDebugIndex(event);
|
|
277
|
+
emitDiagnostic({ type: "receipt", owner, kind: classification.kind, subtype: classification.subtype, index });
|
|
278
|
+
if (!ownerIsCurrent(owner)) {
|
|
279
|
+
reportStale(event, owner, classification, "dispatch");
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
const entry = {
|
|
283
|
+
event,
|
|
284
|
+
classification,
|
|
285
|
+
owner,
|
|
286
|
+
bytes: eventByteSize(event),
|
|
287
|
+
sourceCount: 1,
|
|
288
|
+
sourceIndexes: diagnosticsEnabled && index !== null ? [index] : [],
|
|
289
|
+
};
|
|
290
|
+
enqueue(entry);
|
|
291
|
+
if (classification.barrier) {
|
|
292
|
+
emitDiagnostic({ type: "barrier", reason: classification.subtype, pendingCount: pending.length, pendingBytes });
|
|
293
|
+
flush();
|
|
294
|
+
} else if (pending.length) {
|
|
295
|
+
schedule();
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
},
|
|
299
|
+
flush,
|
|
300
|
+
barrier(reason = "semantic") {
|
|
301
|
+
emitDiagnostic({ type: "barrier", reason: String(reason || "semantic"), pendingCount: pending.length, pendingBytes });
|
|
302
|
+
return flush();
|
|
303
|
+
},
|
|
304
|
+
cancel(owner) {
|
|
305
|
+
if (owner === undefined) pending = [];
|
|
306
|
+
else pending = pending.filter((entry) => entry.owner !== owner);
|
|
307
|
+
pendingBytes = pending.reduce((total, entry) => total + entry.bytes, 0);
|
|
308
|
+
if (!pending.length && frameHandle !== null) {
|
|
309
|
+
cancelFrame(frameHandle);
|
|
310
|
+
frameHandle = null;
|
|
311
|
+
}
|
|
312
|
+
emitDiagnostic({ type: "cancel", owner, pendingCount: pending.length, pendingBytes });
|
|
313
|
+
},
|
|
314
|
+
pendingCount() {
|
|
315
|
+
return pending.length;
|
|
316
|
+
},
|
|
317
|
+
pendingBytes() {
|
|
318
|
+
return pendingBytes;
|
|
319
|
+
},
|
|
320
|
+
limits() {
|
|
321
|
+
return Object.freeze({ maxPendingEntries: entryLimit, maxPendingBytes: byteLimit });
|
|
322
|
+
},
|
|
323
|
+
hasScheduledFrame() {
|
|
324
|
+
return frameHandle !== null;
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
}
|