Skip to content

web: "Load config file…" opens the create-config picker when no configuration is active #192

Closed

Description

@falbany

Summary

When ProFiles starts without an active configuration (config_exists: false), opening the Configuration Editor and clicking Load config file… opens the config picker in Create configuration mode. The user cannot load an existing config from that entry point.

The same happens from the FileList empty-state Choose configuration button. Only the first-run auto-prompt should propose creation; every explicit "load/choose" action must open load mode.

Reproduction

  1. Start ProFiles with no .profiles reachable (fresh install / launcher start).
  2. The first-run Create configuration picker appears (expected).
  3. Open the Configuration Editor (status-bar Config).
  4. Click Load config file… in the editor header.
  5. The picker opens as Create configuration, with the Create configuration primary button. Selecting an existing .profiles file does not enable a load action.

Root cause

Two independent facts are conflated:

  • App keeps a single boolean showConfigPicker (src/profiles/web/src/App.tsx:80), with no record of why the picker was opened.
  • LoadConfigModal derives its mode from the global config state: const isCreateMode = configExists === false (src/profiles/web/src/components/LoadConfigModal.tsx:33), and App passes configExists={config?.config_exists} (App.tsx:982-985).

So every entry point renders create mode whenever the session has no active config:

  • first-run auto-prompt (initializeFromConfig, App.tsx:395-397) — correct;
  • editor Load config file… (App.tsx:975, ConfigEditorModal.tsx) — wrong;
  • FileList empty-state Choose configuration (App.tsx:910) — wrong.

Desired behaviour

Entry point Session config Picker mode
First-run auto-prompt after GET /api/config reports config_exists: false missing Create
Editor header Load config file… any Load
FileList Choose configuration any Load
Status-bar Config → editor → picker any Load

Opening load mode while the session has no active config must still browse the filesystem normally and allow selecting/loading an existing .profiles file. Create remains available through the first-run prompt (and, if desired later, as a secondary action inside load mode — out of scope here).

Approaches considered

Approach Verdict Why
A. Explicit picker intent in App + mode prop on LoadConfigModal (chosen) Adopt The caller knows why the picker opened; the component stops inferring intent from unrelated global state. Small, testable, covers every entry point.
B. Pass a rewritten configExists (true when manually opening) Rejected Makes the prop lie about disk state and couples mode to a boolean that already means something else; the next entry point will regress again.
C. Always open in load mode and expose create as a separate button Rejected Larger UX change than requested; the first-run flow legitimately needs create as the primary action.

Design

State

Replace the boolean in App.tsx:

type ConfigPickerMode = "load" | "create";
const [configPickerMode, setConfigPickerMode] = useState<ConfigPickerMode | null>(null);

null = closed. Derive showConfigPicker if other code needs it (keyboard guards, etc.).

Transitions

  • initializeFromConfig: when !cfg.config_exists, setConfigPickerMode("create") (same auto-open as today).
  • ConfigEditorModal onLoadConfig: setConfigPickerMode("load").
  • FileListTable onLoadConfig: setConfigPickerMode("load").
  • LoadConfigModal onClose: setConfigPickerMode(null).
  • onLoaded: unchanged (handleConfigLoaded + setEditorReloadKey), then close.

Component API

LoadConfigModal takes an explicit mode instead of inferring it:

export interface LoadConfigModalProps {
  isOpen: boolean;
  mode: "load" | "create";
  activeConfigPath?: string;
  onClose: () => void;
  onLoaded: (config: AppConfigData) => void;
}
  • isCreateMode = mode === "create".
  • configExists is removed as a mode source. If the banner copy still needs it, keep it as an optional display-only prop; otherwise drop it and drive the "No configuration file was found" banner from mode === "create".
  • Title, banner, and primary button all follow mode.
  • The initial directory continues to come from activeConfigPath's parent; after the per-user-config design lands, that will be ~/.profiles for a launcher start.

No server/API changes.

Implementation checklist

  • Add ConfigPickerMode state in src/profiles/web/src/App.tsx; replace showConfigPicker reads/writes (initial auto-open, editor handler, FileList handler, modal isOpen/close).
  • Update LoadConfigModal.tsx props and isCreateMode; adjust title/banner/primary button and any tests.
  • Update App.configEditor.test.tsx and add the missing no-config integration case.
  • Optional unit test for LoadConfigModal with mode="load" / mode="create" (currently the component has no dedicated test file).
  • Typecheck / vitest / build.

Tests

  1. App integration — no config, editor entry point (regression):
    • fetchConfig returns config_exists: false.
    • First-run picker shows title Create configuration.
    • Close it.
    • Open the editor, click Load config file….
    • Picker shows title Load configuration and primary button Load configuration.
  2. App integration — FileList entry point:
    • Same setup; click Choose configuration.
    • Picker is in load mode.
  3. With an active config: editor picker remains load mode (existing test must stay green).
  4. LoadConfigModal unit: mode="create" renders create title/button; mode="load" renders load title/button and the load button stays disabled until a config is selected.

Acceptance criteria

  • On a no-config session, no explicit Load config file… / Choose configuration action ever opens create mode.
  • The first-run auto-prompt still opens create mode exactly once (per page load) and can be dismissed.
  • Selecting an existing config from the editor-raised picker loads it and reloads the editor content (existing issue ui(editor): all actions in the header + move "Load config…" from the StatusBar into the editor #101 behaviour).
  • No server change and no change to the first-run auto-open condition.

Related

Activity

  1. added
    bug
    frontend
    on Nov 18, 2026
  2. added this to the v1.0.0 milestone on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrontend

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions