Skip to content

Persistence and Storage

Timon Home edited this page Mar 19, 2026 · 1 revision

Persistence & Storage

JRC uses two persistence layers: electron-store for long-term configuration and sessionStorage for per-session console logs.


electron-store (src/main/store.ts)

electron-store wraps a JSON file on disk with schema validation. JRC uses it to persist profiles and settings.

File location

OS Path
Windows %APPDATA%\java-runner-client\java-runner-config.json
Linux ~/.config/java-runner-client/java-runner-config.json
macOS ~/Library/Application Support/java-runner-client/java-runner-config.json

Schema

interface StoreSchema {
  profiles: Profile[]
  settings: AppSettings
}

Exported functions

getAllProfiles(): Profile[]
saveProfile(profile: Profile): void   // upsert; stamps updatedAt server-side
deleteProfile(id: string): void
getSettings(): AppSettings            // merged with DEFAULT_SETTINGS
saveSettings(settings: AppSettings): void

getSettings() always returns a complete AppSettings object. It spreads DEFAULT_SETTINGS first then the stored value, so adding new settings fields in future releases will not break configs written by older versions.

Default settings

const DEFAULT_SETTINGS: AppSettings = {
  launchOnStartup:    false,
  startMinimized:     false,
  minimizeToTray:     true,
  consoleFontSize:    13,
  consoleMaxLines:    5000,
  consoleWordWrap:    false,
  consoleLineNumbers: false,
  consoleHistorySize: 200,
  theme:              'dark',
}

Direct editing

The JSON file can be edited manually while JRC is closed. Changes take effect on next launch. Corrupt JSON will cause electron-store to reset to defaults.


sessionStorage (renderer)

Console output lines are stored in sessionStorage to survive React re-renders, hot-module replacement, and route changes without requiring another IPC round-trip.

Key format

jrc:console:<profileId>

Example: jrc:console:550e8400-e29b-41d4-a716-446655440000

Behaviour

  • Written after every APPEND_LOG dispatch via saveLogs(id, lines)
  • Read on AppProvider mount for each profile via loadLogs(id, max)
  • Deleted on CLEAR_LOG and on profile deletion
  • Content is trimmed to settings.consoleMaxLines before saving
  • Automatically cleared by the browser when the Electron window is closed (sessionStorage is not persisted to disk by Chromium in Electron)

Activity Log (in-memory only)

The process activity log (processManager.activityLog) is an in-memory array. It is not written to disk and is lost when the app closes. Maximum 500 entries; oldest are dropped when the limit is exceeded.

Clone this wiki locally