troll 0.3.2

The port manager that guards the bridge: permanent claims, expiring leases, and a live view of who listens where.
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="color-scheme" content="light dark">
  <meta name="troll-token" content="{{TROLL_TOKEN}}">
  <title>Troll console</title>
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNyIgZmlsbD0iIzFiMzU3NiIvPjxwYXRoIGQ9Ik01IDEwaDIydjNINXoiIGZpbGw9IiM4NmI5ZmIiLz48cGF0aCBkPSJNNyAxM2g1djEzSDd6bTEzIDBoNXYxM2gtNXoiIGZpbGw9IiM0ZjhiZGQiLz48cGF0aCBkPSJNMTIgMTlhNCA0IDAgMCAxIDggMHYtNmgtOHoiIGZpbGw9IiM0ZjhiZGQiLz48Y2lyY2xlIGN4PSIxNiIgY3k9IjIyIiByPSIyLjYiIGZpbGw9IiM1ZmQzYTgiLz48L3N2Zz4=">
  <link rel="stylesheet" href="/style.css">
  <script src="/app.js" defer></script>
  <script src="/actions.js" defer></script>
</head>
<body>
  <a class="skip" href="#console">Skip to registry</a>
  <header class="masthead">
    <div class="wrap masthead-inner">
      <div class="brand">
        <svg class="brand-mark" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
          <rect class="mark-frame" width="32" height="32" rx="7"></rect>
          <path class="mark-deck" d="M5 9.5h22v3.2H5z"></path>
          <path class="mark-arch" d="M7 12.7h5v13.3H7zm13 0h5v13.3h-5zM12 19a4 4 0 0 1 8 0v-6.3h-8z"></path>
          <circle class="mark-node" cx="16" cy="22.2" r="2.5"></circle>
        </svg>
        <div class="brand-copy">
          <strong>troll</strong>
          <span class="brand-tag small">port guard</span>
          <span id="troll-version" class="version-pill small" title="Troll version">v{{TROLL_VERSION}}</span>
        </div>
        <span id="listening-address" class="address small">127.0.0.1:{{TROLL_PORT}}</span>
      </div>
      <div class="header-tools">
        <label for="theme-picker">Theme</label>
        <select id="theme-picker">
          <option value="system">System</option>
          <option value="slate">Slate</option>
          <option value="graphite">Graphite</option>
          <option value="harbor">Harbor</option>
          <option value="daylight">Daylight</option>
          <option value="meridian">Meridian</option>
          <option value="parchment">Parchment</option>
        </select>
        <span class="muted small">Last refreshed <time id="last-refresh">Never</time></span>
        <button id="refresh-now" class="button" type="button" disabled>Refresh now</button>
        <button id="refresh-toggle" class="button" type="button" disabled>Pause refresh</button>
      </div>
    </div>
  </header>

  <main class="wrap" id="console" tabindex="-1">
    <nav id="screen-nav" class="segmented screens" aria-label="Screens">
      <a class="button" href="/" data-screen="console" aria-current="page">Console</a>
      <a class="button" href="/?screen=apps" data-screen="apps">Apps and local ports</a>
      <a class="button" href="/?screen=history" data-screen="history">History (30d)</a>
    </nav>
    <h1 id="screen-title">Port registry</h1>
    <div id="drift-filters" class="summary" role="group" aria-label="Registry summary and filters">
      <div class="stat">
        <p class="stat-label">Claims held</p>
        <p class="stat-value"><strong id="claims-held" class="count">—</strong></p>
        <div class="rack-frame" aria-hidden="true">
          <span class="rack"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></span>
        </div>
        <button class="metric" type="button" data-drift="claimed_silent" aria-pressed="false" disabled>
          <span class="metric-label" id="silent-label">Claimed silent</span>
          <strong class="count" data-count>—</strong>
        </button>
      </div>
      <div class="stat">
        <p class="stat-label">Leases held</p>
        <p class="stat-value"><strong id="leases-held" class="count">—</strong></p>
        <p id="leases-urgent" class="stat-note"></p>
        <button class="metric" type="button" data-drift="leases_expiring" aria-pressed="false" disabled>
          <span class="metric-label" id="expiring-label">Expiring within 2 h</span>
          <strong class="count" data-count>—</strong>
        </button>
      </div>
      <div class="stat">
        <p class="stat-label">Listening now</p>
        <p class="stat-value"><strong id="listening-now" class="count">—</strong></p>
        <button class="metric" type="button" data-drift="listening_unclaimed" aria-pressed="false" disabled>
          <span class="metric-label" id="unclaimed-label">Listening unclaimed</span>
          <strong class="count" data-count>—</strong>
        </button>
      </div>
      <div class="stat stat-drift">
        <button class="metric" type="button" data-drift="zone_conflicts" aria-pressed="false" disabled>
          <span class="metric-label" id="conflicts-label">Zone conflicts</span>
          <strong class="count" data-count>—</strong>
        </button>
      </div>
    </div>

    <div class="toolbar">
      <div class="search-box">
        <label for="search-filter">Search</label>
        <input id="search-filter" type="search" maxlength="120" autocomplete="off" spellcheck="false"
          placeholder="Port, service, path or owner" aria-describedby="search-hint">
      </div>
      <label for="kind-filter">Process kind</label>
      <select id="kind-filter">
        <option value="all">All kinds</option>
        <option value="ours">Ours</option>
        <option value="system">System</option>
        <option value="third-party">Third-party</option>
        <option value="unknown">Unknown</option>
      </select>
      <label for="listener-filter">Listener</label>
      <select id="listener-filter">
        <option value="all">Any listener state</option>
        <option value="listening">Listening</option>
        <option value="silent">Silent</option>
        <option value="unknown">Listener unknown</option>
      </select>
      <div id="density" class="segmented" role="group" aria-label="Layout">
        <button class="button" type="button" data-density="cards" aria-pressed="true">Cards</button>
        <button class="button" type="button" data-density="list" aria-pressed="false">List</button>
      </div>
    </div>

    <p id="search-hint" class="small muted">Search matches port, service or purpose, detected service, project, component, stack, owner, process name and path.</p>
    <p id="match-summary" class="small" role="status"></p>
    <p id="loading-status" class="banner" role="status">Loading registry…</p>
    <noscript><p class="banner warning">JavaScript is required to load the port registry.</p></noscript>
    <div id="fetch-error" class="banner error" hidden>
      <p id="fetch-error-message" role="alert"></p>
      <button id="retry-refresh" class="button" type="button">Retry</button>
    </div>
    <p id="scan-warning" class="banner warning" hidden></p>
    <div id="access-warning" class="banner warning" hidden>
      <p id="access-message"></p>
      <p id="rejected-token-message"></p>
      <button id="reload-console" class="button" type="button">Reload</button>
    </div>
    <p id="action-result" class="banner" role="status"></p>

    <div id="registry-rows">
      <div id="console-screen">
        <section id="claims" class="registry-section" aria-labelledby="claims-heading">
          <header class="section-head">
            <h2 id="claims-heading" tabindex="-1">Claims</h2>
          </header>
          <section id="apps" class="registry-group" aria-labelledby="apps-heading">
            <header class="section-head">
              <h3 id="apps-heading" tabindex="-1">Apps</h3>
              <button id="reserve-app" class="button primary" type="button" data-write disabled>Reserve app</button>
            </header>
            <div id="app-groups" class="panels"></div>
          </section>

          <section id="single-claims" class="registry-group" aria-labelledby="services-heading">
            <header class="section-head">
              <h3 id="services-heading" tabindex="-1">Services and single claims</h3>
              <button id="claim-port" class="button" type="button" data-write disabled>Claim port</button>
            </header>
            <div id="single-claim-rows" class="panels"></div>
          </section>
        </section>

        <section id="leases" class="registry-section" aria-labelledby="leases-heading">
          <header class="section-head">
            <h2 id="leases-heading" tabindex="-1">Leases</h2>
            <div class="actions">
              <button id="take-lease" class="button" type="button" data-write disabled>Take lease</button>
              <button id="take-stack" class="button" type="button" data-write disabled>Take stack</button>
            </div>
          </header>
          <div id="lease-rows" class="panels"></div>
        </section>

        <section id="unregistered" class="registry-section" aria-labelledby="unregistered-heading">
          <header class="section-head">
            <h2 id="unregistered-heading" tabindex="-1">Listening with no claim</h2>
          </header>
          <div id="unregistered-rows" class="panels"></div>
        </section>

        <section id="zones" class="registry-section" aria-labelledby="zones-heading">
          <header class="section-head">
            <h2 id="zones-heading" tabindex="-1">Red zones</h2>
            <button id="add-zone" class="button" type="button" data-write disabled>Add zone</button>
          </header>
          <div id="zone-rows" class="panels"></div>
          <p class="zone-policy small">Zones govern Troll allocation. Existing claims and leases stay allocated.</p>
        </section>
      </div>

      <div id="apps-screen" hidden>
        <section id="projects" class="registry-section" aria-labelledby="projects-heading">
          <header class="section-head">
            <h2 id="projects-heading" tabindex="-1">Projects</h2>
          </header>
          <div id="project-rows" class="panels"></div>
        </section>

        <section id="no-claim" class="registry-section" aria-labelledby="no-claim-heading">
          <header class="section-head">
            <h2 id="no-claim-heading" tabindex="-1">No claim</h2>
          </header>
          <div id="no-claim-rows" class="panels"></div>
        </section>
      </div>

      <div id="history-screen" hidden>
        <section id="history" class="registry-section" aria-labelledby="history-heading">
          <header class="section-head">
            <h2 id="history-heading" tabindex="-1">Removal history (30 days)</h2>
          </header>
          <p class="muted small history-note">Released or swept apps, claims, components, and leases stay restorable for 30 days. Restoring checks port availability and enabled red zones under the lock.</p>
          <div id="history-rows" class="panels"></div>
        </section>
      </div>
    </div>

    <section id="sweep" class="registry-section" aria-labelledby="sweep-heading">
      <header class="section-head">
        <h2 id="sweep-heading" tabindex="-1">Sweep</h2>
        <button id="sweep-button" class="button" type="button" data-write disabled>Preview sweep</button>
      </header>
      <p class="muted">Preview which reclaimable leases Troll can remove.</p>
    </section>
  </main>

  <dialog id="action-dialog" aria-labelledby="dialog-title" aria-describedby="dialog-description">
    <h2 id="dialog-title"></h2>
    <p id="dialog-description" class="muted"></p>
    <div id="dialog-error-box" class="inset error" hidden>
      <p id="dialog-error" class="error-copy" role="alert"></p>
    </div>
    <div id="dialog-access" class="inset warning" hidden>
      <p>Page access token unavailable. Reload the console.</p>
      <button id="dialog-reload" class="button" type="button">Reload</button>
    </div>
    <p id="dialog-status" class="inset" role="status" hidden></p>
    <div id="dialog-scope" hidden></div>
    <div id="dialog-current" class="inset" hidden></div>
    <form id="action-form" method="dialog">
      <fieldset id="dialog-fields"></fieldset>
      <div class="form-actions">
        <button id="dialog-cancel" class="button" type="button">Cancel</button>
        <button id="dialog-recover" class="button" type="button" hidden>Retry read</button>
        <button id="dialog-use-current" class="button" type="button" hidden>Use current values</button>
        <button id="dialog-review" class="button primary" type="button" hidden></button>
        <button id="dialog-submit" class="button primary" type="submit"></button>
      </div>
    </form>
  </dialog>

  <dialog id="info-dialog" aria-labelledby="info-title">
    <header class="info-head">
      <div class="info-title-wrap">
        <h2 id="info-title"></h2>
        <div id="info-badges" class="state-line"></div>
      </div>
      <div id="info-header-actions" class="actions"></div>
    </header>
    <div id="info-body" class="info-body"></div>
    <div class="form-actions">
      <button id="info-close" class="button primary" type="button">Close</button>
    </div>
  </dialog>
</body>
</html>