feat: serialize public hardware execution
This commit is contained in:
+23
-6
@@ -2790,8 +2790,11 @@ async function loadRuntime() {
|
||||
const profileText = (hardware.firmware_profiles || []).join(" / ") || "未选择 profile";
|
||||
const flashText = hardware.auto_flash_enabled ? "自动烧录已启用" : "自动烧录未启用";
|
||||
const approvalText = hardware.approval_required ? "需授权令牌" : "调试免令牌";
|
||||
const concurrencyText = hardware.concurrency_policy === "single_flight_fail_fast"
|
||||
? " · 单请求独占"
|
||||
: "";
|
||||
$("#hardwareNote").textContent = hardware.configured
|
||||
? `${hardware.backend} · ${hardware.bitrate / 1000} kbit/s · ${profileText} · ${flashText} · ${approvalText}`
|
||||
? `${hardware.backend} · ${hardware.bitrate / 1000} kbit/s · ${profileText} · ${flashText} · ${approvalText}${concurrencyText}`
|
||||
: `真实执行已锁定:${profileText};请完成服务端启用、适配器、固件镜像${hardware.approval_required ? "和令牌" : ""}配置`;
|
||||
$("#hardwareAliasNote").textContent = "副驾座椅 → t2g_primary_seat(统一电机、加热和通风执行器)";
|
||||
$("#autoFlashNote").textContent = hardware.auto_flash_enabled
|
||||
@@ -2802,7 +2805,7 @@ async function loadRuntime() {
|
||||
? '<i data-lucide="shield-check"></i>硬件已配置'
|
||||
: '<i data-lucide="shield-off"></i>硬件锁定';
|
||||
$("#hardwareCoverage").textContent = hardware.configured
|
||||
? `可选 · ${approvalText}`
|
||||
? `可选 · ${approvalText}${concurrencyText}`
|
||||
: "已阻断";
|
||||
$("#hardwareCoverage").className = hardware.configured ? "available" : "blocked";
|
||||
const modeAvailable = state.executionMode === "hardware"
|
||||
@@ -3684,7 +3687,14 @@ async function submitRequest(event) {
|
||||
window.location.replace("/login");
|
||||
return;
|
||||
}
|
||||
if (!response.ok) throw new Error(payload.message || payload.error || `HTTP ${response.status}`);
|
||||
if (!response.ok) {
|
||||
const requestError = new Error(payload.message || payload.error || `HTTP ${response.status}`);
|
||||
requestError.code = payload.error;
|
||||
requestError.retryAfter = Number(
|
||||
payload.retry_after_seconds || response.headers.get("Retry-After") || 0,
|
||||
);
|
||||
throw requestError;
|
||||
}
|
||||
renderResult(payload);
|
||||
if (state.executionMode === "hardware") {
|
||||
await synchronizePhysicalSeatState();
|
||||
@@ -3701,9 +3711,16 @@ async function submitRequest(event) {
|
||||
} catch (error) {
|
||||
window.clearInterval(state.progressTimer);
|
||||
resetPipeline();
|
||||
setRunStatus("failed", "FAILED");
|
||||
$("#resultTitle").textContent = "请求处理失败";
|
||||
showToast(error.message);
|
||||
if (error.code === "hardware_busy") {
|
||||
setRunStatus("failed", "BENCH BUSY");
|
||||
$("#resultTitle").textContent = "真实台架正在使用";
|
||||
const retryHint = error.retryAfter > 0 ? ` 建议 ${error.retryAfter} 秒后重试。` : "";
|
||||
showToast(`${error.message}${retryHint}`);
|
||||
} else {
|
||||
setRunStatus("failed", "FAILED");
|
||||
$("#resultTitle").textContent = "请求处理失败";
|
||||
showToast(error.message);
|
||||
}
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.classList.remove("loading");
|
||||
|
||||
Reference in New Issue
Block a user