Skip to content

Windows desktop

The Windows app runs Niko's workspace and browser inside WSL 2, the Linux system built into Windows. You can't run it on a Mac or on Linux, so you build, test, and debug it on GitHub's Windows runners.

Word Meaning
Profile Niko's data folder, %APPDATA%\niko\profiles\local.
Background service Niko's server, which runs as its own process. The code calls it the engine.
Private computer Niko's own WSL distribution, named niko-<id>. Docker runs the workspace and browser containers inside it.
Runtime pack niko-Runtime-win32-x64.tar.gz, the Linux system, tools, and container images that Niko installs as the private computer.
flowchart TD
  app[niko.exe]:::accent --> db[(PostgreSQL)]
  db --> engine[Background service]
  db --> wsl{{WSL 2 ready?}}
  engine --> chat[Chat]:::go
  wsl -- no --> install[Install WSL]:::stop
  wsl -- yes --> computer[Private computer]
  computer --> containers[Workspace and browser]:::go
  1. The database opens first. PostgreSQL runs on Windows itself, in the profile's database folder, and listens only on 127.0.0.1.
  2. The background service starts. On a profile that's already set up, chat opens when it's ready. The first start after an install or update is the slowest, because Microsoft Defender scans each file the service loads.
  3. The private computer gets ready at the same time. Niko checks WSL, then locks the profile folder so only the user, SYSTEM, and Administrators can open it. On first setup, Niko installs the runtime pack as the private computer. Later starts reuse it. Docker then starts the workspace and browser containers. Tools that need them wait until they're ready.
  4. Without WSL, chat still works. The installer offers to install WSL and restart. If it's still missing after setup, Niko starts installing it once by itself. A profile from an earlier version, where that attempt already happened, gets one more question the next time a chat window opens. Windows asks for administrator approval, and the PC must restart. If that fails or the user declines, the error screen offers Install WSL. With usage sharing on, Niko records each attempt's progress and result as wsl_install_changed.

Niko downloads the new installer, plus the runtime pack if it changed, and checks that the installer is signed by the expected publisher. The update installs when the user selects Restart to update, quits Niko, or leaves it idle. Niko quits, a hidden PowerShell runs the installer silently over the current install, and Niko opens again after Restart to update.

The profile and the private computer stay. A changed runtime pack updates the private computer on the next start.

What Where Code
App %LOCALAPPDATA%\Programs\niko, by default windows-installer.nsi
Profile %APPDATA%\niko\profiles\local protect-profile.ps1
Startup log logs\startup.log in the profile main.mjs
Database database in the profile database.mjs
PostgreSQL programs resources\engine\postgres\bin in the app folder build-windows.mjs
Private computer Its disk, ext4.vhdx, is under desktop-runtime in the profile, or in the folder the user chose windows.mjs and windows-guest.py
Downloaded updates %LOCALAPPDATA%\niko\updates windows-update.mjs

The <id> in niko-<id> is the first 12 characters of a hash of the profile path, so each profile gets its own private computer.