Repository navigation
draw service sidecar for tauri app - #1126
Merged
Merged
Conversation
Devin T. Currie (DTCurrie)
added this pull request to stack #1115
October 19, 2026 16:36
🦋 Changeset detectedLatest commit: dc3f312 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Devin T. Currie (DTCurrie)
force-pushed
the
draw-server-sidecar
branch
from
October 20, 2026 03:24
a68a0fb to
46283f3
Compare
Devin T. Currie (DTCurrie)
force-pushed
the
draw-server-sidecar
branch
from
October 20, 2026 17:15
380b8fb to
690b161
Compare
Micheal Parks (micheal-parks)
approved these changes
Oct 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bundles the Go draw server with the desktop app, so the draw-service panel is live in a standalone install with nothing else running. Stacks on #1116 (
tauri-app-workflows), which stacks on #1114.Draw server
cmd/draw-serveraccepts-port 0and printsdraw-server: listening on http://127.0.0.1:<port>as its first stdout line, with the port the OS actually bound.server.Startnow takes the address from the listener instead of the configured port.-exit-on-stdin-closeshuts the server down when stdin reaches EOF. Off by default, somake upandpnpm devare unaffected.MotionPlanServiceregistration moves intomotionplan_handlers.gobehind//go:build !nomotionplan. Building with-tags nomotionplandrops the nlopt link and IK inspection.main_test.gobuilds the binary and checks the stdout line and the stdin-close exit.server_test.gochecks that port 0 reports a bound address.Desktop app
draw_server.rsspawns the sidecar throughtauri-plugin-shellwith-port 0 -tmp-dir <app local data>/draw-tmp -exit-on-stdin-close, parses the port from the first stdout line within 10 s, forwards the rest to the log plugin, and answers thedraw_service_portcommand with the port ornull.lib.rsspawns only in release builds, or in a debug build withVIAM_VISUALIZER_SIDECAR=1, and kills the child onExitRequestedandExit.tauri.conf.jsondeclaresbundle.externalBin: ["binaries/draw-server"].beforeBuildCommandispnpm tauri:before-build.beforeDevCommandrunspnpm build:sidecarfirst, because tauri-build refuses a missing external binary.Frontend
useDrawServicePortreads the sidecar port over IPC when running in Tauri and resolves toundefinedotherwise.+layout.sveltepicks the draw port asdrawPortquery override, then sidecar port, then the compile-time default, and mountsDrawServiceonly once the port is known so it never dials 3030 first in the desktop app.Build and CI
scripts/build-sidecar.mjs, behind the wireit targetbuild:sidecar, buildssrc-tauri/binaries/draw-server-<triple>with nlopt linked statically and fails ifotool -Lorlddshows a non-system library.tauri-release.ymlinstalls Go and nlopt on every leg. The macOS x86_64 leg builds nlopt from source for that arch on the arm64 runner. Windows installs the MinGW toolchain and nlopt through MSYS2.tauri-check.ymlnow triggers on the Go sources and builds the sidecar before clippy andcargo test, which need the binary.Why?
Why a free port instead of 3030?
server.Startattaches to whatever already listens on its port, which is right formake upand wrong for an unrelated process. With port 0 the sidecar always owns its server and the frontend is told which port.Why does the sidecar watch stdin when the app already kills it on exit?
Tauri's exit events fire for Cmd+Q and window close, not for a signal or a crash. The first runtime check left a
draw-serverrunning afterkill -TERMon the app. The shell plugin pipes the child's stdin, so the pipe closes when the app dies by any cause. The explicit kill stays for the fast path.Why a private
nlopt.pcinstead ofCGO_LDFLAGS?go-nloptlinks through#cgo pkg-config: nlopt, and Homebrew's.pcpoints at a dylib. A shell-levelCGO_LDFLAGS=-L/opt/homebrew/libgoes first on the link line and the dylib wins again, so the script clears it and hands pkg-config a directory holding onlylibnlopt.a.Testing
Ran
pnpm check,pnpm vitest run src/routes/lib/tauri,go test ./cmd/draw-server/... ./client/server/...with and without-tags nomotionplan, andcargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo testinsrc-tauri. Ranpnpm lintthrough the repo's fixer andpnpm exec eslint scripts/build-sidecar.mjs.Added
useDrawServicePort.svelte.spec.ts, two tests incmd/draw-server/main_test.go, one inclient/server/server_test.go, and fourparse_port_linetests indraw_server.rs.Verified on macOS with
pnpm tauri build --debug --bundles appandVIAM_VISUALIZER_SIDECAR=1: the sidecar starts under~/Library/Application Support/com.viam.visualizer/draw-tmp, the webview holds two Connect streams to the sidecar port and none to 3030 while amake upserver sits there, andpgrep -f draw-serveris empty after bothkill -TERMandkill -KILLon the app.Not verified: the release legs. Windows static linking and the macOS x86_64 cross-build are checked structurally only, until the next release run.