Skip to content

🪟 feat: Open a Conversation Beside the Chat From Its Menu - #18440

Merged
danny-avila merged 6 commits into
devfrom
danny-avila/side-chat-open-beside
Nov 18, 2026
Merged

danny-avila merged 6 commits into
devfrom
danny-avila/side-chat-open-beside

Conversation

@danny-avila

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

Copy link
Copy Markdown
Collaborator

Summary

A side chat (#18417) could only be opened one way: by continuing a finished subagent's thread. There was no way to put a conversation the reader already has beside the one they are in.

A conversation's menu in the sidebar now has Open beside chat. It opens that conversation in the side panel, driven like any side chat: its history, a composer, send, stop, reruns. The chat on screen does not move.

an earlier conversation open beside the current one

The item is offered only where it can work:

a chat view is on screen, and the deployment keeps interface.sideChat on offered
the row is the chat on screen not offered: it cannot sit beside itself
the conversation is archived not offered
any other page (no chat to sit beside), or before the deployment's config has answered not offered

An Assistants conversation is refused with a message when chosen: those run over their own routes, which a side chat does not drive, and a sidebar row does not know its endpoint until the record is read.

How it works

Presentation            sideChatBesideAtom = { conversationId } while a chat is on screen and side chats are on,
                        a new value whenever that chat becomes another, none otherwise
                        sideChatAvailableAtom = sideChatBesideAtom != null
ConvoOptions            item shown when sideChatAvailableAtom && !isActiveConvo && !isArchived
ConvoMenuController     openBeside(): note sideChatBesideAtom, set a token in sideChatRequestAtom,
                        fetch [QueryKeys.conversation, id]
                          a newer ask, or a side chat opened or closed meanwhile, took the token  →  nothing
                          the same value is still there, and is not this conversation  →  sideChatAtom = { conversation }
                          the reader moved on meanwhile                                 →  nothing
                          a failed read, or an Assistants endpoint                      →  toast, nothing opened
Presentation            a side chat that opens takes the panel slot: the child-activity selection is cleared,
                        and the artifact panel unless it is undocked. The panel asked for last is the one shown.
                        a child's activity selected, or an artifact shown or switched, withdraws a request still
                        on its way, so it does not arrive over the newer panel
ConvoMenuController     opens through the row's toggleNav: on a small screen the sidebar drawer closes first and the
                        side chat opens once it is out of the way; on a wide one it opens at once. Whether it is still wanted
                        is asked after the record is read and again after the drawer has left
SideChatPanel           focus moves to its composer once the conversation is in (not as a sheet)

The row holds only an id and a title, so the full record is read before opening: a side chat builds its turns from the conversation's endpoint, agent and settings. The handler lives in the menu's controller, which mounts only once a row's menu is used, so idle rows carry nothing new but one boolean subscription on the rows whose menu has mounted.

Type of change

  • Feature
  • Tests / tooling / CI

Testing

Tested environments/configuration:

Chromium on the mock e2e lane, against this branch's own server: the new scenario twice, and the capture above is from it.

Automated tests:

  • e2e/specs/mock/scenarios/side-chat-open-beside.spec.ts, @scenario:side-chat-opens-conversation-beside: two conversations; the earlier one is opened beside the current from its row's menu; it shows its own history and none of the current chat's; a turn from its composer is posted for the earlier conversation and answered there; the page's path does not change; the current chat's own menu has no such item.
  • Same file, @scenario:side-chat-opens-beside-on-a-small-screen (390×844): the drawer leaves, the conversation opens as a sheet over the chat, and its composer takes a tap and typing.
  • packages/chat/src/components/side/__tests__/panel.spec.tsx: focus lands in the side chat's field once the conversation is in.
  • e2e/specs/mock/conversation-management.spec.ts: the scenario that asserts a background chat's exact menu items now expects the new one.
  • client/.../ConvoOptions/__tests__/ConvoOptions.beside.test.tsx (15), over the production menu, hooks and strings, replacing only the record request: the record is read and the side chat opened; not offered when unavailable, for the chat on screen, or for an archived one; a failed read and an Assistants conversation each say so and open nothing; a lookup that lands after the reader moved to another chat, to the requested conversation itself, or off the chat opens nothing; nor over a side chat opened meanwhile, nor over a newer choice that answered first; it opens through the row's way out of the sidebar, and only once that has run; a move to another chat, another panel or a newer ask while the drawer is leaving opens nothing.
  • client/src/components/Chat/Presentation.test.tsx (8): availability is off until the config answers, on once it has, off where the deployment turned side chats off; the chat it sits beside is named and renamed as the reader moves; a side chat opened over a child's activity or an artifact takes the slot, and gives it back to an artifact opened after it; a request still being fetched is withdrawn by a child's activity or an artifact opened after it, and not by an artifact that was already showing.
  • Removing the availability rule and the item's conditions fails five of those; removing the slot claim and the moved-on check fails four more, and removing the newest-request check two more.
  • The 17 app specs that import the conversation row, its menu, the presentation or the side chat and subagents hosts (194 tests); packages/chat npx jest (4002 tests); packages/chat tsc and the locale test; the app tsc filtered to the touched files; npm run static-checks -- --against origin/dev.

Two scenarios in conversation-management.spec.ts ("fences running rename …") time out locally at the model selector, before any conversation menu is involved. They fail the same way on plain dev in my local setup, so they are not from this change; CI is the reference for them.

Risk / compatibility

Additive: one menu item and one atom. interface.sideChat: false hides it, as it turns the rest of side chats off.

Opening a conversation that has a generation running elsewhere attaches to it, as any side chat does.

A conversation's menu in the sidebar offers to open it as a side chat
beside the chat on screen. The item appears only where there is a chat
to sit beside and side chats are on, and not for the chat on screen or
an archived one. The conversation's full record is read first, since a
side chat builds its turns from it.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head 870f049.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T18:06:56.892701Z d7ed75a 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: 870f0494fa

ℹ️ 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".

refuse(localize('com_ui_side_chat_unsupported'));
return;
}
setSideChat({ conversation });

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 Release the occupied side-panel slot before opening the chat

When an artifact or subagent thread is already displayed, choosing Open beside chat closes the menu but leaves the existing panel visible. This handler only sets sideChatAtom, whereas Presentation.tsx:202 gives artifacts and subagent panels precedence over the side chat. Neither existing selection is cleared here, so the requested conversation stays hidden until the user manually closes the other panel. Clear or transition the competing panel state when committing this action, as the subagent continuation flow already does with resetSelection() before navigation.openBeside().

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 755c8cd, in the slot's owner rather than the caller: when a side chat opens, Presentation clears the child-activity selection and, unless the artifact is undocked, the artifact panel, so the panel asked for last is the one shown in every direction (the continuation flow gets the same). Test: "gives the panel slot to a side chat opened while another panel is showing" walks child activity → side chat → artifact → side chat (fails without the effect).

queryClient
.fetchQuery([QueryKeys.conversation, convoId], () => dataService.getConversationById(convoId))
.then(
(conversation) => {

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 Discard pending opens after the main conversation changes

If the conversation lookup is slow and the user navigates before it finishes, this callback still opens the requested side chat beside the new main conversation. In particular, navigating to the requested conversation itself opens the same conversation in both panes, bypassing the menu's !isActiveConvo restriction. Presentation.tsx:87–98 clears side-chat state on navigation or unmount, but that cleanup runs before this pending promise writes it back. Associate the request with the originating chat and discard its result when that context changes or unmounts.

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 755c8cd. Presentation now publishes the chat a side chat would sit beside (sideChatBesideAtom, a new value whenever that chat changes, none when there is no chat). openBeside reads it when asked and again when the record lands, and opens nothing if it is another value, gone, or names the requested conversation itself. Read from the store rather than from this component's props, since the row can unmount while the lookup is in flight. Three tests under "when the reader moves on while the record is read" (all fail without the check).

…hat It Was Asked Beside

A side chat opened while an artifact or a child's activity is showing
now takes their place, as each of them takes its. A record lookup that
finishes after the reader has moved to another chat, or to the very
conversation asked for, opens nothing.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head 755c8cd.

@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: 755c8cd3b8

ℹ️ 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 +43 to +44
jest.mock('@librechat/client', () => ({
DropdownPopup: ({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exercise the real menu primitives in the new tests

The new suite replaces DropdownPopup and Ariakit's menu button with ordinary buttons, and also mocks internal app hooks and providers. This violates AGENTS.md's testing requirement to “Mock only external HTTP APIs or uncontrollable services.” These tests bypass the actual menu lifecycle and keyboard/focus behavior, so they cannot confirm that the new action works through the production menu. Use the real primitives and frontend test harness, mocking the HTTP boundary instead.

AGENTS.md reference: AGENTS.md:L242-L245

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 f9590ff. ConvoOptions.beside.test.tsx is rewritten on test/layout-test-utils: the production DropdownPopup and Ariakit menu (items found by their menuitem role), the app's real hooks, providers and English strings. The only module replaced is dataService.getConversationById, the request for the record; the toast is observed through a spy handed to the real ToastContext. I had copied the heavy mocking from the neighbouring archive test, which is not a reason. 11 cases, all passing.

Comment on lines +232 to +235
(conversation) => {
if (store.get(sideChatBesideAtom) !== beside || beside.conversationId === convoId) {
return;
}

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 Discard side-chat requests superseded by a newer selection

If the reader chooses Open beside chat for conversation A and then for B while A's lookup is still pending, both requests retain the same sideChatBesideAtom value. If B resolves first, it opens correctly, but A's later response passes this guard and replaces B—even if the reader has already started interacting with B. The guard only detects main-chat navigation, not a newer side-chat selection. Track a shared open-request identity across row controllers and discard responses superseded by a later request.

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 f9590ff. A request now carries a token in sideChatRequestAtom: the newest ask replaces the one before it, and sideChatAtom (now written through one setter) withdraws a pending request whenever the side chat on screen changes by any means, the continuation flow and closing included. A response opens only while its token is still the one there. Tests: "lets the reader's newer choice win over an older one that answers after it" (two real row menus, the older answering last) and "leaves a side chat the reader opened meanwhile where it is"; both fail without the check.

An older Open beside chat whose record arrives late no longer replaces
the reader's newer choice, or a side chat opened another way meanwhile.
The item's tests now drive the production menu, hooks and strings, and
replace only the request for the conversation's record.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head f9590ff.

@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: f9590ff8bf

ℹ️ 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 +58 to +60
if (value?.conversation.conversationId !== current?.conversation.conversationId) {
set(sideChatRequestAtom, null);
}

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 Cancel pending opens when another panel takes the slot

If no side chat is currently open, choosing Open beside chat and then opening an artifact or child activity before the lookup finishes leaves the pending request active. Both competing-panel effects in Presentation.tsx call setSideChat(null), but this comparison sees undefined on both sides and does not clear the request token. The delayed lookup consequently opens its side chat and clears the panel the reader selected more recently. Cancel pending requests on an explicit close even when the displayed side chat is already null, while preserving tokens for genuine refinements of an existing side chat.

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 dd4d321. Presentation now withdraws a pending request when another panel is asked for, whether or not a side chat is showing: when a child's activity is selected, and when an artifact takes the slot or another one is chosen in it. The artifact case is keyed on the artifact shown rather than on the panel's renders, so one that is merely updating withdraws nothing, and a side chat asked for over an artifact already showing still opens. Tests under "a side chat still being fetched" in Presentation.test.tsx (3; the two withdrawals fail without the fix).

refuse(localize('com_ui_side_chat_unsupported'));
return;
}
setSideChat({ conversation });

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 Dismiss the mobile drawer when opening the side chat

On mobile, choosing Open beside chat only closes the overflow menu; the conversation drawer remains expanded. Root.tsx:221 makes the entire app pane inert while that drawer is expanded, and UnifiedSidebar.tsx renders the drawer over it at full width by default. Consequently, the side chat opens behind the drawer and cannot be seen or interacted with until the reader separately dismisses navigation. Unlike ordinary conversation selection in Convo.tsx, this path never closes the drawer. Dismiss it through the sidebar's close mechanism when successfully opening the side chat.

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 dd4d321. The row's own toggleNav is passed down to the menu's controller, and the side chat opens through it: on a small screen it closes the drawer and opens once it is out of the way, on a wide one it opens at once. That is the path conversation selection takes in Convo.tsx, passed in rather than reached for. Unit test: "leaves the sidebar the way selecting a conversation does, then opens". Browser: new @scenario:side-chat-opens-beside-on-a-small-screen at 390×844 (the sheet is visible, the row is out of the viewport, the composer takes a tap and typing); both fail without it.

…ear of the Drawer

A side chat still being fetched no longer arrives over an artifact or a
child's activity opened after it was asked for. On a small screen the
sidebar drawer leaves first, the way it does when a conversation is
selected, so the side chat is not opened behind it. Once its
conversation is in, focus moves to its composer.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head dd4d321. Third round, so beyond the two threads I read this entry point by invariant (which panel was asked for last, cancellation, the small-screen path, focus). One more change came out of that: focus moves to the side chat's composer once its conversation is in, since it is opened from a control elsewhere on the page (not as a sheet, whose focus trap decides).

@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: dd4d321a0a

ℹ️ 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 +259 to +264
const open = () => setSideChat({ conversation });
if (leaveSidebar.current == null) {
open();
return;
}
leaveSidebar.current(open);

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 Recheck cancellation after the drawer's deferred close

On mobile, useSidebarToggle.setSidebarOpen defers this callback by three animation frames, but the request token is cleared and the originating-chat check runs before that deferral. If the main conversation changes or a streaming artifact takes the panel slot during those frames, open still installs the side chat, overriding the newer context or panel selection. The new leaveSidebar.current(open) introduces an asynchronous stage after the guards that addressed the earlier lookup race. Keep the request token active through this stage and recheck both identities inside open immediately before writing sideChatAtom.

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, and introduced by my own fix for the drawer. Fixed in 4001076: the request keeps its token until the side chat is written, and one predicate (still the newest ask, still beside the same chat, not that chat itself) is asked after the record is read and again inside the step the drawer defers. Ending a request never clears a newer one's token. Three tests under "while the sidebar is getting out of the way" hold the drawer open and change the chat, take the slot, or ask anew before it leaves; all three fail without the second check.

…Has Left

The drawer takes a few frames to leave, and the checks that a side chat
was still the reader's newest ask ran before that. The request now
stays theirs until the side chat is written, and is asked about again
at that point.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head 4001076.

@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: 4001076ed7

ℹ️ 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".

jest.mock('~/data-provider', () => ({
useDeleteFilesMutation: () => ({ mutateAsync: jest.fn() }),
useGetStartupConfig: () => ({ data: undefined }),
useGetStartupConfig: () => mockStartupConfig,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Test side-chat availability through the real config hook

The new availability tests drive a mocked useGetStartupConfig by assigning its return value directly, extending the existing internal mocks to cover the newly introduced behavior. This violates the root AGENTS.md requirement to mock only external HTTP APIs or uncontrollable services, and bypasses the actual query lifecycle that determines when the action becomes available. Use the real hook and frontend test harness for these new cases, controlling the startup-config response at the HTTP boundary instead.

AGENTS.md reference: AGENTS.md:L242-L245

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 d7ed75a. Presentation.test.tsx now runs the app's real useGetStartupConfig and answers it at the data service (dataService.getStartupConfig), for the whole file. The availability cases follow the query's lifecycle: not available while the request is unanswered, available once it answers, not available when it answers with sideChat: false; two of them fail with the rule removed. What I did not change: the file still uses its existing stand-ins for the lazily loaded panels (artifacts, child activity, and now the side chat) to tell which one holds the slot. Those are what this file asserts on; the real panels and their composition are covered in the browser by side-chat-open-beside.spec.ts and subagent-activity.spec.ts.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head d7ed75a.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: d7ed75a664

ℹ️ 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 marked this pull request as ready for review November 18, 2026 18:09
@danny-avila
danny-avila merged commit ba44abd into dev Nov 18, 2026
60 of 61 checks passed
@danny-avila
danny-avila deleted the danny-avila/side-chat-open-beside branch November 18, 2026 19:09
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