-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chat refactors #29123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisnojima-zoom
merged 59 commits into
nojima/HOTPOT-next-670-clean-2
from
nojima/ZCLIENT-small-chat
Apr 9, 2026
Merged
chat refactors #29123
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
c3e665f
pull non legends list changes from other branch
chrisnojima-zoom 87649da
WIP
chrisnojima-zoom 4085ac0
Merge branch 'nojima/HOTPOT-next-670-clean-2' into nojima/ZCLIENT-sma…
chrisnojima 0a0f058
WIP
chrisnojima 9ad69ff
WIP
chrisnojima-zoom 480dbc5
WIP
chrisnojima 4b6bc14
WIP
chrisnojima-zoom 3bba9a2
WIP
chrisnojima-zoom 08e096b
WIP
chrisnojima-zoom e9f2d84
WIP
chrisnojima-zoom ae335ff
WIP
chrisnojima-zoom f7006f0
WIP
chrisnojima-zoom 260cc3e
WIP
chrisnojima-zoom 999504e
Merge branch 'nojima/HOTPOT-next-670-clean-2' into nojima/ZCLIENT-sma…
chrisnojima 0d11b91
Merge branch 'nojima/HOTPOT-next-670-clean-2' into nojima/ZCLIENT-sma…
chrisnojima a39f89b
Merge branch 'nojima/HOTPOT-next-670-clean-2' into nojima/ZCLIENT-sma…
chrisnojima 9275d73
WIP
chrisnojima-zoom 2ba43f9
WIP
chrisnojima-zoom 83984f7
WIP
chrisnojima-zoom 2b3f975
WIP
chrisnojima 4203c03
WIP
chrisnojima-zoom 1d62edf
WIP
chrisnojima 608dfab
WIP
chrisnojima-zoom d5ddf81
WIP
chrisnojima-zoom fba9ece
WIP
chrisnojima-zoom f20d79e
WIP
chrisnojima-zoom e5bd8b5
WIP
chrisnojima-zoom ead9819
WIP
chrisnojima-zoom af72dd9
WIP
chrisnojima-zoom b14b0ea
WIP
chrisnojima-zoom 2ef186d
WIP
chrisnojima-zoom db173c7
WIP
chrisnojima-zoom c3c9a9b
WIP
chrisnojima-zoom 95caec2
WIP
chrisnojima-zoom b794435
WIP
chrisnojima-zoom efe229f
WIP
chrisnojima-zoom 11aa690
WIP
chrisnojima-zoom 1afa564
WIP
chrisnojima-zoom 102d0de
WIP
chrisnojima-zoom a03a2df
WIP
chrisnojima-zoom c398d7a
WIP
chrisnojima-zoom aed19b3
WIP
chrisnojima-zoom 913f3bd
WIP
chrisnojima-zoom ceec493
WIP
chrisnojima-zoom 6de065a
WIP
chrisnojima-zoom 5832799
WIP
chrisnojima 0d9855b
WIP
chrisnojima-zoom 505416f
WIP
chrisnojima-zoom 0e4cf0d
WIP
chrisnojima-zoom 697e33e
WIP
chrisnojima-zoom f4be1fa
WIP
chrisnojima-zoom 7ed5ad9
WIP
chrisnojima-zoom b8cdba3
WIP
chrisnojima b3b0d20
WIP
chrisnojima-zoom a5dfc21
WIP
chrisnojima-zoom 6e6b92d
WIP
chrisnojima bca7921
WIP
chrisnojima-zoom 4907c02
WIP
chrisnojima-zoom 09a4fe9
WIP
chrisnojima-zoom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| # Chat Message Perf Cleanup Plan | ||
|
|
||
| ## Goal | ||
|
|
||
| Reduce chat conversation mount cost, cut per-row Zustand subscription fan-out, and remove render thrash in the message list without changing behavior. | ||
|
|
||
| ## Constraints | ||
|
|
||
| - Preserve existing chat behavior and platform-specific handling. | ||
| - Prefer small, reviewable patches with one clear ownership boundary each. | ||
| - This machine does not have `node_modules` for this repo, so this plan assumes pure code work unless validation happens elsewhere. | ||
|
|
||
| ## Working Rules | ||
|
|
||
| - Use one clean context per workstream below. | ||
| - Do not mix store-shape changes and row rendering changes in the same patch unless one directly unblocks the other. | ||
| - Keep desktop and native paths aligned unless there is a platform-specific reason not to. | ||
| - Treat each workstream as independently landable where possible. | ||
| - Do not preserve proxy dispatch APIs solely to avoid touching callers when state ownership changes; migrate callers to the new owner in the same workstream. | ||
| - When a checklist item is implemented, update this plan in the same change and mark that item done. | ||
|
|
||
| ## Workstreams | ||
|
|
||
| ### 1. Row Renderer Boundary | ||
|
|
||
| - [x] Introduce a single row entry point that takes `ordinal` and resolves render type inside the row. | ||
| - [x] Remove list-level render dispatch from `messageTypeMap` where possible. | ||
| - [x] Delete the native `extraData` / `forceListRedraw` placeholder escape hatch if the new row boundary makes it unnecessary. | ||
| - [x] Keep placeholder-to-real-message transitions stable on both native and desktop. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/chat/conversation/list-area/index.native.tsx` | ||
| - `shared/chat/conversation/list-area/index.desktop.tsx` | ||
| - `shared/chat/conversation/messages/wrapper/index.tsx` | ||
| - `shared/chat/conversation/messages/placeholder/wrapper.tsx` | ||
|
|
||
| ### 2. Incremental Derived Message Metadata | ||
|
|
||
| - [x] Stop rebuilding whole-thread derived maps on every `messagesAdd`. | ||
| - [x] Update separator, username-grouping, and reaction-order metadata only for changed ordinals and any affected neighbors. | ||
| - [x] Avoid rebuilding and resorting `messageOrdinals` unless thread membership actually changed. | ||
| - [x] Re-evaluate whether some derived metadata should live in store state at all. | ||
| - [ ] Audit per-message render-time computation and decide whether values that are only consumed by one caller should be stored in derived message state instead of recomputed during render. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/stores/convostate.tsx` | ||
| - `shared/chat/conversation/messages/separator.tsx` | ||
| - `shared/chat/conversation/messages/reactions-rows.tsx` | ||
|
|
||
| ### 3. Row Subscription Consolidation | ||
|
|
||
| - [x] Move toward one main convo-store subscription per mounted row. | ||
| - [x] Push row data down as props instead of reopening store subscriptions in reply, reactions, emoji, send-indicator, exploding-meta, and similar children. | ||
| - [x] Audit attachment and unfurl helpers for repeated `messageMap.get(ordinal)` selectors. | ||
| - [x] Keep selectors narrow and stable when a child still needs to subscribe directly. | ||
|
|
||
| Decision note: | ||
|
|
||
| - Avoid override/fallback component modes when a parent can supply concrete row data. | ||
| - Prefer separate components for distinct behaviors, such as a real reaction chip versus an add-reaction button, rather than one component that mixes controlled, connected, and fallback paths. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/chat/conversation/messages/wrapper/wrapper.tsx` | ||
| - `shared/chat/conversation/messages/text/wrapper.tsx` | ||
| - `shared/chat/conversation/messages/text/reply.tsx` | ||
| - `shared/chat/conversation/messages/reactions-rows.tsx` | ||
| - `shared/chat/conversation/messages/emoji-row.tsx` | ||
| - `shared/chat/conversation/messages/wrapper/send-indicator.tsx` | ||
| - `shared/chat/conversation/messages/wrapper/exploding-meta.tsx` | ||
|
|
||
| ### 4. Split Volatile UI State From Message Data | ||
|
|
||
| - [x] Inventory convo-store fields that are transient UI state rather than message graph state. | ||
| - [x] Move thread-search visibility and search request/results state out of `convostate` into route params plus screen-local UI state. | ||
| - [x] Move route-local or composer-local state out of the main convo message store. | ||
| - [x] Keep dispatch call sites readable and avoid direct component store mutation. | ||
| - [x] Minimize unrelated selector recalculation when typing/search/composer state changes. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/stores/convostate.tsx` | ||
| - `shared/chat/conversation/*` | ||
|
|
||
| ### 5. List Data Stability And Recycling | ||
|
|
||
| - [ ] Remove avoidable array cloning / reversing in the hottest list path. | ||
| - [x] Replace effect-driven recycle subtype reporting with data available before or during row render. | ||
| - [ ] Re-check list item type stability after workstreams 1 and 3 land. | ||
| - [ ] Keep scroll position and centered-message behavior unchanged. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/chat/conversation/list-area/index.native.tsx` | ||
| - `shared/chat/conversation/messages/text/wrapper.tsx` | ||
| - `shared/chat/conversation/recycle-type-context.tsx` | ||
|
|
||
| ### 6. Measurement And Regression Guardrails | ||
|
|
||
| - [ ] Add or improve lightweight profiling hooks where they help compare before/after behavior. | ||
| - [ ] Define a manual verification checklist for initial thread mount, new incoming message, placeholder resolution, reactions, edits, and centered jumps. | ||
| - [ ] Capture follow-up profiling notes after each landed workstream. | ||
|
|
||
| Primary files: | ||
|
|
||
| - `shared/chat/conversation/list-area/index.native.tsx` | ||
| - `shared/chat/conversation/list-area/index.desktop.tsx` | ||
| - `shared/perf/*` | ||
|
|
||
| ## Recommended Order | ||
|
|
||
| 1. Workstream 1: Row Renderer Boundary | ||
| 2. Workstream 2: Incremental Derived Message Metadata | ||
| 3. Workstream 3: Row Subscription Consolidation | ||
| 4. Workstream 4: Split Volatile UI State From Message Data | ||
| 5. Workstream 5: List Data Stability And Recycling | ||
| 6. Workstream 6: Measurement And Regression Guardrails | ||
|
|
||
| ## Clean Context Prompts | ||
|
|
||
| Use these as narrow follow-up task starts: | ||
|
|
||
| 1. "Implement Workstream 1 from `PLAN.md`: introduce a row-level renderer boundary and remove the native placeholder redraw hack." | ||
| 2. "Implement Workstream 2 from `PLAN.md`: make convo-store derived message metadata incremental instead of full-thread recompute." | ||
| 3. "Implement Workstream 3 from `PLAN.md`: consolidate message row subscriptions so row children mostly receive props instead of subscribing directly." | ||
| 4. "Implement Workstream 4 from `PLAN.md`: split volatile convo UI state from message graph state." | ||
| 5. "Implement Workstream 5 from `PLAN.md`: stabilize list data and recycling after the earlier refactors." | ||
| 6. "Implement Workstream 6 from `PLAN.md`: add measurement hooks and a regression checklist for the chat message perf cleanup." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this adds some logging. i was seeing inbox unboxing hang every once in awhile. if i restart the ui i could 100% repro this and spent a ton of time trying to see where things were going wrong (see plans/inbox-load-fail.md). after i restarted the service the problem went away and couldn't be repoed so now i think its something in the go layer