The Library's RTK page took ~3.9s to open and the Plugins page's Installed list ~2.2s, every time. - Installed named each plugin's subscriptions from plugin.Providers, the whole providers RPC: each plugin in turn fetching its vendor's model list. The page uses only the names, which plugin.Cached keeps without starting the host (refreshed in the background when a sign-in or the plugins change). It now reads those: 2.2s to 13ms with seven plugins. A plugin added a moment ago has no names yet, so its row no longer claims it "signs in to nothing magpie can use" until the plugins have answered (plugin.Answered, the row's named). - ReadRTK waited up to 3s for GitHub and the package manager; winget show refreshes its sources and takes ~7.7s, so every open waited the full 3s and #1025's "waiting for winget" tag never came from it. GitHub stays on the first read; the package manager is asked in the background, its answer kept 6 hours as before. 3.9s to 1.6s. - ReadRTK and SetRTK detected the agents twice per call; once now. wizzy-yang's PR head 12342aa3, which conflicted with main: plugins.go keeps main's clash rows (plugin.Clashes) with the names from Cached, idName filled from Cached too; plugins.js keeps main's middleware/agent and clash branches ahead of the PR's named one; providers.go keeps main's Told and Settle beside the PR's Answered. Run: see the next commit.
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package plugin
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// An empty providers list means "the plugins haven't been asked yet" or "they
|
|
// answered, and this plugin signs in to nothing", and only the second is what
|
|
// the Installed list may say out loud (#1112). Answered tells them apart.
|
|
func TestAnsweredSaysWhetherTheListIsThePluginsOwn(t *testing.T) {
|
|
sandbox(t)
|
|
|
|
// what is kept from before they were last asked: not the answer
|
|
UseCached(nil)
|
|
if Answered() {
|
|
t.Error("Answered = true with nothing asked: an empty list is not the plugins' answer")
|
|
}
|
|
provMu.Lock()
|
|
provGood, provTried = false, false
|
|
provMu.Unlock()
|
|
if Answered() {
|
|
t.Error("Answered = true after the list was forgotten, want false until the plugins answer")
|
|
}
|
|
|
|
// one asked about, and it has none: the answer is in, so a page may say so
|
|
UseCached([]Provider{})
|
|
provMu.Lock()
|
|
provGood, provTried = true, true
|
|
provMu.Unlock()
|
|
if !Answered() {
|
|
t.Error("Answered = false with an answer in hand, want true")
|
|
}
|
|
|
|
// asked, then the list forgotten again (a sign-in or the plugins changed)
|
|
forgetProviders()
|
|
if Answered() {
|
|
t.Error("Answered = true once the list was invalidated, want false until the plugins answer again")
|
|
}
|
|
}
|