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
+128
@@ -0,0 +1,128 @@
|
||||
//go:build !mygo_noinspector
|
||||
|
||||
package ui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A window comes back from what it wrote down: scroll offsets, what widgets keep,
|
||||
// and where a router is.
|
||||
func TestDevStateRoundTrip(t *testing.T) {
|
||||
defer func(a func(*engine, *state), b func(*state, any, any), c func(*Router, *node)) {
|
||||
restoreElement, restoreLocal, noteRouter = a, b, c
|
||||
}(restoreElement, restoreLocal, noteRouter)
|
||||
restoreElement, restoreLocal, noteRouter = keptElementFor, keptLocalFor, noteDevRouter
|
||||
|
||||
type sheet struct {
|
||||
open bool
|
||||
count int
|
||||
}
|
||||
show := false
|
||||
view := func(r *Router, y *float32, s **sheet) func(*context) {
|
||||
return func(c *context) {
|
||||
if !show {
|
||||
return // until the window is ready to take it back
|
||||
}
|
||||
e := coreScroll(c).Fill().Key("list")
|
||||
*s = coreLocal(e, "sheet", func() sheet { return sheet{count: 1} })
|
||||
e.Children(func() {
|
||||
coreBox(c).Height(1000).Shrink(0)
|
||||
*y = float32(e.st.scrollY)
|
||||
r.coreView(c, func(rt *Route) { coreBox(c).Height(20) })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
r := NewRouter("/a")
|
||||
var y float32
|
||||
var s *sheet
|
||||
first := coreNewTester(view(r, &y, &s), 200, 200)
|
||||
first.rt.dev = &devState{routers: map[uint64]*Router{}}
|
||||
show = true
|
||||
first.Frame()
|
||||
r.Push("/a/b?x=1")
|
||||
s.open, s.count = true, 7
|
||||
first.Scroll(100, 100, 0, 300)
|
||||
first.Frame()
|
||||
first.Frame()
|
||||
if y == 0 {
|
||||
t.Fatal("it didn't scroll")
|
||||
}
|
||||
data := first.rt.keptNow()
|
||||
|
||||
var kept keptWindow
|
||||
if err := json.Unmarshal(data, &kept); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r2 := NewRouter("/a")
|
||||
var y2 float32
|
||||
var s2 *sheet
|
||||
show = false
|
||||
second := coreNewTester(view(r2, &y2, &s2), 200, 200)
|
||||
second.rt.dev = &devState{kept: &kept, routers: map[uint64]*Router{}}
|
||||
show = true
|
||||
second.Frame()
|
||||
second.Frame()
|
||||
if y2 != y {
|
||||
t.Errorf("scroll: %v, want %v", y2, y)
|
||||
}
|
||||
if s2 == nil || !s2.open || s2.count != 7 {
|
||||
t.Errorf("local: %+v", s2)
|
||||
}
|
||||
if r2.Path() != "/a/b" || !r2.CanGoBack() {
|
||||
t.Errorf("router: at %s", r2.Path())
|
||||
}
|
||||
}
|
||||
|
||||
// A route the change of the code removed leaves no blank page: the router starts
|
||||
// where it would have.
|
||||
func TestDevStateRouteGone(t *testing.T) {
|
||||
defer func(a func(*Router, *node), b func(*Router, *node)) { noteRouter, routerBuilt = a, b }(noteRouter, routerBuilt)
|
||||
noteRouter, routerBuilt = noteDevRouter, devRouterBuilt
|
||||
show := false
|
||||
r := NewRouter("/home")
|
||||
tt := coreNewTester(func(c *context) {
|
||||
if !show {
|
||||
return
|
||||
}
|
||||
r.coreView(c, func(rt *Route) {
|
||||
if rt.Match("/home") {
|
||||
coreText(c, "home")
|
||||
}
|
||||
})
|
||||
}, 200, 200)
|
||||
tt.rt.dev = &devState{routers: map[uint64]*Router{}}
|
||||
show = true
|
||||
// Every router's element has one ID in this view: the kept state names it once built.
|
||||
tt.Frame()
|
||||
var id uint64
|
||||
for k := range tt.rt.dev.routers {
|
||||
id = k
|
||||
}
|
||||
tt.rt.dev.routers = map[uint64]*Router{}
|
||||
tt.rt.dev.kept = &keptWindow{Routers: map[string]*keptRouter{
|
||||
strconv.FormatUint(id, 10): {Locs: []string{"/removed"}},
|
||||
}}
|
||||
r2 := NewRouter("/home")
|
||||
r = r2
|
||||
tt.Frame()
|
||||
tt.Frame()
|
||||
if r2.Path() != "/home" {
|
||||
t.Errorf("at %s", r2.Path())
|
||||
}
|
||||
if !tt.HasText("home") {
|
||||
t.Errorf("shows %q", tt.Texts())
|
||||
}
|
||||
}
|
||||
|
||||
// Without mygo dev, nothing of it runs.
|
||||
func TestDevStateOff(t *testing.T) {
|
||||
h := windowHost{rt: &engine{}}
|
||||
attachDevState(&h)
|
||||
if h.rt.dev != nil {
|
||||
t.Error("attached")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user