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
+108
@@ -0,0 +1,108 @@
|
||||
//go:build darwin
|
||||
|
||||
package kqueue
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/internal/platform"
|
||||
"github.com/egoist/mygo/internal/wait"
|
||||
)
|
||||
|
||||
func TestKqueueWatch(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
sub := filepath.Join(dir, "sub")
|
||||
file := filepath.Join(dir, "file")
|
||||
if err := os.Mkdir(sub, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(file, nil, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := syscall.Mkfifo(filepath.Join(dir, "pipe"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
notices := make(chan platform.FileWatchNotice, 16)
|
||||
w, err := New(func(n platform.FileWatchNotice) { notices <- n })
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer w.Close()
|
||||
add := func(id uint64, path string, subtree bool) error {
|
||||
t.Helper()
|
||||
info, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return w.Add(platform.FileWatchTarget{ID: id, Path: path, Directory: info.IsDir(), Info: info, Subtree: subtree})
|
||||
}
|
||||
if err := add(1, dir, true); err != platform.ErrUnsupported {
|
||||
t.Fatalf("subtree: %v", err)
|
||||
}
|
||||
// A pipe is skipped rather than opened, which would wait for a writer.
|
||||
for id, path := range map[uint64]string{1: dir, 2: sub, 3: file, 4: filepath.Join(dir, "pipe")} {
|
||||
if err := add(id, path, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
next := func(want platform.FileWatchNotice) {
|
||||
t.Helper()
|
||||
for {
|
||||
n := wait.For(t, "notice", notices)
|
||||
if n == want {
|
||||
return
|
||||
}
|
||||
if n.Err != nil || n.Kind == platform.FileWatchLost {
|
||||
t.Fatalf("notice %+v, want %+v", n, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(sub, "new"), nil, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next(platform.FileWatchNotice{Target: 2, Kind: platform.FileWatchDirty})
|
||||
if err := os.WriteFile(file, []byte("written"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next(platform.FileWatchNotice{Target: 3, Kind: platform.FileWatchWrite})
|
||||
// A file replaced: its watch is lost, and its directory changed.
|
||||
if err := os.Rename(filepath.Join(sub, "new"), file); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next(platform.FileWatchNotice{Target: 3, Kind: platform.FileWatchLost})
|
||||
// The lost target is gone: its ID can be enrolled again.
|
||||
if err := add(3, file, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(file, []byte("again"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next(platform.FileWatchNotice{Target: 3, Kind: platform.FileWatchWrite})
|
||||
// A target removed reports nothing more: the Add after it waits
|
||||
// until the driver has taken it off.
|
||||
w.Remove(2)
|
||||
if err := add(6, dir, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.RemoveAll(sub); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next(platform.FileWatchNotice{Target: 1, Kind: platform.FileWatchDirty})
|
||||
// A replacement racing the enrollment is not watched in its place.
|
||||
info, err := os.Lstat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Remove(file); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(file, nil, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := w.Add(platform.FileWatchTarget{ID: 5, Path: file, Info: info}); err == nil {
|
||||
t.Fatal("watched a replacement")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user