deploy.sh only reads the sidecar's custom title override, which most conversations never set, so the banner always said "Untitled conversation". /api/deploy-status now looks the session up in the index: the title the list shows (override, else ai-title) and the in-app conversationId. Hidden from a guest who can't see that conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
"""core.routes._attach_conversation: the deploy banner's conversation title is
|
|
resolved from the snapshot's session id (the sidecar override, else the parsed
|
|
ai-title), not trusted from the script — which only ever saw the override."""
|
|
|
|
import os
|
|
import tempfile
|
|
from types import SimpleNamespace
|
|
|
|
# Imported lazily: other test modules point the app's paths at a throwaway
|
|
# dir before their own (module-level) import of it, and core.config reads them
|
|
# once — importing it here at collection time would pin the defaults first.
|
|
os.environ.setdefault("TRANSCRIPTS_DIR", tempfile.mkdtemp())
|
|
|
|
SID = "f7baa782-0000-4000-8000-000000000001"
|
|
|
|
|
|
def _attach(deps, caller, snap):
|
|
from core.routes import _attach_conversation
|
|
_attach_conversation(deps, caller, snap)
|
|
|
|
|
|
def _owner():
|
|
from users.caller import OWNER
|
|
return OWNER
|
|
|
|
|
|
def _deps(meta: dict | None = None):
|
|
from core import config
|
|
ROOT = str(config.TRANSCRIPTS_DIR)
|
|
summaries = [
|
|
(f"{ROOT}/-home-x/{SID}.jsonl",
|
|
{"sessionId": SID, "title": "Fix the deploy banner", "endedAt": "2026-10-12T10:00:00Z"}),
|
|
(f"{ROOT}/-home-x/{SID}/subagents/agent-a.jsonl",
|
|
{"sessionId": SID, "title": "subagent", "endedAt": "2026-10-12T11:00:00Z"}),
|
|
(f"{ROOT}/-home-x/other.jsonl", {"sessionId": "other", "title": "Other"}),
|
|
]
|
|
metas = {SID: meta or {}}
|
|
return SimpleNamespace(
|
|
store=SimpleNamespace(all_summaries=lambda: summaries),
|
|
meta_store=SimpleNamespace(peek=lambda sid: metas.get(sid, {})),
|
|
)
|
|
|
|
|
|
def _snap():
|
|
return {"sessionId": SID, "convTitle": None,
|
|
"convUrl": "https://ai-agent.lab.gabvdl.xyz/conversation/x/y.jsonl"}
|
|
|
|
|
|
def test_resolves_the_parsed_title_and_conversation_id():
|
|
snap = _snap()
|
|
_attach(_deps(), _owner(), snap)
|
|
assert snap["convTitle"] == "Fix the deploy banner"
|
|
assert snap["conversationId"] == f"-home-x/{SID}.jsonl"
|
|
|
|
|
|
def test_a_renamed_conversation_shows_its_custom_title():
|
|
snap = _snap()
|
|
_attach(_deps({"title": "Renamed"}), _owner(), snap)
|
|
assert snap["convTitle"] == "Renamed"
|
|
|
|
|
|
def test_unknown_session_keeps_the_script_stamp():
|
|
snap = {"sessionId": "nope", "convTitle": "From script"}
|
|
_attach(_deps(), _owner(), snap)
|
|
assert snap["convTitle"] == "From script"
|
|
assert "conversationId" not in snap
|
|
|
|
|
|
def test_a_guest_who_cannot_see_it_gets_no_title_or_link():
|
|
from users.caller import guest_from_record
|
|
guest = guest_from_record({"id": "g1"})
|
|
snap = _snap()
|
|
_attach(_deps(), guest, snap)
|
|
assert snap["convTitle"] is None and snap["convUrl"] is None
|
|
assert "conversationId" not in snap
|