chore: introduce ConversationManager as a clearinghouse for all conversations #2240
+406
−654
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things because after I got deep into the first one I started pulling on the thread to the second:
ConversationManager
the place where all in-memory conversations are created and stored. Previously,MessageProcessor
in thecodex-mcp-server
crate was doing this via itssession_map
, but this is something that should be done incodex-core
.ctrl_c: tokio::sync::Notify
that was threaded throughout our code. I think this made sense at one time, but now that we handle Ctrl-C within the TUI and have a properOp::Interrupt
event, I don't think this was quite right, so I removed it. Forcodex exec
andcodex proto
, we now usetokio::signal::ctrl_c()
directly, but we no longer makeNotify
a field ofCodex
orCodexConversation
.Changes of note:
conversation_manager.rs
andcodex_conversation.rs
tocodex-core
.Codex
andCodexSpawnOk
are no longer exported fromcodex-core
: other crates must useCodexConversation
instead (which is created viaConversationManager
).core/src/codex_wrapper.rs
has been deleted in favor ofConversationManager
.ConversationManager::new_conversation()
returnsNewConversation
, which is in line with thenew_conversation
tool we want to add to the MCP server. NoteNewConversation
includesSessionConfiguredEvent
, so we eliminate checks in cases likecodex-rs/core/tests/client.rs
to verifySessionConfiguredEvent
is the first event because that is now internal toConversationManager
.codex-rs/mcp-server/src/message_processor.rs
since it no longer has to manage multiple conversations itself: it goes throughConversationManager
instead.core/tests/live_agent.rs
has been deleted because I had to update a bunch of tests and all the tests in here were ignored, and I don't think anyone ever ran them, so this was just technical debt, at this point.notify_on_sigint()
fromutil.rs
(and in a follow-up, I hope to refactor the blandly-namedutil.rs
into more descriptive files).codex
asconversation
, where appropriate, though admittedly I didn't do it through all the integration tests because that would have added a lot of noise to this PR.Stack created with Sapling. Best reviewed with ReviewStack.
OutgoingMessageSender::send_response()
to takeSerialize
#2263