Fix Codex title MCP startup and remote terminal spawning#618
Fix Codex title MCP startup and remote terminal spawning#618SmallSpider0 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Findings
-
[Major] Standalone installs now require an undeclared
nodeexecutable for Codex MCP — the returned MCP server always runsnode -e ..., while repo docs list Homebrew/prebuilt standalone installs and do not list Node as a runtime requirement for Codex/HAPI. On a standalone HAPI install with Codex available but nonodeonPATH, the HAPI MCP bridge fails before the childhapi mcpprocess can start. Evidencecli/src/codex/utils/buildHapiMcpBridge.ts:102.
Suggested fix:const nodeCommand = resolveNodeExecutable(); const hapiMcpServer = nodeCommand ? { command: nodeCommand, args: ['-e', HAPI_MCP_STDIO_PROXY_SCRIPT, bridgeCommand.command, ...bridgeCommand.args] } : bridgeCommand;
-
[Major] macOS remote terminals no longer get a PTY —
resolveTerminalCommand()excludes Darwin from thescript(1)path and thencreatePipeTerminal()spawns the shell with plain pipes, so interactive shells/apps have no controlling TTY on a documented supported platform. Evidencecli/src/terminal/TerminalManager.ts:84.
Suggested fix:if (process.platform === 'darwin') { return this.createBunTerminal(terminalId, cols, rows, cwd, shell); } return this.createPipeTerminal(terminalId, cols, rows, cwd, shell);
-
[Major] Resize events are acknowledged but never applied to the running PTY — mutating the parent
envobject after spawn does not update the child process or thescript(1)pseudo-terminal window size, so full-screen tools and line wrapping stay at the original dimensions after web/mobile resize. Evidencecli/src/terminal/TerminalManager.ts:214.
Suggested fix:resize: (nextCols: number, nextRows: number) => { pty.resize(nextCols, nextRows); }
Summary
Review mode: initial
The diff introduces regressions in Codex MCP startup portability and remote terminal PTY behavior. Node availability is not documented as a HAPI runtime prerequisite, and the terminal replacement loses real PTY behavior on macOS plus resize propagation on Linux/script-backed sessions.
Testing
Not run (automation; review only, and PR code was not executed).
HAPI Bot
44fe5f7 to
925001c
Compare
|
Updated in 925001c to address the bot review:
Revalidated locally:
|
There was a problem hiding this comment.
Findings
- [Major] Linux/script terminals ignore resize after creation —
TerminalManager.resize()updates the runtime dimensions and callsterminal.resize(), but the new pipe-backed implementation only mutates the parent-sideenvobject after the child has already spawned. On the default non-Darwin path with/usr/bin/script, the running PTY window size never changes, so full-screen tools and prompt wrapping stay at the original dimensions after web/mobile resize. Evidencecli/src/terminal/TerminalManager.ts:286.
Suggested fix:import { spawn } from "node-pty"; const ptyProcess = spawn(shell, ["-i"], { name: "xterm-256color", cols, rows, cwd, env }); const terminal: TerminalHandle = { write: (data) => ptyProcess.write(data), resize: (nextCols, nextRows) => ptyProcess.resize(nextCols, nextRows), close: () => ptyProcess.kill() };
Summary
- Review mode: follow-up after new commits
- The prior Node executable and macOS PTY findings appear addressed in the latest diff. One resize regression remains in the default Linux/script terminal path.
Testing
- Not run (automation; review only). Missing coverage: a TerminalManager test that verifies resize reaches the active PTY/process after creation.
HAPI Bot
925001c to
0d36b8d
Compare
|
Updated again in 0d36b8d to address the follow-up resize finding:
Revalidated locally:
|
There was a problem hiding this comment.
Findings
- No findings.
Summary
- Review mode: follow-up after new commits
- Reviewed the full latest diff plus the prior bot review context. The earlier Linux resize concern is addressed for the normal non-Darwin path by the added Python PTY bridge; the remaining pipe fallback is explicitly best-effort and only used when Python is unavailable or disabled.
- Residual risk: no repo test currently exercises the new TerminalManager PTY bridge lifecycle/resize behavior.
Testing
- Smoke-checked the Python PTY bridge locally for interactive startup, resize propagation via
stty size, and foreground/background process cleanup. - Not run:
bun run --cwd cli typecheckand targeted Vitest suite;bunis not installed in this runner.
HAPI Bot
Fix Codex title MCP startup and remote terminal spawning
Summary
child_process.spawn, using/usr/bin/scripton non-Darwin Unix when available.$SHELLwhen constructing thescript -ccommand.Motivation
Codex app-server can fail to initialize the Bun-backed HAPI MCP stdio bridge, leaving
mcp__hapi__change_titleunavailable in web sessions. Remote terminal sessions can also close immediately withTerminal stream closed unexpectedlyin daemon/web environments.Notes
HAPI_NODE_EXECUTABLEcan override the Node executable used for the MCP stdio proxy./usr/bin/scriptavailability.Validation
bun run --cwd cli typecheckcd cli && bun x vitest run src/codex/utils/codexMcpConfig.test.ts src/codex/utils/appServerConfig.test.ts src/codex/codexLocal.test.ts src/codex/utils/appServerEventConverter.test.ts src/codex/utils/terminalEventGuard.test.ts— 79 tests passedHAPI_MCP readyusing the generated inline proxy argsecho HAPI_TERMINAL_OKoutput and exit 0Known local test limitation
bun run testwas attempted, but this machine is Ubuntu 20.04 and the bundledcli/tools/unpacked/difftbinary requires newer GLIBC versions (GLIBC_2.32,GLIBC_2.33,GLIBC_2.34). As a result, onlysrc/modules/difftastic/index.test.tsfails locally; the remaining CLI tests run past that point and the targeted tests for this change pass.