voelin-core: chat history and the gateway's features in the engine
Chat lived only in the UI's memory. Every chat message a session sees (voice, gateway pushes, query relays, our own sends) is now stored under the server's unique id through a writer thread that batches writes, and opening a chat or reconnecting emits the stored page at once, then syncs with the gateway: the latest page on first contact, afterwards everything past the chat's revision cursor, in pages of chat.history_page. LoadOlderHistory pages back, merging the gateway's page for that range. Copies of one message from different sources become one row, so the UI upserts by local id (Event::ChatHistory). The session's gateway now runs on the typed client, keeping presence and relayed chat as they were, and takes Command::Gateway requests (pins, reactions, topics and topic history, events with RSVP, the stream directory, activity, permissions, runtime config and permission rules), answered and pushed as Event::Gateway updates. It subscribes to events, streams and activity when offered. Our own TeamSpeak 6 stream registers itself in the directory when it goes live and leaves it when it ends, and the directory's registered entries feed stream discovery (also as a StreamLookup), so streams that started before we joined are found even when the server's lookup does not answer. The voice connection now reports the server's unique id (SHA-1 or SHA-256 of its key, per server generation) and ours, and files our own private messages under the receiver. Settings: chat.store_history, chat.history_page, chat.dedupe_tolerance_ms, chat.retention_days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
1 parent
19c47b95c7
commit
7d92d391dc
8 files changed
+2236
-66
No files matched your search
@@ -1061,8 +1061,43 @@ pub static STREAM_PERMISSIONS: Key<StreamPermissions> = Key::new(
|
||||
StreamPermissions::default,
|
||||
);
|
||||
|
||||
/// Keep chat history in the client database. Off: messages seen from now
|
||||
/// on are kept in memory only (for this run), nothing is read from or
|
||||
/// written to the database.
|
||||
pub static CHAT_STORE_HISTORY: Key<bool> =
|
||||
Key::new("chat.store_history", Kind::Bool, "Keep chat history on this device.", || true);
|
||||
|
||||
/// Messages per history page: shown when a chat opens, fetched per step
|
||||
/// when scrolling back, and per request while syncing with a gateway.
|
||||
/// 0: everything at once. No maximum.
|
||||
pub static CHAT_HISTORY_PAGE: Key<u32> = Key::new(
|
||||
"chat.history_page",
|
||||
Kind::UInt { min: 0 },
|
||||
"Messages per chat history page (0: all at once).",
|
||||
|| 100,
|
||||
);
|
||||
|
||||
/// How far apart (ms) two copies of a message from different sources may
|
||||
/// be stamped and still count as one message (e.g. live over voice and
|
||||
/// again from the gateway). No maximum.
|
||||
pub static CHAT_DEDUPE_TOLERANCE_MS: Key<u64> = Key::new(
|
||||
"chat.dedupe_tolerance_ms",
|
||||
Kind::UInt { min: 0 },
|
||||
"Time difference (ms) within which two copies of a message are one.",
|
||||
|| 5000,
|
||||
);
|
||||
|
||||
/// Delete stored chat messages older than this many days (pinned ones
|
||||
/// stay); 0 keeps everything.
|
||||
pub static CHAT_RETENTION_DAYS: Key<u32> = Key::new(
|
||||
"chat.retention_days",
|
||||
Kind::UInt { min: 0 },
|
||||
"Delete stored chat messages older than this many days (0: keep all).",
|
||||
|| 0,
|
||||
);
|
||||
|
||||
/// The keys every [`Settings`] knows from the start.
|
||||
pub fn builtin_keys() -> [&'static dyn Setting; 11] {
|
||||
pub fn builtin_keys() -> [&'static dyn Setting; 15] {
|
||||
[
|
||||
&CRASH_REPORTS,
|
||||
&AUDIO,
|
||||
@@ -1075,6 +1110,10 @@ pub fn builtin_keys() -> [&'static dyn Setting; 11] {
|
||||
&STREAM_SRTP_PROFILES,
|
||||
&STREAM_HARDWARE_ACCELERATION,
|
||||
&STREAM_PERMISSIONS,
|
||||
&CHAT_STORE_HISTORY,
|
||||
&CHAT_HISTORY_PAGE,
|
||||
&CHAT_DEDUPE_TOLERANCE_MS,
|
||||
&CHAT_RETENTION_DAYS,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1127,6 +1166,10 @@ mod tests {
|
||||
);
|
||||
assert!(s.get(&STREAM_HARDWARE_ACCELERATION));
|
||||
assert_eq!(s.get(&STREAM_ENCODER_BACKEND), "auto");
|
||||
assert!(s.get(&CHAT_STORE_HISTORY));
|
||||
assert_eq!(s.get(&CHAT_HISTORY_PAGE), 100);
|
||||
assert_eq!(s.get(&CHAT_DEDUPE_TOLERANCE_MS), 5000);
|
||||
assert_eq!(s.get(&CHAT_RETENTION_DAYS), 0);
|
||||
assert_eq!(s.source("stream.fps"), Some(Source::Default));
|
||||
let names: Vec<_> = s.keys().iter().map(|k| k.name()).collect();
|
||||
assert!(names.contains(&"stream.permissions") && names.contains(&"audio"));
|
||||
|
||||
Reference in new issue
Block a user