LibreChat/client/src/components
Marco Beretta afaf22f608
🧊 fix: Withhold Rerun Controls on Compaction Turns (#15797)
* 🧊 fix: Withhold Rerun Controls on Compaction Turns

A compaction turn's response parents onto the leaf it summarized, not onto a
user message, so the hover Edit's Rerun replayed an assistant message in the
user slot: the request minted a user message under the existing assistant
leaf's id and ran the turn with empty text, which fails. Editing offered
nothing either, since SUMMARY is not an editable part type.

Edit, Regenerate and Continue are now withheld on a compaction turn, and both
rerun paths refuse a parent that is not user-created, matching the guard
`useChatFunctions.regenerate` already applied.

* 🧭 fix: Gate Rerun Controls on the Replayed Parent Turn

Withholding Edit, Regenerate and Continue on summary-only content also hit an
ordinary turn that auto-summarized and was cancelled before its first answer
token: that response is parented to the user's message and is exactly the turn
a rerun is for. The row now resolves the message it would replay and withholds
the rerun shapes only when a model turn hangs off another model turn, which is
the manual compaction shape. An unresolvable parent withholds nothing.

`isCompactionTurn` is gone with it, and `isCompactedLeaf` keeps its original
body; its docstring now says per part what it always measured per part.

* 🧮 fix: Identify a Compaction Turn by Content and Parent

Gating the rerun controls on parent authorship alone withheld Edit, Regenerate
and Continue from any model turn hanging off another model turn. An imported
conversation chains messages sequentially, so a skipped empty human message
leaves an ordinary reply parented to the previous reply; its stored content is
editable and its controls must stay. It also made every model row resolve its
parent out of the flat message list: 100 full-thread scans while mounting a
200-message conversation.

A manual compaction is now both halves of its shape — summary-only content and
a parent that is not the user's turn — so only such a row consults the thread.
`isSummaryOnlyContent` is the content half, in data-provider next to
`isCompactedLeaf`.

* 🧷 test: Pin the Rerun Refusal on a Chained Model Turn

A rerun replays its parent as the user turn, so a model turn parented onto
another model turn must submit nothing rather than mint a user message under an
existing response's id. Removing the guard makes the case call `ask` once.

* 🧱 fix: Gate the Editor on Content and the Rerun on the Parent

Identifying a compaction turn by content shape missed the ones the server
persists with an error part (a skipped or failed compaction keeps its
explanation instead of a summary), which left Edit, Regenerate and Continue on
a turn where every rerun shape is inert.

The two controls answer two different questions now. A rerun replays the
message's parent as the turn's user message, so Regenerate and Continue go
whenever a model turn hangs off a model turn. The editor goes only when that
turn also has no part to type in: an imported chain's reply is saved directly
and stays editable, while a compaction — summary or error part — would open an
empty editor with one inert Rerun.

`findMessageById` indexes the messages array once per identity, so resolving
the parent no longer scans the thread per row: 100 full-array walks while
mounting a 200-message conversation become one.

* 🏷️ fix: Honor the Server's Compaction Marker on Any Leaf

Compact runs on whatever leaf the branch ends with, so a compaction can hang off
a user message rather than off the answer it summarized. Inferring the turn from
its position alone left the rerun controls on that one: replaying the parent
would answer the user's earlier message again instead of redoing the compaction.

`isUserInitiatedCompaction` reads the marker the server already stamps —
`markCompactionSummary` sets `initiatedBy: 'user'`, and nothing else writes it,
so an automatic summary detour keeps its controls. A marked turn is excluded
from the rerun shapes wherever it hangs.

* 🎨 fix: Ask the Editor What It Can Edit

The hover row had its own idea of an editable part and counted artifact-bearing
text as one, while `EditContentParts` keeps an artifact in its read-only
renderer. A chained model turn whose only content is an artifact therefore still
offered Edit, and opening it gave a read-only artifact, a disabled Save and a
Rerun the guards refuse.

`editableParts.ts` now owns that rule for both: `isEditablePart` is the
editor's own filter, `hasEditablePart` asks it per message. The row resolves it
lazily — the artifact check parses markdown, and only a turn with nothing to
replay needs the answer — so a streaming row never pays for it.

* 🚫 fix: Withhold the Editor's Rerun Instead of Refusing It

Both editors resolved the parent inside the handler and returned when it was not
a user turn, so a chained model turn — an imported thread with no user message
between two replies — kept an enabled Rerun that did nothing, with Ctrl/Cmd+Enter
bound to it.

Each editor resolves that parent at render and withholds the action instead: the
button is gone, the shortcut is inert and `aria-keyshortcuts` no longer advertises
it, while Save keeps writing the edit. An unresolvable parent keeps the action,
matching the hover row.

* 🧹 style: Sort the New Imports in Both Editors

CI's import-sort check failed on the two files the previous commit touched.

* 💬 fix: Report Unsaved Changes When No Rerun Is Offered

A save-only editor still warned about the rerun. An answer's draft is discarded
by the rerun, and multi-part edits must be saved before one, but neither is true
where the action is withheld — a model turn chained onto another model turn — so
the status slot claimed a precondition for something the footer does not offer.

Both statuses are gated on the same `canRerun` the button is: the plain-text
editor reports unsaved changes, and `rerunRequiresSave` cannot hold without a
rerun to require it.

* 🧪 test: Exercise the Compaction Controls in the Browser

Eight mock-harness scenarios drive the real row and the real editors: a
finished, failed, error-part and user-parented compaction withhold Edit,
Regenerate and Continue while Copy stays; a turn that only auto-summarized
keeps all three; a reply chained onto a reply keeps a save-only editor whose
status reports unsaved changes; an artifact-only chained reply loses the
editor; and the context indicator still offers Compact after a failed
compaction.

`SeedMessage` carries `content`, `finish_reason` and `model` so a branch can be
seeded in the shapes the mock model cannot produce — a persisted summary, an
error part, an artifact.
2026-09-11 10:41:50 -04:00
..
__tests__
Agents ✨ feat: add morphing state icons across the client (#14697) 2026-09-04 03:27:14 +02:00
Appearance ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Artifacts ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Audio 🧹 chore: Sort Client Imports Left Behind by the Import Order Gate (#15139) 2026-08-23 15:18:05 -04:00
Auth 🔐 fix: Redirect OAuth Browser Navigations Instead of Rendering JSON (#15440) 2026-08-31 21:13:47 -04:00
Banners
Bookmarks ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Chat 🧊 fix: Withhold Rerun Controls on Compaction Turns (#15797) 2026-09-11 10:41:50 -04:00
Conversations 📌 feat: Unified Pinned Section With Sidebar Drag Interactions (#15057) 2026-09-11 10:41:05 -04:00
Endpoints ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Files ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Input ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Insights 🩻 feat(insights): Scope Insights to Authorized Agents (#15549) 2026-09-04 20:16:58 -04:00
MCP 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
MCPUIResource 🧩 fix: Normalize MCP UI Resource Rendering (#14868) 2026-08-15 12:49:59 -04:00
Messages 🌳 fix: Guard Ambiguous BYOM Workspace Selection (#15785) 2026-09-09 14:27:54 -04:00
Nav 📌 feat: Unified Pinned Section With Sidebar Drag Interactions (#15057) 2026-09-11 10:41:05 -04:00
OAuth
Plugins/Store ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Projects 🕰️ feat: Clock Format and Week Start Preferences (#15121) 2026-08-23 18:41:14 -04:00
Prompts ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
Share 🧶 feat: Flatten Active Message Threads Behind a Flag (#15633) 2026-09-06 14:30:50 -04:00
SharePoint 🎨 feat: Refine Client Colors and Sharing Dialogs (#14734) 2026-08-10 22:43:57 -04:00
Sharing ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
SidePanel 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
Skills 📣 fix: Surface Skill Creation Feedback (#15649) 2026-09-06 17:24:37 -04:00
System
Tools 🎨 feat: Refine Client Colors and Sharing Dialogs (#14734) 2026-08-10 22:43:57 -04:00
ui 🎨 feat: Theme-Adaptive SVG Support for Custom MCP and Group Icons (#13817) 2026-09-04 10:49:43 -04:00
UnifiedSidebar 📌 feat: Unified Pinned Section With Sidebar Drag Interactions (#15057) 2026-09-11 10:41:05 -04:00
Variables 🗓️ fix: Hide Unsupported Schedule Variables (#15053) 2026-08-20 18:33:00 -04:00
Web ♿ feat: High Contrast Light and Dark Appearance Modes (#15178) 2026-09-05 22:20:33 +02:00
index.ts
QueryDevtoolsGate.tsx