From 1096967645dacf643181c1a7283a47d61c54bf67 Mon Sep 17 00:00:00 2001 From: psavarmattas Date: Fri, 14 Aug 2026 16:52:34 +0100 Subject: [PATCH] feat(sidebar): add a Home row above the collections list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Home was only reachable via the toolbar house icon — added a pinned row at the top of the sidebar (matching a collection row's style, highlighted when active) so it's a first-class nav target alongside collections rather than toolbar-only. --- .../Collections/CollectionsTreeView.swift | 33 +++++++++++++++++++ .../Collections/ContentView_macOS.swift | 2 ++ 2 files changed, 35 insertions(+) diff --git a/Outpost/Features/Collections/CollectionsTreeView.swift b/Outpost/Features/Collections/CollectionsTreeView.swift index 941801a..013455d 100644 --- a/Outpost/Features/Collections/CollectionsTreeView.swift +++ b/Outpost/Features/Collections/CollectionsTreeView.swift @@ -11,6 +11,8 @@ struct CollectionsTreeView: View { /// somewhere with no direct handle on the sidebar row it belongs /// under — see the identical parameter on `CollectionDocumentsOutline`. let externalRefreshToken: Int + let isShowingHome: Bool + let onSelectHome: () -> Void let onSelectDocument: (OutlineCollection, [OutlineDocument]) -> Void let onSearchInCollection: (OutlineCollection) -> Void @@ -19,6 +21,8 @@ struct CollectionsTreeView: View { selectedCollection: Binding, selectedDocumentID: String?, externalRefreshToken: Int, + isShowingHome: Bool, + onSelectHome: @escaping () -> Void, onSelectDocument: @escaping (OutlineCollection, [OutlineDocument]) -> Void, onSearchInCollection: @escaping (OutlineCollection) -> Void ) { @@ -26,6 +30,8 @@ struct CollectionsTreeView: View { _selectedCollection = selectedCollection self.selectedDocumentID = selectedDocumentID self.externalRefreshToken = externalRefreshToken + self.isShowingHome = isShowingHome + self.onSelectHome = onSelectHome self.onSelectDocument = onSelectDocument self.onSearchInCollection = onSearchInCollection } @@ -37,6 +43,7 @@ struct CollectionsTreeView: View { Task { await viewModel.load() } } } + homeRow content } .task { @@ -48,6 +55,32 @@ struct CollectionsTreeView: View { } } + /// Pinned above the collections list, not inside the scroll region — + /// Home isn't a collection, so it doesn't belong in `viewModel.collections` + /// or compete with them for scroll space. + private var homeRow: some View { + Button(action: onSelectHome) { + HStack(spacing: 6) { + Image(systemName: "house.fill") + .font(.callout) + .foregroundStyle(.secondary) + Text("Home") + .font(.body) + Spacer(minLength: 0) + } + .padding(.vertical, 4) + .padding(.horizontal, 6) + .contentShape(Rectangle()) + .background( + isShowingHome ? Color.accentColor.opacity(0.15) : Color.clear, + in: RoundedRectangle(cornerRadius: 6) + ) + } + .buttonStyle(.plain) + .padding(.horizontal, 8) + .padding(.top, 4) + } + @ViewBuilder private var content: some View { Group { diff --git a/Outpost/Features/Collections/ContentView_macOS.swift b/Outpost/Features/Collections/ContentView_macOS.swift index 89595fe..676f2e4 100644 --- a/Outpost/Features/Collections/ContentView_macOS.swift +++ b/Outpost/Features/Collections/ContentView_macOS.swift @@ -197,6 +197,8 @@ struct ContentView_macOS: View { selectedCollection: $selectedCollection, selectedDocumentID: documentPath.last?.id, externalRefreshToken: documentsChangedToken, + isShowingHome: isShowingHome, + onSelectHome: goHome, onSelectDocument: selectDocumentChain, onSearchInCollection: searchInCollection )