Skip to content

[frontend] P2 refactor: split chat god components (chat-screen 3339 lines / 43 effects; message-item 22 props) — includes real stale-render bug in areMessagesEqual #222

@Interstellar-code

Description

@Interstellar-code

Problem

chat-screen.tsx: 3339 lines, 43 useEffect, 26 useRef, 17 useState, ~155 hook calls. The interdependent effects and shared refs (waitingForResponseRef, activeSendRef, ...) are the root enabler of the race/staleness bugs filed separately (#219, #220) — effect ordering coupling no type system checks.

message-item.tsx: 3029 lines, 22-prop MessageItemProps (:279-300), forcing a hand-written 110-line areMessagesEqual comparator (:2913-3025).

Concrete bug in the comparator: areMessagesEqual never compares the attachedToolMessages prop (verified: 0 mentions in the comparator) even though it is consumed at :2372 and memoized into render at :2396. If attachedToolMessages changes while all compared fields are equal, memo skips the re-render → stale tool output displayed. This is the inherent failure mode of hand-maintaining a comparator against a 22-prop surface.

Fix

Found in chat-area audit 2026-06-11. Related: #212, #219, #220.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions