Skip to content

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.

fix(agentic-ide): title a pane whose session opened with a slash command (#550)

Ruben Lütke5f04837b602e
diff --git a/jarvis/agentic_ide/agent_transcript.py b/jarvis/agentic_ide/agent_transcript.py
index 9c3baaef5c..f91e6b2aa3 100644
--- a/jarvis/agentic_ide/agent_transcript.py
+++ b/jarvis/agentic_ide/agent_transcript.py
@@ -477,6 +477,32 @@ def _text_of(content: Any) -> str:
return "\n".join(parts)
+#: What a person typed after a slash command. Claude Code records
+#: ``/goal fix the login test`` as a command block whose arguments are the
+#: request itself — inside the same kind of tag it wraps its own bookkeeping in.
+_COMMAND_ARGS = re.compile(r"<command-args>(.*?)</command-args>", re.DOTALL)
+
+#: Fewer words than this after a slash command set the command up (``high``,
+#: ``--fix``, a PR number); they do not say what the session is for.
+_COMMAND_REQUEST_WORDS = 3
+
+
+def _command_request(text: str) -> str:
+ """The request a person typed as a slash command's arguments, or "".
+
+ A session opened with ``/goal <request>`` has no plain first message: the
+ whole record is one command block, so :func:`_spoken` finds nobody
+ speaking, and the CLI writes no title of its own for it either. The
+ arguments are still the person's own words, and for such a session they
+ are the only statement of what it is about.
+ """
+ match = _COMMAND_ARGS.search(str(text or ""))
+ if match is None:
+ return ""
+ request = " ".join(match.group(1).split())
+ return request if len(request.split()) >= _COMMAND_REQUEST_WORDS else ""
+
+
def _claude_first_user_text(session_id: str, home: Path | None) -> str | None:
path = _claude_file(session_id, home)
if path is None:
@@ -485,14 +511,16 @@ def _claude_first_user_text(session_id: str, home: Path | None) -> str | None:
if str(row.get("type") or "") != "user":
continue
# A meta row is the CLI annotating the conversation (an image's size, a
- # slash command's echo); a sidechain is a sub-agent's conversation.
- # Neither is the person opening this session.
- if row.get("isMeta") or row.get("isSidechain"):
+ # slash command's echo); a sidechain is a sub-agent's conversation; a
+ # compact summary is the CLI retelling the conversation to itself.
+ # None of them is the person opening this session.
+ if row.get("isMeta") or row.get("isSidechain") or row.get("isCompactSummary"):
continue
message = row.get("message")
if not isinstance(message, dict) or str(message.get("role") or "") != "user":
continue
- spoken = _spoken(_text_of(message.get("content")))
+ text = _text_of(message.get("content"))
+ spoken = _spoken(text) or _command_request(text)
if spoken:
return spoken
return ""
diff --git a/tests/unit/agentic_ide/test_agent_transcript.py b/tests/unit/agentic_ide/test_agent_transcript.py
index ff3f8f71ac..b6fdbfeecb 100644
--- a/tests/unit/agentic_ide/test_agent_transcript.py
+++ b/tests/unit/agentic_ide/test_agent_transcript.py
@@ -239,6 +239,58 @@ class TestOpening:
"What is this button?"
)
+ def test_claude_session_opened_with_a_slash_command_is_named_by_its_request(
+ self, tmp_path: Path
+ ) -> None:
+ """``/goal <request>`` is one command block; its arguments are the request."""
+ _claude_session(
+ tmp_path,
+ "abc",
+ [
+ _msg(
+ "user",
+ "<command-name>/goal</command-name>\n"
+ " <command-message>goal</command-message>\n"
+ " <command-args>Speed up the CI pipeline\nwithout losing tests"
+ "</command-args>",
+ ),
+ _msg("user", "<local-command-stdout>Goal set: Speed up</local-command-stdout>"),
+ _msg("user", "a later question"),
+ ],
+ )
+ assert agent_transcript.first_user_text("claude", "abc", home=tmp_path) == (
+ "Speed up the CI pipeline without losing tests"
+ )
+
+ def test_claude_command_switches_and_compact_summaries_open_nothing(
+ self, tmp_path: Path
+ ) -> None:
+ _claude_session(
+ tmp_path,
+ "abc",
+ [
+ _msg(
+ "user",
+ "<command-name>/code-review</command-name>"
+ "<command-message>code-review</command-message>"
+ "<command-args>high</command-args>",
+ ),
+ _msg("user", "<command-name>/clear</command-name><command-args></command-args>"),
+ {
+ "type": "user",
+ "isCompactSummary": True,
+ "message": {
+ "role": "user",
+ "content": "This session is being continued from a previous conversation.",
+ },
+ },
+ _msg("user", "Fix the sidebar"),
+ ],
+ )
+ assert agent_transcript.first_user_text("claude", "abc", home=tmp_path) == (
+ "Fix the sidebar"
+ )
+
def test_a_missing_file_is_none_and_a_silent_one_is_empty(self, tmp_path: Path) -> None:
assert agent_transcript.first_user_text("claude", "abc", home=tmp_path) is None
_claude_session(tmp_path, "abc", [{"type": "queue-operation"}])