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:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
Vendored
+116
@@ -0,0 +1,116 @@
|
||||
//go:build !js
|
||||
|
||||
package mygo
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestURLSchemes(t *testing.T) {
|
||||
defer func(s string) { packageURLSchemes = s }(packageURLSchemes)
|
||||
packageURLSchemes = "myapp,Other"
|
||||
if err := App.RegisterURLScheme("Run.Time+x"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer App.UnregisterURLScheme("run.time+x")
|
||||
for _, bad := range []string{"", "1abc", "a b", "a:b"} {
|
||||
if err := App.RegisterURLScheme(bad); err == nil {
|
||||
t.Errorf("RegisterURLScheme(%q) succeeded", bad)
|
||||
}
|
||||
}
|
||||
id := appID()
|
||||
if got := fb.URLSchemes["run.time+x"]; got != id+" "+App.Name() {
|
||||
t.Errorf("registered %q", got)
|
||||
}
|
||||
if !App.IsURLSchemeRegistered("run.time+x") || App.IsURLSchemeRegistered("myapp") {
|
||||
t.Error("IsURLSchemeRegistered")
|
||||
}
|
||||
|
||||
args := []string{"--flag", "MyApp://a", "other:b", "run.time+x://c", "https://example.com", `C:\file.txt`, "nope://d", "myapp"}
|
||||
if got, want := urlArgs(args), []string{"MyApp://a", "other:b", "run.time+x://c"}; !slices.Equal(got, want) {
|
||||
t.Errorf("urlArgs = %q, want %q", got, want)
|
||||
}
|
||||
var opened []string
|
||||
off := App.OnOpenURL(func(u string) { opened = append(opened, u) })
|
||||
onMain(func() { deliverArgs(args, "") })
|
||||
off()
|
||||
if len(opened) != 3 {
|
||||
t.Errorf("OnOpenURL got %q", opened)
|
||||
}
|
||||
|
||||
if err := App.UnregisterURLScheme("run.time+x"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if handlesScheme("run.time+x") || App.IsURLSchemeRegistered("run.time+x") {
|
||||
t.Error("the scheme is still handled after UnregisterURLScheme")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageInfo(t *testing.T) {
|
||||
defer func(n, v, id string) { packageName, packageVersion, packageIdentifier = n, v, id }(packageName, packageVersion, packageIdentifier)
|
||||
if _, ok := packageInfo(); ok {
|
||||
t.Fatal("the test binary is not packaged")
|
||||
}
|
||||
packageName, packageVersion, packageIdentifier = "My App", "1.2.3", "com.example.app"
|
||||
if info, ok := packageInfo(); !ok || info.Name != "My App" || info.Version != "1.2.3" || !App.IsPackaged() {
|
||||
t.Errorf("linked package info = %+v %v", info, ok)
|
||||
}
|
||||
if appID() != "com.example.app" {
|
||||
t.Errorf("handler id = %q", appID())
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenAtLogin(t *testing.T) {
|
||||
if App.OpenAtLogin() || App.WasOpenedAtLogin() {
|
||||
t.Fatal("the test binary does not start at login")
|
||||
}
|
||||
if err := App.SetOpenAtLogin(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !App.OpenAtLogin() || fb.LoginItem != appID()+" "+App.Name()+" "+loginArg {
|
||||
t.Errorf("login item = %q", fb.LoginItem)
|
||||
}
|
||||
if err := App.SetOpenAtLogin(false); err != nil || App.OpenAtLogin() {
|
||||
t.Errorf("SetOpenAtLogin(false): %v", err)
|
||||
}
|
||||
|
||||
args, ok := takeLoginArg([]string{"app", "-v", loginArg, "file.txt"})
|
||||
if !ok || !slices.Equal(args, []string{"app", "-v", "file.txt"}) {
|
||||
t.Errorf("takeLoginArg = %q, %v", args, ok)
|
||||
}
|
||||
if _, ok := takeLoginArg([]string{"app", "file.txt"}); ok {
|
||||
t.Error("takeLoginArg found the argument in a plain command line")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileArgs(t *testing.T) {
|
||||
defer func(s string) { packageFileExtensions = s }(packageFileExtensions)
|
||||
packageFileExtensions = "md,txt"
|
||||
dir := t.TempDir()
|
||||
for _, f := range []string{"a.md", "b.TXT", "c.png"} {
|
||||
if err := os.WriteFile(filepath.Join(dir, f), nil, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
fileURL := (&url.URL{Scheme: "file", Path: filepath.ToSlash(filepath.Join(dir, "b.TXT"))}).String()
|
||||
if runtime.GOOS == "windows" {
|
||||
fileURL = "file:///" + filepath.ToSlash(filepath.Join(dir, "b.TXT"))
|
||||
}
|
||||
got := fileArgs([]string{"--flag", "a.md", fileURL, "c.png", "missing.md", dir}, dir)
|
||||
want := []string{filepath.Join(dir, "a.md"), filepath.Join(dir, "b.TXT")}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("fileArgs = %q, want %q", got, want)
|
||||
}
|
||||
var opened []string
|
||||
off := App.OnOpenFile(func(p string) { opened = append(opened, p) })
|
||||
onMain(func() { deliverArgs([]string{"a.md"}, dir) })
|
||||
off()
|
||||
if len(opened) != 1 {
|
||||
t.Errorf("OnOpenFile got %q", opened)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user