reifyui 0.11.0 → 0.11.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reifyui",
3
- "version": "0.11.0",
4
- "description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI \u2014 model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
3
+ "version": "0.11.2",
4
+ "description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
5
5
  "keywords": [
6
6
  "react",
7
7
  "generative-ui",
@@ -91,6 +91,9 @@ export function ChatPanel(props) {
91
91
  const [draft, setDraft] = useState('');
92
92
  const [busy, setBusy] = useState(false);
93
93
  const [connecting, setConnecting] = useState(false);
94
+ // A turn this tab started but can no longer hear: its stream broke after the gateway accepted
95
+ // it. Its messages come from history until it settles.
96
+ const [dropped, setDropped] = useState(false);
94
97
  const [histLoading, setHistLoading] = useState(true);
95
98
  const [staged, setStaged] = useState([]); // files picked, not yet sent
96
99
  const [attachErr, setAttachErr] = useState('');
@@ -182,12 +185,25 @@ export function ChatPanel(props) {
182
185
  }
183
186
  pendingRef.current = null;
184
187
  setConnecting(false);
188
+ if (out.dropped) {
189
+ // The turn is running and this tab lost its stream. Never resend: that starts a second
190
+ // turn behind the first (a game played twice at once, a deck written twice). The message
191
+ // stays as sent, the answer stays "running", and history fills it in below.
192
+ setDropped(true);
193
+ return;
194
+ }
185
195
  updateLastAsst((a) => (a.status === 'running' ? { ...a, status: 'done' } : a));
186
196
  api.current.onChanged?.();
187
- } catch {
188
- dropRunningAsst();
189
- pendingRef.current = { text, files };
190
- setConnecting(true);
197
+ } catch (e) {
198
+ // A refused turn is an answer, not a gateway still coming up: a wall, a bad request, a
199
+ // session busy with another turn. Say so on the message and leave it there; resending
200
+ // every twenty seconds is what filled a pane with "connecting" over a game that was
201
+ // playing fine (2026-09-22).
202
+ updateLastAsst((a) => ({
203
+ ...a,
204
+ blocks: a.blocks.length ? a.blocks : withText([], (e && e.message) || 'The turn could not be started.'),
205
+ status: 'failed',
206
+ }));
191
207
  } finally {
192
208
  setBusy(false);
193
209
  }
@@ -272,6 +288,24 @@ export function ChatPanel(props) {
272
288
  return () => window.clearInterval(iv);
273
289
  }, [connecting, busy, deliver]);
274
290
 
291
+ // A turn this tab started and lost the stream of: poll its history until the turn settles,
292
+ // then one last reload for the final answer and whatever it changed.
293
+ useEffect(() => {
294
+ if (!dropped) return undefined;
295
+ let dead = false;
296
+ const tick = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
297
+ if (dead || !hist?.length) return;
298
+ const last = hist[hist.length - 1];
299
+ const settled = !(last.role === 'assistant' && last.status === 'running')
300
+ && !externalBusy;
301
+ setMessages(hist);
302
+ if (settled) { setDropped(false); api.current.onChanged?.(); }
303
+ }).catch(() => {});
304
+ const iv = window.setInterval(tick, POLL_MS);
305
+ return () => { dead = true; window.clearInterval(iv); };
306
+ // eslint-disable-next-line react-hooks/exhaustive-deps
307
+ }, [dropped, externalBusy, sessionId]);
308
+
275
309
  // A turn may be running that this tab did not start. While that is true and nothing local is
276
310
  // streaming, poll history so its messages appear; when it ends, reload once so the final answer
277
311
  // and whatever it changed land here without a refresh.
@@ -380,6 +414,7 @@ export function ChatPanel(props) {
380
414
  {title ? <span className="uic-chat-title" title={title}>{title}</span> : null}
381
415
  {headerRight}
382
416
  {connecting ? <span className="uic-chat-conn">{connectingLabel}</span> : null}
417
+ {dropped ? <span className="uic-chat-conn">{workingLabel}</span> : null}
383
418
  </div>
384
419
 
385
420
  <div className="uic-chat-body" ref={bodyRef} onScroll={onBodyScroll} role="log" aria-live="polite">
@@ -202,17 +202,22 @@ export async function streamTurn({ sessionId, harnessId, input, instructions, ha
202
202
  hid = h.id;
203
203
  }
204
204
  const existing = sessionId ? String(sessionId) : '';
205
- const res = await fetch(`${CONFIG.base}/responses`, {
206
- method: 'POST',
207
- cache: 'no-store',
208
- headers: { 'content-type': 'application/json', accept: 'text/event-stream' },
209
- body: JSON.stringify({
210
- input,
211
- ...(instructions ? { instructions } : {}),
212
- metadata: { harness_id: hid, ...(existing ? { session_id: existing } : {}) },
213
- stream: true,
214
- }),
215
- });
205
+ let res;
206
+ try {
207
+ res = await fetch(`${CONFIG.base}/responses`, {
208
+ method: 'POST',
209
+ cache: 'no-store',
210
+ headers: { 'content-type': 'application/json', accept: 'text/event-stream' },
211
+ body: JSON.stringify({
212
+ input,
213
+ ...(instructions ? { instructions } : {}),
214
+ metadata: { harness_id: hid, ...(existing ? { session_id: existing } : {}) },
215
+ stream: true,
216
+ }),
217
+ });
218
+ } catch {
219
+ return { connecting: true }; // nothing reached the gateway (down, or restarting): safe to send again
220
+ }
216
221
  if (res.status === 503) return { connecting: true };
217
222
  if (!res.ok || !res.body) {
218
223
  const t = await res.text().catch(() => '');
@@ -225,13 +230,21 @@ export async function streamTurn({ sessionId, harnessId, input, instructions, ha
225
230
  ...handlers,
226
231
  onError: (msg) => { sawError = true; handlers.onError?.(msg); },
227
232
  });
228
- await readSSEStream(res.body, (data) => {
229
- let evt;
230
- try { evt = JSON.parse(data); } catch { return; } // malformed frame
231
- const found = sessionIdOf(evt);
232
- if (found && found !== sid) { sid = found; handlers.onSession?.(found); }
233
- d.dispatch(evt);
234
- });
233
+ try {
234
+ await readSSEStream(res.body, (data) => {
235
+ let evt;
236
+ try { evt = JSON.parse(data); } catch { return; } // malformed frame
237
+ const found = sessionIdOf(evt);
238
+ if (found && found !== sid) { sid = found; handlers.onSession?.(found); }
239
+ d.dispatch(evt);
240
+ });
241
+ } catch {
242
+ // The gateway ACCEPTED the turn (200) and the stream broke afterwards: a console rollout
243
+ // that stopped the old slot, a proxy timeout, a network blink. The turn is running without
244
+ // this stream, so sending the message again would start a second one; the caller attaches
245
+ // to the one that exists instead (its history, polled until it settles).
246
+ return { ok: false, dropped: true, sessionId: sid };
247
+ }
235
248
  return { ok: !sawError, sessionId: sid };
236
249
  }
237
250
 
@@ -426,7 +426,9 @@ export function Timeline({
426
426
 
427
427
  {rows.map((track) => (
428
428
  <div className="rui-tl-row" key={track.id}>
429
- <div className="rui-tl-head" title={track.label}>
429
+ {/* A lane whose name does not explain it can say what it is for. "Layer 2" means
430
+ nothing until something says it is drawn over Layer 1. */}
431
+ <div className="rui-tl-head" title={track.title || track.label}>
430
432
  {track.icon}
431
433
  <span className="rui-tl-headlbl">{track.label}</span>
432
434
  </div>