fix(backend): include context_id in report fetch API to prevent fallback context mismatch in chat

This commit is contained in:
lidf 2026-04-12 16:01:19 +08:00
parent bcdd6e36ff
commit 2f7dd95699

View File

@ -971,7 +971,7 @@ xray.module5: track1(数组,每项含node/action/strategy/purpose), track2(数
db = SessionDB() db = SessionDB()
with db._lock: with db._lock:
cursor = db._conn.execute( cursor = db._conn.execute(
"SELECT report_json, created_at, client_id FROM deepview_reports_v2 WHERE report_id = ?", "SELECT report_json, created_at, client_id, context_id FROM deepview_reports_v2 WHERE report_id = ?",
(reportId,) (reportId,)
) )
row = cursor.fetchone() row = cursor.fetchone()
@ -981,10 +981,12 @@ xray.module5: track1(数组,每项含node/action/strategy/purpose), track2(数
reportData = json.loads(row[0]) reportData = json.loads(row[0])
clientId = row[2] clientId = row[2]
contextId = row[3]
# Hot patch reportCode for older generated reports that might have hallucinated ones # Hot patch reportCode for older generated reports that might have hallucinated ones
reportData["reportCode"] = f"DW-AMXG-{reportId[4:].upper()}" reportData["reportCode"] = f"DW-AMXG-{reportId[4:].upper()}"
reportData["id"] = reportId reportData["id"] = reportId
reportData["context_id"] = contextId
# Attach clientId into the data payload so the frontend knows if it's archived # Attach clientId into the data payload so the frontend knows if it's archived
if clientId: if clientId: