Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Chat is the front door: a Make tab, the "+" menu, and /assist opens Chat

Adarsh9b98373841ed
diff --git a/next.config.ts b/next.config.ts
index 7d66c246..79f8d493 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -65,6 +65,14 @@ const nextConfig: NextConfig = {
{ source: "/settings/about", destination: "/settings", permanent: true },
// The product-link ad apps open the Click to Ad flow (src/lib/catalog/apps.ts).
{ source: "/apps/:id(app-click-to-ad|app-link-to-video-ad)", destination: "/marketing/click-to-ad", permanent: false },
+ // Chat is the one place to talk to Fuobe: a bare /assist opens it. A link to an Assist chat (?c=), a skill
+ // (?skill=), a ready-made starter (?starter=) or a request to plan (?prompt=) still opens Assist, where it runs.
+ {
+ source: "/assist",
+ missing: ["c", "skill", "starter", "prompt"].map((key) => ({ type: "query" as const, key })),
+ destination: "/chat",
+ permanent: false,
+ },
// The Virality Predictor app became the /virality page (its frame step is the Hook Frame app).
{ source: "/apps/app-virality-predictor", destination: "/virality", permanent: true },
// Studio hubs have one path per mode (src/lib/hubs.ts). Old `?mode=` links go to it in src/proxy.ts (hubModeLink),
diff --git a/src/components/chat/chat-home.tsx b/src/components/chat/chat-home.tsx
index 592deada..c1d18670 100644
--- a/src/components/chat/chat-home.tsx
+++ b/src/components/chat/chat-home.tsx
@@ -1,7 +1,7 @@
"use client";
import { useQueryClient } from "@tanstack/react-query";
-import { Pencil, Plus, Settings2 } from "lucide-react";
+import { Pencil, Plus, Settings2, Sparkles } from "lucide-react";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect, useMemo, useRef, useState } from "react";
@@ -16,12 +16,15 @@ import { playMessage, toolMessage } from "@/lib/chat/prompt";
import type { ChatThreadSummary } from "@/lib/chat/types";
import { toastError } from "@/lib/refusals";
import { cn } from "@/lib/utils";
+import { useChats } from "@/components/assist/hooks";
+import type { AssistThreadSummary } from "@/lib/assist";
import { CharacterBuilder } from "./character-builder";
import { CharacterFace } from "./character-face";
import { ChatComposer } from "./composer";
import { ChatSettingsDialog, ChilliDot, CHILLI_BG, MangoChilliDialog, PlayDialog, WriteToolDialog } from "./dialogs";
import { chatSend, useCharacters, useChatMe, useChatThreads, useStartChat } from "./hooks";
import { EngineLine, KindIcon, timeAgo } from "./bits";
+import { MakeBox, MoreMenu } from "./make";
/**
* Fuobe Chat's home: one box to start talking, the kinds of chat (Chat, Ideas, Write, Characters, Play), the
@@ -41,6 +44,8 @@ export function ChatHome() {
const me = useChatMe(signedIn);
const threads = useChatThreads(signedIn);
const characters = useCharacters(signedIn);
+ // The owner's Assist chats sit in Recent too, until they open in Chat itself (an account's list comes back empty).
+ const assistChats = useChats();
const start = useStartChat();
// A link can open a kind, a writing tool or a game with its form (?kind=, ?tool=, ?play=).
@@ -57,6 +62,7 @@ export function ChatHome() {
const [settings, setSettings] = useState(false);
const [chilli, setChilli] = useState(false);
const [starting, setStarting] = useState(false);
+ const [making, setMaking] = useState(() => sp.get("make") === "1");
const mature = !!me.data?.mature;
const gate = () => {
@@ -140,6 +146,7 @@ export function ChatHome() {
</Button>
</>
)}
+ <MoreMenu />
<PhoneNavButton />
</header>
@@ -151,14 +158,37 @@ export function ChatHome() {
</p>
<TabRow role="tablist" aria-label="Kind of chat" className="mt-8 w-fit max-w-full">
- {CHAT_KINDS.map((x) => (
- <button key={x.id} role="tab" aria-selected={x.id === kind} className={TAB_PILL} {...onAttr(x.id === kind)} onClick={() => setKind(x.id)}>
- {x.label}
- </button>
- ))}
+ {CHAT_KINDS.flatMap((x) => {
+ const tab = (
+ <button
+ key={x.id}
+ role="tab"
+ aria-selected={!making && x.id === kind}
+ className={TAB_PILL}
+ {...onAttr(!making && x.id === kind)}
+ onClick={() => {
+ setMaking(false);
+ setKind(x.id);
+ }}
+ >
+ {x.label}
+ </button>
+ );
+ // Make sits beside Ideas: from talking about it to making it.
+ return x.id !== "ideas"
+ ? [tab]
+ : [
+ tab,
+ <button key="make" role="tab" aria-selected={making} className={TAB_PILL} {...onAttr(making)} onClick={() => setMaking(true)}>
+ Make
+ </button>,
+ ];
+ })}
</TabRow>
- {typing && (
+ {making && <MakeBox owner={!!me.data?.owner} guest={known && guest} />}
+
+ {!making && typing && (
<div className="mt-4">
<ChatComposer
key={kind}
@@ -174,7 +204,7 @@ export function ChatHome() {
</div>
)}
- <section className="mt-6">
+ <section className={cn("mt-6", making && "hidden")}>
{kind === "chat" || kind === "ideas" ? (
<div className="grid gap-x-6 sm:grid-cols-2">
{STARTERS[kind].map((s) => (
@@ -231,7 +261,7 @@ export function ChatHome() {
) : null}
</section>
- {(kind === "character" || kind === "chat") && (
+ {!making && (kind === "character" || kind === "chat") && (
<section className="mt-12">
<div className="mb-4 flex items-end justify-between gap-3">
<h2 className="font-heading text-[28px] leading-none">Characters</h2>
@@ -251,7 +281,7 @@ export function ChatHome() {
</section>
)}
- {signedIn && <Recent threads={threads.data?.items} loading={threads.isPending} />}
+ {signedIn && <Recent threads={threads.data?.items} assist={me.data?.owner ? assistChats.data?.threads : undefined} loading={threads.isPending} />}
</div>
</div>
@@ -339,10 +369,30 @@ function CharacterShelf({
);
}
-function Recent({ threads, loading }: { threads: ChatThreadSummary[] | undefined; loading: boolean }) {
+type RecentRow = ChatThreadSummary & { href: string; making?: boolean };
+
+function Recent({ threads, assist, loading }: { threads: ChatThreadSummary[] | undefined; assist?: AssistThreadSummary[]; loading: boolean }) {
const [all, setAll] = useState(false);
- if (!loading && !threads?.length) return null;
- const more = (threads?.length ?? 0) - 12;
+ // Chats and (the owner's) making chats in one list, newest first.
+ const rows: RecentRow[] = [
+ ...(threads ?? []).map((t) => ({ ...t, href: `/chat/${t.id}` })),
+ ...(assist ?? []).map((a) => ({
+ id: a.id,
+ kind: "ideas" as const,
+ title: a.title,
+ characterId: null,
+ character: null,
+ tool: null,
+ play: null,
+ mature: false,
+ preview: "Plans and makes",
+ updatedAt: a.updatedAt,
+ href: `/assist?c=${a.id}`,
+ making: true,
+ })),
+ ].sort((x, y) => y.updatedAt - x.updatedAt);
+ if (!loading && !rows.length) return null;
+ const more = rows.length - 12;
return (
<section className="mt-12">
<h2 className="mb-2 font-heading text-[28px] leading-none">Recent</h2>
@@ -353,14 +403,14 @@ function Recent({ threads, loading }: { threads: ChatThreadSummary[] | undefined
<Skeleton className="h-10 w-full" />
</li>
))
- : threads!.slice(0, all ? undefined : 12).map((t) => (
+ : rows.slice(0, all ? undefined : 12).map((t) => (
<li key={t.id}>
- <Link href={`/chat/${t.id}`} className="group flex items-center gap-3 py-3">
+ <Link href={t.href} className="group flex items-center gap-3 py-3">
{t.character ? (
<CharacterFace name={t.character.name} accent={t.character.accent} portrait={t.character.portrait} className="size-10" />
) : (
<span className="grid size-10 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground">
- <KindIcon kind={t.kind} />
+ {t.making ? <Sparkles className="size-[18px]" /> : <KindIcon kind={t.kind} />}
</span>
)}
<span className="min-w-0 flex-1">
diff --git a/src/components/chat/make.tsx b/src/components/chat/make.tsx
new file mode 100644
index 00000000..b00810ff
--- /dev/null
+++ b/src/components/chat/make.tsx
@@ -0,0 +1,135 @@
+"use client";
+
+import { BookOpen, Brain, CalendarClock, Clapperboard, ImageIcon, Music4, Plus } from "lucide-react";
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
+import { askToSignUp, useAssistActions, useEngine } from "@/lib/api";
+import { ASSIST_SUGGESTIONS } from "@/lib/assist";
+import { makeItHref, type MakeStudio } from "@/lib/chat/prompt";
+import { toastError } from "@/lib/refusals";
+import { cn } from "@/lib/utils";
+import { ChatComposer } from "./composer";
+
+const STUDIOS: { id: MakeStudio; label: string; icon: typeof ImageIcon }[] = [
+ { id: "image", label: "Image", icon: ImageIcon },
+ { id: "video", label: "Video", icon: Clapperboard },
+ { id: "music", label: "Music", icon: Music4 },
+];
+
+/**
+ * Chat's Make tab: say what to make. The owner's request is planned and run step by step (an Assist chat, with each
+ * plan to approve first); anyone else's opens the studio they pick with the words filled in.
+ */
+export function MakeBox({ owner, guest }: { owner: boolean; guest: boolean }) {
+ const router = useRouter();
+ const actions = useAssistActions();
+ const [engine] = useEngine();
+ const [studio, setStudio] = useState<MakeStudio>("image");
+ const [busy, setBusy] = useState(false);
+
+ const make = async (text: string) => {
+ if (!text.trim()) return;
+ if (!owner) {
+ if (guest) return askToSignUp("run");
+ router.push(makeItHref({ studio, prompt: text }));
+ return;
+ }
+ setBusy(true);
+ try {
+ const t = await actions.start({ text, engine, autoApprove: false });
+ if ((t as { note?: string }).note) toast((t as { note?: string }).note);
+ router.push(`/assist?c=${t.id}`);
+ } catch (e) {
+ toastError(e);
+ setBusy(false);
+ }
+ };
+
+ return (
+ <div className="mt-4">
+ <ChatComposer
+ large
+ autoFocus={!guest}
+ pictures={false}
+ busy={busy}
+ disabled={busy}
+ placeholder="Describe what to make: a three-shot watch ad, a product photo, a theme song…"
+ onSend={(text) => make(text)}
+ footer={
+ owner ? (
+ <span className="px-1 text-[12.5px] text-muted-foreground">Shows you the plan, then runs it</span>
+ ) : (
+ <span className="flex items-center gap-1" role="radiogroup" aria-label="Studio">
+ {STUDIOS.map((s) => {
+ const Icon = s.icon;
+ const on = s.id === studio;
+ return (
+ <button
+ key={s.id}
+ type="button"
+ role="radio"
+ aria-checked={on}
+ onClick={() => setStudio(s.id)}
+ className={cn("inline-flex h-8 items-center gap-1.5 rounded-full px-2.5 text-[12.5px] font-medium", on ? "bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}
+ >
+ <Icon className="size-3.5" />
+ {s.label}
+ </button>
+ );
+ })}
+ </span>
+ )
+ }
+ />
+ <div className="mt-6 grid gap-x-6 sm:grid-cols-2">
+ {ASSIST_SUGGESTIONS.map((s) => (
+ <button
+ key={s}
+ type="button"
+ onClick={() => void make(s)}
+ className="group flex items-baseline gap-3 border-b py-3 text-left text-[15px] text-muted-foreground transition-colors hover:text-foreground"
+ >
+ <span className="text-subtle-foreground transition-colors group-hover:text-brand-text" aria-hidden>
+ ✦
+ </span>
+ {s}
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+/** The "+" menu: the tools that keep working across chats (skills, memory, scheduled tasks). */
+export function MoreMenu() {
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon" aria-label="More in Chat">
+ <Plus />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-60">
+ <DropdownMenuItem asChild>
+ <Link href="/assist/skills">
+ <BookOpen /> Skills
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link href="/assist/memory">
+ <Brain /> Memory
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link href="/assist/scheduled">
+ <CalendarClock /> Scheduled tasks
+ </Link>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/src/server/chat/store.ts b/src/server/chat/store.ts
index 07a75441..b54d5bb1 100644
--- a/src/server/chat/store.ts
+++ b/src/server/chat/store.ts
@@ -184,7 +184,13 @@ function summaryOf(who: string, r: ThreadRow, last?: string): ChatThreadSummary
tool: r.tool,
play: r.play,
mature: !!r.mature,
- preview: (last ?? "").replace(/\s+/g, " ").slice(0, 140),
+ // Plain words for the list line: no markdown marks, no "Prompt (image):" labels.
+ preview: (last ?? "")
+ .replace(/^\s*prompt\s*(\([a-z]+\))?\s*:/gim, "")
+ .replace(/[#*_`>]+/g, "")
+ .replace(/\s+/g, " ")
+ .trim()
+ .slice(0, 140),
updatedAt: r.updated_at,
};
}