Commit Graph
2 Commits
Author SHA1 Message Date
yetone ec97a4d7bb plugins: a dependency no plugin needs no longer fails another's install
CHENGJIAHEGOXIS on X (v0.1.4178, Windows) couldn't install GoAnyAPI from
Plugins: "agency-agents" failed with 从缓存复制到目标目录失败, and it was
on no plugin's row, so nothing could remove it.

Cause: every bun add/update/remove installs every dependency in
plugins/package.json again, and a failed `bun add` writes its package
there before exiting 1. agency-agents (a repository with no
package.json) was left by such an add; on Windows a file of its copy in
node_modules is held open, Bun fails "EBUSY: failed copying files from
cache to destination for package agency-agents", and so every later
install failed over a package nothing used.

Fix (internal/plugin/leftover.go, store.go):
- A package Bun says it couldn't install that no plugin is installed as
  (on the list, on or off, an add in flight, pi's agent) is taken out of
  package.json and node_modules and the command runs again: install()
  and runBun, so add, update, check and remove all get it.
- A failed install puts back the dependencies and bun.lock it found.
- An add whose own package went in while another listed plugin's
  failed succeeds; that plugin keeps its dependency.
- Remove and add's clean-ups drop the dependency by hand when
  bun remove fails.
- What is left from before is listed under Installed as "Not used by
  any plugin", each with a Remove (/api/plugins leftovers,
  POST /api/plugins/leftover; pmLeftovers in plugininstalled.js,
  imported when Plugins first draws), in every language.
- plugins.json there and unreadable: nothing is a leftover.
- Core script budget +51 for the one call left in plugins.js (reason in
  core_budget_test.go).

Run:
- mote-run: go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. go test ./internal/plugin (169s) and
  ./internal/provider (148s): ok.
- mica-run go test -count=1 ./internal/gui with the leftovers drawing
  moved into plugininstalled.js: ok (133s); main since touches none of
  internal/gui's core scripts, internal/plugin or plugins.go.
- win-run go test -run 'Leftover|FailedAdd|AnotherPlugin|RemoveTakes|
  BunFailed' ./internal/plugin on xiaomi-gpu: ok.
- Reproduced the EBUSY with Bun 1.4.2 on xiaomi-gpu (a file in
  node_modules/agency-agents held open, then bun add another package).
- Red on the old store.go: TestLeftoverDoesNotFailAnotherAdd,
  TestFailedAddLeavesNoDependency, TestAnotherPluginsFailureDoesNotFailAdd,
  TestRemoveTakesDependencyOutWhenBunFails.
- GUI: plugin-leftover.test.cjs 42/42 (chromium + webkit, en zh zh-TW
  ja de, 980/420px, with and without a plugin); old plugins.js: 21/21
  chromium red.
- mote-run, rebased on fdf42299e: plugin-leftover + i18n-keys 46/46;
  every other plugin*.test.cjs, old-webkit and i18n-en-no-cjk: 255 ok,
  reds only in old-webkit (#6030, #5919), plugin-move-unserved (#4392),
  plugin-option-placement (#6559) and plugin-page-foreign-error
  (#6117), each red the same on a clean origin/main fdf42299e checkout.

Not run: the full go test ./... and the whole GUI suite (mote over
its cores, mica running another session's full suite; one per machine); a real Windows
install through the magpie app.
2026-11-15 03:07:38 +08:00
yetone 65f745dd4c plugins: Installed is narrowed by Discover's kinds and origins
WJaunita45604 on X asked for the Installed tab to be filtered by
Discover's categories, and by whether a plugin is official, with
Discover's own categorisation. Installed now has the same strip and menu
as Discover:
- the kinds strip (All, Subscriptions, Middleware, Agents, Tools, Pages),
  each with how many are installed;
- the Origin menu (magpie community, other authors, unofficial on GitHub),
  without Discover's "Not installed only".

browseBar's strip and Origin button are split out (kindStrip,
originButton) so both tabs draw the same component. The rest is in
plugininstalled.js, imported when Plugins first draws, as plugingrid.js
is (old-webkit lists it); until it is in, the list is drawn whole. What
is left in the core is 674 bytes, within its budget's room. A plugin Discover
lists is put where its card is (kindOf, srcOf). One it doesn't list (a
folder, an unlisted npm package) is put by what it is: middleware or
gateway, agent, tools only, a page, else a subscription; from GitHub,
@magpie-community, else other authors.

The strip shows only when two or more kinds are installed, and the menu
only when two or more origins are. A pick that leaves nothing says "No
plugin matches" with Show all. Installed keeps its pick across tabs and
Discover keeps its own. The list head grows when it wraps
(.pm-listhead.pm-bar), so a narrow row doesn't run under the list. There
are no new strings, no native select (the app menu), and no left-border
accents.

New plugin-installed-filter.test.cjs: seven installed plugins of every
kind and origin, two of them GitHub repos from fixtures/plugins-github-31.
It runs in every language, both engines, at 1100px and 420px.

Run (on mote, Playwright 1.62.0, chromium + webkit): the new test, 20 of
20. Red on origin/main 005178104 (no strip on Installed: waitFor
.pm-listhead .pm-kinds times out).

On mote, both engines: at base 077421733, go test -tags nogui
./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs,
old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and
the two the scroll buttons' commit fixes. Rebased on origin/main
6e03b746b with that commit: TestCoreScriptBudget ok with no raise;
add-sheet*, provider-env-paste, plugin-installed-filter,
plugin-api-prompt-key, plugin-password-prompt, the eight plugin files
red before, old-webkit, i18n-keys and the scroll files that commit
names: green but the reds below.
Reds that fail the same on origin/main 6e03b746b, run alone there:
old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved
(#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938),
plugin-page-foreign-error (#6117), plugin-option-placement (#6559),
rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de
375 (#5869). The whole GUI suite was not run: mote's and mica's loads
were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12).

Rebased on origin/main 1730c75b9, the pushed head (mote): go test -tags
nogui ./internal/gui ok; add-sheet*, provider-env-paste,
plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt,
i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.
a82bae2bd, landed on top since, changes the routing plugin, the
gateway and i18n.js keys of its own, none of these files; the core
measure at the pushed head is 1,267,635 of 1,268,961.
2026-11-14 00:16:51 +08:00