Skip to content

The Open Standard for Generative UI

fix(react-ui): polish AgentInterface empty and navigation states (#848)

Prakhar8cb07ce736e6
diff --git a/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx b/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
index 8af9a3fed..d5ed60bb2 100644
--- a/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
+++ b/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
@@ -3,6 +3,7 @@ import {
useArtifactCategories,
useArtifactRendererRegistry,
useArtifactStorage,
+ useThreadList,
type ArtifactSummary,
} from "@openuidev/react-headless";
import { Boxes, Search, X } from "lucide-react";
@@ -94,6 +95,7 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
const storage = useArtifactStorage();
const categories = useArtifactCategories();
const { navigate } = useNav();
+ const switchToNewThread = useThreadList((s) => s.switchToNewThread);
const { defaultCategory } = useAgentInterfaceLabels();
const category = categoryName ? categories.find((c) => c.name === categoryName) : undefined;
@@ -104,6 +106,9 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
const notFound = categoryName !== undefined && category === undefined;
const typeFilter = category?.filter.type;
const categoryIllustration = useArtifactIcon(typeFilter?.[0] ?? "");
+ const categoryItemLabel = categoryName
+ ? categoryName.replace(/s$/i, "").toLowerCase()
+ : "artifact";
const [search, setSearch] = useState("");
const [debouncedSearch, setDebouncedSearch] = useState("");
@@ -119,11 +124,12 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
}, [search]);
const typeKey = typeFilter?.join(" ");
- // Noun derived from the category name (not a hardcoded "Apps" match).
- const emptyItemLabel = categoryName ? categoryName.toLowerCase() : "artifacts";
- const emptyMessage = debouncedSearch
+ const emptyTitle = debouncedSearch
? `No results found for "${debouncedSearch}"`
- : `No ${emptyItemLabel} yet`;
+ : `Ready to create your first ${categoryItemLabel}?`;
+ const emptySubtitle = debouncedSearch
+ ? undefined
+ : "Start with a prompt and create your first draft.";
// Initial page + reload on search/category change.
useEffect(() => {
@@ -172,6 +178,11 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
});
};
+ const handleNewChat = () => {
+ switchToNewThread();
+ navigate(undefined);
+ };
+
if (!storage) return null;
if (notFound) {
@@ -237,9 +248,21 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
{!error && artifacts.length === 0 && !isLoading && (
<div className="openui-agent-artifact-browser__empty">
<span className="openui-agent-artifact-browser__empty-illustration">
- {debouncedSearch ? categoryIllustration : <Boxes size="1em" />}
+ {categoryIllustration}
</span>
- <span className="openui-agent-artifact-browser__empty-text">{emptyMessage}</span>
+ <div className="openui-agent-artifact-browser__empty-copy">
+ <span className="openui-agent-artifact-browser__empty-text">{emptyTitle}</span>
+ {emptySubtitle && (
+ <span className="openui-agent-artifact-browser__empty-subtitle">
+ {emptySubtitle}
+ </span>
+ )}
+ </div>
+ {!debouncedSearch && (
+ <Button variant="primary" size="small" onClick={handleNewChat}>
+ New Chat
+ </Button>
+ )}
</div>
)}
{artifacts.map((artifact) => {
diff --git a/packages/react-ui/src/components/AgentInterface/__tests__/WelcomeScreen.ssr.test.tsx b/packages/react-ui/src/components/AgentInterface/__tests__/WelcomeScreen.ssr.test.tsx
index e57e85c8e..3fcb65f2f 100644
--- a/packages/react-ui/src/components/AgentInterface/__tests__/WelcomeScreen.ssr.test.tsx
+++ b/packages/react-ui/src/components/AgentInterface/__tests__/WelcomeScreen.ssr.test.tsx
@@ -9,7 +9,7 @@ const CHIPS: PromptTemplate[] = [
{
displayText: "Create a presentation",
prompt: "Create a presentation about ",
- starters: [{ displayText: "Our Q2 business review", prompt: "our Q2 business review" }],
+ completions: [{ displayText: "Our Q2 business review", prompt: "our Q2 business review" }],
},
];
const STARTERS = [{ displayText: "Quarterly deck", prompt: "Create a Q2 deck." }];
diff --git a/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss b/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
index 6bf70940c..7caf68932 100644
--- a/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
+++ b/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
@@ -223,12 +223,24 @@
font-size: 48px;
}
+.openui-agent-artifact-browser__empty-copy {
+ display: flex;
+ flex-direction: column;
+ gap: cssUtils.$space-xs;
+}
+
.openui-agent-artifact-browser__empty-text {
- @include cssUtils.typography(body, default);
+ @include cssUtils.typography(body, heavy);
color: cssUtils.$text-neutral-primary;
}
+.openui-agent-artifact-browser__empty-subtitle {
+ @include cssUtils.typography(body, default);
+
+ color: cssUtils.$text-neutral-secondary;
+}
+
.openui-agent-artifact-browser__load-more {
display: flex;
}
diff --git a/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss b/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
index ee1b37847..907b673e1 100644
--- a/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
+++ b/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
@@ -55,5 +55,9 @@
&__submit-button {
margin-left: auto;
+
+ &:disabled {
+ filter: grayscale(1);
+ }
}
}
diff --git a/packages/react-ui/src/components/AgentInterface/sidebar.scss b/packages/react-ui/src/components/AgentInterface/sidebar.scss
index 39109ccf3..cd88d6c24 100644
--- a/packages/react-ui/src/components/AgentInterface/sidebar.scss
+++ b/packages/react-ui/src/components/AgentInterface/sidebar.scss
@@ -265,7 +265,7 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
display: flex;
align-items: center;
- gap: cssUtils.$space-xs;
+ gap: cssUtils.$space-2xs;
width: 100%;
border-radius: calc(cssUtils.$radius-s + 1px);
color: cssUtils.$text-neutral-primary;
diff --git a/packages/react-ui/src/components/AgentInterface/threadlist.scss b/packages/react-ui/src/components/AgentInterface/threadlist.scss
index f4ef47d82..6e2c259e3 100644
--- a/packages/react-ui/src/components/AgentInterface/threadlist.scss
+++ b/packages/react-ui/src/components/AgentInterface/threadlist.scss
@@ -21,6 +21,26 @@ $thread-list-mask-height: cssUtils.$space-xl;
min-height: 0;
gap: cssUtils.$space-2xs;
overflow: auto;
+ scrollbar-width: thin;
+ scrollbar-color: cssUtils.$highlight-strong transparent;
+
+ &::-webkit-scrollbar {
+ width: 4px;
+ height: 4px;
+ }
+
+ &::-webkit-scrollbar-track {
+ background: transparent;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background-color: cssUtils.$highlight-strong;
+ border-radius: cssUtils.$radius-full;
+
+ &:hover {
+ background-color: cssUtils.$highlight-intense;
+ }
+ }
.openui-agent-container--mobile & {
gap: cssUtils.$space-s;