Skip to content

Commit 46494ca

Browse files
Stabilize sidebar settling animations
- Key card and slim rows by variant to prevent cross-row FLIP artifacts - Render the Settled divider as a stable standalone list item
1 parent 32c6012 commit 46494ca

1 file changed

Lines changed: 30 additions & 14 deletions

File tree

‎apps/web/src/components/SidebarV2.tsx‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
128128
// False on environments whose server predates thread.settle/unsettle:
129129
// the lifecycle affordances hide entirely rather than fail on click.
130130
settlementSupported: boolean;
131-
// Marks where active work transitions into history: a quiet labeled
132-
// rule above the first settled row, so the tail reads as a named zone
133-
// rather than an unexplained gap.
134-
showSettledGap?: boolean;
135131
isActive: boolean;
136132
jumpLabel: string | null;
137133
currentEnvironmentId: string | null;
@@ -397,12 +393,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
397393
data-thread-item
398394
className="list-none [content-visibility:auto] [contain-intrinsic-size:auto_34px]"
399395
>
400-
{props.showSettledGap ? (
401-
<div aria-hidden className="mb-1 mt-3 flex items-center gap-2 px-2.5">
402-
<span className="text-[10px] font-medium text-muted-foreground/50">Settled</span>
403-
<span className="h-px flex-1 bg-border/60" />
404-
</div>
405-
) : null}
406396
<div
407397
role="button"
408398
tabIndex={0}
@@ -1527,7 +1517,7 @@ export default function SidebarV2() {
15271517
) : null}
15281518
<SidebarGroup className="min-h-0 flex-1 overflow-y-auto px-2 py-1">
15291519
<ul ref={attachListAutoAnimateRef} className="flex flex-col gap-px">
1530-
{orderedThreads.map((thread, threadIndex) => {
1520+
{orderedThreads.flatMap((thread, threadIndex) => {
15311521
const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
15321522
const isSettledRow = settledThreadKeys.has(threadKey);
15331523
// Settled is the ONLY thing that collapses a row: every
@@ -1542,10 +1532,14 @@ export default function SidebarV2() {
15421532
scopedThreadKey(scopeThreadRef(previousThread.environmentId, previousThread.id)),
15431533
);
15441534
const showSettledGap = !isCard && previousWasCard;
1545-
return (
1535+
const row = (
15461536
<SidebarV2Row
1547-
showSettledGap={showSettledGap}
1548-
key={threadKey}
1537+
// Keyed per variant on purpose: when a thread settles, the
1538+
// card fades out in place and the slim row fades in at its
1539+
// settled position instead of one element FLIP-sliding
1540+
// through every row in between (rows here are translucent,
1541+
// so a crossing row reads as text painted over text).
1542+
key={`${threadKey}:${isCard ? "card" : "slim"}`}
15491543
thread={thread}
15501544
variant={isCard ? "card" : "slim"}
15511545
// Every settled row can un-settle: explicit settles clear
@@ -1580,6 +1574,28 @@ export default function SidebarV2() {
15801574
onChangeRequestState={handleChangeRequestState}
15811575
/>
15821576
);
1577+
if (!showSettledGap) return [row];
1578+
// The divider is its own keyed list item (not part of the first
1579+
// settled row): it keeps one stable DOM node at the boundary,
1580+
// so settling a thread slides it instead of teleporting it
1581+
// along with whichever row happens to be first in the tail —
1582+
// and row heights stay independent of neighbor classification.
1583+
return [
1584+
<li
1585+
key="settled-divider"
1586+
aria-hidden
1587+
data-thread-selection-safe
1588+
className="list-none"
1589+
>
1590+
<div className="mb-1 mt-3 flex items-center gap-2 px-2.5">
1591+
<span className="text-[10px] font-medium text-muted-foreground/50">
1592+
Settled
1593+
</span>
1594+
<span className="h-px flex-1 bg-border/60" />
1595+
</div>
1596+
</li>,
1597+
row,
1598+
];
15831599
})}
15841600
{hiddenSettledCount > 0 ? (
15851601
<li className="list-none">

0 commit comments

Comments
 (0)