@theoremjs/studio 0.3.4-next.735.g8d504c6 → 0.3.4-next.753.g176c472
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/installed.mjs +10 -1
- package/label-areas.d.ts +5 -0
- package/label-areas.js +6 -0
- package/package.json +19 -4
- package/page/assets/Badge-D78MvW22.js +1 -0
- package/page/assets/{BottomSheet-Dbh6A5Vl.js → BottomSheet-CS905Wxu.js} +1 -1
- package/page/assets/Card-D_40unTk.js +1 -0
- package/page/assets/CheckboxInput-MMjt4mDv.js +2 -0
- package/page/assets/CodeBlock-DzXH_9DF.js +3 -0
- package/page/assets/CollapsibleGroup-D1qiJpkR.js +1 -0
- package/page/assets/ConsoleFrame-CqQsb1GZ.js +3 -0
- package/page/assets/DateInput-BvG86MuZ.js +1 -0
- package/page/assets/{Dialog-Sd04KQS2.js → Dialog-DUNBjHOI.js} +1 -1
- package/page/assets/{HoverCard-DMyWUvwP.js → HoverCard-DMHc1Gh1.js} +1 -1
- package/page/assets/Icon-3c9WmPTH.js +3 -0
- package/page/assets/{IconButton-DVUFx-8p.js → IconButton-BeI1pXEZ.js} +1 -1
- package/page/assets/IconFilter-BO98ezum.js +1 -0
- package/page/assets/IconHistory-VvDVN7WG.js +1 -0
- package/page/assets/{ItemSwipeLayer-Ckn4X6h9.js → ItemSwipeLayer-BzVkYf4E.js} +1 -1
- package/page/assets/{ListItem-QF7KFt0h.js → ListItem-MWWVygeh.js} +1 -1
- package/page/assets/MenuBottomSheet-BInvPU7g.js +1 -0
- package/page/assets/MenuBottomSheetActionList-CYZ56fty.js +1 -0
- package/page/assets/OverflowList-CoxIfkMv.js +1 -0
- package/page/assets/SchemaFields-Bd9lDE4d.js +1 -0
- package/page/assets/ScrollableArea-CZpbLBeP.js +1 -0
- package/page/assets/SidePanel-Bp_RI52Y.js +2 -0
- package/page/assets/{Text-BOqCfzZC.js → Text-B74VhVA7.js} +2 -2
- package/page/assets/TextInput-D1GkClqk.js +1 -0
- package/page/assets/{TimestampHoverCard-CDCVpEWM.js → TimestampHoverCard-BNDnoAyp.js} +1 -1
- package/page/assets/ToolResultCharts-CI9TdyAV.js +1 -0
- package/page/assets/Toolbar-RbTb26eP.js +1 -0
- package/page/assets/{Tooltip-BWs5DLrM.js → Tooltip-DrSpWxD8.js} +1 -1
- package/page/assets/TraceInspector-aObqeJHi.js +1 -0
- package/page/assets/{TraceOverview-DqCofwm4.js → TraceOverview-D5c_l1Ux.js} +4 -4
- package/page/assets/{_virtual_studio-type-sources-nXG6uotl.js → _virtual_studio-type-sources-Cc4WAdgD.js} +50 -17
- package/page/assets/browser-connection-159CdeHX.js +1 -0
- package/page/assets/browser-engine-DI5i0e2R.js +16 -0
- package/page/assets/browser-transport-Dh5ab7QT.js +45 -0
- package/page/assets/compile-iB2CAmRL.js +2 -0
- package/page/assets/{container.stylex-BmOi-8DQ.js → container.stylex-C2nFBhUj.js} +1 -1
- package/page/assets/{embedding-space-view-CN0VHXXH.js → embedding-space-view-JuXKDaFw.js} +1 -1
- package/page/assets/encode-files-CeZxxjYd.js +1 -0
- package/page/assets/{export-agent-BrN5vTz2.js → export-agent-Cd8Q-cK9.js} +3 -3
- package/page/assets/{fieldParts-CoOpDoax.js → fieldParts-Dtp1EoJQ.js} +1 -1
- package/page/assets/{focusOutline.stylex-BT0kfa4t.js → focusOutline.stylex-B9nWSXsG.js} +1 -1
- package/page/assets/guardrail-tester-CR-zyzhr.js +9 -0
- package/page/assets/highlightRanges-yrVxbmkN.js +51 -0
- package/page/assets/index-DakRjE8R.css +1 -0
- package/page/assets/index-Kvukosz3.js +149 -0
- package/page/assets/{labels-provider-uONlWExD.js → labels-provider-Dc-AJqPH.js} +2 -2
- package/page/assets/{live-messages-_FDpxQYF.js → live-messages-D-SPyR3e.js} +1 -1
- package/page/assets/menuItemRoles-Bod0knkp.js +1 -0
- package/page/assets/prompt-row-CE0EDTVb.js +71 -0
- package/page/assets/prompt-row-beoYzntJ.css +1 -0
- package/page/assets/reader-DtOL_I1x.js +5 -0
- package/page/assets/registry-DP0ArymS.js +1 -0
- package/page/assets/schema-Cv4HAfBT.js +3 -0
- package/page/assets/shaped-data-DCfLI4gb.js +21 -0
- package/page/assets/{stub-J0Ig6FyA.js → stub-REBz-ZC7.js} +1 -1
- package/page/assets/studio-code-pane-DCaWq57x.js +10 -0
- package/page/assets/{studio-console-BG1WmM3M.js → studio-console-bHQq_-86.js} +1 -1
- package/page/assets/studio-decision-BaoUot8U.js +1 -0
- package/page/assets/studio-embedding-BVMWcpVq.js +2 -0
- package/page/assets/studio-host-console-BfLdRxc9.js +2 -0
- package/page/assets/studio-labels-CNc-S7NH.js +3 -0
- package/page/assets/studio-live-DeDSZSSs.js +5 -0
- package/page/assets/studio-map-u2kDE0i4.js +1 -0
- package/page/assets/studio-trace-replay-BInKCErs.js +3 -0
- package/page/assets/{studio-type-checker-CF7Re1aY.js → studio-type-checker-JZuu4iVI.js} +1 -1
- package/page/assets/{tokens.stylex-DkHf0P9C.js → tokens.stylex-BpCwr7Mf.js} +1 -1
- package/page/assets/tool-schema-BwaPiLtT.js +17 -0
- package/page/assets/{trace-patterns-D6TbkLLr.js → trace-patterns-D5Rcl0G4.js} +1 -1
- package/page/assets/{trace-record-YSvR6YMe.js → trace-record--uEnDt_D.js} +1 -1
- package/page/assets/tree-CL4ETBd5.js +3 -0
- package/page/assets/{turn-client-Xn70kpoZ.js → turn-client-B3jV7UKH.js} +2 -2
- package/page/assets/types-BDx4pnrt.js +1 -0
- package/page/assets/use-one-call-D9ArlH1f.js +1 -0
- package/page/assets/use-second-ticker-DhbZ0Soz.js +1 -0
- package/page/assets/{useAnnounce-DTSHZvjg.js → useAnnounce-DOkF3CS1.js} +1 -1
- package/page/assets/useAnnounceRenderedText-aqUr1P16.js +1 -0
- package/page/assets/{useClipboard-CbN9bb4J.js → useClipboard-BC4cMFBa.js} +1 -1
- package/page/assets/useKeyboardHint-BBkDGjRh.js +1 -0
- package/page/assets/useLocale-D8GRz3lz.js +1 -0
- package/page/assets/useMenuDrillIn-tTYG6Wzi.js +1 -0
- package/page/assets/{useMenuPress-DLG1QOiE.js → useMenuPress-DPpqa6F7.js} +1 -1
- package/page/assets/{useResolvedRequired-DbsOcDqy.js → useResolvedRequired-68GOSl0j.js} +1 -1
- package/page/assets/{useTooltip-c097gL_-.js → useTooltip-BaCjTHk-.js} +1 -1
- package/page/assets/{workspace-Bfoebvk4.js → workspace-B6d08n7C.js} +1 -1
- package/page/index.html +53 -42
- package/prompt-doc.d.ts +24 -0
- package/prompt-doc.js +251 -0
- package/read-source.js +25 -33
- package/section-notes.d.ts +16 -2
- package/section-notes.js +16 -2
- package/server/runs.d.ts +17 -0
- package/server/runs.js +73 -0
- package/server/save-session.d.ts +4 -0
- package/server/save-session.js +10 -6
- package/server/serve.js +76 -12
- package/ui/built/theme.css +1 -1
- package/ui/built/theorem-studio.js +1 -1
- package/ui/inspector-context.d.ts +2 -0
- package/ui/inspector-context.js +2 -0
- package/ui/inspector.d.ts +44 -2
- package/ui/inspector.js +20 -9
- package/ui/lib/studio-watch.d.ts +6 -0
- package/ui/lib/studio-watch.js +16 -0
- package/ui/profile-editor.js +47 -40
- package/ui/prompt-editor.css +112 -0
- package/ui/prompt-editor.d.ts +16 -0
- package/ui/prompt-editor.js +315 -0
- package/ui/prompt-line-node.d.ts +29 -0
- package/ui/prompt-line-node.js +112 -0
- package/ui/prompt-row.d.ts +9 -0
- package/ui/prompt-row.js +25 -0
- package/ui/provider-editor.js +2 -1
- package/ui/studio-compare.js +48 -7
- package/ui/studio-save.d.ts +2 -0
- package/ui/studio-save.js +13 -5
- package/ui/studio-screen.js +18 -16
- package/ui/studio-theme.d.ts +1 -1
- package/ui/studio-theme.js +2 -0
- package/ui/studio-trace-replay.js +5 -5
- package/ui/studio.css +42 -14
- package/page/assets/Banner-BXQ3eMGX.js +0 -3
- package/page/assets/Card-DruykyeB.js +0 -1
- package/page/assets/CheckboxInput-CFZ_Wq8-.js +0 -2
- package/page/assets/CodeBlock-CfVOtDeO.js +0 -52
- package/page/assets/CollapsibleGroup-BsIYDnJR.js +0 -1
- package/page/assets/ConsoleFrame-DDSgPsZH.js +0 -3
- package/page/assets/DateInput-CalwZl6a.js +0 -1
- package/page/assets/Icon-BqkS-pIq.js +0 -3
- package/page/assets/IconEye-BB5aY-wQ.js +0 -1
- package/page/assets/MenuBottomSheet-CGBoKe8D.js +0 -1
- package/page/assets/SchemaFields-D7ClAIou.js +0 -1
- package/page/assets/ScrollableArea-ChTx-OVZ.js +0 -1
- package/page/assets/SegmentedControlItem-CZs-ycSA.js +0 -1
- package/page/assets/SidePanel-DEd3R1Q3.js +0 -2
- package/page/assets/ToolResultCharts-DiEXUaNn.js +0 -1
- package/page/assets/TraceInspector-CaNKb5tj.js +0 -1
- package/page/assets/browser-connection-Dm_C2k-h.js +0 -3
- package/page/assets/browser-engine-BfnMGcT2.js +0 -16
- package/page/assets/browser-transport-9tBHJSxP.js +0 -45
- package/page/assets/crypto-DbeKCGAB.js +0 -1
- package/page/assets/encode-files-BdORDAbw.js +0 -1
- package/page/assets/guardrail-tester-BrSKPdyb.js +0 -9
- package/page/assets/index-Boxd3JUw.js +0 -149
- package/page/assets/index-C9rhrCGT.css +0 -1
- package/page/assets/reader-CHvIE7jW.js +0 -5
- package/page/assets/shaped-data-B5yHkAzM.js +0 -21
- package/page/assets/studio-code-pane-B4bfZLeO.js +0 -10
- package/page/assets/studio-decision-Ck3RM4xV.js +0 -1
- package/page/assets/studio-embedding-pvHODyby.js +0 -2
- package/page/assets/studio-host-console-DAv2ocEl.js +0 -2
- package/page/assets/studio-labels-DLm-OIlS.js +0 -3
- package/page/assets/studio-live-BBVkUupj.js +0 -5
- package/page/assets/studio-map-DE4o1Dw6.js +0 -1
- package/page/assets/studio-trace-replay-DMnAw57P.js +0 -3
- package/page/assets/tool-schema-CAhMfN4z.js +0 -17
- package/page/assets/tree-sm5ci1wZ.js +0 -3
- package/page/assets/use-one-call-DJQhFDfz.js +0 -1
- package/page/assets/use-second-ticker-B_tRvZF_.js +0 -1
package/server/runs.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runs that are going on in the project's loads: turns and voice calls, while the page is
|
|
3
|
+
* joined to them. A load holds its runs in memory, so it is not replaced under one.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** Keeps count of the runs. `idle` is called each time the last one ends. */
|
|
8
|
+
export function createRuns(idle) {
|
|
9
|
+
let open = 0;
|
|
10
|
+
const waiting = [];
|
|
11
|
+
const ended = () => {
|
|
12
|
+
// invariant: a waiter runs in the tick the count reaches none, so no run starts between.
|
|
13
|
+
while (open === 0 && waiting.length)
|
|
14
|
+
waiting.shift()?.();
|
|
15
|
+
if (open === 0)
|
|
16
|
+
idle();
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
begin: () => {
|
|
20
|
+
open += 1;
|
|
21
|
+
let over = false;
|
|
22
|
+
return () => {
|
|
23
|
+
if (over)
|
|
24
|
+
return;
|
|
25
|
+
over = true;
|
|
26
|
+
open -= 1;
|
|
27
|
+
if (open === 0)
|
|
28
|
+
ended();
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
busy: () => open > 0,
|
|
32
|
+
whenIdle: (then) => {
|
|
33
|
+
if (open === 0)
|
|
34
|
+
then();
|
|
35
|
+
else
|
|
36
|
+
waiting.push(then);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** `response` as it was, with `end` called when its body is read to the end, fails or is dropped. */
|
|
41
|
+
export function untilRead(response, end) {
|
|
42
|
+
if (!response.body) {
|
|
43
|
+
end();
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
const reader = response.body.getReader();
|
|
47
|
+
const body = new ReadableStream({
|
|
48
|
+
async pull(controller) {
|
|
49
|
+
try {
|
|
50
|
+
const { done, value } = await reader.read();
|
|
51
|
+
if (done) {
|
|
52
|
+
end();
|
|
53
|
+
controller.close();
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
controller.enqueue(value);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
end();
|
|
60
|
+
controller.error(error);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
cancel(reason) {
|
|
64
|
+
end();
|
|
65
|
+
return reader.cancel(reason);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
return new Response(body, {
|
|
69
|
+
status: response.status,
|
|
70
|
+
statusText: response.statusText,
|
|
71
|
+
headers: response.headers,
|
|
72
|
+
});
|
|
73
|
+
}
|
package/server/save-session.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface SaveHost<Loaded> {
|
|
|
32
32
|
/** Loads the project from disk. Throws what it printed when it does not start. */
|
|
33
33
|
load(): Promise<Loaded>;
|
|
34
34
|
stop(loaded: Loaded): Promise<void>;
|
|
35
|
+
/** Whether a load is running a turn or a call now. */
|
|
36
|
+
running(): boolean;
|
|
37
|
+
/** Calls `swap` when no load is running anything. Nothing starts between that and the swap. */
|
|
38
|
+
whenQuiet(swap: () => void): Promise<void>;
|
|
35
39
|
/** The workspace a load opened as. */
|
|
36
40
|
opened(loaded: Loaded): StudioWorkspace;
|
|
37
41
|
/** The profiles a load registered that the studio could not open, by id. They are not unregistered. */
|
package/server/save-session.js
CHANGED
|
@@ -272,10 +272,13 @@ export function createSaveSession(host, first) {
|
|
|
272
272
|
await host.stop(next);
|
|
273
273
|
return refusal('differs', differs);
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
let old = project;
|
|
276
|
+
await host.whenQuiet(() => {
|
|
277
|
+
old = project;
|
|
278
|
+
project = next;
|
|
279
|
+
loadedFrom = from;
|
|
280
|
+
unloaded = undefined;
|
|
281
|
+
});
|
|
279
282
|
await host.stop(old);
|
|
280
283
|
return undefined;
|
|
281
284
|
};
|
|
@@ -284,8 +287,9 @@ export function createSaveSession(host, first) {
|
|
|
284
287
|
const now = heldIn(files);
|
|
285
288
|
if (now === loadedFrom)
|
|
286
289
|
unloaded = undefined;
|
|
287
|
-
// Files that did not load are not tried again until they change.
|
|
288
|
-
|
|
290
|
+
// Files that did not load are not tried again until they change. A running turn keeps its
|
|
291
|
+
// load: the page is told of the files again when the turn ends.
|
|
292
|
+
else if (unloaded?.from !== now && !host.running()) {
|
|
289
293
|
said?.({ again: true });
|
|
290
294
|
const refused = await reload(() => [], now);
|
|
291
295
|
if (refused)
|
package/server/serve.js
CHANGED
|
@@ -32,8 +32,9 @@ import { corsHeaders, isForeign, json, KEYS_PATH, STUDIO_BASE, } from "./handler
|
|
|
32
32
|
import { answerOpen, chosenEditor, defaultEditor } from "./open-editor.js";
|
|
33
33
|
import { PROJECT_READY } from "./project.js";
|
|
34
34
|
import { entryOf, isInside } from "./project-source.js";
|
|
35
|
+
import { createRuns, untilRead } from "./runs.js";
|
|
35
36
|
import { answerSave, createSaveSession, isSaveRequest } from "./save-session.js";
|
|
36
|
-
import { createWatchFeed, watchFiles } from "./watch.js";
|
|
37
|
+
import { createEventFeed, createWatchFeed, watchFiles } from "./watch.js";
|
|
37
38
|
function flag(name, fallback) {
|
|
38
39
|
const at = Deno.args.indexOf(`--${name}`);
|
|
39
40
|
return at >= 0 ? (Deno.args[at + 1] ?? fallback) : fallback;
|
|
@@ -185,6 +186,10 @@ catch (error) {
|
|
|
185
186
|
console.error(error instanceof Error ? error.message : error);
|
|
186
187
|
Deno.exit(1);
|
|
187
188
|
}
|
|
189
|
+
/** What the loads are running. When it ends the page hears of the files it was not told of. */
|
|
190
|
+
const runs = createRuns(() => void tellChanged());
|
|
191
|
+
/** The chats that hold the load: each is told when a change waits for them. */
|
|
192
|
+
const holds = createEventFeed();
|
|
188
193
|
/** The load that runs the builder's unsaved edits, while the page compares it with the files. */
|
|
189
194
|
const edited = createEditedSession({
|
|
190
195
|
load: loadProject,
|
|
@@ -202,12 +207,20 @@ const session = createSaveSession({
|
|
|
202
207
|
},
|
|
203
208
|
remove: (path) => Deno.removeSync(path),
|
|
204
209
|
typeChecks,
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
load: loadProject,
|
|
211
|
+
stop,
|
|
212
|
+
running: runs.busy,
|
|
213
|
+
// The files changed: the edited load lies over files that are gone, once its runs are done.
|
|
214
|
+
whenQuiet: async (swap) => {
|
|
215
|
+
if (runs.busy())
|
|
216
|
+
holds.tell({ saved: true });
|
|
217
|
+
await new Promise((quiet) => runs.whenIdle(quiet));
|
|
207
218
|
await edited.close();
|
|
208
|
-
|
|
219
|
+
await new Promise((swapped) => runs.whenIdle(() => {
|
|
220
|
+
swap();
|
|
221
|
+
swapped();
|
|
222
|
+
}));
|
|
209
223
|
},
|
|
210
|
-
stop,
|
|
211
224
|
opened: (loaded) => loaded.description.workspace,
|
|
212
225
|
unopened: (loaded) => loaded.description.problems.map((problem) => problem.profile),
|
|
213
226
|
}, first);
|
|
@@ -216,13 +229,26 @@ async function forward(request, loaded = session.project(), path) {
|
|
|
216
229
|
const url = new URL(request.url);
|
|
217
230
|
const to = path ?? url.pathname;
|
|
218
231
|
if (request.headers.get('upgrade')?.toLowerCase() === 'websocket') {
|
|
219
|
-
return forwardSocket(request, `${loaded.origin}${to}${url.search}
|
|
232
|
+
return forwardSocket(request, `${loaded.origin}${to}${url.search}`, runs.begin());
|
|
220
233
|
}
|
|
234
|
+
const target = `${loaded.origin}${to}${url.search}`;
|
|
235
|
+
// invariant: counted before anything is awaited, in the tick that picked `loaded`.
|
|
236
|
+
if (request.method !== 'POST' || !to.startsWith(PROFILES))
|
|
237
|
+
return passOn(request, target, to);
|
|
238
|
+
const ended = runs.begin();
|
|
239
|
+
const answer = await passOn(request, target, to).catch((error) => {
|
|
240
|
+
ended();
|
|
241
|
+
throw error;
|
|
242
|
+
});
|
|
243
|
+
return untilRead(answer, ended);
|
|
244
|
+
}
|
|
245
|
+
/** The project's answer to a request, watched when it is a run. */
|
|
246
|
+
async function passOn(request, target, to) {
|
|
221
247
|
const headers = new Headers(request.headers);
|
|
222
248
|
headers.delete('host');
|
|
223
249
|
let response;
|
|
224
250
|
try {
|
|
225
|
-
response = await fetch(
|
|
251
|
+
response = await fetch(target, {
|
|
226
252
|
method: request.method,
|
|
227
253
|
headers,
|
|
228
254
|
body: await bodyOf(request),
|
|
@@ -254,13 +280,14 @@ function watchedRun(method, to, response) {
|
|
|
254
280
|
* Joins the page's socket to the same path of the project: a voice call. What the page sends
|
|
255
281
|
* before the project's side opens is held, because a call opens with the page's first message.
|
|
256
282
|
*/
|
|
257
|
-
function forwardSocket(request, to) {
|
|
283
|
+
function forwardSocket(request, to, ended) {
|
|
258
284
|
const { socket: page, response } = Deno.upgradeWebSocket(request);
|
|
259
285
|
const project = new WebSocket(to.replace(/^http/, 'ws'));
|
|
260
286
|
page.binaryType = 'arraybuffer';
|
|
261
287
|
project.binaryType = 'arraybuffer';
|
|
262
288
|
const held = [];
|
|
263
289
|
const shut = (other) => () => {
|
|
290
|
+
ended();
|
|
264
291
|
if (other.readyState === WebSocket.OPEN || other.readyState === WebSocket.CONNECTING)
|
|
265
292
|
other.close();
|
|
266
293
|
};
|
|
@@ -289,6 +316,7 @@ const EVENTS = `${STUDIO_BASE}/events`;
|
|
|
289
316
|
const STATUS = `${STUDIO_BASE}/status`;
|
|
290
317
|
const SAVE = `${STUDIO_BASE}/save`;
|
|
291
318
|
const WATCH = `${STUDIO_BASE}/watch`;
|
|
319
|
+
const HOLD = `${STUDIO_BASE}/hold`;
|
|
292
320
|
const OPEN = `${STUDIO_BASE}/open`;
|
|
293
321
|
const EDITED = `${STUDIO_BASE}/edited`;
|
|
294
322
|
/**
|
|
@@ -403,13 +431,25 @@ function openedSaying(request) {
|
|
|
403
431
|
if (!opens(request)?.steps)
|
|
404
432
|
return undefined;
|
|
405
433
|
const encoder = new TextEncoder();
|
|
434
|
+
// why: the walk outlives a page that leaves, and a closed stream throws at each line.
|
|
435
|
+
let left = false;
|
|
406
436
|
const body = new ReadableStream({
|
|
407
437
|
start(controller) {
|
|
408
|
-
const line = (said) =>
|
|
438
|
+
const line = (said) => {
|
|
439
|
+
if (!left)
|
|
440
|
+
controller.enqueue(encoder.encode(`${JSON.stringify(said)}\n`));
|
|
441
|
+
};
|
|
409
442
|
described(line).then((project) => {
|
|
410
443
|
line({ opened: project });
|
|
411
|
-
|
|
412
|
-
|
|
444
|
+
if (!left)
|
|
445
|
+
controller.close();
|
|
446
|
+
}, (error) => {
|
|
447
|
+
if (!left)
|
|
448
|
+
controller.error(error);
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
cancel() {
|
|
452
|
+
left = true;
|
|
413
453
|
},
|
|
414
454
|
});
|
|
415
455
|
return new Response(body, {
|
|
@@ -422,11 +462,23 @@ function openedSaying(request) {
|
|
|
422
462
|
}
|
|
423
463
|
/** Tells the page when the builder's editor writes a file the setup reads, unless `--no-watch` says not to. */
|
|
424
464
|
const feed = Deno.args.includes('--no-watch') ? undefined : createWatchFeed();
|
|
465
|
+
/** Tells the page which files hold something the load that answers was not read from. */
|
|
466
|
+
async function tellChanged() {
|
|
467
|
+
const files = await session.changed().catch(() => []);
|
|
468
|
+
if (files.length && !runs.busy())
|
|
469
|
+
feed?.tell(files);
|
|
470
|
+
}
|
|
425
471
|
if (feed) {
|
|
426
472
|
watchFiles({
|
|
427
473
|
files: () => session.watched(),
|
|
428
474
|
changed: () => session.changed(),
|
|
429
|
-
|
|
475
|
+
// why: the page would read files the running load was not read from; the end of the run tells it.
|
|
476
|
+
tell: (files) => {
|
|
477
|
+
if (runs.busy())
|
|
478
|
+
holds.tell({ saved: false });
|
|
479
|
+
else
|
|
480
|
+
feed.tell(files);
|
|
481
|
+
},
|
|
430
482
|
watch: (folders) => Deno.watchFs(folders, { recursive: false }),
|
|
431
483
|
});
|
|
432
484
|
}
|
|
@@ -437,6 +489,17 @@ function watching(request) {
|
|
|
437
489
|
const cors = corsHeaders(request, pageOrigins);
|
|
438
490
|
return feed ? feed.subscribe(cors) : new Response(null, { status: 204, headers: cors });
|
|
439
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* `GET <base>/hold`: a chat whose reply is not done holds the load for as long as it reads this,
|
|
494
|
+
* gates included.
|
|
495
|
+
* why: a gate lives in the load and its turn's stream has ended, so no run counts it. The page
|
|
496
|
+
* holds it, not the server: a tab closed on a gate has no answer to wait for.
|
|
497
|
+
*/
|
|
498
|
+
function holding(request) {
|
|
499
|
+
if (request.method !== 'GET' || new URL(request.url).pathname !== HOLD)
|
|
500
|
+
return undefined;
|
|
501
|
+
return untilRead(holds.subscribe(corsHeaders(request, pageOrigins)), runs.begin());
|
|
502
|
+
}
|
|
440
503
|
/**
|
|
441
504
|
* `GET <base>/status`: what the command printed when the project opened, as it is now: what
|
|
442
505
|
* loaded, what the keys said, and what to look at. Plain text, for `theorem-studio status`.
|
|
@@ -511,6 +574,7 @@ async function answered(request) {
|
|
|
511
574
|
const ROUTES = [
|
|
512
575
|
running,
|
|
513
576
|
watching,
|
|
577
|
+
holding,
|
|
514
578
|
openedSaying,
|
|
515
579
|
answerStatus,
|
|
516
580
|
answerEvents,
|
package/ui/built/theme.css
CHANGED
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
--color-accent-muted: light-dark(#f1f1f1, #262626);
|
|
181
181
|
--color-neutral: light-dark(#0000000F, #ffffff1A);
|
|
182
182
|
--color-overlay: light-dark(#00000080, #000000CC);
|
|
183
|
-
--color-overlay-hover: light-dark(#
|
|
183
|
+
--color-overlay-hover: light-dark(#05365914, #FFFFFF14);
|
|
184
184
|
--color-overlay-pressed: light-dark(#0000001A, #ffffff1A);
|
|
185
185
|
--color-text-primary: light-dark(#000000, #ffffff);
|
|
186
186
|
--color-text-secondary: light-dark(#474747, #9e9e9e);
|
|
@@ -114,7 +114,7 @@ export const theoremStudioTheme = {
|
|
|
114
114
|
"--color-accent-muted": "light-dark(#f1f1f1, #262626)",
|
|
115
115
|
"--color-neutral": "light-dark(#0000000F, #ffffff1A)",
|
|
116
116
|
"--color-overlay": "light-dark(#00000080, #000000CC)",
|
|
117
|
-
"--color-overlay-hover": "light-dark(#
|
|
117
|
+
"--color-overlay-hover": "light-dark(#05365914, #FFFFFF14)",
|
|
118
118
|
"--color-overlay-pressed": "light-dark(#0000001A, #ffffff1A)",
|
|
119
119
|
"--color-text-primary": "light-dark(#000000, #ffffff)",
|
|
120
120
|
"--color-text-secondary": "light-dark(#474747, #9e9e9e)",
|
|
@@ -91,6 +91,8 @@ export interface WorkspaceAgent {
|
|
|
91
91
|
agentId: string;
|
|
92
92
|
type: string;
|
|
93
93
|
}
|
|
94
|
+
/** Whether a change waits on the shared-change dialog, so a field showing it isn't reset yet. */
|
|
95
|
+
export declare const ChangeHeld: import("react").Context<boolean>;
|
|
94
96
|
/**
|
|
95
97
|
* The workspace around the agent the editor shows: the agents it can name, which of the library's
|
|
96
98
|
* tools it allows, and, on a project, a way to add or change a provider. `null` when the editor
|
package/ui/inspector-context.js
CHANGED
|
@@ -66,6 +66,8 @@ export const GuardrailTest = createContext(null);
|
|
|
66
66
|
/** What the studio runs on: the page's lent keys, the builder's own, or their machine. */
|
|
67
67
|
export const RunsOn = createContext(ON_OWN_KEYS);
|
|
68
68
|
export const LocalConnection = createContext(null);
|
|
69
|
+
/** Whether a change waits on the shared-change dialog, so a field showing it isn't reset yet. */
|
|
70
|
+
export const ChangeHeld = createContext(false);
|
|
69
71
|
/**
|
|
70
72
|
* The workspace around the agent the editor shows: the agents it can name, which of the library's
|
|
71
73
|
* tools it allows, and, on a project, a way to add or change a provider. `null` when the editor
|
package/ui/inspector.d.ts
CHANGED
|
@@ -35,9 +35,16 @@ export declare function OriginLine({ origin, onOpen }: {
|
|
|
35
35
|
* field the section edits (`path`) on hover, as a row's label does. Under it, `note`: only what
|
|
36
36
|
* the catalog does not say, such as how the editor or the studio treats the field.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
/** Rows of `path`. A field the files set in code says so once, and its rows take no edit. */
|
|
39
|
+
export declare function OwnField({ path, children }: {
|
|
40
|
+
path?: string;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
43
|
+
export declare function InspectorSection({ title, path, hint, note, children, }: {
|
|
39
44
|
title?: string;
|
|
40
45
|
path?: string;
|
|
46
|
+
/** The title's hover, for a section no one catalog field describes. */
|
|
47
|
+
hint?: string;
|
|
41
48
|
note?: string;
|
|
42
49
|
children: ReactNode;
|
|
43
50
|
}): import("react").JSX.Element;
|
|
@@ -75,6 +82,22 @@ export type FieldRowProps = {
|
|
|
75
82
|
/** The draft field whose issues show on this row. */
|
|
76
83
|
field?: string;
|
|
77
84
|
} & IsRequired;
|
|
85
|
+
/**
|
|
86
|
+
* A field row's issue status and presence, and the props its one control shares: labelled but with
|
|
87
|
+
* the label hidden, since the row shows it.
|
|
88
|
+
*/
|
|
89
|
+
export declare function useFieldRow({ label, path, field, isRequired }: FieldRowProps): {
|
|
90
|
+
status: InputStatus | undefined;
|
|
91
|
+
required: boolean;
|
|
92
|
+
unset: string | undefined;
|
|
93
|
+
control: {
|
|
94
|
+
label: string;
|
|
95
|
+
status: InputStatus | undefined;
|
|
96
|
+
isLabelHidden: boolean;
|
|
97
|
+
isRequired: boolean;
|
|
98
|
+
size: "sm";
|
|
99
|
+
};
|
|
100
|
+
};
|
|
78
101
|
/**
|
|
79
102
|
* The names and values of an object the draft holds as JSON text, a row each. The rows are kept
|
|
80
103
|
* here while they are typed, since a row with no name is no part of the object yet, and start
|
|
@@ -106,6 +129,15 @@ export declare function TextRow(props: FieldRowProps & {
|
|
|
106
129
|
maxLength?: number;
|
|
107
130
|
onChange: (next: string) => void;
|
|
108
131
|
}): import("react").JSX.Element;
|
|
132
|
+
/** A field whose control sits under its label, with room for an `action` across from the label. */
|
|
133
|
+
export declare function WideRow({ label, path, isRequired, hasIssue, action, children, }: {
|
|
134
|
+
label: string;
|
|
135
|
+
path: string;
|
|
136
|
+
isRequired: boolean;
|
|
137
|
+
hasIssue: boolean;
|
|
138
|
+
action?: ReactNode;
|
|
139
|
+
children: ReactNode;
|
|
140
|
+
}): import("react").JSX.Element;
|
|
109
141
|
/**
|
|
110
142
|
* Longer text, under its label rather than beside it: wording and JSON. Left blank, it shows
|
|
111
143
|
* `placeholder` (for wording, the kernel's own default line) for Tab to take up, else `hint`.
|
|
@@ -118,6 +150,7 @@ export declare function TextAreaRow(props: FieldRowProps & {
|
|
|
118
150
|
hasSpellCheck?: boolean;
|
|
119
151
|
/** A status of the row's own, such as text that is not JSON; the field's issues win. */
|
|
120
152
|
status?: InputStatus;
|
|
153
|
+
action?: ReactNode;
|
|
121
154
|
onChange: (next: string) => void;
|
|
122
155
|
}): import("react").JSX.Element;
|
|
123
156
|
/** A number the kernel leaves unset when cleared: it gives `null`, shown as what leaving it out does. */
|
|
@@ -261,7 +294,7 @@ export declare function ListRow({ label, path, field, value, options, onChange,
|
|
|
261
294
|
onChange: (next: string[]) => void;
|
|
262
295
|
}): import("react").JSX.Element;
|
|
263
296
|
/** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
|
|
264
|
-
export declare function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow, onChange, }: {
|
|
297
|
+
export declare function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow, marked, onMark, markHint, onChange, }: {
|
|
265
298
|
label: string;
|
|
266
299
|
status?: InputStatus;
|
|
267
300
|
value: string[];
|
|
@@ -270,6 +303,15 @@ export declare function NamesInput({ label, status, value, placeholder, isDisabl
|
|
|
270
303
|
disabledMessage?: string;
|
|
271
304
|
/** `none` keeps every token in sight, at the same height, focused or not. */
|
|
272
305
|
overflow?: 'none' | 'unfocusedInline';
|
|
306
|
+
/** The token shown as chosen. */
|
|
307
|
+
marked?: string;
|
|
308
|
+
/** Pressing a token chooses it. */
|
|
309
|
+
onMark?: (name: string) => void;
|
|
310
|
+
/** What a token's hover says: of the marked one, and of the rest. */
|
|
311
|
+
markHint?: {
|
|
312
|
+
marked: string;
|
|
313
|
+
other: string;
|
|
314
|
+
};
|
|
273
315
|
onChange: (next: string[]) => void;
|
|
274
316
|
}): import("react").JSX.Element;
|
|
275
317
|
/**
|
package/ui/inspector.js
CHANGED
|
@@ -74,12 +74,16 @@ export function OriginLine({ origin, onOpen }) {
|
|
|
74
74
|
* field the section edits (`path`) on hover, as a row's label does. Under it, `note`: only what
|
|
75
75
|
* the catalog does not say, such as how the editor or the studio treats the field.
|
|
76
76
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// A section whose own field the files set in code says so once, and its rows take no edit.
|
|
77
|
+
/** Rows of `path`. A field the files set in code says so once, and its rows take no edit. */
|
|
78
|
+
export function OwnField({ path, children }) {
|
|
80
79
|
const found = useRowOrigin(path);
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if (!found || found.said)
|
|
81
|
+
return children;
|
|
82
|
+
return (_jsxs(SaidOrigin, { value: found.origin, children: [_jsx(OriginLine, { origin: found.origin, onOpen: found.open }), _jsx(SetInCode, { children: _jsx(VStack, { gap: 3, children: children }) })] }));
|
|
83
|
+
}
|
|
84
|
+
export function InspectorSection({ title, path, hint, note, children, }) {
|
|
85
|
+
const heading = title && (_jsx(Text, { type: "label", weight: "semibold", children: title }));
|
|
86
|
+
return (_jsx(Section, { variant: "transparent", padding: 3, children: _jsxs(VStack, { gap: 3, children: [_jsxs(VStack, { gap: 1, hAlign: "start", children: [heading && title && path !== undefined && (_jsx(CatalogHover, { label: title, path: path, children: heading })), heading && title && path === undefined && hint !== undefined && (_jsx(HoverCard, { label: title, content: _jsx(VStack, { maxWidth: 280, children: _jsx(Text, { children: hint }) }), children: heading })), heading && path === undefined && hint === undefined && heading, note && _jsx(Text, { type: "supporting", children: note })] }), _jsx(OwnField, { path: path, children: children })] }) }));
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
85
89
|
* The name of a group of rows inside a section. Astryx's ladder, top down: the page title is 14
|
|
@@ -132,7 +136,7 @@ export function InspectorRow({ label, path, isRequired = false, hasIssue, hasNot
|
|
|
132
136
|
* A field row's issue status and presence, and the props its one control shares: labelled but with
|
|
133
137
|
* the label hidden, since the row shows it.
|
|
134
138
|
*/
|
|
135
|
-
function useFieldRow({ label, path, field, isRequired }) {
|
|
139
|
+
export function useFieldRow({ label, path, field, isRequired }) {
|
|
136
140
|
const status = useFieldStatus()(field);
|
|
137
141
|
const { required, unset } = presence(path, isRequired);
|
|
138
142
|
const control = { label, status, isLabelHidden: true, isRequired: required, size: 'sm' };
|
|
@@ -196,6 +200,10 @@ export function TextRow(props) {
|
|
|
196
200
|
props.onChange(chars.slice(0, props.maxLength).join(''));
|
|
197
201
|
} }) }));
|
|
198
202
|
}
|
|
203
|
+
/** A field whose control sits under its label, with room for an `action` across from the label. */
|
|
204
|
+
export function WideRow({ label, path, isRequired, hasIssue, action, children, }) {
|
|
205
|
+
return (_jsxs(VStack, { gap: 1, [ISSUE_ROW_ATTRIBUTE]: hasIssue || undefined, children: [_jsxs(HStack, { hAlign: "between", vAlign: "center", children: [_jsx(RowLabel, { label: label, path: path, isRequired: isRequired }), action] }), children] }));
|
|
206
|
+
}
|
|
199
207
|
/**
|
|
200
208
|
* Longer text, under its label rather than beside it: wording and JSON. Left blank, it shows
|
|
201
209
|
* `placeholder` (for wording, the kernel's own default line) for Tab to take up, else `hint`.
|
|
@@ -204,7 +212,7 @@ export function TextAreaRow(props) {
|
|
|
204
212
|
const { label, path, value, placeholder, hint, rows = 3, hasSpellCheck = true, onChange } = props;
|
|
205
213
|
const { status: fieldStatus, required, unset, control } = useFieldRow(props);
|
|
206
214
|
const status = fieldStatus ?? props.status;
|
|
207
|
-
return (
|
|
215
|
+
return (_jsx(WideRow, { label: label, path: path, isRequired: required, hasIssue: fieldStatus !== undefined, action: props.action, children: _jsx(TextArea, { ...control, status: status, rows: rows, hasSpellCheck: hasSpellCheck, value: value, placeholder: placeholder ?? hint ?? unset, onKeyDown: tabFills(value, placeholder, onChange), onChange: onChange }) }));
|
|
208
216
|
}
|
|
209
217
|
/** A number the kernel leaves unset when cleared: it gives `null`, shown as what leaving it out does. */
|
|
210
218
|
export function NumberRow(props) {
|
|
@@ -314,8 +322,11 @@ export function ListRow({ label, path, field, value, options, onChange, }) {
|
|
|
314
322
|
/** A names row suggests nothing; every token is one the user typed. */
|
|
315
323
|
const NO_SUGGESTIONS = { search: () => [], bootstrap: () => [] };
|
|
316
324
|
/** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
|
|
317
|
-
export function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow = 'unfocusedInline', onChange, }) {
|
|
318
|
-
return (_jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: overflow,
|
|
325
|
+
export function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow = 'unfocusedInline', marked, onMark, markHint, onChange, }) {
|
|
326
|
+
return (_jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: overflow, renderToken: onMark &&
|
|
327
|
+
((item, onRemove) => (_jsx(Tooltip, { content: item.label === marked ? markHint?.marked : markHint?.other, isEnabled: markHint !== undefined, children: _jsx(Token, { label: item.label, size: "sm", color: item.label === marked ? 'blue' : 'default', onClick: () => {
|
|
328
|
+
onMark(item.label);
|
|
329
|
+
}, onRemove: onRemove }) }))), onChange: (items) => {
|
|
319
330
|
const names = items.map((item) => item.label.trim()).filter(Boolean);
|
|
320
331
|
onChange([...new Set(names)]);
|
|
321
332
|
} }));
|
package/ui/lib/studio-watch.d.ts
CHANGED
|
@@ -10,3 +10,9 @@ export declare function subscribeToFiles(endpoint: string, on: {
|
|
|
10
10
|
open: () => void;
|
|
11
11
|
files: (files: string[]) => void;
|
|
12
12
|
}): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Holds the project's load until the answer is called: the studio does not replace it, so what
|
|
15
|
+
* waits in it can still be answered. `onChange` when a change waits for that, `saved` when the
|
|
16
|
+
* builder saved it here and not in their editor.
|
|
17
|
+
*/
|
|
18
|
+
export declare function holdLoad(endpoint: string, onChange: (saved: boolean) => void): () => void;
|
package/ui/lib/studio-watch.js
CHANGED
|
@@ -25,3 +25,19 @@ export function subscribeToFiles(endpoint, on) {
|
|
|
25
25
|
source.close();
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Holds the project's load until the answer is called: the studio does not replace it, so what
|
|
30
|
+
* waits in it can still be answered. `onChange` when a change waits for that, `saved` when the
|
|
31
|
+
* builder saved it here and not in their editor.
|
|
32
|
+
*/
|
|
33
|
+
export function holdLoad(endpoint, onChange) {
|
|
34
|
+
if (typeof EventSource === 'undefined')
|
|
35
|
+
return () => undefined;
|
|
36
|
+
const source = new EventSource(`${endpoint}/hold`);
|
|
37
|
+
source.onmessage = (event) => {
|
|
38
|
+
onChange(JSON.parse(event.data).saved);
|
|
39
|
+
};
|
|
40
|
+
return () => {
|
|
41
|
+
source.close();
|
|
42
|
+
};
|
|
43
|
+
}
|