Import the official client's identities on every start

Switching clients should not mean a new unique id. On every start the app
now does what `voelinctl identity import --auto` does: identities in the
official TeamSpeak 3/6 clients' databases that Voelin does not have yet
are added, the files opened read-only and immutable as before. The
identity the official client uses by default (field 5 of its payload, now
read into `Found::selected`) goes in first, so when Voelin has no identity
of its own yet, that one becomes Voelin's default and servers see the same
unique id; an existing 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; the sample data
of VOELIN_DEMO_UI never imports. The settings are now opened before the
identity is chosen. Tested with synthetic databases only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 23:18:19 +03:00
1 parent 3242e9bb51
commit 5ad3d44090
5 files changed
+147 -15

No files matched your search

+19 -3
View File
@@ -17,7 +17,7 @@ use anyhow::{Context, Result};
use slint::{ComponentHandle, ModelRc, VecModel};
use tokio::runtime::Runtime;
use tracing::warn;
use voelin_core::settings::{AUDIO, CRASH_REPORTS, Settings};
use voelin_core::settings::{AUDIO, CRASH_REPORTS, IDENTITY_IMPORT, Settings};
use voelin_core::stream::StreamInfo;
use voelin_core::{
AudioSettings, Command, Engine, Event, History, HistoryMessage, SessionState, VoiceState,
@@ -521,6 +521,21 @@ pub fn run(options: RunOptions) -> Result<()> {
Ok(history) => engine.send(Command::AttachHistory(history)),
Err(e) => warn!(%e, "chat history is not stored this time"),
}
let prefs = open_settings(&dir, &options.setting_overrides);
let switches = crate::dev::Switches::from_env();
// New identities of the official TeamSpeak clients, on every start (not
// with the sample data of VOELIN_DEMO_UI); with none of our own yet, the
// client's default identity becomes ours.
let had_identity = !store.identities()?.is_empty();
let imported = if prefs.get(&IDENTITY_IMPORT) && !switches.demo_ui {
voelin_core::identity::import_new(&store, &voelin_core::identity::discover())
.unwrap_or_else(|e| {
warn!(%e, "could not import TeamSpeak identities");
Vec::new()
})
} else {
Vec::new()
};
let identity = match store.identities()?.first() {
Some(entry) => store.identity(entry.id)?,
None => {
@@ -530,7 +545,6 @@ pub fn run(options: RunOptions) -> Result<()> {
identity
}
};
let prefs = open_settings(&dir, &options.setting_overrides);
engine.send(Command::AttachSettings(prefs.clone()));
let mut settings: UiSettings = (*prefs.get_arc(&UI)).clone();
settings.crash_reports = prefs.get(&CRASH_REPORTS);
@@ -560,7 +574,6 @@ pub fn run(options: RunOptions) -> Result<()> {
ptt.set(Some(settings.ptt_key.clone()));
}
let video = Video::new(&dir, settings.openh264);
let switches = crate::dev::Switches::from_env();
let app = App {
ui: ui.as_weak(),
store,
@@ -611,6 +624,9 @@ pub fn run(options: RunOptions) -> Result<()> {
if app.demo {
app.start_demo();
}
if let Some(text) = crate::servers::imported_status(&imported, had_identity) {
app.set_status(text);
}
});
// Engine events -> UI thread, until the event loop is gone.
+19
View File
@@ -3,12 +3,31 @@
use slint::{ComponentHandle, SharedString};
use tracing::warn;
use voelin_core::identity::Found;
use voelin_core::{Command, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_store::{Bookmark, QueryConfig, QueryTransport};
use crate::app::{App, BookmarkForm, Bridge};
use crate::vm;
/// What to tell the user about the identities imported from the official
/// clients at start ([`voelin_core::identity::import_new`]), if any.
/// `had_identity`: we had one before, so it stays the default.
pub(crate) fn imported_status(imported: &[Found], had_identity: bool) -> Option<String> {
let first = imported.first()?;
let n = imported.len();
let names = imported.iter().map(|f| f.nickname.as_str()).collect::<Vec<_>>().join(", ");
Some(match (had_identity, n) {
(true, 1) => format!("Imported the identity \u{201c}{names}\u{201d} from TeamSpeak"),
(true, _) => format!("Imported {n} identities from TeamSpeak: {names}"),
(false, 1) => format!("Using your TeamSpeak identity \u{201c}{names}\u{201d}"),
(false, _) => format!(
"Using your TeamSpeak identity \u{201c}{}\u{201d} ({n} imported: {names})",
first.nickname
),
})
}
impl App {
pub(crate) fn connect_voice(&mut self) {
let Some(b) = self.current.and_then(|id| self.bookmark(id)).cloned() else { return };