feat(accounts): name the instance an account belongs to - #158
Merged
Conversation
Every switch-target row read "Cloud", so an account on the official cloud and one on a self-hosted instance were indistinguishable — same email, same icon, same sublabel. The data was already there: SavedAccount carries server_url. Only a non-default instance is marked, in slots that already exist: the row's icon becomes lucide:server and its sublabel the host, with the full URL in the hover title. An official-cloud row is unchanged. The account header does the same for the account you are on. The auth screen collapsed its server field and reset it to the official cloud, so "Add another account…" aimed a self-hosted user back at api.voltius.app without ever showing which instance they were on. The field now seeds from the instance this machine last signed in to — kept device-scoped, because adding an account clears server_url along with every other account-scoped key — and opens, naming the host, whenever that is not the official cloud. Two duplications collapsed on the way: DEFAULT_SERVER lived in both auth screens, and four routes into a server session each wrote the same keychain list by hand. persistServerSession is now the single place that records the instance, which a fifth route would have forgotten.
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.
Every switch-target row read "Cloud", so an account on the official cloud and one on a self-hosted instance were indistinguishable — same email, same icon, same sublabel.
SavedAccountalready carriedserver_url; only the design was missing.The rule
Mark only what is not the default, in slots that already exist. No new row, no new line, no extra width. An official-cloud account is byte-for-byte unchanged.
circle-user+ "Cloud"lucide:server+stackdome.example.tld, full URL in the hover titlecircle-user+ "Cloud account"lucide:server+ the host<host>"Considered and rejected: the hostname on every row (pushes a URL at people who only ever use one instance), an icon swap with no text (two self-hosted instances stay ambiguous), and user-assigned nicknames (a whole editing surface; deliberately deferred).
How the label is derived
src/utils/serverInstance.ts— hostname, a leadingapi./www.dropped only when the rest still contains a dot, a non-default port kept because it is what distinguishes two instances on one host. Anything absent or unparseable counts as the default: better unmarked than mislabelled.server_urlhttps://api.voltius.apphttps://stackdome.example.tldstackdome.example.tldhttps://api.stackdome.example.tldstackdome.example.tldhttp://192.168.1.40:8443192.168.1.40:8443https://api.localapi.local— stripping would leave a bare namenull/ unparseableThe auth screen, and why it needed a device-scoped record
"Add another account…" landed on the auth screen with the server field collapsed and reset to
https://api.voltius.app, so aiming at a self-hosted instance was one un-clicked disclosure away from silently registering on the official cloud.Auto-expanding on a non-default value is not reachable on its own: adding an account clears
server_urlalong with every otherACCOUNT_CACHE_KEYSentry, so the screen has nothing non-default to open on. The field now seeds fromvoltius.last-server-url— device-scoped localStorage, written on a successful sign-in, surviving teardown becauseclearPersistedAccountUiStateremoves only its explicit key list.Duplications collapsed on the way
DEFAULT_SERVERlived in bothAuthPage.tsxandCloudAuthModal.tsx, as did the disclosure block. Both now useServerUrlField; the screens disagreed only about input styling, which is oneinputClassNameprop.signInToCloud,linkToCloud— each wrote the same keychain list by hand.persistServerSessionis now the single place that writes it, and the single place that records the instance, which a fifth route would otherwise forget.Testing
Suite 3758/3758 across 483 files;
tsc --noEmitexit 0. New: 14 tests for the label rules and the remembered instance, 3 forServerUrlField, 4 inSidebarAccountButton.switcher.test.tsx(two accounts sharing an email on different instances, the server icon and title, and both header cases), 2 inaccount.serverAuth.test.ts(a successful registration remembers the instance, a failed one leaves it alone).