@langchain/macaw-components 1.7.8 → 1.7.10
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/dist/catalog.json +771 -741
- package/dist/components/ChatComposer/ChatComposer.d.ts +10 -1
- package/dist/components/ChatComposer/ChatComposer.js +16 -9
- package/dist/components/ChatComposer/ChatComposer.js.map +1 -1
- package/dist/components/ChatComposer/ChatComposerContext.d.ts +1 -1
- package/dist/components/ChatComposer/ChatComposerContext.js.map +1 -1
- package/dist/components/ChatComposer/ChatComposerRichInput.js +13 -2
- package/dist/components/ChatComposer/ChatComposerRichInput.js.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.d.ts +4 -3
- package/dist/components/ChatMessage/ChatMessage.js +17 -6
- package/dist/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.types.d.ts +2 -0
- package/dist/components/ChatPlan/ChatPlan.d.ts +27 -0
- package/dist/components/ChatPlan/ChatPlan.js +156 -0
- package/dist/components/ChatPlan/ChatPlan.js.map +1 -0
- package/dist/components/ChatPlan/index.d.ts +2 -0
- package/dist/components/ChatPlan/index.js +2 -0
- package/dist/components/ChatRichContent/ChatRichContent.js +79 -28
- package/dist/components/ChatRichContent/ChatRichContent.js.map +1 -1
- package/dist/components/ChatRichContent/ChatRichContent.types.d.ts +18 -0
- package/dist/components/ChatRichContent/index.d.ts +1 -1
- package/dist/components/ChatState/ChatState.d.ts +14 -1
- package/dist/components/ChatState/ChatState.js +6 -5
- package/dist/components/ChatState/ChatState.js.map +1 -1
- package/dist/components/ChatState/ChatStateTimer.d.ts +3 -1
- package/dist/components/ChatState/ChatStateTimer.js +24 -11
- package/dist/components/ChatState/ChatStateTimer.js.map +1 -1
- package/dist/components/ChatState/formatChatDuration.d.ts +16 -0
- package/dist/components/ChatState/formatChatDuration.js +19 -0
- package/dist/components/ChatState/formatChatDuration.js.map +1 -0
- package/dist/components/ChatState/index.d.ts +2 -0
- package/dist/components/ChatState/index.js +2 -1
- package/dist/components/ChatToolCall/ChatToolCall.d.ts +12 -2
- package/dist/components/ChatToolCall/ChatToolCall.js +29 -15
- package/dist/components/ChatToolCall/ChatToolCall.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallAccordion.d.ts +3 -1
- package/dist/components/ChatToolCall/ChatToolCallAccordion.js +40 -26
- package/dist/components/ChatToolCall/ChatToolCallAccordion.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallCaret.d.ts +5 -0
- package/dist/components/ChatToolCall/ChatToolCallCaret.js +20 -0
- package/dist/components/ChatToolCall/ChatToolCallCaret.js.map +1 -0
- package/dist/components/ChatToolCall/ChatToolCallCollapse.d.ts +12 -0
- package/dist/components/ChatToolCall/ChatToolCallCollapse.js +66 -0
- package/dist/components/ChatToolCall/ChatToolCallCollapse.js.map +1 -0
- package/dist/components/ChatToolCall/ChatToolCallGroup.d.ts +20 -2
- package/dist/components/ChatToolCall/ChatToolCallGroup.js +52 -37
- package/dist/components/ChatToolCall/ChatToolCallGroup.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallGroupContext.d.ts +24 -0
- package/dist/components/ChatToolCall/ChatToolCallGroupContext.js +61 -0
- package/dist/components/ChatToolCall/ChatToolCallGroupContext.js.map +1 -0
- package/dist/components/ChatToolCall/ChatToolCallIcon.d.ts +4 -0
- package/dist/components/ChatToolCall/ChatToolCallIcon.js +13 -0
- package/dist/components/ChatToolCall/ChatToolCallIcon.js.map +1 -0
- package/dist/components/ChatToolCall/ChatToolCallReasoning.d.ts +11 -3
- package/dist/components/ChatToolCall/ChatToolCallReasoning.js +34 -17
- package/dist/components/ChatToolCall/ChatToolCallReasoning.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallRowStatus.d.ts +14 -0
- package/dist/components/ChatToolCall/ChatToolCallRowStatus.js +25 -0
- package/dist/components/ChatToolCall/ChatToolCallRowStatus.js.map +1 -0
- package/dist/components/ChatToolCall/ChatToolCallStatusRow.d.ts +3 -1
- package/dist/components/ChatToolCall/ChatToolCallStatusRow.js +29 -18
- package/dist/components/ChatToolCall/ChatToolCallStatusRow.js.map +1 -1
- package/dist/utilities.css +1 -1
- package/docs/CHAT.md +45 -1
- package/docs/DESIGN.md +10 -6
- package/package.json +6 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { ChatStateStatus } from '../ChatState/index.js';
|
|
3
|
+
interface RowReport {
|
|
4
|
+
status: ChatStateStatus;
|
|
5
|
+
/** Host-supplied icon; defaults like the wrench are not reported. */
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface GroupRegistry {
|
|
9
|
+
update: (id: string, report: RowReport) => void;
|
|
10
|
+
remove: (id: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const ChatToolCallGroupContext: import("react").Context<GroupRegistry | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Reports a row's status and icon to the enclosing group, which shows the
|
|
15
|
+
* combined status on its header. Returns whether the row is inside a group.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useReportToGroup({ status, icon }: RowReport): boolean;
|
|
18
|
+
export declare function useGroupRows(): {
|
|
19
|
+
registry: GroupRegistry;
|
|
20
|
+
anyRunning: boolean;
|
|
21
|
+
allSucceeded: boolean;
|
|
22
|
+
icons: ReactElement<unknown, string | import("react").JSXElementConstructor<any>>[];
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext, isValidElement, useContext, useId, useLayoutEffect, useMemo, useState } from "react";
|
|
2
|
+
//#region packages/components/src/components/ChatToolCall/ChatToolCallGroupContext.tsx
|
|
3
|
+
var ChatToolCallGroupContext = createContext(null);
|
|
4
|
+
var iconType = (icon) => isValidElement(icon) && icon.type;
|
|
5
|
+
/**
|
|
6
|
+
* Reports a row's status and icon to the enclosing group, which shows the
|
|
7
|
+
* combined status on its header. Returns whether the row is inside a group.
|
|
8
|
+
*/
|
|
9
|
+
function useReportToGroup({ status, icon }) {
|
|
10
|
+
const registry = useContext(ChatToolCallGroupContext);
|
|
11
|
+
const id = useId();
|
|
12
|
+
useLayoutEffect(() => {
|
|
13
|
+
registry?.update(id, {
|
|
14
|
+
status,
|
|
15
|
+
icon
|
|
16
|
+
});
|
|
17
|
+
}, [
|
|
18
|
+
registry,
|
|
19
|
+
id,
|
|
20
|
+
status,
|
|
21
|
+
icon
|
|
22
|
+
]);
|
|
23
|
+
useLayoutEffect(() => () => registry?.remove(id), [registry, id]);
|
|
24
|
+
return registry !== null;
|
|
25
|
+
}
|
|
26
|
+
function useGroupRows() {
|
|
27
|
+
const [rows, setRows] = useState(() => /* @__PURE__ */ new Map());
|
|
28
|
+
const registry = useMemo(() => ({
|
|
29
|
+
update: (id, report) => setRows((previous) => {
|
|
30
|
+
const current = previous.get(id);
|
|
31
|
+
if (current?.status === report.status && iconType(current.icon) === iconType(report.icon)) return previous;
|
|
32
|
+
return new Map(previous).set(id, report);
|
|
33
|
+
}),
|
|
34
|
+
remove: (id) => setRows((previous) => {
|
|
35
|
+
const next = new Map(previous);
|
|
36
|
+
next.delete(id);
|
|
37
|
+
return next;
|
|
38
|
+
})
|
|
39
|
+
}), []);
|
|
40
|
+
const reports = [...rows.values()];
|
|
41
|
+
const anyRunning = reports.some((report) => report.status === "streaming");
|
|
42
|
+
const allSucceeded = reports.length > 0 && reports.every((report) => report.status === "completed");
|
|
43
|
+
const icons = [];
|
|
44
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const { icon } of reports) {
|
|
46
|
+
if (!isValidElement(icon) || seen.has(icon.type)) continue;
|
|
47
|
+
seen.add(icon.type);
|
|
48
|
+
icons.push(icon);
|
|
49
|
+
if (icons.length === 3) break;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
registry,
|
|
53
|
+
anyRunning,
|
|
54
|
+
allSucceeded,
|
|
55
|
+
icons
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ChatToolCallGroupContext, useGroupRows, useReportToGroup };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=ChatToolCallGroupContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatToolCallGroupContext.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallGroupContext.tsx"],"sourcesContent":["import {\n type ReactElement,\n type ReactNode,\n createContext,\n isValidElement,\n useContext,\n useId,\n useLayoutEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport type { ChatStateStatus } from '../ChatState';\n\ninterface RowReport {\n status: ChatStateStatus;\n /** Host-supplied icon; defaults like the wrench are not reported. */\n icon?: ReactNode;\n}\n\ninterface GroupRegistry {\n update: (id: string, report: RowReport) => void;\n remove: (id: string) => void;\n}\n\nexport const ChatToolCallGroupContext = createContext<GroupRegistry | null>(\n null\n);\n\nconst iconType = (icon: ReactNode) => isValidElement(icon) && icon.type;\n\n/**\n * Reports a row's status and icon to the enclosing group, which shows the\n * combined status on its header. Returns whether the row is inside a group.\n */\nexport function useReportToGroup({ status, icon }: RowReport) {\n const registry = useContext(ChatToolCallGroupContext);\n const id = useId();\n useLayoutEffect(() => {\n registry?.update(id, { status, icon });\n }, [registry, id, status, icon]);\n useLayoutEffect(() => () => registry?.remove(id), [registry, id]);\n return registry !== null;\n}\n\nexport function useGroupRows() {\n const [rows, setRows] = useState<ReadonlyMap<string, RowReport>>(\n () => new Map()\n );\n const registry = useMemo<GroupRegistry>(\n () => ({\n // Hosts recreate icon elements every render, so compare by icon type.\n update: (id, report) =>\n setRows((previous) => {\n const current = previous.get(id);\n if (\n current?.status === report.status &&\n iconType(current.icon) === iconType(report.icon)\n ) {\n return previous;\n }\n return new Map(previous).set(id, report);\n }),\n remove: (id) =>\n setRows((previous) => {\n const next = new Map(previous);\n next.delete(id);\n return next;\n }),\n }),\n []\n );\n\n const reports = [...rows.values()];\n const anyRunning = reports.some((report) => report.status === 'streaming');\n const allSucceeded =\n reports.length > 0 &&\n reports.every((report) => report.status === 'completed');\n const icons: ReactElement[] = [];\n const seen = new Set<ReactElement['type']>();\n for (const { icon } of reports) {\n if (!isValidElement(icon) || seen.has(icon.type)) continue;\n seen.add(icon.type);\n icons.push(icon);\n if (icons.length === 3) break;\n }\n\n return { registry, anyRunning, allSucceeded, icons };\n}\n"],"mappings":";;AAyBA,IAAa,2BAA2B,cACtC,IACF;AAEA,IAAM,YAAY,SAAoB,eAAe,IAAI,KAAK,KAAK;;;;;AAMnE,SAAgB,iBAAiB,EAAE,QAAQ,QAAmB;CAC5D,MAAM,WAAW,WAAW,wBAAwB;CACpD,MAAM,KAAK,MAAM;CACjB,sBAAsB;EACpB,UAAU,OAAO,IAAI;GAAE;GAAQ;EAAK,CAAC;CACvC,GAAG;EAAC;EAAU;EAAI;EAAQ;CAAI,CAAC;CAC/B,4BAA4B,UAAU,OAAO,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;CAChE,OAAO,aAAa;AACtB;AAEA,SAAgB,eAAe;CAC7B,MAAM,CAAC,MAAM,WAAW,+BAChB,IAAI,IAAI,CAChB;CACA,MAAM,WAAW,eACR;EAEL,SAAS,IAAI,WACX,SAAS,aAAa;GACpB,MAAM,UAAU,SAAS,IAAI,EAAE;GAC/B,IACE,SAAS,WAAW,OAAO,UAC3B,SAAS,QAAQ,IAAI,MAAM,SAAS,OAAO,IAAI,GAE/C,OAAO;GAET,OAAO,IAAI,IAAI,QAAQ,CAAC,CAAC,IAAI,IAAI,MAAM;EACzC,CAAC;EACH,SAAS,OACP,SAAS,aAAa;GACpB,MAAM,OAAO,IAAI,IAAI,QAAQ;GAC7B,KAAK,OAAO,EAAE;GACd,OAAO;EACT,CAAC;CACL,IACA,CAAC,CACH;CAEA,MAAM,UAAU,CAAC,GAAG,KAAK,OAAO,CAAC;CACjC,MAAM,aAAa,QAAQ,MAAM,WAAW,OAAO,WAAW,WAAW;CACzE,MAAM,eACJ,QAAQ,SAAS,KACjB,QAAQ,OAAO,WAAW,OAAO,WAAW,WAAW;CACzD,MAAM,QAAwB,CAAC;CAC/B,MAAM,uBAAO,IAAI,IAA0B;CAC3C,KAAK,MAAM,EAAE,UAAU,SAAS;EAC9B,IAAI,CAAC,eAAe,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;EAClD,KAAK,IAAI,KAAK,IAAI;EAClB,MAAM,KAAK,IAAI;EACf,IAAI,MAAM,WAAW,GAAG;CAC1B;CAEA,OAAO;EAAE;EAAU;EAAY;EAAc;CAAM;AACrD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region packages/components/src/components/ChatToolCall/ChatToolCallIcon.tsx
|
|
3
|
+
function ChatToolCallIcon({ children }) {
|
|
4
|
+
return /* @__PURE__ */ jsx("span", {
|
|
5
|
+
"aria-hidden": "true",
|
|
6
|
+
className: "flex size-3 shrink-0 items-center justify-center text-icon-tertiary [&_svg]:size-3",
|
|
7
|
+
children
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ChatToolCallIcon };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=ChatToolCallIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatToolCallIcon.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallIcon.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport function ChatToolCallIcon({ children }: { children: ReactNode }) {\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex size-3 shrink-0 items-center justify-center text-icon-tertiary [&_svg]:size-3\"\n >\n {children}\n </span>\n );\n}\n"],"mappings":";;AAEA,SAAgB,iBAAiB,EAAE,YAAqC;CACtE,OACE,oBAAC,QAAD;EACE,eAAY;EACZ,WAAU;EAET;CACG,CAAA;AAEV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ChatStateStatus } from '../ChatState/index.js';
|
|
3
3
|
export interface ChatToolCallReasoningProps {
|
|
4
4
|
/** Only content intentionally disclosed by the host; never raw hidden model reasoning. */
|
|
5
5
|
children: ReactNode;
|
|
@@ -8,11 +8,19 @@ export interface ChatToolCallReasoningProps {
|
|
|
8
8
|
onInspect?: () => void;
|
|
9
9
|
/** Tooltip and accessible action label for Simple row inspection. */
|
|
10
10
|
inspectLabel?: string;
|
|
11
|
+
/** Use a duration once done, e.g. `Thought for ${formatChatDuration(ms)}`. */
|
|
11
12
|
label?: string;
|
|
12
13
|
status?: ChatStateStatus;
|
|
13
14
|
elapsedMs?: number;
|
|
14
15
|
expanded?: boolean;
|
|
15
16
|
defaultExpanded?: boolean;
|
|
16
17
|
onExpandedChange?: (expanded: boolean) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Open the details while `status` is `streaming` and close them when it
|
|
20
|
+
* ends, so the reader can watch the reasoning arrive. Once the reader opens
|
|
21
|
+
* or closes the details, their choice sticks. Ignored when `expanded` is
|
|
22
|
+
* controlled; replaces `defaultExpanded`.
|
|
23
|
+
*/
|
|
24
|
+
expandWhileStreaming?: boolean;
|
|
17
25
|
}
|
|
18
|
-
export declare function ChatToolCallReasoning({ children, variant, onInspect, inspectLabel, label, status, elapsedMs, expanded, defaultExpanded, onExpandedChange, }: ChatToolCallReasoningProps): import("react").JSX.Element;
|
|
26
|
+
export declare function ChatToolCallReasoning({ children, variant, onInspect, inspectLabel, label, status, elapsedMs, expanded, defaultExpanded, onExpandedChange, expandWhileStreaming, }: ChatToolCallReasoningProps): import("react").JSX.Element;
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
1
2
|
import { Text } from "../Text/Text.js";
|
|
2
|
-
import {
|
|
3
|
+
import { n as ThinkingState_module_default } from "../../_chunks/LoadingIndicator-Itl4c0WV.js";
|
|
3
4
|
import { ChatToolCallAccordion } from "./ChatToolCallAccordion.js";
|
|
5
|
+
import { useReportToGroup } from "./ChatToolCallGroupContext.js";
|
|
6
|
+
import { ChatToolCallIcon } from "./ChatToolCallIcon.js";
|
|
7
|
+
import { ChatToolCallRowStatus } from "./ChatToolCallRowStatus.js";
|
|
4
8
|
import { ChatToolCallStatusRow } from "./ChatToolCallStatusRow.js";
|
|
5
|
-
import {
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { LightbulbIcon } from "@phosphor-icons/react/dist/ssr/Lightbulb";
|
|
6
12
|
//#region packages/components/src/components/ChatToolCall/ChatToolCallReasoning.tsx
|
|
7
|
-
function ChatToolCallReasoning({ children, variant = "default", onInspect, inspectLabel, label = "Reasoning summary", status = "completed", elapsedMs, expanded, defaultExpanded = false, onExpandedChange }) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
function ChatToolCallReasoning({ children, variant = "default", onInspect, inspectLabel, label = "Reasoning summary", status = "completed", elapsedMs, expanded, defaultExpanded = false, onExpandedChange, expandWhileStreaming = false }) {
|
|
14
|
+
const inGroup = useReportToGroup({ status });
|
|
15
|
+
const [readerChoice, setReaderChoice] = useState();
|
|
16
|
+
const followsStream = expandWhileStreaming && expanded === void 0;
|
|
17
|
+
const heading = /* @__PURE__ */ jsxs("span", {
|
|
18
|
+
className: "inline-flex min-w-0 items-center gap-space-2",
|
|
19
|
+
children: [/* @__PURE__ */ jsx(ChatToolCallIcon, { children: /* @__PURE__ */ jsx(LightbulbIcon, {
|
|
20
|
+
size: 12,
|
|
21
|
+
weight: "regular"
|
|
22
|
+
}) }), /* @__PURE__ */ jsx(Text, {
|
|
23
|
+
as: "span",
|
|
24
|
+
variant: "xs",
|
|
25
|
+
weight: "medium",
|
|
26
|
+
color: status === "streaming" ? void 0 : "secondary",
|
|
27
|
+
className: cn("min-w-0 truncate", status === "streaming" && ThinkingState_module_default.shimmer),
|
|
28
|
+
children: label
|
|
29
|
+
})]
|
|
15
30
|
});
|
|
16
|
-
const state = /* @__PURE__ */ jsx(
|
|
17
|
-
variant: "simple",
|
|
31
|
+
const state = /* @__PURE__ */ jsx(ChatToolCallRowStatus, {
|
|
18
32
|
status,
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
elapsedMs,
|
|
34
|
+
inGroup
|
|
21
35
|
});
|
|
22
36
|
if (variant === "simple") return /* @__PURE__ */ jsx(ChatToolCallStatusRow, {
|
|
23
37
|
groupLabel: label,
|
|
@@ -32,10 +46,13 @@ function ChatToolCallReasoning({ children, variant = "default", onInspect, inspe
|
|
|
32
46
|
detailsLabel: `${label} details`,
|
|
33
47
|
heading,
|
|
34
48
|
status: state,
|
|
35
|
-
expanded,
|
|
49
|
+
expanded: followsStream ? readerChoice ?? status === "streaming" : expanded,
|
|
36
50
|
defaultExpanded,
|
|
37
|
-
onExpandedChange
|
|
38
|
-
|
|
51
|
+
onExpandedChange: (next) => {
|
|
52
|
+
if (followsStream) setReaderChoice(next);
|
|
53
|
+
onExpandedChange?.(next);
|
|
54
|
+
},
|
|
55
|
+
detailsClassName: "break-words [overflow-wrap:anywhere]",
|
|
39
56
|
children
|
|
40
57
|
});
|
|
41
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCallReasoning.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallReasoning.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"ChatToolCallReasoning.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallReasoning.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { LightbulbIcon } from '@phosphor-icons/react/dist/ssr/Lightbulb';\n\nimport { cn } from '../../utils/cn';\nimport type { ChatStateStatus } from '../ChatState';\nimport { Text } from '../Text';\nimport { ChatToolCallAccordion } from './ChatToolCallAccordion';\nimport { useReportToGroup } from './ChatToolCallGroupContext';\nimport { ChatToolCallIcon } from './ChatToolCallIcon';\nimport { ChatToolCallRowStatus } from './ChatToolCallRowStatus';\nimport { ChatToolCallStatusRow } from './ChatToolCallStatusRow';\n\nimport thinkingStyles from '../ThinkingState/ThinkingState.module.css';\n\nexport interface ChatToolCallReasoningProps {\n /** Only content intentionally disclosed by the host; never raw hidden model reasoning. */\n children: ReactNode;\n variant?: 'default' | 'simple';\n /** Simple row inspection; the host owns navigation, panes, and permissions. */\n onInspect?: () => void;\n /** Tooltip and accessible action label for Simple row inspection. */\n inspectLabel?: string;\n /** Use a duration once done, e.g. `Thought for ${formatChatDuration(ms)}`. */\n label?: string;\n status?: ChatStateStatus;\n elapsedMs?: number;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /**\n * Open the details while `status` is `streaming` and close them when it\n * ends, so the reader can watch the reasoning arrive. Once the reader opens\n * or closes the details, their choice sticks. Ignored when `expanded` is\n * controlled; replaces `defaultExpanded`.\n */\n expandWhileStreaming?: boolean;\n}\n\nexport function ChatToolCallReasoning({\n children,\n variant = 'default',\n onInspect,\n inspectLabel,\n label = 'Reasoning summary',\n status = 'completed',\n elapsedMs,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n expandWhileStreaming = false,\n}: ChatToolCallReasoningProps) {\n const inGroup = useReportToGroup({ status });\n const [readerChoice, setReaderChoice] = useState<boolean>();\n const followsStream = expandWhileStreaming && expanded === undefined;\n const heading = (\n <span className=\"inline-flex min-w-0 items-center gap-space-2\">\n <ChatToolCallIcon>\n <LightbulbIcon size={12} weight=\"regular\" />\n </ChatToolCallIcon>\n <Text\n as=\"span\"\n variant=\"xs\"\n weight=\"medium\"\n // Streaming reasoning shimmers like ThinkingState's active label.\n color={status === 'streaming' ? undefined : 'secondary'}\n className={cn(\n 'min-w-0 truncate',\n status === 'streaming' && thinkingStyles.shimmer\n )}\n >\n {label}\n </Text>\n </span>\n );\n const state = (\n <ChatToolCallRowStatus\n status={status}\n elapsedMs={elapsedMs}\n inGroup={inGroup}\n />\n );\n\n if (variant === 'simple') {\n return (\n <ChatToolCallStatusRow\n groupLabel={label}\n heading={heading}\n status={state}\n onInspect={onInspect}\n inspectLabel={inspectLabel}\n />\n );\n }\n\n return (\n <ChatToolCallAccordion\n groupLabel={label}\n triggerLabel={label}\n detailsLabel={`${label} details`}\n heading={heading}\n status={state}\n expanded={\n followsStream ? (readerChoice ?? status === 'streaming') : expanded\n }\n defaultExpanded={defaultExpanded}\n onExpandedChange={(next) => {\n if (followsStream) setReaderChoice(next);\n onExpandedChange?.(next);\n }}\n detailsClassName=\"break-words [overflow-wrap:anywhere]\"\n >\n {children}\n </ChatToolCallAccordion>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuCA,SAAgB,sBAAsB,EACpC,UACA,UAAU,WACV,WACA,cACA,QAAQ,qBACR,SAAS,aACT,WACA,UACA,kBAAkB,OAClB,kBACA,uBAAuB,SACM;CAC7B,MAAM,UAAU,iBAAiB,EAAE,OAAO,CAAC;CAC3C,MAAM,CAAC,cAAc,mBAAmB,SAAkB;CAC1D,MAAM,gBAAgB,wBAAwB,aAAa,KAAA;CAC3D,MAAM,UACJ,qBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA,CACE,oBAAC,kBAAD,EAAA,UACE,oBAAC,eAAD;GAAe,MAAM;GAAI,QAAO;EAAW,CAAA,EAC3B,CAAA,GAClB,oBAAC,MAAD;GACE,IAAG;GACH,SAAQ;GACR,QAAO;GAEP,OAAO,WAAW,cAAc,KAAA,IAAY;GAC5C,WAAW,GACT,oBACA,WAAW,eAAe,6BAAe,OAC3C;GAEC,UAAA;EACG,CAAA,CACF;;CAER,MAAM,QACJ,oBAAC,uBAAD;EACU;EACG;EACF;CACV,CAAA;CAGH,IAAI,YAAY,UACd,OACE,oBAAC,uBAAD;EACE,YAAY;EACH;EACT,QAAQ;EACG;EACG;CACf,CAAA;CAIL,OACE,oBAAC,uBAAD;EACE,YAAY;EACZ,cAAc;EACd,cAAc,GAAG,MAAM;EACd;EACT,QAAQ;EACR,UACE,gBAAiB,gBAAgB,WAAW,cAAe;EAE5C;EACjB,mBAAmB,SAAS;GAC1B,IAAI,eAAe,gBAAgB,IAAI;GACvC,mBAAmB,IAAI;EACzB;EACA,kBAAiB;EAEhB;CACoB,CAAA;AAE3B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ChatStateStatus } from '../ChatState/index.js';
|
|
2
|
+
interface ChatToolCallRowStatusProps {
|
|
3
|
+
status: ChatStateStatus;
|
|
4
|
+
label?: string;
|
|
5
|
+
elapsedMs?: number;
|
|
6
|
+
/** Inside a group, the header shows the running indicator instead. */
|
|
7
|
+
inGroup: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Success is hidden visually but stays mounted, so the live region still
|
|
11
|
+
* announces the change.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ChatToolCallRowStatus({ status, label, elapsedMs, inGroup, }: ChatToolCallRowStatusProps): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { ChatState } from "../ChatState/ChatState.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region packages/components/src/components/ChatToolCall/ChatToolCallRowStatus.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Success is hidden visually but stays mounted, so the live region still
|
|
7
|
+
* announces the change.
|
|
8
|
+
*/
|
|
9
|
+
function ChatToolCallRowStatus({ status, label, elapsedMs, inGroup }) {
|
|
10
|
+
return /* @__PURE__ */ jsx("span", {
|
|
11
|
+
className: cn("inline-flex items-center", status === "completed" && "sr-only"),
|
|
12
|
+
children: /* @__PURE__ */ jsx(ChatState, {
|
|
13
|
+
variant: "simple",
|
|
14
|
+
label,
|
|
15
|
+
status,
|
|
16
|
+
showElapsed: status === "streaming",
|
|
17
|
+
showIndicator: !inGroup,
|
|
18
|
+
elapsedMs
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ChatToolCallRowStatus };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=ChatToolCallRowStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatToolCallRowStatus.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallRowStatus.tsx"],"sourcesContent":["import { cn } from '../../utils/cn';\nimport { ChatState, type ChatStateStatus } from '../ChatState';\n\ninterface ChatToolCallRowStatusProps {\n status: ChatStateStatus;\n label?: string;\n elapsedMs?: number;\n /** Inside a group, the header shows the running indicator instead. */\n inGroup: boolean;\n}\n\n/**\n * Success is hidden visually but stays mounted, so the live region still\n * announces the change.\n */\nexport function ChatToolCallRowStatus({\n status,\n label,\n elapsedMs,\n inGroup,\n}: ChatToolCallRowStatusProps) {\n return (\n <span\n className={cn(\n 'inline-flex items-center',\n status === 'completed' && 'sr-only'\n )}\n >\n <ChatState\n variant=\"simple\"\n label={label}\n status={status}\n showElapsed={status === 'streaming'}\n showIndicator={!inGroup}\n elapsedMs={elapsedMs}\n />\n </span>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,sBAAsB,EACpC,QACA,OACA,WACA,WAC6B;CAC7B,OACE,oBAAC,QAAD;EACE,WAAW,GACT,4BACA,WAAW,eAAe,SAC5B;EAEA,UAAA,oBAAC,WAAD;GACE,SAAQ;GACD;GACC;GACR,aAAa,WAAW;GACxB,eAAe,CAAC;GACL;EACZ,CAAA;CACG,CAAA;AAEV"}
|
|
@@ -2,10 +2,12 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
interface ChatToolCallStatusRowProps {
|
|
3
3
|
heading: ReactNode;
|
|
4
4
|
status: ReactNode;
|
|
5
|
+
/** Trailing content before the status, outside the inspect button. */
|
|
6
|
+
meta?: ReactNode;
|
|
5
7
|
groupLabel: string;
|
|
6
8
|
onInspect?: () => void;
|
|
7
9
|
inspectLabel?: string;
|
|
8
10
|
className?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare function ChatToolCallStatusRow({ heading, status, groupLabel, onInspect, inspectLabel, className, }: ChatToolCallStatusRowProps): import("react").JSX.Element;
|
|
12
|
+
export declare function ChatToolCallStatusRow({ heading, status, meta, groupLabel, onInspect, inspectLabel, className, }: ChatToolCallStatusRowProps): import("react").JSX.Element;
|
|
11
13
|
export {};
|
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
3
3
|
import { Button } from "../Button/Button.js";
|
|
4
|
-
import {
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region packages/components/src/components/ChatToolCall/ChatToolCallStatusRow.tsx
|
|
6
|
-
function ChatToolCallStatusRow({ heading, status, groupLabel, onInspect, inspectLabel = "View tool details", className }) {
|
|
7
|
-
const
|
|
6
|
+
function ChatToolCallStatusRow({ heading, status, meta, groupLabel, onInspect, inspectLabel = "View tool details", className }) {
|
|
7
|
+
const headingContent = /* @__PURE__ */ jsx("span", {
|
|
8
8
|
className: "flex min-w-0 flex-1 items-center gap-space-2 py-space-1",
|
|
9
9
|
children: heading
|
|
10
|
-
})
|
|
10
|
+
});
|
|
11
|
+
const trailing = meta != null && /* @__PURE__ */ jsx("span", {
|
|
12
|
+
className: "flex min-w-0 shrink-0 items-center gap-space-1 text-tertiary",
|
|
13
|
+
children: meta
|
|
14
|
+
});
|
|
11
15
|
return /* @__PURE__ */ jsx("div", {
|
|
12
16
|
role: "group",
|
|
13
17
|
"aria-label": groupLabel,
|
|
14
18
|
className: cn("min-w-0 max-w-full font-sans text-xxs text-secondary", className),
|
|
15
|
-
children: onInspect ? /* @__PURE__ */
|
|
16
|
-
|
|
17
|
-
children: /* @__PURE__ */ jsx(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
children: onInspect ? /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "flex min-w-0 items-center gap-space-1",
|
|
21
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
22
|
+
title: inspectLabel,
|
|
23
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
24
|
+
type: "button",
|
|
25
|
+
size: "xs",
|
|
26
|
+
variant: "plain",
|
|
27
|
+
color: "secondary",
|
|
28
|
+
"aria-label": `${groupLabel}: ${inspectLabel}`,
|
|
29
|
+
onClick: onInspect,
|
|
30
|
+
className: "focus-visible:ring-focus flex h-auto w-full min-w-0 flex-1 flex-wrap items-center gap-space-1 rounded-md border-0 px-space-1 py-0 text-left transition-colors duration-fast hover:bg-surface-level-2 focus-visible:outline-hidden focus-visible:ring-2 motion-reduce:transition-none dark:hover:bg-surface-level-2",
|
|
31
|
+
children: [headingContent, status]
|
|
32
|
+
})
|
|
33
|
+
}), trailing]
|
|
34
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
28
35
|
className: "flex flex-wrap items-center gap-space-1 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none",
|
|
29
|
-
children:
|
|
36
|
+
children: [
|
|
37
|
+
headingContent,
|
|
38
|
+
trailing,
|
|
39
|
+
status
|
|
40
|
+
]
|
|
30
41
|
})
|
|
31
42
|
});
|
|
32
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCallStatusRow.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallStatusRow.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Tooltip } from '../Tooltip';\n\ninterface ChatToolCallStatusRowProps {\n heading: ReactNode;\n status: ReactNode;\n groupLabel: string;\n onInspect?: () => void;\n inspectLabel?: string;\n className?: string;\n}\n\nexport function ChatToolCallStatusRow({\n heading,\n status,\n groupLabel,\n onInspect,\n inspectLabel = 'View tool details',\n className,\n}: ChatToolCallStatusRowProps) {\n const
|
|
1
|
+
{"version":3,"file":"ChatToolCallStatusRow.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallStatusRow.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Tooltip } from '../Tooltip';\n\ninterface ChatToolCallStatusRowProps {\n heading: ReactNode;\n status: ReactNode;\n /** Trailing content before the status, outside the inspect button. */\n meta?: ReactNode;\n groupLabel: string;\n onInspect?: () => void;\n inspectLabel?: string;\n className?: string;\n}\n\nexport function ChatToolCallStatusRow({\n heading,\n status,\n meta,\n groupLabel,\n onInspect,\n inspectLabel = 'View tool details',\n className,\n}: ChatToolCallStatusRowProps) {\n const headingContent = (\n <span className=\"flex min-w-0 flex-1 items-center gap-space-2 py-space-1\">\n {heading}\n </span>\n );\n const trailing = meta != null && (\n <span className=\"flex min-w-0 shrink-0 items-center gap-space-1 text-tertiary\">\n {meta}\n </span>\n );\n\n return (\n <div\n role=\"group\"\n aria-label={groupLabel}\n className={cn(\n 'min-w-0 max-w-full font-sans text-xxs text-secondary',\n className\n )}\n >\n {onInspect ? (\n <div className=\"flex min-w-0 items-center gap-space-1\">\n <Tooltip title={inspectLabel}>\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"plain\"\n color=\"secondary\"\n aria-label={`${groupLabel}: ${inspectLabel}`}\n onClick={onInspect}\n className=\"focus-visible:ring-focus flex h-auto w-full min-w-0 flex-1 flex-wrap items-center gap-space-1 rounded-md border-0 px-space-1 py-0 text-left transition-colors duration-fast hover:bg-surface-level-2 focus-visible:outline-hidden focus-visible:ring-2 motion-reduce:transition-none dark:hover:bg-surface-level-2\"\n >\n {headingContent}\n {status}\n </Button>\n </Tooltip>\n {/* Outside the inspect button so interactive metadata stays valid. */}\n {trailing}\n </div>\n ) : (\n <div className=\"flex flex-wrap items-center gap-space-1 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none\">\n {headingContent}\n {trailing}\n {status}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAiBA,SAAgB,sBAAsB,EACpC,SACA,QACA,MACA,YACA,WACA,eAAe,qBACf,aAC6B;CAC7B,MAAM,iBACJ,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA;CAER,MAAM,WAAW,QAAQ,QACvB,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA;CAGR,OACE,oBAAC,OAAD;EACE,MAAK;EACL,cAAY;EACZ,WAAW,GACT,wDACA,SACF;EAEC,UAAA,YACC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,SAAD;IAAS,OAAO;IACd,UAAA,qBAAC,QAAD;KACE,MAAK;KACL,MAAK;KACL,SAAQ;KACR,OAAM;KACN,cAAY,GAAG,WAAW,IAAI;KAC9B,SAAS;KACT,WAAU;KAPZ,UAAA,CASG,gBACA,MACK;;GACD,CAAA,GAER,QACE;EAEL,CAAA,IAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG;IACA;IACA;GACE;;CAEJ,CAAA;AAET"}
|