diff --git a/.changeset/37862-empty-conversation.md b/.changeset/37862-empty-conversation.md new file mode 100644 index 00000000000..d86bdf332f1 --- /dev/null +++ b/.changeset/37862-empty-conversation.md @@ -0,0 +1,18 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/plugin-chatbot': patch +'@object-ui/i18n': patch +--- + +feat(app-shell): one empty-conversation layout for the AI home, the full-window drawer and the narrow drawer + +Clause-②: yes (widening) — `@object-ui/plugin-chatbot` `ChatbotEnhancedProps` gains the optional `renderEmptyState`; `@object-ui/i18n` gains `console.ai.suggestionsLabel` and `console.ai.suggestions.page.*` (eight keys) in every locale +Metadata-protocol: none + +A conversation with no message now shows the same layout in all three places: a greeting, a line on what to ask, suggested questions and the recent conversations with their titles. + +- **The AI home page** (an app's `ai:chat` entry) keeps its large question box, its suggestions that send and its recent conversations that open on the page. Its heading is the entry's declared `title`; with none it now greets the user by the time of day and name, as Home does, where it read "Ask your data". +- **The console's assistant drawer** draws the layout before the first message: large when the drawer fills the window, compact in the side rail and the phone sheet. The composer stays where it is, under the conversation. The `ask` assistant's suggestions follow the page in view: on a record, "Summarize this record" and "What is related to this record?" put their text in the composer for the user to finish; on a list, a dashboard or a report, the page's two questions send at once. Elsewhere, and for other assistants, the starter questions are the ones they had. The recent conversations list the drawer assistant's last three (five in the full window), not the AI home's own, and open in the drawer. +- **`@object-ui/plugin-chatbot`.** `ChatbotEnhanced` takes `renderEmptyState`: a host's empty conversation drawn in place of the built-in one, given `send` (sends a text) and `fill` (puts it in the composer, focused, sending nothing). + +Nothing to migrate. diff --git a/ui/packages/app-shell/src/console/ai/AppAskPage.tsx b/ui/packages/app-shell/src/console/ai/AppAskPage.tsx index c0fe5b98622..da492270653 100644 --- a/ui/packages/app-shell/src/console/ai/AppAskPage.tsx +++ b/ui/packages/app-shell/src/console/ai/AppAskPage.tsx @@ -23,6 +23,11 @@ * (`recentAskPageConversations`). A drawer thread is never one of them. Opening one * writes its `?c=`, so it is restored the way a reload restores it. * + * The home state is the shared empty conversation (`EmptyConversation`, + * objectstack#37862), large, with this page's own question box in its + * composer slot: the drawer draws the same layout. Its heading is the entry's + * declared title, else the time-of-day greeting; the entry's suggestions send. + * * The page is the one ask conversation on its screen: while it is the active * route the console's drawer stays closed and its triggers are hidden or inert * (`useConsoleChatDock`'s `askPageActive`). A build hand-off from here still @@ -34,10 +39,10 @@ import * as React from 'react'; import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; -import { ArrowUp, MessageSquare, Plus, Sparkles } from 'lucide-react'; +import { ArrowUp, Plus, Sparkles } from 'lucide-react'; import { useAuth } from '@object-ui/auth'; -import { Badge, Button, Textarea, cn } from '@object-ui/components'; -import { useDisplayLocale, useObjectTranslation } from '@object-ui/i18n'; +import { Badge, Button, Textarea } from '@object-ui/components'; +import { useObjectTranslation } from '@object-ui/i18n'; import { resolveNavItemLabel } from '@object-ui/layout'; import type { NavigationItem } from '@object-ui/types'; import { resolveAgentParam, useAgents } from '@object-ui/plugin-chatbot/core'; @@ -58,7 +63,8 @@ import { useChatConversation, type HydratedUIMessage } from '../../hooks/useChat import { fetchConversation } from '../../hooks/useChatConversation.js'; import { useAiSurfaceEnabled } from '../../hooks/useAiSurface.js'; import { useConversationList } from '../../hooks/useConversationList.js'; -import { timeAgo } from '../../utils/relativeTime.js'; +import { EmptyConversation, EmptyConversationGreeting, RecentConversationList } from './EmptyConversation.js'; +import { appHomeSuggestions } from './emptyConversationModel.js'; import { useHomePath } from '../../hooks/useHomePath.js'; import { useMetadata } from '../../providers/MetadataProvider.js'; import { useNavigationContext } from '../../context/NavigationContext.js'; @@ -90,6 +96,8 @@ export function AppAskPage() { const entry = React.useMemo(() => findAiChatNavEntry(app), [app]); const copy = React.useMemo(() => readAiChatPageCopy(entry), [entry]); const pageLabel = entry ? resolveNavItemLabel(entry as unknown as NavigationItem, t, undefined, language) : ''; + // The page header's name when the entry has no label: the declared title, + // else the neutral one. The home state's heading greets instead (below). const title = copy.title ?? t('console.ai.empty.ask.title', { defaultValue: 'Ask your data' }); const subtitle = copy.subtitle ?? t('console.ai.empty.ask.description', { defaultValue: @@ -272,7 +280,7 @@ export function AppAskPage() { } else { body = ( } subtitle={subtitle} placeholder={placeholder} suggestions={copy.suggestions} @@ -311,7 +319,7 @@ export function AppAskPage() { function noop() {} interface AskHomeProps { - title: string; + heading: React.ReactNode; subtitle: string; placeholder: string; suggestions: string[]; @@ -322,77 +330,65 @@ interface AskHomeProps { recent?: React.ReactNode; } -/** The home state: the welcome, the large question box and the suggested questions. */ -function AskHome({ title, subtitle, placeholder, suggestions, scopeLabel, sendLabel, onAsk, recent }: AskHomeProps) { +/** + * The home state: the shared empty conversation, large, with this page's + * question box in its composer slot. The entry's suggestions send. + */ +function AskHome({ heading, subtitle, placeholder, suggestions, scopeLabel, sendLabel, onAsk, recent }: AskHomeProps) { const [text, setText] = React.useState(''); const submit = () => { if (text.trim()) onAsk(text); }; + const homeSuggestions = React.useMemo(() => appHomeSuggestions(suggestions), [suggestions]); return ( -
-
-
-

- {title} -

-

- {subtitle} -

-
-
{ - event.preventDefault(); - submit(); - }} - > -