Skip to content

refactor(ui): restore ChatView boundaries in three stages #829

Closed

Description

@Astro-Han

Problem

While fixing #827 in #828, a missed props.mode dependency exposed a structural problem: ChatView survives section switches while its chat DOM does not. Scroll effects must therefore track navigation state individually, even though navigation is not a chat concern.

The same component also owns section routing, transcript scrolling, and detailed turn rendering. Its roughly 1,800 lines are a symptom; the problem is that independently changing responsibilities share one lifecycle and API.

This issue governs a three-stage cleanup. It is not intended to close through one large PR.

Target boundary

ChatView should be the sessions-section chat container:

  • app-shell decides whether chat or another section is mounted;
  • ChatView owns chat-page composition;
  • a scroll seam owns transcript DOM lifecycle;
  • a turn seam owns rendering of a materialized turn.

The goal is clear ownership, not a line-count target.

Stage 1 — Page ownership

Move section dispatch to app-shell so ChatView mounts only for sessions.

Outcomes:

  • ChatView has no mode prop or non-chat branches;
  • non-chat module props leave the ChatView API;
  • app-shell is the single authority for section routing;
  • chat effects no longer depend on navigation state;
  • existing lazy loading and behavior are preserved.

Acceptance:

Stage 2 — Turn rendering

Move the rendering of one materialized turn behind a cohesive component boundary.

Outcomes:

  • ChatView composes the transcript without implementing turn internals;
  • turn-only helpers remain private to the turn module;
  • DOM structure, memoization, and behavior remain unchanged;
  • no parallel rendering path or premature subcomponent-per-file split is introduced.

Acceptance:

  • A materialized turn has one clear rendering boundary.
  • ChatView no longer owns turn-level presentation details.
  • Affected unit, contract, and E2E tests stay green.

Stage 3 — Scroll lifecycle

Move transcript scroll state and effects behind a chat-specific hook or equivalent seam.

Outcomes:

  • the seam owns the viewport ref, pinned state, session reset, size following, warm-up, explicit targets, highlighting, and scroll-to-bottom behavior;
  • it composes the existing pinned-bottom and turn-size-warmup mechanisms rather than duplicating them;
  • it knows nothing about navigation modes or non-chat sections;
  • behavior remains unchanged.

Acceptance:

  • Scroll state and effects no longer live inline in ChatView.
  • Existing scroll mechanisms remain the authoritative implementations.
  • The complete scroll-geometry suite stays green.

Delivery

Deliver the stages as three independently reviewable and revertible PRs, in order:

  1. page ownership;
  2. turn rendering;
  3. scroll lifecycle.

Each PR should reference this issue and identify its stage. Close this issue after all three stages merge.

Stop condition

Stop after these boundaries are restored unless a remaining extraction solves a concrete responsibility or defect. Do not split components merely to reduce file length.

Out of scope

  • visual or behavioral redesign;
  • redesign of message materialization or live-turn projection;
  • one-file-per-component cleanup;
  • governance of other large files based on size alone.

Refs #827, #828.

Activity

  1. changed the title [-]refactor(ui): ChatView owns non-chat mode dispatch — lift it to app-shell and split the file[/-] [+]refactor(ui): restore ChatView boundaries in three stages[/+] on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions