Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(threads): name a coding thread right after its first message (#1101)
Ruben Lütkee427a48408fc
diff --git a/dodaios/sessions/chat_titles.py b/dodaios/sessions/chat_titles.pyindex 321b92951a..cb163fbaa7 100644--- a/dodaios/sessions/chat_titles.py+++ b/dodaios/sessions/chat_titles.py@@ -122,7 +122,7 @@ _LEAD_IN_RE = re.compile(r"(?:kannst|könntest|kannste|würdest|kann(?:st)?)\s+du"r"(?:\s+(?:mir|für\s+mich|bitte|mal|eben|kurz|schnell|einfach|nochmal|auch|ganz))*|"r"ich\s+(?:möchte|will|würde\s+gerne?|hätte\s+gerne?)(?:\s+(?:bitte|gerne?|jetzt))*"- r",?\s+dass\s+du(?:\s+(?:mir|für\s+mich|bitte|mal|kurz|einfach))*|"+ r",?\s+dass(?:\s+du)?(?:\s+(?:mir|für\s+mich|bitte|mal|kurz|einfach))*|"r"(?:can|could|would|will)\s+you(?:\s+(?:please|just|quickly|maybe))*|"r"(?:puedes|podrías)(?:\s+por\s+favor)?|"r"(?:podes|poderias|consegues)(?:\s+por\s+favor)?|ajuda-me|por\s+favor|"@@ -415,6 +415,10 @@ class TitleRequest:#: For typed chats: the title the store derives from a first message, so a#: title the user typed themselves is recognised and kept.auto_title: Callable[[str], str] | None = field(default=None, compare=False)+ #: Named by the model from its opening message, before it settles — the+ #: way a coding CLI names a terminal session a moment after the first+ #: prompt. Only the first name: a renewal still waits until it is quiet.+ name_early: bool = Falsedef _first_guess(req: TitleRequest) -> str:@@ -502,9 +506,12 @@ class ChatTitler:return outdef _wants_model(self, req: TitleRequest, entry: TitleEntry | None) -> bool:- if not req.settled or time.monotonic() < self._quiet_until:+ if time.monotonic() < self._quiet_until:return False- if entry is None or entry.writer == WRITER_RULES:+ unnamed = entry is None or entry.writer == WRITER_RULES+ if not req.settled and not (req.name_early and unnamed):+ return False+ if unnamed:return entry is None or entry.attempts < MODEL_ATTEMPTS_PER_ITEMif entry.writer == WRITER_USER or entry.seed != req.seed:return Falsediff --git a/dodaios/ui/web/agent_chat_routes.py b/dodaios/ui/web/agent_chat_routes.pyindex 0aaa4337ef..016cf6228d 100644--- a/dodaios/ui/web/agent_chat_routes.py+++ b/dodaios/ui/web/agent_chat_routes.py@@ -1014,7 +1014,8 @@ def _title_chats(request: Request, svc: Any, rows: list[dict[str, Any]]) -> NoneThe ``jarvis`` surface — the front page's own history — and the ``agent``surface — the IDE's threads — are retitled. A thread whose coding CLI namedthe conversation itself keeps that name (``cli_title``); Claude Code in- print mode never writes one, so most threads are named here. A title the+ print mode never writes one, so most threads are named here — right after+ their first message, the way the CLI names a terminal pane. A title theuser typed is recognised by the titler and kept."""from dodaios.agent_chat.store import _title_from@@ -1052,6 +1053,9 @@ def _title_chats(request: Request, svc: Any, rows: list[dict[str, Any]]) -> Noneseed=str(row.get("title") or ""),loader=load,auto_title=_title_from,+ # A thread is named a moment after its first message, as its CLI+ # names a terminal pane — not only once the agent has gone quiet.+ name_early=surface == "agent",))if not requests:returndiff --git a/tests/unit/sessions/test_chat_titles.py b/tests/unit/sessions/test_chat_titles.pyindex c99f9fa2ee..f0465a99b2 100644--- a/tests/unit/sessions/test_chat_titles.py+++ b/tests/unit/sessions/test_chat_titles.py@@ -175,6 +175,42 @@ def test_unsettled_chats_get_rules_only() -> None:assert brain.prompts == []+def _thread(user: list[str], *, settled: bool) -> TitleRequest:+ return TitleRequest(+ kind=chat_titles.KIND_TYPED, conv_id="thread", version=str(len(user)),+ message_count=len(user), updated_ms=1, settled=settled, seed=user[0],+ loader=lambda: [("user", text) for text in user],+ auto_title=lambda text: text, name_early=True,+ )+++def test_a_running_thread_is_named_from_its_first_message() -> None:+ brain = _ScriptedBrain("1: Terminaltitel im Thread-Modus")+ titler = _titler(brain)+ request = _thread(["Hallo, die Terminaltitel im Thread-Modus sind schlecht"], settled=False)+ titler.titles_for([request])+ _drain_queue(titler)+ assert titler.titles_for([request]) == {("agent", "thread"): "Terminaltitel im Thread-Modus"}+ assert len(brain.prompts) == 1+++def test_a_running_thread_is_not_renamed_until_it_settles() -> None:+ brain = _ScriptedBrain("1: First name")+ titler = _titler(brain)+ titler.titles_for([_thread(["Fix the login test"], settled=False)])+ _drain_queue(titler)+ grown = _thread(["Fix the login test", "a", "b", "c", "d", "e"], settled=False)+ titler.titles_for([grown])+ _drain_queue(titler)+ assert titler.titles_for([grown]) == {("agent", "thread"): "First name"}+ assert len(brain.prompts) == 1+++def test_a_wish_for_something_keeps_what_is_wished() -> None:+ title = tidy_title(["Hallo, ich möchte bitte, dass wenn Sub-Agents gespawnt werden"])+ assert title == "Wenn Sub-Agents gespawnt werden"++def test_without_a_subscription_the_rules_title_stands() -> None:titler = _titler(None)request = _voice("a", ["Hallo", "Kannst du bitte das Wetter prüfen"])