@ai-matrx/chat 0.3.9 → 0.3.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-matrx/chat
2
2
 
3
+ ## 0.3.11 — 2026-10-07
4
+ ### Re-sync before matrx-frontend consumes the published package (P27)
5
+
6
+ - Carries every matrx-frontend `packages/chat` edit after `ebed60e111`: floating runs settle and a failed
7
+ launch says why (`useFloatingAgentRun.settle`), live-run failure display, composer menu, window openers,
8
+ chat manifest, caret hand-off, and `host/db-types.ts` regenerated from the frontend's current schema
9
+ (the app's Supabase client is assignable to the package's again).
10
+ - `system-agent-registry` drops the three `agent_apps.*` builtins whose mandates applets B3 deleted (the
11
+ package did not type-check against `@ai-matrx/agents` 0.50.1).
12
+ - Consumer action: none.
13
+
14
+ ## 0.3.10
15
+
16
+ - Clipboard failure handling lives in the `false` branch of the kit copy, which never throws: the dead `catch` blocks around `copyText` in the webpage context body, prompt preview, voice debug panel and transcript-integrity button are gone (the hook's notify already reports the failure).
17
+
18
+ ### Consumer action
19
+
20
+ - None required.
21
+
3
22
  ## 0.3.9
4
23
 
5
24
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -9,7 +9,6 @@ import {
9
9
  TooltipContent,
10
10
  TooltipTrigger
11
11
  } from "@ai-matrx/design-system";
12
- import { toast } from "../../../../host/notify.js";
13
12
  import { WebpageSnapshotView } from "../../../../host/ui-slots.js";
14
13
  import { webpageTitle, webpageUrl } from "../../../resources/webpage-snapshot.js";
15
14
  import { Button } from "@ai-matrx/design-system/controls";
@@ -47,13 +46,9 @@ function WebpageFooter({ item }) {
47
46
  const [copied, setCopied] = useState(false);
48
47
  if (!url) return null;
49
48
  const copy = async () => {
50
- try {
51
- if (!await copyText(url)) return;
52
- setCopied(true);
53
- setTimeout(() => setCopied(false), 1500);
54
- } catch {
55
- toast.error("Failed to copy");
56
- }
49
+ if (!await copyText(url)) return;
50
+ setCopied(true);
51
+ setTimeout(() => setCopied(false), 1500);
57
52
  };
58
53
  return /* @__PURE__ */ jsxs(Fragment, { children: [
59
54
  /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate font-mono text-[11px] text-muted-foreground", children: url }),
@@ -225,6 +225,17 @@ function ComposerMenuLevel({ children }) {
225
225
  };
226
226
  return /* @__PURE__ */ jsx(ComposerMenuLevelContext.Provider, { value: { openId, setOpenId, request, cancel }, children });
227
227
  }
228
+ function useNarrowViewport() {
229
+ const [narrow, setNarrow] = useState(false);
230
+ useEffect(() => {
231
+ const query = window.matchMedia("(max-width: 639px)");
232
+ const sync = () => setNarrow(query.matches);
233
+ sync();
234
+ query.addEventListener("change", sync);
235
+ return () => query.removeEventListener("change", sync);
236
+ }, []);
237
+ return narrow;
238
+ }
228
239
  function ComposerSubmenu({
229
240
  row,
230
241
  children,
@@ -249,6 +260,7 @@ function ComposerSubmenu({
249
260
  const closeAll = useContext(ComposerMenuCloseAllContext);
250
261
  const presentation = useContext(ComposerMenuPresentationContext);
251
262
  const sheetNav = useContext(ComposerSheetNavContext);
263
+ const narrow = useNarrowViewport();
252
264
  if (sheetNav) {
253
265
  return /* @__PURE__ */ jsx(
254
266
  ComposerMenuRow,
@@ -286,9 +298,10 @@ function ComposerSubmenu({
286
298
  /* @__PURE__ */ jsx(
287
299
  PopoverContent,
288
300
  {
289
- side: "right",
301
+ side: narrow ? "top" : "right",
290
302
  align: "start",
291
303
  sideOffset: 6,
304
+ collisionPadding: 8,
292
305
  onEscapeKeyDown: () => {
293
306
  close();
294
307
  closeAll?.();
@@ -305,7 +318,8 @@ function ComposerSubmenu({
305
318
  className: cn(
306
319
  "flex max-h-[var(--radix-popover-content-available-height)] flex-col overflow-hidden p-1",
307
320
  COMPOSER_MENU_NO_ENTRANCE,
308
- panelClassName ?? "w-72"
321
+ panelClassName ?? "w-72",
322
+ "max-sm:!w-[calc(100vw-1rem)]"
309
323
  ),
310
324
  children: /* @__PURE__ */ jsx(ComposerMenuLevel, { children: drillInPlace ? /* @__PURE__ */ jsx(InPlaceNav, { children: typeof children === "function" ? children(close) : children }) : typeof children === "function" ? children(close) : children })
311
325
  }
@@ -19,6 +19,12 @@ export interface LiveRunDisplayProps {
19
19
  * the status line alive from the very first click (no dead moment).
20
20
  */
21
21
  pending?: boolean;
22
+ /**
23
+ * The run failed before any stream existed (the launch was refused — e.g. a
24
+ * Mandate with no Holder). Shown in the error slot instead of "Starting…",
25
+ * so a refused launch never reads as a run still on its way.
26
+ */
27
+ failure?: string | null;
22
28
  /** Renders a dismiss (X) affordance; caller tears the run down. */
23
29
  onDismiss?: () => void;
24
30
  className?: string;
@@ -36,4 +42,4 @@ export interface LiveRunDisplayProps {
36
42
  */
37
43
  variant?: "card" | "bare";
38
44
  }
39
- export declare function LiveRunDisplay({ conversationId, requestId: requestIdProp, label, pending, onDismiss, className, bodyClassName, variant, }: LiveRunDisplayProps): import("react").JSX.Element | null;
45
+ export declare function LiveRunDisplay({ conversationId, requestId: requestIdProp, label, pending, failure, onDismiss, className, bodyClassName, variant, }: LiveRunDisplayProps): import("react").JSX.Element | null;
@@ -20,12 +20,19 @@ function LiveRunDisplay({
20
20
  requestId: requestIdProp,
21
21
  label,
22
22
  pending = false,
23
+ failure = null,
23
24
  onDismiss,
24
25
  className,
25
26
  bodyClassName,
26
27
  variant = "card"
27
28
  }) {
28
- const { requestId, isActive, statusText, errorMessage, chunkCount } = useLiveRunStatus(conversationId, requestIdProp, pending);
29
+ const status = useLiveRunStatus(
30
+ conversationId,
31
+ requestIdProp,
32
+ pending && !failure
33
+ );
34
+ const { requestId, isActive, statusText, chunkCount } = status;
35
+ const errorMessage = status.errorMessage ?? (failure || null);
29
36
  const conversationMessages = useAppSelector(
30
37
  conversationId ? selectConversationMessages(conversationId) : selectNoConversationMessages
31
38
  );
@@ -40,7 +47,7 @@ function LiveRunDisplay({
40
47
  if (el) el.scrollTop = el.scrollHeight;
41
48
  }, [chunkCount, isActive]);
42
49
  const hasRun = Boolean(conversationId || requestId);
43
- if (!hasRun && !pending) return null;
50
+ if (!hasRun && !pending && !failure) return null;
44
51
  if (variant === "bare") {
45
52
  return /* @__PURE__ */ jsxs("div", { className: cn("h-full min-h-0", className), children: [
46
53
  errorMessage ? /* @__PURE__ */ jsxs("p", { className: "pb-2 text-xs text-destructive", children: [
@@ -94,7 +101,7 @@ function LiveRunDisplay({
94
101
  ),
95
102
  children: [
96
103
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-border px-2.5 py-1.5 text-xs text-muted-foreground", children: [
97
- isActive || pending && !requestId ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 shrink-0 animate-spin text-primary" }) : errorMessage ? /* @__PURE__ */ jsx(TriangleAlert, { className: "h-3.5 w-3.5 shrink-0 text-destructive" }) : null,
104
+ isActive || pending && !requestId && !errorMessage ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 shrink-0 animate-spin text-primary" }) : errorMessage ? /* @__PURE__ */ jsx(TriangleAlert, { className: "h-3.5 w-3.5 shrink-0 text-destructive" }) : null,
98
105
  /* @__PURE__ */ jsxs("span", { className: "min-w-0 truncate font-medium", children: [
99
106
  label ?? "AI run",
100
107
  serverPhase ? /* @__PURE__ */ jsxs("span", { className: "font-normal text-muted-foreground/80", children: [
@@ -67,16 +67,10 @@ function TranscriptIntegrityCopyButtonInner({
67
67
  pathname,
68
68
  effectiveVisibleGroupLimit
69
69
  });
70
- try {
71
- if (!await copyText(formatTranscriptIntegrityReport(report))) return;
72
- toast.success(
73
- report.anomalies.length === 0 ? "Transcript report copied \u2014 no anomalies detected" : `Transcript report copied \u2014 ${report.anomalies.length} anomal${report.anomalies.length === 1 ? "y" : "ies"} flagged`
74
- );
75
- } catch (err) {
76
- toast.error(
77
- `Could not copy the transcript report: ${err instanceof Error ? err.message : String(err)}`
78
- );
79
- }
70
+ if (!await copyText(formatTranscriptIntegrityReport(report))) return;
71
+ toast.success(
72
+ report.anomalies.length === 0 ? "Transcript report copied \u2014 no anomalies detected" : `Transcript report copied \u2014 ${report.anomalies.length} anomal${report.anomalies.length === 1 ? "y" : "ies"} flagged`
73
+ );
80
74
  };
81
75
  return /* @__PURE__ */ jsx(
82
76
  Button,
@@ -15,9 +15,6 @@ import { type MandateKey } from "@ai-matrx/agents/mandates";
15
15
  * `services/mandates/client_mandates.py`, then add its key here.
16
16
  */
17
17
  export declare const SYSTEM_AGENT_MANDATES: {
18
- readonly "prompt-app-auto-create": "agent_apps.auto_create";
19
- readonly "prompt-app-auto-create-lightning": "agent_apps.auto_create_lightning";
20
- readonly "prompt-app-metadata-generator": "agent_apps.metadata";
21
18
  readonly "prompt-app-ui-editor": "code_editor.prompt_app_ui_edit";
22
19
  readonly "generic-code-editor": "code_editor.code_edit";
23
20
  readonly "code-editor-dynamic-context": "code_editor.dynamic_context_edit";
@@ -1,8 +1,5 @@
1
1
  import { MANDATE_KEYS } from "@ai-matrx/agents/mandates";
2
2
  const SYSTEM_AGENT_MANDATES = {
3
- "prompt-app-auto-create": MANDATE_KEYS.agent_apps__auto_create,
4
- "prompt-app-auto-create-lightning": MANDATE_KEYS.agent_apps__auto_create_lightning,
5
- "prompt-app-metadata-generator": MANDATE_KEYS.agent_apps__metadata,
6
3
  "prompt-app-ui-editor": MANDATE_KEYS.code_editor__prompt_app_ui_edit,
7
4
  "generic-code-editor": MANDATE_KEYS.code_editor__code_edit,
8
5
  "code-editor-dynamic-context": MANDATE_KEYS.code_editor__dynamic_context_edit,
@@ -1,4 +1,10 @@
1
1
  import { type LiveAgentRunOptions } from "./useLiveAgentRun.js";
2
+ /**
3
+ * The words a failed launch shows in its window: the server's own reason when
4
+ * the run carried one (a Mandate with no Holder names the rungs it checked),
5
+ * else the error's message.
6
+ */
7
+ export declare function floatingFailureReason(error: unknown): string;
2
8
  /**
3
9
  * A run this hook only WATCHES — launched and owned elsewhere, its state read
4
10
  * straight out of React. Pass it as `track` and the window follows it; there is
@@ -48,6 +54,19 @@ export interface FloatingRun {
48
54
  bindRequest: (requestId: string) => void;
49
55
  /** Close this run's window (and release its instance when owned). */
50
56
  close: () => void;
57
+ /**
58
+ * The launch failed: the window stops saying "Starting…" and shows `reason`.
59
+ * Call it from the launch's failure path — a window left pending after a
60
+ * refused launch reads as a run that is still coming (the Spaces "Build
61
+ * with AI" incident, 2026-10-07).
62
+ */
63
+ fail: (reason: string) => void;
64
+ /**
65
+ * Call once the launch has returned, however it ended: a window still
66
+ * waiting for its first stream handle shows `reason` instead of "Starting…"
67
+ * forever. A bound window is left alone — its own stream tells the story.
68
+ */
69
+ settle: (reason: string) => void;
51
70
  }
52
71
  export interface UseFloatingRunWindow {
53
72
  /** Open the window BEFORE launching, then bind the run to it. */
@@ -7,6 +7,13 @@ import {
7
7
  useLiveAgentRun
8
8
  } from "./useLiveAgentRun.js";
9
9
  import { useLiveRunHandle } from "./useLiveRunHandle.js";
10
+ import { HeadlessAgentRunError } from "./useHeadlessAgentJson.js";
11
+ import { isOrganizationSelectionCancelled } from "../../host/org.js";
12
+ function floatingFailureReason(error) {
13
+ if (error instanceof HeadlessAgentRunError && error.detail) return error.detail;
14
+ if (error instanceof Error && error.message) return error.message;
15
+ return "The run could not start.";
16
+ }
10
17
  function useFloatingRunWindow(options = {}) {
11
18
  const { instanceId, width, height, owns = true, track } = options;
12
19
  const openWindow = useOpenLiveRunWindow();
@@ -76,13 +83,22 @@ function useFloatingRunWindow(options = {}) {
76
83
  height
77
84
  });
78
85
  handleRef.current = handle;
86
+ let bound = false;
79
87
  return {
80
88
  bind: (conversationId) => {
89
+ bound = true;
81
90
  if (owns) run.claim(conversationId);
82
91
  handle.update({ conversationId, pending: false });
83
92
  },
84
- bindRequest: (requestId) => handle.update({ requestId, pending: false }),
85
- close
93
+ bindRequest: (requestId) => {
94
+ bound = true;
95
+ handle.update({ requestId, pending: false });
96
+ },
97
+ close,
98
+ fail: (reason) => handle.update({ pending: false, failure: reason }),
99
+ settle: (reason) => {
100
+ if (!bound) handle.update({ pending: false, failure: reason });
101
+ }
86
102
  };
87
103
  };
88
104
  return { start, close };
@@ -93,13 +109,19 @@ function useFloatingAgentRun(options = {}) {
93
109
  async function run(opts) {
94
110
  const { label, ...runOptions } = opts;
95
111
  const bound = floating.start(label ?? options.label ?? "AI is working");
96
- return live.run({
97
- ...runOptions,
98
- onConversationCreated: (conversationId) => {
99
- bound.bind(conversationId);
100
- opts.onConversationCreated?.(conversationId);
101
- }
102
- });
112
+ try {
113
+ return await live.run({
114
+ ...runOptions,
115
+ onConversationCreated: (conversationId) => {
116
+ bound.bind(conversationId);
117
+ opts.onConversationCreated?.(conversationId);
118
+ }
119
+ });
120
+ } catch (error) {
121
+ if (isOrganizationSelectionCancelled(error)) bound.close();
122
+ else bound.fail(floatingFailureReason(error));
123
+ throw error;
124
+ }
103
125
  }
104
126
  return {
105
127
  run,
@@ -114,6 +136,7 @@ function useFloatingAgentRun(options = {}) {
114
136
  };
115
137
  }
116
138
  export {
139
+ floatingFailureReason,
117
140
  useFloatingAgentRun,
118
141
  useFloatingRunWindow
119
142
  };
@@ -43,12 +43,8 @@ function PromptPreviewContent({
43
43
  };
44
44
  }, [conversationId, store, nonce]);
45
45
  const copy = async (label, text) => {
46
- try {
47
- if (!await copyText(text)) return;
48
- toast.success(`${label} copied`);
49
- } catch {
50
- toast.error("Couldn't copy");
51
- }
46
+ if (!await copyText(text)) return;
47
+ toast.success(`${label} copied`);
52
48
  };
53
49
  return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-3 bg-textured p-4", children: [
54
50
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [