feat(conversations): pre-SDK rows read from canonical messages, implied titles, markdown adopts them by first prompt
This commit is contained in:
@@ -392,6 +392,7 @@ class MarkdownFrontend(Frontend):
|
||||
metadata=parsed.metadata,
|
||||
agent_name=agent.name,
|
||||
file_path=file_path,
|
||||
first_user_text=parsed.turns[0].text,
|
||||
)
|
||||
outcome = diff_and_fork(stored=stored_msgs, incoming=parsed.turns)
|
||||
capture = TurnCapture()
|
||||
@@ -587,6 +588,7 @@ class MarkdownFrontend(Frontend):
|
||||
metadata=parsed.metadata,
|
||||
agent_name=agent.name,
|
||||
file_path=file_path,
|
||||
first_user_text=parsed.turns[0].text,
|
||||
)
|
||||
except HTTPException as exc:
|
||||
yield sse_pack(
|
||||
@@ -823,13 +825,15 @@ class MarkdownFrontend(Frontend):
|
||||
metadata: dict[str, Any],
|
||||
agent_name: str,
|
||||
file_path: Path,
|
||||
first_user_text: str = "",
|
||||
) -> tuple[Conversation, str, list[dict[str, Any]]]:
|
||||
"""Resolve the ``deep`` conversation for this file + its stored messages.
|
||||
|
||||
Frontmatter ``conversation_id`` wins; a file that lost it is found
|
||||
by its visible ``(markdown, path)`` binding; otherwise a new
|
||||
conversation is created. The binding follows the file: a moved
|
||||
chat re-binds to its new path on the next turn.
|
||||
by its visible ``(markdown, path)`` binding, then by adopting the
|
||||
one unbound pre-SDK conversation that starts with the same prompt;
|
||||
otherwise a new conversation is created. The binding follows the
|
||||
file: a moved chat re-binds to its new path on the next turn.
|
||||
"""
|
||||
conversations = runtime.conversations
|
||||
rel = file_path.relative_to(self.vault_path).as_posix()
|
||||
@@ -837,6 +841,12 @@ class MarkdownFrontend(Frontend):
|
||||
conv = await conversations.get(raw) if isinstance(raw, str) and raw else None
|
||||
if conv is None:
|
||||
conv = await conversations.find_bound(frontend=FRONTEND, external_id=rel)
|
||||
if conv is None:
|
||||
conv = await conversations.adopt(
|
||||
kind="deep", first_user_text=first_user_text
|
||||
)
|
||||
if conv is not None:
|
||||
_log.info("adopted conversation %s for %s", conv.external_id, rel)
|
||||
if conv is None:
|
||||
try:
|
||||
conv = await conversations.create(
|
||||
|
||||
Reference in New Issue
Block a user