Files
openchamber-android-native/third_party/mygo/plugins/terminal/library.go
T
OpenChamber 6c0ee61750 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.
2026-11-18 13:22:59 +08:00

57 lines
1.6 KiB
Go

package terminal
import (
_ "embed"
"fmt"
"runtime"
"sync"
"github.com/egoist/mygo/plugins/terminal/internal/library"
"github.com/egoist/mygo/plugins/terminal/internal/vt"
)
//go:generate go run ./internal/libbuild
// natives describes the builds of libghostty-vt this package binds, one
// per platform, which `mygo build` and `mygo dev` put into apps: the CLI
// reads this file from the package's directory.
//
//go:embed mygo-plugin.json
var natives []byte
var load struct {
once sync.Once
path string
err error
}
// Load loads libghostty-vt, once, from LibraryPath. New calls it; call it
// earlier to report a missing library before showing a terminal.
func Load() error {
load.once.Do(func() {
if !vt.Supported {
load.err = fmt.Errorf("terminal: not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
return
}
load.path, load.err = LibraryPath()
if load.err == nil {
load.err = vt.Load(load.path)
}
})
return load.err
}
// LibraryPath returns the libghostty-vt the terminal loads, the first of:
//
// - the file $MYGO_GHOSTTY_VT names;
// - the one among the app's resources (mygo.PathResources), where `mygo
// build` and `mygo dev` put it, signed with the app on macOS;
// - the one next to the executable;
// - the one in the user's cache, where the CLI downloads it
// (<cache>/mygo/natives/<sha256>/), which programs that are not
// packaged apps, as under `go run` and `go test`, download there when
// it is missing, checking its SHA-256.
//
// Packaged apps never download it: build them with the CLI.
func LibraryPath() (string, error) { return library.Find(natives) }