bug fixes, and performance improvements, and drawer

This commit is contained in:
Zoe
2026-09-27 18:44:51 -05:00
parent d48d8163a7
commit 2b9f8d64d7
52 changed files with 4913 additions and 778 deletions
+21
View File
@@ -0,0 +1,21 @@
/** Stable across database Dates, JSON SSE payloads, and Nuxt hydration. */
export const serializeTopicSnapshot = (topic: unknown): string => JSON.stringify(topic, (_key, value) => {
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
return value;
}
return Object.fromEntries(Object.keys(value).sort().map(key => [key, value[key]]));
});
/** Absolute offsets make replay across a snapshot boundary idempotent. */
export const appendTextDelta = (current: string, content: string, offset?: number): string => {
if (offset === undefined) {
return current + content;
}
if (offset > current.length) {
// A gap requires reconciliation, not silently concatenating corrupt text.
return current;
}
const overlap = current.length - offset;
return overlap >= content.length ? current : current + content.slice(overlap);
};