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

+96
View File
@@ -0,0 +1,96 @@
//go:build windows && (amd64 || arm64)
package windows
import (
"errors"
"fmt"
"syscall"
"unsafe"
"github.com/egoist/mygo/internal/platform"
)
// secrets keeps secrets as generic credentials of the Credential Manager,
// as keytar does: the target is "service/account", the user name the
// account, and they persist like keytar's, roaming with the user's profile
// on a domain. The system encrypts them for the user (DPAPI). The
// functions may be called from any thread.
type secrets struct{}
var (
procCredWriteW = advapi32.NewProc("CredWriteW")
procCredReadW = advapi32.NewProc("CredReadW")
procCredDeleteW = advapi32.NewProc("CredDeleteW")
procCredFree = advapi32.NewProc("CredFree")
)
const (
credTypeGeneric = 1
credPersistEnterprise = 3
errorNotFound = syscall.Errno(1168)
)
// credential is CREDENTIALW.
type credential struct {
Flags uint32
Type uint32
TargetName *uint16
Comment *uint16
LastWritten [2]uint32 // FILETIME
CredentialBlobSize uint32
CredentialBlob *byte
Persist uint32
AttributeCount uint32
Attributes uintptr
TargetAlias *uint16
UserName *uint16
}
func credTarget(service, account string) *uint16 { return u16(service + "/" + account) }
func credErr(op string, err error) error {
if errors.Is(err, errorNotFound) {
return platform.ErrSecretNotFound
}
return fmt.Errorf("credential manager: %s: %w", op, err)
}
func (secrets) SetSecret(service, account string, secret []byte) error {
c := credential{
Type: credTypeGeneric,
TargetName: credTarget(service, account),
Persist: credPersistEnterprise,
UserName: u16(account),
CredentialBlobSize: uint32(len(secret)),
}
if len(secret) > 0 {
c.CredentialBlob = &secret[0]
}
if r, _, err := procCredWriteW.Call(uintptr(unsafe.Pointer(&c)), 0); r == 0 {
return credErr("write", err)
}
return nil
}
func (secrets) Secret(service, account string) ([]byte, error) {
var p uintptr
if r, _, err := procCredReadW.Call(uintptr(unsafe.Pointer(credTarget(service, account))), credTypeGeneric, 0, uintptr(unsafe.Pointer(&p))); r == 0 {
return nil, credErr("read", err)
}
defer procCredFree.Call(p)
c := (*credential)(native(p))
if c.CredentialBlobSize == 0 || c.CredentialBlob == nil {
return []byte{}, nil
}
return append([]byte(nil), unsafe.Slice(c.CredentialBlob, c.CredentialBlobSize)...), nil
}
func (secrets) DeleteSecret(service, account string) error {
if r, _, err := procCredDeleteW.Call(uintptr(unsafe.Pointer(credTarget(service, account))), credTypeGeneric, 0); r == 0 {
if err := credErr("delete", err); !errors.Is(err, platform.ErrSecretNotFound) {
return err
}
}
return nil
}