Compare commits

...
Author SHA1 Message Date
Hanzo AI 1fe7df76a5 worklog: widen ?q= search to paths + refs, not just prompt
An ingested render row has an empty prompt, so filtering Queue & History by
filename found nothing. Widen the /v1/worklog ?q= filter to also match kind,
output_prefix, output (the landed path), and refs — so a render is findable by
its filename or source image, not only by a typed prompt. Test covers filename,
ref, and prompt matches.
2026-07-16 23:48:32 -07:00
2 changed files with 27 additions and 1 deletions
+5 -1
View File
@@ -1199,7 +1199,11 @@ def add_studio_home_routes(routes: web.RouteTableDef, server) -> None:
out.append(row)
q = (request.query.get("q") or "").lower().strip()
if q:
out = [r for r in out if q in (r.get("prompt", "") or "").lower() or q in (r.get("kind", "") or "")]
# search prompt + kind + the render's paths (output_prefix/output) + refs, so
# an ingested render with an empty prompt is still findable by its filename.
out = [r for r in out if q in " ".join(str(x) for x in
[r.get("prompt", ""), r.get("kind", ""), r.get("output_prefix", ""),
r.get("output", ""), *(r.get("refs") or [])]).lower()]
return web.json_response({"org": org, "items": out[:200]})
@routes.get("/v1/worklog/lineage")
@@ -566,3 +566,25 @@ async def test_library_upload_indexes_into_assets_and_worklog(tmp_path, monkeypa
wl3 = await (await client.get("/v1/worklog", headers={"X-Org": "acme"})).json()
assert sum(1 for x in wl3["items"] if x["output_prefix"] == "renders/shot.png") == 1
await client.close()
@pytest.mark.asyncio
async def test_worklog_search_matches_paths_and_refs_not_just_prompt(tmp_path, monkeypatch):
_orgaware(tmp_path, monkeypatch)
(Path(sh.folder_paths.get_org_output_directory("acme")) / "library.json").write_text('{"assets":[]}')
# an ingested render: empty prompt, findable only by its filename / ref
sh.worklog.record("acme", kind="render", prompt="", refs=["srcphoto.png"], uploads=[],
parents=[], output_prefix="renders/model_shot.png", pid="r1", status="done")
sh.worklog.record("acme", kind="fix", prompt="brighten the sky", refs=[], uploads=[],
parents=[], output_prefix="fixes/x", pid="r2")
client = await _client(_FakeServer())
async def ids(q):
r = await client.get("/v1/worklog?q=" + q, headers={"X-Org": "acme"})
return [it["id"] for it in (await r.json())["items"]]
assert await ids("model_shot") == ["r1"] # by output filename, empty prompt
assert await ids("srcphoto") == ["r1"] # by reference
assert await ids("brighten") == ["r2"] # prompt search still works
assert await ids("nomatch") == []
await client.close()