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
+71
@@ -0,0 +1,71 @@
|
||||
package platform
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFitIcon(t *testing.T) {
|
||||
for _, c := range []struct{ w, h, box, ww, wh int }{
|
||||
{16, 16, 16, 16, 16},
|
||||
{64, 64, 32, 32, 32},
|
||||
{60, 40, 16, 16, 11}, // a 3:2 flag
|
||||
{40, 60, 16, 11, 16},
|
||||
{4, 3, 24, 24, 18},
|
||||
{200, 1, 16, 16, 1}, // never thinner than a pixel
|
||||
{0, 10, 16, 0, 0},
|
||||
} {
|
||||
if w, h := FitIcon(c.w, c.h, c.box); w != c.ww || h != c.wh {
|
||||
t.Errorf("FitIcon(%d, %d, %d) = %d, %d, want %d, %d", c.w, c.h, c.box, w, h, c.ww, c.wh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMenuIconNativeOnce(t *testing.T) {
|
||||
ic := &MenuIcon{PNG: []byte{1}}
|
||||
n := 0
|
||||
make := func() any { n++; return nil }
|
||||
ic.Native(make)
|
||||
ic.Native(make)
|
||||
if n != 1 {
|
||||
t.Errorf("made %d times, want once, a failure kept too", n)
|
||||
}
|
||||
}
|
||||
|
||||
// Apply keeps a snapshot a backend builds menus from later current.
|
||||
func TestMenuApply(t *testing.T) {
|
||||
icon := &MenuIcon{PNG: []byte{1}}
|
||||
m := &Menu{Items: []*MenuItem{
|
||||
{ID: 1, Label: "A"},
|
||||
{ID: 2, Label: "Sub", Type: MenuItemSubmenu, Submenu: &Menu{Items: []*MenuItem{
|
||||
{ID: 3, Label: "B", Type: MenuItemRadio},
|
||||
}}},
|
||||
}}
|
||||
old := m.Items[1].Submenu.Items[0]
|
||||
m.Apply(&MenuItem{ID: 3, Label: "B", Type: MenuItemRadio, Checked: true, Icon: icon})
|
||||
got := m.Items[1].Submenu.Items[0]
|
||||
if !got.Checked || got.Icon != icon {
|
||||
t.Errorf("item 3 = %+v, want checked with the icon", got)
|
||||
}
|
||||
if old.Checked {
|
||||
t.Error("Apply changed the item it replaced, which a menu being built may hold")
|
||||
}
|
||||
if m.Items[0].Label != "A" {
|
||||
t.Error("Apply changed another item")
|
||||
}
|
||||
(*Menu)(nil).Apply(got) // no menu, nothing to do
|
||||
}
|
||||
|
||||
// TestLabelWithSubtitleAndBadge checks the fallback of platforms that draw
|
||||
// neither the subtitle nor the badge on its own.
|
||||
func TestLabelWithSubtitleAndBadge(t *testing.T) {
|
||||
if got := (&MenuItem{Label: "Node"}).LabelWithBadge(); got != "Node" {
|
||||
t.Errorf("label without badge = %q", got)
|
||||
}
|
||||
if got := (&MenuItem{Label: "Node", Badge: "120 ms"}).LabelWithBadge(); got != "Node 120 ms" {
|
||||
t.Errorf("label with badge = %q", got)
|
||||
}
|
||||
if got := (&MenuItem{Label: "Node", Subtitle: "Hong Kong"}).LabelWithSubtitleAndBadge(); got != "Node — Hong Kong" {
|
||||
t.Errorf("label with subtitle = %q", got)
|
||||
}
|
||||
if got := (&MenuItem{Label: "Node", Subtitle: "Hong Kong", Badge: "120 ms"}).LabelWithSubtitleAndBadge(); got != "Node — Hong Kong 120 ms" {
|
||||
t.Errorf("label with subtitle and badge = %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user