vfox-plus is a graphical front end for the vfox command line tool. It is built with mygo, the desktop application framework for Go, and its native user interface: no web view, no HTML, no JavaScript. mygo draws the window itself, from elements that are laid out with flexbox and painted with its own renderer, and opens it through GTK 3 without a C compiler.
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
flowchart TB
accTitle: Repository layout
accDescr: docs holds the documentation, shared the resources used by the application, mygo the application, the gateway of the Docker image and the phone app, and .github the CI workflows.
subgraph docs["<b>docs/</b> · all documentation, by language, then by audience"]
direction LR
d1("<b>en/user/</b><br/>user guides: install, use,<br/>remote and Android") ~~~ d2("<b>en/dev/</b><br/>developer specification<br/>(this document lives here)") ~~~ d3("<b>zh-CN/user/</b><br/>Simplified Chinese<br/>user guides") ~~~ d4("<b>zh-CN/dev/</b><br/>Simplified Chinese<br/>developer specification")
end
subgraph shared["<b>shared/</b> · machine-readable resources used by the application"]
direction LR
s1("<b>i18n/</b><br/>translation catalogues<br/>(ARB: JSON with ICU messages)") ~~~ s2("<b>icons.json</b><br/>Material Symbols used<br/>by the user interface") ~~~ s3("<b>fixtures/</b><br/>captured vfox output and<br/>the expected parser results") ~~~ s4("<b>test-plugin/</b><br/>offline vfox plugin for end-to-end<br/>tests against the real vfox")
s5("<b>packaging/linux/</b><br/>desktop entry, AppStream metadata<br/>and icon, for <code>vfxtool build-deb</code>") ~~~ s6("<b>packaging/windows/</b><br/>MSIX manifest, logos and bundle<br/>layout, for <code>vfxtool build-msix</code>") ~~~ s7("<b>tooling/</b><br/><code>vfxtool</code>, the Go tool that builds,<br/>tests and packages everything") ~~~ s8("<b>sandbox/</b><br/>shared parts of the<br/>Docker sandbox")
end
subgraph code["<b>Applications</b> and <b>automation</b>"]
direction LR
m("<b>mygo/</b><br/>the desktop application and its server<br/>for other devices (Go; it takes no arguments),<br/>and the gateway of the Docker image") ~~~ a("<b>mygo/phone/</b><br/>the phone app: a native application<br/>of mygo for Android") ~~~ g("<b>.github/</b><br/>CI and release workflows: repository<br/>checks, the build, the phone app,<br/>the memory report, the dev container,<br/>the sandbox and the release")
end
docs ~~~ shared ~~~ code
classDef docs fill:#E4E0FF,stroke:#5A4BE8,color:#1E1470,stroke-width:1.5px,rx:12,ry:12
classDef shared fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px,rx:12,ry:12
classDef app fill:#D9F2EA,stroke:#13836B,color:#06332A,stroke-width:1.5px,rx:12,ry:12
classDef ci fill:#ECEBF3,stroke:#8E8BA8,color:#2B2840,stroke-width:1.5px,rx:12,ry:12
class d1,d2,d3,d4 docs
class s1,s2,s3,s4,s5,s6,s7,s8 shared
class m,a app
class g ci
style docs fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
style shared fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
style code fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
The application reads the shared resources from shared/ and never copies
them, so that a translation or a fixture is changed in one place only.
The application is organised in three layers. Dependencies only point downwards.
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
flowchart TB
accTitle: Layers of the application
accDescr: UI depends on State, State depends on Core, and Core runs the vfox command line as child processes.
subgraph UI["<b>UI</b> · mygo/ui"]
direction LR
ui1(["Pages"]) ~~~ ui2(["Components<br/>ui/kit"]) ~~~ ui3(["Theme<br/>ui/mcu · ui/shapes"]) ~~~ ui4(["Motion"]) ~~~ ui5(["Platform<br/>integration"])
end
subgraph State["<b>State</b> · mygo/state"]
direction LR
st1(["Settings"]) ~~~ st2(["vfox<br/>availability"]) ~~~ st3(["Installed<br/>SDKs"]) ~~~ st4(["Registry"]) ~~~ st5(["Configuration"]) ~~~ st6(["Task queue"])
end
subgraph Core["<b>Core</b> · mygo/core · no UI framework"]
direction LR
co1(["Models"]) ~~~ co2(["Process runner"]) ~~~ co3(["vfox client and<br/>output parsers"]) ~~~ co4(["Settings store"])
end
UI --> State --> Core
Core -->|"child processes"| vfox(["vfox CLI"])
classDef ui fill:#E4E0FF,stroke:#5A4BE8,color:#1E1470,stroke-width:1.5px
classDef state fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px
classDef core fill:#D9F2EA,stroke:#13836B,color:#06332A,stroke-width:1.5px
classDef ext fill:#17123F,stroke:#17123F,color:#FFFFFF,stroke-width:1.5px
class ui1,ui2,ui3,ui4,ui5 ui
class st1,st2,st3,st4,st5,st6 state
class co1,co2,co3,co4 core
class vfox ext
style UI fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
style State fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
style Core fill:#F4F2FF,stroke:#B9B3F5,stroke-width:1.5px,rx:16,ry:16
linkStyle default stroke-width:2px
Core is plain Go without a UI framework. It contains:
- the domain models (
InstalledSdk,PluginInfo,AvailablePlugin,AvailableVersion,ConfigEntry,UseScope); - a process runner interface with one implementation based on the platform's process API; tests use a scripted fake, and a future remote back end (see below) can provide another one;
- the vfox client, which builds command lines, runs read-only queries and parses their output, and describes state-changing operations as commands (values) instead of running them;
- the settings store;
- the translation catalogues with their ICU messages (
core/i18n); - the plugin profiles (
core/profile), see below.
It is tested against shared/fixtures.
State turns core results into observable state for the UI. The most important piece is the task queue: every state-changing command (install, uninstall, use, unuse, add, remove, update) is queued and executed one at a time, because vfox does not lock its data directory. Each task streams the output of its process, extracts the download progress, keeps a bounded log and summarises failures. When a task finishes, the installed SDKs are reloaded.
UI renders the state, following the UI specification and
the design system. Desktop integration (browser, file
choosers, clipboard, accent colour) sits behind a small platform services
interface so that UI tests can replace it. The Material 3 Expressive
components live in ui/kit, built on mygo's elements and headless widgets;
the colour scheme (ui/mcu, a Go port of the Material colour utilities) and
the shapes (ui/shapes, a Go port of androidx.graphics.shapes) are plain Go
without a UI framework, like core and state.
In the sources the layers are mygo/core, mygo/state and mygo/ui
(ui/kit, ui/mcu and ui/shapes are part of the UI layer); core knows
nothing of the others, and state only knows core.
vfox lists, installs, selects and removes versions the same way for every plugin,
but the plugins of the version-fox organisation offer more, and none of it shows
in the output of vfox: vfox search java tem lists one distribution of Java
where vfox search java lists OpenJDK only, nodejs@24 installs the newest
Node.js 24 and flutter@stable the release of a channel, and each plugin reads
environment variables that move its downloads to a mirror and version files such
as .nvmrc. Without knowing this, an interface can only offer what every plugin
has in common, which is how the web interface of the first version came to show
the OpenJDK list of Java and nothing else (#43).
A profile (core/profile) writes it down, as plain data that the three
interfaces share, for java, nodejs, flutter, gradle, golang, python,
maven, php, dart, kotlin, dotnet and cmake:
| Part | What it is |
|---|---|
| Search | What follows the plugin name in vfox search: for java the 31 distributions of Foojay and all (on Linux for loong64 the Loongnix JDKs instead), with the one vfox uses without an argument |
| Shorthands | Names that vfox install <plugin>@<name> accepts besides the listed versions |
| Variables | The environment variables the plugin reads, with the mirrors that were checked, and what each takes (an http:// or https:// address, or one of a few values) |
| Version files | The files vfox reads through the plugin, and whether the vfox setting legacyVersionFile.strategy matters for them |
| Facets | The filters that suit the notes and the names of the listed versions: LTS, JavaFX, the channels and the architectures of Flutter |
| Naming | How a version name is put together, so that 21.0.12.1+1-tem shows Temurin and 3.47.7-x64 shows x64 |
| Guide, tips, docs | A few sentences on the names, the things that surprise people and links to the documentation of the plugin |
The texts of a profile are written in both languages next to the data, not in
the catalogues, because the web interface gets them over HTTP and the page does not
carry the catalogues. A plugin without a curated profile still
gets filters and mirrors without a code change: facets are inferred from the
listed versions (notes become a note filter, shared -suffix tails a variant
filter), environment variables from scanning the installed plugin for
os.getenv("VFOX_*"), and legacy files from PLUGIN.legacyFilenames in its
metadata.lua. A vfox-plus.json at the root of the plugin repository (see
core/profile/external.go) overlays these inferences with curated texts, and
profiles/<plugin>.json next to the settings overlays everything; the built-in
registry only holds what is curated in the repository.
A profile belongs to the plugin, whatever name vfox knows it by. vfox calls a plugin
that was added with vfox add --alias by the alias, and vfox info still says which
plugin it is, so the controller of the details looks the profile up by the name of the
plugin first and, when that has none, by the name that the information reports once it
has loaded (the page of the details shows the options tab at that moment, and the web
API waits for the information). The registry is state.AppModel.Profiles; the
end-to-end tests register a profile for their offline test plugin.
SdkDetailController carries the chosen search and the chosen facets. SetSearch
forgets the earlier list and the facets (the list loads when somebody asks for it);
ChooseSearch is the same for a choice of the user and also hands it to a
SearchMemory, which AppModel implements with the searches setting, so that the
choice survives the details and a restart and is the same in every interface; the
controller starts at the choice that the memory holds, when the profile still offers
it. AppModel.SetPluginVariable checks a value against its variable and stores it in
the extra environment of the settings, which every vfox process runs with.
The GUI never reads or writes vfox's files directly; everything goes through the command line, as described in the CLI contract. This keeps the GUI correct across vfox releases and lets vfox keep its invariants. The contract also lists the quirks of the current vfox output that parsers must cope with.
Read-only queries run concurrently and are cheap (about 10 ms each); only
vfox search and vfox available may touch the network.
Settings of the GUI itself are stored as JSON:
- on Linux,
$XDG_CONFIG_HOME/vfox-plus/settings.json(by default~/.config/vfox-plus/settings.json); - on Windows,
%APPDATA%/vfox-plus/settings.json.
| Key | Type | Default | Meaning |
|---|---|---|---|
theme |
string | "system" |
system, light or dark. |
useSystemColor |
boolean | true |
Derive the colours from the desktop accent colour. |
seedColor |
integer (ARGB) | 0xFFF28C1B |
Seed colour when the accent colour is not used. |
language |
string | "system" |
system, english or simplifiedChinese. |
vfoxExecutable |
string | absent | Path of vfox; absent means "detect". |
extraEnvironment |
object | {} |
Extra environment variables for vfox, e.g. mirrors. |
railExpanded |
boolean | false |
Whether the navigation rail shows its labels. |
lightweight |
boolean | false |
Closing the window leaves the application running without it, while other devices may connect. |
webRemote |
boolean | false |
Let other devices on the network connect, over HTTPS: the Docker gateway, phones and other computers. |
webInterface, remoteAccess |
boolean | absent | Retired: the application serves no web interface on its computer. Read only, so that they are dropped from the file, and never written. |
webPort |
integer | absent | The port that other devices connect to, from 1024 to 65535; absent means 8369. |
webCertificate, webKey |
string | absent | The PEM files of the certificate and the private key that other devices get; absent means a certificate that the application makes for itself. |
searches |
object | {} |
What was chosen to list for a plugin, by its name: {"java": "tem"}. The default has no entry. |
updateMirror |
string | "" |
Mirror prefix for GitHub, e.g. https://gh-proxy.org/. Empty means direct. Used for self-updates and plugin profiles. |
Unknown keys must be preserved or ignored, never rejected.
The vfox configuration (proxy, registry, storage directory, …) is not part
of these settings: it belongs to vfox and is edited through vfox config.
If no executable is configured, the GUI searches PATH, then the usual install
locations that a desktop launcher's PATH often lacks:
- on Linux:
/usr/local/bin,/usr/bin,~/.local/bin,~/bin,~/.linuxbrew/bin,/home/linuxbrew/.linuxbrew/binand/snap/bin, looking forvfox; - on Windows:
%ProgramFiles%/vfox,%LOCALAPPDATA%/Programs/vfox,%LOCALAPPDATA%/Microsoft/WindowsApps,~/scoop/shimsand~/.vfox/bin, looking forvfox.exe(PATHis split at;).
The user can also pick the executable. If vfox is missing or broken, the GUI explains how to install it and keeps the settings reachable.
core/update checks the GitHub releases of version-fox/vfox-plus and
downloads the asset for the platform: GET https://api.github.com/repos/version-fox/vfox-plus/releases/latest gives the
newest tag and its assets, and the download goes to
https://github.com/.../releases/download/..., optionally prefixed with the
updateMirror setting such as https://gh-proxy.org/ where github.com is
slow. The check itself is direct; the mirror applies to the download, which
falls back to direct when the mirror fails. Nothing installs itself: the
.deb is left for dpkg and the .msixbundle for the installer. The release
workflow publishes the names below, and TestPlatformAssetPrefersDebAndFallsBackToTarball locks the choice between a package and its fallback:
| Platform | Preferred | Fallback |
|---|---|---|
| Linux amd64 | vfox-plus_<version>_amd64.deb |
vfox-plus-<version>-linux-x64.tar.gz |
| Linux arm64 | vfox-plus_<version>_arm64.deb |
vfox-plus-<version>-linux-arm64.tar.gz |
| Windows x64/arm64 | vfox-plus_<version>_x64.msix / vfox-plus_<version>_arm64.msix |
vfox-plus_<version>.msixbundle |
The other assets of a release, the APK, the snap, the archive of the Windows executables and vfxtool.exe, are not offered: the check looks only at the names above.
The desktop checks once silently on startup and fills the settings page; the
update section there (updateSection) has the check button, the mirror field,
and the download button with the releases page next to it. An update that is
newer than ui.Version shows the download; otherwise the page says up to
date. The remote web interface only carries the updateMirror setting, and
has no check button: the update belongs to the machine the server runs on.
Every runtime dependency must fall in Category A or B of the license
classification of the Apache Software Foundation
(see https://www.apache.org/legal/resolved): what the ASF allows in its
products may be used here — permissive licenses (for example Apache-2.0,
MIT, BSD, Unlicense) or weak-copyleft licenses (for example MPL-2.0,
EPL-2.0). Category X (strong copyleft such as GPL and AGPL) is excluded.
Category B dependencies ship under their own license and its conditions
(their notices stay intact and their source stays obtainable); the
application links them unmodified. mygo, the framework of the application, is under the MIT license, and
the Go modules it links are purego under the Apache License 2.0, the text
shaper go-text/typesetting under the Unlicense or a BSD license, and the
golang.org/x modules under BSD licenses, as is the Go standard library; the
QR encoder skip2/go-qrcode (MIT) encodes the pairing link of the settings as a
QR code for the phone app to scan, and the QR decoder makiuchi-d/gozxing (MIT, a Go port of ZXing) reads the QR code of a photo for the phone app to pair with; the
ports in mygo/ui/mcu and mygo/ui/shapes are of libraries under the Apache
License 2.0 and the MIT license, and their notices ship with the application
(mygo/NOTICE.txt). The application does not link GTK 3,
GLib, Pango and Cairo, which are under the LGPL: mygo loads them from the system
when it starts, and the package depends on them as declared in
vfxtool runtask (shared/tooling/internal/runtask). The tray icon on Linux needs no library:
the application speaks the protocol of the panels over the session bus (see
The tray). The application
ships no strong-copyleft (Category X) code; weak-copyleft (Category B)
dependencies, if any, ship under their own license terms. The build tooling
in shared/tooling (vfxtool, never shipped in the application) additionally
uses go-github (the GitHub API for the memory report),
nfpm (Debian packaging as a library), go-licenses (license classification for
the license collector), go-getter (resumable downloads with a checksum, for the
package prefetch and the npm package of the icons), chromedp (starts Chrome and speaks the DevTools Protocol for the
measurement of the web heap and the screenshots of the web interface, MIT),
golang.org/x/image (the vector rasterizer that draws the
Windows logos, BSD-3-Clause), golang.org/x/tools (the parser of the coverage
profiles, BSD-3-Clause) and golang.org/x/sys (the Windows calls of
vfxtool sign-msix: the token for the elevation, the certificate store;
BSD-3-Clause) and godbus/dbus (the session bus, for the stand-in for the host of the tray icons that
the end-to-end tests use, and for what they ask of GNOME Shell; BSD-2-Clause), all Category A. The icons are Material Symbols Rounded by Google (Apache-2.0),
which vfxtool prepare cuts out of the npm package @iconify-json/material-symbols that
shared/icons.json pins: the package is downloaded and checked at build time, never linked,
and only the SVGs of the symbols in use are embedded. The Windows .msix and .msixbundle need no
additional runtime dependency: the Go executable is self-contained and the
package carries its own logos.
Prefer the platform and the official libraries of a technology over third-party
packages, and document why each dependency is needed next to its declaration.
Low memory use is a goal of the project. The application:
- keeps lists lazy (the version list of Node.js alone has close to 900 entries);
- keeps the newest 500 lines of each finished task in memory (2000 while it streams) and forgets finished tasks past 50; a failed task keeps its full log on disk, pruned to the newest 20 files;
- ships only the icons it uses (63 symbols, outlined and filled, about 70 KB of SVG, parsed when first drawn);
- stops animations that are not visible, and asks for less motion on the desktop whatever the platform asks (see the design system);
- avoids caching data that vfox can produce again cheaply;
- without its window, tells the system that it does not want the pages of its files for now (the resident set falls by 11 MB), and the Go scheduler uses at most four processors, which keep caches of memory of their own (see the memory page).
The memory page records what the application uses.
The application is a desktop application and has no command line: it takes no arguments, and
what else it does is a matter of its settings. One of them is whether other devices may connect.
The package mygo/pair holds the server for them, and a Host runs it as the settings say; the
window and the pages of the paired devices both write those settings. The application shows no
web interface on the computer it runs on: the Docker gateway serves the interface to browsers, and the
phone app is a native client of the same API, with screens of its own.
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
flowchart TB
accTitle: How the settings decide whether other devices connect
accDescr: The settings webRemote, webPort and the certificate are read by the Host. With webRemote on, it runs a server over HTTPS for the Docker gateway, phones and other computers. The window makes the pairing links, and the paired pages change the settings.
set(["<b>Settings</b><br/>webRemote · webPort<br/>webCertificate · lightweight"]) --> host("<b>pair.Host</b><br/>follows the settings,<br/>starts and stops at once")
rem("<b>Remote server</b><br/>0.0.0.0, the port of the settings,<br/>HTTPS only,<br/>sessions of 24 hours")
host -->|webRemote| rem
rem --> b2(["<b>The gateway, phones<br/>and other computers</b>"])
win(["<b>The window</b><br/>Pair a phone"]) -->|"RemoteLink"| host
web(["<b>Paired pages</b><br/>Other devices · Lightweight mode · Quit"]) -->|"PUT /api/web · POST /api/quit"| set
classDef cfg fill:#E4E0FF,stroke:#5A4BE8,color:#1E1470,stroke-width:1.5px
classDef own fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px,rx:12,ry:12
classDef client fill:#17123F,stroke:#17123F,color:#FFFFFF,stroke-width:1.5px
class set,win,web cfg
class host,rem own
class b2 client
linkStyle default stroke-width:2px
- Other devices (
webRemote) start a server on0.0.0.0and the port of the settings, which speaks HTTPS only, and whichpair.NewServerrefuses to start without a certificate. The certificate is the one ofwebCertificateandwebKey, or one that the application makes for itself next to the settings (EnsureServerCert), whose fingerprint the settings show for comparison. Pair a phone mints a link for it (Host.RemoteLink), with an address of the computer that the user chooses in it, and draws it as a QR code (pair.QRMatrix). Turning it off closes the server and every connection it holds, the server-sent events of the paired pages included, and with it the sessions. A port that is taken, or a certificate that does not load, is what the settings report:Status.RemoteError. - Settings are applied at once.
Hostlistens to the settings and applies the difference (Host.Apply); it notifies its own listeners, which the window redraws on and the paired pages learn of by awebevent. - The paired pages can change how other devices connect, and quit the application
(
PUT /api/web,POST /api/quit, same-origin and paired only). - The end-to-end build (the
e2etag) also starts a loopback server (LocalLink), whenVFOX_PLUS_E2E_LINKnames the file for its link. That link pairs the gateway that the tools picture and measure the interface through. The builds that are released have none (mygo/pair/loopback_e2e.goandloopback_off.go).
One application runs per user. RequestSingleInstanceLock of mygo makes a second one forward
its start to the first and end, and the first opens its window (App.showWindow) or, if it
has one, brings it to the front. The end-to-end builds, which tests start whatever else runs,
skip the lock.
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
stateDiagram-v2
accTitle: The window and the lightweight mode
accDescr: The application starts with its window. When the window is closed it quits, unless the lightweight mode is on and other devices may connect, in which case it keeps running without a window, releasing what the window held and putting an icon in the tray. Choosing Open in the menu of the icon, or starting the application again, opens the window again; quitting from the menu of the icon, from the settings, from a paired page or by a signal ends it.
direction LR
[*] --> window: start
window --> quit: window closed,<br/>lightweight off<br/>or no other devices
window --> background: window closed,<br/>lightweight on and<br/>other devices allowed
background --> window: tray icon ·<br/>started again
background --> quit: Quit · signal
window --> quit: Quit
quit --> [*]
classDef busy fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px
classDef stop fill:#ECEBF3,stroke:#8E8BA8,color:#2B2840,stroke-width:1.5px
class window busy
class background busy
class quit stop
Closing the last window (OnWindowAllClosed) quits the application, unless
Settings.Lightweight is on and Host.Status().Remote. Then App.releaseWindow lets go of
everything that the window held (the widgets, the page, the lists, the listeners on the tasks,
the work that was meant for the window), puts the icon in the tray (see The tray), and
returns the memory of Go to the system, and two seconds later, if the window is still closed, tells the
system that it does not want the pages of its files (App.scheduleTrim, see
Memory); a window opened later starts from a clean state. Tasks,
the server for other devices and its sessions go on, since they are not the window's. The toolkit of mygo (GTK 3 and its libraries) stays loaded, which is
why the lightweight mode saves a few MB and not the most of the memory (see
Memory).
State-changing commands stay serialized even when two models do run side
by side (for example the applications of two users on one vfox data directory, or the
end-to-end tests): every task holds a cross-process lock (tasks.lock next to the settings,
core.ProcessLock) while its vfox process runs, in addition to the in-process queue.
While the application runs without its window, an icon in the tray stands for it. It is supported on
the two desktops that the application is tested on: Windows 11, where it is in the notification area,
and GNOME, where the AppIndicator extension of the shell shows it in the panel (Ubuntu enables the
extension). Others are not supported: KDE Plasma and the desktops whose tray is of the old kind (XEmbed)
are for the user to leave for GNOME, or to do without the icon, as the application then runs without
it. The code does not refuse them (on Linux the icon is made wherever a StatusNotifierWatcher is on the
session bus, and on macOS it is in the menu bar), and nothing of it is tested or promised.
Its menu has Open vfox+ and Quit vfox+. It is the way back to the window, and the way to end the
application, that a process without a window would otherwise lack. The code is mygo/ui/tray.go, with
the icon of Linux in mygo/ui/tray_linux.go and the icon of mygo in mygo/ui/tray_other.go.
- When.
App.releaseWindowmakes the icon (showTray) as it lets go of the window, andApp.openWindowremoves it (hideTray), so the application has no icon while it has a window, and the state in which the memory matters most holds nothing for it. - The identity. On Linux the icon is an item of the StatusNotifierItem protocol, which the code puts
on the session bus itself, with the godbus library, and not through a library of the desktop. The item
has the ID of the application, by which a desktop keeps the settings it has for the icon. Each
appearance is a new item under a name of its own on the bus,
org.freedesktop.StatusNotifierItem-PID-N, with a counter. Opening the window gives the name up, so the desktop takes the icon out of its panel and forgets the item; closing the window again makes the next item, under the next name. On Windows and on macOS the ID keeps the place that the user gave the icon, which mygo 0.9.1 honours. This is the protocol's way, and it is the one that GNOME Shell handles. The library that the application loaded before (libayatana-appindicator3) kept one item for the life of the application. GNOME Shell kept the indicator it had for an item that registered again under the same ID, hidden, so the icon stayed out of the panel after its first appearance, and each appearance left a hidden indicator behind (about 1.6 MB of the shell's memory each time).vfxtool e2e-run tray-gnomechecks both. - A seam, like the window.
desktop.newTraytakestrayOptions(the PNG, the tool tip, the entries as label and click, and what activation does) and returns atrayIcon(Update,Destroy).newNativeTrayputs the item on the bus on Linux, and callsmygo.NewTrayon Windows and macOS. The tests replace it with a recorder (fakeTray) that clicks the entries. - The menu is the way back. On Linux the item is a menu (
ItemIsMenu), so a click on the icon shows it, and the panel needs no activation for that. The item also takesActivate, which brings the window back, for a desktop that calls it on a click instead of showing the menu. - The icon waits for a host. The icon is shown by the host of the icons on the session bus, the
StatusNotifierWatcher. Without a session bus there is no icon. With a session bus, but nothing that owns
org.kde.StatusNotifierWatcher, the icon is made all the same and waits, holding no connection to the bus: it keeps its text and its menu. It asks the bus whether the watcher has an owner (waitForHost) five seconds after it starts to wait, and then at longer intervals, doubling up to once a minute, each time over a connection that it gives up at once. The check isNameHasOwner, which starts no service. When the watcher has an owner, the icon connects and is shown, and from then on it is taken again each time that the watcher starts over, as a shell does when it restarts with none of the icons it had (watchOwners). - A missing tray is not an error. No session bus, or a registration that fails: one line in the log ("no icon in the tray: ..."), and the application goes on without it. Starting it again is still the way back.
- Removal. The icon is removed by a goroutine after the choice that asked for the window returns, because
the libraries of the desktop do not expect the owner of a menu item to disappear in the handler of the item
(
hideTray), and at once when the application ends (OnWillQuit→removeTray), because Windows shows the icon of a program that is gone until the pointer passes over it. On Linux, giving the name up takes the icon away in the same way. - Language. The labels are in the language of the settings, which another device can
change while there is no window to draw it: a listener on the settings (
refreshTray) writes the menu again when the language changed. - The picture.
tray.png, 32 by 32 pixels, is the fox of the application icon without its plate (orange shows on a light panel and on a dark one). The repository holds no picture, sovfxtool preparedraws it withappicon.RenderFox,mygo/assetsembeds it, and it is ignored by git like the other collected assets. On Linux the item carries its pixels (the protocol'sIconPixmap, alpha first), so the desktop finds no file for the picture. - Packaging. Nothing is linked for the icon, and the package names no library for it: the application speaks the protocol over the session bus, and the panel of the desktop draws the icon.
What the icon costs in memory is in Memory. It is tested at four levels:
- The logic by the unit tests of
ui, which replace the tray with a recorder (fakeTray) that chooses the entries, and by the tests of the item of Linux itself (its picture, its menu, its name on the bus). - The protocol by a stand-in for the host of the tray icons, which a CI runner needs because it
has no panel: package
trayhostof the tooling ownsorg.kde.StatusNotifierWatcheron the session bus, reads the item and its dbusmenu as the AppIndicator extension of GNOME does, and chooses entries (godbus, BSD-2-Clause, is its one dependency).vfxtool e2e-run tray, a step of thebuildjob, closes the window and checks the icon, its ID, its tool tip, its picture (the pixels that the item carries: a 32 by 32 fox, with no plate) and its menu, chooses Open vfox+ (the window comes back and the item leaves the bus), checks that the application opens no link (a stand-in for the browser of the user, registered as the handler of the links, records none), and quits from the menu (the application ends with the code 0, and its item leaves the bus). The host also leaves the bus and comes up again, as a shell does when it restarts: the icon takes its place with the new host. Then the application runs where no host has come up yet, and a host that comes up after the window has closed takes the icon (tray-late). - The shell by a real GNOME Shell.
vfxtool gnome-sessionruns a command inside Ubuntu's GNOME Shell 50 without a screen (mutter serves Wayland without a GPU) with the AppIndicator extension enabled, in the container ofshared/sandbox/gnome.Dockerfile, andvfxtool e2e-run tray-gnome, which thetray-gnomejob runs, is the scenario against it: the application closes its window, and the shell puts an indicator for it in its panel, makes the menu of it (what it makes is read withorg.gnome.Shell.Eval, which the shell serves in unsafe mode), chooses Open vfox+ and Quit vfox+ as the user does, by having the extension send the event of the click, and the application does what they say. The shell hides the icon when the window comes back. Each time the window closes, the panel shows the one icon of the application, and the indicator of the appearance before is gone. The shell drops the icon when the application ends, and is still up after it all. - Windows by the
run-windowsjob, which runsvfxtool e2e-run fake,vfxtool e2e-run pythonandvfxtool e2e-run trayon Windows Server 2025 (x64) and Windows 11 on ARM with the end-to-end build for Windows, on the desktop of the runner (explorer.exeruns there, with its taskbar). The window comes back and the application ends as the control file of the end-to-end build asks, since a click on an icon of the taskbar is not for a program to make. The place of the icon is asked of the desktop by the application (Tray.Boundsof mygo, which isShell_NotifyIconGetRect), and the application writes the answer to its log, for each icon that it makes: on Windows Server 2025 the icon gets a place in the notification area, both times that it is made. Whether a desktop can say where an icon is is found out by a plain icon that the scenario adds itself, withShell_NotifyIconWand the structures that every program uses (tray_windows_probe.go), and the application's icon is judged against it. On the runner for Windows 11 on ARM the shell takes no icon of any program (the call refuses even the plain one, withexplorer.exeand its taskbar on the same desktop, session and user as the test), so there the place of the icon is not checked: the scenario says so in a note and checks what it can, the window and the application. The first line of the scenario says which Windows it runs on.
The control file is VFOX_PLUS_E2E_CONTROL of the end-to-end build: the tool writes close, show or quit
into it, and the application does what the user does with the close button and with the two entries of the
menu, and removes it. The automation plugin of mygo has no way to close a window, and Windows has no signal to
send for it.
The server for other devices (package mygo/pair) serves one-time links and expiring
sessions. A paired device gets the API of the server: installed SDKs with
install/use/uninstall, the plugin registry with add/update/remove, tasks with live
progress and logs over server-sent events, and the settings. The server serves no
page: the interface is the gateway's (see below). The HTTP surface that the interface
uses is specified in the remote protocol.
The phone app (mygo/phone) is a native client of the same API, and it has no page of
its own. It is a mygo application for Android, whose screens are built from the components
of ui/kit in the theme of the desktop application (seed colour #F28C1B). It pairs with a
computer through the pairing link of the computer's settings, after the person has compared
the certificate fingerprint on both screens, and then drives the vfox-plus instance on that
computer. The remote protocol specifies how it pairs,
keeps its session and makes its calls. Its packages are remote (the client of the API),
pairing (the link and the fingerprint), store (the saved computer and its session),
app (the connection and the data that the screens show), screens (the interface) and i18n (its
texts, in English and Simplified Chinese).
The web interface follows the design system (seed colour, shapes, motion)
with inlined assets, the favicon among them, because the gateway serves a single
embedded page with no external requests. The gateway serves a web app manifest at
/manifest.webmanifest, which lets Chromium browsers install the page as an application
with the same icon.
The Docker image (mygo/Dockerfile) is a second client of the remote server, next to the phone app,
and not an instance of the application. Its program is mygo/cmd/vfox-plus-gateway, which takes no
arguments, and its package is mygo/gateway. It uses mygo/pair for the certificates and their
fingerprints and nothing of the window, the toolkit or vfox, so it builds without cgo into one static
binary of about 10 MB, and the image is that binary on scratch with the certificates of the
authorities and a home directory for the user 10001. A person who wants to reach the interface of a
vfox-plus through an address of their choice (a container host, say) pairs the gateway with it.
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
flowchart LR
accTitle: The two pairings of the gateway
accDescr: A browser pairs with the gateway over HTTPS with the certificate of the gateway, and holds the cookie vfox-plus-gateway. The gateway pairs with the remote server of an instance over HTTPS, with the certificate that a person compared as the only root, and holds the cookie vfox-plus-session. The gateway serves pages of its own and the page of the interface, and forwards the API of the instance.
b(["<b>Browser</b>"]) -->|"HTTPS, the certificate of the gateway<br/>cookie <code>vfox-plus-gateway</code>"| g("<b>gateway</b><br/>its pages and the interface,<br/>and a reverse proxy")
g -->|"HTTPS, the certificate that<br/>a person compared is the root<br/>cookie <code>vfox-plus-session</code>"| r("<b>Remote server</b><br/>of an instance")
classDef own fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px,rx:12,ry:12
classDef client fill:#17123F,stroke:#17123F,color:#FFFFFF,stroke-width:1.5px
class g,r own
class b client
linkStyle default stroke-width:2px
- Two pairings, as the protocol has them. A browser pairs with the gateway with a one-time link
(
/auth/connect/<token>, five minutes, printed when the gateway starts) and holds a session of its own. Its cookie isvfox-plus-gatewayand notvfox-plus-session: cookies belong to a host and not to a port, so the cookie of a gateway and that of an instance on the same host would be one. The gateway pairs with an instance as the phone app does: a person pastes a pairing link of the instance on the page of the gateway, the gateway looks at the certificate (certificateOf), and the session cookie it gets is the gateway's. A certificate that the roots of the system vouch for is trusted; the one that the application makes for itself is shown as a fingerprint to compare with the settings of the application, and trusted, and pinned, only when the person says that they are the same. No connection ever skips the verification of a certificate (InsecureSkipVerifyis not used): the one that is looked at is learned from the error of a connection that is verified and fails, which has the certificate that was presented, and the one that is pinned is kept (in the state of the gateway) and is the only root of the connections to that instance, so that it is verified as any certificate is, its dates and its use included, for a name that it has (the application names the addresses of its computer in it, and the gateway may reach the computer by another). The certificate that was shown is the one that is trusted: it is looked at again when the person agrees, and a different one is refused. A certificate that changes later is not served with the session of the gateway, and is asked about again with a warning. Plain HTTP is for loopback addresses only, and only the end-to-end build serves it, for the tools. The address in the pasted link is checked for its form (hostPattern,checkAddress): a host name or an IP address and a port from 1 to 65535, which the numbers that a resolver reads as addresses of forms of their own (127.1,2130706433,0x7f.1) are not, nor are characters that a host name has no use for. That is all that is said of the address. Which hosts a person may name is not restricted, since the instance may be anywhere, and the people who are paired with the gateway are trusted with that (the user guide says so); a list of the targets that the person who runs the gateway authorizes would restrict it, and the gateway has none. - What the gateway serves, and what is the instance's. The page
/,/auth/connect/,/api/token, the forms under/gateway/, the page of the interface at/appand its manifest at/manifest.webmanifestare the gateway's (see the remote protocol). The instance serves no page. The routes of/api/*are the instance's, forwarded byhttputil.ReverseProxywith the session of the gateway. The page calls them, and it is built from the same sources as the gateway, so a gateway and an instance of different versions may disagree about the routes. The events are flushed as they come. The proxy takes out of the request what is the browser's and the gateway's and not the instance's (the cookies,Origin,Referer,Authorization,Forwarded,X-Forwarded-*,X-Real-IpandSec-Fetch-*: the instance refuses a change whose origin names another host, and the gateway has checked the origin against its own, withhttp.CrossOriginProtection, before it forwards), and theSet-Cookieof the answers. - Staying paired. A session of an instance lasts 24 hours and ends with the instance.
keepPairedrenews it when the gateway starts and every six hours, withGET /api/token(a paired device may mint a link for a second one) and the pairing with that link; an instance that cannot be reached is tried again after five minutes and the session is kept, since the instance may be back before it ends; a401of the instance marks the session as ended (invalidate), and the page of the gateway asks for a new link. A request finishes with the instance and the session it began with, even if the gateway is paired again meanwhile. - What it remembers.
gateway.json(mode0600: it holds the session at the instance, and the certificate of the instance that a person compared) and the certificate of the gateway,serve-cert.pemandserve-key.pemmade bypair.EnsureServerCert, orcert.pemandkey.pemthat a person puts there, invfox-plus-gatewayof the configuration directory of the user (a volume in the image). The sessions of the browsers are not remembered: a gateway that starts again prints a new link. - Stopping. The events of the page never end, so a browser with the interface open would keep
docker stopwaiting for the whole grace period: the gateway lets the requests that are on their way finish for one second, and ends with the code 0. - What CodeQL says of it. The pairing of the gateway makes a request to an address that a person typed,
which
go/request-forgeryreports. It is not removed by a check on the value (the gateway is for that), and the check of its form above is what the query takes as validation: it accepts any match of a regular expression, whatever the expression says. It does not make the gateway safe from a person who is paired with it, and nobody should read it so. - Tests. The package tests run the gateway against the real servers of
mygo/pair, in plain HTTP and in HTTPS with the certificate that the application makes.vfxtool gateway-checkruns the image, or the program, against the application itself (see the implementation guide).