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

+149
View File
@@ -0,0 +1,149 @@
package webview2
import (
"os"
"path/filepath"
"strings"
"testing"
)
func touch(t *testing.T, path string) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, nil, 0o644); err != nil {
t.Fatal(err)
}
}
// runtimeDir makes a runtime's directory, with what the loader looks for.
func runtimeDir(t *testing.T, version string) string {
dir := filepath.Join(t.TempDir(), version)
touch(t, filepath.Join(dir, browserExe))
touch(t, filepath.Join(dir, clientDir, archDir(), clientDLL))
return dir
}
func TestClientDLL(t *testing.T) {
dir := runtimeDir(t, "154.0.4258.62")
if got, want := ClientDLL(dir), filepath.Join(dir, clientDir, archDir(), clientDLL); got != want {
t.Errorf("ClientDLL of a runtime = %q, want %q", got, want)
}
// The Edge browser's layout: the library without the runtime's browser
// process, whose environments fail with ERROR_NOT_SUPPORTED.
edge := t.TempDir()
touch(t, filepath.Join(edge, clientDir, archDir(), clientDLL))
if got := ClientDLL(edge); got != "" {
t.Errorf("ClientDLL of the library alone = %q, want none", got)
}
browser := t.TempDir()
touch(t, filepath.Join(browser, browserExe))
if got := ClientDLL(browser); got != "" {
t.Errorf("ClientDLL of the browser alone = %q, want none", got)
}
other := t.TempDir()
touch(t, filepath.Join(other, browserExe))
touch(t, filepath.Join(other, clientDir, "other", clientDLL))
if got := ClientDLL(other); got != "" {
t.Errorf("ClientDLL of another architecture's runtime = %q, want none", got)
}
}
func TestFind(t *testing.T) {
key := func(channel string) string { return `SOFTWARE\Microsoft\EdgeUpdate\ClientState\` + channel }
registry := func(values map[bool]map[string]string) func(bool, string, string) string {
return func(machine bool, path, name string) string {
if name != clientDir {
return ""
}
return values[machine][path]
}
}
older, newer := runtimeDir(t, "153.0.1.2"), runtimeDir(t, "154.0.4258.62")
beta := runtimeDir(t, "155.0.1.1")
gone := filepath.Join(t.TempDir(), "154.0.4258.62")
for _, tc := range []struct {
name string
fixed string
values map[bool]map[string]string
dir string
err string
}{
{name: "none", err: "not installed"},
{
name: "machine",
values: map[bool]map[string]string{true: {key(channels[0]): newer}},
dir: newer,
},
{
name: "newest of a channel",
values: map[bool]map[string]string{
true: {key(channels[0]): older},
false: {key(channels[0]): newer},
},
dir: newer,
},
{
name: "stable before beta",
values: map[bool]map[string]string{
true: {key(channels[0]): older, key(channels[1]): beta},
},
dir: older,
},
{
// EdgeUpdate keeps the record of a runtime whose files are gone.
name: "stale",
values: map[bool]map[string]string{true: {key(channels[0]): gone}},
err: gone,
},
{
name: "stale stable, beta installed",
values: map[bool]map[string]string{
true: {key(channels[0]): gone, key(channels[1]): beta},
},
dir: beta,
},
{name: "fixed", fixed: older, dir: older},
{
name: "fixed without a runtime",
fixed: gone,
values: map[bool]map[string]string{true: {key(channels[0]): newer}},
err: "WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
},
} {
t.Run(tc.name, func(t *testing.T) {
dir, fixed, err := find(tc.fixed, registry(tc.values))
if tc.err != "" {
if err == nil || !strings.Contains(err.Error(), tc.err) {
t.Fatalf("find = %q, %v; want an error naming %q", dir, err, tc.err)
}
return
}
if err != nil || dir != tc.dir || fixed != (tc.fixed != "") {
t.Errorf("find = %q, %v, %v; want %q, %v", dir, fixed, err, tc.dir, tc.fixed != "")
}
})
}
}
func TestCompareVersions(t *testing.T) {
for _, tc := range []struct {
a, b string
want int
}{
{"154.0.4258.62", "154.0.4258.62", 0},
{"155.0.1.1", "154.9.9.9", 1},
{"154.0.4258.62", "154.0.4258.100", -1},
{"154.0", "154.0.1", -1},
{"not-a-version", "1.0.0.0", -1},
} {
if got := compareVersions(parseVersion(tc.a), parseVersion(tc.b)); got != tc.want {
t.Errorf("compareVersions(%q, %q) = %d, want %d", tc.a, tc.b, got, tc.want)
}
}
}