feat: map run citation to run_<uuid> payload

This commit is contained in:
CREDO23 2026-07-22 19:34:56 +02:00
parent 609adea006
commit 81f2d694bd

View file

@ -1,10 +1,11 @@
"""Map a registered citation to the frontend ``[citation:<payload>]`` payload. """Map a registered citation to the frontend ``[citation:<payload>]`` payload.
The citation renderer understands a chunk id (``42``), a negative chunk id for The citation renderer understands a chunk id (``42``), a negative chunk id for
anonymous uploads (``-3``), and a URL. This is the seam that turns a server-side anonymous uploads (``-3``), a URL, and a scraper-run handle (``run_<uuid>``).
source into one the renderer can resolve; it grows as more source kinds become This is the seam that turns a server-side source into one the renderer can
renderable. Kinds with no renderable form yet return ``None`` so the marker is resolve; it grows as more source kinds become renderable. Kinds with no
dropped rather than emitted broken. renderable form yet return ``None`` so the marker is dropped rather than
emitted broken.
""" """
from __future__ import annotations from __future__ import annotations
@ -22,6 +23,9 @@ def to_frontend_payload(entry: CitationEntry) -> str | None:
case CitationSourceType.WEB_RESULT: case CitationSourceType.WEB_RESULT:
url = locator.get("url") url = locator.get("url")
return url or None return url or None
case CitationSourceType.RUN:
run_id = locator.get("run_id")
return str(run_id) if run_id else None
case _: case _:
# Connector items and chat turns have no client-side renderer yet # Connector items and chat turns have no client-side renderer yet
# (the frontend resolves only chunk ids and URLs), so they stay # (the frontend resolves only chunk ids and URLs), so they stay