feat(web): unpin threads from the sidebar multi-select menu (#9651)

Co-authored-by: Claude Fable 5.1 <[email protected]>
This commit is contained in:
GianmarcoandClaude Fable 5.1 authored and GitHub committed 2026-09-04 13:49:26 -04:00
1 parent 7d5dc66c15
commit c7bf3115f2
3 files changed
+48

No files matched your search

@@ -4,6 +4,7 @@ import {
animatePinnedLayoutChanges,
archiveSelectedThreadEntries,
buildBulkTitleRegenerationContextMenuItem,
buildBulkUnpinContextMenuItem,
buildMultiSelectThreadContextMenuItems,
createThreadJumpHintVisibilityController,
filterSidebarProjectScopeItems,
@@ -185,6 +186,19 @@ describe("archiveSelectedThreadEntries", () => {
});
});
describe("buildBulkUnpinContextMenuItem", () => {
it("counts only the pinned rows of a mixed selection", () => {
expect(buildBulkUnpinContextMenuItem({ pinnedCount: 2 })).toEqual({
id: "unpin",
label: "Unpin (2)",
});
});
it("omits the action when nothing selected is pinned", () => {
expect(buildBulkUnpinContextMenuItem({ pinnedCount: 0 })).toBeNull();
});
});
describe("buildBulkTitleRegenerationContextMenuItem", () => {
it("counts only threads that can start a new regeneration", () => {
expect(
+12
View File
@@ -177,6 +177,18 @@ export function buildBulkTitleRegenerationContextMenuItem(input: {
};
}
/**
* Bulk unpin follows the same "count only what the action will touch" rule
* as title regeneration: on a mixed selection the label counts the pinned
* rows alone, and the item disappears when nothing selected is pinned.
*/
export function buildBulkUnpinContextMenuItem(input: {
pinnedCount: number;
}): ContextMenuItem<"unpin"> | null {
if (input.pinnedCount === 0) return null;
return { id: "unpin", label: `Unpin (${input.pinnedCount})` };
}
export interface ThreadStatusPill {
label:
| "Working"
+22
View File
@@ -130,6 +130,7 @@ import { buildThreadActionMenuItems } from "./threadActionMenu.logic";
import {
animatePinnedLayoutChanges,
buildBulkTitleRegenerationContextMenuItem,
buildBulkUnpinContextMenuItem,
filterSidebarProjectScopeItems,
formatWorkingDurationLabel,
firstValidTimestampMs,
@@ -3025,10 +3026,22 @@ export default function Sidebar() {
supportedCount: titleRegenerationThreads.length,
actionableCount: regeneratableTitleThreads.length,
});
// Unpin (k) counts only the pinned rows in pin-capable environments —
// on a mixed selection the unpinned rows are untouched, and the item
// is omitted entirely when nothing selected is pinned.
const pinnedSelectedThreads = selectedThreads.filter(
(thread) =>
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadPinning ===
true && thread.pinnedAt != null,
);
const unpinMenuItem = buildBulkUnpinContextMenuItem({
pinnedCount: pinnedSelectedThreads.length,
});
const snoozePresets = resolveSnoozePresets(new Date(), timestampFormat);
const clicked = await settlePromise(() =>
api.contextMenu.show(
[
...(unpinMenuItem ? [unpinMenuItem] : []),
{ id: "settle", label: `Settle (${count})` },
...(canSnoozeSelection
? [
@@ -3110,6 +3123,14 @@ export default function Sidebar() {
}
return;
}
if (clicked.value === "unpin") {
// Each unpin reports its own failure, like the single-row action.
for (const thread of pinnedSelectedThreads) {
attemptUnpin(scopeThreadRef(thread.environmentId, thread.id));
}
clearSelection();
return;
}
if (clicked.value === "regenerate-title") {
for (const thread of regeneratableTitleThreads) {
const result = await updateThreadMetadata({
@@ -3199,6 +3220,7 @@ export default function Sidebar() {
[
attemptSettle,
attemptSnooze,
attemptUnpin,
clearSelection,
confirmThreadDelete,
deleteThread,