The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
A collapsed pinned section keeps the last pinned tab in sight after picking a favorite
Victor154d35767f18
diff --git a/Packages/CraCore/Sources/CraCore/PinnedPeek.swift b/Packages/CraCore/Sources/CraCore/PinnedPeek.swiftnew file mode 100644index 0000000..e942d43--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/PinnedPeek.swift@@ -0,0 +1,30 @@+/// A collapsed pinned section (a click on the space's name) keeps the pinned row you were last on+/// in sight, also once you pick a favorite or a Today tab, so a glance at the sidebar still says+/// which pinned tab is open. Arc 1.171 keeps one such row per window's sidebar,+/// `peekedPinnedSidebarItemID` beside `pinnedSectionExpansionState`, and doesn't save it with the+/// window. Cra listed only the open tab's row, which vanished the moment you picked another tab+/// (X DM, 6 Nov 2026).+public enum PinnedPeek {+ /// The peeked row once a tab comes on screen: its pinned row (the tab, or the split holding+ /// it) when it has one. A favorite or a Today tab leaves the one before in sight.+ public static func showing<ID>(pinnedRow: ID?, peek: ID?) -> ID? {+ pinnedRow ?? peek+ }++ /// The peeked row as the section collapses: only the open tab's, as a closed folder keeps.+ public static func collapsing<ID>(openPinnedRow: ID?) -> ID? {+ openPinnedRow+ }++ /// The peek once the tab `closed` (or the split `rowOfClosed` holding it) closes (⌘W).+ public static func closing<ID: Equatable>(_ closed: ID, rowOfClosed: ID?, peek: ID?) -> ID? {+ peek == closed || (rowOfClosed != nil && peek == rowOfClosed) ? nil : peek+ }++ /// The rows a collapsed section lists, in sidebar order (`pinnedRows`): the open tab's and the+ /// peeked one, while they are still pinned.+ public static func listed<ID: Hashable>(open: ID?, peek: ID?, pinnedRows: [ID]) -> [ID] {+ let wanted = Set([open, peek].compactMap { $0 })+ return wanted.isEmpty ? [] : pinnedRows.filter(wanted.contains)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/PinnedPeekTests.swift b/Packages/CraCore/Tests/CraCoreTests/PinnedPeekTests.swiftnew file mode 100644index 0000000..b400efc--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/PinnedPeekTests.swift@@ -0,0 +1,34 @@+import CraCore+import Testing++/// A collapsed pinned section keeps the pinned row you were last on in sight (Arc's+/// peekedPinnedSidebarItemID; X DM 6 Nov 2026).+struct PinnedPeekTests {+ let reddit = "reddit", mail = "mail", split = "split", pane = "pane"++ @Test func aFavoriteOrTodayTabKeepsTheLastPinnedRow() {+ #expect(PinnedPeek.showing(pinnedRow: nil, peek: reddit) == reddit)+ #expect(PinnedPeek.showing(pinnedRow: mail, peek: reddit) == mail)+ #expect(PinnedPeek.showing(pinnedRow: String?.none, peek: nil) == nil)+ }++ @Test func collapsingKeepsOnlyTheOpenTabsRow() {+ #expect(PinnedPeek.collapsing(openPinnedRow: reddit) == reddit)+ #expect(PinnedPeek.collapsing(openPinnedRow: String?.none) == nil)+ }++ @Test func closingTheTabOrAPaneOfItsSplitDropsIt() {+ #expect(PinnedPeek.closing(reddit, rowOfClosed: nil, peek: reddit) == nil)+ #expect(PinnedPeek.closing(pane, rowOfClosed: split, peek: split) == nil)+ #expect(PinnedPeek.closing(mail, rowOfClosed: nil, peek: reddit) == reddit)+ #expect(PinnedPeek.closing(mail, rowOfClosed: nil, peek: nil) == nil)+ }++ @Test func listsTheOpenAndPeekedRowsInSidebarOrderWhileStillPinned() {+ let rows = [mail, split, reddit]+ #expect(PinnedPeek.listed(open: reddit, peek: mail, pinnedRows: rows) == [mail, reddit])+ #expect(PinnedPeek.listed(open: reddit, peek: reddit, pinnedRows: rows) == [reddit])+ #expect(PinnedPeek.listed(open: nil, peek: "unpinned", pinnedRows: rows) == [])+ #expect(PinnedPeek.listed(open: String?.none, peek: nil, pinnedRows: rows) == [])+ }+}diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swiftindex 867481f..ca8893e 100644--- a/Sources/Cra/Services/SidebarStore.swift+++ b/Sources/Cra/Services/SidebarStore.swift@@ -48,6 +48,9 @@ final class SidebarStore {/// Per window, the tab shown before the selected one: a close goes back to it (CloseSuccessor)./// Not saved: after a relaunch it has no page, so Arc wouldn't go back to it either.@ObservationIgnored private var previousTab: [UUID: UUID] = [:]+ /// Per window and space, the pinned row a collapsed pinned section keeps in sight (PinnedPeek).+ /// Not saved, like Arc's peekedPinnedSidebarItemID. Observed: the collapsed list draws it.+ private var pinnedPeeks: [UUID: [UUID: UUID]] = [:]/// Whether a tab's page is loaded; AppDelegate asks the windows' browser managers.@ObservationIgnored var hasPage: (UUID) -> Bool = { _ in true }/// A tab came into a space's pinned tabs from elsewhere (⌘D, a drag, a menu): Tidy Tab Titles@@ -229,9 +232,36 @@ final class SidebarStore {// showed is the one a close goes back to (CloseSuccessor; Arc counts space switches too).let shown = { (s: WindowSession) in s.focusedSpaceID.flatMap { s.selectedTabPerSpace[$0] } }if shown(w) != shown(prefs.windows[i]) { previousTab[w.id] = shown(prefs.windows[i]) }+ // A pinned tab coming on screen is the one its collapsed section keeps in sight; a+ // favorite or a Today tab leaves the one before (Arc's peekedPinnedSidebarItemID).+ var peeks = pinnedPeeks[w.id] ?? [:]+ for (sid, tab) in w.selectedTabPerSpace where prefs.windows[i].selectedTabPerSpace[sid] != tab {+ peeks[sid] = PinnedPeek.showing(pinnedRow: pinnedRow(of: tab, in: sid), peek: peeks[sid])+ }+ if peeks != (pinnedPeeks[w.id] ?? [:]) { pinnedPeeks[w.id] = peeks }prefs.windows[i] = w}+ /// The row a tab draws in a space's pinned section (the tab, or the split holding it); nil+ /// when it isn't pinned there.+ private func pinnedRow(of tab: UUID, in sid: UUID) -> UUID? {+ guard let row = splitContaining(tab) ?? items[tab], rootContainer(of: row.id) == .pinned(spaceID: sid) else { return nil }+ return row.id+ }++ /// Every row a space's pinned section can draw, in sidebar order: tabs and splits, the ones+ /// in folders included.+ private func pinnedRows(in space: Space) -> [UUID] {+ var out: [UUID] = []+ func walk(_ id: UUID) {+ for c in children(of: id) {+ if c.isTab || c.isSplit { out.append(c.id) } else { walk(c.id) }+ }+ }+ walk(space.pinnedContainerID)+ return out+ }+/// A new window on `spaceID` with nothing open yet.func addWindow(spaceID: UUID, frame: String?) -> WindowSession {let w = WindowSession(focusedSpaceID: spaceID, frame: frame)@@ -244,6 +274,7 @@ final class SidebarStore {func removeWindow(_ id: UUID) {guard prefs.windows.count > 1, let gone = prefs.windows.first(where: { $0.id == id }) else { return }prefs.windows.removeAll { $0.id == id }+ pinnedPeeks[id] = nilif activeWindowID == id { activeWindowID = prefs.windows.first { !$0.isIncognito }?.id ?? prefs.windows[0].id }if gone.isIncognito, let sid = gone.focusedSpaceID, let space = spaces[sid] {var ids = Set<UUID>()@@ -350,12 +381,13 @@ final class SidebarStore {return out}- /// The top-level pinned rows a space's list draws. Collapsed, only the- /// pinned item holding the open tab stays.+ /// The top-level pinned rows a space's list draws. Collapsed, only the pinned row of the open+ /// tab stays, and the one last open after a favorite or a Today tab is picked (PinnedPeek).func listedPinnedItems(in space: Space, window: UUID? = nil) -> [SidebarItem] {guard isPinnedCollapsed(space.id) else { return children(of: space.pinnedContainerID) }- let selected = selectedTabID(in: space.id, window: window).flatMap { splitContaining($0) ?? item($0) }- return selected.flatMap { rootContainer(of: $0.id) == .pinned(spaceID: space.id) ? [$0] : nil } ?? []+ let open = selectedTabID(in: space.id, window: window).flatMap { pinnedRow(of: $0, in: space.id) }+ let peek = pinnedPeeks[self.window(window).id]?[space.id]+ return PinnedPeek.listed(open: open, peek: peek, pinnedRows: pinnedRows(in: space)).compactMap { items[$0] }}/// Favorites + pinned + today for a space, in sidebar order. This is what@@ -565,9 +597,12 @@ final class SidebarStore {t.returnHome()it.data = .tab(t)items[id] = it- // Closed, it no longer shows under a closed folder (Arc).+ // Closed, it no longer shows under a closed folder or a collapsed pinned section (Arc).let peeks = FolderPeek.removing(id, peeks: _prefs.peekedFolders)if peeks != _prefs.peekedFolders { prefs.peekedFolders = peeks }+ let row = splitContaining(id)?.id+ let pinned = pinnedPeeks.mapValues { $0.compactMapValues { PinnedPeek.closing(id, rowOfClosed: row, peek: $0) } }+ if pinned != pinnedPeeks { pinnedPeeks = pinned }touch()return t.savedURL}@@ -1376,7 +1411,13 @@ final class SidebarStore {return _prefs.collapsedPinnedSpaces.contains(spaceID)}func togglePinnedCollapsed(_ spaceID: UUID) {- if prefs.collapsedPinnedSpaces.remove(spaceID) == nil { prefs.collapsedPinnedSpaces.insert(spaceID) }+ guard prefs.collapsedPinnedSpaces.remove(spaceID) == nil else { return }+ prefs.collapsedPinnedSpaces.insert(spaceID)+ // Collapsed, each window keeps only its open tab's row in sight, as a closed folder does.+ for w in prefs.windows {+ let open = w.selectedTabPerSpace[spaceID].flatMap { pinnedRow(of: $0, in: spaceID) }+ pinnedPeeks[w.id, default: [:]][spaceID] = PinnedPeek.collapsing(openPinnedRow: open)+ }}/// Arc's topAppsEmptyStateDismissedForProfiles: the × on the empty Favorites card closes itdiff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swiftindex 27a69aa..22ca530 100644--- a/Tests/StoreTests.swift+++ b/Tests/StoreTests.swift@@ -34,6 +34,7 @@ enum StoreTests {tabFavicons()moveTabToSpace()folderPeek()+ collapsedPinnedPeek()closeSuccessor()favoritesEmptyState()sharedFavorites()@@ -1053,6 +1054,44 @@ enum StoreTests {expect(store.integrityProblems().isEmpty, "and the sidebar stays sound")}+ /// A collapsed pinned section keeps the pinned tab you were last on in sight once you pick a+ /// favorite or a Today tab (Arc's peekedPinnedSidebarItemID; X DM 6 Nov 2026: Reddit vanished+ /// from under the space name as soon as YouTube was picked).+ @MainActor+ private static func collapsedPinnedPeek() {+ let store = AppComposition(clock: ManualScheduler()).store+ let space = store.focusedSpace+ let favorite = store.createTab(url: "https://youtube.com/", pinned: true, select: false, parent: space.favoritesContainerID)+ let reddit = store.createTab(url: "https://reddit.com/", pinned: true, select: false, parent: space.pinnedContainerID)+ let mail = store.createTab(url: "https://mail.example/", pinned: true, select: false, parent: space.pinnedContainerID)+ let today = store.createTab(url: "https://example.net/", select: true)+ store.togglePinnedCollapsed(space.id)+ let listed = { store.listedPinnedItems(in: store.focusedSpace).map(\.id) }+ expect(listed().isEmpty, "a collapsed section on a Today tab lists nothing")++ store.selectTab(reddit.id)+ expect(listed() == [reddit.id], "picking a pinned tab lists it")+ store.selectTab(favorite.id)+ expect(listed() == [reddit.id], "it stays in sight when a favorite is picked")+ store.selectTab(today.id)+ expect(listed() == [reddit.id], "and when a Today tab is picked")+ store.selectTab(mail.id)+ store.selectTab(favorite.id)+ expect(listed() == [mail.id], "only the last pinned tab stays, not every one you were on")++ let other = store.addWindow(spaceID: space.id, frame: nil)+ expect(store.listedPinnedItems(in: store.focusedSpace, window: other.id).isEmpty, "another window keeps its own")++ store.togglePinnedCollapsed(space.id)+ store.togglePinnedCollapsed(space.id)+ expect(listed().isEmpty, "collapsing again keeps only the open tab's row, as a closed folder does")+ store.selectTab(reddit.id)+ store.selectTab(today.id)+ _ = store.resetPinnedTab(reddit.id)+ expect(listed().isEmpty, "closing it (⌘W) takes it out")+ expect(store.integrityProblems().isEmpty, "and the sidebar stays sound")+ }+/// Tidy Tabs (Arc's tab groups in Today): the model's plan applied, undone, and the header's/// actions, on the production store.@MainActor