Files
codecraft/web/src/components/settings/GitAccount.tsx
T
Richard ZinkandClaude Opus 5.5 df1924b0a1 Add web terminal, git credentials, OpenSCAD, review loops, automations
- Web terminal (PTY over WebSocket, xterm.js, sandboxed, reattach with replay)
- Per-user git credentials and commit identity (credential store in the user's home)
- OpenSCAD tool (STL/3MF + preview renders, bounding box) and cad skill; 3D model card
- Craft phase inferred from tool activity when the agent does not report it
- Configurable review loop per mode (rounds, reviewer model, criteria)
- Delete config and Markdown agents from the agent editor
- Automations: cron-scheduled agents from Markdown job files, schedule tool, page
- change_directory tool (only on the user's request)

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

95 lines
3.6 KiB
TypeScript

import { useEffect, useState } from "react";
import { get, put } from "../../api";
import { useT } from "../../i18n";
import { toast } from "../../dialogs";
import { Icon } from "../Icon";
interface Cred {
host: string;
username: string;
token: string;
protocol?: string;
}
interface GitSettings {
name: string;
email: string;
credentials: Cred[];
}
/** Git identity and credentials for agents, terminal and git client (per user). */
export function GitAccount() {
const t = useT();
const [s, setS] = useState<GitSettings>();
const [saving, setSaving] = useState(false);
useEffect(() => {
get<GitSettings>("/account/git")
.then((v) => setS({ name: v.name ?? "", email: v.email ?? "", credentials: v.credentials ?? [] }))
.catch((e) => toast(e.message));
}, []);
if (!s) return null;
const setCred = (i: number, patch: Partial<Cred>) => setS({ ...s, credentials: s.credentials.map((c, j) => (j === i ? { ...c, ...patch } : c)) });
const save = async () => {
setSaving(true);
try {
const v = await put<GitSettings>("/account/git", s);
setS({ name: v.name ?? "", email: v.email ?? "", credentials: v.credentials ?? [] });
toast(t("gitcred.saved"), "success");
} catch (e: any) {
toast(e.message);
} finally {
setSaving(false);
}
};
return (
<div className="panel">
<h3>
<Icon name="fork" /> {t("gitcred.title")}
</h3>
<div className="hint" style={{ marginBottom: 10 }}>
{t("gitcred.hint")}
</div>
<div className="form">
<label>{t("gitcred.name")}</label>
<input value={s.name} onChange={(e) => setS({ ...s, name: e.target.value })} placeholder="Jane Doe" autoComplete="name" />
<label>{t("gitcred.email")}</label>
<input value={s.email} onChange={(e) => setS({ ...s, email: e.target.value })} placeholder="jane@example.com" autoComplete="email" />
</div>
<h4 style={{ margin: "16px 0 8px" }}>{t("gitcred.credentials")}</h4>
<div className="gitcred-list">
{s.credentials.length === 0 && <div className="empty" style={{ padding: 8 }}>{t("gitcred.none")}</div>}
{s.credentials.map((c, i) => (
<div key={i} className="gitcred-row">
<input value={c.host} placeholder="git.example.com" onChange={(e) => setCred(i, { host: e.target.value })} aria-label={t("gitcred.host")} />
<input value={c.username} placeholder={t("gitcred.user")} onChange={(e) => setCred(i, { username: e.target.value })} aria-label={t("gitcred.user")} autoComplete="off" />
<input
type="password"
value={c.token}
placeholder={t("gitcred.token")}
onFocus={(e) => c.token.startsWith("•") && e.target.select()}
onChange={(e) => setCred(i, { token: e.target.value })}
aria-label={t("gitcred.token")}
autoComplete="new-password"
/>
<button className="ghost small" onClick={() => setS({ ...s, credentials: s.credentials.filter((_, j) => j !== i) })} aria-label={t("common.remove")}>
<Icon name="trash" />
</button>
</div>
))}
</div>
<div className="row" style={{ marginTop: 10, gap: 8 }}>
<button className="small" onClick={() => setS({ ...s, credentials: [...s.credentials, { host: "", username: "", token: "" }] })}>
<Icon name="plus" /> {t("gitcred.add")}
</button>
<span className="grow" />
<button className="primary" onClick={save} disabled={saving}>
{t("common.save")}
</button>
</div>
</div>
);
}