Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
/**
* A full theme export is a few KB, so anything past this is not a theme file.
* The guard runs on the size before the bytes are ever read: a large file
* would otherwise be pulled into memory, highlighted, and rendered, which
* locks the UI for as long as that takes.
*/
export const MAX_THEME_FILE_BYTES = 256 * 1024;
function formatByteSize(bytes: number): string {
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`;
return `${bytes} bytes`;
}
/** Returns the error to show for a file too large to be a theme, else null. */
export function describeOversizedThemeFile(bytes: number): string | null {
if (bytes <= MAX_THEME_FILE_BYTES) return null;
return `That file is ${formatByteSize(bytes)}. Theme files are only a few KB, so this one was not read (limit ${formatByteSize(MAX_THEME_FILE_BYTES)}).`;
}