Skip to content

fix(codex): resume catalog sessions with the catalog's CODEX_HOME; add main-content terminal placement - #120708

Merged
steipete merged 2 commits into
mainfrom
steipete/priceless-burnell-907e5e
Aug 8, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/priceless-burnell-907e5e

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening a Codex session from the Control UI session catalog into a terminal failed with:

ERROR: No saved session found with ID <threadId>. Run `codex resume` without an ID to choose from existing sessions.

Additionally, the terminal only rendered as a bottom/right dock strip; a resumed session could not occupy the main content area like the transcript viewer does.

Why This Change Was Made

Bug root cause: the Codex session catalog lists threads through the plugin's supervision app-server connection, which can run on the agent-scoped Codex home (plugins.entries.codex.config.appServer.homeScope: "agent" → <agentDir>/codex-home). Verified on a live gateway: the failing thread existed in the agent home's state_5.sqlite and sessions tree, not in ~/.codex. The terminal plan spawned a bare codex resume <threadId> under the operator login shell env, so the CLI resolved its default ~/.codex (codex-rs/utils/home-dir) and correctly reported no such session. The catalog knew which CODEX_HOME it listed from and discarded that fact before the spawn — an env ownership gap on both the gateway-local and paired-node PTY paths.

Fix shape: record the fact where it is produced. SessionCatalogTerminalPlan (local variant) gains a bounded env map; openCodexCatalogTerminal resolves the supervision connection's home and pins CODEX_HOME on local and node resume plans; the gateway merges plan env into the PTY spawn; runNodePtyCommand accepts env overrides. The home-scope resolution that existed in three copies (auth-bridge startup, cache-key identity, and now the terminal) is consolidated into one shared resolveCodexAppServerLocalHomeDir, so the terminal cannot drift from what the app-server actually used.

Main-pane terminal: the dock system gains a third placement "main" alongside bottom/right — the panel fills the content region next to the sidebar (no resize divider; routed content stays mounted underneath). A three-way placement switcher in the panel header persists through the existing openclaw.terminal.panel.v1 store. Opening a session from the catalog selects main mode so a resumed session comes up as a full window. Named tradeoff (commented): main mode ignores sibling dock reservations; a right-docked browser/custodian panel overlays rather than shrinks it.

User Impact

  • "Open in terminal" on a catalog Codex session now resumes the correct session on gateways using agent-scoped Codex homes (the default supervision scope on stdio transports resolves to the user home, so ~/.codex setups keep working unchanged — startOptions.env.CODEX_HOME still wins when set).
  • The terminal can now act as the primary window: catalog-opened sessions fill the main content area, and the mode is switchable/persistent from the panel header.

Evidence

Focused suites (via node scripts/run-vitest.mjs), all green:

  • extensions/codex/src/session-catalog.test.ts — 99 passed (new: agent-home vs user-home plan env, node PTY CODEX_HOME injection)
  • src/gateway/server-methods/terminal.test.ts — 24 passed (spawn env contains plan CODEX_HOME and preserves pathEnv PATH)
  • src/node-host/pty-command.test.ts — 3 passed (env override precedence, TERM/OPENCLAW_TERMINAL markers)
  • ui/src/components/{dock-panel-layout,terminal/terminal-panel,terminal/terminal-panel-suppression,terminal/terminal-panel-accessibility}.test.ts — 37 passed (main-mode persistence round-trip, no resizer in main mode, catalog-open forcing main, settings-takeover suppression, switcher a11y labels)

Gates: pnpm plugin-sdk:surface:check green, i18n baseline green, git diff --check clean, changed-files check gate green (remote routing unavailable; documented trusted-source local fallback used). Codex autoreview (gpt-5.6-sol, high): clean, no accepted/actionable findings.

Dependency proof: codex resume id lookup path read directly in sibling ../codex checkout — codex-rs/tui/src/lib.rs (lookup_session_target_with_app_server → thread/read), codex-rs/app-server/src/request_processors/thread_processor.rs (read_thread_view), codex-rs/thread-store/src/local/read_thread.rs (resolve_rollout_path scoped to config.codex_home) — confirming resume resolution is strictly CODEX_HOME-scoped.

Production LOC: +93 net (new placement + env ownership boundary; resolver consolidation nets negative inside the codex plugin). Tests: +141.

The Codex session catalog lists threads through the plugin's supervision
app-server connection, which can run on the agent-scoped Codex home
(homeScope: "agent"). The terminal resume plan spawned a bare
'codex resume <threadId>' under the operator login shell, so the CLI
resolved its default ~/.codex and failed with "No saved session found".

Terminal plans now carry the catalog connection's CODEX_HOME (local and
paired-node paths), the gateway merges plan env into the PTY spawn, and
the triplicated home-scope resolution collapses into one shared
resolveCodexAppServerLocalHomeDir.
The terminal panel gains a third dock placement, "main", filling the
content region next to the sidebar like the transcript pane. The panel
header gets a bottom/right/main placement switcher (persisted in the
existing openclaw.terminal.panel.v1 store), and opening a Codex/Claude
session from the session catalog selects main mode so resumed sessions
appear as a full window instead of a bottom strip.
@steipete
steipete marked this pull request as ready for review August 8, 2026 21:15
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime extensions: codex size: M maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete
steipete merged commit 909509a into main Aug 8, 2026
181 of 183 checks passed
@steipete
steipete deleted the steipete/priceless-burnell-907e5e branch August 8, 2026 21:33
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
…d main-content terminal placement (openclaw#120708)

* fix(codex): pin catalog CODEX_HOME onto terminal resume spawns

The Codex session catalog lists threads through the plugin's supervision
app-server connection, which can run on the agent-scoped Codex home
(homeScope: "agent"). The terminal resume plan spawned a bare
'codex resume <threadId>' under the operator login shell, so the CLI
resolved its default ~/.codex and failed with "No saved session found".

Terminal plans now carry the catalog connection's CODEX_HOME (local and
paired-node paths), the gateway merges plan env into the PTY spawn, and
the triplicated home-scope resolution collapses into one shared
resolveCodexAppServerLocalHomeDir.

* feat(ui): add main-content terminal placement

The terminal panel gains a third dock placement, "main", filling the
content region next to the sidebar like the transcript pane. The panel
header gets a bottom/right/main placement switcher (persisted in the
existing openclaw.terminal.panel.v1 store), and opening a Codex/Claude
session from the session catalog selects main mode so resumed sessions
appear as a full window instead of a bottom strip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant