Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ui/src/app/agents/[namespace]/[name]/chat/[chatId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"use client";
import { use } from "react";
import ChatInterface from "@/components/chat/ChatInterface";

export default function ChatPageView({ params }: { params: Promise<{ name: string; namespace: string; chatId: string }> }) {
const { name, namespace, chatId } = use(params);
export const dynamic = "force-dynamic";

export default async function ChatPageView({ params }: { params: Promise<{ name: string; namespace: string; chatId: string }> }) {
const { name, namespace, chatId } = await params;

return <ChatInterface
selectedAgentName={name}
selectedNamespace={namespace}
sessionId={chatId}
headline={process.env.KAGENT_UI_HEADLINE}
/>;
Comment on lines 11 to 13
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env.NEXT_PUBLIC_HEADLINE is being read inside a Client Component page (this file has "use client"), which means the value is inlined at build time and won’t reflect runtime env var changes. To achieve runtime configurability, read the env var in a Server Component (remove "use client" from this page or move the env read into the server layout/page) and pass it to ChatInterface as a prop (and force dynamic rendering for the route or layout).

Copilot uses AI. Check for mistakes.
}
12 changes: 7 additions & 5 deletions ui/src/app/agents/[namespace]/[name]/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import ChatInterface from "@/components/chat/ChatInterface";
import { use } from 'react';

export const dynamic = "force-dynamic";

// This page component receives props (like params) from the Layout
export default function ChatAgentPage({ params }: { params: Promise<{ name: string, namespace: string }> }) {
const { name, namespace } = use(params);
return <ChatInterface selectedAgentName={name} selectedNamespace={namespace} />;
}
export default async function ChatAgentPage({ params }: { params: Promise<{ name: string, namespace: string }> }) {
const { name, namespace } = await params;
const headline = process.env.KAGENT_UI_HEADLINE;
return <ChatInterface selectedAgentName={name} selectedNamespace={namespace} headline={headline} />;
}
8 changes: 6 additions & 2 deletions ui/src/app/agents/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import AgentList from "@/components/AgentList";
export default function AgentListPage() {
return <AgentList />;

export const dynamic = "force-dynamic";

export default async function AgentListPage() {
const subtitle = process.env.KAGENT_UI_SUBTITLE;
return <AgentList subtitle={subtitle} />;
}
5 changes: 4 additions & 1 deletion ui/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import AgentList from "@/components/AgentList";

export const dynamic = "force-dynamic";

export default async function AgentListPage() {
return <AgentList />;
const subtitle = process.env.KAGENT_UI_SUBTITLE;
return <AgentList subtitle={subtitle} />;
}
11 changes: 9 additions & 2 deletions ui/src/components/AgentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { Button } from "./ui/button";
import { LoadingState } from "./LoadingState";
import { useAgents } from "./AgentsProvider";

export default function AgentList() {
interface AgentListProps {
subtitle?: string;
}

export default function AgentList({ subtitle }: AgentListProps) {
const { agents , loading, error } = useAgents();

if (error) {
Expand All @@ -23,7 +27,10 @@ export default function AgentList() {
<div className="mt-12 mx-auto max-w-6xl px-6">
<div className="flex justify-between items-center mb-8">
<div className="flex items-center gap-4">
<h1 className="text-2xl font-bold">Agents</h1>
<div>
<h1 className="text-2xl font-bold">Agents</h1>
{subtitle && <p className="text-muted-foreground text-sm mt-1">{subtitle}</p>}
</div>
</div>
</div>

Expand Down
5 changes: 3 additions & 2 deletions ui/src/components/chat/ChatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ interface ChatInterfaceProps {
selectedNamespace: string;
selectedSession?: Session | null;
sessionId?: string;
headline?: string;
}

export default function ChatInterface({ selectedAgentName, selectedNamespace, selectedSession, sessionId }: ChatInterfaceProps) {
export default function ChatInterface({ selectedAgentName, selectedNamespace, selectedSession, sessionId, headline }: ChatInterfaceProps) {
const router = useRouter();
const containerRef = useRef<HTMLDivElement>(null);
const [currentInputMessage, setCurrentInputMessage] = useState("");
Expand Down Expand Up @@ -626,7 +627,7 @@ export default function ChatInterface({ selectedAgentName, selectedNamespace, se
) : storedMessages.length === 0 && streamingMessages.length === 0 && !isStreaming ? (
<div className="flex items-center justify-center h-full min-h-[50vh]">
<div className="bg-card p-6 rounded-lg shadow-sm border max-w-md text-center">
<h3 className="text-lg font-medium mb-2">Start a conversation</h3>
<h3 className="text-lg font-medium mb-2">{headline ?? "Start a conversation"}</h3>
<p className="text-muted-foreground">
To begin chatting with the agent, type your message in the input box below.
</p>
Expand Down
Loading