Merge pull request #709 from AutoMaker-Org/refactor/store-defaults

refactor(store): Extract default values into store/defaults/
This commit is contained in:
Shirone
2026-01-25 22:39:59 +00:00
committed by GitHub
7 changed files with 74 additions and 62 deletions

View File

@@ -5,11 +5,7 @@ import { getElectronAPI } from '@/lib/electron';
import { getHttpApiClient } from '@/lib/http-api-client'; import { getHttpApiClient } from '@/lib/http-api-client';
import { createLogger } from '@automaker/utils/logger'; import { createLogger } from '@automaker/utils/logger';
// Note: setItem/getItem moved to ./utils/theme-utils.ts // Note: setItem/getItem moved to ./utils/theme-utils.ts
import { import { UI_SANS_FONT_OPTIONS, UI_MONO_FONT_OPTIONS } from '@/config/ui-font-options';
UI_SANS_FONT_OPTIONS,
UI_MONO_FONT_OPTIONS,
DEFAULT_FONT_VALUE,
} from '@/config/ui-font-options';
import type { import type {
Feature as BaseFeature, Feature as BaseFeature,
FeatureImagePath, FeatureImagePath,
@@ -63,6 +59,7 @@ import {
type BoardViewMode, type BoardViewMode,
type ShortcutKey, type ShortcutKey,
type KeyboardShortcuts, type KeyboardShortcuts,
type BackgroundSettings,
// Settings types // Settings types
type ApiKeys, type ApiKeys,
// Chat types // Chat types
@@ -111,6 +108,9 @@ import {
isClaudeUsageAtLimit, isClaudeUsageAtLimit,
} from './utils'; } from './utils';
// Import default values from modular defaults files
import { defaultBackgroundSettings, defaultTerminalState, MAX_INIT_OUTPUT_LINES } from './defaults';
// Import internal theme utils (not re-exported publicly) // Import internal theme utils (not re-exported publicly)
import { import {
getEffectiveFont, getEffectiveFont,
@@ -145,6 +145,7 @@ export type {
BoardViewMode, BoardViewMode,
ShortcutKey, ShortcutKey,
KeyboardShortcuts, KeyboardShortcuts,
BackgroundSettings,
ApiKeys, ApiKeys,
ImageAttachment, ImageAttachment,
TextFileAttachment, TextFileAttachment,
@@ -189,6 +190,9 @@ export {
isClaudeUsageAtLimit, isClaudeUsageAtLimit,
}; };
// Re-export defaults from ./defaults for backward compatibility
export { defaultBackgroundSettings, defaultTerminalState, MAX_INIT_OUTPUT_LINES } from './defaults';
// NOTE: Type definitions moved to ./types/ directory, utilities moved to ./utils/ directory // NOTE: Type definitions moved to ./types/ directory, utilities moved to ./utils/ directory
// The following inline types have been replaced with imports above: // The following inline types have been replaced with imports above:
// - ViewMode, ThemeMode, BoardViewMode (./types/ui-types.ts) // - ViewMode, ThemeMode, BoardViewMode (./types/ui-types.ts)
@@ -203,31 +207,10 @@ export {
// - Theme utilities: THEME_STORAGE_KEY, getStoredTheme, getStoredFontSans, getStoredFontMono, etc. (./utils/theme-utils.ts) // - Theme utilities: THEME_STORAGE_KEY, getStoredTheme, getStoredFontSans, getStoredFontMono, etc. (./utils/theme-utils.ts)
// - Shortcut utilities: parseShortcut, formatShortcut, DEFAULT_KEYBOARD_SHORTCUTS (./utils/shortcut-utils.ts) // - Shortcut utilities: parseShortcut, formatShortcut, DEFAULT_KEYBOARD_SHORTCUTS (./utils/shortcut-utils.ts)
// - Usage utilities: isClaudeUsageAtLimit (./utils/usage-utils.ts) // - Usage utilities: isClaudeUsageAtLimit (./utils/usage-utils.ts)
// The following default values have been moved to ./defaults/:
// Maximum number of output lines to keep in init script state (prevents unbounded memory growth) // - MAX_INIT_OUTPUT_LINES (./defaults/constants.ts)
export const MAX_INIT_OUTPUT_LINES = 500; // - defaultBackgroundSettings (./defaults/background-settings.ts)
// - defaultTerminalState (./defaults/terminal-defaults.ts)
// Default background settings for board backgrounds
export const defaultBackgroundSettings: {
imagePath: string | null;
imageVersion?: number;
cardOpacity: number;
columnOpacity: number;
columnBorderEnabled: boolean;
cardGlassmorphism: boolean;
cardBorderEnabled: boolean;
cardBorderOpacity: number;
hideScrollbar: boolean;
} = {
imagePath: null,
cardOpacity: 100,
columnOpacity: 100,
columnBorderEnabled: true,
cardGlassmorphism: true,
cardBorderEnabled: true,
cardBorderOpacity: 100,
hideScrollbar: false,
};
const initialState: AppState = { const initialState: AppState = {
projects: [], projects: [],
@@ -319,23 +302,7 @@ const initialState: AppState = {
isAnalyzing: false, isAnalyzing: false,
boardBackgroundByProject: {}, boardBackgroundByProject: {},
previewTheme: null, previewTheme: null,
terminalState: { terminalState: defaultTerminalState,
isUnlocked: false,
authToken: null,
tabs: [],
activeTabId: null,
activeSessionId: null,
maximizedSessionId: null,
defaultFontSize: 14,
defaultRunScript: '',
screenReaderMode: false,
fontFamily: DEFAULT_FONT_VALUE,
scrollbackLines: 5000,
lineHeight: 1.0,
maxSessions: 100,
lastActiveProjectPath: null,
openTerminalMode: 'newTab',
},
terminalLayoutByProject: {}, terminalLayoutByProject: {},
specCreatingForProject: null, specCreatingForProject: null,
defaultPlanningMode: 'skip' as PlanningMode, defaultPlanningMode: 'skip' as PlanningMode,

View File

@@ -0,0 +1,13 @@
import type { BackgroundSettings } from '../types/ui-types';
// Default background settings for board backgrounds
export const defaultBackgroundSettings: BackgroundSettings = {
imagePath: null,
cardOpacity: 100,
columnOpacity: 100,
columnBorderEnabled: true,
cardGlassmorphism: true,
cardBorderEnabled: true,
cardBorderOpacity: 100,
hideScrollbar: false,
};

View File

@@ -0,0 +1,2 @@
// Maximum number of output lines to keep in init script state (prevents unbounded memory growth)
export const MAX_INIT_OUTPUT_LINES = 500;

View File

@@ -0,0 +1,3 @@
export { defaultBackgroundSettings } from './background-settings';
export { defaultTerminalState } from './terminal-defaults';
export { MAX_INIT_OUTPUT_LINES } from './constants';

View File

@@ -0,0 +1,21 @@
import { DEFAULT_FONT_VALUE } from '@/config/ui-font-options';
import type { TerminalState } from '../types/terminal-types';
// Default terminal state values
export const defaultTerminalState: TerminalState = {
isUnlocked: false,
authToken: null,
tabs: [],
activeTabId: null,
activeSessionId: null,
maximizedSessionId: null,
defaultFontSize: 14,
defaultRunScript: '',
screenReaderMode: false,
fontFamily: DEFAULT_FONT_VALUE,
scrollbackLines: 5000,
lineHeight: 1.0,
maxSessions: 100,
lastActiveProjectPath: null,
openTerminalMode: 'newTab',
};

View File

@@ -25,7 +25,13 @@ import type {
SidebarStyle, SidebarStyle,
} from '@automaker/types'; } from '@automaker/types';
import type { ViewMode, ThemeMode, BoardViewMode, KeyboardShortcuts } from './ui-types'; import type {
ViewMode,
ThemeMode,
BoardViewMode,
KeyboardShortcuts,
BackgroundSettings,
} from './ui-types';
import type { ApiKeys } from './settings-types'; import type { ApiKeys } from './settings-types';
import type { ChatMessage, ChatSession, FeatureImage } from './chat-types'; import type { ChatMessage, ChatSession, FeatureImage } from './chat-types';
import type { TerminalState, TerminalPanelContent, PersistedTerminalState } from './terminal-types'; import type { TerminalState, TerminalPanelContent, PersistedTerminalState } from './terminal-types';
@@ -253,20 +259,7 @@ export interface AppState {
isAnalyzing: boolean; isAnalyzing: boolean;
// Board Background Settings (per-project, keyed by project path) // Board Background Settings (per-project, keyed by project path)
boardBackgroundByProject: Record< boardBackgroundByProject: Record<string, BackgroundSettings>;
string,
{
imagePath: string | null; // Path to background image in .automaker directory
imageVersion?: number; // Timestamp to bust browser cache when image is updated
cardOpacity: number; // Opacity of cards (0-100)
columnOpacity: number; // Opacity of columns (0-100)
columnBorderEnabled: boolean; // Whether to show column borders
cardGlassmorphism: boolean; // Whether to use glassmorphism (backdrop-blur) on cards
cardBorderEnabled: boolean; // Whether to show card borders
cardBorderOpacity: number; // Opacity of card borders (0-100)
hideScrollbar: boolean; // Whether to hide the board scrollbar
}
>;
// Theme Preview (for hover preview in theme selectors) // Theme Preview (for hover preview in theme selectors)
previewTheme: ThemeMode | null; previewTheme: ThemeMode | null;

View File

@@ -68,6 +68,19 @@ export interface ShortcutKey {
alt?: boolean; // Alt/Option key modifier alt?: boolean; // Alt/Option key modifier
} }
// Board background settings
export interface BackgroundSettings {
imagePath: string | null;
imageVersion?: number;
cardOpacity: number;
columnOpacity: number;
columnBorderEnabled: boolean;
cardGlassmorphism: boolean;
cardBorderEnabled: boolean;
cardBorderOpacity: number;
hideScrollbar: boolean;
}
// Keyboard Shortcuts - stored as strings like "K", "Shift+N", "Cmd+K" // Keyboard Shortcuts - stored as strings like "K", "Shift+N", "Cmd+K"
export interface KeyboardShortcuts { export interface KeyboardShortcuts {
// Navigation shortcuts // Navigation shortcuts