Skip to content

Commit 13a6a19

Browse files
authored
upgrade AG-UI to 0.0.42-alpha.1 and add thread switcher demo (#40)
* AG-UI 0.0.42-alpha.1 * Add thread switching * v0.0.22-alpha.0
1 parent 21655ed commit 13a6a19

File tree

15 files changed

+569
-335
lines changed

15 files changed

+569
-335
lines changed

apps/angular/demo-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "node --env-file=.env --loader tsx src/index.ts"
99
},
1010
"dependencies": {
11-
"@ag-ui/client": "0.0.41",
11+
"@ag-ui/client": "0.0.42-alpha.1",
1212
"@ag-ui/langgraph": "^0.0.11",
1313
"@copilotkitnext/demo-agents": "workspace:^",
1414
"@copilotkitnext/runtime": "workspace:^",

apps/angular/storybook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"storybook:build": "ng run storybook-angular:build-storybook"
1010
},
1111
"dependencies": {
12-
"@ag-ui/client": "0.0.41",
12+
"@ag-ui/client": "0.0.42-alpha.1",
1313
"@angular/animations": "^18.2.0",
1414
"@angular/common": "^18.2.0",
1515
"@angular/compiler": "^18.2.0",

apps/react/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@ag-ui/client": "0.0.41",
12+
"@ag-ui/client": "0.0.42-alpha.1",
1313
"@copilotkitnext/agent": "workspace:*",
1414
"@copilotkitnext/core": "workspace:*",
1515
"@copilotkitnext/react": "workspace:*",

apps/react/demo/src/app/page.tsx

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@copilotkitnext/react";
1010
import type { ToolsMenuItem } from "@copilotkitnext/react";
1111
import { z } from "zod";
12-
import { useMemo } from "react";
12+
import { useMemo, useState } from "react";
1313

1414
// Disable static optimization for this page
1515
export const dynamic = "force-dynamic";
@@ -61,6 +61,13 @@ export default function Home() {
6161
}
6262

6363
function Chat() {
64+
const [selectedThreadId, setSelectedThreadId] = useState<"thread---a" | "thread---b" | "thread---c">("thread---a");
65+
const threadOptions: Array<{ id: typeof selectedThreadId; label: string }> = [
66+
{ id: "thread---a", label: "Thread A" },
67+
{ id: "thread---b", label: "Thread B" },
68+
{ id: "thread---c", label: "Thread C" },
69+
];
70+
6471
//useConfigureSuggestions({
6572
// instructions: "Suggest helpful next actions",
6673
//});
@@ -120,5 +127,37 @@ function Chat() {
120127
[],
121128
);
122129

123-
return <CopilotChat inputProps={{ toolsMenu }} threadId="xyz" />;
130+
return (
131+
<div style={{ display: "flex", flexDirection: "column", height: "100%", padding: "16px", gap: "16px" }}>
132+
<div style={{ display: "flex", gap: "10px", justifyContent: "center" }}>
133+
{threadOptions.map(({ id, label }) => {
134+
const isActive = id === selectedThreadId;
135+
return (
136+
<button
137+
key={id}
138+
type="button"
139+
onClick={() => setSelectedThreadId(id)}
140+
aria-pressed={isActive}
141+
style={{
142+
padding: "6px 14px",
143+
borderRadius: "20px",
144+
border: isActive ? "2px solid #111827" : "1px solid #d1d5db",
145+
backgroundColor: isActive ? "#111827" : "#ffffff",
146+
color: isActive ? "#ffffff" : "#111827",
147+
fontWeight: 600,
148+
fontSize: "0.85rem",
149+
cursor: "pointer",
150+
transition: "all 0.15s ease-in-out",
151+
}}
152+
>
153+
{label}
154+
</button>
155+
);
156+
})}
157+
</div>
158+
<div style={{ flex: 1, minHeight: 0 }}>
159+
<CopilotChat inputProps={{ toolsMenu }} threadId={selectedThreadId} />
160+
</div>
161+
</div>
162+
);
124163
}

packages/agent/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@copilotkitnext/agent",
3-
"version": "0.0.21",
3+
"version": "0.0.22-alpha.0",
44
"description": "Basic Agent for CopilotKit",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -36,7 +36,7 @@
3636
"vitest": "^3.0.5"
3737
},
3838
"dependencies": {
39-
"@ag-ui/client": "0.0.41",
39+
"@ag-ui/client": "0.0.42-alpha.1",
4040
"@ai-sdk/anthropic": "^2.0.22",
4141
"@ai-sdk/google": "^2.0.17",
4242
"@ai-sdk/mcp": "^0.0.8",

packages/angular/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@copilotkitnext/angular",
3-
"version": "0.0.21",
3+
"version": "0.0.22-alpha.0",
44
"description": "Angular library for CopilotKit",
55
"main": "dist/fesm2022/copilotkitnext-angular.mjs",
66
"module": "dist/fesm2022/copilotkitnext-angular.mjs",
@@ -31,8 +31,8 @@
3131
"test:watch": "vitest --watch"
3232
},
3333
"dependencies": {
34-
"@ag-ui/client": "0.0.41",
35-
"@ag-ui/core": "0.0.41",
34+
"@ag-ui/client": "0.0.42-alpha.1",
35+
"@ag-ui/core": "0.0.42-alpha.1",
3636
"@copilotkitnext/core": "workspace:*",
3737
"@copilotkitnext/shared": "workspace:*",
3838
"clsx": "^2.1.1",

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@copilotkitnext/core",
3-
"version": "0.0.21",
3+
"version": "0.0.22-alpha.0",
44
"description": "Core web utilities for CopilotKit2",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -36,7 +36,7 @@
3636
"vitest": "^3.2.4"
3737
},
3838
"dependencies": {
39-
"@ag-ui/client": "0.0.41",
39+
"@ag-ui/client": "0.0.42-alpha.1",
4040
"@copilotkitnext/shared": "workspace:*",
4141
"rxjs": "7.8.1",
4242
"zod": "^3.25.75",

packages/core/src/core/run-handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ export class RunHandler {
104104
*/
105105
async connectAgent({ agent }: CopilotKitCoreConnectAgentParams): Promise<RunAgentResult> {
106106
try {
107+
// Detach any active run before connecting to avoid previous runs interfering
108+
await agent.detachActiveRun();
109+
agent.setMessages([]);
110+
agent.setState({});
111+
107112
if (agent instanceof HttpAgent) {
108113
agent.headers = { ...(this.core as unknown as CopilotKitCoreFriendsAccess).headers };
109114
}

packages/react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@copilotkitnext/react",
3-
"version": "0.0.21",
3+
"version": "0.0.22-alpha.0",
44
"description": "React components for CopilotKit2",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -53,8 +53,8 @@
5353
"vitest": "^3.2.4"
5454
},
5555
"dependencies": {
56-
"@ag-ui/client": "0.0.41",
57-
"@ag-ui/core": "0.0.41",
56+
"@ag-ui/client": "0.0.42-alpha.1",
57+
"@ag-ui/core": "0.0.42-alpha.1",
5858
"@copilotkitnext/core": "workspace:*",
5959
"@copilotkitnext/shared": "workspace:*",
6060
"@copilotkitnext/web-inspector": "workspace:*",

packages/react/src/components/chat/CopilotChat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaul
130130
const providedStopHandler = providedInputProps?.onStop;
131131
const hasMessages = agent.messages.length > 0;
132132
const shouldAllowStop = agent.isRunning && hasMessages;
133-
const effectiveStopHandler = shouldAllowStop ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
133+
const effectiveStopHandler = shouldAllowStop ? (providedStopHandler ?? stopCurrentRun) : providedStopHandler;
134134

135135
const finalInputProps = {
136136
...providedInputProps,
@@ -139,7 +139,7 @@ export function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaul
139139
isRunning: agent.isRunning,
140140
} as Partial<CopilotChatInputProps> & { onSubmitMessage: (value: string) => void };
141141

142-
finalInputProps.mode = agent.isRunning ? "processing" : finalInputProps.mode ?? "input";
142+
finalInputProps.mode = agent.isRunning ? "processing" : (finalInputProps.mode ?? "input");
143143

144144
const finalProps = merge(mergedProps, {
145145
messages: agent.messages,

0 commit comments

Comments
 (0)