Skip to content

[feat] /Combine - #1

Open
vishaltandale00 wants to merge 10 commits into
mainfrom
codex/merge-feature
Open

vishaltandale00 wants to merge 10 commits into
mainfrom
codex/merge-feature

Conversation

@vishaltandale00

@vishaltandale00 vishaltandale00 commented Mar 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a workspace thread combine feature that creates a new thread from a base thread plus one or more additional threads from the same workspace.

This is not a semantic merge. The implementation preserves each source thread's effective conversation state and appends the selected thread histories in user-chosen order.

Related upstream issue: openai#15133

What this changes

User-facing behavior

  • Adds /combine in the TUI.
  • Lets the user choose a base thread, select additional threads from the same workspace, review the ordered selection, and create a new combined thread.
  • Shows combined-thread provenance in history/UI.

Core behavior

  • Introduces combined rollout construction in codex-rs/core/src/thread_combine.rs.
  • Appends selected source rollouts behind explicit MergeBoundary items.
  • Records provenance in session metadata via:
    • merge_base_thread_id
    • merged_from_thread_ids
  • Restricts combine candidates to the same workspace/cwd using helpers in codex-rs/core/src/thread_workspace.rs.

Replay / reconstruction correctness

A naive append of rollout items is wrong because source threads may contain:

  • compaction markers
  • rollback markers
  • inherited history from forks
  • partial turn metadata

To keep combined threads correct on resume/fork/reload, rollout reconstruction now treats MergeBoundary as a hard replay segment boundary. That prevents rollback, compaction, and reference-context state from one appended source thread from leaking into another source thread.

Why this is useful

Forking is good for branching exploration, but there is no clean path to bring useful branches back together. This fills that gap by letting users recombine multiple workspace threads into one new conversation without manually copying context or discarding the original threads.

Implementation notes

The branch intentionally trimmed scope and dropped a public thread-merge RPC. This keeps the feature TUI-first while landing the core storage/replay/product behavior.

Important pieces:

  • codex-rs/core/src/thread_combine.rs
    • builds the combined rollout
    • validates source ids
    • preserves selected order
    • carries forward provenance
  • codex-rs/core/src/codex/rollout_reconstruction.rs
    • replays merged rollouts segment-by-segment across MergeBoundary
  • codex-rs/core/src/rollout/recorder.rs
    • persists merge boundaries
  • codex-rs/protocol/src/protocol.rs
    • adds RolloutItem::MergeBoundary
  • codex-rs/tui/src/app.rs, resume_picker.rs, chatwidget.rs
    • picker, review, and combined-thread UX

Coverage

The change includes regression coverage for:

  • sibling and descendant thread combine cases
  • preserving selected order
  • nested provenance
  • compaction semantics
  • rollback semantics
  • duplicate source rejection
  • mismatched source id rejection

Validation

  • just fmt
  • cargo test -p codex-core
  • TUI snapshot updates for combine picker / review / history rendering

Handle descendant merges against logical rollout state, including compaction and rollback semantics. Also widen the merge picker to load resume candidates across providers while excluding the active thread, and add regression coverage for duplicate sources, cycles, ordering, and rollback cases.
@vishaltandale00

Copy link
Copy Markdown
Owner Author
Screenshot 2026-03-18 at 7 04 53 PM Screenshot 2026-03-18 at 7 05 01 PM https://github.com//pull/1 Screenshot 2026-03-18 at 7 05 10 PM Screenshot 2026-03-18 at 7 05 18 PM Screenshot 2026-03-18 at 7 05 25 PM Screenshot 2026-03-18 at 7 06 01 PM

@vishaltandale00 vishaltandale00 changed the title Codex/merge feature [feat] /Combine Mar 19, 2026
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