LibreChat/client
Marco Beretta 9bf51fc302
🧷 style: Sidebar Row Controls, Pinned Unpin Badge and Drag Rules (#15870)
* 🔘 style: Seat Sidebar Row Actions One Radius Inside Their Row

Every control that sits on a sidebar row took the base `rounded-lg`, the same
radius as the row hosting it, so a hovered button filled corner to corner with
its row. `row-action` and `section-action` now carry `rounded-md`, one step
inside the rows, which stay as they were.

Three controls also diverged from the recipe they were built on. `ConvoOptions`
and the Projects heading action overrode the variant's hover fill with
`surface-hover`; the rename form's save and cancel buttons answered the pointer
with `hover:opacity-70` and no fill at all. All four now take the shared hover.

The project row's two actions are the exception that earns its own recipe: they
sit on a row that fills on hover, where the variant's hover surface reads as a
second, weaker hover stacked on the first. They take `surface-active` instead,
under the pointer and while the menu one of them owns is open, and sit 4px apart
like a pinned chat's own pair.

* 🧲 fix: Give Both Pinned Row Kinds One Unpin Badge, and Stop Its Flicker

Pinned chats and pinned agents/models sit in one list and are dragged against
each other, but their unpin badges were two controls: the chat's was
`text-text-primary` and always visible, the favorite's was a hand-rolled copy of
the shared row action, `text-text-secondary`, revealed on hover. `UnpinButton`
is now the single badge both rows render. It keeps the favorites' reveal, holds
open while the row's overflow menu is, and is inert while hidden so it cannot
swallow a click meant for the row.

The reveal is asked for in JS rather than through an `@media (hover: hover)`
variant: the variant has to beat the `group-hover` rules that reveal the badge,
and it loses that cascade for `opacity` while winning it for `pointer-events`,
which left the badge visible and unclickable.

Two things made a row's controls flicker under the pointer:

- The overflow slot took its width from its content, and the menu mounts a tick
  after the row is hovered. The unpin badge beside it slid 28px left at that
  moment, out from under the pointer, mid-fill; whatever landed there started
  its own. The slot now reserves its width from the row's hover, and `shrink-0`
  keeps a growing sibling from squeezing it.
- `hasInteracted` unmounted that menu on every leave, so each entry mounted a
  fresh button one frame late into an already-revealed slot, restarting its fill
  from transparent. A row that has been reached now keeps its control for as
  long as the row lives; virtualization still drops the whole row.

* 🧺 feat: Unpin a Chat by Dropping It on Chats, and Keep Pinned Kinds Apart

Dropping a chat on the Chats section filed it out of its project but left a
pinned one pinned, so the section it landed in was not the section it went to.
The drop now also unpins, and accepts a pinned chat that is already in the root
list; a chat that is both filed and pinned comes out of both, each call a no-op
for the half that already holds.

Pinned chats and pinned agents/models could be dragged through each other, which
the list cannot honour: the two are ordered independently and a row dropped into
the other group snapped back. Each row now accepts only its own drag type, so
the other kind never previews a displacement, and Alt+Arrow refuses the same
step. An order saved while the two interleaved is read back grouped, or a row
would be walled in by neighbours it is not allowed to swap with.

* 🧹 fix: Unnest the Row Action Width Ternary and Correct the Pinned Doc

The rebase onto `dev` left two things the branch's own checks catch: the width
branch that reserves a chat row's action slot had grown a nested ternary, which
the repository's ESLint forbids, and `dnd.ts` carried an import out of order.

The section's own doc comment still promised that favorites and conversations
"interleave freely", which this branch stopped being true: a row only reorders
against its own kind, and a stored order is read back grouped.

* 🪃 fix: Keep a Pinned Reorder That Was Released on a Row

Reordering the Pinned section with the pointer never survived the release. The
rows shifted under the drag, and the moment the button came up they snapped back
to where they had started; nothing was written, so a reload showed the old order
too. Only Alt+Arrow could actually reorder the list.

A row is a drop target — that is what makes the hover that reorders the list
arrive at all, since the HTML5 backend reports hover only for targets that could
receive the drag. react-dnd then counts that target as having handled the drop
whether or not it carries a `drop` handler, so `monitor.didDrop()` was true for
every release on a row, and the drag's `end` reads that as "this chat was filed
somewhere else" and discards the arrangement the drag built.

The row now answers the release with a result that names it, and `end` treats a
handled drop as a filing action only when the result is not that one. The same
change stops a row swallowing the drop of an unpinned chat that lands on it:
that drop reaches the section underneath, which is what pins the chat.

Covered by `dropping-a-chat-on-a-pinned-row-pins-it` and the same-kind control
inside `a-pinned-chat-cannot-be-dragged-through-a-pinned-model`, both in
`e2e/specs/mock/scenarios/pinned-drag-rules.spec.ts`.

* 🧪 test: Drive the Sidebar Row Rules in a Real Browser

Twelve scenarios in the mock harness, one per behaviour this branch claims: the
radius and fill every row control draws inside its row, the one unpin badge both
pinned row kinds carry and when it shows, the controls holding still while the
pointer crosses a row, the touch tap that reaches the badge directly, the drop on
Chats that unpins, the drop on a pinned row that pins, the kind boundary a drag
and Alt+Arrow both refuse, and the stored interleaved order that loads grouped.

They seed pinned chats straight into Mongo and set favourites and the pinned
order through the routes the star and the drag use, so the server's own cache
invalidation runs. Pointer-only scenarios skip on a pointer that cannot hover and
the touch scenario skips where it can, which is what lets the same file cover the
desktop and mobile projects.

`dragRowOnto` steps the pointer rather than jumping: the list reorders on
`dragover` once the pointer has crossed the hovered row's midpoint, and a single
move never delivers enough of them.

* 🧭 fix: Sequence the Two Halves of a Drop on Chats, and Reach the Mobile Drawer

Dropping a chat that is both pinned and filed in a project asked for the two
writes at once. The pin route answers with the conversation as it stands after
its own write, and the sidebar publishes that answer into every list, so a pin
that overlapped the project write could put the old `chatProjectId` back over
the lists the assignment had just corrected — and a failed assignment still left
the chat unpinned, out of the section it had been dragged from and still in the
project it was supposed to leave.

The unpin now waits for the assignment and runs only if it took, so a failure
leaves the chat exactly where it was and the published snapshot is the one taken
after both writes. `useAssignDroppedConversation` reports that outcome through a
named `AssignDroppedConversation` type, and the project row's drop keeps handing
back nothing, since the pinned list reads the drop result to tell a reorder from
a filing action.

On a narrow viewport the sidebar is a drawer that slides out of view rather than
unmounting, so its rows answer every query while nothing on them can be tapped.
The scenario helpers open it through the chat header the way a person does,
which is what lets the touch and keyboard scenarios run in the mobile project.

* 📝 docs: Say What the Kept Overflow Control Actually Costs

The comment beside `hasInteracted` claimed virtualization bounded the controls a
hovered row leaves mounted. It does for the chats list, which drops a row as it
scrolls out, but not for the Pinned section: that one mounts every pinned row at
once, so a pointer crossing it leaves one `ConvoOptions` per row it touched,
standing until the section unmounts. The bound there is the number of chats the
user pinned, which is worth stating rather than implying it is zero.

* ⏱️ test: Give the Sidebar Scenario Hooks the Time Their Seeding Takes

`test.setTimeout` called inside a test body does not reach the hooks around it,
and the slow part of these scenarios is in a hook: seeding a pinned list, then
reloading and waiting for the section. On a loaded machine the `beforeEach` hit
the default 30s and failed a scenario whose own budget was 60s. The timeout is
configured once per file instead, and the per-test calls it duplicated are gone.

* ⏳ test: Allow for the Cold Start the First Sidebar Scenario Pays

The first test of a run loads the app for the first time against a database that\nmay be a network hop away, and under reviewctl verify that first load pushed the\nseeding hook past 60s. The file budget is 120s and the navigation waits are 30s,\nwhich is the cold start plus room, not a licence for a slow assertion: every\nassertion here still resolves in single-digit seconds once the app is warm.

* 🧱 test: Tell an Unlaid Sidebar From a Closed One

The helper that brings the sidebar on screen read a missing bounding box as "off\nscreen" and reached for the chat header's opener, which desktop widths do not\nrender: the click waited out the whole test budget while the panel it was waiting\nfor was already open beside it. Placement is now three states — on screen, slid\nout of view, not laid out yet — and only a drawer that is really closed, on a\nviewport that really has an opener, is clicked.

* 🧮 fix: Keep Each Pinned Kind in Its Own Slots, and Never Report a Pending Write as Done

Two ways the drop and order bookkeeping could still move a row nobody touched.

A stored order written before the two kinds were kept apart can interleave them,
and `mergeVisibleOrder` substituted visible keys across that interleaving. With
part of the pinned list still draining, reordering two visible chats could carry
an undelivered chat across the favorite between them, so the row moved within its
own group once the rest of the list arrived. The stored order is now grouped the
way the section reads it back, and each kind is substituted inside its own run.

`useAssignDroppedConversation` treated a pending assignment's destination as an
outcome: dropping the same chat on Chats again while its first write was still in
flight matched `effectiveProjectId`, reported success, and unpinned the chat — and
if that first write then failed, the chat stayed in its project with its pin gone.
A write already heading where the drop asks now reports "not filed", so the drop
that started it keeps ownership of what follows.

Covered by `dnd.spec.ts` (`keeps each kind in its own slots when a legacy order
interleaves them`), `unpinDropped.spec.tsx` (`does not unpin again while an
assignment to the same place is in flight`) and the `PinnedSection` hidden-key
test, which now states the normalized order it expects.

The pinned scenarios also wait for the rows to advertise their reorder shortcut
before dragging: a move is refused until the saved order has arrived, so a drag
issued before that passed or failed on how fast the query answered.

* 🔗 fix: Wait for the Write a Drop Asked For, Whoever Started It

The pending-assignment guard assumed the write in flight belonged to another\ndrop, which would unpin the chat when it landed. The row menu populates the same\nmap and unfiles a chat without unpinning it, so a drop onto Chats made while that\nmenu action was in flight did nothing at all: an accepted drop left the chat in\nthe Pinned section.\n\nA pending entry now only stops this path from reading \ as\n"already there". The drop issues its own write and waits for that one; the\nmutation queues writes per conversation, so it lands after the one already out\nand repeats what it asked for, which the server takes as the no-op it is. The\nunpin still runs only on a write this drop saw succeed.

* 🛰️ fix: Let the Server Say Whether a Dropped Chat Is Out of Its Project

Three rounds of review found three ways the same guess went wrong, so the guess
is gone. Deciding locally whether the filing half of a Chats drop "already
holds" meant reading one of three things that are not the answer: a pending
write, which is a request that can still fail; a cached project, which another
tab may already have changed; or the drag item's own copy, older still. Each one
could let the drop unpin a chat that stayed in its project, and a chat that is
pinned nowhere and filed in a project is in neither list the sidebar shows.

The drop now always sends the assignment and acts on what comes back. Repeating
an assignment the chat already has is the no-op update it looks like, and the
mutation queues writes per conversation, so this one lands after anything
already out. The success notice reads the two project ids in the response rather
than the fact that a request was sent, so a write that moved nothing stays
quiet — which is what a pinned chat with no project gets when it is dropped on
Chats.

`unpinDropped.spec.tsx` covers the three: the unpin waits for the write, a failed
write keeps the pin, and a chat already out of every project is still confirmed
with the server and unpinned without announcing a move that did not happen.

The scenario drag helper also steps its pointer more finely. The list shifts rows
as it reorders and reads the pointer offset when the hover fires; a pointer that
arrived in one jump got a single reading, sometimes taken mid-render, and the
reorder it asked for did not always happen.

* 🧷 test: Press Only a Row the List Has Connected for Dragging

The pinned list disconnects its drag sources while the saved order reconciles,\nand a press on a disconnected row is not a refused drag — it is a click, so the\nrow opens instead of moving. Against the lab database, where that reconciliation\ntakes long enough to overlap the gesture, the Chats-drop scenario failed with the\ndragged row still pinned and now the active chat.\n\nreact-dnd marks a connected source \, so the helper waits for that\nbefore pressing.
2026-09-13 16:40:00 +02:00
..
public 🍋 feat: Add AMD Lemonade Provider Recognition and Branding (#15664) 2026-09-06 20:46:08 +02:00
src 🧷 style: Sidebar Row Controls, Pinned Unpin Badge and Drag Rules (#15870) 2026-09-13 16:40:00 +02:00
sw
test
babel.config.cjs
check_updates.sh
index.html 🔭 feat: Tag Browser Diagnostics With Client Build IDs (#15656) 2026-09-06 12:47:34 -04:00
jest.config.cjs 🚀 v0.8.8-rc3 (#15859) 2026-09-13 02:17:48 -04:00
jest.resolver.cjs
nginx.conf
package.json 🚀 v0.8.8-rc3 (#15859) 2026-09-13 02:17:48 -04:00
postcss.config.cjs
tailwind.config.cjs
tsconfig.json
vite.config.ts 🖼️ fix: Precache PWA Icons and Let Them Refresh (#15654) 2026-09-06 11:32:09 -04:00