oliver-zehentleitner / maity

clean-up: web chat: one conversation pane for direct and group chat

Sign in to report

tsk-d4ths4493xsj Open

From the web clean-up audit, area 17 (tsk-hgnbapyw7hnh), read at 80647565 (findings sent to lotse, seq 125449). Line numbers are from 80647565, so re-check them on current main. This is the largest and riskiest web clean-up: the most-used surface.

#11 Chat and group chat: the open-conversation pane is written twice (duplication).
Each pair below is chat.js first, then group-chat.js:

  • the older page and the earlier button: chat.js:825-850, group-chat.js:192-225
  • add() with the KEEP/PAGE trim: chat.js:888-905, group-chat.js:227-242
  • the RESYNC walk-back: chat.js:934-949, group-chat.js:246-272
  • redaction: chat.js:951-977, group-chat.js:145-160 and 274-283
  • quote: chat.js:979-986, group-chat.js:162-168
  • the draft key and typedInChat: chat.js:1005-1008, group-chat.js:419-422
  • send with attachments: chat.js:1033-1057, group-chat.js:429-450
  • fit, open and reveal: chat.js:1082-1094, group-chat.js:500-511
  • EARLIER_PAGE = 50 at group-chat.js:15 repeats PAGE at chat.js:389

What is wrong:

  • M.chatParts shares only the leaves (timeline, follower, newestPage). Each view keeps its own message state and its own copy of every step.
  • The copies have drifted. A direct redaction patches the DOM in place (markRemoved), while a group redaction redraws everything. The group quote skips the mention-hint refresh and the caret. The two earlier buttons handle focus differently.

Proposal:

  • One conversationPane(ctx, {path, kind, observer, closed, head, delivery, mentionRule}) that owns the messages, paging, add/trim, resync, redact, quote and composer. Direct and group supply only their head and policies.
  • First step: split chat.js (1096 lines) into chat-parts, chat-list and chat (direct).

Effort L. Risk medium-high: smoke.js patches chatParts internals (smoke.js:6220, 10783).

#14 Chats (All projects): the list injects fake events into the open pane listeners (design).

  • Where: chats.js:172-174, consumed at chat.js:908-931 and group-chat.js:247-293.
  • To refresh the open pane, chats.js builds a fake "message" event (seq MAX_SAFE_INTEGER, actor.member_id = open.id) and calls pane.ctx.listeners directly. For a group, that puts a cnv- id where an actor id belongs.
  • In a direct chat the fake actor equals agent.id, so every nudge also runs checkDelivery() (chat.js:918).
  • Listener errors are swallowed by .catch at chats.js:174.
  • Together with RESYNC (chat.js:22), this is a private protocol around ctx.onEvents.
  • Proposal: the pane returns {pull(), resync()}, chats.js calls them, and failures go to the status line of the pane.
  • Effort M. Risk medium.

Order: do #14 together with or after #11, since the pane API is what #14 calls. The smaller chat card (mentions, unread rule, fallbacks) can go first and touches the same files, so rebase on whichever merges first.