diff --git a/spacetimedb/src/lib.rs b/spacetimedb/src/lib.rs
index 3770b82..5362873 100644
--- a/spacetimedb/src/lib.rs
+++ b/spacetimedb/src/lib.rs
@@ -90,14 +90,25 @@ pub fn init(ctx: &ReducerContext) {
pub fn on_connect(ctx: &ReducerContext) {
log::info!("on_connect START: identity={}", ctx.sender().to_hex());
- // We'll keep this extremely minimal to ensure connection stability
+ // Extract potential name from OIDC if available
+ let mut initial_name = None;
+ if let Some(jwt) = ctx.sender_auth().jwt() {
+ let sub = jwt.subject();
+ // Use first 8 chars of sub if it's a long string/UUID
+ initial_name = Some(if sub.len() > 12 { sub[..8].to_string() } else { sub.to_string() });
+ }
+
if let Some(mut user) = ctx.db.user().identity().find(ctx.sender()) {
user.online = true;
+ // Update name from OIDC if current user has no name
+ if user.name.is_none() && initial_name.is_some() {
+ user.name = initial_name;
+ }
ctx.db.user().identity().update(user);
} else {
ctx.db.user().insert(User {
identity: ctx.sender(),
- name: None,
+ name: initial_name,
online: true,
issuer: None,
subject: None,
@@ -160,9 +171,16 @@ pub fn update_auth_info(ctx: &ReducerContext) {
log::info!("update_auth_info: identity={}", ctx.sender().to_hex());
if let Some(mut user) = ctx.db.user().identity().find(ctx.sender()) {
if let Some(jwt) = ctx.sender_auth().jwt() {
+ let sub = jwt.subject();
user.issuer = Some(jwt.issuer().to_string());
- user.subject = Some(jwt.subject().to_string());
+ user.subject = Some(sub.to_string());
user.anonymous = false;
+
+ // Also update name if they don't have a custom one yet
+ if user.name.is_none() {
+ user.name = Some(if sub.len() > 12 { sub[..8].to_string() } else { sub.to_string() });
+ }
+
ctx.db.user().identity().update(user);
sync_server_member_info(&ctx.db, ctx.sender());
log::info!("update_auth_info: updated user with OIDC info");
diff --git a/src/InnerProvider.svelte b/src/InnerProvider.svelte
index 1a5403e..69b93d0 100644
--- a/src/InnerProvider.svelte
+++ b/src/InnerProvider.svelte
@@ -1,6 +1,7 @@
diff --git a/src/auth/AuthGate.svelte b/src/auth/AuthGate.svelte
index 6a4617b..9dde66b 100644
--- a/src/auth/AuthGate.svelte
+++ b/src/auth/AuthGate.svelte
@@ -53,13 +53,13 @@
}
});
- // Split combined connection if it changes
+ // Split combined connection if it changes (Only when on login screen)
$effect(() => {
- if (combinedConnection.includes(":")) {
+ if (!userWantsToConnect && combinedConnection.includes(":")) {
const lastColon = combinedConnection.lastIndexOf(":");
const host = combinedConnection.substring(0, lastColon);
const db = combinedConnection.substring(lastColon + 1);
- if (host && db) {
+ if (host && db && (host !== stdbHost || db !== stdbDbName)) {
untrack(() => {
stdbHost = host;
stdbDbName = db;
@@ -71,23 +71,31 @@
// Update combined connection if individual fields change (e.g. on mount)
$effect(() => {
const hostPart = stdbHost.replace(/^(https?|wss?):\/\//, "");
- combinedConnection = `${hostPart}:${stdbDbName}`;
+ const expected = `${hostPart}:${stdbDbName}`;
+ if (combinedConnection !== expected) {
+ combinedConnection = expected;
+ }
});
let hasStoredToken = $state(false);
$effect(() => {
- // Check for token on mount and when connection params change
- const _ = combinedConnection;
- hasStoredToken = !!TokenStore.get(stdbHost, stdbDbName);
+ // Check for token when connection params change
+ if (stdbHost && stdbDbName) {
+ hasStoredToken = !!TokenStore.get(stdbHost, stdbDbName);
+ }
});
$effect(() => {
- if (stdbHost) localStorage.setItem(HOST_KEY, stdbHost);
+ if (stdbHost && localStorage.getItem(HOST_KEY) !== stdbHost) {
+ localStorage.setItem(HOST_KEY, stdbHost);
+ }
});
$effect(() => {
- if (stdbDbName) localStorage.setItem(DB_NAME_KEY, stdbDbName);
+ if (stdbDbName && localStorage.getItem(DB_NAME_KEY) !== stdbDbName) {
+ localStorage.setItem(DB_NAME_KEY, stdbDbName);
+ }
});
const isBypassEnabled =
diff --git a/src/chat/ChatContainer.svelte b/src/chat/ChatContainer.svelte
index 365c626..c5e032a 100644
--- a/src/chat/ChatContainer.svelte
+++ b/src/chat/ChatContainer.svelte
@@ -301,7 +301,11 @@
{/if}
{#if chat.userContextMenu}
- (chat.userContextMenu = null)} />
+ (chat.userContextMenu = null)}
+ onAction={closeSidebars}
+ />
{/if}
{#if chat.confirmModal}
diff --git a/src/chat/components/UserContextMenu.svelte b/src/chat/components/UserContextMenu.svelte
index f6a3e96..f41fd4a 100644
--- a/src/chat/components/UserContextMenu.svelte
+++ b/src/chat/components/UserContextMenu.svelte
@@ -5,11 +5,12 @@
import type * as Types from "../../module_bindings/types";
import { portal } from "../../portal";
- let { x, y, user, onClose }: {
+ let { x, y, user, onClose, onAction }: {
x: number,
y: number,
user: Types.User,
- onClose: () => void
+ onClose: () => void,
+ onAction?: () => void
} = $props();
const chat = getContext("chat");
@@ -108,6 +109,7 @@
{#if !isMe}