After magpie writes Kimi's config.toml, every Kimi was told "reads its settings at start-up — restart open kimi sessions". That holds for the old Python kimi-cli (~/.kimi). Kimi Code 2.x (~/.kimi-code, npm @moonshot-ai/kimi-code) watches config.toml and reloads it, so an open session takes the new models at once; only its web and desktop app's model picker is read again when Settings › Providers is opened again. jiabubu picked from that stale picker and got "Model \"magpie/...\" is not configured in config.toml". The notice now follows KimiDir's legacy flag: kimi-cli keeps the restart advice word for word, and Kimi Code 2.x is told "reads this as it runs; in its web or desktop app, reopen Settings › Providers or reload the page to see new models". The same goes for Kimi in a WSL distro: wslKind gets an optional restartAt, which Kimi's kind uses to pick its notice from the distro's folder (a stopped distro reads as ~/.kimi-code, as kimiDir has it). Both new strings are in NOTICES and translated in zh, zh-TW, ja and de. Run (worktree at027360021+ this commit, through mote-run / wsl-run): - gofmt -l internal/agent: nothing. go vet ./internal/agent, GOOS=linux go vet -tags nogui ./internal/agent ./internal/gui, GOOS=windows go vet ./internal/agent ./internal/gui: ok. - go test -count=1 -timeout 45m ./internal/agent: ok (157s), including the new TestKimiNoticeByKind and TestEveryNoticeIsTranslated. - Broken by hand: with kimi.go and wsl.go reverted, TestKimiNoticeByKind fails for Kimi Code 2.x both here and in WSL (the restart advice). - GUI (wsl-run): agent-notice-lang in WebKit 11/11 and Chromium 11/11. i18n-keys 3 of 4; "a plugin's words are its own" fails on "Unmarked" (plugins/routing vs internal/usage/search_calls_test.go), red on main, #4524. - go test ./internal/gui (at0407d69e8+ this change) failed only in TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll, #4514) and real-window AppKit tests killed at their deadline on mote (#4125, #2645); the same five of them, run at clean origin/main027360021, fail the same way. Not tried: a real Kimi Code app showing this notice in magpie's GUI. Kimi Code 2.4.1's reload behaviour is from an earlier sandbox run.
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package agent
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
// Kimi Code 2.x reloads config.toml as it runs, and only its web and
|
||
// desktop app's model picker needs Settings › Providers opened again
|
||
// (jiabubu: the stale picker's pick was "not configured in config.toml"),
|
||
// so it isn't told to restart its sessions; kimi-cli, which reads the file
|
||
// at start-up, still is. On this machine and in a WSL distro.
|
||
func TestKimiNoticeByKind(t *testing.T) {
|
||
was := Running
|
||
Running = func(...string) bool { return true }
|
||
t.Cleanup(func() { Running = was })
|
||
t.Setenv("KIMI_SHARE_DIR", "")
|
||
t.Setenv("KIMI_CODE_HOME", "")
|
||
check := func(t *testing.T, where string, legacy bool, n string) {
|
||
t.Helper()
|
||
restart := strings.Contains(n, "restart open kimi sessions")
|
||
picker := strings.Contains(n, "Settings › Providers")
|
||
if legacy && (!restart || picker) || !legacy && (restart || !picker) {
|
||
t.Errorf("%s, kimi-cli %v: %q", where, legacy, n)
|
||
}
|
||
}
|
||
for _, c := range []struct {
|
||
dir string
|
||
legacy bool
|
||
}{{".kimi-code", false}, {".kimi", true}} {
|
||
home := syncHome(t)
|
||
os.MkdirAll(filepath.Join(home, c.dir), 0o755)
|
||
check(t, "here", c.legacy, kimi(home).Notice())
|
||
|
||
root := t.TempDir()
|
||
os.MkdirAll(filepath.Join(root, "home", "me", c.dir), 0o755)
|
||
k := wslKindOf("kimi")
|
||
_, has, versions := wslFinds(k)
|
||
d := distro{Name: "Ubuntu", Root: root, Home: "/home/me", Has: has, Versions: versions,
|
||
Gateway: "172.20.0.1", Mirrored: true, Running: true}
|
||
n := wslAgent(k, d).Notice()
|
||
if !strings.HasPrefix(n, "Kimi Code in WSL Ubuntu ") {
|
||
t.Errorf("WSL: %q", n)
|
||
}
|
||
check(t, "WSL", c.legacy, n)
|
||
}
|
||
}
|