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

+72
View File
@@ -0,0 +1,72 @@
package text
import (
"slices"
"syscall/js"
"testing"
"unicode/utf8"
)
// fakeCanvas has the canvas engine measure every character 10 DIPs wide,
// where no browser gives it a canvas, as Node.js.
func fakeCanvas(t *testing.T) {
g := js.Global()
if !g.Get("document").IsUndefined() || !g.Get("OffscreenCanvas").IsUndefined() {
return
}
measure := js.FuncOf(func(this js.Value, args []js.Value) any {
return map[string]any{
"width": 10 * utf8.RuneCountInString(args[0].String()),
"fontBoundingBoxAscent": 8,
"fontBoundingBoxDescent": 2,
"actualBoundingBoxAscent": 5,
}
})
getContext := js.FuncOf(func(this js.Value, args []js.Value) any {
ctx := g.Get("Object").New()
ctx.Set("measureText", measure)
return ctx
})
canvas := js.FuncOf(func(this js.Value, args []js.Value) any {
c := g.Get("Object").New()
c.Set("getContext", getContext)
return c
})
g.Set("OffscreenCanvas", canvas)
t.Cleanup(func() {
g.Delete("OffscreenCanvas")
canvas.Release()
getContext.Release()
measure.Release()
})
}
// The canvas engine breaks Korean between words (#1403).
func TestCanvasKeepAll(t *testing.T) {
fakeCanvas(t)
e := newCanvas()
ends := func(text, lang string, width float32, wholeWords bool) []int {
var out []int
for _, l := range e.shape([]rune(text), Style{Size: 16, Lang: lang}, nil, width, false, wholeWords) {
out = append(out, l.end)
}
return out
}
const text = "안녕하세요 반갑습니다 오늘은 날씨가 좋네요"
for _, c := range []struct {
text, lang string
wholeWords bool
want []int
}{
{text, "ko", false, []int{6, 12, 16, 20, 23}},
{text, "ko-KR", false, []int{6, 12, 16, 20, 23}},
{text, "en", false, []int{6, 12, 17, 22, 23}},
// A word longer than a line breaks within itself.
{"가나 다라마바사아자 차", "ko", false, []int{3, 8, 12}},
{"가나 다라마바사아자 차", "ko", true, []int{3, 11, 12}},
} {
if got := ends(c.text, c.lang, 50, c.wholeWords); !slices.Equal(got, c.want) {
t.Errorf("%q in %q, whole words %v: lines end at %v, want %v", c.text, c.lang, c.wholeWords, got, c.want)
}
}
}