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

未关闭 适合新手
#125 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
73/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
fastapi, python
领域
api, backend

调研方向

阅读 routes/config.py 中 _config_response 和 reload_config_endpoint 附近的代码,然后对比 issue 中提到的 /save 检查和 GET /content 的行为。检查 server/state.py 中相关的状态辅助函数,以及涵盖 reload 和会话 trial 的测试。完成标准是:重新加载 trial 不会丢弃其内容,且 trial 响应不会报告虚构的配置路径。

由索引模型根据 Issue 内容生成。

描述

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).
主要语言
Python
星标
1
派生
1
平均合并
4 小时 46 分钟
30 天内合并 PR
55

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

falbany/ProFiles 的其他 Issue

查看 falbany/ProFiles 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。