feat: improve project agent onboarding

This commit is contained in:
2026-09-06 13:54:20 +08:00
parent a4fc3a5251
commit df02680f9d
15 changed files with 826 additions and 74 deletions

View File

@@ -41,7 +41,12 @@ import { CodingConversationSidebar } from './CodingConversationSidebar';
import { CodingConversationHeader } from './CodingConversationHeader';
import { CodingConversationTimeline } from './CodingConversationTimeline';
import { CodingInteractionPanel } from './CodingInteractionPanel';
import { CodingProjectSetupEmptyState } from './CodingProjectSetupEmptyState';
import { createLocalConversationSnapshot } from './coding-chat-snapshot';
import {
isCodingProjectAgentReady,
isCodingProjectConversationReady,
} from '../../../shared/coding-project-contracts';
export interface CodingChatPanelProps {
navigationDraft?: string;
@@ -158,8 +163,9 @@ export function CodingChatPanel({
const submissionFlightsRef = useRef(new Set<string>());
const agents = useMemo(() => (
config?.agents.filter((agent) => agent.enabled && !agent.archivedAt) ?? []
config?.agents.filter(isCodingProjectAgentReady) ?? []
), [config]);
const conversationReady = Boolean(config && isCodingProjectConversationReady(config));
const selectedAgent = agents.find((agent) => agent.id === selectedAgentId) ?? null;
const selectedConversation = conversations.find((conversation) => (
conversation.id === selectedConversationId
@@ -615,6 +621,10 @@ export function CodingChatPanel({
);
}
if (activeProject && config && !conversationReady && workspaceLoadState !== 'loading') {
return <CodingProjectSetupEmptyState onOpenProjectSettings={onOpenProjectSettings} />;
}
return (
<section className="flex min-h-0 flex-1 overflow-hidden bg-background text-foreground" data-testid="coding-chat-panel">
<CodingConversationSidebar

View File

@@ -0,0 +1,33 @@
import { Bot, Settings2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
export function CodingProjectSetupEmptyState({
onOpenProjectSettings,
}: {
onOpenProjectSettings?(): void;
}) {
return (
<section
className="flex min-h-0 flex-1 items-center justify-center bg-background p-6"
data-testid="coding-chat-agent-setup-empty-state"
>
<div className="surface-card max-w-md rounded-2xl bg-background p-8 text-center shadow-float">
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-brand-soft text-brand shadow-[0_0_0_1px_rgba(0,0,0,0.06)]">
<Bot className="h-5 w-5" aria-hidden="true" />
</div>
<h1 className="mt-4 text-balance text-xl font-semibold">创建项目智能体后开始对话</h1>
<p className="mt-2 text-pretty text-sm leading-6 text-muted-foreground">
当前项目还没有可用的项目智能体。完成名称、模型和职责设置后,就可以发送消息。
</p>
<Button
type="button"
className="mt-5 min-h-10 rounded-xl px-4 transition-transform duration-150 ease-out active:scale-[0.96]"
onClick={onOpenProjectSettings}
>
<Settings2 className="mr-2 h-4 w-4" aria-hidden="true" />
创建或恢复项目智能体
</Button>
</div>
</section>
);
}