-
+ {/* In the hero layout the banner hangs below the composer without
+ contributing height, so connect/reconnect churn cannot
+ re-center the headline and composer. */}
+ {isDraftHeroState ? null : (
+
+ )}
- {isGitRepo && (
-
-
+
+ {isGitRepo && (
+
+
+
+ )}
+
+ {isDraftHeroState ? (
+
- )}
+ ) : null}
diff --git a/apps/web/src/components/chat/DraftHeroHeadline.tsx b/apps/web/src/components/chat/DraftHeroHeadline.tsx
new file mode 100644
index 0000000000..a30dcb9f1f
--- /dev/null
+++ b/apps/web/src/components/chat/DraftHeroHeadline.tsx
@@ -0,0 +1,88 @@
+import type { ScopedProjectRef } from "@t3tools/contracts";
+import { scopedProjectKey, scopeProjectRef } from "@t3tools/client-runtime/environment";
+import { ChevronDownIcon } from "lucide-react";
+import { useMemo } from "react";
+
+import { useNewThreadHandler } from "~/hooks/useHandleNewThread";
+import { useProjects, useThreadShells } from "~/state/entities";
+import { sortProjectsForSidebar } from "../Sidebar.logic";
+import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "../ui/menu";
+
+interface DraftHeroHeadlineProps {
+ readonly activeProjectRef: ScopedProjectRef | null;
+ readonly activeProjectTitle: string | null;
+}
+
+export function DraftHeroHeadline({
+ activeProjectRef,
+ activeProjectTitle,
+}: DraftHeroHeadlineProps) {
+ const projects = useProjects();
+ const threads = useThreadShells();
+ const handleNewThread = useNewThreadHandler();
+
+ const orderedProjects = useMemo(
+ () => sortProjectsForSidebar(projects, threads, "updated_at"),
+ [projects, threads],
+ );
+ const projectByKey = useMemo(
+ () =>
+ new Map(
+ orderedProjects.map(
+ (project) =>
+ [
+ scopedProjectKey(scopeProjectRef(project.environmentId, project.id)),
+ project,
+ ] as const,
+ ),
+ ),
+ [orderedProjects],
+ );
+ const activeProjectKey = activeProjectRef === null ? "" : scopedProjectKey(activeProjectRef);
+
+ const projectLabel = activeProjectTitle ?? "this project";
+ return (
+
+ What should we do in{" "}
+ {orderedProjects.length > 1 ? (
+
+ ) : (
+ {projectLabel}
+ )}
+ ?
+
+ );
+}
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 61d7855844..d67dd286fa 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -179,6 +179,7 @@ interface MessagesTimelineProps {
contentInsetEndAdjustment: number;
onIsAtEndChange: (isAtEnd: boolean) => void;
onManualNavigation: () => void;
+ hideEmptyPlaceholder?: boolean;
}
// ---------------------------------------------------------------------------
@@ -212,6 +213,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
contentInsetEndAdjustment,
onIsAtEndChange,
onManualNavigation,
+ hideEmptyPlaceholder = false,
}: MessagesTimelineProps) {
const [expandedTurnIds, setExpandedTurnIds] = useState
>(new Set());
const [expandedWorkGroupIds, setExpandedWorkGroupIds] = useState>(new Set());
@@ -458,6 +460,9 @@ export const MessagesTimeline = memo(function MessagesTimeline({
);
if (rows.length === 0 && !isWorking) {
+ if (hideEmptyPlaceholder) {
+ return null;
+ }
return (
diff --git a/apps/web/src/hooks/useHandleNewThread.ts b/apps/web/src/hooks/useHandleNewThread.ts
index 1b1c07b31c..232551349d 100644
--- a/apps/web/src/hooks/useHandleNewThread.ts
+++ b/apps/web/src/hooks/useHandleNewThread.ts
@@ -47,6 +47,7 @@ export function useNewThreadHandler() {
worktreePath?: string | null;
envMode?: DraftThreadEnvMode;
startFromOrigin?: boolean;
+ replace?: boolean;
},
): Promise => {
const {
@@ -120,6 +121,7 @@ export function useNewThreadHandler() {
await router.navigate({
to: "/draft/$draftId",
params: { draftId: reusableStoredDraftThread.draftId },
+ replace: options?.replace ?? false,
});
})();
}
@@ -180,6 +182,7 @@ export function useNewThreadHandler() {
await router.navigate({
to: "/draft/$draftId",
params: { draftId },
+ replace: options?.replace ?? false,
});
})();
},
diff --git a/apps/web/src/routes/_chat.index.tsx b/apps/web/src/routes/_chat.index.tsx
index 94d49d00af..9e88f9379e 100644
--- a/apps/web/src/routes/_chat.index.tsx
+++ b/apps/web/src/routes/_chat.index.tsx
@@ -1,10 +1,16 @@
+import { scopeProjectRef } from "@t3tools/client-runtime/environment";
import { createFileRoute, Link } from "@tanstack/react-router";
import { LinkIcon, PlusIcon } from "lucide-react";
+import { useEffect, useMemo, useRef } from "react";
+import { useOpenAddProjectCommandPalette } from "../commandPaletteContext";
import { NoActiveThreadState } from "../components/NoActiveThreadState";
+import { sortProjectsForSidebar } from "../components/Sidebar.logic";
import { Button } from "../components/ui/button";
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../components/ui/empty";
import { SidebarInset } from "../components/ui/sidebar";
+import { useNewThreadHandler } from "../hooks/useHandleNewThread";
+import { useProjects, useThreadShells } from "../state/entities";
import { useEnvironments } from "../state/environments";
import { APP_DISPLAY_NAME } from "~/branding";
import { hasCloudPublicConfig } from "~/cloud/publicConfig";
@@ -19,9 +25,70 @@ function ChatIndexRouteView() {
return ;
}
+ return ;
+}
+
+/**
+ * Landing on the index route drops straight into a draft thread for the most
+ * recently active project, so the first screen is a prompt instead of a dead
+ * end. Falls back to an add-project hero when no project exists yet.
+ */
+function IndexDraftLanding() {
+ const projects = useProjects();
+ const threads = useThreadShells();
+ const handleNewThread = useNewThreadHandler();
+ const startedRef = useRef(false);
+
+ const mostRecentProject = useMemo(
+ () => sortProjectsForSidebar(projects, threads, "updated_at")[0] ?? null,
+ [projects, threads],
+ );
+
+ useEffect(() => {
+ if (mostRecentProject === null || startedRef.current) {
+ return;
+ }
+ startedRef.current = true;
+ void handleNewThread(scopeProjectRef(mostRecentProject.environmentId, mostRecentProject.id), {
+ replace: true,
+ });
+ }, [handleNewThread, mostRecentProject]);
+
+ if (mostRecentProject === null) {
+ return ;
+ }
return ;
}
+function NoProjectsHero() {
+ const openAddProject = useOpenAddProjectCommandPalette();
+
+ return (
+
+
+
+
+
+
+ What should we work on?
+
+
+ Add a project to start your first thread.
+
+
+
+
+
+
+
+ );
+}
+
export const Route = createFileRoute("/_chat/")({
component: ChatIndexRouteView,
});