@theoremjs/studio 0.3.4-next.671.gfa09ab2 → 0.3.4-next.673.ga492632

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.
Files changed (25) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{Banner-DEVAsFER.js → Banner-BxvBuYgz.js} +2 -2
  3. package/page/assets/{ConsoleFrame-CqUUcrR4.js → ConsoleFrame-_YA1HkXX.js} +1 -1
  4. package/page/assets/{MenuBottomSheet-DOa09vl1.js → MenuBottomSheet-BbniF3mM.js} +1 -1
  5. package/page/assets/{SchemaFields-CMwMU1Px.js → SchemaFields-Bg4OxBw3.js} +1 -1
  6. package/page/assets/{ToolResultCharts-CW23-D1x.js → ToolResultCharts-PhjAbSXq.js} +1 -1
  7. package/page/assets/{TraceInspector-h030OQ82.js → TraceInspector-fiuM6pWK.js} +1 -1
  8. package/page/assets/{TraceOverview-BsON_uZj.js → TraceOverview-BzerB7QI.js} +1 -1
  9. package/page/assets/{browser-engine-Cf6d-zNH.js → browser-engine-SBozuru0.js} +1 -1
  10. package/page/assets/{browser-transport-BK4cbTE_.js → browser-transport-BHWgtIIH.js} +3 -3
  11. package/page/assets/{export-agent-CaHsJPsM.js → export-agent-GKC4g6Ei.js} +1 -1
  12. package/page/assets/{guardrail-tester-BDhFLvT5.js → guardrail-tester-HDwGIn2U.js} +1 -1
  13. package/page/assets/{index-CqwmMJ4C.js → index-Xice1eg1.js} +15 -15
  14. package/page/assets/{studio-code-pane-C1wH63Y2.js → studio-code-pane-DPxkcxON.js} +1 -1
  15. package/page/assets/{studio-console-DRzo4yTy.js → studio-console-CdUQW84-.js} +1 -1
  16. package/page/assets/{studio-decision-C7QWMm7Q.js → studio-decision-B9Zvbyst.js} +1 -1
  17. package/page/assets/{studio-embedding-D8KroBXY.js → studio-embedding-Ds3gGEie.js} +1 -1
  18. package/page/assets/{studio-host-console-HkX8BerX.js → studio-host-console-Bqya7q0s.js} +2 -2
  19. package/page/assets/{studio-labels-6w1SKC2D.js → studio-labels-D1VY2Jy8.js} +1 -1
  20. package/page/assets/{studio-live-BmVeXAu4.js → studio-live-Ccx0NJuI.js} +1 -1
  21. package/page/assets/{studio-map-5ZU1nicW.js → studio-map-B4_FRhhr.js} +1 -1
  22. package/page/assets/{studio-trace-replay-CSbJSN5e.js → studio-trace-replay-DXW5DXpK.js} +1 -1
  23. package/page/assets/{use-one-call-Br2IVJLU.js → use-one-call-mxMqUe5Q.js} +1 -1
  24. package/page/index.html +4 -4
  25. package/ui/studio-compare.js +52 -24
@@ -1,16 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Center } from '@astryxdesign/core/Center';
3
+ import { ComplexSelector } from '@astryxdesign/core/ComplexSelector';
3
4
  import { Divider } from '@astryxdesign/core/Divider';
4
5
  import { HStack } from '@astryxdesign/core/HStack';
5
6
  import { Icon } from '@astryxdesign/core/Icon';
6
7
  import { IconButton } from '@astryxdesign/core/IconButton';
8
+ import { RadioList, RadioListItem } from '@astryxdesign/core/RadioList';
7
9
  import { StackItem } from '@astryxdesign/core/Stack';
8
10
  import { Text } from '@astryxdesign/core/Text';
9
11
  import { VStack } from '@astryxdesign/core/VStack';
10
- import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand } from '@tabler/icons-react';
12
+ import { IconInputAi, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, } from '@tabler/icons-react';
11
13
  import { createComposerPendingMessage, orderComposerPendingMessages, removeComposerPendingMessage, } from '@theoremjs/agents/interface';
12
- import { ChatComposerBar, DEFAULT_CHAT_MAX_WIDTH, InPlace, PaneFailure, PaneLoading, TheoremChat, } from '@theoremjs/react/ui';
13
- import { clientFailure, composerFieldsFromDraft, composerHasPayload, createHttpTransport, createTraceFeed, encodeComposerDraft, followGenerationDefaults, } from '@theoremjs/web/client';
14
+ import { ChatComposerBar, DEFAULT_CHAT_MAX_WIDTH, generationOptions, InPlace, PaneFailure, PaneLoading, TheoremChat, } from '@theoremjs/react/ui';
15
+ import { clientFailure, composerFieldsFromDraft, composerHasPayload, createHttpTransport, createTraceFeed, encodeComposerDraft, } from '@theoremjs/web/client';
14
16
  import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
15
17
  import { atStart } from "../mod.js";
16
18
  import { useActingAs } from "./lib/acting-as.js";
@@ -194,10 +196,52 @@ function pairPending(states) {
194
196
  }
195
197
  /** Whether a side's running turn would take a steer now. */
196
198
  const takesSteer = (state) => state.phase === 'streaming' && allowsSteering(state);
199
+ /** A side's name where the two are named in a line. */
200
+ const SIDE_NAMES = { saved: 'Saved', edited: 'Edited' };
201
+ /** One column of the model control: what this side's own composer offers, and it alone. */
202
+ function SideGeneration({ side, chat, state }) {
203
+ const { selectedModel, selectedEffort } = state.session;
204
+ if (!state.iface)
205
+ return null;
206
+ const { models, efforts } = generationOptions(state.iface, selectedModel);
207
+ const isDisabled = state.phase === 'streaming';
208
+ return (_jsxs(VStack, { gap: 3, style: { flex: '1 1 12rem', minWidth: 0 }, children: [models.length > 0 ? (_jsx(RadioList, { label: SIDE_NAMES[side], size: "sm", isDisabled: isDisabled, value: selectedModel ?? '', onChange: (modelId) => {
209
+ chat.setGeneration({ modelId });
210
+ }, children: models.map((model) => (_jsx(RadioListItem, { value: model.id, label: model.id, description: model.label === model.id ? undefined : model.label }, model.id))) })) : (_jsxs(VStack, { gap: 1, children: [_jsx(Text, { type: "supporting", weight: "semibold", children: SIDE_NAMES[side] }), _jsx(Text, { type: "supporting", color: "secondary", children: selectedModel })] })), selectedModel && efforts.length > 0 && (_jsx(RadioList, { label: "Effort", size: "sm", isDisabled: isDisabled, value: selectedEffort ?? '', onChange: (effort) => {
211
+ chat.setGeneration({ modelId: selectedModel, effort });
212
+ }, children: efforts.map((option) => (_jsx(RadioListItem, { value: option.alias, label: option.alias, description: option.level }, option.alias))) }))] }));
213
+ }
214
+ /**
215
+ * The composer's model control when two chats share it: each side's choices, side by side. A pick
216
+ * is that side's, held by its chat, as its own composer would hold it.
217
+ */
218
+ function PairGeneration({ sides }) {
219
+ const offered = sides.filter(({ state }) => {
220
+ const { models, efforts } = state.iface
221
+ ? generationOptions(state.iface, state.session.selectedModel)
222
+ : { models: [], efforts: [] };
223
+ return models.length + efforts.length > 0;
224
+ });
225
+ if (offered.length === 0)
226
+ return null;
227
+ const running = sides.flatMap(({ side, state }) => {
228
+ const model = state.session.selectedModel;
229
+ return model ? [{ side, model }] : [];
230
+ });
231
+ const label = new Set(running.map(({ model }) => model)).size === 1
232
+ ? running[0].model
233
+ : running.map(({ side, model }) => `${SIDE_NAMES[side]} ${model}`).join(' · ');
234
+ return (_jsx(ComplexSelector, { label: "Model", size: "sm", variant: "ghost", placement: "above", startIcon: _jsx(IconInputAi, { size: 14 }), value: label, triggerLabel: label, children: () => (_jsx(HStack, { gap: 4, padding: 3, wrap: "wrap", style: {
235
+ width: 'min(32rem, calc(100vw - 2rem))',
236
+ maxHeight: 'min(60vh, 28rem)',
237
+ overflowY: 'auto',
238
+ }, children: sides.map((side) => (_jsx(SideGeneration, { ...side }, side.side))) })) }));
239
+ }
197
240
  /**
198
241
  * The one composer of both sides. It only types for them: each side does with what is sent what
199
242
  * its own composer would. An idle side sends it, a busy one queues it; a steer goes to each side
200
- * whose running turn takes one; and each side refuses a model or file its profile does not take.
243
+ * whose running turn takes one; and each side refuses a file its profile does not take. The model
244
+ * is each side's own.
201
245
  */
202
246
  function SharedComposer({ sides, edited, inputRef, }) {
203
247
  const iface = edited.iface ?? undefined;
@@ -205,19 +249,11 @@ function SharedComposer({ sides, edited, inputRef, }) {
205
249
  const [pendingFiles, setPendingFiles] = useState([]);
206
250
  const [pendingVoice, setPendingVoice] = useState([]);
207
251
  const [failure, setFailure] = useState(null);
208
- const [pick, setPick] = useState({ isChosen: false });
209
- // The pick follows the edited side's profile as a chat's own composer follows its profile.
210
- if (iface && pick.of !== iface) {
211
- const next = followGenerationDefaults(iface, pick, pick.of);
212
- setPick({ ...next, of: iface, isChosen: pick.isChosen && next.model === pick.model });
213
- }
214
252
  const states = sides.map((side) => side.state);
215
253
  const phase = pairPhase(states);
216
254
  if (!iface)
217
255
  return null;
218
- // Unchosen, each side runs its own defaults: an edit to the defaults is what the two show.
219
- const chosen = pick.isChosen ? { model: pick.model, effort: pick.effort } : {};
220
- const options = () => ({ files: pendingFiles, voice: pendingVoice, ...chosen });
256
+ const options = () => ({ files: pendingFiles, voice: pendingVoice });
221
257
  const message = async (kind) => createComposerPendingMessage({
222
258
  kind,
223
259
  draft: await encodeComposerDraft({ text: draftText, pendingFiles, pendingVoice }),
@@ -227,10 +263,6 @@ function SharedComposer({ sides, edited, inputRef, }) {
227
263
  setPendingFiles([]);
228
264
  setPendingVoice([]);
229
265
  };
230
- const takePick = (chat) => {
231
- if (chosen.model !== undefined)
232
- chat.setGeneration({ modelId: chosen.model, effort: chosen.effort });
233
- };
234
266
  /** Each side as its own composer would: an idle side sends, a busy one takes `kind`. */
235
267
  const deliver = async (kind) => {
236
268
  const text = draftText;
@@ -261,7 +293,6 @@ function SharedComposer({ sides, edited, inputRef, }) {
261
293
  void chat.sendText(text, sent);
262
294
  continue;
263
295
  }
264
- takePick(chat);
265
296
  void (kind === 'send_now' ? chat.sendNow(shared) : chat.pend(shared));
266
297
  }
267
298
  };
@@ -279,7 +310,7 @@ function SharedComposer({ sides, edited, inputRef, }) {
279
310
  ...('allowSteering' in iface
280
311
  ? { allowSteering: sides.some(({ state }) => takesSteer(state)) }
281
312
  : {}),
282
- }, draftText: draftText, pendingFiles: pendingFiles, pendingVoice: pendingVoice, pendingMessages: pending, issues: [], phase: phase, failure: failure, selectedModel: pick.model, selectedEffort: pick.effort, placeholder: "Message both", inputRef: inputRef, onDraftTextChange: setDraftText, onFilesSelected: (files) => {
313
+ }, draftText: draftText, pendingFiles: pendingFiles, pendingVoice: pendingVoice, pendingMessages: pending, issues: [], phase: phase, failure: failure, placeholder: "Message both", inputRef: inputRef, onDraftTextChange: setDraftText, onFilesSelected: (files) => {
283
314
  setPendingFiles((prev) => [...prev, ...files]);
284
315
  }, onAttachmentRemove: (index) => {
285
316
  setPendingFiles((prev) => prev.filter((_, at) => at !== index));
@@ -295,9 +326,7 @@ function SharedComposer({ sides, edited, inputRef, }) {
295
326
  });
296
327
  }, onMenuAction: (action) => {
297
328
  void deliver(action);
298
- }, onGenerationChange: (next) => {
299
- setPick({ model: next.modelId, effort: next.effort, of: iface, isChosen: true });
300
- }, slotChoices: edited.slots && {
329
+ }, generationSelect: _jsx(PairGeneration, { sides: sides }), slotChoices: edited.slots && {
301
330
  ...edited.slots,
302
331
  onChange: (name, value) => {
303
332
  each((chat) => {
@@ -337,7 +366,6 @@ function SharedComposer({ sides, edited, inputRef, }) {
337
366
  const held = state.pendingMessages.find((m) => m.id === id);
338
367
  if (!held)
339
368
  continue;
340
- takePick(chat);
341
369
  void chat.sendNow(held);
342
370
  }
343
371
  } }) }));
@@ -496,7 +524,7 @@ export function ProjectChat(props) {
496
524
  const shared = SIDES.flatMap((side) => {
497
525
  const chat = pair.chats[side];
498
526
  const state = pair.states[side];
499
- return chat && state ? [{ chat, state }] : [];
527
+ return chat && state ? [{ side, chat, state }] : [];
500
528
  });
501
529
  const common = {
502
530
  detectCodeLanguage: true,