mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-07 05:11:51 +08:00
release(v0.3.35): sandbox upgrade guard, shell timezone i18n, and release notes
- Add validate_sandbox_compose check and compose snapshot backup/restore in deploy-lib.sh - Show both git clone and non-git sync upgrade commands in sandbox page and settings card - Gate standalone-to-sandbox warning in update modal to Docker non-sandbox mode only - Add timezone-based zh/en auto-switching (with ARTEX_LANG override) across shell scripts - Extract CHANGELOG.md section into GitHub Release notes and add v0.3.35 release notes
This commit is contained in:
1 parent
96a01bfeba
commit
659e43e91e
13 files changed
+738
-245
No files matched your search
@@ -91,8 +91,8 @@ export default function SandboxPage() {
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
const [pruning, setPruning] = React.useState(false);
|
||||
const [busyKey, setBusyKey] = React.useState<string>("");
|
||||
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.34");
|
||||
const [copiedUpgradeCmd, setCopiedUpgradeCmd] = React.useState(false);
|
||||
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.35");
|
||||
const [copiedCmd, setCopiedCmd] = React.useState<"" | "git" | "sync">("");
|
||||
// Filters
|
||||
const [scopeFilter, setScopeFilter] = React.useState<"all" | "task" | "session">("all");
|
||||
const [stateFilter, setStateFilter] = React.useState<"all" | "running" | "stopped">("all");
|
||||
@@ -184,14 +184,25 @@ export default function SandboxPage() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const upgradeCommand = `git pull\n./update.sh --upgrade --tag ${upgradeTag}`;
|
||||
const gitUpgradeCommand = `git pull --ff-only && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
|
||||
const syncUpgradeCommand = [
|
||||
"(",
|
||||
" set -e",
|
||||
" mkdir -p scripts",
|
||||
" if [ -f docker-compose.yml ]; then cp docker-compose.yml docker-compose.yml.bak; fi",
|
||||
" for f in docker-compose.yml update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh; do",
|
||||
` curl -fsSL "https://raw.githubusercontent.com/RuoJi6/ARTEX/${upgradeTag}/$f" -o "$f"`,
|
||||
" done",
|
||||
" chmod +x update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh",
|
||||
`) && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`,
|
||||
].join("\n");
|
||||
|
||||
const handleCopyUpgradeCommand = async () => {
|
||||
const handleCopyUpgradeCommand = async (kind: "git" | "sync", cmd: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(upgradeCommand);
|
||||
setCopiedUpgradeCmd(true);
|
||||
await navigator.clipboard.writeText(cmd);
|
||||
setCopiedCmd(kind);
|
||||
toast.success(L("升级命令已复制", "Upgrade command copied"));
|
||||
window.setTimeout(() => setCopiedUpgradeCmd(false), 2000);
|
||||
window.setTimeout(() => setCopiedCmd((prev) => (prev === kind ? "" : prev)), 2000);
|
||||
} catch {
|
||||
toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually"));
|
||||
}
|
||||
@@ -440,32 +451,68 @@ export default function SandboxPage() {
|
||||
)}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5">
|
||||
<div className="flex min-w-0 items-start gap-2.5">
|
||||
<TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
||||
<pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed">
|
||||
<code>{upgradeCommand}</code>
|
||||
</pre>
|
||||
<CardContent className="space-y-3.5">
|
||||
<div className="space-y-1.5">
|
||||
<p className="font-medium text-foreground text-xs">
|
||||
{L("方式一:git clone 部署目录", "Option 1: Git clone deployment")}
|
||||
</p>
|
||||
<div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5">
|
||||
<div className="flex min-w-0 items-start gap-2.5">
|
||||
<TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
||||
<pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed">
|
||||
<code>{gitUpgradeCommand}</code>
|
||||
</pre>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1.5 px-2.5 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand("git", gitUpgradeCommand)}
|
||||
>
|
||||
{copiedCmd === "git" ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedCmd === "git" ? L("已复制", "Copied") : L("复制命令", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1.5 px-2.5 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand()}
|
||||
>
|
||||
{copiedUpgradeCmd ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedUpgradeCmd ? L("已复制", "Copied") : L("复制命令", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<p className="font-medium text-foreground text-xs">
|
||||
{L(
|
||||
"方式二:非 git 部署目录(仅含 docker-compose.yml 与 .env,自动备份并同步新版编排与脚本)",
|
||||
"Option 2: Non-Git deployment (backs up docker-compose.yml and syncs latest compose & scripts)",
|
||||
)}
|
||||
</p>
|
||||
<div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5">
|
||||
<div className="flex min-w-0 items-start gap-2.5">
|
||||
<TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
||||
<pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed">
|
||||
<code>{syncUpgradeCommand}</code>
|
||||
</pre>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1.5 px-2.5 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand("sync", syncUpgradeCommand)}
|
||||
>
|
||||
{copiedCmd === "sync" ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedCmd === "sync" ? L("已复制", "Copied") : L("复制命令", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-muted-foreground text-xs leading-relaxed">
|
||||
{L(
|
||||
`升级会保留原有 PostgreSQL 数据、./data 与 ./skills,切换后无法回滚但会显著提高运行安全性。若非 git clone 部署,请先同步最新 docker-compose.yml、update.sh 与 scripts/ 后再执行 ./update.sh --upgrade --tag ${upgradeTag};完成后刷新本页即可进入 Docker 沙箱模式。`,
|
||||
`Preserves PostgreSQL data, ./data, and ./skills. This switch is irreversible but significantly improves isolation security. If not deployed via git clone, sync the latest docker-compose.yml, update.sh, and scripts/ first, then run ./update.sh --upgrade --tag ${upgradeTag} and refresh this page.`,
|
||||
"升级会保留原有 PostgreSQL 数据、./data 与 ./skills,并启动 4 个服务容器(postgres、docker-socket-proxy、artex、artex-gateway)。切换后无法回滚但会显著提高运行安全性;完成后刷新本页即可进入 Docker 沙箱模式。",
|
||||
"Preserves PostgreSQL data, ./data, and ./skills, and starts 4 services (postgres, docker-socket-proxy, artex, artex-gateway). This switch is irreversible but significantly improves isolation security; refresh this page after upgrading.",
|
||||
)}
|
||||
</p>
|
||||
</CardContent>
|
||||
|
||||
@@ -56,8 +56,8 @@ export function SandboxCard() {
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
const [pruning, setPruning] = React.useState(false);
|
||||
const [busyKey, setBusyKey] = React.useState("");
|
||||
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.34");
|
||||
const [copiedUpgradeCmd, setCopiedUpgradeCmd] = React.useState(false);
|
||||
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.35");
|
||||
const [copiedCmd, setCopiedCmd] = React.useState<"" | "git" | "sync">("");
|
||||
const [image, setImage] = React.useState("");
|
||||
const [memoryMB, setMemoryMB] = React.useState("2048");
|
||||
const [cpus, setCpus] = React.useState("2");
|
||||
@@ -120,14 +120,15 @@ export function SandboxCard() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const upgradeCommand = `git pull && ./update.sh --upgrade --tag ${upgradeTag}`;
|
||||
const gitUpgradeCommand = `git pull --ff-only && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
|
||||
const syncUpgradeCommand = `(set -e; mkdir -p scripts; if [ -f docker-compose.yml ]; then cp docker-compose.yml docker-compose.yml.bak; fi; for f in docker-compose.yml update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh; do curl -fsSL "https://raw.githubusercontent.com/RuoJi6/ARTEX/${upgradeTag}/$f" -o "$f"; done; chmod +x update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh) && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
|
||||
|
||||
const handleCopyUpgradeCommand = async () => {
|
||||
const handleCopyUpgradeCommand = async (kind: "git" | "sync", cmd: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(upgradeCommand);
|
||||
setCopiedUpgradeCmd(true);
|
||||
await navigator.clipboard.writeText(cmd);
|
||||
setCopiedCmd(kind);
|
||||
toast.success(L("升级命令已复制", "Upgrade command copied"));
|
||||
window.setTimeout(() => setCopiedUpgradeCmd(false), 2000);
|
||||
window.setTimeout(() => setCopiedCmd((prev) => (prev === kind ? "" : prev)), 2000);
|
||||
} catch {
|
||||
toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually"));
|
||||
}
|
||||
@@ -280,31 +281,60 @@ export function SandboxCard() {
|
||||
) : null}
|
||||
|
||||
{status && !status.enabled ? (
|
||||
<div className="space-y-2 rounded-md border border-amber-500/40 bg-amber-500/5 p-3">
|
||||
<div className="space-y-2.5 rounded-md border border-amber-500/40 bg-amber-500/5 p-3">
|
||||
<p className="text-muted-foreground text-xs">
|
||||
{L(
|
||||
"在宿主机原部署目录执行以下命令升级至沙箱隔离版(保留数据库、./data 与 ./skills):",
|
||||
"Run the following command on the host deployment directory to upgrade to the sandbox edition (preserves DB, ./data, and ./skills):",
|
||||
"在宿主机原部署目录执行以下命令升级至沙箱隔离版(保留数据库、./data 与 ./skills,需同步新版 docker-compose.yml):",
|
||||
"Run one of the commands below in your host deployment directory to upgrade to the sandbox edition (preserves DB, ./data, and ./skills; requires latest docker-compose.yml):",
|
||||
)}
|
||||
</p>
|
||||
<div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<code className="overflow-x-auto font-mono text-foreground text-xs">{upgradeCommand}</code>
|
||||
<div className="space-y-1">
|
||||
<p className="font-medium text-foreground text-[11px]">
|
||||
{L("Git clone 部署目录", "Git clone deployment")}
|
||||
</p>
|
||||
<div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<code className="overflow-x-auto font-mono text-foreground text-xs">{gitUpgradeCommand}</code>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1 px-2 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand("git", gitUpgradeCommand)}
|
||||
>
|
||||
{copiedCmd === "git" ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedCmd === "git" ? L("已复制", "Copied") : L("复制", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="font-medium text-foreground text-[11px]">
|
||||
{L("非 Git 部署目录(自动同步编排与脚本)", "Non-Git deployment (syncs compose & scripts)")}
|
||||
</p>
|
||||
<div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<code className="overflow-x-auto font-mono text-foreground text-xs">{syncUpgradeCommand}</code>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1 px-2 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand("sync", syncUpgradeCommand)}
|
||||
>
|
||||
{copiedCmd === "sync" ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedCmd === "sync" ? L("已复制", "Copied") : L("复制", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 shrink-0 gap-1 px-2 text-xs"
|
||||
onClick={() => void handleCopyUpgradeCommand()}
|
||||
>
|
||||
{copiedUpgradeCmd ? (
|
||||
<CheckIcon className="size-3.5 text-emerald-500" />
|
||||
) : (
|
||||
<CopyIcon className="size-3.5" />
|
||||
)}
|
||||
{copiedUpgradeCmd ? L("已复制", "Copied") : L("复制", "Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -56,6 +56,7 @@ export function UpdateCard() {
|
||||
const { t, liveT } = useLiveTranslation();
|
||||
const [info, setInfo] = React.useState<UpdateCheck | null>(null);
|
||||
const [checking, setChecking] = React.useState(true);
|
||||
const [sandboxEnabled, setSandboxEnabled] = React.useState<boolean | null>(null);
|
||||
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
||||
const [progress, setProgress] = React.useState<UpdateProgress | null>(null);
|
||||
// 与 progress 分开:暂存完成后进程就没了,SSE 会断,此时要切到轮询 /api/version。
|
||||
@@ -86,6 +87,21 @@ export function UpdateCard() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
let active = true;
|
||||
api
|
||||
.sandboxStatus(false)
|
||||
.then((st) => {
|
||||
if (active) setSandboxEnabled(Boolean(st.enabled));
|
||||
})
|
||||
.catch(() => {
|
||||
// keep null if sandbox status is unavailable
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => () => streamRef.current?.close(), []);
|
||||
|
||||
// quiet 同时决定要不要绕过后端缓存:进页面时的自动检查用缓存(顶栏刚查过),
|
||||
@@ -458,13 +474,15 @@ export function UpdateCard() {
|
||||
<AlertDialogDescription asChild>
|
||||
<div className="space-y-2.5 text-left">
|
||||
<p>{t("settings.updateInterruptWarning")}</p>
|
||||
<div className="space-y-1 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-amber-800 text-xs dark:text-amber-300">
|
||||
<p className="flex items-center gap-1.5 font-medium">
|
||||
<ShieldCheckIcon className="size-4 shrink-0" />
|
||||
{t("settings.standaloneToSandboxTitle")}
|
||||
</p>
|
||||
<p className="leading-relaxed">{t("settings.standaloneToSandboxWarning")}</p>
|
||||
</div>
|
||||
{info?.mode === "docker" && sandboxEnabled === false && (
|
||||
<div className="space-y-1 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-amber-800 text-xs dark:text-amber-300">
|
||||
<p className="flex items-center gap-1.5 font-medium">
|
||||
<ShieldCheckIcon className="size-4 shrink-0" />
|
||||
{t("settings.standaloneToSandboxTitle")}
|
||||
</p>
|
||||
<p className="leading-relaxed">{t("settings.standaloneToSandboxWarning")}</p>
|
||||
</div>
|
||||
)}
|
||||
{info?.mode === "docker" && (
|
||||
<p className="text-muted-foreground text-xs">{t("settings.dockerUpdateWarning")}</p>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user