mirror of
https://github.com/rookiestar28/ComfyUI-OpenClaw.git
synced 2026-08-14 00:48:07 +00:00
fix(assets): accept hash aliases for previews
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# ComfyUI Asset API Adoption Decision (2026-04-16)
|
||||
|
||||
## 2026-05-31 reconfirmation
|
||||
|
||||
- Current host reference evidence shows upstream asset responses may expose `hash` alongside `asset_hash`.
|
||||
- OpenClaw accepts `hash` as an alias for hash-backed previews, but still resolves those refs through `/view?filename=blake3:...`.
|
||||
- This does not change the no-go decision for automatic direct `/api/assets` runtime fetches.
|
||||
|
||||
## Scope
|
||||
|
||||
- Goal: decide whether OpenClaw should adopt upstream `/api/assets` semantics as a normal runtime dependency beyond the bounded `/view` interoperability layer.
|
||||
|
||||
@@ -140,7 +140,7 @@ test.describe('R107 Live Backend Parity', () => {
|
||||
{
|
||||
filename: "preview.png",
|
||||
type: "temp",
|
||||
asset_hash: "blake3:abc123",
|
||||
hash: "blake3:abc123",
|
||||
},
|
||||
{
|
||||
asset: {
|
||||
|
||||
@@ -2,13 +2,20 @@ function pickAssetHash(imageRef = {}) {
|
||||
if (!imageRef || typeof imageRef !== "object") {
|
||||
return "";
|
||||
}
|
||||
const direct = typeof imageRef.asset_hash === "string" ? imageRef.asset_hash.trim() : "";
|
||||
const direct = typeof imageRef.asset_hash === "string"
|
||||
? imageRef.asset_hash.trim()
|
||||
: (typeof imageRef.hash === "string" ? imageRef.hash.trim() : "");
|
||||
if (direct) {
|
||||
return direct;
|
||||
}
|
||||
const nested = imageRef.asset;
|
||||
if (nested && typeof nested === "object" && typeof nested.asset_hash === "string") {
|
||||
return nested.asset_hash.trim();
|
||||
if (nested && typeof nested === "object") {
|
||||
if (typeof nested.asset_hash === "string" && nested.asset_hash.trim()) {
|
||||
return nested.asset_hash.trim();
|
||||
}
|
||||
if (typeof nested.hash === "string" && nested.hash.trim()) {
|
||||
return nested.hash.trim();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -75,6 +75,52 @@ describe("openclaw asset refs", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts top-level hash as an asset_hash alias", () => {
|
||||
expect(
|
||||
normalizeComfyOutputRef({
|
||||
filename: "hash-alias.png",
|
||||
hash: "blake3:alias123",
|
||||
})
|
||||
).toEqual({
|
||||
filename: "hash-alias.png",
|
||||
subfolder: "",
|
||||
type: "output",
|
||||
asset_hash: "blake3:alias123",
|
||||
asset_api_id: "",
|
||||
asset_api_required: false,
|
||||
resolution: "view",
|
||||
unsupported_reason: "",
|
||||
is_asset_backed: true,
|
||||
viewParams: {
|
||||
filename: "blake3:alias123",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts nested asset.hash as an asset_hash alias", () => {
|
||||
expect(
|
||||
normalizeComfyOutputRef({
|
||||
name: "nested-hash-alias.png",
|
||||
asset: {
|
||||
hash: "blake3:nested-alias",
|
||||
},
|
||||
})
|
||||
).toEqual({
|
||||
filename: "nested-hash-alias.png",
|
||||
subfolder: "",
|
||||
type: "output",
|
||||
asset_hash: "blake3:nested-alias",
|
||||
asset_api_id: "",
|
||||
asset_api_required: false,
|
||||
resolution: "view",
|
||||
unsupported_reason: "",
|
||||
is_asset_backed: true,
|
||||
viewParams: {
|
||||
filename: "blake3:nested-alias",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps asset-api-only refs explicit instead of silently turning them into /api/assets fetches", () => {
|
||||
expect(
|
||||
normalizeComfyOutputRef({
|
||||
|
||||
Reference in New Issue
Block a user