fix themes

This commit is contained in:
Alec Koifman
2025-12-12 17:52:06 -05:00
parent 5873e888a9
commit 1a4e9ccfcb
3 changed files with 17 additions and 5 deletions

View File

@@ -210,6 +210,7 @@ export function Sidebar() {
cycleNextProject,
clearProjectHistory,
setProjectTheme,
setTheme,
theme: globalTheme,
} = useAppStore();
@@ -430,12 +431,16 @@ export function Sidebar() {
);
useAppStore.setState({ projects: updatedProjects });
} else {
// Create new project
// Create new project - check for trashed project with same path first (preserves theme if deleted/recreated)
// Then fall back to current effective theme, then global theme
const trashedProject = trashedProjects.find((p) => p.path === path);
const effectiveTheme = trashedProject?.theme || currentProject?.theme || globalTheme;
project = {
id: `project-${Date.now()}`,
name,
path,
lastOpened: new Date().toISOString(),
theme: effectiveTheme,
};
addProject(project);
}
@@ -474,7 +479,7 @@ export function Sidebar() {
});
}
}
}, [projects, addProject, setCurrentProject]);
}, [projects, trashedProjects, addProject, setCurrentProject, currentProject, globalTheme]);
const handleRestoreProject = useCallback(
(projectId: string) => {
@@ -963,6 +968,10 @@ export function Sidebar() {
value={currentProject.theme || ""}
onValueChange={(value) => {
if (currentProject) {
// If selecting an actual theme (not "Use Global"), also update global
if (value !== "") {
setTheme(value as any);
}
setProjectTheme(
currentProject.id,
value === "" ? null : (value as any)

View File

@@ -82,12 +82,14 @@ export function SettingsView() {
// Compute the effective theme for the current project
const effectiveTheme = (settingsProject?.theme || theme) as Theme;
// Handler to set theme - saves to project if one is selected, otherwise to global
// Handler to set theme - always updates global theme (user's preference),
// and also sets per-project theme if a project is selected
const handleSetTheme = (newTheme: typeof theme) => {
// Always update global theme so user's preference persists across all projects
setTheme(newTheme);
// Also set per-project theme if a project is selected
if (currentProject) {
setProjectTheme(currentProject.id, newTheme);
} else {
setTheme(newTheme);
}
};

View File

@@ -636,6 +636,7 @@ export const useAppStore = create<AppState & AppActions>()(
name: trashed.name,
path: trashed.path,
lastOpened: new Date().toISOString(),
theme: trashed.theme, // Preserve theme from trashed project
};
set({