Skip to content

📺 feat: Render Followed Chats With Main Chat's Message List - #18193

Merged
danny-avila merged 4 commits into
devfrom
danny-avila/followed-thread-view
Nov 17, 2026
Merged

danny-avila merged 4 commits into
devfrom
danny-avila/followed-thread-view

Conversation

@danny-avila

@danny-avila danny-avila commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Main chat's message list (MessagesView, its thread, rows and parts) reads a ChatContract from ChatContext, and the only thing that produces one is the hooks session (useChatHelpers), which is bound to the app's pane store, route and composer. A conversation held by a Chat therefore has nothing to render it with except hand-built rows, which is how the subagent panel ended up with its own transcript.

This adds the adapter and the component that close that gap for a conversation the reader follows rather than drives. useFollowedContract builds the ChatContract the rows read from a followed Chat (#18192), and FollowedThread mounts main chat's own list under it. The rows, parts, scrolling and progressive mounting are the ones main chat uses, not copies.

Fifth in a stack, on #18192. The subagent panel mounts it in the next PR; nothing in the app renders it yet.

How it works

useFollowChat(id)                      # 18192: a Chat over [QueryKeys.messages, id]
  └─ FollowedThread
       ├─ useFollowedContract          # ChatContract from the Chat
       │    reads   getMessages, messagesKey, subscribeMessages, getMessagesRevision,
       │            latestMessageId / latestMessageDepth (the same cache projection main chat uses),
       │            isSubmitting (status is submitted | streaming), sibling selection
       │    inert   ask, regenerate, continue, stop, files, preset, new conversation
       └─ ChatContext.Provider
            └─ ScreenMessages → MessagesView   # main chat's list, unchanged

The contract's reads are real and its writes are inert, because the reader takes no turn in a followed conversation. Inert handlers alone would leave actions that bypass them, so the contract also says so: ChatContract.readOnly, optional and absent for a chat the reader drives. Where it is set, a row offers no regenerate, edit or continue (copy and fork stay: a fork makes a conversation of the reader's own), and MessagesViewProvider reports the view as read-only, which is what the MCP app bridge and frame and the error-recovery prompts read through useIsMessagesViewReadOnly() before offering a host-bound action. The tail of the branch on screen comes from useBranchTailSelect over the conversation's cache entry, the projection useChatHelpers uses, so it does not re-render per streamed token.

Three of the list's slots are empty by default here: the pending turn and pending steers (the reader has neither in a conversation they do not drive) and the navigation rail (the surface sits beside a chat). A host can supply any of them through slots.

index is a required argument. The package's own state for rows is keyed by conversation, but a host may key per-pane state by it, so the host passes a pane number no driven chat renders into.

FollowedThread loads through loadFollowedThread, the same dynamic import as loadScreenMessages, so the message renderer stays out of the components entry.

Type of change

  • Feature
  • Tests / tooling / CI

Testing

Tested environments/configuration:

jsdom, with a real QueryClient, a real Chat through useFollowChat, and the package's real thread and row components; the transport and the two body slots are test doubles. Not yet seen in a browser: there is no app surface that mounts it until the next PR.

Automated tests:

  • Added packages/chat/src/components/pane/__tests__/followed.spec.tsx (6 cases): a stored conversation drawn by the real thread with the contract the rows read (messagesKey, latestMessageId, isSubmitting, getMessages); a running generation drawn as it streams and then as its stored result, with isSubmitting following it; send, regenerate and stop reaching neither the transport nor the list; the navigation rail absent by default and present when a host supplies one; no messages-end id or screenshot target written; the view reported read-only inside the list (fails with the provider left at readOnly: false).
  • generations.spec.ts: the same message offers rerun, edit and continue when driven, and none of them (fork still offered) when read-only. HoverButtons.spec.tsx: a read-only chat draws Copy and neither Regenerate nor Edit.
  • npx jest src/components/pane src/components/messages/thread in packages/chat plus MessagesView.spec.tsx and the thread specs (110 tests); npx tsc --noEmit; npm run static-checks -- --against origin/dev.

Screenshots / recordings

No user-facing change in this PR: the component has no caller in the app. The panel PR that mounts it carries the captures.

Risk / compatibility

MessagesView is main chat's component and gains one prop. primary defaults to true, which is today's output exactly; a followed thread passes false. The reason is two page-wide hooks the list writes: id="messages-end", which getMainScrollContainer (keyboard shortcuts) and scrollToEnd find with document.getElementById, and data-testid="screenshot-target", which the export path's host ref and several e2e specs look up. A second list on the page would duplicate both, so a non-primary list writes neither and does not take the host's screenshot ref.

readOnly is absent for every chat the app renders today, so main chat, the added pane and the shared view offer what they did.

Everything else is additive.

@danny-avila
danny-avila added this pull request to stack #18259 November 17, 2026 14:36
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch 2 times, most recently from f7dd788 to 33c9d5b Compare November 17, 2026 15:05
@lia-by-librechat lia-by-librechat Bot changed the title 🪟 feat: Draw a Followed Chat With Main Chat's Message List 📺 feat: Render Followed Chats With Main Chat's Message List Nov 17, 2026
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T16:32:22.048030Z 812db7a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33c9d5b546

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +53 to +57
<ScreenMessages
messagesTree={messagesTree}
messages={messages}
slots={listSlots}
primary={false}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate read-only mode to the followed message renderer

When a followed conversation is rendered with the app's message hosts, ScreenMessages installs MessagesViewProvider, which unconditionally sets readOnly: false. Making the contract's submission handlers inert does not disable actions that bypass them: for a non-subagent conversation, the row's Edit → Save action calls useUpdateMessageMutation directly and persists changes, while embedded MCP apps see a writable view and enable authenticated tool/resource operations through useAppBridge. Thus the supposedly display-only thread still permits writes and host-bound actions. Propagate an explicit read-only mode through the view provider and row controls rather than relying solely on no-op submission handlers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. Fixed in a8889397b2 (import order in a4e1169d5f). Read-only is now part of the contract a followed thread hands its rows, not only a set of inert handlers:

  • ChatContract.readOnly is set by useFollowedContract.
  • MessagesViewProvider reports it, so useIsMessagesViewReadOnly() is true inside a followed thread and the host-bound actions that read it (the MCP app bridge and frame, error recovery) stay off.
  • The row controls honor it: no regenerate or continue, and the edit button is hidden, so Edit → Save cannot be reached.

The contract field and the row-control gating were in #18196, two PRs up; they moved down into this one so the followed view is read-only from the PR that introduces it. #18196 keeps the tool-call-limit notice. Pinned by tells its rows the view is read-only, so host-bound actions in them stay off in pane/__tests__/followed.spec.tsx (fails with the provider left at readOnly: false), plus the moved generations and HoverButtons cases.

@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from 33c9d5b to a888939 Compare November 17, 2026 15:33
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head a4e1169.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a4e1169d5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch 2 times, most recently from f3978de to e543239 Compare November 17, 2026 15:42
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from e543239 to 98f9682 Compare November 17, 2026 15:48
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from 98f9682 to b808869 Compare November 17, 2026 15:54
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from b808869 to 0bcddea Compare November 17, 2026 16:10
@danny-avila
danny-avila marked this pull request as ready for review November 17, 2026 16:11
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from 0bcddea to 1d0ffce Compare November 17, 2026 16:15
Base automatically changed from danny-avila/follow-chat-hook to dev November 17, 2026 16:30
@danny-avila
danny-avila force-pushed the danny-avila/followed-thread-view branch from 1d0ffce to 812db7a Compare November 17, 2026 16:30
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head 812db7a (rebased onto dev after #18192 merged).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 812db7a6e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila merged commit c030523 into dev Nov 17, 2026
59 of 60 checks passed
@danny-avila
danny-avila deleted the danny-avila/followed-thread-view branch November 17, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant