Repository navigation
Description
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
- Start ProFiles with no
.profilesreachable (fresh install / launcher start). - The first-run Create configuration picker appears (expected).
- Open the Configuration Editor (status-bar Config).
- Click Load config file… in the editor header.
- The picker opens as Create configuration, with the Create configuration primary button. Selecting an existing
.profilesfile does not enable a load action.
Root cause
Two independent facts are conflated:
Appkeeps a single booleanshowConfigPicker(src/profiles/web/src/App.tsx:80), with no record of why the picker was opened.LoadConfigModalderives its mode from the global config state:const isCreateMode = configExists === false(src/profiles/web/src/components/LoadConfigModal.tsx:33), andApppassesconfigExists={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).ConfigEditorModalonLoadConfig:setConfigPickerMode("load").FileListTableonLoadConfig:setConfigPickerMode("load").LoadConfigModalonClose: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".configExistsis 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 frommode === "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~/.profilesfor a launcher start.
No server/API changes.
Implementation checklist
- Add
ConfigPickerModestate insrc/profiles/web/src/App.tsx; replaceshowConfigPickerreads/writes (initial auto-open, editor handler, FileList handler, modalisOpen/close). - Update
LoadConfigModal.tsxprops andisCreateMode; adjust title/banner/primary button and any tests. - Update
App.configEditor.test.tsxand add the missing no-config integration case. - Optional unit test for
LoadConfigModalwithmode="load"/mode="create"(currently the component has no dedicated test file). - Typecheck / vitest / build.
Tests
- App integration — no config, editor entry point (regression):
fetchConfigreturnsconfig_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.
- App integration — FileList entry point:
- Same setup; click Choose configuration.
- Picker is in load mode.
- With an active config: editor picker remains load mode (existing test must stay green).
- 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
- ui(editor): all actions in the header + move "Load config…" from the StatusBar into the editor #101 — editor-raised config picker and editor reload key.
- Launcher config-location issue (per-user
~/.profiles/.profiles): once fixed, the picker's initial directory for a no-config launcher session becomes~/.profilesinstead ofC:\Windows\System32.
Activity
fix(web): config picker opens Load mode from explicit entry points (#192