Skip to content

Commit 5c9ec7d

Browse files
gsimoneclaude
andcommitted
feat(web): unpin threads from the sidebar multi-select menu
Multi-selecting sidebar threads now offers "Unpin (k)" in the right-click menu. On a mixed selection the label counts only the pinned rows in pin-capable environments, following the bulk title-regeneration pattern, and the item is omitted when nothing selected is pinned. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent d5b9410 commit 5c9ec7d

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
animatePinnedLayoutChanges,
55
archiveSelectedThreadEntries,
66
buildBulkTitleRegenerationContextMenuItem,
7+
buildBulkUnpinContextMenuItem,
78
buildMultiSelectThreadContextMenuItems,
89
createThreadJumpHintVisibilityController,
910
filterSidebarProjectScopeItems,
@@ -185,6 +186,19 @@ describe("archiveSelectedThreadEntries", () => {
185186
});
186187
});
187188

189+
describe("buildBulkUnpinContextMenuItem", () => {
190+
it("counts only the pinned rows of a mixed selection", () => {
191+
expect(buildBulkUnpinContextMenuItem({ pinnedCount: 2 })).toEqual({
192+
id: "unpin",
193+
label: "Unpin (2)",
194+
});
195+
});
196+
197+
it("omits the action when nothing selected is pinned", () => {
198+
expect(buildBulkUnpinContextMenuItem({ pinnedCount: 0 })).toBeNull();
199+
});
200+
});
201+
188202
describe("buildBulkTitleRegenerationContextMenuItem", () => {
189203
it("counts only threads that can start a new regeneration", () => {
190204
expect(

‎apps/web/src/components/Sidebar.logic.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ export function buildBulkTitleRegenerationContextMenuItem(input: {
177177
};
178178
}
179179

180+
/**
181+
* Bulk unpin follows the same "count only what the action will touch" rule
182+
* as title regeneration: on a mixed selection the label counts the pinned
183+
* rows alone, and the item disappears when nothing selected is pinned.
184+
*/
185+
export function buildBulkUnpinContextMenuItem(input: {
186+
pinnedCount: number;
187+
}): ContextMenuItem<"unpin"> | null {
188+
if (input.pinnedCount === 0) return null;
189+
return { id: "unpin", label: `Unpin (${input.pinnedCount})` };
190+
}
191+
180192
export interface ThreadStatusPill {
181193
label:
182194
| "Working"

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ import { buildThreadActionMenuItems } from "./threadActionMenu.logic";
130130
import {
131131
animatePinnedLayoutChanges,
132132
buildBulkTitleRegenerationContextMenuItem,
133+
buildBulkUnpinContextMenuItem,
133134
filterSidebarProjectScopeItems,
134135
formatWorkingDurationLabel,
135136
firstValidTimestampMs,
@@ -2971,10 +2972,22 @@ export default function Sidebar() {
29712972
supportedCount: titleRegenerationThreads.length,
29722973
actionableCount: regeneratableTitleThreads.length,
29732974
});
2975+
// Unpin (k) counts only the pinned rows in pin-capable environments —
2976+
// on a mixed selection the unpinned rows are untouched, and the item
2977+
// is omitted entirely when nothing selected is pinned.
2978+
const pinnedSelectedThreads = selectedThreads.filter(
2979+
(thread) =>
2980+
serverConfigs.get(thread.environmentId)?.environment.capabilities.threadPinning ===
2981+
true && thread.pinnedAt != null,
2982+
);
2983+
const unpinMenuItem = buildBulkUnpinContextMenuItem({
2984+
pinnedCount: pinnedSelectedThreads.length,
2985+
});
29742986
const snoozePresets = resolveSnoozePresets(new Date(), timestampFormat);
29752987
const clicked = await settlePromise(() =>
29762988
api.contextMenu.show(
29772989
[
2990+
...(unpinMenuItem ? [unpinMenuItem] : []),
29782991
{ id: "settle", label: `Settle (${count})` },
29792992
...(canSnoozeSelection
29802993
? [
@@ -3056,6 +3069,14 @@ export default function Sidebar() {
30563069
}
30573070
return;
30583071
}
3072+
if (clicked.value === "unpin") {
3073+
// Each unpin reports its own failure, like the single-row action.
3074+
for (const thread of pinnedSelectedThreads) {
3075+
attemptUnpin(scopeThreadRef(thread.environmentId, thread.id));
3076+
}
3077+
clearSelection();
3078+
return;
3079+
}
30593080
if (clicked.value === "regenerate-title") {
30603081
for (const thread of regeneratableTitleThreads) {
30613082
const result = await updateThreadMetadata({
@@ -3145,6 +3166,7 @@ export default function Sidebar() {
31453166
[
31463167
attemptSettle,
31473168
attemptSnooze,
3169+
attemptUnpin,
31483170
clearSelection,
31493171
confirmThreadDelete,
31503172
deleteThread,

0 commit comments

Comments
 (0)