removed home status, adjust style, reset draft on submitted chat, give error echo back
This commit is contained in:
@@ -2434,6 +2434,7 @@ export function WorkspaceLauncher({
|
||||
recentRunStopReason: null,
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
resetLauncherHomeDraft();
|
||||
return '已创建项目并进入项目开发';
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
@@ -2551,17 +2552,21 @@ export function WorkspaceLauncher({
|
||||
}
|
||||
const pendingProject = pendingNonEmptyProject;
|
||||
setPendingNonEmptyProject(null);
|
||||
if (pendingProject.kind === 'home-create') {
|
||||
await createHomeProjectFromDirectory(
|
||||
pendingProject.projectPath,
|
||||
pendingProject.mode,
|
||||
pendingProject.prompt,
|
||||
pendingProject.attachments,
|
||||
true,
|
||||
);
|
||||
return;
|
||||
try {
|
||||
if (pendingProject.kind === 'home-create') {
|
||||
await createHomeProjectFromDirectory(
|
||||
pendingProject.projectPath,
|
||||
pendingProject.mode,
|
||||
pendingProject.prompt,
|
||||
pendingProject.attachments,
|
||||
true,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await createProjectFromProjectPage(pendingProject.projectPath, true);
|
||||
} catch (error) {
|
||||
setStatus(error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
await createProjectFromProjectPage(pendingProject.projectPath, true);
|
||||
}
|
||||
|
||||
function cancelCreateInNonEmptyFolder() {
|
||||
@@ -3294,6 +3299,8 @@ export function WorkspaceLauncher({
|
||||
{launcherView === 'home' ? (
|
||||
<HomeView
|
||||
hasPromo={launcherNotifications.length > 0}
|
||||
status={status}
|
||||
onStatusChange={setStatus}
|
||||
homeAgentModeItems={homeAgentModeItems}
|
||||
recentProjectRows={recentProjectRows}
|
||||
onCreateDraft={createHomeDraft}
|
||||
|
||||
@@ -52,6 +52,8 @@ export type HomeShowcaseResource = {
|
||||
|
||||
type HomeViewProps = {
|
||||
hasPromo: boolean;
|
||||
status: string;
|
||||
onStatusChange: (status: string) => void;
|
||||
homeAgentModeItems: readonly HomeAgentModeItem[];
|
||||
recentProjectRows: readonly HomeProjectRow[];
|
||||
onCreateDraft: (draft: HomeDraft) => Promise<string>;
|
||||
@@ -61,6 +63,8 @@ type HomeViewProps = {
|
||||
|
||||
export default function HomeView({
|
||||
hasPromo,
|
||||
status,
|
||||
onStatusChange,
|
||||
homeAgentModeItems,
|
||||
recentProjectRows,
|
||||
onCreateDraft,
|
||||
@@ -81,7 +85,6 @@ export default function HomeView({
|
||||
(state) => state.removeAttachment,
|
||||
);
|
||||
const [homeCreationBusy, setHomeCreationBusy] = useState(false);
|
||||
const [homeStatus, setHomeStatus] = useState('请选择创作模式');
|
||||
const { resources: showcaseResources, status: showcaseStatus } =
|
||||
useHomeShowcase();
|
||||
const homeAttachmentInputRef = useRef<HTMLInputElement | null>(null);
|
||||
@@ -114,16 +117,16 @@ export default function HomeView({
|
||||
async function handleHomeSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
if (!homePrompt.trim() && homeAttachments.length === 0) {
|
||||
setHomeStatus(
|
||||
onStatusChange(
|
||||
homeAgentModeItems.find((item) => item.mode === homeAgentMode)
|
||||
?.emptyPrompt ?? '请输入需求或上传附件',
|
||||
);
|
||||
return;
|
||||
}
|
||||
setHomeCreationBusy(true);
|
||||
setHomeStatus('请选择项目目录');
|
||||
onStatusChange('请选择项目目录');
|
||||
try {
|
||||
setHomeStatus(
|
||||
onStatusChange(
|
||||
await onCreateDraft({
|
||||
mode: homeAgentMode,
|
||||
prompt: homePrompt,
|
||||
@@ -131,7 +134,7 @@ export default function HomeView({
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
setHomeStatus(error instanceof Error ? error.message : String(error));
|
||||
onStatusChange(error instanceof Error ? error.message : String(error));
|
||||
} finally {
|
||||
setHomeCreationBusy(false);
|
||||
}
|
||||
@@ -140,17 +143,17 @@ export default function HomeView({
|
||||
return (
|
||||
<>
|
||||
<section
|
||||
className={`grid min-h-93.5 content-start justify-items-center gap-3.25 px-6 pb-4.5 pt-25.75 max-[720px]:min-h-0 max-[720px]:gap-4 max-[720px]:px-3.5 max-[720px]:pb-[34px] max-[720px]:pt-[84px] ${
|
||||
hasPromo ? 'pt-33.75 max-[720px]:pt-21' : ''
|
||||
className={`grid min-h-93.5 content-start justify-items-center gap-3.25 px-6 pb-4.5 pt-25.75 max-[760px]:min-h-0 max-[760px]:gap-4 max-[760px]:px-3.5 max-[760px]:pb-[34px] max-[760px]:pt-[84px] ${
|
||||
hasPromo ? 'pt-33.75 max-[760px]:pt-21' : ''
|
||||
}`}
|
||||
aria-label="首页输入"
|
||||
>
|
||||
<div className="flex items-center gap-3 text-center max-[720px]:flex-col max-[720px]:gap-2.5">
|
||||
<div className="flex items-center gap-3 text-center max-[760px]:flex-col max-[760px]:gap-2.5">
|
||||
<span className="grid size-7.5 shrink-0 place-items-center rounded-full bg-[#060606] text-[11px] font-bold text-white">
|
||||
<ActiveHomeModeIcon size={18} aria-hidden="true" />
|
||||
</span>
|
||||
<div>
|
||||
<h1 className="m-0 text-[27px] font-[750] tracking-normal max-[720px]:text-[22px]">
|
||||
<h1 className="m-0 text-[27px] font-[750] tracking-normal max-[760px]:text-[22px]">
|
||||
陶泥儿 GameAgent
|
||||
</h1>
|
||||
<p className="m-0 mt-3 text-[13px] text-[#a0a0a0]">
|
||||
@@ -159,7 +162,7 @@ export default function HomeView({
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="flex w-[min(488px,calc(100vw-110px))] flex-wrap justify-center gap-[9px] max-[720px]:w-[min(100%,calc(100vw-76px))]"
|
||||
className="flex w-[min(488px,calc(100vw-110px))] flex-wrap justify-center gap-[9px] max-[760px]:w-[min(100%,calc(100vw-76px))]"
|
||||
aria-label="Agent 分类"
|
||||
>
|
||||
{homeAgentModeItems.map((item) => {
|
||||
@@ -183,7 +186,7 @@ export default function HomeView({
|
||||
})}
|
||||
</div>
|
||||
<form
|
||||
className="grid min-h-20 w-[min(488px,calc(100vw-110px))] grid-rows-[minmax(42px,auto)_auto_auto] rounded-[18px] border border-[#e1e4e8] bg-white px-3 pb-2 pt-[13px] shadow-[0_8px_24px_rgb(15_23_42_/_8%)] max-[720px]:w-[min(100%,calc(100vw-76px))]"
|
||||
className="grid min-h-20 w-[min(488px,calc(100vw-110px))] grid-rows-[minmax(42px,auto)_auto_auto] rounded-[18px] border border-[#e1e4e8] bg-white px-3 pb-2 pt-[13px] shadow-[0_8px_24px_rgb(15_23_42_/_8%)] max-[760px]:w-[min(100%,calc(100vw-76px))]"
|
||||
onSubmit={handleHomeSubmit}
|
||||
>
|
||||
<textarea
|
||||
@@ -216,7 +219,7 @@ export default function HomeView({
|
||||
<div className="grid grid-cols-[auto_1fr_auto] items-center gap-2.5 text-[12px] text-[#777]">
|
||||
<input
|
||||
ref={homeAttachmentInputRef}
|
||||
className="pointer-events-none absolute size-px opacity-0"
|
||||
className="launcher-file-input pointer-events-none absolute size-px opacity-0"
|
||||
type="file"
|
||||
multiple
|
||||
onChange={handleHomeAttachmentSelection}
|
||||
@@ -229,7 +232,7 @@ export default function HomeView({
|
||||
>
|
||||
<Upload size={15} aria-hidden="true" />
|
||||
</button>
|
||||
<span>{homeStatus}</span>
|
||||
<span>{status}</span>
|
||||
<button
|
||||
className="grid size-6 cursor-pointer place-items-center rounded-full border-0 bg-[#f1f1f1] p-0 text-[#9a9a9a] disabled:cursor-not-allowed disabled:opacity-55"
|
||||
type="submit"
|
||||
@@ -243,14 +246,14 @@ export default function HomeView({
|
||||
</section>
|
||||
|
||||
<section
|
||||
className="mx-auto grid w-[min(1054px,calc(100vw-122px))] gap-[14px] max-[720px]:w-[min(100%,calc(100vw-76px))]"
|
||||
className="mx-auto grid w-[min(1054px,calc(100vw-122px))] gap-[14px] max-[760px]:w-[min(100%,calc(100vw-76px))]"
|
||||
aria-label="最近项目"
|
||||
>
|
||||
<header className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="m-0 text-[15px] text-gray-900">最近项目</h2>
|
||||
<p className="mb-0 mt-1 text-[12px] text-[#8b8b8b]">
|
||||
{homeStatus}
|
||||
{status}
|
||||
</p>
|
||||
</div>
|
||||
<div className="launcher-project-list-actions">
|
||||
@@ -264,11 +267,11 @@ export default function HomeView({
|
||||
</div>
|
||||
</header>
|
||||
{recentProjectRows.length > 0 ? (
|
||||
<div className="grid grid-cols-5 gap-3 overflow-hidden max-[720px]:grid-cols-1 max-[720px]:overflow-visible">
|
||||
<div className="grid grid-cols-5 gap-3 overflow-hidden max-[760px]:grid-cols-1 max-[760px]:overflow-visible">
|
||||
{recentProjectRows.map((project) => (
|
||||
<article className="grid min-w-0" key={project.path}>
|
||||
<button
|
||||
className="grid h-[116px] w-full cursor-pointer content-start justify-items-start gap-1.5 overflow-hidden rounded-lg border border-[#e1e4e8] bg-[#f7f7f7] p-3 text-left disabled:cursor-not-allowed disabled:opacity-[0.58] max-[720px]:h-[132px]"
|
||||
className="grid h-[116px] w-full cursor-pointer content-start justify-items-start gap-1.5 overflow-hidden rounded-lg border border-[#e1e4e8] bg-[#f7f7f7] p-3 text-left disabled:cursor-not-allowed disabled:opacity-[0.58] max-[760px]:h-[132px]"
|
||||
type="button"
|
||||
disabled={!project.canOpen}
|
||||
onClick={() => onProjectOpen(project.path)}
|
||||
@@ -305,7 +308,7 @@ export default function HomeView({
|
||||
</section>
|
||||
|
||||
<section
|
||||
className="mx-auto mt-[22px] grid w-[min(1054px,calc(100vw-122px))] gap-[14px] max-[720px]:w-[min(100%,calc(100vw-76px))]"
|
||||
className="mx-auto mt-[22px] grid w-[min(1054px,calc(100vw-122px))] gap-[14px] max-[760px]:w-[min(100%,calc(100vw-76px))]"
|
||||
aria-label="灵感推荐"
|
||||
>
|
||||
<header className="flex items-center justify-start gap-3">
|
||||
@@ -318,7 +321,7 @@ export default function HomeView({
|
||||
</div>
|
||||
</header>
|
||||
{showcaseResources.length > 0 ? (
|
||||
<div className="grid grid-cols-6 gap-3 max-[720px]:grid-cols-1">
|
||||
<div className="grid grid-cols-6 gap-3 max-[760px]:grid-cols-1">
|
||||
{showcaseResources.map((resource) => (
|
||||
<article
|
||||
className="grid gap-[7px] overflow-hidden rounded-lg border border-gray-200 bg-white pb-2.5"
|
||||
|
||||
Reference in New Issue
Block a user