refactor(web): ChatView's module-level helpers live in their own files#22665

merged1
main
refactor/chatview-helpers
opened3d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 3d ago

ChatView.tsx is ~9,100 lines, and about 500 of them are module-level helpers that have nothing to do with rendering. This is the first layer of a stack that splits ChatView up.

What moved:

  • ThreadVisitWatermark → chat/ThreadVisitWatermark.tsx
  • useDraftHeroLayoutTransition → chat/useDraftHeroLayoutTransition.ts
  • useLocalDispatchState → chat/useLocalDispatchState.ts
  • The multiple-model send state and startFanoutThread / rewindToMessage → chat/chatViewSend.ts
  • Pure helpers (formatOutgoingPrompt, isCompactCommandMessage, makeThreadErrorSetter, makeModelDisabledReason, releaseChatTimelineAnchor, chatActionErrorMessage) → ChatView.logic.ts

The code is unchanged. Render boundaries don't change in this layer, so it has no render numbers of its own.

mainthis layer
ChatView.tsx lines9,0938,585

Tests: vp test run src/reactCompilerCoverage.test.ts for ChatView and every new file (0 bailouts), vp test run src/components/ChatView.logic.test.ts, tsc-rs --noEmit for apps/web, and oxlint on the changed files.

🤖 Generated with Claude Code

Checks

All checks passed

Added 1 commit

  • refactor(web): ChatView's module-level helpers live in their own filesf48841f
Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 8ed77143-361b-4a59-8e02-57e85121ec6c
📥 Commits

Reviewing files that changed from the base of the PR and between 618761a2d6d615b2c0a07e5de4d82384a583f717 and f48841f9ef73601c5af03586ca7c334684b92fb5.

📒 Files selected for processing: 6
  • apps/web/src/components/ChatView.logic.ts
  • apps/web/src/components/ChatView.tsx
  • apps/web/src/components/chat/ThreadVisitWatermark.tsx
  • apps/web/src/components/chat/chatViewSend.ts
  • apps/web/src/components/chat/useDraftHeroLayoutTransition.ts
  • apps/web/src/components/chat/useLocalDispatchState.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

ChatView now imports extracted modules for send and rewind handling, draft-hero transitions, local dispatch state, and thread visit tracking. ChatView.logic adds prompt formatting, compact-command detection, thread error handling, timeline-anchor release, and model disabled-reason helpers.

Changes: ChatView behavior

Layer / File(s)Summary
Prompt and thread action helpers
apps/web/src/components/ChatView.logic.ts, apps/web/src/components/ChatView.tsx
ChatView.logic adds outgoing prompt formatting, compact-command detection, timestamped thread errors, timeline-anchor release, and model disabled-reason generation. ChatView removes related local helpers and imports.
Send, fanout, and rewind behavior
apps/web/src/components/chat/chatViewSend.ts, apps/web/src/components/ChatView.tsx
chatViewSend adds route-scoped send state, handling for uncertain fanout submissions, and rewind behavior. ChatView removes the former local implementations and imports the extracted functionality.
Dispatch state and draft-hero transitions
apps/web/src/components/chat/useLocalDispatchState.ts, apps/web/src/components/chat/useDraftHeroLayoutTransition.ts, apps/web/src/components/ChatView.tsx
New hooks track local dispatch state and animate eligible draft-hero layout changes. ChatView removes the corresponding local implementations and related imports.
Thread visit watermark
apps/web/src/components/chat/ThreadVisitWatermark.tsx, apps/web/src/components/ChatView.tsx
ThreadVisitWatermark tracks local visits and dispatches deduplicated server visit commands. ChatView imports the component and removes its former in-file implementation.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to f4884

This refactor moves non-rendering chat helpers into their own files without a stated behavior change. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check nameStatusExplanationResolution
Description checkWarningThe description explains the problem, the extracted modules, and the verification performed. It does not provide the required Scope and approval information, and it does not state the model and harnes…Add the triaged issue or maintainer approval with the approval comment. If no prior discussion was required, explain why this refactor qualifies for that exception. Add the model and harness used with Claude Code. If UI evidence is not appl…
Passed Passed checks: 3 passed
Check nameStatusExplanation
Title checkPassedThe title clearly identifies the main change: moving ChatView module-level helpers into separate files.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, the extracted modules, and the verification performed. It does not provide the required Scope and approval information, and it does not state the model and harness used for the agent-generated changes.

Resolution

Add the triaged issue or maintainer approval with the approval comment. If no prior discussion was required, explain why this refactor qualifies for that exception. Add the model and harness used with Claude Code. If UI evidence is not applicable because behavior and render boundaries are unchanged, state that explicitly; otherwise add the required screenshots or recording for transition-related changes.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Comment @coderabbitai help to get the list of available commands.

Synced from GitHub

Approvability

Verdict: Approved at f48841f

Macroscope's review found this PR approvable — This refactor extracts existing ChatView helpers, hooks, and send logic into focused files without introducing new behavior or changing runtime boundaries. The large diff is primarily code movement with no schema, configuration-default, or infrastructure impact.

You can add or adjust custom eligibility rules. Learn more.