Refactor: deduplicate thread_archive / thread_unarchive ID + path handling

Resolved 💬 2 comments Opened Feb 15, 2026 by iyoda Closed Feb 15, 2026

What

  • Propose extracting the shared logic in thread_archive and thread_unarchive

(thread id parsing, rollout path lookup, and error response construction)
into two helpers.

Why

  • Reduces duplication and makes the error-handling flow consistent.
  • Keeps behavior identical while improving maintainability.

How

  • Add helpers in codex-rs/app-server/src/codex_message_processor.rs:
  • parse_thread_id(request_id, thread_id_str) -> Option<ThreadId>
  • find_thread_rollout_path(request_id, thread_id, archived) -> Option<PathBuf>
  • Use them from:
  • thread_archive: replaces inline parse + find_thread_path_by_id_str + error blocks
  • thread_unarchive: replaces inline parse + find_archived_thread_path_by_id_str + error blocks

Concrete example

  • The same “invalid thread id” error handling is currently duplicated in both methods.

With the helper, it lives in a single place.

  • The “no rollout found” and “failed to locate thread id” cases are duplicated across both

methods, differing only by the archived/non-archived prefix; the helper unifies this.

Tests

  • cargo test -p codex-app-server (passes locally)

Scope / Behavior

  • No API shape changes.
  • Error messages remain equivalent (including archived vs non-archived variants).

Request

  • This repo accepts external PRs by invitation only; could a maintainer confirm

whether this change is acceptable and invite a PR?

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗