Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(codex): derive workbench session titles (#444)
Call Whitea3eeca82b505
diff --git a/modules/agents/native_sessions/codex.py b/modules/agents/native_sessions/codex.pyindex e9bcd6167..6312b922b 100644--- a/modules/agents/native_sessions/codex.py+++ b/modules/agents/native_sessions/codex.py@@ -102,11 +102,13 @@ class CodexNativeSessionProvider(NativeSessionProvider):) -> BackendSessionTitle | None:if not self.db_path.exists():return None+ row: tuple[str | None, str | None] | None+ has_first_user_message_column = Truetry:with self._connect() as conn:row = conn.execute("""- SELECT title+ SELECT title, first_user_messageFROM threadsWHERE id = ? AND cwd = ? AND archived = 0LIMIT 1@@ -114,9 +116,41 @@ class CodexNativeSessionProvider(NativeSessionProvider):(native_session_id, working_path),).fetchone()except Exception as exc:- logger.warning("Failed to read Codex thread title %s: %s", native_session_id, exc)+ if "no such column: first_user_message" in str(exc):+ has_first_user_message_column = False+ try:+ with self._connect() as conn:+ title_row = conn.execute(+ """+ SELECT title+ FROM threads+ WHERE id = ? AND cwd = ? AND archived = 0+ LIMIT 1+ """,+ (native_session_id, working_path),+ ).fetchone()+ row = (title_row[0], None) if title_row else None+ except Exception as fallback_exc:+ logger.warning("Failed to read Codex thread title %s: %s", native_session_id, fallback_exc)+ return None+ else:+ logger.warning("Failed to read Codex thread title %s: %s", native_session_id, exc)+ return None+ if row is None:return None- title = normalize_title_text(str(row[0] or "")) if row else ""+ try:+ title_value, first_user_value = row+ except ValueError:+ title_value = row[0]+ first_user_value = None+ stored_first_user_message = normalize_title_text(str(first_user_value or ""))+ if has_first_user_message_column and stored_first_user_message:+ fallback_first_user_message = normalize_title_text(first_user_message)+ derived = normalize_title_text(first_user_message or stored_first_user_message, limit=10)+ if derived:+ return BackendSessionTitle(title=derived, source="derived_first_prompt", confidence="low")++ title = normalize_title_text(str(title_value or ""))if not title or self.is_placeholder_title(title):return Nonereturn BackendSessionTitle(title=title, source="backend", confidence="high")diff --git a/tests/test_native_session_providers.py b/tests/test_native_session_providers.pyindex 4d28fbd34..35a6796b5 100644--- a/tests/test_native_session_providers.py+++ b/tests/test_native_session_providers.py@@ -279,21 +279,22 @@ def test_codex_title_provider_reads_thread_title(tmp_path: Path) -> None:id text primary key,cwd text,archived integer,- title text+ title text,+ first_user_message text)""")conn.execute(- "insert into threads (id, cwd, archived, title) values (?, ?, ?, ?)",- ("thread_empty", "/repo", 0, ""),+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ ("thread_empty", "/repo", 0, "", ""),)conn.execute(- "insert into threads (id, cwd, archived, title) values (?, ?, ?, ?)",- ("thread_title", "/repo", 0, "Backend title"),+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ ("thread_title", "/repo", 0, "Backend title", ""),)conn.execute(- "insert into threads (id, cwd, archived, title) values (?, ?, ?, ?)",- ("thread_archived", "/repo", 1, "Archived title"),+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ ("thread_archived", "/repo", 1, "Archived title", "Archived prompt"),)provider = CodexNativeSessionProvider(db_path=str(db_path))@@ -306,6 +307,76 @@ def test_codex_title_provider_reads_thread_title(tmp_path: Path) -> None:assert title.source == "backend"+def test_codex_title_provider_prefers_derived_first_message_over_thread_title(tmp_path: Path) -> None:+ db_path = tmp_path / "state_5.sqlite"+ with sqlite3.connect(db_path) as conn:+ conn.execute(+ """+ create table threads (+ id text primary key,+ cwd text,+ archived integer,+ title text,+ first_user_message text+ )+ """+ )+ conn.execute(+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ (+ "thread_with_first_message",+ "/repo",+ 0,+ "Maybe generated title",+ "帮我检查 Codex session title",+ ),+ )++ provider = CodexNativeSessionProvider(db_path=str(db_path))++ title = provider.get_title(native_session_id="thread_with_first_message", working_path="/repo")++ assert title is not None+ assert title.title == "帮我检查 Codex"+ assert title.source == "derived_first_prompt"+ assert title.confidence == "low"+++def test_codex_title_provider_derives_when_thread_title_is_first_message(tmp_path: Path) -> None:+ db_path = tmp_path / "state_5.sqlite"+ with sqlite3.connect(db_path) as conn:+ conn.execute(+ """+ create table threads (+ id text primary key,+ cwd text,+ archived integer,+ title text,+ first_user_message text+ )+ """+ )+ conn.execute(+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ (+ "thread_prompt_title",+ "/repo",+ 0,+ " 帮我\n实现 session title 回填 ",+ " 帮我\n实现 session title 回填 ",+ ),+ )++ provider = CodexNativeSessionProvider(db_path=str(db_path))++ title = provider.get_title(native_session_id="thread_prompt_title", working_path="/repo")++ assert title is not None+ assert title.title == "帮我 实现 sess"+ assert title.source == "derived_first_prompt"+ assert title.confidence == "low"++def test_codex_title_provider_honors_codex_home(monkeypatch, tmp_path: Path) -> None:codex_home = tmp_path / "codex-home"codex_home.mkdir()@@ -317,13 +388,14 @@ def test_codex_title_provider_honors_codex_home(monkeypatch, tmp_path: Path) ->id text primary key,cwd text,archived integer,- title text+ title text,+ first_user_message text)""")conn.execute(- "insert into threads (id, cwd, archived, title) values (?, ?, ?, ?)",- ("thread_title", "/repo", 0, "CODEX_HOME title"),+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ ("thread_title", "/repo", 0, "CODEX_HOME title", ""),)monkeypatch.setenv("CODEX_HOME", str(codex_home))@@ -335,6 +407,71 @@ def test_codex_title_provider_honors_codex_home(monkeypatch, tmp_path: Path) ->assert title.title == "CODEX_HOME title"+def test_codex_title_provider_reads_legacy_schema_without_first_message(tmp_path: Path) -> None:+ db_path = tmp_path / "state_5.sqlite"+ with sqlite3.connect(db_path) as conn:+ conn.execute(+ """+ create table threads (+ id text primary key,+ cwd text,+ archived integer,+ title text+ )+ """+ )+ conn.execute(+ "insert into threads (id, cwd, archived, title) values (?, ?, ?, ?)",+ ("thread_legacy", "/repo", 0, "Legacy backend title"),+ )++ provider = CodexNativeSessionProvider(db_path=str(db_path))++ title = provider.get_title(+ native_session_id="thread_legacy",+ working_path="/repo",+ first_user_message="Caller prompt should not replace legacy title",+ )++ assert title is not None+ assert title.title == "Legacy backend title"+ assert title.source == "backend"+ assert title.confidence == "high"+++def test_codex_title_provider_preserves_title_when_first_message_column_empty(tmp_path: Path) -> None:+ db_path = tmp_path / "state_5.sqlite"+ with sqlite3.connect(db_path) as conn:+ conn.execute(+ """+ create table threads (+ id text primary key,+ cwd text,+ archived integer,+ title text,+ first_user_message text+ )+ """+ )+ conn.execute(+ "insert into threads (id, cwd, archived, title, first_user_message) values (?, ?, ?, ?, ?)",+ ("thread_sparse", "/repo", 0, "Sparse backend title", ""),+ )++ provider = CodexNativeSessionProvider(db_path=str(db_path))++ title = provider.get_title(+ native_session_id="thread_sparse",+ working_path="/repo",+ first_user_message="Caller prompt should not replace sparse title",+ )++ assert title is not None+ assert title.title == "Sparse backend title"+ assert title.source == "backend"+ assert title.confidence == "high"++def test_claude_title_provider_derives_first_10_visible_chars(tmp_path: Path) -> None:provider = ClaudeNativeSessionProvider(root=str(tmp_path / "projects"), history_path=str(tmp_path / "history.jsonl"))