fix(journal): decouple broker from session

The broker connection now persists across session changes. Joining or switching a session swaps subscriptions instead of reconnecting, and a lobby lets sessions be listed and created before joining one.

Fixes session switching being a no-op (the store only updated local state) and session creation being unreachable before connecting. Also removes the dead ConnectionBar and the no-op hydrateFromServer/setSessionId store calls.
This commit is contained in:
2026-09-13 13:23:50 +08:00
parent 59f87bffda
commit 30ec8a43cf
9 changed files with 350 additions and 293 deletions
+10 -9
View File
@@ -2,7 +2,7 @@
* CreateSessionDialog — modal for naming a new session
*/
import { Component, createSignal, onMount } from "solid-js";
import { createSession, setSessionId, hydrateFromServer } from "../stores/journalStream";
import { createSession, joinSession } from "../stores/journalStream";
interface CreateSessionDialogProps {
onClose: () => void;
@@ -19,15 +19,16 @@ export const CreateSessionDialog: Component<CreateSessionDialogProps> = (
const trimmed = name().trim();
if (!trimmed) return;
setCreating(true);
const id = createSession(trimmed);
if (id) {
setSessionId(id);
// Hydrate the new (empty) session so the UI reflects it immediately
await hydrateFromServer(id).catch(() => {});
try {
const id = await createSession(trimmed);
if (id) await joinSession(id);
} catch (e) {
console.error("[journal] failed to create session:", e);
} finally {
setName("");
setCreating(false);
props.onClose();
}
setName("");
setCreating(false);
props.onClose();
};
onMount(() => inputRef?.focus());