Fix Codex fork session reporting with standalone startup

This commit is contained in:
2026-10-23 03:21:59 +00:00
parent 8cac4370bf
commit fbd3da715a
3 changed files with 26 additions and 4 deletions
+10 -1
View File
@@ -91,7 +91,9 @@ class ForkSource:
@property
def arguments(self) -> list[str]:
if self.kind == "codex":
return ["fork", self.session_id]
# A shared Codex server can retain another pane's Herdr environment.
# Keep the fork and its session-reporting hooks in the new pane.
return ["--no-daemon", "fork", self.session_id]
return ["--resume", self.session_id, "--fork-session"]
@@ -116,9 +118,16 @@ def parse_snapshot(payload: object) -> ForkSource:
raise ControlError(f"暂不支持 Fork {kind};支持 Codex / Claude")
session = pane.get("agent_session")
if not isinstance(session, dict):
recovery = (
"\n若 Codex 集成已安装,共享后台服务可能沿用了旧 pane 环境。"
"可在新 Herdr Tab 中运行 codex --no-daemon fork,选择原会话;"
"发送首条消息后按 Ctrl+R 重读。"
if kind == "codex" else ""
)
raise ControlError(
f"当前 {kind.capitalize()} 尚未向 Herdr 上报会话 ID,暂时无法 Fork。\n"
f"在目标主机检查 herdr integration status;确认集成已加载后按 Ctrl+R 重读。"
f"{recovery}"
)
if session.get("kind") != "id" or session.get("agent") != kind:
raise ControlError("当前 Agent 尚未报告可 Fork 的 conversation ID")