Web UI on Ant Design, scrollable factory columns, fix empty page after deleting the open chat
Buttons, fields, drop-downs, check boxes, tabs, dialogs and notices are Ant Design components; their tokens come from the theme variables (web/src/ui). Every factory board column has its own vertical scrollbar. ChatView rendered fewer hooks once its chat was deleted. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
90b9ab6670
commit
6b1a1742b2
79 files changed
+2628
-1393
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { Button, Input } from "antd";
|
||||
import { DraftBar, IssueBar, isDraftChat, isIssueChat } from "./FactoryDraft";
|
||||
import { takePrefill } from "../share";
|
||||
import { Icon } from "./Icon";
|
||||
@@ -201,21 +202,21 @@ function ChatSearch({ sessionId, onPick, onClose }: { sessionId: string; onPick:
|
||||
<div className="chat-search" role="search">
|
||||
<div className="row">
|
||||
<Icon name="search" />
|
||||
<input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
|
||||
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
|
||||
<Input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
|
||||
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
{hits && (
|
||||
<div className="chat-search-hits">
|
||||
<div className="hint">{hits.length ? t("chat.searchHits", { n: hits.length }) : t("chat.searchNone")}</div>
|
||||
{hits.map((h) => (
|
||||
<button key={h.id} onClick={() => onPick(h.id)}>
|
||||
<Button key={h.id} onClick={() => onPick(h.id)}>
|
||||
<span className="who">
|
||||
{t(h.role === "assistant" ? "chat.agent" : "chat.you")} · {new Date(h.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
|
||||
</span>
|
||||
<span className="snippet">{h.snippet}</span>
|
||||
</button>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
@@ -535,9 +536,9 @@ function OlderLoader({ sessionId, afterSummary, scrollRef }: { sessionId: string
|
||||
{loading ? (
|
||||
<Spinner small />
|
||||
) : (
|
||||
<button className="small ghost" onClick={() => void load()}>
|
||||
<Button type="text" size="small" onClick={() => void load()}>
|
||||
<Icon name="arrow-up" /> {t(afterSummary ? "chat.showBeforeSummary" : "chat.loadOlder")}
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -719,6 +720,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
return () => ro.disconnect();
|
||||
}, [hasSession, sessionId]);
|
||||
|
||||
// Before the early returns: a chat that is deleted while open must render the same hooks.
|
||||
const [rewinding, setRewinding] = useState<Message>();
|
||||
|
||||
if (loadError) return <div className="empty">{loadError}</div>;
|
||||
if (!session) return <div className="empty">{t("common.loading")}</div>;
|
||||
|
||||
@@ -762,7 +766,6 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
};
|
||||
|
||||
|
||||
const [rewinding, setRewinding] = useState<Message>();
|
||||
const rewind = (m: Message) => setRewinding(m);
|
||||
rewindRef.current = rewind;
|
||||
const rewindDone = async () => {
|
||||
@@ -834,9 +837,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
return (
|
||||
<ChatCtx.Provider value={{ sessionId, canFork: !session.parent_id && !readOnly && !busy, canReply: !readOnly }}>
|
||||
<div className="topbar" data-color={session.color}>
|
||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||
<Icon name="menu" />
|
||||
</button>
|
||||
</Button>
|
||||
<div className="grow">
|
||||
<h1 onDoubleClick={() => !readOnly && setEditingTitle(true)} title={readOnly ? undefined : t("chat.renameHint")}>
|
||||
{session.parent_id && (
|
||||
@@ -847,9 +850,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
{session.icon && <Icon name={session.icon} className="chat-icon" />}
|
||||
{session.title || t("session.untitled")}
|
||||
{!readOnly && (
|
||||
<button className="ghost small title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
|
||||
<Button type="text" size="small" className="title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
|
||||
<Icon name="edit" />
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
</h1>
|
||||
<div className="path">{session.cwd}</div>
|
||||
@@ -886,27 +889,27 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
{!readOnly && (
|
||||
<>
|
||||
{!session.parent_id && (
|
||||
<button className="small ghost hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
|
||||
<Button type="text" size="small" className="hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
|
||||
<Icon name="share" />
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
<button
|
||||
className="small ghost hide-mobile"
|
||||
<Button type="text" size="small"
|
||||
className="hide-mobile"
|
||||
onClick={() => void tabs.openTerminal()}
|
||||
title={t("terminal.here")}
|
||||
>
|
||||
<Icon name="terminal" />
|
||||
</button>
|
||||
<button className={`small ghost ${searching ? "active" : ""}`} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
|
||||
</Button>
|
||||
<Button type="text" size="small" className={searching ? "active" : ""} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
|
||||
<Icon name="search" />
|
||||
</button>
|
||||
<button className="small ghost hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
|
||||
</Button>
|
||||
<Button type="text" size="small" className="hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
|
||||
<Icon name="folder" />
|
||||
</button>
|
||||
</Button>
|
||||
{!session.parent_id && (
|
||||
<button className="small ghost hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
|
||||
<Button type="text" size="small" className="hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
|
||||
<Icon name="fork" />
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
<details className="menu-pop">
|
||||
<summary className="small ghost" title={t("chat.more")} aria-label={t("chat.more")}>
|
||||
@@ -1021,18 +1024,18 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
<button className="small ghost hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
|
||||
<Button type="text" size="small" className="hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
|
||||
<Icon name="compact" />
|
||||
</button>
|
||||
<button className="small ghost danger hide-mobile" onClick={remove} title={t("chat.delete")}>
|
||||
</Button>
|
||||
<Button type="text" danger size="small" className="hide-mobile" onClick={remove} title={t("chat.delete")}>
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{onClosePane && (
|
||||
<button className="small ghost" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
|
||||
<Button type="text" size="small" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{gallery && (
|
||||
@@ -1124,33 +1127,32 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
||||
{errors?.map((e) => (
|
||||
<div key={e.id} className="error-box" role="alert">
|
||||
<span>{e.message}</span>
|
||||
<button className="small ghost" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
|
||||
<Button type="text" size="small" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
{session.agent === "plan" && !busy && lastIsAssistant && (
|
||||
<div className="row" style={{ justifyContent: "center", margin: "12px 0" }}>
|
||||
<button
|
||||
className="primary"
|
||||
<Button type="primary"
|
||||
onClick={async () => {
|
||||
await update({ agent: "build" });
|
||||
await send(t("plan.implementPrompt"), []);
|
||||
}}
|
||||
>
|
||||
{t("plan.implement")}
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(!following || scrolled) && (
|
||||
<div className="jump-latest">
|
||||
<button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
|
||||
<Button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
|
||||
<Icon name="arrow-up" />
|
||||
</button>
|
||||
{!following && <button className="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
|
||||
</Button>
|
||||
{!following && <Button type="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
|
||||
<Icon name="arrow-down" />
|
||||
</button>}
|
||||
</Button>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user