refactor(webui): shrink fork implementation

This commit is contained in:
Xubin Ren
2026-06-10 04:26:06 +08:00
parent 1f926e3769
commit 916525f94a
24 changed files with 134 additions and 879 deletions
+6 -5
View File
@@ -696,22 +696,23 @@ class WebSocketChannel(BaseChannel):
if forked is None:
await self._send_event(connection, "error", detail="invalid fork source or index")
return
fork_id, fork_key = forked
except Exception as exc:
self.logger.warning("fork_chat failed: {}", exc)
await self._send_event(connection, "error", detail="fork_chat_failed")
return
scope = self._workspaces.scope_for_session_key(forked.session_key)
self._attach(connection, forked.chat_id)
await self._send_event(connection, "attached", chat_id=forked.chat_id)
scope = self._workspaces.scope_for_session_key(fork_key)
self._attach(connection, fork_id)
await self._send_event(connection, "attached", chat_id=fork_id)
await self._send_event(
connection,
"session_updated",
chat_id=forked.chat_id,
chat_id=fork_id,
scope="metadata",
workspace_scope=scope.payload(),
)
await self._hydrate_after_subscribe(forked.chat_id)
await self._hydrate_after_subscribe(fork_id)
return
if t == "attach":
cid = envelope.get("chat_id")