From 3ed2d3ec5fa24b4741202026b463e7654890c46a Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:22:27 +0800 Subject: [PATCH] fix(agents): fork agent sessions in remote workspaces Forking from a pane in a remote workspace always failed with "the pane is still connecting": a remote workspace's new pane is dialled asynchronously, and the fork path demanded a ready terminal to type into. It now hands the fork line to `run_when_ready`, the same land-then-run path quick launch uses. The new pane also opens in the source's directory on its own host (`spawnable_cwd`) rather than only a local one. Agents key their history by directory, so a fork started in the remote home would find nothing to branch. Panes that have ssh'd or entered WSL themselves stay excluded (tty7 holds no link to that machine), and the notification now says exactly that instead of "local panes only". --- src/ui/app.rs | 14 +++++++------- src/ui/i18n/en.rs | 5 +++-- src/ui/i18n/ja.rs | 3 +-- src/ui/i18n/mod.rs | 1 - src/ui/i18n/zh.rs | 3 +-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ui/app.rs b/src/ui/app.rs index 7ede071a..fe297981 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -5456,9 +5456,12 @@ impl Tty7App { self.activate(index, window, cx); } + // The directory the source runs in, on whichever host it runs on: an + // agent keys its history by directory, and a fork started anywhere + // else finds nothing to branch. let (cwd, shell) = { let view = source.read(cx); - (view.local_cwd(), view.shell_spec()) + (view.spawnable_cwd(), view.shell_spec()) }; let group = self.spawn_group(cwd.as_deref(), cx); let new = match new_terminal( @@ -5484,12 +5487,9 @@ impl Tty7App { return; } }; - let Some(terminal) = new.terminal() else { - log::error!("fork spawn produced a pane that is still connecting"); - window.push_notification(t(L10nKey::AppForkStillConnecting), cx); - return; - }; - terminal.read(cx).run_command_line(&cmd); + // A remote workspace's pane is still dialling here; the fork runs + // the moment it lands. + crate::ui::agent_launch::run_when_ready(&new, cmd, cx); match placement { ForkPlacement::NewTab => { diff --git a/src/ui/i18n/en.rs b/src/ui/i18n/en.rs index f88c2e9a..f8e29df7 100644 --- a/src/ui/i18n/en.rs +++ b/src/ui/i18n/en.rs @@ -1901,10 +1901,11 @@ pub fn translate_en(key: L10nKey) -> &'static str { L10nKey::AppWorktreeRemovedBranchKept => { "Removed worktree; kept branch \"{branch}\", which has unmerged commits" } - L10nKey::AppForkStillConnecting => "Could not fork: the pane is still connecting", L10nKey::AppPaneNoCodingAgent => "This pane isn't running a coding agent", L10nKey::AppForkNoCommand => "tty7 has no fork command for {name}", - L10nKey::AppForkLocalOnly => "{name} sessions can only be forked from a local pane", + L10nKey::AppForkLocalOnly => { + "{name} sessions can't be forked from inside an SSH or WSL session" + } L10nKey::AppForkNoSessionId => { "tty7 hasn't seen a {name} session id in this pane — install its hooks in Settings → Integrations" } diff --git a/src/ui/i18n/ja.rs b/src/ui/i18n/ja.rs index 650fc3a5..81da14e4 100644 --- a/src/ui/i18n/ja.rs +++ b/src/ui/i18n/ja.rs @@ -1946,11 +1946,10 @@ pub fn translate_ja(key: L10nKey) -> Option<&'static str> { L10nKey::AppWorktreeRemovedBranchKept => { "ワークツリーを削除しました。ブランチ「{branch}」には未マージのコミットがあるため残しました" } - L10nKey::AppForkStillConnecting => "フォークできませんでした: ペインはまだ接続中です", L10nKey::AppPaneNoCodingAgent => "このペインはコーディングエージェントを実行していません", L10nKey::AppForkNoCommand => "tty7 には {name} 用のフォークコマンドがありません", L10nKey::AppForkLocalOnly => { - "{name} のセッションはローカルペインからしかフォークできません" + "SSH または WSL セッション内の {name} のセッションはフォークできません" } L10nKey::AppForkNoSessionId => { "tty7 はこのペインで {name} のセッション ID を確認できていません — 設定 → 連携でフックをインストールしてください" diff --git a/src/ui/i18n/mod.rs b/src/ui/i18n/mod.rs index 3b5f1460..9d044c97 100644 --- a/src/ui/i18n/mod.rs +++ b/src/ui/i18n/mod.rs @@ -1601,7 +1601,6 @@ l10n_keys! { AppWorktreeSetupSkip, AppWorktreeNotCarried, AppWorktreeRemovedBranchKept, - AppForkStillConnecting, AppPaneNoCodingAgent, AppForkNoCommand, AppForkLocalOnly, diff --git a/src/ui/i18n/zh.rs b/src/ui/i18n/zh.rs index 22d3aeab..a705729a 100644 --- a/src/ui/i18n/zh.rs +++ b/src/ui/i18n/zh.rs @@ -1768,10 +1768,9 @@ pub fn translate_zh(key: L10nKey) -> Option<&'static str> { L10nKey::AppWorktreeRemovedBranchKept => { "已删除 worktree;分支“{branch}”有未合并的提交,已保留" } - L10nKey::AppForkStillConnecting => "无法 fork:窗格仍在连接中", L10nKey::AppPaneNoCodingAgent => "此窗格未运行编码 agent", L10nKey::AppForkNoCommand => "tty7 没有用于 {name} 的 fork 命令", - L10nKey::AppForkLocalOnly => "{name} 会话只能从本地窗格 fork", + L10nKey::AppForkLocalOnly => "无法在 SSH 或 WSL 会话里 fork {name} 会话", L10nKey::AppForkNoSessionId => { "tty7 尚未在此窗格中看到 {name} 的会话 ID,请在“设置 → 集成”中安装其 hook" }