Files
codecraft/web/src/components/RenameDialog.tsx
T
Richard ZinkandClaude Opus 5.5 a0d0e707f2 Add Web Push, guided start screen, SVG icons, chunked uploads, rename
- Web Push (VAPID + RFC 8291, pure Rust): permission/question/finished
  notifications while no app window is visible; settings with test button
- Guided new-session flow: task, craft target (website/app/game/old
  software/fresh), clean room or deep, description, model, folder
  (new, existing or cloned git repository); originals upload to original/
- Craft phase bar (craft_phase tool) for study/specify/build/check/ready
- Chunked uploads (8 MB) up to server.max_upload_mb (default 500 MB)
- All UI glyphs and emojis replaced by themeable SVG icons
- Rename dialog with manual name or model-generated suggestion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:03:26 +01:00

73 lines
2.6 KiB
TypeScript

import { useState } from "react";
import { patch, post } from "../api";
import { useFetch } from "../hooks";
import { useT } from "../i18n";
import { Icon } from "./Icon";
import { ModelSelect } from "./ModelSelect";
import { Spinner } from "./Activity";
/** Rename a session: type a name, or let a chosen model suggest one. */
export function RenameDialog({ sessionId, title, onClose }: { sessionId: string; title: string; onClose: () => void }) {
const t = useT();
const config = useFetch<{ small_model?: string; default_model?: string }>("/config").data;
const [value, setValue] = useState(title);
const [model, setModel] = useState("");
const [busy, setBusy] = useState<"gen" | "save">();
const [error, setError] = useState<string>();
const chosen = model || config?.small_model || config?.default_model || "";
const generate = async () => {
setBusy("gen");
setError(undefined);
try {
const r = await post<{ title: string }>(`/sessions/${sessionId}/title`, { model: chosen || undefined });
setValue(r.title);
} catch (e: any) {
setError(e.message);
} finally {
setBusy(undefined);
}
};
const save = async () => {
setBusy("save");
try {
await patch(`/sessions/${sessionId}`, { title: value.trim() });
onClose();
} catch (e: any) {
setError(e.message);
setBusy(undefined);
}
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-label={t("rename.title")} onClick={(e) => e.stopPropagation()}>
<h3>{t("rename.title")}</h3>
<input
autoFocus
style={{ width: "100%" }}
value={value}
placeholder={t("session.untitled")}
onChange={(e) => setValue(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && !busy && void save()}
/>
<div className="rename-gen">
<span className="hint">{t("rename.generateWith")}</span>
<ModelSelect value={chosen} onChange={setModel} />
<button className="small" onClick={generate} disabled={!!busy}>
{busy === "gen" ? <Spinner small /> : <Icon name="sparkle" />} {t("rename.generate")}
</button>
</div>
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" onClick={save} disabled={!!busy}>
{t("common.save")}
</button>
</div>
</div>
</div>
);
}