Skip to content

feat: hot reload user scripts#1380

Open
130040167 wants to merge 2 commits into
BigPizzaV3:mainfrom
130040167:main
Open

feat: hot reload user scripts#1380
130040167 wants to merge 2 commits into
BigPizzaV3:mainfrom
130040167:main

Conversation

@130040167

Copy link
Copy Markdown
Contributor

Summary

  • Add user script snapshots so Codex++ can detect changes to installed marketplace scripts, local .js files, and user_scripts.json.
  • Start a lightweight launcher-side hot reload watcher after bridge injection; changed scripts are re-bundled and re-evaluated in the current Codex page.
  • Make user-script enable/disable/delete operations trigger an immediate reload instead of only updating inventory state.

Verification

  • cargo fmt --check
  • cargo test -p codex-plus-core
  • cargo test -p codex-plus-core --test bridge_routes
  • cargo test -p codex-plus-launcher --no-run
  • cargo build -p codex-plus-launcher --release

Note: hot reload re-executes enabled scripts. Scripts that register global listeners or mutate DOM still need to be idempotent, or require a page reload to fully clear old side effects after disabling.

@130040167

Copy link
Copy Markdown
Contributor Author

主要是完善脚本市场的热重载功能。因为有的时候会重新安装、主动修一下脚本的bug,尤其是让ai改起来会更加方便

@BigPizzaV3

Copy link
Copy Markdown
Owner

这个功能方向可以,不过建议加一个开关再合并。

现在 launcher 在 bridge 注入成功后会直接启动 start_user_script_hot_reload_watchdog(),每 1 秒对 user_scripts.json、builtin/user 脚本目录做 snapshot 检查。对经常改脚本的人很有用,但不是所有用户都需要热重载;默认常驻轮询可能会给不同使用场景带来没必要的资源消耗,也会增加一些脚本重复执行副作用的概率。

建议:

  • 在设置里加一个“用户脚本热重载”开关;
  • 只有开关开启时才启动 watchdog;
  • 手动点击 reload、启用/禁用/删除脚本时仍然可以立即 reload;
  • 如果默认开启,需要在 PR 里说明资源消耗和脚本副作用边界。

加完开关后我觉得这个 PR 更适合合并。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants