Skip to content

远程 Codex App 会话被误识别为 Codex CLI,无法跳转并提示 thread not loaded #273

Description

@Akemi-Homura

环境

  • Ping Island:v0.26.0
  • macOS:Apple Silicon
  • 本机:Ping Island + Codex App
  • 远程主机:Linux x86_64
  • 远程 Codex:0.145.0
  • Codex App 已通过 Remote/Connected Host 打开远程项目和任务
  • Ping Island 已配置同一远程主机,Bridge、SSH 转发和 Hooks 均已正常工作

问题描述

远程 Hook 问题解决后,Ping Island 已经能够收到并显示由 Codex App 在远程主机上运行的任务,但该任务被识别为 Codex CLI

点击 Ping Island 中的远程任务卡片时,无法跳转到 Codex App 中已经存在的对应任务窗口;在 Ping Island 内尝试继续发送消息时,会显示:

thread not loaded: <已脱敏的 thread id>

Codex App 中确实存在同一个远程任务,并且使用相同 thread ID 直接导航可以正常打开,因此不是任务不存在或 thread ID 错误。

复现步骤

  1. 在 macOS Codex App 中连接一台远程主机。
  2. 在 Codex App 中基于该远程主机启动一个任务。
  3. 确认 Ping Island 已连接同一远程主机,并能收到该任务的 Hook 事件。
  4. 在 Ping Island 会话列表中找到该远程任务。
  5. 点击任务卡片,尝试跳转到 Codex App。
  6. 在 Ping Island 的消息输入框中尝试继续该任务。

实际结果

  1. Ping Island 能显示远程任务的标题、目录、状态和最新消息。
  2. 点击任务卡片后,不能跳转到 Codex App 中已存在的对应任务。
  3. Ping Island 会尝试按远程 SSH/终端会话处理,但该任务实际上由 Codex App 的远程 Host 管理。
  4. 在 Ping Island 中继续发送消息时提示 thread not loaded
  5. 部分已完成或空闲的任务仍可能显示为 waitingForInput

关键诊断信息

Ping Island 保存的会话关联中出现了互相矛盾的客户端信息:

{
  "kind": "codexCLI",
  "profileID": "codex-app",
  "origin": "desktop",
  "transport": "ssh"
}

其中用户名、主机名、项目路径、真实 thread ID 和会话文件路径均已删除。

进一步验证:

  • Codex App 的任务列表中存在相同 thread ID,Host 类型为远程主机;
  • 使用 codex://threads/<thread-id> 可以正确打开 Codex App 中的对应远程任务;
  • 当前任务在 Codex App 中状态为 idle,不是丢失或损坏;
  • Ping Island 的后台 SSH Bridge 没有交互式 TTY,因此不能作为需要聚焦的终端窗口。

源码层面的可能原因

1. Codex 客户端类型合并时 CLI 优先

SessionStore.normalizedCodexClientInfo 中,只要 incoming 或 restored 的 kindcodexCLI,就会使用 SessionClientInfo.codexCLI() 作为基础:

https://github.com/erha19/ping-island/blob/v0.26.0/PingIsland/Services/State/SessionStore.swift#L4686-L4705

这会导致 profileID=codex-apporigin=desktop 的远程 Codex App 任务仍被固定为 codexCLI

2. codexCLI 会关闭 Codex App 导航

SessionClientInfo.prefersAppNavigationcodexCLI 直接返回 false

https://github.com/erha19/ping-island/blob/v0.26.0/PingIsland/Models/SessionProvider.swift#L545-L550

随后 SessionLauncher 会因为该会话是远程会话而优先尝试查找交互式 SSH Carrier:

https://github.com/erha19/ping-island/blob/v0.26.0/PingIsland/Services/Window/SessionLauncher.swift#L26-L50

但这类任务实际应使用 Codex App 已支持的:

codex://threads/<thread-id>

3. 继续消息可能发送给了错误的 app-server

sendSessionMessagecodexAppServer 会话调用 CodexAppServerMonitor.shared.continueThread

https://github.com/erha19/ping-island/blob/v0.26.0/PingIsland/Services/Session/SessionMonitor.swift#L698-L756

对于由 Codex App 远程 Host 管理的任务,本机 Ping Island 当前连接的 app-server 未加载该远程 thread,因此返回 thread not loaded

期望结果

  1. 当会话具有 profileID=codex-apporigin=desktop,并且对应 thread 已存在于 Codex App 的远程 Host 时,应识别为 codexApp,而不是 codexCLI
  2. 即使 transport=ssh,点击任务卡片也应优先使用 codex://threads/<thread-id> 打开 Codex App 中的对应任务。
  3. 如果 Ping Island 暂时不能把消息路由到远程 Host 对应的 app-server,应禁用输入框或提示“请在 Codex App 中继续”,而不是调用本地 app-server 后显示 thread not loaded
  4. 已完成或空闲任务的状态应与 Codex App 保持一致,避免继续显示 waitingForInput

与现有 Issue 的关系

该问题是在 #271 的远程会话不可见问题排查后发现的后续问题。

目前远程 Bridge、Hooks 和 SSH 转发已经正常,Ping Island 可以显示远程任务;本 Issue 聚焦的是:

  • 远程 Codex App 任务被错误分类为 Codex CLI;
  • 点击任务无法跳转到 Codex App;
  • 后续消息被发送到错误的 app-server。

隐私说明

以上内容已删除用户名、主机名、域名、IP、项目名称、具体路径、真实 thread ID、截图及原始日志。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions