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
feat(workbench): show fork source metadata
cyh8e89cebf94d9
diff --git a/core/services/session_fork.py b/core/services/session_fork.pyindex 3982c8aaf..f7856681e 100644--- a/core/services/session_fork.py+++ b/core/services/session_fork.py@@ -25,13 +25,17 @@ class SessionForkSpec:source_session_id: strsource_native_session_id: strsource_backend: str+ source_message_id: Optional[str] = Nonedef to_metadata(self) -> dict[str, Any]:- return {+ metadata = {"source_session_id": self.source_session_id,"source_native_session_id": self.source_native_session_id,"source_backend": self.source_backend,}+ if self.source_message_id:+ metadata["source_message_id"] = self.source_message_id+ return metadata@dataclass(frozen=True)@@ -93,6 +97,7 @@ def reserve_forked_session(raise SessionForkError(f"agent session has no native session id to fork: {source_session_id}")+ source_message_id = _latest_source_message_id(conn, str(row["id"]))override_agent = agent_store.require_enabled(agent_name) if agent_name else Noneif override_agent is not None and override_agent.backend != source_backend:@@ -118,6 +123,8 @@ def reserve_forked_session({"created_via": "session_fork","fork_source_session_id": str(row["id"]),+ "fork_source_session_title": str(row["title"] or ""),+ "fork_source_message_id": source_message_id,"fork_source_native_session_id": source_native,"fork_source_backend": source_backend,"fork_created_at": now,@@ -148,6 +155,7 @@ def reserve_forked_session(source_session_id=str(source_session_id),source_native_session_id=source_native,source_backend=source_backend,+ source_message_id=source_message_id,)return SessionForkResult(session_id=session_id,@@ -238,6 +246,27 @@ def _clean_optional(value: Any) -> Optional[str]:return text or None+def _latest_source_message_id(conn: Any, source_session_id: str) -> Optional[str]:+ from sqlalchemy import func, or_, select++ from storage.messages_service import TRANSCRIPT_TYPES+ from storage.models import messages++ row = conn.execute(+ select(messages.c.id)+ .where(+ messages.c.session_id == source_session_id,+ or_(+ messages.c.type.in_(list(TRANSCRIPT_TYPES)),+ func.json_extract(messages.c.metadata_json, "$.source") == "show_page",+ ),+ )+ .order_by(messages.c.created_at.desc(), messages.c.id.desc())+ .limit(1)+ ).scalar_one_or_none()+ return str(row) if row else None++def _fork_session_anchor(value: Any, *, source_session_id: str, now: str) -> Optional[str]:anchor = _clean_optional(value)if not anchor or anchor == source_session_id:diff --git a/tests/test_session_fork.py b/tests/test_session_fork.pyindex 83989b6d2..2b736b676 100644--- a/tests/test_session_fork.py+++ b/tests/test_session_fork.py@@ -1,5 +1,6 @@from __future__ import annotations+import jsonfrom pathlib import Pathimport pytest@@ -16,6 +17,7 @@ from core.vibe_agents import VibeAgentStorefrom modules.im import MessageContextfrom storage.agent_session_rows import create_agent_session_rowfrom storage.db import create_sqlite_engine+from storage import messages_servicefrom storage.models import agent_sessions, scope_settingsfrom storage.sessions_service import SQLiteSessionsServicefrom storage.settings_service import upsert_scope@@ -73,6 +75,32 @@ def _seed_source_session(db_path: Path, tmp_path: Path) -> str:def test_reserve_forked_session_copies_row_and_applies_overrides(tmp_path: Path) -> None:db_path = tmp_path / "vibe.sqlite"source_id = _seed_source_session(db_path, tmp_path)+ engine = create_sqlite_engine(db_path)+ try:+ with engine.begin() as conn:+ source_row = conn.execute(+ select(agent_sessions.c.scope_id).where(agent_sessions.c.id == source_id)+ ).mappings().one()+ visible_message = messages_service.append(+ conn,+ scope_id=source_row["scope_id"],+ session_id=source_id,+ platform="avibe",+ author="agent",+ message_type="result",+ text="source answer",+ )+ messages_service.append(+ conn,+ scope_id=source_row["scope_id"],+ session_id=source_id,+ platform="avibe",+ author="agent",+ message_type="assistant",+ text="hidden process log",+ )+ finally:+ engine.dispose()store = VibeAgentStore(db_path)try:store.create(name="reviewer", backend="codex", model="gpt-5.1", reasoning_effort="high")@@ -89,6 +117,7 @@ def test_reserve_forked_session_copies_row_and_applies_overrides(tmp_path: Path)assert result.session_id != source_idassert result.fork.source_native_session_id == "thread-source"+ assert result.fork.source_message_id == visible_message["id"]engine = create_sqlite_engine(db_path)try:with engine.connect() as conn:@@ -98,6 +127,7 @@ def test_reserve_forked_session_copies_row_and_applies_overrides(tmp_path: Path)finally:engine.dispose()+ metadata = json.loads(row["metadata_json"])assert row["agent_name"] == "reviewer"assert row["agent_backend"] == "codex"assert row["agent_variant"] == "codex"@@ -107,6 +137,8 @@ def test_reserve_forked_session_copies_row_and_applies_overrides(tmp_path: Path)assert row["native_session_id"] == ""assert row["session_anchor"] == result.session_idassert row["title"] == "Source"+ assert metadata["fork_source_message_id"] == visible_message["id"]+ assert metadata["fork_source_session_title"] == "Source"def test_reserve_forked_session_keeps_im_anchor_and_resets_variant_for_agent_override(tmp_path: Path) -> None:diff --git a/tests/test_ui_session_stream.py b/tests/test_ui_session_stream.pyindex 136aec761..c071c315d 100644--- a/tests/test_ui_session_stream.py+++ b/tests/test_ui_session_stream.py@@ -180,6 +180,7 @@ def test_fork_session_creates_new_workbench_session(isolated_state, tmp_path):from sqlalchemy import update+ from storage import messages_servicefrom storage.db import create_sqlite_enginefrom storage.models import agent_sessionsfrom vibe.ui_server import app@@ -192,6 +193,15 @@ def test_fork_session_creates_new_workbench_session(isolated_state, tmp_path):.where(agent_sessions.c.id == session_id).values(native_session_id="native-source-1", title="Source session"))+ source_message = messages_service.append(+ conn,+ scope_id=scope_id,+ session_id=session_id,+ platform="avibe",+ author="user",+ message_type="user",+ text="fork from here",+ )with patch("vibe.sse_broker.broker.publish") as publish:client = app.test_client()@@ -209,6 +219,8 @@ def test_fork_session_creates_new_workbench_session(isolated_state, tmp_path):assert payload["native_session_id"] == ""assert payload["metadata"]["created_via"] == "session_fork"assert payload["metadata"]["fork_source_session_id"] == session_id+ assert payload["metadata"]["fork_source_session_title"] == "Source session"+ assert payload["metadata"]["fork_source_message_id"] == source_message["id"]assert payload["metadata"]["fork_source_native_session_id"] == "native-source-1"publish.assert_called_with("session.activity",diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsxindex 9650927dc..1ce9c0b20 100644--- a/ui/src/components/workbench/ChatPage.tsx+++ b/ui/src/components/workbench/ChatPage.tsx@@ -1408,7 +1408,16 @@ const Transcript: React.FC<TranscriptProps> = ({typeof session.metadata?.fork_source_session_id === 'string'? session.metadata.fork_source_session_id: null;+ const forkSourceSessionTitle =+ typeof session.metadata?.fork_source_session_title === 'string' &&+ session.metadata.fork_source_session_title.trim()+ ? session.metadata.fork_source_session_title.trim()+ : null;const isForkedSession = session.metadata?.created_via === 'session_fork';+ const forkSourceBanner =+ isForkedSession && forkSourceSessionId ? (+ <ForkSourceBanner sourceSessionId={forkSourceSessionId} sourceTitle={forkSourceSessionTitle} />+ ) : null;const scrollRef = useRef<HTMLDivElement | null>(null);const contentRef = useRef<HTMLDivElement | null>(null);// ``true`` while the viewport is FOLLOWING the bottom (at/near it) — drives the@@ -1542,16 +1551,15 @@ const Transcript: React.FC<TranscriptProps> = ({if (empty) {if (isForkedSession && forkSourceSessionId) {return (- <div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center text-muted">- <GitFork className="size-8 opacity-70" />- <div className="max-w-[360px] text-[13px] font-semibold text-foreground">{t('chat.forkedEmptyTitle')}</div>- <div className="max-w-[440px] text-[12px] leading-relaxed">{t('chat.forkedEmptyBody')}</div>- <Link- to={`/chat/${encodeURIComponent(forkSourceSessionId)}`}- className="text-[12px] font-medium text-cyan hover:underline"- >- {t('chat.forkedSource')}- </Link>+ <div className="flex min-h-0 flex-1 flex-col px-4 py-5 md:px-8">+ <div className="mx-auto flex w-full max-w-[1080px] flex-col gap-3">+ {forkSourceBanner}+ </div>+ <div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center text-muted">+ <GitFork className="size-8 opacity-70" />+ <div className="max-w-[360px] text-[13px] font-semibold text-foreground">{t('chat.forkedEmptyTitle')}</div>+ <div className="max-w-[440px] text-[12px] leading-relaxed">{t('chat.forkedEmptyBody')}</div>+ </div></div>);}@@ -1566,6 +1574,7 @@ const Transcript: React.FC<TranscriptProps> = ({<div className="relative flex min-h-0 flex-1 flex-col"><div ref={scrollRef} onScroll={handleScroll} className="min-h-0 flex-1 overflow-y-auto px-4 py-5 [overflow-anchor:none] md:px-8"><div ref={contentRef} className="mx-auto flex w-full max-w-[1080px] flex-col gap-3">+ {forkSourceBanner}{loadingOlder && (<div className="flex h-8 items-center justify-center text-muted"><Loader2 className="size-4 animate-spin" />@@ -1601,6 +1610,32 @@ const Transcript: React.FC<TranscriptProps> = ({);};+const formatForkSourceLabel = (sourceSessionId: string, sourceTitle: string | null): string => {+ if (sourceTitle) return sourceTitle;+ if (sourceSessionId.length <= 14) return sourceSessionId;+ return `${sourceSessionId.slice(0, 8)}...${sourceSessionId.slice(-4)}`;+};++const ForkSourceBanner: React.FC<{ sourceSessionId: string; sourceTitle: string | null }> = ({+ sourceSessionId,+ sourceTitle,+}) => {+ const { t } = useTranslation();+ const sourceLabel = formatForkSourceLabel(sourceSessionId, sourceTitle);+ return (+ <div className="flex w-full justify-center">+ <Link+ to={`/chat/${encodeURIComponent(sourceSessionId)}`}+ className="inline-flex max-w-full items-center gap-2 rounded-full border border-cyan/30 bg-cyan/[0.08] px-3 py-1.5 text-[12px] text-cyan transition-colors hover:border-cyan/50 hover:bg-cyan/[0.12]"+ >+ <GitFork className="size-3.5 shrink-0" />+ <span className="shrink-0">{t('chat.forkedFromPrefix')}</span>+ <span className="min-w-0 truncate font-semibold text-foreground">{sourceLabel}</span>+ </Link>+ </div>+ );+};+// Small role avatar — a tinted rounded square with a lucide glyph, shown on the// header line above a left-aligned message bubble (IM layout). Kept on its owndiff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex b0e290ebe..68cb0d036 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -1777,6 +1777,7 @@"transcriptEmpty": "Type a message below to start the conversation","forkedEmptyTitle": "Forked session ready","forkedEmptyBody": "The native agent context was forked from the source session. This transcript starts clean and will only show new messages sent here.",+ "forkedFromPrefix": "Forked from","forkedSource": "Open source session","scrollToBottom": "Scroll to latest","streaming": "Streaming",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 7d166011d..f88e1e6c7 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -1776,6 +1776,7 @@"transcriptEmpty": "在下方输入消息开始对话","forkedEmptyTitle": "Fork 会话已创建","forkedEmptyBody": "底层 Agent 上下文已从源会话 fork 过来。这里的聊天记录从空白开始,只显示此会话里的新消息。",+ "forkedFromPrefix": "Fork 自","forkedSource": "打开源会话","scrollToBottom": "回到最新","streaming": "实时输出中",