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

+128
View File
@@ -0,0 +1,128 @@
package gl
import (
"errors"
"fmt"
"github.com/ebitengine/purego"
)
// EGL's functions, which make the contexts of OpenGL ES and the surfaces
// of the windows they draw into, on Android.
var (
eglGetDisplay func(id uintptr) uintptr
eglInitialize func(display uintptr, major, minor *int32) uint32
eglChooseConfig func(display uintptr, attribs *int32, configs *uintptr, size int32, n *int32) uint32
eglCreateContext func(display, config, share uintptr, attribs *int32) uintptr
eglCreateWindowSurface func(display, config, window uintptr, attribs *int32) uintptr
eglMakeCurrent func(display, draw, read, context uintptr) uint32
eglSwapBuffers func(display, surface uintptr) uint32
eglDestroySurface func(display, surface uintptr) uint32
eglDestroyContext func(display, context uintptr) uint32
eglGetCurrentContext func() uintptr
eglGetError func() int32
)
const (
eglNone = 0x3038
eglRenderableType = 0x3040
eglOpenGLES3Bit = 0x40
eglSurfaceType = 0x3033
eglWindowBit = 0x4
eglRedSize = 0x3024
eglGreenSize = 0x3023
eglBlueSize = 0x3022
eglAlphaSize = 0x3021
eglContextVersion = 0x3098
)
func loadEGL() error {
lib, err := purego.Dlopen("libEGL.so", purego.RTLD_NOW|purego.RTLD_GLOBAL)
if err != nil {
return fmt.Errorf("gl: cannot load libEGL: %w", err)
}
for name, f := range map[string]any{
"eglGetDisplay": &eglGetDisplay, "eglInitialize": &eglInitialize, "eglChooseConfig": &eglChooseConfig,
"eglCreateContext": &eglCreateContext, "eglCreateWindowSurface": &eglCreateWindowSurface,
"eglMakeCurrent": &eglMakeCurrent, "eglSwapBuffers": &eglSwapBuffers, "eglDestroySurface": &eglDestroySurface,
"eglDestroyContext": &eglDestroyContext, "eglGetCurrentContext": &eglGetCurrentContext, "eglGetError": &eglGetError,
} {
sym, err := purego.Dlsym(lib, name)
if err != nil || sym == 0 {
return fmt.Errorf("gl: libEGL lacks %s", name)
}
purego.RegisterFunc(f, sym)
}
return nil
}
// Window is a window's surface (an ANativeWindow) and the context of
// OpenGL ES 3 that draws into it.
type Window struct {
display, context, surface uintptr
}
// NewWindow makes a context and a surface for an ANativeWindow, the
// context current.
func NewWindow(native uintptr) (*Window, error) {
if native == 0 {
return nil, errors.New("gl: no window")
}
if err := load(); err != nil {
return nil, err
}
w := &Window{display: eglGetDisplay(0)}
if w.display == 0 || eglInitialize(w.display, nil, nil) == 0 {
return nil, fmt.Errorf("gl: EGL has no display (%#x)", eglGetError())
}
attribs := []int32{eglRenderableType, eglOpenGLES3Bit, eglSurfaceType, eglWindowBit,
eglRedSize, 8, eglGreenSize, 8, eglBlueSize, 8, eglAlphaSize, 8, eglNone}
var config uintptr
var n int32
if eglChooseConfig(w.display, &attribs[0], &config, 1, &n) == 0 || n == 0 {
return nil, fmt.Errorf("gl: EGL has no configuration of OpenGL ES 3 (%#x)", eglGetError())
}
ctxAttribs := []int32{eglContextVersion, 3, eglNone}
if w.context = eglCreateContext(w.display, config, 0, &ctxAttribs[0]); w.context == 0 {
return nil, fmt.Errorf("gl: EGL cannot make a context (%#x)", eglGetError())
}
if w.surface = eglCreateWindowSurface(w.display, config, native, nil); w.surface == 0 {
eglDestroyContext(w.display, w.context)
return nil, fmt.Errorf("gl: EGL cannot make a window's surface (%#x)", eglGetError())
}
if !w.MakeCurrent() {
w.Release()
return nil, fmt.Errorf("gl: EGL cannot make the context current (%#x)", eglGetError())
}
return w, nil
}
// MakeCurrent makes the window's context current on this thread, drawing
// into its surface.
func (w *Window) MakeCurrent() bool {
return eglMakeCurrent(w.display, w.surface, w.surface, w.context) != 0
}
// Swap shows the frame drawn into the surface.
func (w *Window) Swap() error {
if eglSwapBuffers(w.display, w.surface) == 0 {
return fmt.Errorf("gl: EGL cannot show the frame (%#x)", eglGetError())
}
return nil
}
// Release lets go of the surface and the context; the ANativeWindow stays
// its owner's.
func (w *Window) Release() {
if w.display == 0 {
return
}
eglMakeCurrent(w.display, 0, 0, 0)
if w.surface != 0 {
eglDestroySurface(w.display, w.surface)
}
if w.context != 0 {
eglDestroyContext(w.display, w.context)
}
*w = Window{}
}