feat: port the client to MyGo native UI (0.3.0)

Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
This commit is contained in:
OpenChamber committed 2026-11-18 13:22:59 +08:00
1 parent 2fb4a8ea79
commit 6c0ee61750
2538 files changed
+675779 -4792

No files matched your search

+98
View File
@@ -0,0 +1,98 @@
package updater
import (
"context"
"errors"
"testing"
"time"
)
func activateAvailabilityHarness(t *testing.T) *harness {
t.Helper()
h := newHarness(t, Options{})
active.Store(h.u)
t.Cleanup(func() { active.Store(nil) })
return h
}
func TestAvailableVersionChangesNotify(t *testing.T) {
h := activateAvailabilityHarness(t)
if AvailableVersion() != "" {
t.Fatal("a new updater already has an available version")
}
originalNow := now
now = func() time.Time { return time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) }
t.Cleanup(func() { now = originalNow })
changes := make(chan string, 8)
off := OnChange(func() { changes <- AvailableVersion() })
defer off()
wantChange := func(want string) {
t.Helper()
select {
case got := <-changes:
if got != want {
t.Fatalf("available version = %q, want %q", got, want)
}
case <-time.After(5 * time.Second):
t.Fatal("availability change was not reported")
}
}
h.u.checked(nil, "2.0.0", false)
wantChange("2.0.0")
h.u.checked(errors.New("offline"), "", false)
wantChange("")
h.u.checked(nil, "2.0.0", false)
wantChange("2.0.0") // LastCheck is unchanged; availability must still notify.
h.u.checked(nil, "", false)
wantChange("")
}
func TestAvailableVersionFollowsSkipAndLater(t *testing.T) {
h := activateAvailabilityHarness(t)
h.result = func(context.Context) (*release, error) { return newRelease("2.0.0", nil), nil }
done := h.begin(true)
s := h.shown()
v := waitView(t, s, "A new version of")
if AvailableVersion() != "2.0.0" {
t.Fatal("a detected update did not expose its version")
}
s.Respond(v.Prompt, actionSkip, false)
waitDone(t, done)
if AvailableVersion() != "" {
t.Fatal("a skipped update remains available")
}
waitDone(t, h.begin(false))
h.noWindow()
if AvailableVersion() != "" {
t.Fatal("the automatic check exposed a skipped update")
}
h.result = func(context.Context) (*release, error) { return newRelease("3.0.0", nil), nil }
done = h.begin(false)
s = h.shown()
v = waitView(t, s, "A new version of")
s.Respond(v.Prompt, actionLater, false)
waitDone(t, done)
if AvailableVersion() != "3.0.0" {
t.Fatal("reminding later lost the detected version")
}
h.result = func(context.Context) (*release, error) { return nil, nil }
waitDone(t, h.begin(false))
if AvailableVersion() != "" {
t.Fatal("an up-to-date result retained the previous version")
}
}
func TestAvailableVersionRetainedAfterInstallation(t *testing.T) {
h := activateAvailabilityHarness(t)
h.result = func(context.Context) (*release, error) { return newRelease("2.0.0", nil), nil }
done := h.begin(true)
s := h.shown()
v := waitView(t, s, "A new version of")
s.Respond(v.Prompt, actionInstall, false)
v = waitView(t, s, "Ready to Relaunch")
s.Respond(v.Prompt, actionLater, false)
waitDone(t, done)
if AvailableVersion() != "2.0.0" {
t.Fatal("the installed update needs to remain discoverable until relaunch")
}
}