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:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
@@ -0,0 +1,68 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func TestContrasted(t *testing.T) {
|
||||
white, black := ui.RGB(255, 255, 255), ui.RGB(0, 0, 0)
|
||||
for _, c := range []struct {
|
||||
fg, bg ui.Color
|
||||
ratio float32
|
||||
}{
|
||||
{ui.RGB(240, 240, 240), white, 3}, // a dark theme's gray on a light one
|
||||
{ui.RGB(30, 30, 30), black, 3}, // a light theme's on a dark one
|
||||
{ui.RGB(229, 229, 16), white, 4.5}, // bright yellow
|
||||
} {
|
||||
got := contrasted(c.fg, c.bg, c.ratio)
|
||||
r := contrast(luminance(got), luminance(c.bg))
|
||||
if r < c.ratio || r > c.ratio*1.1 {
|
||||
t.Errorf("contrasted(%v, %v, %v) = %v, a ratio of %v", c.fg, c.bg, c.ratio, got, r)
|
||||
}
|
||||
}
|
||||
if got := contrasted(black, white, 4.5); got != black {
|
||||
t.Errorf("black on white changed to %v", got)
|
||||
}
|
||||
// Short of the ratio even at black or white, the text takes the one
|
||||
// that contrasts more.
|
||||
if got := contrasted(ui.RGB(100, 100, 100), ui.RGB(128, 128, 128), 21); got != black {
|
||||
t.Errorf("gray on gray at 21 = %v, want black", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Shapes keep their colors under the minimum contrast, as in Ghostty, and
|
||||
// text takes it: Copilot CLI's input box, a light gray edged with half
|
||||
// blocks of that gray, showed dark bars on a white background.
|
||||
func TestMinimumContrastShapes(t *testing.T) {
|
||||
loadLib(t)
|
||||
light := &Theme{Foreground: ui.RGB(0x20, 0x20, 0x20), Background: ui.RGB(255, 255, 255)}
|
||||
term, err := New(Options{Conn: newPipe(), Theme: light, MinimumContrast: 3})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer term.Close()
|
||||
tt := ui.NewTester(func(c *ui.Context) { View(c, term).Fill() }, 400, 200)
|
||||
gray := ui.RGB(232, 233, 235)
|
||||
term.Feed([]byte("\x1b[38;2;232;233;235m▄▀█\U0001fb82A"))
|
||||
tt.Frame()
|
||||
term.mu.Lock()
|
||||
line := term.v.lines[0]
|
||||
term.mu.Unlock()
|
||||
for _, b := range line.boxes {
|
||||
if b.c != gray {
|
||||
t.Errorf("%q drawn in %v, want %v", b.r, b.c, gray)
|
||||
}
|
||||
}
|
||||
if len(line.boxes) != 4 {
|
||||
t.Errorf("drew %d shapes, want 4", len(line.boxes))
|
||||
}
|
||||
var text []ui.Color
|
||||
for _, r := range line.runs {
|
||||
text = append(text, r.c)
|
||||
}
|
||||
if len(text) == 0 || text[len(text)-1] == gray {
|
||||
t.Errorf("text in %v: not contrasted from %v", text, gray)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user