Merge remote-tracking branch 'origin/master' into fix/chunk-context-indexed-lookup

# Conflicts:
#	nextcloud_mcp_server/api/visualization.py
#	nextcloud_mcp_server/auth/viz_routes.py
This commit is contained in:
Chris Coutinho
2026-05-08 23:10:09 +02:00
27 changed files with 1728 additions and 282 deletions
+14 -22
View File
@@ -623,8 +623,10 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
f"after_len={len(chunk_context.after_context)}"
)
# For PDF files, also fetch the highlighted page image from Qdrant
highlighted_page_image = None
# For PDF files, also fetch the chunk bbox from Qdrant so the client
# can overlay a highlight on top of a render-on-demand page image
# (Deck #76).
chunk_bbox = None
page_number = chunk_context.page_number
if doc_type == "file":
try:
@@ -632,7 +634,7 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
qdrant_client = await get_qdrant_client()
username = request.user.display_name
# Prefer chunk_index for the highlighted-image lookup (always indexed);
# Prefer chunk_index for the chunk-bbox lookup (always indexed);
# fall back to (chunk_start_offset, chunk_end_offset) when not provided.
if chunk_index is not None:
points_response = await qdrant_client.scroll(
@@ -646,10 +648,6 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
FieldCondition(
key="user_id", match=MatchValue(value=username)
),
FieldCondition(
key="doc_type",
match=MatchValue(value=doc_type),
),
FieldCondition(
key="chunk_index",
match=MatchValue(value=chunk_index),
@@ -658,7 +656,7 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
),
limit=1,
with_vectors=False,
with_payload=["highlighted_page_image", "page_number"],
with_payload=["chunk_bbox", "page_number"],
)
else:
points_response = await qdrant_client.scroll(
@@ -672,10 +670,6 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
FieldCondition(
key="user_id", match=MatchValue(value=username)
),
FieldCondition(
key="doc_type",
match=MatchValue(value=doc_type),
),
FieldCondition(
key="chunk_start_offset",
match=MatchValue(value=start),
@@ -688,22 +682,20 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
),
limit=1,
with_vectors=False,
with_payload=["highlighted_page_image", "page_number"],
with_payload=["chunk_bbox", "page_number"],
)
points = points_response[0]
if points and points[0].payload:
highlighted_page_image = points[0].payload.get(
"highlighted_page_image"
)
chunk_bbox = points[0].payload.get("chunk_bbox")
page_number = points[0].payload.get("page_number")
if highlighted_page_image:
if chunk_bbox:
logger.info(
f"Found highlighted image for chunk: "
f"page={page_number}, image_size={len(highlighted_page_image)}"
f"Found chunk bbox: page={page_number}, "
f"rects={len(chunk_bbox)}"
)
except Exception as e:
logger.warning(f"Failed to fetch highlighted image: {e}")
logger.warning(f"Failed to fetch chunk bbox: {e}")
# Return response compatible with frontend expectations
response_data: dict = {
@@ -718,8 +710,8 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
"total_chunks": chunk_context.total_chunks,
}
if highlighted_page_image:
response_data["highlighted_page_image"] = highlighted_page_image
if chunk_bbox:
response_data["chunk_bbox"] = chunk_bbox
return JSONResponse(response_data)