Skip to content

Simplify the drive name shown in the Explorer sidebar#498

Open
RyanEwen wants to merge 1 commit into
haiwen:masterfrom
RyanEwen:sidebar-drive-name
Open

Simplify the drive name shown in the Explorer sidebar#498
RyanEwen wants to merge 1 commit into
haiwen:masterfrom
RyanEwen:sidebar-drive-name

Conversation

@RyanEwen

@RyanEwen RyanEwen commented Jul 6, 2026

Copy link
Copy Markdown

What this does

The sync root currently appears in the Explorer navigation pane as SeaDrive - Ryan Ewen(seafile.example.com). Two changes:

  1. Missing space: getDisplayName() now returns Name (host) instead of Name(host), so the registered label reads SeaDrive - Ryan Ewen (seafile.example.com).
  2. Drop the account suffix when it carries no information: when only one sync root is registered, the sidebar entry is relabeled to just SeaDrive. With two or more accounts, each entry keeps its full SeaDrive - Name (host) label so they can be told apart. Labels self-correct when accounts are added or removed.

Note: this contains a workaround for daemon behavior

The seadrive daemon always registers the sync root as SeaDrive - <display name>, where only <display name> comes from the GUI (via seafile_add_account). There is no way to get a plain SeaDrive label through the RPC alone — passing an empty display name would presumably leave a dangling SeaDrive - .

So the single-account case is handled by rewriting the label after the daemon registers it: Explorer reads the sidebar label from the default value of HKCU\Software\Classes\CLSID\<NamespaceCLSID> (per-user writable, unlike the SyncRootManager entry under HKLM), and the new RegElement::setSyncRootSidebarLabel() overwrites that value. Because the daemon registers sync roots asynchronously after the RPC returns, the rewrite is retried a few times (2s/10s/30s) after accounts are added/removed and on every daemon start.

If the daemon were changed to use the GUI-provided display name verbatim (i.e. not force the "SeaDrive - " prefix, letting the GUI pass SeaDrive or SeaDrive - Name (host) as the full label), the registry rewrite, the retry timers, and AccountManager::updateSyncRootSidebarLabels() could all be deleted — the GUI would simply pass the right label in seafile_add_account.

Changes

  • src/rpc/rpc-client.cpp: space fix in getDisplayName(), now also declared in the header for reuse
  • src/utils/registry.{h,cpp}: collectSyncRootManagerIds() and setSyncRootSidebarLabel() helpers
  • src/account-mgr.{h,cpp}: updateSyncRootSidebarLabels() computes the desired label per account; scheduled with retries from account add/remove
  • src/seadrive-gui.cpp: labels refreshed on daemon start/restart

The daemon registers each sync root in the navigation pane as
"SeaDrive - <user>(<server>)". Two problems with that: the space
between the user name and the parenthesized server host is missing,
and when there is only one account the whole suffix carries no
information.

Fix the missing space in getDisplayName(), and relabel the sidebar
entry to the plain brand name when a single sync root is registered,
keeping the account suffix only when multiple accounts need to be
told apart.

Explorer reads the sidebar label from the default value of
HKCU\Software\Classes\CLSID\<NamespaceCLSID>, which is per-user
writable, so the label can be rewritten there without elevation (the
SyncRootManager entry itself is under HKLM and is owned by the
daemon). Since the daemon registers sync roots asynchronously after
the seafile_add_account rpc, the rewrite is retried a few times after
accounts are added or removed.
@RyanEwen

Copy link
Copy Markdown
Author

@feiniks sorry to bug but it looks like you're the one who usually handles PRs around here based on commit history. Hoping to get my PRs looked at :)

@feiniks

feiniks commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Hello @RyanEwen ,

Hiding the user information when only one account is signed in is a good idea. However, with the current implementation, there isn't a better way to update the display name. In particular, when a second account is added, the display name of the first account also needs to be updated. Since this would typically require modifying the Windows Registry, we don't plan to change this behavior for now.

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.

2 participants