Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(community): streamline server creation

Gusaea45beb0b24
diff --git a/src/web/src/components/community/create-dialog-shell.tsx b/src/web/src/components/community/create-dialog-shell.tsx
index 3a795daf2..6b1b41404 100644
--- a/src/web/src/components/community/create-dialog-shell.tsx
+++ b/src/web/src/components/community/create-dialog-shell.tsx
@@ -11,10 +11,8 @@ import { cn } from "@/lib/utils"
// breadcrumb header, and the floating (borderless) footer. Body + footer
// content are passed in; the shell only owns the frame.
//
-// `title` is usually the quiet breadcrumb ("New channel in DEV"); pass
-// `mutedTitle={false}` for a full-weight heading (create-server's "choose"
-// step). `footerClassName` lets create-server switch to `justify-between`
-// (Back + action) instead of the default right-aligned actions.
+// `title` is usually the quiet breadcrumb ("New channel in DEV"). Callers can
+// opt into a full-weight heading or a different footer alignment when needed.
export function CreateDialogShell({
open = true,
onClose,
@@ -28,7 +26,7 @@ export function CreateDialogShell({
onClose: () => void
title: React.ReactNode
mutedTitle?: boolean
- // Omit for a footerless dialog (e.g. create-server's "choose" step).
+ // Omit for a footerless dialog.
footer?: React.ReactNode
footerClassName?: string
children: React.ReactNode
diff --git a/src/web/src/components/community/create-server-dialog.tsx b/src/web/src/components/community/create-server-dialog.tsx
index 01c7170ee..a7a8a8b33 100644
--- a/src/web/src/components/community/create-server-dialog.tsx
+++ b/src/web/src/components/community/create-server-dialog.tsx
@@ -1,33 +1,98 @@
"use client"
-import { useRef, useState } from "react"
+import { useId, useRef, useState } from "react"
+import { ImagePlus } from "lucide-react"
import { toast } from "sonner"
-import { Plus, ChevronRight, Link2 } from "lucide-react"
-import { CreateDialogShell } from "./create-dialog-shell"
+import { MarbleBackground } from "@/components/avatar"
import { Button } from "@/components/ui/button"
+import { avatarInitial } from "@/lib/community/avatar"
+import { validateIconSourceFile } from "@/lib/community/image-crop"
+import { previewSlug } from "@/lib/community/slug-preview"
import { tid } from "@/lib/community/testids"
-import { SlugHint } from "./slug-hint"
+import { CreateDialogShell } from "./create-dialog-shell"
import { ImageCropDialog } from "./image-crop-dialog"
-import { previewSlug } from "@/lib/community/slug-preview"
-import { validateIconSourceFile } from "@/lib/community/image-crop"
+import { SlugHint } from "./slug-hint"
+
+const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)"
+
+function playNameImpact(
+ input: HTMLInputElement,
+ avatar: HTMLButtonElement | null,
+ direction: 1 | -1,
+ currentAnimations: { dialog: Animation | null; avatar: Animation | null },
+) {
+ if (window.matchMedia(REDUCED_MOTION_QUERY).matches) return currentAnimations
+
+ const dialog = input.closest<HTMLElement>("[role='dialog']")
+ if (!dialog || typeof dialog.animate !== "function") return currentAnimations
+
+ currentAnimations.dialog?.cancel()
+ currentAnimations.avatar?.cancel()
-// Create / join server dialog.
-export function CreateServerDialog({ onClose, onCreateServer, onJoinServer, initialStep = "choose" }: {
+ // A short, low-amplitude hit: enough to make each character feel physical,
+ // while keeping the input caret readable and the dialog anchored in place.
+ // `margin-*` and individual `scale` deliberately avoid clobbering the
+ // translate transform that centers DialogContent.
+ const dialogAnimation = dialog.animate(
+ [
+ { marginLeft: "0px", marginTop: "0px", scale: "1" },
+ { marginLeft: `${direction * 1.75}px`, marginTop: "0.5px", scale: "0.994", offset: 0.24 },
+ { marginLeft: `${direction * -0.8}px`, marginTop: "-0.75px", scale: "1.003", offset: 0.58 },
+ { marginLeft: "0px", marginTop: "0px", scale: "1" },
+ ],
+ { duration: 140, easing: "cubic-bezier(.2,.8,.2,1)" },
+ )
+
+ const avatarAnimation = avatar?.animate(
+ [
+ { scale: "1", rotate: "0deg" },
+ { scale: "0.92", rotate: `${direction * -1.5}deg`, offset: 0.24 },
+ { scale: "1.07", rotate: `${direction * 0.8}deg`, offset: 0.62 },
+ { scale: "1", rotate: "0deg" },
+ ],
+ { duration: 170, easing: "cubic-bezier(.2,.8,.2,1)" },
+ ) ?? null
+
+ return { dialog: dialogAnimation, avatar: avatarAnimation }
+}
+
+// The rail's plus button is an explicit create action. Invite links already
+// own the join journey, so this dialog stays single-purpose and name-first.
+export function CreateServerDialog({ onClose, onCreateServer }: {
onClose: () => void
onCreateServer?: (name: string, icon?: File) => void
- onJoinServer?: (invite: string) => void
- initialStep?: "choose" | "create" | "join"
}) {
- const [step, setStep] = useState<"choose" | "create" | "join">(initialStep)
const [name, setName] = useState("")
- const [invite, setInvite] = useState("")
const [iconFile, setIconFile] = useState<File | null>(null)
const [iconPreview, setIconPreview] = useState<string | null>(null)
const [pendingCropSrc, setPendingCropSrc] = useState<{ src: string; fileName: string } | null>(null)
const fileRef = useRef<HTMLInputElement>(null)
+ const nameRef = useRef<HTMLInputElement>(null)
+ const avatarRef = useRef<HTMLButtonElement>(null)
+ const impactDirectionRef = useRef<1 | -1>(1)
+ const impactAnimationsRef = useRef<{ dialog: Animation | null; avatar: Animation | null }>({ dialog: null, avatar: null })
+ const previewSeed = `new-server-${useId()}`
const namePreview = previewSlug(name)
+ const initial = name.trim() ? avatarInitial(name) : null
const pickIcon = () => fileRef.current?.click()
+ const submit = () => {
+ if (!namePreview.slug) return
+ onCreateServer?.(name.trim(), iconFile ?? undefined)
+ onClose()
+ }
+ const onNameChange = (nextName: string) => {
+ setName(nextName)
+ const input = nameRef.current
+ if (!input || nextName === name) return
+ impactDirectionRef.current = impactDirectionRef.current === 1 ? -1 : 1
+ impactAnimationsRef.current = playNameImpact(
+ input,
+ avatarRef.current,
+ impactDirectionRef.current,
+ impactAnimationsRef.current,
+ )
+ }
const onFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0]
e.target.value = ""
@@ -39,94 +104,74 @@ export function CreateServerDialog({ onClose, onCreateServer, onJoinServer, init
}
setPendingCropSrc({ src: URL.createObjectURL(file), fileName: file.name })
}
+
return (
<>
<CreateDialogShell
onClose={onClose}
- mutedTitle={step !== "choose"}
- title={step === "choose" ? "Create a Server" : step === "create" ? "Customize your server" : "Join a Server"}
- footerClassName="justify-between"
- footer={step === "choose" ? undefined : (
- <>
- <Button variant="ghost" size="sm" onClick={() => setStep("choose")}>Back</Button>
- <Button
- size="sm"
- data-testid={tid.createServerSubmit}
- disabled={step === "create" ? !namePreview.slug : !invite.trim()}
- onClick={() => {
- if (step === "create") onCreateServer?.(name.trim(), iconFile ?? undefined)
- else onJoinServer?.(invite.trim())
- onClose()
- }}
- >
- {step === "create" ? "Create" : "Join Server"}
- </Button>
- </>
+ title="Create a server"
+ footer={(
+ <Button
+ size="sm"
+ data-testid={tid.createServerSubmit}
+ disabled={!namePreview.slug}
+ onClick={submit}
+ >
+ Create server
+ </Button>
)}
>
- <div className="px-5 pb-5">
- {step === "choose" && (
- <div className="space-y-1">
- <p className="mb-3 text-sm text-muted-foreground">Your server is where you and your agents hang out. Make yours and start talking.</p>
- {/* Frameless hover rows — the icon chip carries the accent, no box. */}
- <button onClick={() => setStep("create")} className="flex w-full items-center gap-3 rounded-md p-2 text-left transition-colors hover:bg-accent/40">
- <span className="grid size-10 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground"><Plus className="size-5" /></span>
- <span className="flex-1 text-sm font-medium">Create a server</span>
- <ChevronRight className="size-4 text-muted-foreground" />
- </button>
- <button onClick={() => setStep("join")} className="flex w-full items-center gap-3 rounded-md p-2 text-left transition-colors hover:bg-accent/40">
- <span className="grid size-10 shrink-0 place-items-center rounded-full bg-secondary text-foreground"><Link2 className="size-5" /></span>
- <span className="flex-1 text-sm font-medium">Join with invite</span>
- <ChevronRight className="size-4 text-muted-foreground" />
- </button>
- </div>
- )}
- {step === "create" && (
- <div className="flex flex-col items-center gap-4 pt-2">
- {/* Icon = centered on top, the single upload affordance (the
- dropzone IS the button — no redundant separate upload pill).
- A server's identity is visual, so the icon leads. NOT
- ServerIcon: no server id/marble seed pre-creation. */}
- <input ref={fileRef} type="file" accept="image/png,image/jpeg,image/webp" className="hidden" onChange={onFileChange} />
- <button onClick={pickIcon} className="group grid size-24 shrink-0 place-items-center overflow-hidden rounded-2xl ring-1 ring-border/50 text-muted-foreground transition-colors hover:text-foreground hover:ring-primary/60">
- {iconPreview ? (
- <img src={iconPreview} alt="" className="size-full object-cover" />
- ) : (
- <span className="flex flex-col items-center gap-1">
- <Plus className="size-6" />
- <span className="text-[10px] font-medium">Upload icon</span>
+ <div className="px-5 pb-1">
+ <div className="flex items-center gap-4">
+ <input
+ ref={fileRef}
+ type="file"
+ accept="image/png,image/jpeg,image/webp"
+ className="hidden"
+ onChange={onFileChange}
+ />
+ <button
+ ref={avatarRef}
+ type="button"
+ onClick={pickIcon}
+ aria-label="Upload server icon"
+ className="group relative grid size-16 shrink-0 place-items-center overflow-hidden rounded-xl text-white ring-1 ring-border/40 outline-none transition-[box-shadow,filter] hover:brightness-105 focus-visible:ring-2 focus-visible:ring-ring [text-shadow:0_1px_2px_rgb(0_0_0/0.35)]"
+ >
+ {iconPreview ? (
+ <img src={iconPreview} alt="" className="size-full object-cover" />
+ ) : (
+ <>
+ <MarbleBackground seed={previewSeed} />
+ {initial ? (
+ <span className="relative -translate-x-0.5 font-brand text-[2rem] font-bold leading-none [-webkit-text-stroke:0.5px_currentColor]">
+ {initial}
</span>
+ ) : (
+ <ImagePlus className="relative size-5 opacity-70 drop-shadow-sm" />
)}
- </button>
- {/* Server name below the icon — left-aligned so the cursor sits
- at a consistent left position (a centered input makes the
- caret jump around as you type). */}
- <div className="w-full">
- <input
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="My community"
- autoFocus
- aria-label="Server name"
- className="w-full border-0 bg-transparent p-0 text-[26px] font-medium leading-tight tracking-tight shadow-none outline-none placeholder:font-normal placeholder:text-muted-foreground/40 focus-visible:ring-0"
- />
- <SlugHint {...namePreview} />
- </div>
- </div>
- )}
- {step === "join" && (
- <div className="pt-2">
- <input
- value={invite}
- onChange={(e) => setInvite(e.target.value)}
- placeholder="Paste an invite link or code"
- autoFocus
- aria-label="Invite link"
- className="w-full border-0 bg-transparent p-0 text-lg shadow-none outline-none placeholder:text-muted-foreground/40 focus-visible:ring-0"
- />
- </div>
- )}
+ </>
+ )}
+ <span className="absolute inset-0 grid place-items-center bg-black/20 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100">
+ <ImagePlus className="size-4 drop-shadow-sm" />
+ </span>
+ </button>
+ <div className="min-w-0 flex-1">
+ <input
+ ref={nameRef}
+ value={name}
+ onChange={(e) => onNameChange(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) submit()
+ }}
+ placeholder="My community"
+ autoFocus
+ aria-label="Server name"
+ className="w-full border-0 bg-transparent p-0 text-[26px] font-medium leading-tight tracking-tight shadow-none outline-none placeholder:font-normal placeholder:text-muted-foreground/35 focus-visible:ring-0"
+ />
+ <SlugHint {...namePreview} />
+ </div>
</div>
+ </div>
</CreateDialogShell>
{pendingCropSrc && (
<ImageCropDialog
diff --git a/src/web/src/components/community/server-rail.tsx b/src/web/src/components/community/server-rail.tsx
index 1eebb6697..d02f812dd 100644
--- a/src/web/src/components/community/server-rail.tsx
+++ b/src/web/src/components/community/server-rail.tsx
@@ -24,7 +24,7 @@ import {
export const ServerRail = memo(function ServerRail({
servers, folders, activeServerId: activeServerIdProp, serversLoading, setMobileZone, view, bottomInset,
- onHome, onServer, onServerNavigate, onCreateServer, onJoinServer, onLeaveServer,
+ onHome, onServer, onServerNavigate, onCreateServer, onLeaveServer,
onOpenSettings, onOpenInvitePopover, onUngroupFolder, onReorderRail, onReorderFolders, onFolderItemsChange, onDragCreateFolder,
}: {
servers: Server[]
@@ -38,7 +38,6 @@ export const ServerRail = memo(function ServerRail({
onServer: () => void
onServerNavigate?: (id: string) => void
onCreateServer?: (name: string, icon?: File) => void
- onJoinServer?: (invite: string) => void
onLeaveServer?: (id: string) => void
onOpenSettings?: (serverId: string) => void
onOpenInvitePopover?: (serverId: string) => void
@@ -72,7 +71,6 @@ export const ServerRail = memo(function ServerRail({
useEffect(() => { if (activeFromProps) setActiveId(activeFromProps) }, [activeFromProps])
const [createOpen, setCreateOpen] = useState(false)
- const [guidedCreate, setGuidedCreate] = useState(false)
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }))
const pickServer = (id: string) => { setActiveId(id); onServer(); onServerNavigate?.(id); setMobileZone?.("nav") }
@@ -247,7 +245,6 @@ export const ServerRail = memo(function ServerRail({
onboardingTarget="add-server"
onClick={() => {
const guided = isCommunityOnboardingStage("server")
- setGuidedCreate(guided)
setCreateOpen(true)
if (guided) completeCommunityOnboarding()
}}
@@ -256,9 +253,7 @@ export const ServerRail = memo(function ServerRail({
{createOpen && (
<CreateServerDialog
onClose={() => setCreateOpen(false)}
- initialStep={guidedCreate ? "create" : "choose"}
onCreateServer={(name, icon) => { onCreateServer?.(name, icon) }}
- onJoinServer={(invite) => { onJoinServer?.(invite) }}
/>
)}
</nav>
diff --git a/src/web/src/components/community/shell-frame.tsx b/src/web/src/components/community/shell-frame.tsx
index 55f6dc9b2..2b4087c6c 100644
--- a/src/web/src/components/community/shell-frame.tsx
+++ b/src/web/src/components/community/shell-frame.tsx
@@ -41,7 +41,6 @@ import { useInboxAutoCollapse } from "@/hooks/community/use-inbox-auto-collapse"
import { useCommunityOnboarding } from "@/lib/community-onboarding"
import {
useCreateServer,
- useJoinServer,
useLeaveServer,
useUploadServerIcon,
useDeleteServerFolder,
@@ -142,7 +141,6 @@ export function ShellFrame({
// re-rendering the whole shell (children included) on any shell re-render.
// Mirrors the message-side fix (see page.tsx messageActions deps note).
const { mutateAsync: createServerAsync } = useCreateServer()
- const { mutateAsync: joinServerAsync } = useJoinServer()
const { mutate: leaveServerMutate } = useLeaveServer()
const { mutate: uploadServerIconMutate } = useUploadServerIcon()
const { mutate: deleteFolderMutate } = useDeleteServerFolder()
@@ -209,18 +207,6 @@ export function ShellFrame({
},
[createServerAsync, uploadServerIconMutate, router],
)
- const onRailJoinServer = useCallback(
- async (invite: string) => {
- try {
- const data = await joinServerAsync({ inviteCode: invite })
- toast("Joined server")
- router.push(`/c/channels/${data.serverId}`)
- } catch (e) {
- toastApiError(e, "Failed to join server")
- }
- },
- [joinServerAsync, router],
- )
const onRailLeaveServer = useCallback(
(id: string) => {
// Mark BEFORE mutate — the WS `member.leave` fanout / servers-list
@@ -315,7 +301,6 @@ export function ShellFrame({
onServer: goServer,
onServerNavigate: onRailServerNavigate,
onCreateServer: onRailCreateServer,
- onJoinServer: onRailJoinServer,
onLeaveServer: onRailLeaveServer,
onOpenSettings: onRailOpenSettings,
onOpenInvitePopover: onRailOpenInvitePopover,
diff --git a/src/web/src/test/e2e-ui/_fixtures/actions.ts b/src/web/src/test/e2e-ui/_fixtures/actions.ts
index 95dc3650e..fd098a01e 100644
--- a/src/web/src/test/e2e-ui/_fixtures/actions.ts
+++ b/src/web/src/test/e2e-ui/_fixtures/actions.ts
@@ -19,8 +19,6 @@ import { tid } from "./testids"
export async function createServer(page: Page, name: string, opts?: { autoDialog?: boolean }): Promise<string> {
if (!opts?.autoDialog) {
await page.getByTestId(tid.serverAdd).click()
- // Choose "Create a server" in the choose step.
- await page.getByRole("button", { name: "Create a server" }).click()
}
await page.getByLabel("Server name").fill(name)
await page.getByTestId(tid.createServerSubmit).click()