mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-15 03:12:21 +02:00
perf(ui): stop session loading from blocking shell (#5927)
* perf(ui): stop session loading from blocking shell * fix(startup): open routes on their own data, retire the loader for good Follow-up to review on #5927. - Route openers are now classified by the data they actually read. Only /email touches the hydrated session list (its new-chat path falls back to the most recent session's model when no default chat is set), so every other route opens as soon as module wiring completes instead of queueing behind /api/sessions. This is the deferred-route half of #5926, which the first pass left unimplemented. - index.html's 5s fallback removes the loader node again. Leaving it in the DOM indefinitely kept _shouldPreserveStartupComposer true forever on a hung /api/sessions, so the composer stopped clearing on session switch. - A missing session module settles hydration instead of leaving the sidebar on "Loading chats…" and dropping the user's route on the floor. - Startup sequencing moved to static/js/startupShell.js so it can be run by tests. The source-text assertions in test_startup_shell_session_loading.py are replaced by node-driven behavioural tests, per tests/TESTING_STANDARD.md. - Reverted the unrequested loader a11y rework, removed the duplicated inert writes (the module stops the wave interval through a callback), and moved the bootstrap row's inline styles into .session-list-bootstrap. * fix: preserve session bootstrap failure state --------- Co-authored-by: Léo <leograndcontact@gmail.com>
This commit is contained in:
+20
-1
@@ -1683,8 +1683,21 @@ export async function loadSessions() {
|
||||
url += `?active_incognito_id=${encodeURIComponent(currentSessionId)}`;
|
||||
}
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
let detail = '';
|
||||
try {
|
||||
const payload = await res.json();
|
||||
detail = payload?.detail || payload?.error || '';
|
||||
} catch (_) {}
|
||||
const error = new Error(detail || `Session request failed (HTTP ${res.status})`);
|
||||
error.status = res.status;
|
||||
throw error;
|
||||
}
|
||||
fetched = await res.json();
|
||||
}
|
||||
if (!Array.isArray(fetched)) {
|
||||
throw new Error('Session request returned an invalid response');
|
||||
}
|
||||
sessions = _normalizeSessionsList(fetched);
|
||||
renderSessionList();
|
||||
|
||||
@@ -1807,9 +1820,15 @@ export async function loadSessions() {
|
||||
_autoCreateInProgress = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('Error in loadSessions:', error);
|
||||
uiModule.showError('Failed to load sessions: ' + error.message);
|
||||
// app.js's global fetch wrapper owns expired-auth navigation. Avoid
|
||||
// flashing a redundant session error while that 401 redirect is pending.
|
||||
if (error?.status !== 401) {
|
||||
uiModule.showError('Failed to load sessions: ' + error.message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user