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

+79
View File
@@ -0,0 +1,79 @@
package markdown
import (
"slices"
"testing"
"github.com/egoist/mygo/ui"
)
// TestViewLinkMenu checks that Options.LinkMenu gives each link with a
// destination a context menu of its own, told which link it is, in View
// and in Stream, while the text around it, links to #a-heading, footnote
// references and a link still being written keep the menu of the
// Selectable container around the view.
func TestViewLinkMenu(t *testing.T) {
const src = "# Top\n\nIntro text.\n\nSee [plan.md](file:///proj/plan.md), [notes](notes.md) and [up](#top).[^1]\n\n[^1]: A note.\n\nNow [half](file:///pr"
linkMenu := []string{"Copy Path", "Reveal in Finder", "-", "Copy", "-", "Select All"}
outer := []string{"Quote", "-", "Copy", "-", "Select All"}
for _, stream := range []bool{false, true} {
var asked, copied []string
o := &Options{
ShareSelection: true,
Reveal: &Reveal{Unit: AtOnce},
LinkMenu: func(m *ui.Menu, url string) {
asked = append(asked, url)
if m.Item("Copy Path").Chosen() {
copied = append(copied, url)
}
m.Item("Reveal in Finder")
m.Separator()
m.EditItems()
},
}
tt := ui.NewTester(func(c *ui.Context) {
ui.Column(c).Fill().Padding(10).Selectable().ContextMenu(func(m *ui.Menu) {
m.Item("Quote")
m.Separator()
m.EditItems()
}).Children(func() {
if stream {
Stream(c, src, o)
} else {
View(c, src, o)
}
})
}, 600, 400)
for _, s := range []string{"plan.md", "notes"} {
if err := tt.RightClick(s); err != nil {
t.Fatal(err)
}
if !slices.Equal(tt.Menu(), linkMenu) {
t.Errorf("stream %v: menu of %q %q, want %q", stream, s, tt.Menu(), linkMenu)
}
if err := tt.ChooseMenuItem("Copy Path"); err != nil {
t.Fatal(err)
}
}
if want := []string{"file:///proj/plan.md", "notes.md"}; !slices.Equal(copied, want) {
t.Errorf("stream %v: Copy Path got %q, want %q", stream, copied, want)
}
for _, s := range []string{"Intro text.", "up", "[1]", "half"} {
if s == "half" && !stream {
continue // only Stream has a link still being written
}
if err := tt.RightClick(s); err != nil {
t.Fatal(err)
}
if !slices.Equal(tt.Menu(), outer) {
t.Errorf("stream %v: menu of %q %q, want %q", stream, s, tt.Menu(), outer)
}
tt.CloseMenu()
}
for _, url := range asked {
if url != "file:///proj/plan.md" && url != "notes.md" {
t.Errorf("stream %v: LinkMenu asked for %q", stream, url)
}
}
}
}