Files
openchamber/packages/ui/src/lib/projectMeta.ts
T
Bohdan Triapitsyn d1a41000ca perf: speed up desktop startup and unify theme-aware branding (#596)
* fix: unify startup logo and loading theme behavior

Show desktop window immediately with animated splash logo
Align splash/logo colors with selected app theme and default themes
Keep auth loading state on full-screen logo without size jump
Make project SVG icons follow active app theme
Use the active theme foreground color for project icons discovered from favicons
Apply server-side SVG color overrides for currentColor icons via icon request params
Keep non-SVG project icons unchanged while preserving existing fallback behavior

* perf: speed up desktop startup and unify loading logo visuals

Desktop startup now shows UI sooner while backend boot continues in background
Startup host probing uses a faster local path with safer remote fallback retries
OpenChamber logo cube highlights now match splash screens consistently

* fix: keep macOS traffic-light buttons in the correct position on load

Stop native window title updates on macOS during app initialization
Prevent title bar relayout that reset custom traffic-light positioning

* fix: recover missing providers and agents after fast startup

Retries provider/agent loading when connection is up but core config is still empty
Prevents cold-start state where models/agents appear only after manual project switch
Keeps startup responsive with throttled background recovery in app bootstrap
2026-03-04 19:16:45 +02:00

87 lines
3.6 KiB
TypeScript

import {
RiCodeBoxLine,
RiTerminalBoxLine,
RiRocketLine,
RiFlaskLine,
RiGamepadLine,
RiBriefcaseLine,
RiHomeLine,
RiGlobalLine,
RiLeafLine,
RiShieldLine,
RiPaletteLine,
RiServerLine,
RiSmartphoneLine,
RiDatabase2Line,
RiLightbulbLine,
RiMusicLine,
RiCameraLine,
RiBookOpenLine,
RiHeartLine,
type RemixiconComponentType,
} from '@remixicon/react';
import type { ProjectEntry } from '@/lib/api/types';
type ThemeVariant = 'light' | 'dark';
export const PROJECT_ICONS: Array<{ key: string; Icon: RemixiconComponentType; label: string }> = [
{ key: 'code', Icon: RiCodeBoxLine, label: 'Code' },
{ key: 'terminal', Icon: RiTerminalBoxLine, label: 'Terminal' },
{ key: 'rocket', Icon: RiRocketLine, label: 'Rocket' },
{ key: 'flask', Icon: RiFlaskLine, label: 'Lab' },
{ key: 'gamepad', Icon: RiGamepadLine, label: 'Game' },
{ key: 'briefcase', Icon: RiBriefcaseLine, label: 'Work' },
{ key: 'home', Icon: RiHomeLine, label: 'Home' },
{ key: 'globe', Icon: RiGlobalLine, label: 'Web' },
{ key: 'leaf', Icon: RiLeafLine, label: 'Nature' },
{ key: 'shield', Icon: RiShieldLine, label: 'Security' },
{ key: 'palette', Icon: RiPaletteLine, label: 'Design' },
{ key: 'server', Icon: RiServerLine, label: 'Server' },
{ key: 'phone', Icon: RiSmartphoneLine, label: 'Mobile' },
{ key: 'database', Icon: RiDatabase2Line, label: 'Data' },
{ key: 'lightbulb', Icon: RiLightbulbLine, label: 'Idea' },
{ key: 'music', Icon: RiMusicLine, label: 'Music' },
{ key: 'camera', Icon: RiCameraLine, label: 'Media' },
{ key: 'book', Icon: RiBookOpenLine, label: 'Docs' },
{ key: 'heart', Icon: RiHeartLine, label: 'Favorite' },
];
export const PROJECT_ICON_MAP: Record<string, RemixiconComponentType> = Object.fromEntries(
PROJECT_ICONS.map((i) => [i.key, i.Icon])
);
export const PROJECT_COLORS: Array<{ key: string; label: string; cssVar: string }> = [
{ key: 'keyword', label: 'Purple', cssVar: 'var(--syntax-keyword)' },
{ key: 'string', label: 'Green', cssVar: 'var(--syntax-string)' },
{ key: 'number', label: 'Pink', cssVar: 'var(--syntax-number)' },
{ key: 'type', label: 'Gold', cssVar: 'var(--syntax-type)' },
{ key: 'constant', label: 'Cyan', cssVar: 'var(--syntax-constant)' },
{ key: 'comment', label: 'Muted', cssVar: 'var(--syntax-comment)' },
{ key: 'error', label: 'Red', cssVar: 'var(--status-error)' },
{ key: 'primary', label: 'Blue', cssVar: 'var(--primary)' },
{ key: 'success', label: 'Green', cssVar: 'var(--status-success)' },
];
export const PROJECT_COLOR_MAP: Record<string, string> = Object.fromEntries(
PROJECT_COLORS.map((c) => [c.key, c.cssVar])
);
export const getProjectIconImageUrl = (
project: Pick<ProjectEntry, 'id' | 'iconImage'>,
options?: { themeVariant?: ThemeVariant; iconColor?: string },
): string | null => {
if (!project.iconImage || typeof project.iconImage.updatedAt !== 'number' || project.iconImage.updatedAt <= 0) {
return null;
}
const params = new URLSearchParams({ v: String(project.iconImage.updatedAt) });
if (typeof options?.iconColor === 'string' && options.iconColor.trim()) {
params.set('iconColor', options.iconColor.trim());
}
if (options?.themeVariant === 'light' || options?.themeVariant === 'dark') {
params.set('theme', options.themeVariant);
}
return `/api/projects/${encodeURIComponent(project.id)}/icon?${params.toString()}`;
};