Settings → Identities: see and choose the identity servers see

With the official client's identity taking the place of the one Voelin
made, the user needs to see which identity is in use and switch either
way. Settings has an Identities section now (a sixth tab, ID, on the
phone): every stored identity with where it came from, its security
level and unique id, "Default" on the one servers see and "Use as
default" on the others. A choice applies from the next connection,
says so in the status, and is the user's: no import replaces it (the
store marks a created identity chosen this way as the user's). The
section also has the switch for importing the official clients'
identities on start (identity.import_from_teamspeak).

The rows are a pure function with a test; screenshots, headless, of a
store with the created identity and two synthetic TeamSpeak ones.
docs/identity.md describes the one-time replacement and the section;
VOELIN_OPEN=settings:identities opens it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 04:43:02 +03:00
1 parent 4ef5b422f0
commit c551378729
11 files changed
+249 -17

No files matched your search

+6
View File
@@ -52,4 +52,10 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_open_about(|| {
with_app(|app| app.load_notices());
});
bridge.on_use_identity(|id| {
with_app(|app| app.use_identity(id as i64));
});
bridge.on_set_identity_import(|on| {
with_app(|app| app.set_identity_import(on));
});
}
+2 -1
View File
@@ -12,7 +12,7 @@
//! - `VOELIN_DEMO_STREAM=1`: a local test stream in the viewer.
//! - `VOELIN_OPEN=<what>[,<what>...]`: open screens on start: `home`,
//! `server`, `settings[:<section>]` (voice, keybinds, streaming, privacy,
//! appearance, or 0-4), `about`, `share`, `bookmark` (add a server;
//! appearance, identities, or 0-5), `about`, `share`, `bookmark` (add a server;
//! `bookmark:edit` the current one, Advanced open),
//! `emoji` (the picker), `client` (the volume dialog of the first other
//! client once connected), `panel` / `no-panel` (the members panel),
@@ -108,6 +108,7 @@ fn section(name: &str) -> SettingsSection {
"2" | "streaming" => SettingsSection::Streaming,
"3" | "privacy" => SettingsSection::Privacy,
"4" | "appearance" => SettingsSection::Appearance,
"5" | "identities" => SettingsSection::Identities,
_ => SettingsSection::Voice,
}
}
+101
View File
@@ -0,0 +1,101 @@
//! Settings → Identities: the stored identities, which one servers see us
//! as (the default), and the import of the official clients' identities on
//! start (`voelin_core::identity::import_new`, app.rs).
use slint::ComponentHandle;
use tracing::warn;
use voelin_core::settings::IDENTITY_IMPORT;
use voelin_store::{IdentityEntry, IdentityOrigin};
use crate::app::{App, Bridge, IdentityItem, model};
use crate::vm::avatar;
/// A row of the identities card.
fn item(entry: &IdentityEntry) -> IdentityItem {
let origin = match entry.origin {
IdentityOrigin::Imported => "From TeamSpeak",
IdentityOrigin::Created | IdentityOrigin::User => "Made in Voelin",
};
IdentityItem {
id: entry.id as i32,
name: entry.name.clone().into(),
detail: format!("{origin} · level {}", entry.level).into(),
uid: entry.uid.clone().into(),
initials: avatar::initials(&entry.name).into(),
tint: avatar::tint(&entry.name),
is_default: entry.is_default,
}
}
impl App {
pub(crate) fn refresh_identities(&self) {
let Some(ui) = self.ui.upgrade() else { return };
let bridge = ui.global::<Bridge>();
let mut entries = self.store.identities().unwrap_or_default();
// A store from before defaults were marked: the first one.
let default = self.store.default_identity().ok().flatten().map(|e| e.id);
for entry in &mut entries {
entry.is_default = Some(entry.id) == default;
}
bridge.set_identities(model(entries.iter().map(item).collect()));
bridge.set_identity_import(self.prefs.get(&IDENTITY_IMPORT));
}
/// The user's choice of the identity servers see us as, from the next
/// connection on; no import replaces it.
pub(crate) fn use_identity(&mut self, id: i64) {
let result =
self.store.set_default_identity(id, true).and_then(|()| self.store.identity(id));
match result {
Ok(identity) => {
self.identity = identity;
let name = self
.store
.identities()
.ok()
.and_then(|all| all.into_iter().find(|e| e.id == id))
.map(|e| e.name)
.unwrap_or_default();
self.set_status(format!(
"Servers see you as \u{201c}{name}\u{201d} from your next connection"
));
}
Err(e) => self.set_status(format!("Could not change the identity: {e}")),
}
self.refresh_identities();
}
pub(crate) fn set_identity_import(&mut self, on: bool) {
if let Err(e) = self.prefs.set(&IDENTITY_IMPORT, on) {
warn!(%e, "could not store the setting");
}
self.refresh_identities();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn rows_say_where_an_identity_came_from() {
let entry = |origin, is_default| IdentityEntry {
id: 3,
name: "Main Nick".into(),
uid: "uid=".into(),
level: 8,
origin,
is_default,
};
let row = item(&entry(IdentityOrigin::Imported, true));
assert_eq!((row.id, row.name.as_str(), row.uid.as_str()), (3, "Main Nick", "uid="));
assert_eq!(row.detail, "From TeamSpeak · level 8");
assert!(row.is_default);
assert_eq!(row.initials, avatar::initials("Main Nick"));
for origin in [IdentityOrigin::Created, IdentityOrigin::User] {
let row = item(&entry(origin, false));
assert_eq!(row.detail, "Made in Voelin · level 8");
assert!(!row.is_default);
}
}
}
+1
View File
@@ -7,6 +7,7 @@ mod chat;
mod dev;
mod emoji;
mod hotkey;
mod identities;
mod images;
mod inbox;
mod members;
+1
View File
@@ -41,6 +41,7 @@ impl App {
bridge.set_h264_enabled(self.settings.openh264);
bridge.set_image_cache_usage(crate::images::usage_text().into());
self.refresh_h264();
self.refresh_identities();
}
pub(crate) fn close_settings(&mut self) {
+19
View File
@@ -274,6 +274,19 @@ export struct ShareForm {
auto-accept: bool,
}
// An identity in Settings → Identities.
export struct IdentityItem {
id: int,
name: string,
// "From TeamSpeak · level 8"
detail: string,
// The unique id servers know it by (TeamSpeak 3 form).
uid: string,
initials: string,
tint: color,
is-default: bool,
}
export struct AudioForm {
// 0 = system default, then the devices.
input-index: int,
@@ -446,6 +459,12 @@ export global Bridge {
in property <string> crash-notice;
// Third-party notices, one entry per line, for the About page.
in property <[string]> notices;
// Settings → Identities: who servers see us as, and the import of the
// official clients' identities on start (identity.import_from_teamspeak).
in property <[IdentityItem]> identities;
in-out property <bool> identity-import;
callback use-identity(int);
callback set-identity-import(bool);
callback select-server(int);
// The search field of the top bar: filters the channel tree.
+1
View File
@@ -22,6 +22,7 @@ export enum SettingsSection {
streaming,
privacy,
appearance,
identities,
}
// Tabs of the bottom navigation in the narrow (mobile) layout.
+89 -7
View File
@@ -4,7 +4,7 @@ import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge } from "../bridge.slint";
import { Nav, SettingsSection } from "../nav.slint";
import { Icon, Button, ButtonKind, TextField, Field, Select, Toggle, ToggleRow, Slider, SegmentedTabs, Card, Meter, NavItem, Divider, ScrollView } from "../components/index.slint";
import { Icon, Button, ButtonKind, TextField, Field, Select, Toggle, ToggleRow, Slider, SegmentedTabs, Card, Meter, NavItem, Divider, ScrollView, Avatar, Chip } from "../components/index.slint";
// A label, a control (@children) and a value at the right.
component SliderRow inherits HorizontalLayout {
@@ -89,6 +89,13 @@ export component SettingsNav inherits VerticalLayout {
selected: Nav.settings-section == SettingsSection.appearance;
clicked => { Nav.open-settings(SettingsSection.appearance); }
}
NavItem {
icon: Icons.user;
text: @tr("Identities");
subtitle: @tr("Who servers see you as");
selected: Nav.settings-section == SettingsSection.identities;
clicked => { Nav.open-settings(SettingsSection.identities); }
}
Divider { }
NavItem {
icon: Icons.info;
@@ -450,6 +457,77 @@ component AppearanceSection inherits VerticalLayout {
}
}
// The identities (key pairs; servers know us by their unique ids) and which
// one is used.
component IdentitiesSection inherits VerticalLayout {
alignment: start;
spacing: Theme.space-5;
Card {
title: @tr("Your identities");
icon: Icons.user;
for identity in Bridge.identities: HorizontalLayout {
spacing: Theme.space-4;
Avatar {
initials: identity.initials;
tint: identity.tint;
label: identity.name;
y: (parent.height - self.height) / 2;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: identity.name;
color: Theme.text;
font-weight: Theme.weight-semibold;
overflow: elide;
}
Text {
text: identity.detail;
color: Theme.text-secondary;
font-size: Theme.font-sm;
overflow: elide;
}
Text {
text: identity.uid;
color: Theme.text-muted;
font-size: Theme.font-xs;
overflow: elide;
}
}
if identity.is-default: Chip {
text: @tr("Default");
icon: Icons.check;
tint: Theme.accent-text;
fill: Theme.accent-soft;
y: (parent.height - self.height) / 2;
}
if !identity.is-default: Button {
small: true;
text: @tr("Use as default");
y: (parent.height - self.height) / 2;
clicked => { Bridge.use-identity(identity.id); }
}
}
Hint {
text: @tr("Servers know you by the default identity's unique id, from the next connection on. An identity is a key: whoever has a copy can be you on every server.");
}
}
Card {
title: @tr("TeamSpeak");
icon: Icons.download;
ToggleRow {
text: @tr("Import identities from TeamSpeak on start");
description: @tr("Reads the official clients' identities, never changes them");
checked <=> Bridge.identity-import;
toggled => { Bridge.set-identity-import(Bridge.identity-import); }
}
Hint {
text: @tr("While you use the identity Voelin made for you, the one TeamSpeak uses becomes your default, once.");
}
}
}
// The page of the selected section.
export component SettingsPage inherits Rectangle {
// Show the section navigation above the content (narrow windows).
@@ -457,15 +535,18 @@ export component SettingsPage inherits Rectangle {
property <image> section-icon: Nav.settings-section == SettingsSection.voice ? Icons.mic
: Nav.settings-section == SettingsSection.keybinds ? Icons.keyboard
: Nav.settings-section == SettingsSection.streaming ? Icons.radio
: Nav.settings-section == SettingsSection.privacy ? Icons.shield : Icons.palette;
: Nav.settings-section == SettingsSection.privacy ? Icons.shield
: Nav.settings-section == SettingsSection.identities ? Icons.user : Icons.palette;
property <string> section-title: Nav.settings-section == SettingsSection.voice ? @tr("Voice & Video")
: Nav.settings-section == SettingsSection.keybinds ? @tr("Keybinds")
: Nav.settings-section == SettingsSection.streaming ? @tr("Streaming")
: Nav.settings-section == SettingsSection.privacy ? @tr("Privacy & Safety") : @tr("Appearance");
: Nav.settings-section == SettingsSection.privacy ? @tr("Privacy & Safety")
: Nav.settings-section == SettingsSection.identities ? @tr("Identities") : @tr("Appearance");
property <string> section-subtitle: Nav.settings-section == SettingsSection.voice ? @tr("Set up your microphone, speakers and voice processing.")
: Nav.settings-section == SettingsSection.keybinds ? @tr("Talk with a key, even while other windows have focus.")
: Nav.settings-section == SettingsSection.streaming ? @tr("Codecs for watching streams.")
: Nav.settings-section == SettingsSection.privacy ? @tr("What the app keeps on this device.") : @tr("Theme, text size and layout. Changes apply at once.");
: Nav.settings-section == SettingsSection.privacy ? @tr("What the app keeps on this device.")
: Nav.settings-section == SettingsSection.identities ? @tr("Who servers see you as.") : @tr("Theme, text size and layout. Changes apply at once.");
accessible-role: AccessibleRole.groupbox;
accessible-label: section-title;
sv := ScrollView {
@@ -475,11 +556,11 @@ export component SettingsPage inherits Rectangle {
spacing: Theme.space-5;
alignment: start;
if root.compact: SegmentedTabs {
model: [@tr("Voice"), @tr("Keys"), @tr("Streams"), @tr("Privacy"), @tr("Look")];
current-index: Nav.settings-section == SettingsSection.voice ? 0 : Nav.settings-section == SettingsSection.keybinds ? 1 : Nav.settings-section == SettingsSection.streaming ? 2 : Nav.settings-section == SettingsSection.privacy ? 3 : 4;
model: [@tr("Voice"), @tr("Keys"), @tr("Streams"), @tr("Privacy"), @tr("Look"), @tr("ID")];
current-index: Nav.settings-section == SettingsSection.voice ? 0 : Nav.settings-section == SettingsSection.keybinds ? 1 : Nav.settings-section == SettingsSection.streaming ? 2 : Nav.settings-section == SettingsSection.privacy ? 3 : Nav.settings-section == SettingsSection.identities ? 5 : 4;
label: @tr("Settings sections");
selected(i) => {
Nav.open-settings(i == 0 ? SettingsSection.voice : i == 1 ? SettingsSection.keybinds : i == 2 ? SettingsSection.streaming : i == 3 ? SettingsSection.privacy : SettingsSection.appearance);
Nav.open-settings(i == 0 ? SettingsSection.voice : i == 1 ? SettingsSection.keybinds : i == 2 ? SettingsSection.streaming : i == 3 ? SettingsSection.privacy : i == 5 ? SettingsSection.identities : SettingsSection.appearance);
}
}
HorizontalLayout {
@@ -510,6 +591,7 @@ export component SettingsPage inherits Rectangle {
if Nav.settings-section == SettingsSection.streaming: StreamingSection { }
if Nav.settings-section == SettingsSection.privacy: PrivacySection { }
if Nav.settings-section == SettingsSection.appearance: AppearanceSection { }
if Nav.settings-section == SettingsSection.identities: IdentitiesSection { }
}
}
}
+21 -8
View File
@@ -171,14 +171,27 @@ voelinctl identity export <id> <path> [--store <db>]
**On every start** the app does the same as `import --auto`
(`voelin_core::identity::import_new`): identities found in the default
locations that the client database does not have yet are added, the files
are only read. The identity the official client uses by default (field 5 of
its payload, below) goes in first, so when Voelin has no identity of its own
yet, that one becomes Voelin's default (the first identity) and servers see
the same unique id; otherwise Voelin's default stays. What was imported is
shown once, in the status line (the toast on desktop), by nickname. The
runtime setting `identity.import_from_teamspeak` (default on) turns it off,
e.g. `--set identity.import_from_teamspeak=false`. The sample data of
`VOELIN_DEMO_UI` never imports.
are only read. The user should appear as on the official client, so the
identity the official client uses by default (field 5 of its payload, below;
TeamSpeak 6's before TeamSpeak 3's) becomes Voelin's default when Voelin has
none, or only the one it created on its own the first time it started,
which nobody chose. That happens once: the created identity is kept, and
choosing it again in Settings → Identities makes it the user's own, which
no import replaces; identities that were imported or chosen are never
replaced. The store keeps where each identity came from and which one is the
default (`identities.origin`: `created`, `imported`, `user`;
`identities.is_default`; schema version 4, which marks the first identity
named `Default` of an older database as created). What happened is shown
once in the status line (the toast on desktop), by nickname, e.g. "You now
use your TeamSpeak identity "X"; your previous one is kept". The runtime
setting `identity.import_from_teamspeak` (default on, also in Settings →
Identities) turns it off, e.g. `--set identity.import_from_teamspeak=false`.
The sample data of `VOELIN_DEMO_UI` never imports.
**Settings → Identities** lists the stored identities with where they came
from, their security level and unique id; "Use as default" picks the one
servers see from the next connection on. `voelinctl identity list` shows
the same (origin and default).
- **Import** prints what it found as nickname, unique id and security level —
all three are public, everything else in an identity is the private key —
Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

+8 -1
View File
@@ -216,6 +216,12 @@ server is saved without one and when it connects
and one found is stored as if typed. `bookmark` and `bookmark:edit` open
it (below).
Settings → Identities (`IdentitiesSection` in `screens/settings.slint`,
`identities.rs`) lists the stored identities, marks the default and has
"Use as default" for the others, plus the switch for importing the
official clients' identities on start ([identity.md](identity.md)).
`settings:identities` opens it.
## Adding a screen
1. Write the screen in `ui/screens/<name>.slint` from the components
@@ -277,7 +283,7 @@ Environment variables (see `src/dev.rs`):
- `VOELIN_DEMO_UI=1`: sample servers, channels, members, chat with emoji and
a stream, without a server (nothing is stored).
- `VOELIN_OPEN=<what>[,<what>...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance]`,
- `VOELIN_OPEN=<what>[,<what>...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance|identities]`,
`about`, `share[:live]`, `bookmark[:edit]`, `emoji`, `client`, `panel`, `no-panel`,
`voice`, `pins`, `topics`, `topic:<id>`, `member`, `watch`, `popout`
(the server page, above), `tab:<home|servers|chat|activity|you>` (phone
@@ -333,6 +339,7 @@ the window's size so the pointer is not over the window, and passes
| ![emoji](screenshots/desktop-emoji-picker.png) | ![volume](screenshots/desktop-client-volume.png) |
| ![share](screenshots/desktop-share-dialog.png) | ![sharing](screenshots/desktop-share-live.png) |
| ![add server](screenshots/desktop-add-server.png) | ![about](screenshots/desktop-about.png) |
| ![identities](screenshots/desktop-settings-identities.png) | |
| Phone layout | | | | |
|---|---|---|---|---|