server: POST /api/config/reload discards a dropped session-trial config and loads a phantom CWD-resolved .profiles

Open Beginner friendly
#125 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
73/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, python
Domain
api, backend

Research direction

Read routes/config.py around _config_response and reload_config_endpoint, then compare the /save guard and GET /content behavior cited in the issue. Check the related state helpers in server/state.py and tests covering reload and session trials. Done means reloading a trial cannot discard its content, and trial responses do not report a phantom config path.

Written by the indexing model from the issue text.

Description

bug

Problem

After POST /load-content (drag-drop), state.session_trial = True and no real path exists. But _config_response records a phantom path on every call (routes/config.py:93):

state.config_path = config_path

where active_config_path() falls back to find_config_file() or Path.cwd() / PRIMARY_CONFIG_NAME (server/state.py:67-69). POST /reload has no session-trial guard (unlike /save, which gates on has_disk_path() at config.py:442):

# routes/config.py:323-357
config_path = state.active_config_path()   # resolves the phantom
…
state.session_trial = False
state.trial_content = None

It loads that unrelated file, clears the trial state, and the user's dropped, possibly-unsaved draft is discarded — replaced by whatever .profiles sits in the CWD subtree (or by defaults if none loads: ConfigReader.load() silently falls back, reader.py:156-170).

The UI exposes this unconditionally: Ctrl+R (App.tsx:1299-1303) and the HeaderBar reload button (App.tsx:1571) call handleReloadConfig() with no trial check.

Suggested fix

  1. In reload_config_endpoint, refuse trials exactly like /save does: if not has_disk_path(state): raise HTTPException(400, "Cannot reload: the active configuration is a session trial…").
  2. Stop _config_response from mutating state.config_path / cfg.config_path when state.session_trial is True.
  3. Bonus: GET /content already returns config_path: None for trials (config.py:390-396) — _config_response should do the same so the UI can tell it is on a trial after a page refresh (related: #127-GET-mutation issue).
Dominant language
Python
Stars
1
Forks
1
Avg merge
4h 46m
Merged PRs (30d)
55

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from falbany/ProFiles

All issues in falbany/ProFiles

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.