Skip to content

feat(sidebar): add a favorite/pin toggle for connections - #812

Open
Asgabani wants to merge 2 commits into
libredb:mainfrom
Asgabani:feat/favorite-connections
Open

feat(sidebar): add a favorite/pin toggle for connections#812
Asgabani wants to merge 2 commits into
libredb:mainfrom
Asgabani:feat/favorite-connections

Conversation

@Asgabani

Copy link
Copy Markdown

Closes #694.

A star toggle on each connection row in the sidebar, persisted to a new favorite_connections storage 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: a managed:true connection 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: useFavoriteConnections is built on useSyncExternalStore rather than an effect that reads storage and calls setStatefavorite_connections is 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 by react-hooks/set-state-in-effect on my first draft). The new collection is wired into every place that treats STORAGE_COLLECTIONS as the full set (server-sync pull path, the collection-data switch), 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 (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 my environment) or DB-provider integration tests needing a live database. Verified identical on a clean, unmodified checkout via git stash before starting. None are in a file this PR touches.

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
cevheri self-requested a review September 12, 2026 10:37
@cevheri

cevheri commented Sep 12, 2026

Copy link
Copy Markdown
Member

thanks and welcome @Asgabani
I’m working on PR #811 right now, which includes some big changes to the schema/objects explorer(nosql databases test remaining)

After that, I’ll do a detailed local test your PR and give feedback

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to mark a connection as a favorite

2 participants