πŸ“„ File detail

migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.ts

🧩 .tsπŸ“ 23 linesπŸ’Ύ 1,000 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œmigrations/”, which covers version migrations for settings or on-disk data. On the API surface it exposes migrateReplBridgeEnabledToRemoteControlAtStartup β€” mainly functions, hooks, or classes. It composes internal code from utils (relative imports).

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import { saveGlobalConfig } from '../utils/config.js' /** * Migrate the `replBridgeEnabled` config key to `remoteControlAtStartup`. *

πŸ“€ Exports (heuristic)

  • migrateReplBridgeEnabledToRemoteControlAtStartup

πŸ–₯️ Source preview

import { saveGlobalConfig } from '../utils/config.js'

/**
 * Migrate the `replBridgeEnabled` config key to `remoteControlAtStartup`.
 *
 * The old key was an implementation detail that leaked into user-facing config.
 * This migration copies the value to the new key and removes the old one.
 * Idempotent β€” only acts when the old key exists and the new one doesn't.
 */
export function migrateReplBridgeEnabledToRemoteControlAtStartup(): void {
  saveGlobalConfig(prev => {
    // The old key is no longer in the GlobalConfig type, so access it via
    // an untyped cast. Only migrate if the old key exists and the new key
    // hasn't been set yet.
    const oldValue = (prev as Record<string, unknown>)['replBridgeEnabled']
    if (oldValue === undefined) return prev
    if (prev.remoteControlAtStartup !== undefined) return prev
    const next = { ...prev, remoteControlAtStartup: Boolean(oldValue) }
    delete (next as Record<string, unknown>)['replBridgeEnabled']
    return next
  })
}