fix(ui): document viewer back button returns to the page you came from (chat or sources)

This commit is contained in:
2026-08-22 15:26:43 -04:00
parent 8ca564cd83
commit 2485b50af0
6 changed files with 287 additions and 31 deletions
+7 -4
View File
@@ -99,10 +99,11 @@ def test_source_chip_opens_document(
chip = page.locator(".msg.brain .source-chip", has_text="kubernetes.md")
expect(chip).to_have_count(1, timeout=30_000)
# New-tab contract: same-origin viewer URL, both query values encoded
# (the path's slashes come out as %2F — exactly why encoding matters).
# New-tab contract: same-origin viewer URL, all query values encoded
# (the path's slashes come out as %2F — exactly why encoding matters),
# plus back=/ (phase 13) so the viewer's back button returns to chat.
expect(chip.first).to_have_attribute(
"href", "/document.html?source=docs&path=homelab%2Fkubernetes.md"
"href", "/document.html?source=docs&path=homelab%2Fkubernetes.md&back=%2F"
)
expect(chip.first).to_have_attribute("target", "_blank")
expect(chip.first).to_have_attribute("rel", "noopener")
@@ -112,7 +113,9 @@ def test_source_chip_opens_document(
viewer = popup_info.value
expect(viewer).to_have_url(
re.compile(
re.escape(f"{app_url}/document.html?source=docs&path=homelab%2Fkubernetes.md")
re.escape(
f"{app_url}/document.html?source=docs&path=homelab%2Fkubernetes.md&back=%2F"
)
)
)
expect(viewer.locator("#doc-title")).to_have_text("Kubernetes Homelab Cluster")