CLI: picker renders before initial session load completes
What issue are you seeing?
On Codex CLI 0.118.0, running codex resume from a repo that already has saved sessions can render an incorrect empty state on the first frame:
No sessions yet
I reproduced this in /Users/dxm/gitlab/alloy-test on macOS.
The saved sessions are not actually missing:
codex resume --lastsuccessfully resumes the latest session for the repo.codex resume <session_id>works.codex resume --allshows the sessions.thread/listfrom the embedded app server returns the expected session rows for this repo, including when filtering bycwd=/Users/dxm/gitlab/alloy-test.
I traced this to the TUI picker logic. The picker clears rows and starts an async load, but the empty-state renderer checks:
all_rows.is_empty() && num_scanned_files == 0-> renderNo sessions yet
before it checks whether an initial load is still pending.
So the first frame reports “no sessions” even though the session page is still loading.
Relevant code in rust-v0.118.0:
codex-rs/tui/src/resume_picker.rsaroundstart_initial_load()codex-rs/tui/src/resume_picker.rsaroundrender_empty_state_line()
What steps can reproduce the bug?
- Use Codex CLI
0.118.0on macOS. - Ensure a repo already has saved interactive sessions.
- Run
codex resumefrom that repo. - Observe that the picker can initially render
No sessions yeteven though saved sessions exist.
In my case:
cd /Users/dxm/gitlab/alloy-test
codex resume
Related checks:
cd /Users/dxm/gitlab/alloy-test
codex resume --last
codex resume --all
To verify the data layer itself is fine, I also queried the embedded app server directly with thread/list using:
modelProviders = ["codeproxy"]sourceKinds = ["cli", "vscode"]sortKey = "updated_at"
and it returned the expected /Users/dxm/gitlab/alloy-test session row.
What is the expected behavior?
The resume picker should not render No sessions yet while the initial session page is still loading.
Expected behavior:
- show a loading state such as
Loading sessions...on the initial frame, or - avoid showing the empty-state message until the initial async load has completed.
Additional information
Environment:
- Codex CLI:
0.118.0 - OS: macOS 26.3.1 on Apple Silicon
- Terminal: Apple Terminal
A direct thread/list check from the embedded app server returned rows quickly on the same machine:
initialize: about121 msthread/list: about230 ms
So this does not look like session loss or a backend filtering problem. It looks like a TUI state-ordering / empty-state rendering bug in the resume picker.
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I reproduced this against current
mainand prepared a small fix locally on branchfeat/andrzej_codex-resume-picker-initial-loading(commitb6e39b3eb6b9e92628e43622a0d1b133594d65fb).Repro summary:
codex resume.No sessions yeteven though the initial thread-list request is already in flight and sessions exist.Root cause:
codex-rs/tui/src/resume_picker.rscheckedall_rows.is_empty() && num_scanned_files == 0before checking whetherpagination.loadingwas already pending. So the empty-state renderer treated "initial page request in progress" as "no sessions exist yet".Approaches compared:
initial_load_completeflag and branch the copy off that.render_empty_state_line(...)prefer a loading message while the initial page load is pending.I chose B because the pending/idle state is already explicit in
PaginationState, so adding another flag would just duplicate state for a one-line renderer decision.Fix summary:
pagination.loadingis pending and the picker still has zero rows / zero scanned files, renderLoading sessions…Loading older sessions…for later pagination loadsNo sessions yetonce the initial load actually completes with no rowsValidation from this run:
CARGO_INCREMENTAL=0 RUSTFLAGS='-C debuginfo=0' cargo test -p codex-tui --lib render_empty_state_line_ -- --nocapturecargo fmt --check -p codex-tuigit diff --checkLocal environment note:
target/directory and using a lower-footprint Rust build (CARGO_INCREMENTAL=0,-C debuginfo=0). The final targeted test run above passed.Sandbox limitation for publication:
git push(Could not resolve host: github.com), so I could not publish the fork branch URL directly from this run. If this direction looks right and you want an invited PR, I can push/open it quickly from the committed branch above once branch publication is available.Thanks, this matches what I saw locally.
A couple of points from my repro that may help narrow the scope:
thread/listreturns the expected session row on the first page, both with and without thecwdfilter.codex resume --lastworks because it bypasses the picker and directly uses the filtered thread lookup.codex resumevia the TUI picker.So I agree this looks like an initial-load empty-state ordering bug in the picker, not a session lookup / filtering failure. Rendering
Loading sessions...whilepagination.loadingis pending, and only showingNo sessions yetafter the first page has actually completed empty, sounds like the right fix.Also, the related issue I opened as
#16515was closed as a duplicate of this one, so this is the main thread to track. If a PR goes up, I can test it on the same macOS setup where I reproduced the issue.Thanks for the bug report. This will be fixed in the next release.