feat(web): drag threads across sections with consistent motion #9731
Mergedjuliusmarmingemerged 4 commits into
sidebar/mobile-active-order fromrefs/pull/9731/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -2775,3 +3034,19 @@27753034 );2776- const canonicalKeys = canonical.map((thread) =>2777- scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),3035+ const thread = canonicalByKey.get(optimisticDrop.key);3036+ if (thread === undefined || thread.archivedAt !== null) {3037+ setOptimisticDrop(null);3038+ return;3039+ }3040+ const canonicalSection = effectiveSnoozed(thread, { now: new Date().toISOString() })3041+ ? "snoozed"3042+ : thread.settledOverride === "settled"3043+ ? "settled"3044+ : thread.pinnedAt != null3045+ ? "pinned"3046+ : "active";3047+ if (3048+ canonicalSection !== optimisticDrop.sourceSection &&3049+ canonicalSection !== optimisticDrop.section3050+ ) {3051+ setOptimisticDrop(null);3052+ return;@@ -2850,0 +3178,21 @@3178+ return [];3179+ }3180+ const items: SidebarListItem[] = [{ kind: "marker", marker: "pinned-header" }];3181+ const pinnedRows = rowsOf(pinnedThreads, "pinned");3182+ items.push(...pinnedRows);3183+ items.push({ kind: "marker", marker: "pinned-divider" });3184+ const activeRows = rowsOf(activeThreads, "active");3185+ if (activeRows.length === 0) {3186+ items.push({ kind: "marker", marker: "active-placeholder" });3187+ }3188+ items.push(...activeRows);3189+ if (snoozedThreads.length > 0) {3190+ items.push({ kind: "marker", marker: "snoozed-header" });3191+ items.push(...rowsOf(visibleSnoozedThreads, "snoozed"));3192+ }3193+ items.push({ kind: "marker", marker: "settled-header" });3194+ const settledRows = rowsOf(renderedSettledThreads, "settled");3195+ if (settledRows.length === 0) {3196+ items.push({ kind: "marker", marker: "settled-placeholder" });3197+ }3198+ items.push(...settledRows);
- apps/web/src/components/Sidebar.tsx lines 2490 to 2494OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2273,10 +2480,15 @@22732480 // Threads on servers without the settlement capability (old server,22742481 // or descriptor not loaded yet) never classify as settled: the user22752482 // could neither un-settle nor pin them, so auto-settling them would22762483 // strand rows in a tail with no working affordances.2277- const supportsSettlement =2278- serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSettlement === true;2279- const supportsSnooze =2280- serverConfigs.get(thread.environmentId)?.environment.capabilities.threadSnooze === true;2281- // Snooze outranks settlement and pinning until the thread wakes.2282- if (supportsSnooze && effectiveSnoozed(thread, { now: preciseNow })) {2484+ const supportsSettlement = capabilities?.threadSettlement === true;2485+ const supportsSnooze = capabilities?.threadSnooze === true;2486+ const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));2487+ if (capabilities?.threadActiveReorder === true) activeReorderable.add(threadKey);2488+ // Older servers retain their existing drag actions. Active placement2489+ // additionally requires its own ordering capability at the drop target.2490+ if (2491+ supportsSettlement &&2492+ capabilities?.threadPinning === true &&2493+ capabilities.threadPinReorder === true2494+ ) {apps/web/src/components/Sidebar.logic.ts line 242Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -85,0 +217,21 @@217+ activePinned = activeSection === "pinned",218+ activeSettled = activeSection === "settled",219+ target,220+ pinnedOrder,221+ pinnedKeysById,222+ reorderableKeys,223+ activeOrder,224+ activeKeysById,225+ activeReorderableKeys,226+ } = input;227+ switch (target.section) {228+ case "active": {229+ const order = target.activeOrder;230+ if (231+ activeSection === "active" &&232+ order.length === activeOrder.length &&233+ order.every((key, index) => key === activeOrder[index])234+ ) {235+ return { kind: "none" };236+ }237+ const assignments = planPinnedReorder({apps/web/src/components/Sidebar.logic.ts line 95OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -79,7 +79,17 @@797980-// The list already reaches its destination through sortable transforms while81-// the pointer is down. dnd-kit's default also animates the committed DOM order82-// after release, replaying the same movement across every affected row.83-export const animatePinnedLayoutChanges: AnimateLayoutChanges = (args) =>80+// Sidebar.motion handles ordinary section changes. Sortable transforms own81+// dragging; replaying their committed DOM order would animate the drop twice.82+export const animateSidebarLayoutChanges: AnimateLayoutChanges = (args) =>8483 args.isSorting ? defaultAnimateLayoutChanges(args) : false;858485+// Rows and section markers share one sortable list. The separators resolve86+// the lifecycle action; Sidebar.drag previews the resulting layout. Pinned87+// and active threads keep the dragged position; settled threads use time88+// order. Snoozed rows can leave the shelf, but dropping into it is not89+// supported because snoozing requires a wake time.90+91+export type SidebarSection = "pinned" | "active" | "snoozed" | "settled";92+93+/** Sortable ids: thread rows use their scoped key; structural items use a94+ prefix that cannot collide with `<environmentId>:<threadId>`. */95+const SIDEBAR_MARKER_PREFIX = "marker:";
juliusmarminge merged this4023d93
juliusmarminge closed this
Sign in to join this conversation.






Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
e908032· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.