Skip to content

Refactor chatwidget protocol flows into modules (phase 3)#22433

Merged
etraut-openai merged 1 commit into
mainfrom
etraut/chatwidget-refactor-phase-3
May 13, 2026
Merged

Refactor chatwidget protocol flows into modules (phase 3)#22433
etraut-openai merged 1 commit into
mainfrom
etraut/chatwidget-refactor-phase-3

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented May 13, 2026

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 Refactor chatwidget state into modules #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 Refactor chatwidget input flow into modules #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.

@etraut-openai etraut-openai merged commit 8fe0ecb into main May 13, 2026
27 checks passed
@etraut-openai etraut-openai deleted the etraut/chatwidget-refactor-phase-3 branch May 13, 2026 15:52
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants