Skip to content

Commit 247ac52

Browse files
authored
feat(desktop): add user-defined channel sections to sidebar (#789)
1 parent d810608 commit 247ac52

11 files changed

Lines changed: 1775 additions & 250 deletions

‎desktop/package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"tauri:build": "tauri build"
2222
},
2323
"dependencies": {
24+
"@dnd-kit/core": "^6.3.1",
25+
"@dnd-kit/sortable": "^10.0.0",
26+
"@dnd-kit/utilities": "^3.2.2",
2427
"@emoji-mart/data": "^1.2.1",
2528
"@emoji-mart/react": "^1.1.1",
2629
"@radix-ui/react-alert-dialog": "^1.1.15",

‎desktop/scripts/check-file-sizes.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ const overrides = new Map([
3939
["src/features/channels/ui/ChannelManagementSheet.tsx", 800],
4040
["src/features/channels/ui/ChannelPane.tsx", 540], // composer/timeline/sidebar orchestration + anchored agent activity footers + imetaMedia threading on editTarget + thread follow props passthrough
4141
["src/features/channels/ui/ChannelScreen.tsx", 580], // profile panel state + mutual exclusion wiring + ProfilePanelProvider context + agent typing classification + imetaMedia projection on editTarget + thread follow wiring from AppShell context
42-
["src/features/channels/useUnreadChannels.ts", 715], // NIP-RS read marker tracking + participated/authored/followed thread ID sets + localStorage persistence + catch-up REQ with thread activity collection + thread reply activity feed items + mutedRootIds denylist with localStorage persistence + muteThread/unmuteThread callbacks
42+
["src/features/channels/useUnreadChannels.ts", 717], // NIP-RS read marker tracking + participated/authored/followed thread ID sets + localStorage persistence + catch-up REQ with thread activity collection + thread reply activity feed items + mutedRootIds denylist with localStorage persistence + muteThread/unmuteThread callbacks + markChannelRead latestByChannelRef fallback chain (matches markChannelUnread)
4343
["src/features/notifications/hooks.ts", 535], // notification settings + feed notification lifecycle + profile batch resolution + truncated-pubkey guard + badge state
4444
["src/features/home/ui/HomeView.tsx", 505], // inbox/feed orchestration + thread context + reply/delete flow + NIP-RS read-state projection wiring (useHomeInboxReadState)
4545
["src/features/messages/hooks.ts", 500], // message query/mutation hooks + optimistic updates
4646
["src/features/messages/lib/useRichTextEditor.ts", 560], // editor setup + 3 inline Tiptap keymap extensions (macEmacs/smartShiftEnter/submitOnEnter) + editorProps.handleKeyDown for ↑-to-edit + editable-toggle focus-restore (records isFocused before disable on send, re-focuses on re-enable so the WebView blur-on-disable doesn't strand focus on body). Split candidate: extract the 3 keymap extensions to a sibling module (tracked follow-up).
4747
["src/features/messages/ui/MessageComposer.tsx", 820], // media upload handlers (paste, drop, dialog) + channelId reset effect + edit mode (pre-fill, save, cancel, escape) + composer autofocus (#572) + Sprout code-block paste branch (round-trips copy-button output as a literal codeBlock so Markdown can't reshape it) + scroll-to-bottom on multi-line paste (#619) + Slack-style attachment-editable edits: seed pendingImeta from edit target, stash/restore user's draft pendingImeta across edit-mode entry/exit, re-append imeta markdown lines on edit-submit so renderer draws them
4848
["src/features/settings/ui/SettingsView.tsx", 600],
49-
["src/features/sidebar/ui/AppSidebar.tsx", 860], // channels + forums creation forms + Pulse nav
49+
["src/features/sidebar/ui/AppSidebar.tsx", 830], // channels + forums creation forms + Pulse nav + channel sections state/dialogs + SidebarDndContext wrapper + sectionIds memo for DnD section reorder + controlled create-channel dialog for ⌘⇧N shortcut
50+
["src/features/sidebar/ui/CustomChannelSection.tsx", 615], // ChannelGroupSection + CustomChannelSection + SectionHeaderActions + ChannelContextMenuItems + MoveToSectionSubmenu + per-section mark-all-read + DnD wrappers (SortableSectionShell, DraggableChannelRow, DroppableSectionBody, DroppableUngroupedBody) + draggable prop on ChannelGroupSection
5051
["src/shared/api/relayClientSession.ts", 1040], // durable websocket session manager with reconnect/replay/recovery state + sendTypingIndicator + fetchChannelHistoryBefore + subscribeToChannelLive (huddle TTS) + subscribeToHuddleEvents (huddle indicator) + disconnect() for workspace switch teardown + fetchEvents/subscribeLive/publishEvent for NIP-RS read state + publishUserStatus/subscribeToUserStatusUpdates (NIP-38) + ConnectionState plumbing & stall-watchdog wiring for half-open WS detection (Warp orange-icon case) + terminal session latch (auth rejection no longer racing back to reconnecting) — emitter + watchdog + reconnect policy logic extracted to relayConnectionStateEmitter.ts / relayStallWatchdog.ts / relayReconnectPolicy.ts
5152
["src-tauri/src/migration.rs", 1010], // worktree shared-agent-data symlink sync (SHARED_AGENT_FILES + SHARED_AGENT_DIRS symlink-to-canonical + sibling pack migration) + mcp_command provider reconciliation + persona_pack_path reconciliation + tests
5253
["src-tauri/src/commands/media.rs", 730], // ffmpeg video transcode + poster frame extraction + run_ffmpeg_with_timeout (find_ffmpeg via resolve_command, is_video_file, transcode_to_mp4, extract_poster_frame, transcode_and_extract_poster) + spawn_blocking wrappers + tests

‎desktop/src/features/channels/readState/readStateManager.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export class ReadStateManager {
101101
}
102102

103103
markContextRead(contextId: string, unixTimestamp: number): void {
104+
this.forcedContexts.delete(contextId);
104105
this.advanceContext(contextId, unixTimestamp, { publishable: true });
105106
}
106107

‎desktop/src/features/channels/useUnreadChannels.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ export function useUnreadChannels(
296296

297297
const markChannelRead = React.useCallback(
298298
(channelId: string, readAt: string | null | undefined) => {
299-
const unixSeconds = toUnixSeconds(readAt);
299+
const unixSeconds =
300+
toUnixSeconds(readAt) ??
301+
latestByChannelRef.current.get(channelId) ??
302+
null;
300303
if (unixSeconds === null) return;
301304
// Reading clears any prior manual mark-unread.
302305
if (forcedUnreadRef.current.delete(channelId)) {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const STORAGE_KEY_PREFIX = "sprout-channel-sections.v1";
2+
3+
export type ChannelSection = {
4+
id: string;
5+
name: string;
6+
order: number;
7+
};
8+
9+
export type ChannelSectionStore = {
10+
version: 1;
11+
sections: ChannelSection[];
12+
assignments: Record<string, string>;
13+
};
14+
15+
export const DEFAULT_STORE: ChannelSectionStore = Object.freeze({
16+
version: 1,
17+
sections: [],
18+
assignments: {},
19+
});
20+
21+
export function storageKey(pubkey: string): string {
22+
return `${STORAGE_KEY_PREFIX}:${pubkey}`;
23+
}
24+
25+
export function stripOrphanedAssignments(
26+
store: ChannelSectionStore,
27+
): ChannelSectionStore {
28+
const sectionIds = new Set(store.sections.map((s) => s.id));
29+
const cleaned = Object.fromEntries(
30+
Object.entries(store.assignments).filter(([, sid]) => sectionIds.has(sid)),
31+
);
32+
if (Object.keys(cleaned).length === Object.keys(store.assignments).length)
33+
return store;
34+
return { ...store, assignments: cleaned };
35+
}
36+
37+
export function parseChannelSectionPayload(
38+
json: unknown,
39+
): ChannelSectionStore | null {
40+
if (typeof json !== "object" || json === null) return null;
41+
const obj = json as Record<string, unknown>;
42+
const sections: ChannelSection[] = Array.isArray(obj.sections)
43+
? obj.sections.filter(
44+
(entry: unknown): entry is ChannelSection =>
45+
typeof entry === "object" &&
46+
entry !== null &&
47+
typeof (entry as Record<string, unknown>).id === "string" &&
48+
typeof (entry as Record<string, unknown>).name === "string" &&
49+
typeof (entry as Record<string, unknown>).order === "number",
50+
)
51+
: [];
52+
const assignments: Record<string, string> =
53+
typeof obj.assignments === "object" &&
54+
obj.assignments !== null &&
55+
!Array.isArray(obj.assignments)
56+
? Object.fromEntries(
57+
Object.entries(obj.assignments as Record<string, unknown>).filter(
58+
(entry): entry is [string, string] => typeof entry[1] === "string",
59+
),
60+
)
61+
: {};
62+
return stripOrphanedAssignments({ version: 1, sections, assignments });
63+
}
64+
65+
export function readChannelSectionsStore(pubkey: string): ChannelSectionStore {
66+
try {
67+
const raw = window.localStorage.getItem(storageKey(pubkey));
68+
if (!raw) {
69+
return DEFAULT_STORE;
70+
}
71+
const parsed = JSON.parse(raw);
72+
if (typeof parsed !== "object" || parsed === null || parsed.version !== 1) {
73+
return DEFAULT_STORE;
74+
}
75+
return parseChannelSectionPayload(parsed) ?? DEFAULT_STORE;
76+
} catch {
77+
return DEFAULT_STORE;
78+
}
79+
}
80+
81+
export function writeChannelSectionsStore(
82+
pubkey: string,
83+
store: ChannelSectionStore,
84+
): boolean {
85+
try {
86+
window.localStorage.setItem(storageKey(pubkey), JSON.stringify(store));
87+
return true;
88+
} catch {
89+
return false;
90+
}
91+
}

0 commit comments

Comments
 (0)