Skip to content

Hangar: local dev environment (multi-server, backups, ngrok, UX)#49454

Draft
AndreyKizimenko wants to merge 9 commits into
mainfrom
feat/hangar-dev-services
Draft

Hangar: local dev environment (multi-server, backups, ngrok, UX)#49454
AndreyKizimenko wants to merge 9 commits into
mainfrom
feat/hangar-dev-services

Conversation

@AndreyKizimenko

Copy link
Copy Markdown
Member

Related issue: N/A — internal developer tooling (tools/hangar).

Summary

Fleet Hangar is the local dev-environment control panel (tools/hangar, Go + Wails). This PR builds out multi-server support — running up to 3 independent local Fleet servers in parallel, each on its own git worktree, offset ports, and docker compose project — plus a set of refinements found while QAing it.

Opening as a draft for transparency. All changes are confined to tools/hangar/; nothing touches the Fleet server, agent, or any shipped code.

Note: this replaces #49453, which GitHub auto-closed during a branch rename (feat/hangar-multi-serverfeat/hangar-dev-services) that coincided with a GitHub incident. Same branch, same commits — new PR. Next up on this branch: a local SCEP server tab (start/tail logs) and a local TUF server + package generation tab.

What's here (one commit per item):

  • DB backups in app-data + cross-server restore — backups are keyed by server id under the app-data dir (so they survive worktree teardown), the backup/restore docker command is built by Hangar itself instead of the worktree's tools/backup_db scripts (so a secondary worktree on an old ref can't silently dump/restore the primary stack), and the Database tab can browse and restore another server's backups into the active server.
  • Start-button feedback — keep the button disabled/"starting…" until fleet serve is actually listening.
  • ngrok stale-tunnel heal — drop tunnel selections that no longer exist in ngrok.yml.
  • ngrok live public-URL links — clickable links pulled from ngrok's local API (127.0.0.1:4040).
  • Per-server open-in-browser linkshttps://<project>.localhost:PORT (isolated login cookie per host) plus https://localhost:PORT, fixing cross-server session clobbering.
  • Single status dot on server-switcher pills, server-scoped vs global tab grouping (with switcher dimming), and main pinned to the top of the RC branch list.

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes — N/A: tools/hangar is a developer tool and is not part of a Fleet release.

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented, JS inline code is prevented, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

    • Backup names are validated to [A-Za-z0-9._-] (and rejected if starting with .); server-id path segments are sanitized to [A-Za-z0-9_-] (no dots, so no traversal); paths interpolated into the docker command are single-quoted.
  • Timeouts are implemented and retries are limited to avoid infinite loops

    • The ngrok local-API fetch uses a 2s HTTP timeout; no unbounded loops or retries were added.
  • If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI — N/A: no Fleet server API changes.

Testing

  • Added/updated automated tests
    • Go unit tests for the backups directory logic (dir-scoped list/delete/name-check, server-id sanitization/traversal safety).
  • Where appropriate, automated tests simulate multiple hosts and test for host isolation — N/A.
  • QA'd all new/changed functionality manually (ongoing local multi-server testing).

Database migrations

N/A — no database migrations.

New Fleet configuration settings

N/A — no Fleet server configuration settings (Hangar stores its own settings in app-data).

fleetd/orbit/Fleet Desktop

N/A — no fleetd/orbit/Fleet Desktop changes.

Moved off rc-minor-fleet-v4.89.0 where it was sitting uncommitted.
Adds per-server orchestration (ServerSwitcher, servers/ipc libs) and
related Go service + frontend changes across the Hangar dev tool.
Backups now live under the app-data dir keyed by server id (surviving
worktree teardown), and the backup/restore docker command is built by
Hangar itself instead of the worktree's tools/backup_db scripts — so a
secondary worktree on an old ref can't silently target the primary stack.
The Database tab can browse and restore another server's backups into the
active server.
startServe only spawns the process, so the button re-enabled instantly and
looked spammable while the server was still booting. Hold the busy state
until health reports it up (with a timeout safety net).
A renamed/removed tunnel lingered in default_tunnels (no chip to unpick it)
and was still passed to `ngrok start`, which failed. Drop selections that
no longer exist in the yml on a valid parse, in both the Server and Settings
tabs.
Fetch running tunnels from ngrok's local API (127.0.0.1:4040) and render
each public_url as a clickable link on the ngrok card while it's running.
The fleet-serve card links to https://<project>.localhost:PORT (isolated
login cookie per host — Chrome/Firefox resolve *.localhost with no setup)
and https://localhost:PORT, so signing into one local server no longer
clobbers another's session.
Replace the per-server accent dot + cryptic s/d badges with one dot that's
green when anything's running on that server, grey otherwise — matching the
Server-tab process cards. Server identity stays on the name + active border.
Split the tab bar into server-scoped (Git/Server/Logs/Database) and global
(fleetctl/GitOps/osquery-perf) groups, and fade the server switcher on global
tabs where the selection doesn't apply.
A dedicated filter for a single branch was noise. Fetch main separately and
render it as the first row of the RC list; a search still matches across all
refs.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/hangar-dev-services

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant