@copilotkit/react-ui 1.55.3-canary.1776243725 → 1.55.3-canary.1776979102
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/index.cjs +14 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +19 -25
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +15 -11
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +14 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/chat/Markdown.tsx +3 -2
- package/src/components/chat/messages/AssistantMessage.tsx +8 -7
- package/src/components/chat/messages/ErrorMessage.tsx +8 -7
- package/src/components/dev-console/console.tsx +4 -5
- package/src/css/colors.css +1 -1
- package/src/css/console.css +10 -16
- package/src/css/input.css +5 -5
- package/src/css/markdown.css +3 -3
- package/src/components/chat/Markdown.test.ts +0 -101
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/react-ui",
|
|
3
|
-
"version": "1.55.3-canary.
|
|
3
|
+
"version": "1.55.3-canary.1776979102",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"rehype-raw": "^7.0.0",
|
|
49
49
|
"remark-gfm": "^4.0.1",
|
|
50
50
|
"remark-math": "^6.0.0",
|
|
51
|
-
"@copilotkit/react-core": "1.55.3-canary.
|
|
52
|
-
"@copilotkit/
|
|
53
|
-
"@copilotkit/
|
|
51
|
+
"@copilotkit/react-core": "1.55.3-canary.1776979102",
|
|
52
|
+
"@copilotkit/shared": "1.55.3-canary.1776979102",
|
|
53
|
+
"@copilotkit/runtime-client-gql": "1.55.3-canary.1776979102"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.1.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"tsdown": "^0.20.3",
|
|
63
63
|
"typescript": "^5.2.3",
|
|
64
64
|
"vitest": "^3.2.4",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
65
|
+
"tsconfig": "1.4.12",
|
|
66
|
+
"tailwind-config": "1.4.12"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"react": "^18 || ^19 || ^19.0.0-rc"
|
|
@@ -59,6 +59,7 @@ const defaultComponents: Components = {
|
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<CodeBlock
|
|
62
|
+
key={Math.random()}
|
|
62
63
|
language={(match && match[1]) || ""}
|
|
63
64
|
value={String(children).replace(/\n$/, "")}
|
|
64
65
|
{...props}
|
|
@@ -96,9 +97,9 @@ const defaultComponents: Components = {
|
|
|
96
97
|
</h6>
|
|
97
98
|
),
|
|
98
99
|
p: ({ children, ...props }) => (
|
|
99
|
-
<
|
|
100
|
+
<p className="copilotKitMarkdownElement" {...props}>
|
|
100
101
|
{children}
|
|
101
|
-
</
|
|
102
|
+
</p>
|
|
102
103
|
),
|
|
103
104
|
pre: ({ children, ...props }) => (
|
|
104
105
|
<pre className="copilotKitMarkdownElement" {...props}>
|
|
@@ -3,7 +3,6 @@ import { useChatContext } from "../ChatContext";
|
|
|
3
3
|
import { Markdown } from "../Markdown";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { copyToClipboard } from "@copilotkit/shared";
|
|
7
6
|
|
|
8
7
|
export const AssistantMessage = (props: AssistantMessageProps) => {
|
|
9
8
|
const { icons, labels } = useChatContext();
|
|
@@ -20,14 +19,16 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
|
|
|
20
19
|
} = props;
|
|
21
20
|
const [copied, setCopied] = useState(false);
|
|
22
21
|
|
|
23
|
-
const handleCopy =
|
|
22
|
+
const handleCopy = () => {
|
|
24
23
|
const content = message?.content || "";
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (content && onCopy) {
|
|
25
|
+
navigator.clipboard.writeText(content);
|
|
26
|
+
setCopied(true);
|
|
27
|
+
onCopy(content);
|
|
28
|
+
setTimeout(() => setCopied(false), 2000);
|
|
29
|
+
} else if (content) {
|
|
30
|
+
navigator.clipboard.writeText(content);
|
|
29
31
|
setCopied(true);
|
|
30
|
-
if (onCopy) onCopy(content);
|
|
31
32
|
setTimeout(() => setCopied(false), 2000);
|
|
32
33
|
}
|
|
33
34
|
};
|
|
@@ -2,21 +2,22 @@ import { ErrorMessageProps } from "../props";
|
|
|
2
2
|
import { useChatContext } from "../ChatContext";
|
|
3
3
|
import { Markdown } from "../Markdown";
|
|
4
4
|
import { useState } from "react";
|
|
5
|
-
import { copyToClipboard } from "@copilotkit/shared";
|
|
6
5
|
|
|
7
6
|
export const ErrorMessage = (props: ErrorMessageProps) => {
|
|
8
7
|
const { icons, labels } = useChatContext();
|
|
9
8
|
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
10
9
|
const [copied, setCopied] = useState(false);
|
|
11
10
|
|
|
12
|
-
const handleCopy =
|
|
11
|
+
const handleCopy = () => {
|
|
13
12
|
const content = error.message;
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (content && onCopy) {
|
|
14
|
+
navigator.clipboard.writeText(content);
|
|
15
|
+
setCopied(true);
|
|
16
|
+
onCopy(content);
|
|
17
|
+
setTimeout(() => setCopied(false), 2000);
|
|
18
|
+
} else if (content) {
|
|
19
|
+
navigator.clipboard.writeText(content);
|
|
18
20
|
setCopied(true);
|
|
19
|
-
if (onCopy) onCopy(content);
|
|
20
21
|
setTimeout(() => setCopied(false), 2000);
|
|
21
22
|
}
|
|
22
23
|
};
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
ExclamationMarkTriangleIcon,
|
|
21
21
|
} from "./icons";
|
|
22
22
|
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
|
23
|
-
import { COPILOTKIT_VERSION
|
|
23
|
+
import { COPILOTKIT_VERSION } from "@copilotkit/shared";
|
|
24
24
|
import { SmallSpinnerIcon } from "../chat/Icons";
|
|
25
25
|
import { CopilotKitHelpModal } from "../help-modal";
|
|
26
26
|
|
|
@@ -170,12 +170,11 @@ function VersionInfo({
|
|
|
170
170
|
`&& npm install @copilotkit/runtime@${latestVersion}`,
|
|
171
171
|
].join(" ");
|
|
172
172
|
|
|
173
|
-
const handleCopyClick =
|
|
174
|
-
|
|
175
|
-
if (success) {
|
|
173
|
+
const handleCopyClick = () => {
|
|
174
|
+
navigator.clipboard.writeText(installCommand.trim()).then(() => {
|
|
176
175
|
setCopyStatus("Command copied to clipboard!");
|
|
177
176
|
setTimeout(() => setCopyStatus(""), 1000);
|
|
178
|
-
}
|
|
177
|
+
});
|
|
179
178
|
};
|
|
180
179
|
|
|
181
180
|
if (versionStatus === "update-available" || versionStatus === "outdated") {
|
package/src/css/colors.css
CHANGED
|
@@ -48,7 +48,7 @@ html.dark,
|
|
|
48
48
|
body.dark,
|
|
49
49
|
[data-theme="dark"],
|
|
50
50
|
html[style*="color-scheme: dark"],
|
|
51
|
-
body[style*="color-scheme: dark"] {
|
|
51
|
+
body[style*="color-scheme: dark"] :root {
|
|
52
52
|
/* Main brand/action color - used for buttons, interactive elements */
|
|
53
53
|
--copilot-kit-primary-color: rgb(255, 255, 255);
|
|
54
54
|
/* Color that contrasts with primary - used for text on primary elements */
|
package/src/css/console.css
CHANGED
|
@@ -83,28 +83,22 @@
|
|
|
83
83
|
color: var(--copilot-kit-dev-console-text);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.dark
|
|
87
|
-
html.dark
|
|
88
|
-
body.dark
|
|
89
|
-
[data-theme="dark"]
|
|
90
|
-
html[style*="color-scheme: dark"]
|
|
91
|
-
.copilotKitDevConsole
|
|
92
|
-
.copilotKitDebugMenuTriggerButton,
|
|
86
|
+
.dark,
|
|
87
|
+
html.dark,
|
|
88
|
+
body.dark,
|
|
89
|
+
[data-theme="dark"],
|
|
90
|
+
html[style*="color-scheme: dark"],
|
|
93
91
|
body[style*="color-scheme: dark"]
|
|
94
92
|
.copilotKitDevConsole
|
|
95
93
|
.copilotKitDebugMenuTriggerButton {
|
|
96
94
|
color: white;
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
.dark
|
|
100
|
-
html.dark
|
|
101
|
-
body.dark
|
|
102
|
-
[data-theme="dark"]
|
|
103
|
-
|
|
104
|
-
.copilotKitDebugMenuTriggerButton:hover,
|
|
105
|
-
html[style*="color-scheme: dark"]
|
|
106
|
-
.copilotKitDevConsole
|
|
107
|
-
.copilotKitDebugMenuTriggerButton:hover,
|
|
97
|
+
.dark,
|
|
98
|
+
html.dark,
|
|
99
|
+
body.dark,
|
|
100
|
+
[data-theme="dark"],
|
|
101
|
+
html[style*="color-scheme: dark"],
|
|
108
102
|
body[style*="color-scheme: dark"]
|
|
109
103
|
.copilotKitDevConsole
|
|
110
104
|
.copilotKitDebugMenuTriggerButton:hover {
|
package/src/css/input.css
CHANGED
|
@@ -145,11 +145,11 @@
|
|
|
145
145
|
margin: 0 !important;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
.dark
|
|
149
|
-
html.dark
|
|
150
|
-
body.dark
|
|
151
|
-
[data-theme="dark"]
|
|
152
|
-
html[style*="color-scheme: dark"]
|
|
148
|
+
.dark,
|
|
149
|
+
html.dark,
|
|
150
|
+
body.dark,
|
|
151
|
+
[data-theme="dark"],
|
|
152
|
+
html[style*="color-scheme: dark"],
|
|
153
153
|
body[style*="color-scheme: dark"] .poweredBy {
|
|
154
154
|
color: rgb(69, 69, 69) !important;
|
|
155
155
|
}
|
package/src/css/markdown.css
CHANGED
|
@@ -47,14 +47,14 @@ a.copilotKitMarkdownElement {
|
|
|
47
47
|
text-decoration: underline;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.
|
|
50
|
+
p.copilotKitMarkdownElement {
|
|
51
51
|
padding: 0px;
|
|
52
52
|
margin: 0px;
|
|
53
53
|
line-height: 1.75;
|
|
54
54
|
font-size: 1rem;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.
|
|
57
|
+
p.copilotKitMarkdownElement:not(:last-child),
|
|
58
58
|
pre.copilotKitMarkdownElement:not(:last-child),
|
|
59
59
|
ol.copilotKitMarkdownElement:not(:last-child),
|
|
60
60
|
ul.copilotKitMarkdownElement:not(:last-child),
|
|
@@ -70,7 +70,7 @@ blockquote.copilotKitMarkdownElement {
|
|
|
70
70
|
padding-left: 10px;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
blockquote.copilotKitMarkdownElement
|
|
73
|
+
blockquote.copilotKitMarkdownElement p {
|
|
74
74
|
padding: 0.7em 0;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* These tests verify that CSS selectors in markdown.css correctly target
|
|
6
|
-
* the class names used by the Markdown component. When the p tag was changed
|
|
7
|
-
* to a div (to fix hydration errors), the CSS selectors must use class-only
|
|
8
|
-
* selectors instead of element-qualified selectors for paragraphs.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const cssPath = resolve(__dirname, "../../css/markdown.css");
|
|
12
|
-
const tsxPath = resolve(__dirname, "Markdown.tsx");
|
|
13
|
-
|
|
14
|
-
const cssContent = readFileSync(cssPath, "utf-8");
|
|
15
|
-
const tsxContent = readFileSync(tsxPath, "utf-8");
|
|
16
|
-
|
|
17
|
-
describe("Markdown CSS/component selector consistency", () => {
|
|
18
|
-
it("should not use p.copilotKitMarkdownElement selector in CSS", () => {
|
|
19
|
-
// After the p->div change, CSS must not use element-qualified p selectors
|
|
20
|
-
expect(cssContent).not.toMatch(/\bp\.copilotKitMarkdownElement\b/);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should have .copilotKitParagraph selector in CSS for paragraph styling", () => {
|
|
24
|
-
expect(cssContent).toMatch(/\.copilotKitParagraph\s*\{/);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should have .copilotKitParagraph:not(:last-child) selector for paragraph spacing", () => {
|
|
28
|
-
expect(cssContent).toMatch(/\.copilotKitParagraph:not\(:last-child\)/);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should use copilotKitParagraph class on the paragraph component", () => {
|
|
32
|
-
// The p component override in Markdown.tsx should include copilotKitParagraph
|
|
33
|
-
expect(tsxContent).toMatch(/copilotKitParagraph/);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("should render a div instead of p for the paragraph component", () => {
|
|
37
|
-
// The paragraph component should use <div> to avoid hydration errors
|
|
38
|
-
// when block-level elements are nested inside markdown paragraphs
|
|
39
|
-
const pComponentMatch = tsxContent.match(
|
|
40
|
-
/p:\s*\(\{[^}]*\}\)\s*=>\s*\(\s*<(\w+)/,
|
|
41
|
-
);
|
|
42
|
-
expect(pComponentMatch).not.toBeNull();
|
|
43
|
-
expect(pComponentMatch![1]).toBe("div");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should still have copilotKitMarkdownElement class on the paragraph div", () => {
|
|
47
|
-
// The div should retain the base class for any shared styling
|
|
48
|
-
const pSection = tsxContent.match(/p:\s*\([^)]*\)\s*=>\s*\([^)]+\)/s);
|
|
49
|
-
expect(pSection).not.toBeNull();
|
|
50
|
-
expect(pSection![0]).toContain("copilotKitMarkdownElement");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should use .copilotKitParagraph (not p) inside blockquote selector", () => {
|
|
54
|
-
// After p->div, blockquote nested paragraph selector must target the class
|
|
55
|
-
expect(cssContent).toMatch(
|
|
56
|
-
/blockquote\.copilotKitMarkdownElement\s+\.copilotKitParagraph\s*\{/,
|
|
57
|
-
);
|
|
58
|
-
expect(cssContent).not.toMatch(
|
|
59
|
-
/blockquote\.copilotKitMarkdownElement\s+p\s*\{/,
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("other element selectors remain valid", () => {
|
|
64
|
-
const elementSelectors = [
|
|
65
|
-
{ element: "h1", selector: "h1.copilotKitMarkdownElement" },
|
|
66
|
-
{ element: "h2", selector: "h2.copilotKitMarkdownElement" },
|
|
67
|
-
{ element: "h3", selector: "h3.copilotKitMarkdownElement" },
|
|
68
|
-
{ element: "h4", selector: "h4.copilotKitMarkdownElement" },
|
|
69
|
-
{ element: "h5", selector: "h5.copilotKitMarkdownElement" },
|
|
70
|
-
{ element: "h6", selector: "h6.copilotKitMarkdownElement" },
|
|
71
|
-
{ element: "a", selector: "a.copilotKitMarkdownElement" },
|
|
72
|
-
{ element: "pre", selector: "pre.copilotKitMarkdownElement" },
|
|
73
|
-
{
|
|
74
|
-
element: "blockquote",
|
|
75
|
-
selector: "blockquote.copilotKitMarkdownElement",
|
|
76
|
-
},
|
|
77
|
-
{ element: "ul", selector: "ul.copilotKitMarkdownElement" },
|
|
78
|
-
{ element: "li", selector: "li.copilotKitMarkdownElement" },
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
for (const { element, selector } of elementSelectors) {
|
|
82
|
-
it(`should have ${element} component rendering <${element}> with copilotKitMarkdownElement class`, () => {
|
|
83
|
-
// Verify the component still uses the actual HTML element
|
|
84
|
-
// Some components use arrow syntax, others use function syntax
|
|
85
|
-
const arrowRegex = new RegExp(
|
|
86
|
-
`${element}:\\s*\\(\\{[^}]*\\}\\)\\s*=>\\s*\\(\\s*<${element}[\\s\\S]*?copilotKitMarkdownElement`,
|
|
87
|
-
);
|
|
88
|
-
const funcRegex = new RegExp(
|
|
89
|
-
`${element}\\([^)]*\\)\\s*\\{[\\s\\S]*?<${element}[\\s\\S]*?copilotKitMarkdownElement`,
|
|
90
|
-
);
|
|
91
|
-
const matches =
|
|
92
|
-
arrowRegex.test(tsxContent) || funcRegex.test(tsxContent);
|
|
93
|
-
expect(matches).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it(`should have CSS selector ${selector}`, () => {
|
|
97
|
-
expect(cssContent).toContain(selector);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
});
|