mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 21:43:06 +00:00
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
* 🔭 feat: Recover Stale Chunks Without the Error Page and Ship Client Logs to RUM Stale chunks: a tab left open across a deploy that opens a code-split panel requests a hashed chunk the new deploy removed. Vite's preload handler hands the failure to the stale-asset recovery, which reloads, but the import then resolves to `undefined` and `React.lazy` throws a TypeError into the route error boundary, so the error page flashes before the reload. Lazy imports now go through `lazyWithRecovery`/`importWithRecovery`, which turn that result into a `ChunkLoadError`; the route boundary recognizes chunk failures (and any error while a recovery reload is underway), asks the page recovery once, and renders a localized "Updating to the latest version…" status. When the loop guard declines, the normal error page with its reload action shows instead. The page recovery is now idempotent within a page, so concurrent callers join the in-flight reload rather than tripping the guard. Client logs: with RUM in proxy mode, the client logger's warn/error calls, error-boundary catches and stale-asset recovery events are exported as OTLP log records through the authenticated `/api/rum/v1/logs` proxy. Records carry allowlisted, scrubbed fields only, follow RUM session sampling, dedupe repeats with a count, are budgeted per minute and per page, batch with backoff, flush with keepalive on page hide, and stop after persistent failures. The proxy now refuses non-OTLP content types and applies a per-user rate limit. `RUM_CLIENT_LOGS=false` turns the export off. * 🔒 fix: Keep Client Logs Opt-In and Drop Application Error Messages - RUM_CLIENT_LOGS now defaults to off, like console capture, so enabling RUM proxy mode never starts a new log stream on its own. - Error messages are exported only for engine, browser and library generated types (TypeError, SyntaxError, DOMException, AxiosError, chunk failures); application errors keep type, status and stack only, since their messages can echo prompt or response text. All quoted fragments are now redacted. - Batches are measured in encoded UTF-8 bytes of the exact request body, and page hide drains every queued record that fits the keepalive quota. - Queued stale-asset events are delivered as soon as the log exporter starts, independent of the RUM SDK loading, and marked so they are never logged twice. * 🔒 fix: Export Only Known Generated Error Messages and Ack Queued Events - Error messages are exported only when the whole text matches a known engine, browser or library message shape (property access on undefined, "x is not a function", fetch/abort/axios status, chunk and CSS preload failures). The error class alone no longer qualifies, since any code can throw a TypeError carrying arbitrary text. - Queued stale-asset events are marked logged only after the collector accepts the record carrying them, so an undelivered event replays on the next page; in-flight events are skipped by the SDK path. - A fractional RUM_PROXY_USER_MAX below one falls back to the default instead of flooring to a limit of zero. * 🔒 fix: Hold Unacknowledged Asset Events, Re-send In-Flight Logs on Hide - The RUM SDK flush no longer drops queued stale-asset events whose client log record is still unacknowledged: they stay queued and persisted, flagged so their SDK action is not repeated, and leave the queue once the collector accepts the record. - Page hide re-sends the records of an unanswered regular request with keepalive; each record belongs to the latest request carrying it, so a late response to the original request neither marks nor requeues it. - Client-log export stops when the authenticated layout unmounts. - The proxy refuses /v1/logs while client logs, console capture and replay are all off, so turning RUM_CLIENT_LOGS off also stops tabs that still hold an older startup config. * 🔒 fix: Export Only Complete Stack Frames, Never the Message Header Stack reduction now strips the V8 `name: message` header (including every line of a multi-line message) and keeps only lines with a complete V8, Gecko or WebKit frame shape that ends in a URL or absolute path with a line number. A message ending in a source-position-like suffix can no longer pass as a frame. * fix: centralize RUM delivery and asset recovery lifecycle * fix: preserve RUM page lifetime and collector acknowledgements * fix: retain page transport quotas and recover functional chunks * fix: scope RUM client sessions to authenticated identity --------- Co-authored-by: Lia <lia@librechat.ai>
310 lines
12 KiB
HTML
310 lines
12 KiB
HTML
<!doctype html>
|
|
<html lang="en-US">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<base href="/" />
|
|
<meta name="theme-color" content="#171717" />
|
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
<meta
|
|
name="description"
|
|
content="LibreChat - An open source chat application with support for multiple AI models"
|
|
/>
|
|
<title>LibreChat</title>
|
|
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32x32.png" />
|
|
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon-16x16.png" />
|
|
<link rel="apple-touch-icon" href="assets/apple-touch-icon-180x180.png" />
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1, interactive-widget=resizes-content"
|
|
/>
|
|
<style>
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
<script>
|
|
(function () {
|
|
let theme = null;
|
|
try {
|
|
theme = localStorage.getItem('color-theme');
|
|
} catch (e) {
|
|
/* Web Storage denied by browser policy: the shell falls back to the system theme. */
|
|
}
|
|
const loadingContainerStyle = document.createElement('style');
|
|
let dark;
|
|
let contrast;
|
|
|
|
if (theme === 'high-contrast-dark' || theme === 'high-contrast-light') {
|
|
dark = theme === 'high-contrast-dark';
|
|
contrast = true;
|
|
} else if (theme === 'dark' || theme === 'light') {
|
|
dark = theme === 'dark';
|
|
contrast = false;
|
|
} else {
|
|
/* `system`, and anything unset or unrecognised, which ThemeProvider also
|
|
* resolves as `system`. The OS decides the scheme and the contrast, and
|
|
* a contrast request moves the dark canvas to pure black, so keying off
|
|
* the scheme alone would flash #0d0d0d behind the black palette.
|
|
* The three contrast queries mirror ThemeProvider's `CONTRAST_QUERIES`:
|
|
* a Windows Contrast Theme reports `forced-colors: active` with
|
|
* `prefers-contrast: custom`, never `more`. */
|
|
dark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
contrast = [
|
|
'(prefers-contrast: more)',
|
|
'(prefers-contrast: custom)',
|
|
'(forced-colors: active)',
|
|
].some(function (query) {
|
|
return window.matchMedia(query).matches;
|
|
});
|
|
}
|
|
let backgroundColor = dark ? (contrast ? '#000000' : '#0d0d0d') : '#ffffff';
|
|
const root = document.documentElement;
|
|
root.classList.add(dark ? 'dark' : 'light');
|
|
|
|
/* The deployment theme (`interface.theme`) arrives with /api/config, so a
|
|
* signed-in reload replays the copy DeploymentTheme cached under
|
|
* `deployment-theme` (client/src/Providers/themeCache.ts) to paint it
|
|
* before the bundle runs. High contrast outranks it, as in ThemeProvider,
|
|
* which drops this copy (`data-theme-boot`) once it applies its own. */
|
|
const base = document.querySelector('base');
|
|
const basePath = base ? new URL(base.href).pathname : '/';
|
|
const path =
|
|
location.pathname.indexOf(basePath) === 0
|
|
? location.pathname.slice(basePath.length)
|
|
: location.pathname.replace(/^\//, '');
|
|
/* Same list as `isPublicRoute`: auth pages and shared links never render
|
|
* under the viewer's signed-in config. */
|
|
const publicRoute =
|
|
/^(?:share|oauth|login|register|forgot-password|reset-password|verify)(?:\/|$)/i.test(
|
|
path,
|
|
);
|
|
if (!contrast && !publicRoute) {
|
|
try {
|
|
const cached = JSON.parse(localStorage.getItem('deployment-theme') || 'null');
|
|
const boot =
|
|
cached && cached.v === 1 && cached.modes && cached.modes[dark ? 'dark' : 'light'];
|
|
if (boot && Array.isArray(boot.properties)) {
|
|
let surface;
|
|
boot.properties.forEach(function (entry) {
|
|
if (typeof entry[0] === 'string' && entry[0].indexOf('--') === 0) {
|
|
root.style.setProperty(entry[0], String(entry[1]));
|
|
/* Only an `R G B` triple reaches the shell's stylesheet text; any
|
|
* whitespace between channels is accepted, as the theme validator does. */
|
|
const channels = String(entry[1]).trim().split(/\s+/);
|
|
if (
|
|
entry[0] === '--surface-primary-alt' &&
|
|
channels.length === 3 &&
|
|
channels.every(function (channel) {
|
|
return /^\d{1,3}$/.test(channel);
|
|
})
|
|
) {
|
|
surface = channels.join(', ');
|
|
}
|
|
}
|
|
});
|
|
['data-theme', 'data-theme-disabled', 'data-theme-field-focus'].forEach(
|
|
function (name) {
|
|
const value = boot.attributes && boot.attributes[name];
|
|
if (typeof value === 'string') {
|
|
root.setAttribute(name, value);
|
|
}
|
|
},
|
|
);
|
|
root.setAttribute('data-theme-boot', '');
|
|
if (surface) {
|
|
backgroundColor = 'rgb(' + surface + ')';
|
|
}
|
|
}
|
|
} catch (e) {
|
|
/* Denied or corrupt storage paints the stock shell, as before. */
|
|
}
|
|
}
|
|
|
|
loadingContainerStyle.innerHTML = `
|
|
#loading-container {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100vh;
|
|
background-color: ${backgroundColor};
|
|
}
|
|
`;
|
|
document.head.appendChild(loadingContainerStyle);
|
|
})();
|
|
</script>
|
|
<script>
|
|
(function () {
|
|
var KEY = 'lc-asset-recovery-at';
|
|
var RUM_QUEUE_KEY = 'lc-rum-queue';
|
|
var MAX_RUM_QUEUE = 20;
|
|
window.__lcRumRecoveryGuardInstalled = true;
|
|
window.__lcRumQueue = Array.isArray(window.__lcRumQueue) ? window.__lcRumQueue : [];
|
|
try {
|
|
var persistedQueue = JSON.parse(sessionStorage.getItem(RUM_QUEUE_KEY) || '[]');
|
|
if (Array.isArray(persistedQueue)) {
|
|
window.__lcRumQueue = persistedQueue.concat(window.__lcRumQueue).slice(-MAX_RUM_QUEUE);
|
|
}
|
|
} catch (e) {
|
|
/* Diagnostics should never affect application startup. */
|
|
}
|
|
window.__lcRumPush = function (type, attributes) {
|
|
try {
|
|
var safeAttributes = {};
|
|
Object.keys(attributes || {}).forEach(function (key) {
|
|
var value = attributes[key];
|
|
if (
|
|
typeof value !== 'string' &&
|
|
typeof value !== 'number' &&
|
|
typeof value !== 'boolean'
|
|
) {
|
|
return;
|
|
}
|
|
safeAttributes[key] = value;
|
|
});
|
|
/* Stamp before persistence: a recovery reload may precede the RUM module. */
|
|
safeAttributes.clientBuildId = 'unknown';
|
|
var entryScripts = document.querySelectorAll('script[type="module"][src]');
|
|
for (var i = 0; i < entryScripts.length; i++) {
|
|
var filename = entryScripts[i]
|
|
.getAttribute('src')
|
|
.split(/[?#]/, 1)[0]
|
|
.split('/')
|
|
.pop();
|
|
if (/^index[.-][\w-]+\.js$/.test(filename)) {
|
|
safeAttributes.clientBuildId = filename;
|
|
break;
|
|
}
|
|
}
|
|
if (window.__lcRumQueue.length >= MAX_RUM_QUEUE) {
|
|
window.__lcRumQueue.shift();
|
|
}
|
|
window.__lcRumQueue.push({
|
|
type: type,
|
|
at: Math.round(performance.now()),
|
|
visibilityState: document.visibilityState,
|
|
attributes: safeAttributes,
|
|
});
|
|
sessionStorage.setItem(RUM_QUEUE_KEY, JSON.stringify(window.__lcRumQueue));
|
|
} catch (e) {
|
|
/* Diagnostics should never affect application startup. */
|
|
}
|
|
};
|
|
function shouldRecover() {
|
|
try {
|
|
var last = Number(sessionStorage.getItem(KEY)) || 0;
|
|
if (Date.now() - last < 60000) {
|
|
return false;
|
|
}
|
|
sessionStorage.setItem(KEY, String(Date.now()));
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
/* Every caller in this page shares one recovery: once a reload is underway, later
|
|
* chunk failures (Vite preload, unhandled rejection, error boundary) join it instead
|
|
* of tripping the loop guard and painting the error page before the reload lands. */
|
|
window.__lcRecoverStaleAssets = function () {
|
|
if (window.__lcStaleAssetRecoveryPending === true) {
|
|
return true;
|
|
}
|
|
if (!shouldRecover()) {
|
|
window.__lcRumPush('stale-asset-recovery-declined');
|
|
return false;
|
|
}
|
|
window.__lcStaleAssetRecoveryPending = true;
|
|
window.__lcRumPush('stale-asset-recovery-start');
|
|
var reload = function () {
|
|
window.__lcRumPush('stale-asset-recovery-reload');
|
|
window.location.reload();
|
|
};
|
|
if (navigator.serviceWorker) {
|
|
var scopeBase = new URL('./', document.baseURI || window.location.href).href;
|
|
navigator.serviceWorker
|
|
.getRegistrations()
|
|
.then(function (registrations) {
|
|
return Promise.all(
|
|
registrations
|
|
.filter(function (registration) {
|
|
return registration.scope.indexOf(scopeBase) === 0;
|
|
})
|
|
.map(function (registration) {
|
|
return registration.unregister();
|
|
}),
|
|
);
|
|
})
|
|
.then(reload, reload);
|
|
} else {
|
|
reload();
|
|
}
|
|
return true;
|
|
};
|
|
if (navigator.serviceWorker) {
|
|
navigator.serviceWorker.addEventListener('message', function (event) {
|
|
if (!event.data || event.data.type !== 'LC_SW_PING') {
|
|
return;
|
|
}
|
|
var source = event.source || navigator.serviceWorker.controller;
|
|
if (source) {
|
|
source.postMessage({ type: 'LC_SW_PONG' });
|
|
}
|
|
});
|
|
}
|
|
window.addEventListener(
|
|
'error',
|
|
function (event) {
|
|
var el = event.target;
|
|
if (!el || !el.tagName) {
|
|
return;
|
|
}
|
|
var failedScript = el.tagName === 'SCRIPT' && el.src;
|
|
var failedPreload =
|
|
el.tagName === 'LINK' && /preload/.test(el.rel || '') && /\.js$/.test(el.href || '');
|
|
if (failedScript || failedPreload) {
|
|
var isRumBootstrap = el.getAttribute('data-lc-rum-bootstrap') === 'true';
|
|
window.__lcRumPush('asset-load-error', {
|
|
tagName: el.tagName,
|
|
assetUrl: el.src || el.href,
|
|
optional: isRumBootstrap,
|
|
});
|
|
/* Caught optional imports must not reload the app. Required lazy imports
|
|
* recover at their own boundary; preload links only report diagnostics. */
|
|
if (isRumBootstrap || failedPreload) {
|
|
return;
|
|
}
|
|
window.__lcRecoverStaleAssets();
|
|
}
|
|
},
|
|
true,
|
|
);
|
|
window.addEventListener('unhandledrejection', function (event) {
|
|
var message = event.reason && event.reason.message;
|
|
if (
|
|
typeof message === 'string' &&
|
|
(message.indexOf('dynamically imported module') !== -1 ||
|
|
message.indexOf('Importing a module script failed') !== -1)
|
|
) {
|
|
window.__lcRumPush('dynamic-import-error');
|
|
window.__lcRecoverStaleAssets();
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
<script
|
|
data-lc-rum-bootstrap="true"
|
|
type="module"
|
|
src="/src/lib/rum/bootstrap-entry.js"
|
|
></script>
|
|
<script defer type="module" src="/src/main.jsx"></script>
|
|
</head>
|
|
<body>
|
|
<div id="root">
|
|
<div id="loading-container"></div>
|
|
</div>
|
|
</body>
|
|
</html>
|