paseo-plugin-genui 0.2.2 → 0.3.1

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 (44) hide show
  1. package/OVERVIEW.md +5 -3
  2. package/README.md +15 -7
  3. package/assets/screenshot-chat.png +0 -0
  4. package/assets/screenshot-gallery.png +0 -0
  5. package/assets/screenshot-map.png +0 -0
  6. package/assets/screenshot-playground.png +0 -0
  7. package/client/components/content.tsx +41 -21
  8. package/client/components/data.tsx +18 -7
  9. package/client/components/dev.tsx +38 -26
  10. package/client/components/diagram.tsx +1 -1
  11. package/client/components/feedback.tsx +333 -0
  12. package/client/components/inputs.tsx +54 -47
  13. package/client/components/layout.tsx +3 -1
  14. package/client/components/media.tsx +2 -2
  15. package/client/components/project.tsx +7 -2
  16. package/client/components/widgets.tsx +35 -24
  17. package/client/gallery.tsx +7 -5
  18. package/client/live-ui.tsx +26 -2
  19. package/client/markdown.tsx +1 -5
  20. package/client/node-renderer.tsx +6 -1
  21. package/client/queue-pill.tsx +123 -0
  22. package/client/render.tsx +2 -0
  23. package/client/reply-queue.ts +82 -0
  24. package/client/runtime.ts +7 -0
  25. package/gallery/Other.ui +11 -0
  26. package/gallery/Plan.ui +1 -1
  27. package/index.client.tsx +6 -1
  28. package/index.server.ts +10 -0
  29. package/package.json +2 -2
  30. package/paseo-plugin.json +2 -1
  31. package/server/render-tool.ts +45 -0
  32. package/shared/actions-only.test.ts +23 -0
  33. package/shared/core/catalog.ts +23 -5
  34. package/shared/core/evaluate.ts +2 -0
  35. package/shared/core/markdown.ts +2 -0
  36. package/shared/core/types.ts +2 -1
  37. package/shared/diagram/markdown.test.ts +13 -0
  38. package/shared/diagram/markdown.ts +15 -1
  39. package/shared/fallback.ts +21 -1
  40. package/shared/hermes-syntax.test.ts +1 -1
  41. package/shared/instructions.ts +3 -1
  42. package/shared/logic/reply.test.ts +29 -0
  43. package/shared/logic/reply.ts +33 -0
  44. package/shared/logic/values.ts +1 -0
@@ -1,6 +1,9 @@
1
1
  import { ExternalLink } from "@getpaseo/plugin/client/ui";
2
2
  import React, { useEffect, useMemo, useState } from "react";
3
3
  import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
4
+ import { hasOwnNumber } from "../../shared/logic/reply";
5
+ import { useItemFeedback } from "./feedback";
6
+ import { CheckBox } from "./inputs";
4
7
  import {
5
8
  decisionMessage,
6
9
  estimateTask,
@@ -342,6 +345,10 @@ export function Plan({ props }: { props: Props }) {
342
345
  initialChecks(steps),
343
346
  (v) => (Array.isArray(v) ? v.map(Boolean) : null),
344
347
  );
348
+ const feedback = useItemFeedback(`plan:${propsKey(props.steps)}`, {
349
+ comments: props.comments === true,
350
+ editable: props.editable === true,
351
+ });
345
352
  if (error) return <ErrorLine message={error} />;
346
353
  const total = planTotal(steps, checked);
347
354
 
@@ -349,16 +356,17 @@ export function Plan({ props }: { props: Props }) {
349
356
  <View style={{ gap: 8 }}>
350
357
  {steps.map((step, idx) => {
351
358
  const isOn = checked[idx] !== false;
359
+ const original = { title: step.title, detail: step.detail ?? "" };
360
+ const shown = feedback.fields(idx, original);
361
+ const toggle = () =>
362
+ setChecked((prev) => {
363
+ const next = [...prev];
364
+ next[idx] = !isOn;
365
+ return next;
366
+ });
352
367
  return (
353
- <Pressable
368
+ <View
354
369
  key={idx}
355
- onPress={() =>
356
- setChecked((prev) => {
357
- const next = [...prev];
358
- next[idx] = !isOn;
359
- return next;
360
- })
361
- }
362
370
  style={{
363
371
  flexDirection: "row",
364
372
  alignItems: "flex-start",
@@ -366,41 +374,42 @@ export function Plan({ props }: { props: Props }) {
366
374
  padding: 10,
367
375
  borderRadius: 8,
368
376
  borderWidth: StyleSheet.hairlineWidth,
369
- borderColor: isOn ? theme.colors.accent : theme.colors.border,
377
+ borderColor: theme.colors.border,
370
378
  backgroundColor: theme.colors.surface2,
371
379
  }}
372
380
  >
373
- <Text style={{ color: isOn ? theme.colors.accent : theme.colors.foregroundMuted, fontSize: 14 }}>
374
- {isOn ? "☑" : "☐"}
375
- </Text>
376
- <View style={{ flex: 1, gap: 3 }}>
377
- <View style={{ flexDirection: "row", justifyContent: "space-between", gap: 8 }}>
381
+ <Pressable accessibilityRole="checkbox" accessibilityState={{ checked: isOn }} onPress={toggle} style={{ paddingTop: 1 }}>
382
+ <CheckBox checked={isOn} />
383
+ </Pressable>
384
+ <View style={{ flex: 1, gap: 4 }}>
385
+ <Pressable onPress={toggle} style={{ flexDirection: "row", justifyContent: "space-between", gap: 8 }}>
378
386
  <Text style={{ color: theme.colors.foreground, fontSize: 13, fontWeight: "600", flex: 1 }}>
379
- {idx + 1}. {step.title}
387
+ {hasOwnNumber(shown.title) ? shown.title : `${idx + 1}. ${shown.title}`}
380
388
  </Text>
381
389
  {step.estimate ? (
382
390
  <Text style={{ color: theme.colors.foregroundMuted, fontSize: 11.5 }}>
383
391
  {step.estimate}
384
392
  </Text>
385
393
  ) : null}
386
- </View>
387
- {step.detail ? (
388
- <Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}><InlineMarkdown text={step.detail} theme={theme} /></Text>
394
+ </Pressable>
395
+ {shown.detail ? (
396
+ <Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}><InlineMarkdown text={shown.detail} theme={theme} /></Text>
389
397
  ) : null}
390
398
  {step.files.length > 0 ? (
391
399
  <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
392
400
  {step.files.map((f, fIdx) => (
393
401
  <Text
394
402
  key={fIdx}
395
- style={{ color: theme.colors.accent, fontFamily: "monospace", fontSize: 11 }}
403
+ style={{ color: theme.colors.foregroundMuted, fontFamily: "monospace", fontSize: 11 }}
396
404
  >
397
- {f.path}
405
+ {f.line === null ? f.path : `${f.path}:${f.line}`}
398
406
  </Text>
399
407
  ))}
400
408
  </View>
401
409
  ) : null}
410
+ {feedback.controls(idx, hasOwnNumber(step.title) ? `step "${step.title}"` : `step ${idx + 1} (${step.title})`, original)}
402
411
  </View>
403
- </Pressable>
412
+ </View>
404
413
  );
405
414
  })}
406
415
  <View style={{ flexDirection: "row", justifyContent: "space-between", alignItems: "center" }}>
@@ -434,6 +443,7 @@ export function Plan({ props }: { props: Props }) {
434
443
 
435
444
  export function Decision({ props }: { props: Props }) {
436
445
  const { theme, run } = useUiRuntime();
446
+ const feedback = useItemFeedback(`decision:${propsKey(props.options)}`, { comments: props.comments === true, editable: false });
437
447
  const parsed = readDecision(props.options, props.criteria);
438
448
  if (!parsed.ok) return <ErrorLine message={parsed.error} />;
439
449
  const { model } = parsed;
@@ -508,8 +518,8 @@ export function Decision({ props }: { props: Props }) {
508
518
  key={entry.index}
509
519
  style={{
510
520
  borderRadius: 8,
511
- borderWidth: isLeader ? 1.5 : StyleSheet.hairlineWidth,
512
- borderColor: isLeader ? theme.colors.accent : theme.colors.border,
521
+ borderWidth: StyleSheet.hairlineWidth,
522
+ borderColor: theme.colors.border,
513
523
  backgroundColor: theme.colors.surface2,
514
524
  padding: 10,
515
525
  gap: 6,
@@ -519,7 +529,7 @@ export function Decision({ props }: { props: Props }) {
519
529
  <Text style={{ color: theme.colors.foreground, fontSize: 13.5, fontWeight: "600" }}>
520
530
  {opt.name}
521
531
  </Text>
522
- <Text style={{ color: theme.colors.accent, fontSize: 13, fontWeight: "700" }}>
532
+ <Text style={{ color: theme.colors.foreground, fontSize: 13, fontWeight: isLeader ? "700" : "500" }}>
523
533
  {round(entry.total, 2)} / {model.scale}
524
534
  </Text>
525
535
  </View>
@@ -556,6 +566,7 @@ export function Decision({ props }: { props: Props }) {
556
566
  Go with {opt.name}
557
567
  </Text>
558
568
  </Pressable>
569
+ {feedback.controls(entry.index, `option "${opt.name}"`, {})}
559
570
  </View>
560
571
  );
561
572
  })}
@@ -10,6 +10,8 @@ import { SidebarRow } from "@getpaseo/plugin/client/ui";
10
10
  import React, { useCallback, useEffect, useMemo, useState } from "react";
11
11
  import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
12
12
  import { COMPONENTS, componentSignature, type ComponentGroup, type ComponentName } from "../shared/core/catalog";
13
+
14
+ const COMPONENT_COUNT = Object.keys(COMPONENTS).length;
13
15
  import { componentsIn, GALLERY_GROUPS, searchComponents } from "../shared/logic/gallery-search";
14
16
  import { galleryGetRpc, galleryListRpc } from "../shared/rpc";
15
17
  import { SpecBlockView } from "./live-ui";
@@ -154,7 +156,7 @@ function GalleryBody({
154
156
  Generative UI Gallery
155
157
  </Text>
156
158
  <Text style={{ color: theme.colors.foregroundMuted, fontSize: 12.5 }}>
157
- 86 components in 10 groups · {files.length} live examples
159
+ {COMPONENT_COUNT} components in 10 groups · {files.length} live examples
158
160
  </Text>
159
161
  </View>
160
162
  <View style={{ flexDirection: "row", gap: 6 }}>
@@ -231,7 +233,7 @@ function GalleryBody({
231
233
  setQuery(txt);
232
234
  if (txt.trim()) setSelectedComponent(null);
233
235
  }}
234
- placeholder="Search 86 components (e.g. Chart, Diagram, Map, Decision, Kanban)…"
236
+ placeholder={`Search ${COMPONENT_COUNT} components (e.g. Chart, Diagram, Map, Decision, Kanban)…`}
235
237
  placeholderTextColor={theme.colors.foregroundMuted}
236
238
  style={{
237
239
  borderRadius: 8,
@@ -263,7 +265,7 @@ function GalleryBody({
263
265
  borderRadius: 999,
264
266
  backgroundColor: active ? theme.colors.accent : theme.colors.surface1,
265
267
  borderWidth: StyleSheet.hairlineWidth,
266
- borderColor: active ? theme.colors.accent : theme.colors.border,
268
+ borderColor: active ? theme.colors.foregroundMuted : theme.colors.border,
267
269
  }}
268
270
  >
269
271
  <Text
@@ -294,12 +296,12 @@ function GalleryBody({
294
296
  borderRadius: 6,
295
297
  backgroundColor: active ? theme.colors.surface2 : "transparent",
296
298
  borderWidth: StyleSheet.hairlineWidth,
297
- borderColor: active ? theme.colors.accent : theme.colors.border,
299
+ borderColor: active ? theme.colors.foregroundMuted : theme.colors.border,
298
300
  }}
299
301
  >
300
302
  <Text
301
303
  style={{
302
- color: active ? theme.colors.accent : theme.colors.foregroundMuted,
304
+ color: active ? theme.colors.foreground : theme.colors.foregroundMuted,
303
305
  fontSize: 11.5,
304
306
  fontFamily: "monospace",
305
307
  }}
@@ -16,7 +16,9 @@ import {
16
16
  import type { Action, Diagnostic, Value } from "../shared/core/types";
17
17
  import type { GenUiBlockData, GenUiTextData } from "../shared/rpc";
18
18
  import { useAudioLoader, useImageLoader, useLoadedData, useTextLoader, type FileScope } from "./loaders";
19
+ import { composeReply } from "../shared/logic/reply";
19
20
  import { RenderNodes } from "./render";
21
+ import { clearQueue, queueOf, setQueued as setQueuedFor, useReplyQueue } from "./reply-queue";
20
22
  import { UiRuntimeContext, type UiRuntime } from "./runtime";
21
23
  import { canRenderWebIframe, mountSandboxedAppIframe, openWorkspaceFile, readStorage, writeStorage } from "./web";
22
24
 
@@ -102,14 +104,30 @@ export function LiveUi({
102
104
  [initial],
103
105
  );
104
106
 
107
+ // The gallery has no agent; its UIs share one local queue.
108
+ const queueAgent = agentId ?? "local";
109
+ const queue = useReplyQueue(queueAgent);
110
+ const queuePrefix = blockKey ?? stateKey;
111
+ const setQueued = useCallback(
112
+ (id: string, text: string | null) => setQueuedFor(queueAgent, `${queuePrefix}:${id}`, text),
113
+ [queueAgent, queuePrefix],
114
+ );
115
+
105
116
  const runAction = useCallback(
106
117
  async (action: Action) => {
107
118
  switch (action.type) {
108
119
  case "set":
109
120
  setValue(action.name, action.value);
110
121
  return;
122
+ case "queue": {
123
+ const id = `queue:${action.text}`;
124
+ const queued = queueOf(queueAgent).some((item) => item.id === `${queuePrefix}:${id}`);
125
+ setQueued(id, queued ? null : action.text);
126
+ return;
127
+ }
111
128
  case "send":
112
- await send(action.text);
129
+ await send(composeReply(queueOf(queueAgent).map((item) => item.text), action.text));
130
+ clearQueue(queueAgent);
113
131
  setAnswer(action.text);
114
132
  writeStorage(answerKey, action.text);
115
133
  return;
@@ -122,7 +140,7 @@ export function LiveUi({
122
140
  return;
123
141
  }
124
142
  },
125
- [answerKey, send, setValue, toast],
143
+ [answerKey, queueAgent, queuePrefix, send, setQueued, setValue, toast],
126
144
  );
127
145
 
128
146
  const runtime = useMemo<UiRuntime>(
@@ -134,6 +152,9 @@ export function LiveUi({
134
152
  loadAudio,
135
153
  playAudio,
136
154
  answer,
155
+ queue,
156
+ setQueued,
157
+ queued: (id) => queue.find((item) => item.id === `${queuePrefix}:${id}`)?.text ?? null,
137
158
  superseded,
138
159
  agentId,
139
160
  blockKey,
@@ -156,6 +177,9 @@ export function LiveUi({
156
177
  loadAudio,
157
178
  playAudio,
158
179
  answer,
180
+ queue,
181
+ queuePrefix,
182
+ setQueued,
159
183
  superseded,
160
184
  agentId,
161
185
  blockKey,
@@ -102,11 +102,7 @@ function BlockView({
102
102
  if (block.kind === "quote") {
103
103
  return (
104
104
  <View
105
- style={{
106
- borderLeftWidth: 2,
107
- borderLeftColor: theme.colors.accent,
108
- paddingLeft: 10,
109
- }}
105
+ style={{ paddingLeft: 12 }}
110
106
  >
111
107
  <Text selectable style={{ ...body, color: theme.colors.foregroundMuted }}>
112
108
  <Spans content={block.content} theme={theme} />
@@ -84,6 +84,11 @@ export function RenderNode({ node }: { node: UiNode }): ReactNode {
84
84
  return <Renderer props={node.props} />;
85
85
  }
86
86
 
87
+ /** Buttons and Other sit together in one wrapping, left-aligned group. */
88
+ export function isButtonLike(node: UiNode): boolean {
89
+ return node.type === "Button" || node.type === "Other";
90
+ }
91
+
87
92
  export function RenderNodes({
88
93
  nodes,
89
94
  isolate = false,
@@ -107,7 +112,7 @@ export function RenderNodes({
107
112
  <RenderNode key={key} node={node} />
108
113
  );
109
114
 
110
- if (node.type !== "Button" || !Group) {
115
+ if (!isButtonLike(node) || !Group) {
111
116
  run = null;
112
117
  out.push(element);
113
118
  } else if (run === null) {
@@ -0,0 +1,123 @@
1
+ // A composer pill per chat whose reply queue has items: open it to review the
2
+ // queued parts, then send them or clear them.
3
+ import type { PluginClientContext } from "@getpaseo/plugin/client";
4
+ import type { PluginButtonContentProps, PluginButtonRegistration } from "@getpaseo/plugin/client";
5
+ import { Icon } from "@getpaseo/plugin/client/react-native";
6
+ import React from "react";
7
+ import { Pressable, StyleSheet, Text, View } from "react-native";
8
+ import { composeReply } from "../shared/logic/reply";
9
+ import { clearQueue, knownQueueAgents, queueOf, setQueued, subscribeQueues, useReplyQueue } from "./reply-queue";
10
+
11
+ export function registerQueuePills(client: PluginClientContext): () => void {
12
+ const pills = new Map<string, PluginButtonRegistration>();
13
+ const pending = new Set<string>();
14
+
15
+ const label = (count: number) => `${count} queued`;
16
+
17
+ const sync = () => {
18
+ for (const agentId of knownQueueAgents()) {
19
+ if (agentId === "local") continue;
20
+ const count = queueOf(agentId).length;
21
+ const pill = pills.get(agentId);
22
+ if (count === 0) {
23
+ pill?.remove();
24
+ pills.delete(agentId);
25
+ } else if (pill) {
26
+ pill.update({ label: label(count) });
27
+ } else if (!pending.has(agentId)) {
28
+ pending.add(agentId);
29
+ void register(agentId).finally(() => pending.delete(agentId));
30
+ }
31
+ }
32
+ };
33
+
34
+ const register = async (agentId: string) => {
35
+ const agent = client.paseo.agents.ref(agentId);
36
+ if (agent.workspaceId === null) await agent.refresh();
37
+ const workspaceId = agent.workspaceId;
38
+ const count = queueOf(agentId).length;
39
+ if (workspaceId === null || count === 0 || pills.has(agentId)) return;
40
+ pills.set(
41
+ agentId,
42
+ client.addComposerPill({
43
+ id: `reply-queue-${agentId}`,
44
+ workspaceId,
45
+ agentId,
46
+ button: {
47
+ title: "Queued reply",
48
+ label: label(count),
49
+ icon: "MessageSquare",
50
+ behavior: {
51
+ kind: "popover",
52
+ Content: (props) => (
53
+ <QueuePopover {...props} send={(text) => client.paseo.agents.ref(agentId).send(text)} />
54
+ ),
55
+ },
56
+ },
57
+ }),
58
+ );
59
+ };
60
+
61
+ const unsubscribe = subscribeQueues(sync);
62
+ sync();
63
+ return () => {
64
+ unsubscribe();
65
+ for (const pill of pills.values()) pill.remove();
66
+ pills.clear();
67
+ };
68
+ }
69
+
70
+ function QueuePopover({
71
+ theme,
72
+ close,
73
+ send,
74
+ ...context
75
+ }: PluginButtonContentProps & { send(text: string): Promise<void> }) {
76
+ const agentId = context.context === "agent" ? context.agentId : null;
77
+ const queue = useReplyQueue(agentId);
78
+ if (agentId === null) return null;
79
+
80
+ return (
81
+ <View style={{ gap: 8, padding: 12, maxWidth: 420 }}>
82
+ {queue.map((item) => (
83
+ <View key={item.id} style={{ flexDirection: "row", gap: 8, alignItems: "flex-start" }}>
84
+ <Text style={{ color: theme.colors.foreground, fontSize: 12.5, flex: 1 }}>{item.text}</Text>
85
+ <Pressable accessibilityRole="button" accessibilityLabel="Remove" onPress={() => setQueued(agentId, item.id, null)}>
86
+ <Icon name="Trash2" size={13} color={theme.colors.foregroundMuted} />
87
+ </Pressable>
88
+ </View>
89
+ ))}
90
+ <View style={{ flexDirection: "row", gap: 8, paddingTop: 4 }}>
91
+ <Pressable
92
+ accessibilityRole="button"
93
+ onPress={() => {
94
+ const text = composeReply(queueOf(agentId).map((item) => item.text), null);
95
+ if (text === "") return;
96
+ void send(text).then(() => clearQueue(agentId));
97
+ close();
98
+ }}
99
+ style={{ paddingHorizontal: 12, paddingVertical: 6, borderRadius: 8, backgroundColor: theme.colors.accent }}
100
+ >
101
+ <Text style={{ color: theme.colors.accentForeground, fontSize: 12.5, fontWeight: "600" }}>Send now</Text>
102
+ </Pressable>
103
+ <Pressable
104
+ accessibilityRole="button"
105
+ onPress={() => {
106
+ clearQueue(agentId);
107
+ close();
108
+ }}
109
+ style={{
110
+ paddingHorizontal: 12,
111
+ paddingVertical: 6,
112
+ borderRadius: 8,
113
+ backgroundColor: theme.colors.surface2,
114
+ borderWidth: StyleSheet.hairlineWidth,
115
+ borderColor: theme.colors.border,
116
+ }}
117
+ >
118
+ <Text style={{ color: theme.colors.foreground, fontSize: 12.5, fontWeight: "600" }}>Clear</Text>
119
+ </Pressable>
120
+ </View>
121
+ </View>
122
+ );
123
+ }
package/client/render.tsx CHANGED
@@ -66,6 +66,7 @@ import {
66
66
  TextArea,
67
67
  Toggle,
68
68
  } from "./components/inputs";
69
+ import { Other } from "./components/feedback";
69
70
  import { Card, Carousel, Details, Divider, Grid, Row, Stack, Tabs } from "./components/layout";
70
71
  import { Gallery, Hotspots, ImageSearch, MapView } from "./components/media";
71
72
  import {
@@ -140,6 +141,7 @@ export const RENDERERS = {
140
141
  Flashcards,
141
142
  Carousel,
142
143
  OptionCards,
144
+ Other,
143
145
  Swatches,
144
146
  EditableTable,
145
147
  FollowUps,
@@ -0,0 +1,82 @@
1
+ // The reply the user is building across every UI in one chat: Queue actions,
2
+ // item comments and edits, and Other boxes add to it; the next Send sends it all.
3
+ import { useSyncExternalStore } from "react";
4
+ import { readStorage, writeStorage } from "./web";
5
+
6
+ export interface QueuedReply {
7
+ /** Stable per source (a button, an item's comment), so a source replaces its own entry. */
8
+ readonly id: string;
9
+ readonly text: string;
10
+ }
11
+
12
+ const EMPTY: readonly QueuedReply[] = [];
13
+ const queues = new Map<string, readonly QueuedReply[]>();
14
+ const listeners = new Set<() => void>();
15
+
16
+ const storageKey = (agentId: string) => `genui:queue:${agentId}`;
17
+
18
+ export function queueOf(agentId: string): readonly QueuedReply[] {
19
+ const cached = queues.get(agentId);
20
+ if (cached !== undefined) return cached;
21
+ let stored: readonly QueuedReply[] = EMPTY;
22
+ try {
23
+ const parsed: unknown = JSON.parse(readStorage(storageKey(agentId)) ?? "[]");
24
+ if (Array.isArray(parsed)) {
25
+ stored = parsed.filter(
26
+ (item): item is QueuedReply => typeof item?.id === "string" && typeof item?.text === "string",
27
+ );
28
+ }
29
+ } catch {
30
+ // A corrupt entry starts an empty queue.
31
+ }
32
+ queues.set(agentId, stored);
33
+ // A queue restored from storage still needs its composer pill.
34
+ if (stored.length > 0) void Promise.resolve().then(notify);
35
+ return stored;
36
+ }
37
+
38
+ function notify(): void {
39
+ for (const listener of listeners) listener();
40
+ }
41
+
42
+ /** Agents whose queue has been read or written in this session. */
43
+ export function knownQueueAgents(): string[] {
44
+ return [...queues.keys()];
45
+ }
46
+
47
+ function write(agentId: string, next: readonly QueuedReply[]): void {
48
+ queues.set(agentId, next);
49
+ writeStorage(storageKey(agentId), JSON.stringify(next));
50
+ notify();
51
+ }
52
+
53
+ /** Adds, replaces (same id) or, with null text, removes one entry. */
54
+ export function setQueued(agentId: string, id: string, text: string | null): void {
55
+ const current = queueOf(agentId);
56
+ const without = current.filter((item) => item.id !== id);
57
+ const index = current.findIndex((item) => item.id === id);
58
+ if (text === null) {
59
+ if (index !== -1) write(agentId, without);
60
+ return;
61
+ }
62
+ const next = [...without];
63
+ next.splice(index === -1 ? next.length : index, 0, { id, text });
64
+ write(agentId, next);
65
+ }
66
+
67
+ export function clearQueue(agentId: string): void {
68
+ if (queueOf(agentId).length > 0) write(agentId, EMPTY);
69
+ }
70
+
71
+ export function subscribeQueues(listener: () => void): () => void {
72
+ listeners.add(listener);
73
+ return () => listeners.delete(listener);
74
+ }
75
+
76
+ export function useReplyQueue(agentId: string | null): readonly QueuedReply[] {
77
+ return useSyncExternalStore(
78
+ subscribeQueues,
79
+ () => (agentId === null ? EMPTY : queueOf(agentId)),
80
+ () => EMPTY,
81
+ );
82
+ }
package/client/runtime.ts CHANGED
@@ -2,6 +2,7 @@ import type { PluginTheme } from "@getpaseo/plugin";
2
2
  import { createContext, useCallback, useContext, useState } from "react";
3
3
  import type { Action, Value } from "../shared/core/types";
4
4
  import type { Tone } from "../shared/logic/values";
5
+ import type { QueuedReply } from "./reply-queue";
5
6
  import { readStorage, writeStorage } from "./web";
6
7
 
7
8
  export type ImageUrl =
@@ -21,6 +22,12 @@ export interface UiRuntime {
21
22
  loadAudio: ((src: string) => Promise<ImageUrl>) | null;
22
23
  playAudio: ((dataUrl: string) => Promise<void>) | null;
23
24
  answer: string | null;
25
+ /** The reply being built across this chat's UIs; the next send carries it. */
26
+ queue: readonly QueuedReply[];
27
+ /** Adds, replaces or (null) removes this block's queue entry `id`. */
28
+ setQueued(id: string, text: string | null): void;
29
+ /** The text of this block's queue entry `id`, or null. */
30
+ queued(id: string): string | null;
24
31
  superseded: boolean;
25
32
  agentId: string | null;
26
33
  blockKey: string | null;
@@ -0,0 +1,11 @@
1
+ Card("Review: src/worker/queue.ts", [
2
+ Findings([
3
+ {severity: "high", title: "A retry drops the job's payload", file: "src/worker/queue.ts", line: 88, detail: "requeue() passes only the id", fix: "Pass the payload too"},
4
+ {severity: "medium", title: "Backoff has no ceiling", file: "src/worker/queue.ts", line: 120, detail: "Delay doubles forever on a stuck job"}
5
+ ], comments: true, editable: true),
6
+ Row([
7
+ Button("Add a regression test", Queue("Add a regression test for the dropped payload")),
8
+ Button("Cap backoff at 5 min", Queue("Cap the backoff at 5 minutes"))
9
+ ]),
10
+ Row([Other(), Button("Fix these", Send("Fix the findings above."), variant: "primary")])
11
+ ])
package/gallery/Plan.ui CHANGED
@@ -6,4 +6,4 @@ Plan([
6
6
  {title: "Show “rate limited, retrying” in Map and ImageSearch", files: ["ui/components/Map.tsx", "ui/components/webMedia.tsx"], risk: "low", estimate: "2h", optional: true},
7
7
  {title: "Tests: bucket timing with fake timers, Retry-After parsing", files: ["web/web.test.ts"], risk: "low", estimate: "1.5h"},
8
8
  {title: "Document the limits in the README", files: ["README.md:94"], estimate: "20m"}
9
- ], submit: "Approve plan")
9
+ ], submit: "Approve plan", comments: true, editable: true)
package/index.client.tsx CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  GalleryWorkspacePanel,
18
18
  } from "./client/gallery";
19
19
  import { TimelineBlockItem, TimelineTextItem } from "./client/live-ui";
20
+ import { registerQueuePills } from "./client/queue-pill";
20
21
  import { GenUiSettingsScreen } from "./client/settings";
21
22
 
22
23
  export default function contribute(client: PluginClientContext) {
@@ -30,6 +31,8 @@ export default function contribute(client: PluginClientContext) {
30
31
  await client.playAudio({ base64, mimeType });
31
32
  };
32
33
 
34
+ const removeQueuePills = registerQueuePills(client);
35
+
33
36
  client.addTimelineTransformer({
34
37
  id: "genui-assistant",
35
38
  query: { itemType: "assistant_message" },
@@ -160,5 +163,7 @@ export default function contribute(client: PluginClientContext) {
160
163
  },
161
164
  });
162
165
 
163
- return () => {};
166
+ return () => {
167
+ removeQueuePills();
168
+ };
164
169
  }
package/index.server.ts CHANGED
@@ -54,6 +54,7 @@ import {
54
54
  readProjectPullRequest,
55
55
  readProjectThreads,
56
56
  } from "./server/project";
57
+ import { renderUiTool } from "./server/render-tool";
57
58
  import { createWebLookups } from "./server/web/lookups";
58
59
 
59
60
  const DEFAULT_DEMO_SPEC = `$seats = 10
@@ -129,11 +130,20 @@ export default function contribute(server: PluginServerContext) {
129
130
  if (request !== null) await agent.send(request);
130
131
  });
131
132
 
133
+ // render_ui only reads files the plugin may already read and adds UI to the chat, so it needs no prompt.
134
+ server.on("agent.permission_requested", async ({ agent, request }, { paseo }) => {
135
+ if (!/^(mcp__paseo__|paseo\.)render_ui$/.test(request.name)) return;
136
+ await paseo.agents.ref(agent.id).respondToPermission({ requestId: request.id, response: { behavior: "allow" } });
137
+ });
138
+
132
139
  server.before("agent.session_open", async ({ request }) => {
140
+ const current = await settings.read();
141
+ const renderTool = current.status !== "ready" || current.values.autoInstructions;
133
142
  const storageDir = agentStorageDir(request.agentId);
134
143
  await mkdir(storageDir, { recursive: true }).catch(() => undefined);
135
144
  return {
136
145
  ...request,
146
+ tools: renderTool ? [...request.tools, renderUiTool] : request.tools,
137
147
  env: {
138
148
  ...request.env,
139
149
  BB_THREAD_STORAGE: storageDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-genui",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Paseo plugin: agents answer with charts, diagrams, maps, plans and forms rendered inline in the chat.",
5
5
  "keywords": [
6
6
  "paseo",
@@ -39,7 +39,7 @@
39
39
  "test": "vitest run"
40
40
  },
41
41
  "devDependencies": {
42
- "@getpaseo/plugin": "0.13.0",
42
+ "@getpaseo/plugin": "^0.14.0",
43
43
  "@tanstack/react-query": "^5.90.11",
44
44
  "@types/node": "^24.19.2",
45
45
  "@types/react": "~19.2.0",
package/paseo-plugin.json CHANGED
@@ -4,11 +4,12 @@
4
4
  "description": "Agents answer with charts, diagrams, maps, plans and forms rendered inline in the chat.",
5
5
  "icon": "assets/icon.png",
6
6
  "media": [
7
+ "assets/screenshot-map.png",
7
8
  "assets/screenshot-chat.png",
8
9
  "assets/screenshot-gallery.png",
9
10
  "assets/screenshot-playground.png"
10
11
  ],
11
12
  "requirements": {
12
- "paseo": ">=0.13.0"
13
+ "paseo": ">=0.14.0"
13
14
  }
14
15
  }