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
@@ -0,0 +1,112 @@
|
||||
// App runs the round trip's checks where go test does not reach, and the
|
||||
// SQLite plugin's: in an app on a phone, whose modules are their Swift on
|
||||
// iOS and their Kotlin on Android. It logs each check, then "roundtrip: PASS" or "roundtrip:
|
||||
// FAIL", which CI waits for in the system's log:
|
||||
//
|
||||
// go run ./cmd/mygo build -platform android/arm64 native/internal/roundtrip/app
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"github.com/egoist/mygo"
|
||||
"github.com/egoist/mygo/native/internal/roundtrip/check"
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func main() {
|
||||
result := "running"
|
||||
mygo.App.WhenReady(func() {
|
||||
var w *mygo.Window
|
||||
w = mygo.NewWindow(mygo.WindowOptions{Title: "Round trip", Content: ui.View(func(c *ui.Context) {
|
||||
ui.Column(c).Fill().Padding(24).Children(func() {
|
||||
ui.Text(c, "roundtrip: "+result).FontSize(20)
|
||||
})
|
||||
})})
|
||||
go func() {
|
||||
failed := run()
|
||||
mygo.RunOnMain(func() {
|
||||
result = map[bool]string{true: "FAIL", false: "PASS"}[failed]
|
||||
w.Invalidate()
|
||||
})
|
||||
log.Printf("roundtrip: %s", map[bool]string{true: "FAIL", false: "PASS"}[failed])
|
||||
}()
|
||||
})
|
||||
if err := mygo.App.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// run runs the checks, each on a goroutine of its own, as a test is, and
|
||||
// reports whether one failed.
|
||||
func run() bool {
|
||||
failed := false
|
||||
checks := append(check.All, struct {
|
||||
Name string
|
||||
Run func(check.T)
|
||||
}{"SQLite", checkSQLite})
|
||||
for _, c := range checks {
|
||||
t := &tester{name: c.Name}
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.failed = true
|
||||
t.log(fmt.Sprint("panic: ", r))
|
||||
}
|
||||
}()
|
||||
c.Run(t)
|
||||
}()
|
||||
<-done
|
||||
for i := len(t.cleanups) - 1; i >= 0; i-- {
|
||||
t.cleanups[i]()
|
||||
}
|
||||
switch {
|
||||
case t.failed:
|
||||
failed = true
|
||||
log.Printf("roundtrip: --- FAIL: %s", c.Name)
|
||||
case t.skipped:
|
||||
// A check that skips here fails: the app is for where the module
|
||||
// runs.
|
||||
failed = true
|
||||
log.Printf("roundtrip: --- SKIP: %s", c.Name)
|
||||
default:
|
||||
log.Printf("roundtrip: --- ok: %s", c.Name)
|
||||
}
|
||||
}
|
||||
return failed
|
||||
}
|
||||
|
||||
// tester is a check's T: Fatal and Skip end its goroutine, as testing.T's
|
||||
// do.
|
||||
type tester struct {
|
||||
name string
|
||||
failed, skipped bool
|
||||
cleanups []func()
|
||||
}
|
||||
|
||||
func (t *tester) Helper() {}
|
||||
|
||||
func (t *tester) log(msg string) { log.Printf("roundtrip: %s: %s", t.name, msg) }
|
||||
|
||||
func (t *tester) Fatal(args ...any) {
|
||||
t.failed = true
|
||||
t.log(fmt.Sprint(args...))
|
||||
runtime.Goexit()
|
||||
}
|
||||
|
||||
func (t *tester) Fatalf(format string, args ...any) { t.Fatal(fmt.Sprintf(format, args...)) }
|
||||
|
||||
func (t *tester) Skip(args ...any) {
|
||||
t.skipped = true
|
||||
t.log(fmt.Sprint(args...))
|
||||
runtime.Goexit()
|
||||
}
|
||||
|
||||
func (t *tester) Context() context.Context { return context.Background() }
|
||||
|
||||
func (t *tester) Cleanup(f func()) { t.cleanups = append(t.cleanups, f) }
|
||||
Reference in new issue
Block a user