@coral-ai/chat 0.4.2 → 0.6.0

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/README.md CHANGED
@@ -22,4 +22,18 @@ import { Chat } from "@coral-ai/chat";
22
22
  `ChatChunk`s, or a `ChatResponse`. A backend URL can also be supplied via the
23
23
  `api` prop or `coral.config.json`'s `chat.api`.
24
24
 
25
+ `disclaimer?: React.ReactNode` adds optional content beneath the input. By
26
+ default no disclaimer or footer space is rendered; `undefined`, `null`, and
27
+ `false` also hide it. To retain the previous built-in text, opt in explicitly:
28
+
29
+ ```tsx
30
+ <Chat api="/api/chat" disclaimer="AI makes mistakes. Check outputs." />
31
+ ```
32
+
33
+ Custom React content, such as a policy link, is also supported.
34
+
25
35
  See [coral-ai](https://github.com/mochimilk/coral-ai) for the full project.
36
+
37
+ ## Migrating to 0.6
38
+
39
+ User-message editing and `useChatContext().editMessage` have been removed. Assistant Copy/Regenerate and error Retry remain. The disclaimer is opt-in: pass `disclaimer` to render footer content; omission reserves no space. Sidecars use the true default 15px assistant font. Message rows use a 0px gap; footer buttons are small with a 2px gap.
package/dist/index.d.ts CHANGED
@@ -44,18 +44,29 @@ type ChatMessage = {
44
44
  approval?: ChatApprovalRequest;
45
45
  /**
46
46
  * If present, this assistant message carries a multi-step task plan.
47
- * Rendered inline as a collapsible checklist above the message text and
48
- * persists in history for replay. Updated in place as the agent streams.
47
+ * Legacy field — new messages use `blocks` to position the todo list
48
+ * inline at the stream point where it first appeared. Still read by the
49
+ * renderer as a fallback for persisted messages saved before blocks.
49
50
  */
50
51
  todos?: ChatTodo[];
51
52
  /**
52
53
  * If present, this assistant message carries one or more chart specs.
53
- * Rendered inline (above the message text) via `<CoralChart>` from
54
- * `@coral-ai/charts`. Streamed in incrementally as the agent calls the
55
- * built-in `render_chart` tool, and persisted with the conversation so
56
- * the visualizations survive reloads.
54
+ * Legacy field — new messages use `blocks` to position each chart at
55
+ * the stream point where it was emitted. Still read by the renderer
56
+ * as a fallback for persisted messages saved before blocks.
57
57
  */
58
58
  charts?: CoralChartSpec[];
59
+ /**
60
+ * Ordered list of inline blocks (text, charts, todos) in the order the
61
+ * agent emitted them. Renderers iterate this in stream order so a chart
62
+ * tool call appears at the exact point in the prose where it happened,
63
+ * matching the convention used by Claude.ai and ChatGPT.
64
+ *
65
+ * When absent, the renderer synthesizes blocks from the legacy
66
+ * `content` / `charts` / `todos` fields so old persisted conversations
67
+ * still display correctly.
68
+ */
69
+ blocks?: ChatBlock[];
59
70
  /**
60
71
  * If present, the turn that produced this assistant message failed. The
61
72
  * message renders as an error card (with a Retry button) instead of normal
@@ -97,6 +108,22 @@ type ChatApprovalRequest = {
97
108
  text?: string;
98
109
  };
99
110
  };
111
+ /**
112
+ * One inline block within an assistant message. Blocks are rendered in the
113
+ * order the agent emitted them, so charts and todo lists appear at the exact
114
+ * stream position where they happened (e.g. text → chart → text), rather than
115
+ * being pinned above the message.
116
+ */
117
+ type ChatBlock = {
118
+ type: "text";
119
+ content: string;
120
+ } | {
121
+ type: "chart";
122
+ spec: CoralChartSpec;
123
+ } | {
124
+ type: "todos";
125
+ todos: ChatTodo[];
126
+ };
100
127
  /**
101
128
  * One step in a multi-step task plan. The agent emits the whole list on each
102
129
  * update; the convention is exactly one item `in_progress` at a time.
@@ -200,6 +227,8 @@ interface ChatProps {
200
227
  * to invoke `sendMessage(text)` on click.
201
228
  */
202
229
  promptSuggestions?: React__default.ReactNode;
230
+ /** Optional content below the input. Omit or pass null to render no footer or reserved space. */
231
+ disclaimer?: React__default.ReactNode;
203
232
  /**
204
233
  * Pass `null` to disable the chat's built-in surface motion (input slide to
205
234
  * bottom on first message). Omit / leave undefined for default motion.
@@ -523,11 +552,6 @@ interface ChatContextValue {
523
552
  * If `messageId` targets a user message, the existing assistant reply for that turn is discarded and re-generated.
524
553
  */
525
554
  regenerate: (messageId?: string) => Promise<void>;
526
- /**
527
- * Replaces the content of an existing user message and re-runs from that point.
528
- * Truncates everything after the edited message and re-invokes the handler.
529
- */
530
- editMessage: (messageId: string, newContent: string) => Promise<void>;
531
555
  scrollToBottom: () => void;
532
556
  /** Pre-binds navigator.clipboard.writeText + the onCopy prop callback. */
533
557
  handleCopy: (content: string) => void;