native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf(shelf): render spines from single loop

onevcat dfd40af4 d58edc77

+32 -52
+32 -52
supacode/Features/Shelf/Views/ShelfView.swift
··· 16 16 let terminalManager: WorktreeTerminalManager 17 17 let createTab: () -> Void 18 18 19 - /// Shared namespace so each spine's `matchedGeometryEffect` can bridge 20 - /// the left-stack ForEach and the right-stack ForEach without breaking 21 - /// visual identity while it moves between them. 22 - @Namespace private var spineNamespace 23 - 24 19 /// Mirrors the Ghostty `background-opacity` setting so the Shelf can 25 20 /// honor the same window transparency as normal view mode. A previous 26 21 /// plain `.background(.background)` defeated transparency entirely by ··· 43 38 } 44 39 45 40 HStack(spacing: 0) { 46 - if let openIndex { 47 - spineStack(books: Array(books[0...openIndex]), openIndex: openIndex, baseOffset: 0) 48 - openBookArea(for: books[openIndex], state: state) 49 - .transition(.opacity) 50 - let rightStart = openIndex + 1 51 - if rightStart < books.count { 52 - spineStack( 53 - books: Array(books[rightStart..<books.count]), 54 - openIndex: openIndex, 55 - baseOffset: rightStart 56 - ) 41 + ForEach(Array(books.enumerated()), id: \.element.id) { index, book in 42 + spine(book: book, index: index, openIndex: openIndex) 43 + if book.id == openBookID { 44 + openBookArea(for: book, state: state) 45 + .transition(.opacity) 57 46 } 58 - } else { 59 - spineStack(books: books, openIndex: nil, baseOffset: 0) 47 + } 48 + if openBookID == nil { 60 49 emptyOpenArea() 61 50 } 62 51 } ··· 69 58 .animation(.easeInOut(duration: 0.2), value: openBookID) 70 59 } 71 60 72 - /// `baseOffset` is the index of `books.first` within the full ordered 73 - /// list, so we can reconstruct each spine's global index and compute 74 - /// its distance to `openIndex` without re-scanning the full list. 75 61 @ViewBuilder 76 - private func spineStack(books: [ShelfBook], openIndex: Int?, baseOffset: Int) -> some View { 77 - HStack(spacing: 0) { 78 - ForEach(Array(books.enumerated()), id: \.element.id) { localIndex, book in 79 - let globalIndex = baseOffset + localIndex 80 - let distance = openIndex.map { abs(globalIndex - $0) } 81 - let open = globalIndex == openIndex 82 - ShelfSpineView( 83 - book: book, 84 - isOpen: open, 85 - distanceFromOpen: distance, 86 - terminalState: terminalManager.stateIfExists(for: book.id), 87 - onOpenBook: { openBook(book, selectingTab: nil) }, 88 - onSelectTab: { tabID in openBook(book, selectingTab: tabID) }, 89 - onNewTab: { 90 - // On a closed spine, `+` doubles as "pull this book out and 91 - // start a fresh tab". Sequencing is fine because TCA runs 92 - // reducers synchronously — `newTerminal` will observe the 93 - // new `selectedTerminalWorktree` set by `selectWorktree`. 94 - switchToBookIfNeeded(book) 95 - createTab() 96 - }, 97 - onSplitVertical: open ? { performSplit(direction: "new_split:right") } : nil, 98 - onSplitHorizontal: open ? { performSplit(direction: "new_split:down") } : nil, 99 - closeMenuTitle: closeMenuTitle(for: book), 100 - onCloseBook: { closeBook(book) }, 101 - onOpenRepositorySettings: { 102 - store.send(.repositoryManagement(.openRepositorySettings(book.repositoryID))) 103 - } 104 - ) 105 - .matchedGeometryEffect(id: book.id, in: spineNamespace) 62 + private func spine(book: ShelfBook, index: Int, openIndex: Int?) -> some View { 63 + let distance = openIndex.map { abs(index - $0) } 64 + let open = index == openIndex 65 + ShelfSpineView( 66 + book: book, 67 + isOpen: open, 68 + distanceFromOpen: distance, 69 + terminalState: terminalManager.stateIfExists(for: book.id), 70 + onOpenBook: { openBook(book, selectingTab: nil) }, 71 + onSelectTab: { tabID in openBook(book, selectingTab: tabID) }, 72 + onNewTab: { 73 + // On a closed spine, `+` doubles as "pull this book out and 74 + // start a fresh tab". Sequencing is fine because TCA runs 75 + // reducers synchronously — `newTerminal` will observe the 76 + // new `selectedTerminalWorktree` set by `selectWorktree`. 77 + switchToBookIfNeeded(book) 78 + createTab() 79 + }, 80 + onSplitVertical: open ? { performSplit(direction: "new_split:right") } : nil, 81 + onSplitHorizontal: open ? { performSplit(direction: "new_split:down") } : nil, 82 + closeMenuTitle: closeMenuTitle(for: book), 83 + onCloseBook: { closeBook(book) }, 84 + onOpenRepositorySettings: { 85 + store.send(.repositoryManagement(.openRepositorySettings(book.repositoryID))) 106 86 } 107 - } 87 + ) 108 88 } 109 89 110 90 /// Dispatch the open-book action only when `book` isn't already the open