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

+116
View File
@@ -0,0 +1,116 @@
package ui
// ListRow gives a row its shared context, index, selection and list focus,
// and what the pointer does to it: content drawing the row's hover, press
// or a ripple from the pointer reads them here, as the row's Element would
// report them, and leaves the row the one element taking the click.
type ListRow struct {
Context *Context
Index int
owner Element
row Element
selected bool
}
func (r ListRow) Selected() bool { return r.owner.Valid() && r.selected }
func (r ListRow) ListFocused() bool { return r.owner.FocusWithin() }
// Hovered reports whether the pointer is over the row, as Element.Hovered
// does for the row: content asking for it is built again as the pointer
// comes and goes, while the row keeps taking the input.
func (r ListRow) Hovered() bool { return r.row.Hovered() }
// Pressed reports whether the pointer's primary button presses the row,
// as Element.Pressed does for the row, which takes the press: content
// asking for it draws the press without taking it, so a click on the row,
// or Tester.Click on its ListState.Label, still chooses it. In a list
// that does not choose its rows, asking makes the row take the press.
func (r ListRow) Pressed() bool { return r.row.Pressed() }
// PointerPosition returns the pointer's position relative to the row's
// box and whether it is over the row, as Element.PointerPosition does for
// the row: a ripple starts where Pressed first reports the press.
//
// if row.Pressed() && app.ripple.Row != row.Index {
// x, y, _ := row.PointerPosition()
// app.ripple = Ripple{Row: row.Index, X: x, Y: y, At: time.Now()}
// }
func (r ListRow) PointerPosition() (x, y float32, over bool) { return r.row.PointerPosition() }
type listSpec struct {
state *ListState
count int
built bool
}
// List creates a virtual list. The original row callback remains supported.
// Omit it to configure ItemKey and Selection, then call Rows.
func List(c *Context, s *ListState, n int, row ...func(int)) Element {
raw := c.build()
if raw == nil {
return Element{}
}
if len(row) > 1 {
panic("ui: List accepts one row builder")
}
if len(row) == 1 {
// List is a public constructor, as the generated ones: its input
// reaches Changed as it returns, also in a container still
// building, as a split's pane.
raw.rt.beginBuild()
e := coreList(raw, s, n, row[0])
raw.rt.endBuild()
return wrapElement(e)
}
e := coreScroll(raw)
e.widget, e.role = "List", RoleList
if s == nil {
s = coreLocal(e, "list", func() ListState { return ListState{} })
}
*valueBinding[listSpec](e) = listSpec{state: s, count: n}
return wrapElement(e)
}
func (e Element) ItemKey(key func(int) any) Element {
if n := e.node(); n != nil {
if s, ok := n.st.valueBinding.(*listSpec); ok {
s.state.Key = key
}
}
return e
}
func (e Element) Selection(selection Selector) Element {
if n := e.node(); n != nil {
if s, ok := n.st.valueBinding.(*listSpec); ok {
s.state.Selection = selection
}
}
return e
}
func (e Element) Rows(row func(ListRow)) Element {
n := e.node()
if n == nil {
return e
}
s, ok := n.st.valueBinding.(*listSpec)
if !ok {
return e
}
if s.built {
panic("ui: List.Rows called twice in one pass")
}
s.built = true
// Rows builds the list: it is the constructor, as List with a row.
n.c.rt.beginBuild()
buildList(n.c, n, n, s.state, s.count, func(i int) {
if row == nil {
return
}
r := ListRow{Context: makeContext(n.c), Index: i, owner: e}
if rb := n.c.row; rb != nil {
r.row, r.selected = wrapElement(rb.e), rb.chosen
}
row(r)
}, plainList)
n.c.rt.endBuild()
return e
}