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

+132
View File
@@ -0,0 +1,132 @@
package diff
import (
"unicode"
"unicode/utf8"
)
// Range is a range of bytes, Start to End.
type Range struct{ Start, End int }
// Words compares two texts word by word, as review tools highlight what
// changed within lines: words (letters, digits and underscores), runs of
// whitespace and other characters one at a time. It returns the byte
// ranges of a and b that changed, joined across the whitespace between
// them, and how much of the two texts stayed the same, from 0 to 1, by
// their bytes.
func Words(a, b string) (ra, rb []Range, same float64) {
return tokens(a, b, wordTokens)
}
// Chars compares two texts character by character, as Words does by words.
func Chars(a, b string) (ra, rb []Range, same float64) {
return tokens(a, b, charTokens)
}
func tokens(a, b string, split func(string, []Range) []Range) (ra, rb []Range, same float64) {
ta, tb := split(a, nil), split(b, nil)
ids := make(map[string]int32, len(ta)+len(tb))
conv := func(s string, t []Range) []int32 {
out := make([]int32, len(t))
for i, r := range t {
v := s[r.Start:r.End]
id, ok := ids[v]
if !ok {
id = int32(len(ids))
ids[v] = id
}
out[i] = id
}
return out
}
ia, ib := conv(a, ta), conv(b, tb)
hunks := Ints(ia, ib)
changed := 0
for _, h := range hunks {
if h.A0 < h.A1 {
ra = join(ra, Range{ta[h.A0].Start, ta[h.A1-1].End}, a)
changed += ta[h.A1-1].End - ta[h.A0].Start
}
if h.B0 < h.B1 {
rb = join(rb, Range{tb[h.B0].Start, tb[h.B1-1].End}, b)
changed += tb[h.B1-1].End - tb[h.B0].Start
}
}
if total := len(a) + len(b); total > 0 {
same = 1 - float64(changed)/float64(total)
} else {
same = 1
}
return ra, rb, same
}
// join appends r to rs, merged with the last range when only whitespace
// is between them.
func join(rs []Range, r Range, s string) []Range {
if n := len(rs); n > 0 {
last := &rs[n-1]
gap := s[last.End:r.Start]
blank := true
for _, c := range gap {
if c == '\n' || !unicode.IsSpace(c) {
blank = false
break
}
}
if blank {
last.End = r.End
return rs
}
}
return append(rs, r)
}
func isWord(r rune) bool {
return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
}
func wordTokens(s string, out []Range) []Range {
for i := 0; i < len(s); {
r, n := utf8.DecodeRuneInString(s[i:])
j := i + n
switch {
case isWord(r):
for j < len(s) {
r, n := utf8.DecodeRuneInString(s[j:])
if !isWord(r) {
break
}
j += n
}
case r != '\n' && unicode.IsSpace(r):
for j < len(s) {
r, n := utf8.DecodeRuneInString(s[j:])
if r == '\n' || !unicode.IsSpace(r) {
break
}
j += n
}
}
out = append(out, Range{i, j})
i = j
}
return out
}
func charTokens(s string, out []Range) []Range {
for i := 0; i < len(s); {
_, n := utf8.DecodeRuneInString(s[i:])
// Combining marks stay with their base.
j := i + n
for j < len(s) {
r, n := utf8.DecodeRuneInString(s[j:])
if !unicode.Is(unicode.Mn, r) && !unicode.Is(unicode.Me, r) && r != 0x200d && !(r >= 0xfe00 && r <= 0xfe0f) {
break
}
j += n
}
out = append(out, Range{i, j})
i = j
}
return out
}