Fix storage panel error handling and candidate layout

This commit is contained in:
Miura Yoshiki
2026-10-13 13:15:10 +00:00
parent d8fbf287a9
commit 5325f2a59e
12 changed files with 144 additions and 28 deletions
+1
View File
@@ -7,6 +7,7 @@
- Protect unknown owners, live processes and mapped outputs during cleanup, including outputs whose helper has already been removed. Track new cache directories for dead-process recovery.
- Add manual RAM and Disk-backed capacity checks and account for discoverable Linux cgroup memory limits. Keep Auto's 4 GiB threshold and reserve, existing node controls, frame dtype and generation/storage identities.
- Keep V3.9 and V3.8X2 workflows and public node schemas unchanged. No new GPU generation is claimed for this storage update; see PACKAGE_VALIDATION.txt for CPU/browser/platform coverage.
- Follow-up: report missing/empty/invalid storage responses with HTTP status and recovery guidance. Keep storage candidates visible at a usable width and mutations disabled until status is available. Preserve Core address/profile handling and never replay a mutating request.
## 3.9.2 — Issue #30 frontend hotfix (2026-10-13)
+9 -9
View File
@@ -4,7 +4,7 @@ cb19f6b668d08217621f92ec2cc890e9ba3fbe205d1212e01e6b2dd31a0992de .comfyignore
3e22b441fe96bb6d099f0fcb92265f7a986c444f6c45be263c7905898aea4ac7 .github/workflows/tests.yml
a28c4c592d56c57e0967f0adce5655313b942b8cc04f77766c0db1bec96c13e0 .gitignore
3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py
32353be7af0fe26ff5aa2ffbc9e22823f1360af9213f27d5011208294b053b80 CHANGELOG.md
05d5cb54819b31e3573585c3b1d06cb75dbf1011a97445eec7618eb3224087ad CHANGELOG.md
c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py
4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py
294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py
@@ -132,16 +132,16 @@ fd23c7f32810788aaaf1709c4959c40ec72303aecc6f6afa5fa68d824cca97a8 minimax-h3-con
d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py
ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py
f67982dd107c1c37c033a860adab343b86390af4ff94bc20f16c836f6dc8915d PACKAGE_INFO_JA.txt
e71abe10be665cf58a5f07cd2eea45b3f94ea06443616daadfa2b7c44e3d71de PACKAGE_VALIDATION.txt
5ef2df776b46558eaa69d98f6797e77da2da16038116d7aacf297d8e86d82caa PACKAGE_VALIDATION.txt
b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
e6190cc7b2ce1adcaa37e221c2edca1f257ca516a80003d6ea87b2e146e028f9 pyproject.toml
94fdc2d545b2d4077a4d70229fd22ba3ccac21d49d1097d2873f76d04e9a3c7a pytest.ini
7b5dde75e41dbc133c6958dcbf54ce381c10e7e1fef253100019bd7e14c7fb47 README_JA.md
c1a40d0ed6ffb2cbe893b92677de50e871bcfc8456753656b466540129224174 README.md
9b786f0c36dbdefd072ea602aa4e4dd42a49d17150fdde9fa38cb8c1ee71d91a README_JA.md
4f93d8bdc3943f4594e0d37b4c4d2509f2e8701e07225518b7f590bf5ef5bdfb README.md
9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py
5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py
caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py
b03dca829ef2e380e7cd030b54f8a8f81cea7f5d81ee7536c0f3fd661ee84bf2 REGISTRY_MANIFEST.sha256
ba289d33435cab21d8f3f4c2a5a250eba8eae0ff96955dfe4316729a79a9ae42 REGISTRY_MANIFEST.sha256
467edb2c188d024c2392aafe7423b3f835e16b10f570da76e2f7dda8a962c1c5 requirements.txt
1845cbf7ba4d3b35afd087a15f5a4d92dc73d4858e61982f8ccf431a836a22b1 run_storage.py
6056de6c0a5322a8a51ba5a114538dca2ef67788cd1afba10fedd483b95f6afa state_io.py
@@ -429,13 +429,13 @@ d2e59eae0a724626b0a4e361921643dd31cb3612ae1f0d1b8b355c9d42c06174 tests/test_v39
319258798ca198312cf684f369990924657d1af168a148ad34303af31c06a350 tests/test_v39_review_refine_scope.py
8d0ccf5711e1be0bf63b4e02fecb0b37cd88979894d27b89337cda4a6d1c4ec5 tests/frontend_issue30_ui.cjs
d6b5b969a0c02f1b282da990db3e503e0768747cfac8a4edd32cf8677550e024 tests/test_issue30_frontend.py
1bc5274ee15de5e0cee6637bd4712c7915bd5133617486a2d6bfbb1bbbc69539 docs/TEMPORARY_STORAGE_JA.md
4546ffb0cbaf270c52d1900908e46bfa2d3c0e2d0035ae5694680890e89aedd8 docs/TEMPORARY_STORAGE_JA.md
660a9df28c7d62ad383cda5514c48c7efcb3576f435af023040116d533a56563 storage_api.py
517662b104ab1507bb927a39f25b8503f092c2ba4c39bc277379ba9d9e31b334 storage_fs.py
daeda14d9f5338835661e6738e074a3897d936cd847fe3e78519efabbcdfd0ef storage_memory.py
53da3ac42f4a66e8adc4560049c7c8e7ada82599be8c61f0573c234342ca36ed storage_settings.py
baa86a523872c9dfbe0123b466535fbf94cf408787a516fb17315064c6acef70 tests/frontend_storage_settings.mjs
ea47f51abe07e9b2af840272939c0f363369636af30f4c6dffb0bb696b752c8a tests/frontend_storage_settings.mjs
1bbc7e5755f71d6fdfddcc6dc8337444febee87cb86773835ca6ac6c79d89357 tests/test_storage_api.py
599c8fac84ae817af33ac7972ca3d53d01d1ac49f36f3d5a374dcd8d6d91d217 tests/test_storage_frontend.py
82f049d7e51c8d6c43322ac4e0043d3fee6323c7989a2c446b86a936bd5ce790 tests/test_storage_frontend.py
8a512b3afdf394af043a4d6bd7c4fca0c9326e1207930bf5d96b4d0bd7205b4e tests/test_temporary_storage.py
b1083e90751f7cf115ce973db11bc5331afc2c22289e21c0110e98312057534e web/storage_settings.js
42afab2241d39c1b07ff33d8b1370d4b0f729d81e53b4c99f4bc54c6a96b8800 web/storage_settings.js
+20
View File
@@ -39,6 +39,26 @@ Candidate validation
result is a separate gate from these local Linux checks. The browser
gate is headless desktop Chromium, not mobile hardware or GPU generation.
3.9.3 frontend follow-up
- Empty HTTP 404 reproduced the reported parser error and empty selector.
User startup logs identified the failed updated process binding to a port
already held by an older process. Starting the updated backend on an
available port restored status and controls in the user's environment.
- Improve HTTP/invalid-response diagnostics, initialized candidate labels,
full-width layout and manual recovery. Preserve Core URL/auth/profile
handling; no automatic retries or replay of mutating requests.
- Targeted CPU/JavaScript/HTTP regression: 59 passed / 2 existing expected
Inspector failures. Full Core 0.39.0 CPU regression: 1740 passed /
2 skipped / 2 existing Inspector expected failures; CUDA attempts zero.
- Core 0.39.0 / frontend 1.53.10 static assets / Chromium smoke passed on
an alternate loopback host and port: initial empty-404 reproduction,
explicit HTTP 404/403/empty-200 errors, initialized full-width selector,
Refresh recovery without page reload, and actual settings save/cleanup.
No page errors, prompt submissions or automatic mutation replay.
This used Linux CPU dependencies; it is separate from Windows/GPU quality
validation. Core registration/planning and compileall also passed.
- Source/Registry hashes and unchanged workflow bytes are checked again.
Limits and update
No GPU generation, long-form throughput, physical SSD write measurement or
mobile hardware validation was performed for this storage change. Memory
+2
View File
@@ -6,6 +6,8 @@ Updated: 2026-10-13 (Japan time).
The current source adds a server-side scratch folder setting for Finalize and Decode Cache, storage usage/free-space reporting and conservative unused-file cleanup. Manual buffer capacity checks retain the existing Auto policy. Node schemas, official workflow bytes, generation identity and saved Runs/Takes are preserved.
Frontend follow-up improves missing/empty-response diagnostics and storage candidate initialization. The Core request address/profile handling is retained, and no automatic mutation retries are added.
The new setting is available under Settings → H3Continuum → Storage. Validation and platform limitations are recorded in PACKAGE_VALIDATION.txt. Source publication does not imply a new GitHub Release/tag or Registry publication.
## Previous package 3.9.2 — Issue #30 frontend hotfix
+2
View File
@@ -15,6 +15,8 @@ Update the custom node package, restart ComfyUI to load the backend, and hard-re
The storage changes preserve frame dtype, video/audio assembly and generation identity. Validation and remaining platform limits are recorded in [PACKAGE_VALIDATION.txt](PACKAGE_VALIDATION.txt). Screenshots will be added from the implemented settings screen. GitHub Release/tag and Registry publication are separate from this source update.
If the panel reports HTTP 404, inspect the ComfyUI startup log. An old process can keep the chosen address/port occupied, so the updated process fails to start while its new JavaScript is already visible. Stop the obsolete instance or choose another port, then start the updated backend. **Refresh** retrieves storage status; it does not restart ComfyUI. Failed reads now show the HTTP result and keep mutations disabled until status is available.
## 3.9.2 — Issue #30 frontend hotfix (2026-10-13)
This hotfix reduces unnecessary Review and Reference Images UI work:
+2
View File
@@ -15,6 +15,8 @@
映像のdtype、動画・音声の結合計算、生成条件の識別は維持します。[実装仕様](docs/TEMPORARY_STORAGE_JA.md)と[検証記録](PACKAGE_VALIDATION.txt)も参照してください。設定画面のスクリーンショットは、実装後の実画面を受領してから追加します。GitHub Release/tag・Registry公開は今回のソース更新とは別です。
画面にHTTP 404が出る場合は、ComfyUI起動ログを確認してください。旧プロセスが同じアドレス・ポートを占有していると、更新後の起動が失敗し、新しい画面だけが表示される場合があります。残っている旧環境を終了するか別のポートを選んで、新しいComfyUIを起動してください。**Refresh(更新)**は保存先の状態を再取得するボタンで、ComfyUIの再起動ではありません。取得失敗時はHTTP結果と対応方法を表示し、状態を取得できるまで保存・削除を無効にします。
## 3.9.2 — Issue #30 Frontend hotfix(2026-10-13)
ReviewとReference Imagesの不要なUI処理を削減します。
+6 -6
View File
@@ -1,7 +1,7 @@
02ea0951ce2e7ac2d5f3bbf02c596a9f9ea8adcdf2a113dca4c8db3cc19c36b3 __init__.py
cb19f6b668d08217621f92ec2cc890e9ba3fbe205d1212e01e6b2dd31a0992de .comfyignore
3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py
32353be7af0fe26ff5aa2ffbc9e22823f1360af9213f27d5011208294b053b80 CHANGELOG.md
05d5cb54819b31e3573585c3b1d06cb75dbf1011a97445eec7618eb3224087ad CHANGELOG.md
c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py
4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py
294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py
@@ -46,11 +46,11 @@ d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py
d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py
ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py
f67982dd107c1c37c033a860adab343b86390af4ff94bc20f16c836f6dc8915d PACKAGE_INFO_JA.txt
e71abe10be665cf58a5f07cd2eea45b3f94ea06443616daadfa2b7c44e3d71de PACKAGE_VALIDATION.txt
5ef2df776b46558eaa69d98f6797e77da2da16038116d7aacf297d8e86d82caa PACKAGE_VALIDATION.txt
b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
e6190cc7b2ce1adcaa37e221c2edca1f257ca516a80003d6ea87b2e146e028f9 pyproject.toml
7b5dde75e41dbc133c6958dcbf54ce381c10e7e1fef253100019bd7e14c7fb47 README_JA.md
c1a40d0ed6ffb2cbe893b92677de50e871bcfc8456753656b466540129224174 README.md
9b786f0c36dbdefd072ea602aa4e4dd42a49d17150fdde9fa38cb8c1ee71d91a README_JA.md
4f93d8bdc3943f4594e0d37b4c4d2509f2e8701e07225518b7f590bf5ef5bdfb README.md
9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py
5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py
caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py
@@ -142,9 +142,9 @@ ae59273f163a116ece418957c557c4fd8c3285e3c60814679b9361d2e6e6fa02 web/reference_
beea70f6e25e1366aba5e2689c31733478472f207dc50cad1562cd877152e4f9 web/reference_images_v39.js
bf41bf08dd0504eb753fa5781e6c2b8c1285758ad4bb7309975bb9231d5f8e41 web/video_reference_mode_ui.js
7fd122ff08232e114a6ef32171217ea6324e980eb7257d560c466b8177a3d3ec audio_compat.py
1bc5274ee15de5e0cee6637bd4712c7915bd5133617486a2d6bfbb1bbbc69539 docs/TEMPORARY_STORAGE_JA.md
4546ffb0cbaf270c52d1900908e46bfa2d3c0e2d0035ae5694680890e89aedd8 docs/TEMPORARY_STORAGE_JA.md
660a9df28c7d62ad383cda5514c48c7efcb3576f435af023040116d533a56563 storage_api.py
517662b104ab1507bb927a39f25b8503f092c2ba4c39bc277379ba9d9e31b334 storage_fs.py
daeda14d9f5338835661e6738e074a3897d936cd847fe3e78519efabbcdfd0ef storage_memory.py
53da3ac42f4a66e8adc4560049c7c8e7ada82599be8c61f0573c234342ca36ed storage_settings.py
b1083e90751f7cf115ce973db11bc5331afc2c22289e21c0110e98312057534e web/storage_settings.js
42afab2241d39c1b07ff33d8b1370d4b0f729d81e53b4c99f4bc54c6a96b8800 web/storage_settings.js
+6
View File
@@ -1,5 +1,11 @@
# Public development log
## 2026-10-13 - 3.9.3 storage panel failure handling
- Reproduce the initial panel failure with an empty HTTP 404. Startup logs identified a stale process retaining the configured address/port while the updated backend failed to bind; the new frontend could still be served from updated files.
- Keep Core's request address, base path and user/auth handling. Add explicit HTTP/invalid-response guidance, an initialized full-width storage candidate field, safe disabled mutation controls and manual recovery without reloading the page. Do not retry save or cleanup automatically.
- Keep the backend and generation contracts unchanged. Core 0.39.0 CPU regression passed 1,740 cases with 2 skips and 2 existing expected Inspector failures; CUDA attempts were zero. The frontend 1.53.10 browser gate passed empty-response diagnostics, manual recovery, save and cleanup at an alternate host/port. See PACKAGE_VALIDATION.txt for scope.
## 2026-10-13 — package 3.9.3 temporary storage
- Re-review the scratch storage proposal against actual Finalize, Decode Cache and Core settings lifecycles. Implement server-side settings with revision checks, queue coordination, immutable directory identities and no silent disk fallback.
+2
View File
@@ -41,6 +41,8 @@ ComfyUIの設定に「H3Continuum → Storage → 一時ストレージを管理
描画callbackや常時タイマーでディスクを走査しない。画面表示・操作時に管理対象の範囲だけ確認し、ブラウザー側にイベントの重複登録を作らない。
API応答が404・空・不正な形式の場合は、その結果と再取得方法を表示する。候補欄は取得前から説明付きの幅を確保し、状態取得に成功するまで保存・削除を無効にする。更新で復帰でき、保存・削除リクエストを自動再送しない。起動ログにポート使用中エラーがある場合、旧プロセスが残って新しいPython側機能を起動できていない可能性を案内する。
## 3. 保存先の決定と既存動作
### 空欄
+40 -2
View File
@@ -22,11 +22,20 @@ let definition;
globalThis.__app = { ui: { settings: { getSettingValue: () => "en", addSetting: d => { definition = d; } } }, registerExtension: d => d.setup() };
const api = globalThis.__api = new EventTarget();
const requests = [];
let responseMode = "normal";
let state = { path: "", revision: 0, busy: false, read_only: false, memory: { available_bytes: 8 * 1024 ** 3 }, roots: [], volumes: [], last_backend: null };
api.fetchApi = async (path, options) => {
const action = path.split("/").at(-1);
const body = options.body ? JSON.parse(options.body) : undefined;
requests.push({ action, body });
requests.push({ action, body, path, options });
if (responseMode === "network") throw new TypeError("fetch failed");
if (responseMode === "both404") return new Response("", { status: 404 });
if (responseMode === "empty200") return new Response("", { status: 200 });
if (responseMode === "empty403") return new Response("", { status: 403 });
if (responseMode === "empty500") return new Response("", { status: 500 });
if (responseMode === "html") return new Response("<!doctype html><title>ComfyUI</title>", { status: 200 });
if (responseMode === "schema") return Response.json({});
if (responseMode === "cleanupEmpty" && action === "cleanup") return new Response("", { status: 200 });
let value = structuredClone(state), ok = true;
if (action === "settings") { assert.equal(body.revision, state.revision); state = { ...state, path: body.path, revision: state.revision + 1 }; value = state; }
if (action === "validate") {
@@ -34,8 +43,9 @@ api.fetchApi = async (path, options) => {
value = ok ? { path: body.path, roots: [{ free_bytes: 10 * 1024 ** 3 }] } : { error: "absolute path required" };
}
if (action === "cleanup") { assert.deepEqual(body, {}); value = { roots: [] }; }
return { ok, status: ok ? 200 : 400, json: async () => value };
return Response.json(value, { status: ok ? 200 : 400 });
};
const source = fs.readFileSync(new URL("../web/storage_settings.js", import.meta.url), "utf8")
.replace('import { app } from "../../scripts/app.js";', "const app = globalThis.__app;")
.replace('import { api } from "../../scripts/api.js";', "const api = globalThis.__api;")
@@ -87,4 +97,32 @@ assert.equal(control("Save").disabled, true);
assert.equal(control("Delete unused temporary files").disabled, true);
assert.equal(connected("input")[0].disabled, true);
control("Close").click();
state.read_only = false;
for (const [mode, text, count] of [["both404", "HTTP 404", 1], ["empty403", "HTTP 403", 1],
["empty500", "HTTP 500", 1], ["empty200", "HTTP 200", 1], ["html", "HTTP 200", 1],
["schema", "HTTP 200", 1], ["network", "current address", 1]]) {
responseMode = mode;
const before = requests.length;
launch.click(); await settle();
assert.equal(requests.length - before, count, mode);
assert.ok(all.some(x => x.isConnected && x.attributes.role === "status" && x.textContent.includes(text)), mode);
assert.equal(connected("input")[0].disabled, true, "no mutations with unavailable status");
assert.equal(control("Save").disabled, true);
assert.equal(connected("select")[0].disabled, true);
assert.ok(connected("select")[0].children[0].textContent.includes("Refresh"));
assert.equal(control("Refresh").disabled, false, "manual recovery stays available");
responseMode = "normal";
control("Refresh").click(); await settle();
assert.equal(control("Save").disabled, false, "recover without reloading the browser");
control("Close").click();
}
// A successful save/cleanup with an empty response must never be replayed.
responseMode = "normal"; launch.click(); await settle();
responseMode = "cleanupEmpty";
const beforeCleanup = requests.length;
control("Delete unused temporary files").click(); await settle();
assert.equal(requests.length - beforeCleanup, 1, "never retry a mutating request");
assert.ok(all.some(x => x.isConnected && x.attributes.role === "status" && x.textContent.includes("HTTP 200")));
control("Close").click();
console.log("Temporary storage frontend: settings nesting, deduplication, errors, save, busy/read-only gates, cleanup, and 100 reopen cycles passed");
console.log("Empty/invalid HTTP responses, recovery, and no POST replay passed");
+1
View File
@@ -11,3 +11,4 @@ def test_storage_settings_frontend_lifecycle():
capture_output=True, timeout=30)
assert result.returncode == 0, result.stdout + result.stderr
assert "100 reopen cycles passed" in result.stdout
assert "Empty/invalid HTTP responses, recovery, and no POST replay passed" in result.stdout
+53 -11
View File
@@ -15,6 +15,11 @@ const words = {
note: "This is the server's storage, not the browser device. File sizes are logical sizes, not SSD write totals. Moving to another folder on the same physical disk does not reduce its writes.",
modes: "Keep choosing Auto / RAM / Disk-backed in Finalize, and Auto / RAM / Off in Decode Cache Helper. They are independent. Deleting a cache can require decoding and writing it again.",
memory: "Available CPU RAM", last: "Last Finalize allocation", never: "No Finalize allocation in this process yet",
noVolumes: "No storage candidates found. Enter an absolute server folder above.",
unavailable: "Storage service unavailable (HTTP {status}). The old ComfyUI process may still be running, or the updated process failed to start. Check the startup log for a port already in use.",
invalidResponse: "Empty or invalid storage response (HTTP {status}). Click Refresh to retry; if it persists, check the ComfyUI startup log.",
networkError: "Cannot reach ComfyUI at the current address. Click Refresh to retry.",
unloaded: "Storage data unavailable — click Refresh",
},
ja: {
title: "H3 Continuum — 一時ストレージ", open: "一時ストレージを管理", close: "閉じる",
@@ -29,6 +34,11 @@ const words = {
note: "対象はブラウザー端末ではなくComfyUIサーバーです。表示容量はファイルの論理サイズで、SSDの累計書き込み量ではありません。同じ物理ディスク内の移動では、そのディスクへの書き込みは減りません。",
modes: "使用方式は従来どおりFinalizeのAuto/RAM/Disk-backedと、Decode Cache HelperのAuto/RAM/Offで選びます。両者は独立しています。キャッシュ削除後は再デコード・再書き込みが必要になる場合があります。",
memory: "利用可能なCPU RAM", last: "直近のFinalize確保", never: "このプロセスではまだFinalizeを実行していません",
noVolumes: "候補を取得できません。上の欄にサーバー側の絶対パスを入力できます。",
unavailable: "一時ストレージ機能に接続できません(HTTP {status})。旧ComfyUIが残っているか、更新後の起動に失敗した可能性があります。起動ログのポート使用中エラーを確認してください。",
invalidResponse: "一時ストレージの応答が空か、不正な形式です(HTTP {status})。更新で再取得し、続く場合はComfyUI起動ログを確認してください。",
networkError: "現在のアドレスでComfyUIへ接続できません。更新で再取得してください。",
unloaded: "保存先の状態を取得できません — 更新で再取得",
},
};
@@ -53,11 +63,31 @@ function element(tag, text, parent) {
}
async function request(operation, body) {
const response = await api.fetchApi(`/h3-continuum/storage/${operation}`, body === undefined
const path = `/h3-continuum/storage/${operation}`;
const options = body === undefined
? { cache: "no-store" }
: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
const value = await response.json();
if (!response.ok) throw new Error(value.error || `HTTP ${response.status}`);
: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) };
const t = language();
let response;
try {
// Core retains the UI address, base path and user/auth handling.
// Never replay a save or cleanup after an empty/failed response:
// it may already have run on the server.
response = await api.fetchApi(path, options);
} catch {
throw new Error(t.networkError);
}
let value;
try { value = JSON.parse(await response.text()); } catch { /* Report HTTP status instead of a JSON parser exception. */ }
if (!response.ok) {
const fallback = response.status === 404 ? t.unavailable : `HTTP ${response.status}`;
throw new Error(typeof value?.error === "string" ? value.error : fallback.replace("{status}", response.status));
}
if (!value || typeof value !== "object" || Array.isArray(value)
|| (operation === "status" && (typeof value.path !== "string" || !Number.isInteger(value.revision)
|| !Array.isArray(value.roots) || !Array.isArray(value.volumes) || !value.memory))) {
throw new Error(t.invalidResponse.replace("{status}", response.status));
}
return value;
}
@@ -82,8 +112,11 @@ export function openStorageDialog(event) {
const input = element("input", null, label);
input.type = "text"; input.placeholder = t.default; input.setAttribute("aria-label", t.path);
Object.assign(input.style, { display: "block", width: "100%", margin: "8px 0", padding: "8px", boxSizing: "border-box" });
const select = element("select", null, dialog);
select.setAttribute("aria-label", t.volumes); select.style.maxWidth = "100%";
const volumeLabel = element("label", t.volumes, dialog);
const select = element("select", null, volumeLabel);
select.setAttribute("aria-label", t.volumes);
Object.assign(select.style, { display: "block", width: "100%", minHeight: "34px", margin: "8px 0", boxSizing: "border-box" });
const placeholder = element("option", t.loading, select); placeholder.value = "";
const actions = element("div", null, dialog);
Object.assign(actions.style, { display: "flex", gap: "8px", flexWrap: "wrap", margin: "12px 0" });
const buttons = {};
@@ -102,15 +135,15 @@ export function openStorageDialog(event) {
function controls() {
for (const name of ["validate", "save", "cleanup"]) buttons[name].disabled = pending || !state || state.busy || state.read_only;
buttons.refresh.disabled = pending;
input.disabled = pending || !!state?.read_only;
select.disabled = input.disabled;
input.disabled = pending || !state || !!state.read_only;
select.disabled = input.disabled || !state?.volumes?.length;
notice.textContent = state?.read_only ? t.readonly : state?.busy ? t.busy : "";
}
function render(value) {
state = value;
if (!dirty) input.value = value.path;
select.replaceChildren();
const option = element("option", t.volumes, select); option.value = "";
const option = element("option", value.volumes.length ? t.volumes : t.noVolumes, select); option.value = "";
for (const volume of value.volumes) {
const option = element("option", `${volume.path} (${t.free}: ${size(volume.free_bytes)})`, select);
option.value = volume.path;
@@ -131,8 +164,17 @@ export function openStorageDialog(event) {
}
}
async function refresh() {
const value = await request("status");
if (!closed) render(value);
try {
const value = await request("status");
if (!closed) render(value);
} catch (error) {
if (!closed) {
state = null;
select.replaceChildren();
const option = element("option", t.unloaded, select); option.value = "";
}
throw error;
}
}
async function perform(action) {
if (pending) return;