- 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>
82 lines
3.5 KiB
TypeScript
82 lines
3.5 KiB
TypeScript
import { Icon } from "./Icon";
|
|
import { useEffect, useState } from "react";
|
|
import { get, post } from "../api";
|
|
import { toast } from "../dialogs";
|
|
import { fmtRelative, useT } from "../i18n";
|
|
import { Spinner } from "./Activity";
|
|
|
|
interface ShellInfo {
|
|
id: string;
|
|
command: string;
|
|
started_at: number;
|
|
running: boolean;
|
|
exit_code: number | null;
|
|
output: string;
|
|
}
|
|
|
|
/** Header chip with the session's background shells; opens a live output popup. */
|
|
export function ShellsChip({ sessionId, busy }: { sessionId: string; busy: boolean }) {
|
|
const t = useT();
|
|
const [shells, setShells] = useState<ShellInfo[]>([]);
|
|
const [open, setOpen] = useState(false);
|
|
const [selected, setSelected] = useState<string>();
|
|
|
|
useEffect(() => {
|
|
let alive = true;
|
|
const load = () => get<ShellInfo[]>(`/sessions/${sessionId}/shells`).then((s) => alive && setShells(s)).catch(() => undefined);
|
|
void load();
|
|
const anyRunning = shells.some((s) => s.running);
|
|
if (!open && !busy && !anyRunning) return () => void (alive = false);
|
|
const h = setInterval(load, open ? 1500 : 5000);
|
|
return () => {
|
|
alive = false;
|
|
clearInterval(h);
|
|
};
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [sessionId, open, busy, shells.some((s) => s.running)]);
|
|
|
|
const running = shells.filter((s) => s.running).length;
|
|
if (shells.length === 0) return null;
|
|
const current = shells.find((s) => s.id === selected) ?? shells[0];
|
|
return (
|
|
<>
|
|
<button className={`chip ${running ? "warn" : ""}`} style={{ border: "none" }} onClick={() => setOpen(true)} title={t("shells.title")}>
|
|
{running ? <Spinner small /> : <Icon name="terminal" />} {t("shells.chip", { n: running, total: shells.length })}
|
|
</button>
|
|
{open && (
|
|
<div className="modal-backdrop" onClick={() => setOpen(false)}>
|
|
<div className="modal wide" role="dialog" aria-label={t("shells.title")} onClick={(e) => e.stopPropagation()}>
|
|
<div className="row" style={{ marginBottom: 8 }}>
|
|
<h3 style={{ margin: 0 }}>{t("shells.title")}</h3>
|
|
<span className="spacer" />
|
|
<button className="small ghost" onClick={() => setOpen(false)} aria-label={t("common.close")}>
|
|
<Icon name="close" />
|
|
</button>
|
|
</div>
|
|
<div className="mode-tabs" style={{ flexWrap: "wrap", marginBottom: 8 }}>
|
|
{shells.map((s) => (
|
|
<button key={s.id} className={s.id === current.id ? "active" : ""} onClick={() => setSelected(s.id)}>
|
|
<Icon name={s.running ? "dot" : "radio-off"} className={`tiny ${s.running ? "ok" : ""}`} />{" "}
|
|
{s.command.slice(0, 40)}
|
|
</button>
|
|
))}
|
|
</div>
|
|
<div className="row" style={{ fontSize: 12.5, color: "var(--muted)", marginBottom: 6 }}>
|
|
<code>{current.command}</code>
|
|
<span>· {fmtRelative(current.started_at)}</span>
|
|
<span>· {current.running ? t("shells.running") : t("shells.exited", { code: current.exit_code ?? "?" })}</span>
|
|
<span className="spacer" />
|
|
{current.running && (
|
|
<button className="small danger" onClick={() => post(`/sessions/${sessionId}/shells/${current.id}/kill`).catch(toast)}>
|
|
<Icon name="stop" /> {t("shells.stop")}
|
|
</button>
|
|
)}
|
|
</div>
|
|
<pre className="shell-output">{current.output || t("shells.noOutput")}</pre>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|