feat(sidebar): add a favorite/pin toggle for connections - #812
Open
Asgabani wants to merge 2 commits into
Open
Conversation
A star toggle on each connection row in the sidebar, persisted to the storage facade's new favorite_connections collection. Favorited connections render together in their own group above the rest of the list, which keeps exactly the order and behaviour it always had - this only ever pulls entries out of it, never reorders or filters what remains. Deliberately a separate id set rather than a field on DatabaseConnection: a managed:true connection is always taken fresh from the server on every load (mergeManagedConnections in use-connection-manager.ts), so a field on the connection itself would be silently discarded on reload for exactly the connections a user is most likely to want to favorite. A separate id list favorites correctly regardless of who owns the connection, and a duplicated connection (new id) does not inherit the original's favorite status for free. useFavoriteConnections is built on useSyncExternalStore rather than an effect that reads storage and calls setState - favorite_connections is exactly that: state that lives outside React, mutated by the storage facade - so a favorite pulled down from the server, or toggled from another mounted instance of the hook, is reflected without a synchronous setState-in-effect render cascade (caught by react-hooks/set-state-in-effect on the first draft). The new collection is wired into every place that treats STORAGE_COLLECTIONS as the full set: the server-sync pull path and the collection-data switch in use-storage-sync.ts, alongside the existing dismissed_seeds entry. Testing: bun run format, lint, typecheck, knip, chart:check, channels:showcase:check, readme:check, security:check, and build all pass. bun run test:coverage + coverage:check: 100.00% (47133/47133 lines) on the merged report; every file this PR touches is individually at 100%, including the SSR-only getServerSnapshot branch in use-favorite-connections.ts (exercised via ReactDOMServer.renderToString, matching the existing pattern in use-line-numbers-preference.test.ts). bun run test itself still fails locally - 195 pre-existing failures, all either Helm chart tests (no `helm` binary in this environment) or DB-provider integration tests that need a live database connection; verified identical on a clean, unmodified checkout via git stash before starting this change. None are in a file this PR touches.
cevheri
self-requested a review
September 12, 2026 10:37
Member
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ctions # Conflicts: # src/components/Studio.tsx # src/components/sidebar/Sidebar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #694.
A star toggle on each connection row in the sidebar, persisted to a new
favorite_connectionsstorage collection. Favorited connections render together in their own group above the rest of the list, which keeps exactly the order and behaviour it always had — toggling a favorite only ever pulls entries out of the regular list, never reorders or filters what remains.Why a separate id set, not a field on
DatabaseConnection: amanaged:trueconnection is always taken fresh from the server on every load, so a field on the connection object itself would be silently discarded on reload for exactly the connections a user is most likely to want to favorite. A separate id list favorites correctly regardless of who owns the connection, and a duplicated connection (new id) doesn't inherit the original's favorite status for free.Implementation:
useFavoriteConnectionsis built onuseSyncExternalStorerather than an effect that reads storage and callssetState—favorite_connectionsis exactly that: state living outside React, mutated by the storage facade — so a favorite pulled down from the server, or toggled from another mounted instance of the hook, is reflected without a synchronous setState-in-effect render cascade (caught byreact-hooks/set-state-in-effecton my first draft). The new collection is wired into every place that treatsSTORAGE_COLLECTIONSas the full set (server-sync pull path, the collection-data switch), alongside the existingdismissed_seedsentry.Testing
bun run format,lint,typecheck,knip,chart:check,channels:showcase:check,readme:check,security:check, andbuildall pass.bun run test:coverage+coverage:check: 100.00% (47133/47133 lines) on the merged report. Every file this PR touches is individually at 100%, including the SSR-onlygetServerSnapshotbranch (exercised viaReactDOMServer.renderToString, matching the existing pattern inuse-line-numbers-preference.test.ts).bun run testitself still fails locally — 195 pre-existing failures, all either Helm chart tests (nohelmbinary in my environment) or DB-provider integration tests needing a live database. Verified identical on a clean, unmodified checkout viagit stashbefore starting. None are in a file this PR touches.