Commit Graph

1 Commits

  • Refactor chatwidget protocol flows into modules (phase 3) (#22433)
    ## Why
    
    `chatwidget.rs` is still carrying too many unrelated responsibilities in
    one file. #22269 started a five-phase cleanup to move coherent behavior
    domains into focused modules while keeping `chatwidget.rs` as the
    composition layer. #22407 completed phase 2 by extracting input and
    submission flow.
    
    This PR is phase 3. It keeps moving high-churn event handling out of the
    central widget by extracting protocol, replay, streaming, and tool
    lifecycle handling without changing the visible behavior those flows
    already provide. This is once again just a mechanical movement of
    existing functions. No functional changes.
    
    ## What Changed
    
    - Added focused modules for protocol request dispatch, replay rendering,
    assistant/plan/reasoning streaming, turn runtime bookkeeping, hook
    lifecycle handling, command lifecycle handling, tool lifecycle
    rendering, and interactive tool request prompts.
    - Kept active-cell grouping, transcript invalidation, interrupt
    deferral, and final-message separator behavior in the same flows, just
    moved into smaller files.
    - Added module header comments to the new files so the ownership
    boundaries are explicit.
    - Left `codex-rs/tui/src/chatwidget.rs` as the registration and
    orchestration surface for these extracted behaviors.
    
    ## Cleanup Phases
    
    The five-phase cleanup plan from #22269 is:
    
    1. Phase 1: mechanical helper and state moves. Completed in #22269.
    2. Phase 2: extract input and submission flow, including queued user
    messages, shell prompt submission, pending steer restoration, and thread
    input snapshot/restore behavior. Completed in #22407.
    3. Phase 3: extract protocol, replay, streaming, and tool lifecycle
    handling, while preserving active-cell grouping, transcript
    invalidation, interrupt deferral, and final-message separator behavior.
    This PR.
    4. Phase 4: extract settings, popups, and status surfaces, including
    model/reasoning/collaboration/personality popups, permission prompts,
    rate-limit UI, and connectors helpers.
    5. Phase 5: clean up the remaining constructor and orchestration code
    once the larger behavior domains have moved out, leaving `chatwidget.rs`
    as the composition layer.