Skip to content

fix(codex): show history of chats started outside the app - #460

Open
Mayaskara25 wants to merge 1 commit into
yuga-hashimoto:mainfrom
Mayaskara25:fix/codex-history-backfill
Open

Mayaskara25 wants to merge 1 commit into
yuga-hashimoto:mainfrom
Mayaskara25:fix/codex-history-backfill

Conversation

@Mayaskara25

Copy link
Copy Markdown

Problem. Codex conversations started outside AndCode's chat screen (in the terminal, with codex exec, or copied from another device) appear in the chat list with their title, but open empty.

Cause. The chat list comes from Codex (thread/list), but listMessages reads only the local codex-messages.json. That file is filled only by live notifications while AndCode runs a turn itself.

Fix. When a thread has no stored messages and no turn in flight, CodexRuntime pages through thread/items/list (ascending, 100 per page, capped). Entries are converted with a separate CodexItemParser instance, so live state is untouched, and keep their original startedAtMs/completedAtMs. They are stored and flushed. Threads Codex reports as empty are remembered per process. Failures are logged and fall back to the store. thread/items/list is the paginated API that Codex 0.172 points to now that full-history hydration with includeTurns is deprecated.

Not included: re-syncing a thread that is only partly stored (started in AndCode, then continued elsewhere). That needs a way to replace a session's stored list without losing details the live stream recorded; better as a follow-up.

Testing. Tested on a Samsung Galaxy F41 (SM-F415F) with Codex 0.172.0 and Claude Code 2.1.332.

  • CodexHistoryTest (7 tests: conversion and ordering, timestamps, paging, empty threads, failure fallback, turn in flight, page cap); all *Codex* and ChatViewModelTest tests pass.
  • On the device: had a conversation with codex in the terminal, opened it in the chat screen, and saw the earlier messages with their original times. Sent a follow-up, which answered in context, and the history was still there after a force-stop.

🤖 Generated with Claude Code

Codex chats from the terminal or another device opened empty.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant