detached 818aa54

Merge pull request #86 from kitpdr/fix/convex-client-setup

fix(deploy): align convex setup with static env
commit
818aa5467c93c2e442a8db63fc973e6fa6faa033
author
KiT · · 2026-01-24 09:00 UTC
committer
GitHub · · 2026-01-24 09:00 UTC
merge of
a47c61c + c844c36 · diff against the first parent
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
2 files · +25 -12
M src/lib/components/chat-room.svelte +25 -10
@@ -7,6 +7,7 @@
77 import { onMount, tick } from 'svelte';
88 import { SvelteSet, SvelteMap } from 'svelte/reactivity';
99 import { browser } from '$app/environment';
10+ import { env } from '$env/dynamic/public';
1011 import { api } from '$lib/api/client';
1112 import { draggable } from '$lib/actions/draggable';
1213 import { resizable } from '$lib/actions/resizable';
@@ -39,27 +40,31 @@
3940 initialTextStyle?: TextStyle;
4041 }>();
4142
43+ const isClient = browser && Boolean(env.PUBLIC_CONVEX_URL);
44+
4245 // ============ CONVEX REAL-TIME SUBSCRIPTIONS ============
4346
4447 // Subscribe to default room (to get room ID)
45- const defaultRoomQuery = useQuery(convexApi.queries.getDefaultRoomPublic, {});
48+ const defaultRoomQuery = isClient ? useQuery(convexApi.queries.getDefaultRoomPublic, {}) : null;
4649
4750 // Subscribe to users (buddy list) - real-time updates
48- const usersQuery = useQuery(convexApi.queries.getUsersPublic, {});
51+ const usersQuery = isClient ? useQuery(convexApi.queries.getUsersPublic, {}) : null;
4952
5053 // Room ID from Convex query
51- const roomId = $derived(defaultRoomQuery.data?.id as Id<'chatRooms'> | undefined);
54+ const roomId = $derived(defaultRoomQuery?.data?.id as Id<'chatRooms'> | undefined);
5255
5356 // Subscribe to messages - only when room ID is available
5457 const messagesQuery = $derived(
55- roomId ? useQuery(convexApi.queries.getMessagesPublic, () => ({ roomId: roomId! })) : null
58+ roomId && isClient
59+ ? useQuery(convexApi.queries.getMessagesPublic, () => ({ roomId: roomId! }))
60+ : null
5661 );
5762
58- const convexClient = useConvexClient();
63+ const convexClient = isClient ? useConvexClient() : null;
5964
6065 // Transform Convex users to SafeUser format
6166 const onlineUsers = $derived.by<SafeUser[]>(() => {
62- if (!usersQuery.data) return [];
67+ if (!usersQuery?.data) return [];
6368 return usersQuery.data
6469 .map((u) => ({
6570 id: u.id,
@@ -122,11 +127,13 @@
122127
123128 // Loading and error states from Convex
124129 const isInitialLoading = $derived(
125- defaultRoomQuery.isLoading || usersQuery.isLoading || messagesQuery?.isLoading
130+ (defaultRoomQuery?.isLoading ?? false) ||
131+ (usersQuery?.isLoading ?? false) ||
132+ (messagesQuery?.isLoading ?? false)
126133 );
127134 const connectionError = $derived.by<string | null>(() => {
128- if (defaultRoomQuery.error) return 'Erreur de connexion au salon';
129- if (usersQuery.error) return 'Erreur de chargement des utilisateurs';
135+ if (defaultRoomQuery?.error) return 'Erreur de connexion au salon';
136+ if (usersQuery?.error) return 'Erreur de chargement des utilisateurs';
130137 if (messagesQuery?.error) return 'Erreur de chargement des messages';
131138 return null;
132139 });
@@ -950,7 +957,15 @@
950957 const target = event.target as HTMLElement;
951958 const { scrollTop } = target;
952959
953- if (scrollTop < 100 && !isLoadingMore && hasMoreMessages && roomId && chatArea && currentUser) {
960+ if (
961+ scrollTop < 100 &&
962+ !isLoadingMore &&
963+ hasMoreMessages &&
964+ roomId &&
965+ chatArea &&
966+ currentUser &&
967+ convexClient
968+ ) {
954969 isLoadingMore = true;
955970 const prevScrollHeight = chatArea.scrollHeight;
956971 const prevScrollTop = chatArea.scrollTop;
@@ -7,6 +7,7 @@
7 import { onMount, tick } from 'svelte';7 import { onMount, tick } from 'svelte';
8 import { SvelteSet, SvelteMap } from 'svelte/reactivity';8 import { SvelteSet, SvelteMap } from 'svelte/reactivity';
9 import { browser } from '$app/environment';9 import { browser } from '$app/environment';
10+ import { env } from '$env/dynamic/public';
10 import { api } from '$lib/api/client';11 import { api } from '$lib/api/client';
11 import { draggable } from '$lib/actions/draggable';12 import { draggable } from '$lib/actions/draggable';
12 import { resizable } from '$lib/actions/resizable';13 import { resizable } from '$lib/actions/resizable';
@@ -39,27 +40,31 @@
39 initialTextStyle?: TextStyle;40 initialTextStyle?: TextStyle;
40 }>();41 }>();
41 42
43+ const isClient = browser && Boolean(env.PUBLIC_CONVEX_URL);
44+
42 // ============ CONVEX REAL-TIME SUBSCRIPTIONS ============45 // ============ CONVEX REAL-TIME SUBSCRIPTIONS ============
43 46
44 // Subscribe to default room (to get room ID)47 // Subscribe to default room (to get room ID)
45- const defaultRoomQuery = useQuery(convexApi.queries.getDefaultRoomPublic, {});48+ const defaultRoomQuery = isClient ? useQuery(convexApi.queries.getDefaultRoomPublic, {}) : null;
46 49
47 // Subscribe to users (buddy list) - real-time updates50 // Subscribe to users (buddy list) - real-time updates
48- const usersQuery = useQuery(convexApi.queries.getUsersPublic, {});51+ const usersQuery = isClient ? useQuery(convexApi.queries.getUsersPublic, {}) : null;
49 52
50 // Room ID from Convex query53 // Room ID from Convex query
51- const roomId = $derived(defaultRoomQuery.data?.id as Id<'chatRooms'> | undefined);54+ const roomId = $derived(defaultRoomQuery?.data?.id as Id<'chatRooms'> | undefined);
52 55
53 // Subscribe to messages - only when room ID is available56 // Subscribe to messages - only when room ID is available
54 const messagesQuery = $derived(57 const messagesQuery = $derived(
55- roomId ? useQuery(convexApi.queries.getMessagesPublic, () => ({ roomId: roomId! })) : null58+ roomId && isClient
59+ ? useQuery(convexApi.queries.getMessagesPublic, () => ({ roomId: roomId! }))
60+ : null
56 );61 );
57 62
58- const convexClient = useConvexClient();63+ const convexClient = isClient ? useConvexClient() : null;
59 64
60 // Transform Convex users to SafeUser format65 // Transform Convex users to SafeUser format
61 const onlineUsers = $derived.by<SafeUser[]>(() => {66 const onlineUsers = $derived.by<SafeUser[]>(() => {
62- if (!usersQuery.data) return [];67+ if (!usersQuery?.data) return [];
63 return usersQuery.data68 return usersQuery.data
64 .map((u) => ({69 .map((u) => ({
65 id: u.id,70 id: u.id,
@@ -122,11 +127,13 @@
122 127
123 // Loading and error states from Convex128 // Loading and error states from Convex
124 const isInitialLoading = $derived(129 const isInitialLoading = $derived(
125- defaultRoomQuery.isLoading || usersQuery.isLoading || messagesQuery?.isLoading130+ (defaultRoomQuery?.isLoading ?? false) ||
131+ (usersQuery?.isLoading ?? false) ||
132+ (messagesQuery?.isLoading ?? false)
126 );133 );
127 const connectionError = $derived.by<string | null>(() => {134 const connectionError = $derived.by<string | null>(() => {
128- if (defaultRoomQuery.error) return 'Erreur de connexion au salon';135+ if (defaultRoomQuery?.error) return 'Erreur de connexion au salon';
129- if (usersQuery.error) return 'Erreur de chargement des utilisateurs';136+ if (usersQuery?.error) return 'Erreur de chargement des utilisateurs';
130 if (messagesQuery?.error) return 'Erreur de chargement des messages';137 if (messagesQuery?.error) return 'Erreur de chargement des messages';
131 return null;138 return null;
132 });139 });
@@ -950,7 +957,15 @@
950 const target = event.target as HTMLElement;957 const target = event.target as HTMLElement;
951 const { scrollTop } = target;958 const { scrollTop } = target;
952 959
953- if (scrollTop < 100 && !isLoadingMore && hasMoreMessages && roomId && chatArea && currentUser) {960+ if (
961+ scrollTop < 100 &&
962+ !isLoadingMore &&
963+ hasMoreMessages &&
964+ roomId &&
965+ chatArea &&
966+ currentUser &&
967+ convexClient
968+ ) {
954 isLoadingMore = true;969 isLoadingMore = true;
955 const prevScrollHeight = chatArea.scrollHeight;970 const prevScrollHeight = chatArea.scrollHeight;
956 const prevScrollTop = chatArea.scrollTop;971 const prevScrollTop = chatArea.scrollTop;
M src/routes/+layout.svelte +0 -2
@@ -9,8 +9,6 @@
99 // Initialize Convex client for real-time subscriptions
1010 if (browser && env.PUBLIC_CONVEX_URL) {
1111 setupConvex(env.PUBLIC_CONVEX_URL);
12- } else if (browser && !env.PUBLIC_CONVEX_URL) {
13- console.error('Missing PUBLIC_CONVEX_URL for Convex client setup');
1412 }
1513
1614 let { children, data } = $props();
@@ -9,8 +9,6 @@
9 // Initialize Convex client for real-time subscriptions9 // Initialize Convex client for real-time subscriptions
10 if (browser && env.PUBLIC_CONVEX_URL) {10 if (browser && env.PUBLIC_CONVEX_URL) {
11 setupConvex(env.PUBLIC_CONVEX_URL);11 setupConvex(env.PUBLIC_CONVEX_URL);
12- } else if (browser && !env.PUBLIC_CONVEX_URL) {
13- console.error('Missing PUBLIC_CONVEX_URL for Convex client setup');
14 }12 }
15 13
16 let { children, data } = $props();14 let { children, data } = $props();

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 3

Tags 8

↑↓ moveenter openesc close