magpie icon indicating copy to clipboard operation
magpie copied to clipboard

Feature: hide a plugin page from the sidebar (Settings › Plugins Show/Hide)

Open Beyfish opened this issue 4 weeks ago • 5 comments

请求给 magpie 加个小功能,也请求 maintainer 允许提 PR。

需求(来自用户) 侧边栏「插件」的一栏(比如 RTK for DSH 自己的页面)没法单独隐藏;「停用」会把整个插件关掉,连功能也没了。想要在 设置 → 插件 里给每个插件页面切 显示/隐藏:隐藏后左侧栏没这栏,但插件继续运行、面板继续、「扩展 → 插件 → 已安装」里照常可见。

实现已备好(被权限卡住)

  • 分支:Beyfish/magpie 的 feat/plugin-page-visibility,commit 5e672cf
  • Settings › Plugins 列表 + POST /api/plugin-pages/hidden + 设置存 pluginPagesHidden
  • 测试:TestPluginPagesHidden、plugin-page-hidden.test.cjs(5 语言、Chromium/WebKit、宽窄窗)
  • 这边(Beyfish)对 yetone/magpie 只有只读权限,gh pr create 被 GitHub 拒了:Beyfish does not have the correct permissions to execute CreatePullRequest

请 maintainer 二选一

  1. 给 Beyfish 开 yetone/magpie 的协作者(写)权限,我立刻从该分支开正式 PR;
  2. 或直接拉该分支审;或告诉可接受的提 PR 方式。

验收:设置 → 插件里每个插件页面一栏可切;隐藏后侧边栏无该栏,插件与已安装不受影响;切换即时生效、重启保留。

Beyfish avatar Nov 08 '26 07:11 Beyfish

Thanks @Beyfish — I reviewed 5e672cf line by line and ran it. The feature is wanted and the code follows the same pattern as Usage's hidden lists (its own route, kept by settingsapi.Merge, normalised by ids in saveOwn). One thing blocks it, and there's one small change.

What was run (cherry-picked onto origin/main 195d79939, on a separate macOS box):

  • go test ./internal/gui/ ./internal/settings/ ./internal/settingsapi/ ./internal/cli/: settings, settingsapi and cli ok. gui fails only TestCoreScriptBudget (see 1).
  • node --test plugin-page-hidden.test.cjs i18n-keys.test.cjs menu-scroll.test.cjs: 30 pass, 0 fail.
  • Broken by hand: with the list.filter((e) => !hidden.has(e.key)) line removed from pluginpages.js, plugin-page-hidden goes 0 of 2. So the test guards the change.

1. Core script budget (blocking). The only conflict with main was core_budget_test.go. Main's budget is still 1,533,802, and with this change the core is 1,535,371, which is 1,569 bytes over. The branch raised the budget. The repo's rule now is that a raise has to move something out first (LESSONS.md, "A size budget raised whenever a change reaches it bounds nothing"). #5720 and #5795 made room the same way. So please don't raise it. Instead, make the settings list load only when it is needed: for example, put drawPagesSettings in a small script that is loaded when Settings › Plugins is opened, the way #5720 loads About's licenses dialog. Or cut something of the same size from the core. Only the sidebar filter (a few lines in load()) has to stay in the core.

2. Drop the head row's sub-line "Shown in the sidebar. A hidden page's plugin stays on, …" and its four translations. The Show/Hide segments explain themselves, and the GUI avoids secondary descriptions. This also gives back a few hundred bytes towards 1.

Once 1 and 2 are pushed to the branch, I'll run it again and land it with Co-authored-by: Beyfish. On the collaborator request: granting access is the owner's call. I've passed it on to him as written.

yetone avatar Nov 09 '26 12:11 yetone

Thanks — both points done, pushed to Beyfish:feat/plugin-page-visibility (now 5886b9e on cd0ba05).

1. Core budget back under, no raise. drawPagesSettings moved out of pluginpages.js into internal/gui/assets/pluginpagesettings.js, loaded the #5720 way: import("./pluginpagesettings.js") when pluginpages.js draws them, so the list is fetched only when Settings › Plugins is drawn. pluginpagesettings.js is not in index.html's <script> list, so it does not count toward the core budget; it is in old-webkit.test.cjs's lazy-file allowlist (comment updated) and is embedded like every other asset.

Only the sidebar filter stays in the core: in load(), const hidden = new Set(state.settings?.pluginPagesHidden || []); list = list.filter((e) => !hidden.has(e.key)); — the few lines you called out. titled() was only used by settings; its logic lives in the lazy file now as pagesTitled(e) (same expression over locale).

To close the last gap without raising the budget I trimmed only bytes in the same files this change touched — no unrelated behavior changed. pluginpages.js's header now points at plugin-runtime.md (which documents the sandbox/panels/actions in full) plus the lazy-file note; app.js code is untouched by this commit.

Result: core 1,533,713 of budget 1,533,802 (was 1,535,371 on the branch, 1,569 over — same numbers you got). TestCoreScriptBudget passes; the core_budget_test.go budget value is untouched.

2. Sub-line dropped. The head row's sub-line "Shown in the sidebar. A hidden page's plugin stays on, ..." is gone from pluginpagesettings.js, and its four translations (zh / zh-TW / ja / de) are removed from i18n.js. The head row still names the section (Plugin pages) and each row carries the Show/Hide segs.

Verification on 5886b9e:

  • go test -tags nogui -run TestCoreScriptBudget ./internal/gui/: PASS.
  • go test -tags nogui ./internal/gui/ ./internal/settings/ ./internal/settingsapi/ ./internal/cli/: settings, settingsapi, cli pass; 8 pre-existing gui failures on this machine (confirmed identical on a clean tree with changes stashed: %AppData%-dependent lody tests, proxy 502, Kimi agent row, update relaunch).
  • node --test plugin-page-hidden.test.cjs (alone): 2/2 pass, both engines. Run together with the other two suites at --test-concurrency=1, a webkit titlebar CORS flake appears on this machine; standalone it passes.
  • i18n-keys.test.cjs + menu-scroll.test.cjs at --test-concurrency=1: 28/28 pass.
  • old-webkit.test.cjs: fails the same way on this machine with the changes stashed — pre-existing here, not in your test set for this issue.

Ready for your re-run whenever you want to land it with Co-authored-by: Beyfish.

Beyfish avatar Nov 09 '26 13:11 Beyfish

P.S. (also via Discord #feedback): if convenient, could the owner consider adding @Beyfish as a collaborator, so future changes like this one can go through the normal PR review path? Happy to keep contributing either way — plugin issues/PRs merged so far include plugins#837, plugins#841, and this #5685 branch.

Beyfish avatar Nov 09 '26 13:11 Beyfish

Gentle ping — no rush. I noticed main has moved a lot since the review (my branch is now 718 commits behind, and the core budget is 1,263,333), and 22f2759d added Settings › General › Sidebar pages. From navpages.js / navHides() it looks like plugin page tabs also carry data-view, so that broader setting may already cover the use case in #5685.

If so, please feel free to skip 5886b9e or close this issue — I don't want to add review cost to a stale branch. If you'd still like the plugin-specific variant, I can rebase onto current main and adapt it to the new core split.

One small thing I can help verify: plugin tabs are added asynchronously by pluginpages.load(), so renderNavPages() / navHides() may need a refresh after load to keep a previously hidden plugin tab hidden and to show it in the picker. I can prepare a tiny regression test / patch on my fork if useful.

Separately, on the collaborator note: what would you like to see before considering access? Happy to keep using the issue → fork → Co-authored-by path in the meantime.

(Going forward I'll keep all communication here on the issue — no more Discord pings.)

Beyfish avatar Nov 12 '26 08:11 Beyfish

收尾:这个需求上游已经实现了,我把自己的分支提案撤回,本条就关了。

官方在 22f2759d(Settings › General › Sidebar pages)加了侧边栏页面显隐的多选菜单,我在 v0.1.3901 上确认可用,需求已达成。感谢 @yetone 对 5e672cf 的逐行 review —— 按那两点意见改出了 5886b9e(设置列表改成用时才加载、核心体积回到线下不抬预算,并删掉副标题与四语译文)。

既然上游已有更通用的做法,我不再把 Beyfish:feat/plugin-page-visibility 开成上游 PR,也不再申请协作者权限,免得两套开关打对台、给维护者增加 review 成本。这条以「已完成」关闭(是办成了,只是用官方那版办成的,不是合并了我的代码)。

Beyfish avatar Nov 12 '26 13:11 Beyfish