Skip to content

fix(desktop): skip non-config odoc documents instead of failing the apply (#193) - #196

Open
falbany wants to merge 5 commits into
mainfrom
fix/193-odoc-folder-toast
Open

falbany wants to merge 5 commits into
mainfrom
fix/193-odoc-folder-toast

Conversation

@falbany

@falbany falbany commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Closes #193.

Root cause recap

macOS delivers the opened folder as an odoc AppleEvent. The startup path handles that gracefully — resolve_config_path skips non-config documents and falls back to the directory search (documented wildcard fallback picks a.profiles) — but the running-window applier (_make_document_applier, added by #188) fed every delivered path into apply_config_from_disk, which rejects non-whitelisted names with 400 Not a ProFiles configuration file → spurious Could not apply '<folder>': … toast, even though the launch had already resolved the folder's config correctly.

Change

Not changed on purpose: the launch-time wildcard fallback itself (documented, deliberate) and launch resolution's case-sensitive document matching — out of scope here.

Verification

Launcher-style launches (Start Menu, pinned taskbar, .desktop entries)
run with an uninformative CWD — System32, the home folder, or an
install/runtime directory — and used to propose creating .profiles in
that system directory, with a starter scanning it.

New profiles.core.paths module is the single source of truth:

- user_data_dir() / user_config_path(): ~/.profiles shared by logs and
  the per-user default config (default_log_path now delegates).
- find_user_config(): canonical names at depth 0 in the data dir.
- is_uninformative_directory(): None, filesystem roots, home itself,
  sys.prefix, the executable's directory, and %SystemRoot%/%windir% /
  %ProgramFiles% when set (env-driven so tests are portable).
- default_config_path(): uninformative start or a directory collision
  (CWD == home vs the ~/.profiles log dir) falls back to the per-user
  path; informative starts propose in place.
- default_search_directory(): home for launcher starts, never System32.

Wiring: launch resolution skips the CWD tree search for uninformative
directories and falls back to the user config; app startup binds the
defaults AppConfig to the policy-chosen path; load_config() and
propose_config_creation() follow the same policy; ServerState
.active_config_path() never returns an existing directory; the server's
create/template endpoints and empty-config first paint use
default_search_directory. STARTER_CONFIG_TEMPLATE discovery comment
documents the new order.

Closes #191
)

With no active configuration, the editor's "Load config file…" and the
file list's "Choose configuration" buttons opened the picker in Create
mode: App kept a single showConfigPicker boolean with no record of why
the picker opened, and LoadConfigModal inferred its mode from the global
config state (configExists === false), so every entry point rendered
Create whenever the session had no config.

App now carries the intent explicitly: configPickerMode is
"load" | "create" | null (null = closed). The first-run auto-prompt
(initializeFromConfig) is the only entry point that opens "create";
both explicit actions open "load". LoadConfigModal takes that mode as a
prop and stops consulting configExists; title, banner and primary
button follow it.

No server/API change; onLoaded/onClose behavior unchanged (editor
reload key still bumps on pick, issue #101).

Closes #192
Fresh vite build (tsc -b && vite build) serving the Load-mode picker
fix; regenerated PWA precache hashes.

The minified bundle crossed the pre-commit large-file line (1 MB), so
check-added-large-files now exempts the tracked dist/ build output —
it is a generated artifact, not hand-edited source.
CI's pyright flagged Path|None operand/return types in
default_config_path/default_search_directory: the CWD fallback hid the
None case from the type checker. A shared _effective_start() helper
resolves the start (or CWD) once, and the explicit None checks narrow
before use. Behavior unchanged.
…pply

macOS also delivers the opened folder — or any non-config document — as
an odoc AppleEvent. The running-window applier (_make_document_applier)
fed every delivered path into apply_config_from_disk, which rejects
non-whitelisted names with 400 'Not a ProFiles configuration file',
turning a normal folder open into a spurious 'Could not apply ...'
failure toast (issue #193) — while launch resolution had already
correctly resolved the folder via its documented wildcard fallback
(a.profiles-style configs).

The applier now skips non-config-named paths exactly like
resolve_config_path skips them, logging at DEBUG instead of toasting.
The shared, case-insensitive predicate (is_config_file_name) moves to
the core next to CONFIG_FILE_NAMES so the guard can never drift from
what the apply endpoints accept (issue #95 wave case handling).
Config-named but missing/invalid files keep their failure toast.

Closes #193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant