The Codex app seems to drop the connection if you click on anything (away, other parts of the app). The Codex CLI should hold onto a single connection for the entire session. I recommend giving the CLI another go.
Although I do think Xcode could be a lot better here.
Topic:
Developer Tools & Services
SubTopic:
Xcode