README
¶
SofCat UI
SofCat UI is a Wails v3 desktop application in the repository's root Go module.
It runs as the logged-in standard user and calls the existing SYSTEM SofCat
service through the shared typed client in pkg/service. It never receives
SofCat configuration, credentials, package-server settings, or internal catalog
objects.
Layout
main.go: Wails application,--pipe-nameflag (defaultsofcat-service),--user-sync(place this user's user-scope zip items without a window and exit; see ARCHITECTURE.md "Protocol"; a no-op off Windows), bundled WebView window titled with the branding title, orSofCat UIservice.go: the bound service —ListOptionalInstalls,InstallItem,RemoveItem,WatchOperation,GetBranding,CancelOperationlog.go: opt-in diagnosticsusersync_windows.go/usersync_other.go: the--user-syncentry point aroundpkg/usersyncassets_production.go/assets_development.go: embeddedfrontend/distunder theproductiontag, compile-safe source filesystem otherwisefrontend/: vanilla TypeScript, CSS, and Vite assets (no framework, router, or component library)frontend/bindings/: Wails-generated TypeScript — committed, never hand-editedfrontend/src/wails-api.tsandmock-api.ts: the two implementations of the singleSofCatApiadapter declared infrontend/src/api.ts
Backend surface
Six bound methods and exactly one event channel, sofcat:operation-status.
Each status record carries operationId, seq, itemName, displayName,
state, item-scoped progressPercent (only when measured), message, a
millisecond timestampUtc, and terminal error/cancellation fields. The frontend subscribes once, routes
records by operationId and orders each operation's records by seq.
Behind the bindings, pkg/service.Client talks JSON-RPC 2.0 to the service over
the named pipe; the "Protocol" section of ARCHITECTURE.md is the contract.
Service errors reach the frontend as <data.code>: <message>, for example
operation_not_cancelable: ... or server_busy: ....
Self-service selections belong to the machine: on a shared machine (fast
user switching, Remote Desktop Services) every user sees the one self-service
selection. Only the user who selected an item, or a local administrator, can
remove it, take back its pending removal, or cancel that user's operation;
anyone else gets not_authorized, which the card shows as "Only the person
who added this, or an administrator, can change it." An item nobody is
recorded as selecting (a default, or an older selection) stays removable by
anyone. Operation IDs are 128 random bits, so a user cannot guess another
user's operation to watch it.
Progress semantics
progressPercentis per item. It may reset when the event's item changes (for example when a dependency or updater runs). It is never aggregate operation progress, and is present only when measured: a download of known length is; an install or removal is not. An item's detail page shows its current phase beside a spinner; a Home card shows no progress, only a pending or required item's status and a failure or deferral reason. The one bar is in the bottom strip, for the operation being worked on, and is indeterminate for a phase without a percentage. The record timeline is only in Activity.ItemCompletedandItemFailedare non-terminal. A dependency failure does not end the operation.- Only
Succeeded,Failed,Deferred, andCanceledend an operation. - Installed/managed state is never inferred from progress. After every terminal
record the UI calls
ListOptionalInstallsand replaces the list and cache from that authoritative response. If that refresh fails, the previous data is kept and marked stale. - Cancel, in the bottom strip, works only until the service starts the item's
installer or uninstaller (
Requested,Queued,Downloading); after that it is disabled, and the service refuses a late request withoperation_not_cancelable. A running installer is never interrupted. An accepted cancel reverts the request's self-service selection, skips the item in the run under way (aborting its download), and ends the operation withCanceledfrom the user. Test it withsofcat.exe -S CancelOperation:<id>. Failed,Deferred,Canceled, pipe unavailability, request timeout, and premature stream end (stream_ended) are shown as-is and never converted into success.
Branding
An organisation can put its name, a tagline, a logo, a help link and an accent
colour on the UI with no rebuild or re-signing, and it works offline. The SYSTEM
service resolves the branding and validates it; the UI only asks for it with
GetBranding and never reads config.yaml or the registry itself. Each field
comes from the first source that sets it:
- Policy values under
HKLM\SOFTWARE\Policies\SofCat\Branding, all REG_SZ. A rebranded build readsHKLM\SOFTWARE\Policies\<Name>\Brandinginstead, where<Name>is itspkg/identityname, so profiles for one build never brand another. - The
branding:block inconfig.yaml(seeexamples/example_config.yaml). - Nothing. The UI then looks exactly as it does unbranded.
| Policy value | config.yaml key |
Accepted |
|---|---|---|
Title |
title |
Plain text, up to 120 characters. Also the window title and the app-bar name. |
Tagline |
tagline |
Plain text, up to 240 characters. |
LogoPath |
logo |
Local path to a PNG, JPEG or SVG of at most 512 KiB, checked by content. A PNG also becomes the window, taskbar and Alt+Tab icon. |
HelpUrl |
help_url |
Absolute http or https URL, opened in the system browser. |
HelpLabel |
help_label |
Plain text, up to 60 characters. Defaults to "Get help". |
Accent |
accent |
#rrggbb. Recolours buttons, links and the banner, and on Windows 11 the native title bar (Windows 10 keeps its default caption). |
ListHeading |
list_heading |
Plain text, up to 120 characters. Replaces the "Available software" heading; "My items" is unchanged. |
Sections |
sections |
A list in config.yaml; one comma-separated REG_SZ as policy. Up to 50 entries of plain text, up to 120 characters each. Sets the storefront tab order: the sections listed come first, then the rest alphabetically. Items without a catalog section appear under a "Software" tab, so give every item a section to hide it. |
Set the policy values with Intune (a custom OMA-URI or a registry script), Group
Policy Preferences, or reg add:
reg add HKLM\SOFTWARE\Policies\SofCat\Branding /v Title /t REG_SZ /d "Acme Software Center" /f
reg add HKLM\SOFTWARE\Policies\SofCat\Branding /v Accent /t REG_SZ /d "#0b6e4f" /f
Policy values apply on the next GetBranding call. A config.yaml change needs
a service restart, like any other config change. A value that fails its check is
dropped (debug log only) and is not replaced by the config value. Check the
result with sofcat.exe -S GetBranding, which prints the payload with the logo
replaced by its size in bytes. The UI caches the last payload in
localStorage key sofcat.branding.v1, applies it at start, then fetches
again.
Cache and Activity limitations
localStorage keys sofcat.optional-items.v1 and sofcat.activity.v1 hold the
last successful list (with timestamp) and locally initiated activity. A valid cache
renders immediately, then a live refresh replaces it; a failed refresh keeps the
cached data behind a non-blocking stale/service-unavailable notice with Retry in
the app bar.
Corrupt or unavailable storage is ignored and never blocks a live request.
Activity is local display history for this UI profile only — up to the 100 most recent records. It is not inventory, an audit log, or cross-user history, and restarting the app does not resume an old stream; the next authoritative list refresh provides convergence.
Keyboard
Everything is reachable with Tab and real buttons. Ctrl+L shows or hides
Activity (like Managed Software Center's ⌘L), and Escape leaves the detail page
or Activity. Both are frontend-only; nothing is added to the bound surface.
Development mock
npm run dev serves a browser-only mock (frontend/src/mock-api.ts) selected by
Vite's module alias in the development and demo modes. Every other mode
aliases the Wails adapter, so the production bundle contains no mock fixture
data and no SOFCAT_VITE_MOCK_ONLY marker; src/vite-config.test.mjs pins
that mapping.
The mock serves one of two Acme fixture stores (frontend/src/mock-stores.ts),
each with its own branding, sections and items. They share the mock's
behaviours: a failing install, a dependency installed in the same run, required
and managed items, pending installs and removals, custom action labels, restart
badges, a deferral, and Cancel during the download.
?store=apps(the default): Acme Software Center, Windows installers in Productivity, Developer tools and Utilities.?store=skills: Acme AI Skills, cross-platform skills and plugins withworksInharnesses and placement labels.?unbranded: the same store's items with empty branding, the stock look.?offline: the item list fails, showing the cached list or the offline state.
Each store keeps its own cache and Activity in localStorage under the mock, so
switching stores does not show the other store's list.
npm run build:demo builds the public demo (vite build --mode demo --base /demo/ --outDir dist-demo) that sofcat.app serves at /demo/. Demo mode adds
a bar above the shell saying the service is simulated, with links between the
stores and the unbranded view; the bar and the mock are absent from dist/.
Commands
just ui-lint # tsc --noEmit plus the generated-binding check
just ui-test # node --test frontend state/cache tests
just build # frontend assets, then build/sofcat.exe and build/sofcat-ui.exe
The Windows executable is a pure-Go cross-build:
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \
go build -tags production -ldflags "-H windowsgui" -o build/sofcat-ui.exe ./ui
Regenerate committed bindings from ui/ with the pinned command:
go run github.com/wailsapp/wails/v3/cmd/wails3@v3.1.0 generate bindings -clean -ts -noevents -d frontend/bindings .
Diagnostics
Diagnostics are disabled by default and create no directory or file. Set
SOFCAT_UI_DEBUG=1 or SOFCAT_DEBUG=1 before launch to write structured debug
records to %LOCALAPPDATA%\sofcat\ui-client.log. The log rotates at 10 MiB and
keeps one backup; setup or rotation failures never block startup or fail a UI
operation.
The only runtime argument is --pipe-name, defaulting to sofcat-service.
Windows VM procedure
The real validation loop lives in the repository AGENTS.md: build, bootstrap the
dialog-win11 VM with the self-serve fixtures and the real SYSTEM service, run
run-selfserve-smoke.ps1 (must exit 0 with SELF-SERVE SMOKE PASSED), then launch
launch-wails-ui.ps1 through an interactive scheduled task and screenshot the
desktop to judge Home, item progress, terminal Failed/Deferred, Activity, and
the offline cached/stale state.