Add strategy and folder pinning#75
Conversation
Greptile SummaryAdds pin/unpin support for strategy tiles and folder pills, backed by a standalone Hive
Confidence Score: 4/5The change is well-scoped and the core persistence and deletion cleanup paths are correct. The two open items are cosmetic and a minor Riverpod style point — no data-correctness risk. The provider, Hive wiring, and deletion cleanup are all implemented correctly. The only rough edge is using lib/widgets/folder_content.dart — minor Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant StrategyTile/FolderPill
participant PinnedItemsProvider
participant HiveBox
participant FolderContent
User->>StrategyTile/FolderPill: Right-click / ⋮ → Pin
StrategyTile/FolderPill->>PinnedItemsProvider: togglePin(id)
PinnedItemsProvider->>HiveBox: put(id, nowMs)
PinnedItemsProvider->>PinnedItemsProvider: "state = {...state, id: nowMs}"
PinnedItemsProvider-->>FolderContent: rebuild (ref.watch)
FolderContent->>PinnedItemsProvider: pinnedIdsByRecency()
FolderContent->>FolderContent: hoist pinned items to front of lists
User->>StrategyTile/FolderPill: Delete
StrategyTile/FolderPill->>PinnedItemsProvider: removePin(id)
PinnedItemsProvider->>HiveBox: delete(id)
PinnedItemsProvider->>PinnedItemsProvider: "state = {...state}..remove(id)"
Reviews (1): Last reviewed commit: "Float pinned items to top of grid instea..." | Re-trigger Greptile |
| final pinnedIds = ref | ||
| .read(pinnedItemsProvider.notifier) | ||
| .pinnedIdsByRecency(); |
There was a problem hiding this comment.
ref.read inside build() for state access
pinnedIdsByRecency() is called via ref.read(pinnedItemsProvider.notifier) on line 183 inside build(). Riverpod's ref.read takes a snapshot at call time and does not subscribe, so in the narrow window between the ref.watch on line 180 and this ref.read, the notifier state could theoretically change (e.g. a concurrent async pin toggle completing). In practice this means pinned (line 180) and the snapshot used by pinnedIdsByRecency() could differ. Since pinned is already the full Map<String, int> state, you can derive the sorted order directly from it — no ref.read needed.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
What
Adds the ability to pin strategies and folders. Pinned items float to the top of the home-screen grid, rendered as normal tiles/pills (no separate section or visual indicator — per discussion, the owner will style the indicator himself).
Storage approach
Rather than adding an
isPinnedfield to the existing StrategyData / Folder models (which would need a migration), pins live in a separate Hive box as a registry ofitemId -> pinnedTimestamp. One registry handles both strategies and folders uniformly, and the existing data models are untouched.Tests
Added
test/pinned_items_provider_test.dartcovering pin/toggle, recency ordering, and remove-when-absent.flutter analyzeis clean on all touched files.