Web UI: theme preference is persisted but never restored; session-trial theme leaks into localStorage

未关闭
#129 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@falbany 已经在做这个了。

开始于 2026年11月17日。

  • #184 来自 @falbany —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
67/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript
领域
frontend

调研方向

Start in web/src/App.tsx at the theme state initializer, initializeFromConfig, handleConfigLoaded, and the persistence effect; also read utils/theme.ts for how auto is resolved. Check the existing theme-related tests or add coverage for restoring a saved preference and preventing a session-trial theme from being saved. Done when the saved theme is restored, config themes still override it, and trial themes do not leak into localStorage.

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

描述

bug frontend

Problem

localStorage.setItem("profiles-theme", …) is written in two places (App.tsx:564, App.tsx:1450), but a full grep of web/src, index.html and the desktop shell finds zero getItem("profiles-theme") reads; initial state is hardcoded useState<"dark" | "light">("dark") (line 66). The persistence is dead — theme resets to dark every session.

Additionally, handleConfigLoaded's comment (App.tsx:377-380) promises a dropped/session-trial config's theme "must NOT persist… that would leak the trial into the next session" — but setTheme(...) from the trial fires the persistence effect (App.tsx:1447-1454), which writes the trial theme to localStorage anyway. Today that's harmless only because nothing reads it; the moment someone implements the read side, the leak activates.

Suggested fix

  1. Initialize theme from localStorage.getItem("profiles-theme") in the useState initializer.
  2. Track theme provenance in a ref; skip the write when the theme came from a session-trial config.
  3. Keep config-file theme as the override in initializeFromConfig.
  4. While in there: consider honoring theme: auto via matchMedia("(prefers-color-scheme: light)") — resolveSessionTheme (utils/theme.ts:6-8) currently flattens auto to dark.
主要语言
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 摘要。