Ensure MCP launch resources are cleaned up - #455
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d35203f90f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (when cleanup-fn | ||
| (funcall cleanup-fn))) |
There was a problem hiding this comment.
Clean the prepared launch when session startup fails
The cleanup added here only covers reuse of a live session. For a fresh Claude Code launch whose process is nil or exits during the initialization delay—for example, when the CLI cannot start—ai-code-backends-infra--create-new-session calls ai-code-backends-infra--handle-session-start-failure without invoking cleanup-fn, and no sentinel was installed to invoke it later. The newly created MCP configuration file is therefore still leaked on this failure path; ensure launch cleanup also runs when session creation fails.
Useful? React with 👍 / 👎.
Summary
This PR adds lifecycle management for temporary resources created by
ai-code-mcp-agent-prepare-launch.Claude Code launches create a temporary MCP configuration file, but the previous cleanup function only unregistered the MCP session. The temporary file could therefore remain on disk after the session ended.
Changes
Impact
Claude Code MCP temporary configuration files are now removed when the session cleanup function runs. Other MCP-enabled backends keep their existing command behavior.
Validation
test/test_ai-code-mcp-agent.el.Follow-up
Startup-failure cleanup in the shared terminal/session infrastructure is intentionally left for a separate focused change, so this PR remains limited to resources owned by
ai-code-mcp-agent.