~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/socialweb-computer-console

console.socialweb.computer: kcp, kubectl and ssh compiled to wasm in a browser tab with a terminal; a kcp fork

0
0
main
439 lines · 13.7 KB Raw History
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>socialweb.computer</title>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/css/xterm.css"
/>
<style>
  :root {
    color-scheme: dark;
    --bg: #0b0e14;
    --panel: #11151f;
    --border: #1f2633;
    --fg: #d5dbe5;
    --muted: #7c869a;
    --accent: #7aa2f7;
    --critical: #ef8b8b;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background: var(--bg);
    color: var(--fg);
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    display: flex;
    flex-direction: column;
  }
  header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }
  header h1 { font-size: 14px; margin: 0; font-weight: 600; }
  header .meta { color: var(--muted); font-size: 12px; }
  header .meta b { color: var(--fg); font-weight: 500; }
  #status { margin-left: auto; font-size: 12px; color: var(--muted); }
  #status.connected { color: #9ece6a; }
  #status.running { color: #e0af68; }
  #status.disconnected { color: var(--critical); }
  #retry {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--critical);
    border-radius: 4px;
    padding: 1px 8px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
  }
  #banners { display: flex; flex-direction: column; }
  #banners[hidden] { display: none; }
  .banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
  }
  .banner-warn { background: #3a2f12; color: #f3d38a; }
  .banner-error { background: #3d1a1a; color: #f4b4b4; }
  .banner-info { background: var(--panel); color: var(--fg); }
  .banner-text { flex: 1 1 16em; }
  .banner button {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 2px 10px;
    font: inherit;
    cursor: pointer;
  }
  main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
  #left-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
  }
  #terminal-pane {
    flex: 1;
    min-height: 120px;
    min-width: 0;
    padding: 8px;
    overflow: hidden;
  }
  #terminal { width: 100%; height: 100%; touch-action: none; overscroll-behavior: contain; }
  #terminal .xterm-viewport { overscroll-behavior: contain; }
  .xterm { height: 100%; }
  #mobile-keys { display: none; }
  #splitter {
    height: 6px;
    flex: none;
    cursor: row-resize;
    background: var(--border);
    border-top: 1px solid var(--bg);
    border-bottom: 1px solid var(--bg);
  }
  #splitter:hover { background: var(--accent); }
  #log-pane {
    height: 190px;
    flex: none;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    background: #070a10;
    overflow: hidden;
  }
  #log-pane.collapsed { height: auto; min-height: 0; flex: 0 0 auto; }
  #log-pane.collapsed #log { display: none; }
  #left-pane.log-collapsed #splitter { display: none; }
  .log-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 3px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }
  .log-head button {
    margin-left: 0;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    text-transform: none;
    letter-spacing: 0;
    padding: 0 6px;
    cursor: pointer;
  }
  .log-head button:hover { color: var(--fg); border-color: var(--muted); }
  #log {
    flex: 1;
    overflow: auto;
    padding: 4px 10px;
    font-size: 11px;
    line-height: 1.45;
  }
  #log > div { white-space: pre-wrap; overflow-wrap: anywhere; }
  #log:not(.verbose) .log-debug { display: none; }
  #log .log-info { color: #9aa5b8; }
  #log .log-ok { color: #9ece6a; }
  #log .log-warn { color: #e0af68; }
  #log .log-error { color: var(--critical); }
  #log .log-debug { color: #5f6b80; }
  .log-head label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    margin-left: auto;
  }
  .log-head input { margin: 0; }
  #diagram-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    overflow: auto;
  }
  #app-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 12px;
    margin-bottom: 12px;
  }
  .app-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    padding: 8px 10px;
    min-width: 0;
  }
  .app-block h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin: 0 0 6px;
  }
  .app-block label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
    color: var(--muted);
    font-size: 11px;
  }
  .app-block label > span { min-width: 52px; }
  .app-block input, .app-block select, .app-block textarea {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    font-size: 11px;
    padding: 3px 6px;
  }
  .app-block textarea { min-height: 44px; resize: vertical; }
  .app-block button, .app-block a.button {
    text-decoration: none;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    font: inherit;
    font-size: 11px;
    padding: 3px 10px;
    cursor: pointer;
    margin-top: 4px;
  }
  .app-block button:disabled { color: var(--muted); border-color: var(--border); cursor: default; }
  .app-block .app-status {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .app-block .app-status.ok { color: #9ece6a; }
  .app-block .app-status.warn { color: #e0af68; }
  .app-block .app-status.err { color: var(--critical); }
  .app-block input[type="checkbox"] { flex: 0 0 auto; }
  .compute-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11px; }
  #toast {
    position: fixed; right: 12px; bottom: 12px; z-index: 50; max-width: min(320px, calc(100vw - 24px));
    padding: 8px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--panel);
    color: var(--fg); font-size: 12px; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  }
  #toast[hidden] { display: none; }
  .compute-list li { border-top: 1px solid var(--border); padding: 5px 0; overflow-wrap: anywhere; }
  .compute-list .phase-Held { color: #9ece6a; }
  .compute-list .phase-Failed { color: var(--critical); }
  .compute-list .phase-Released { color: var(--muted); }
  .compute-list .detail { color: var(--muted); }
  .compute-list button, .compute-list a.button { margin: 3px 0 0 6px; }
  .app-block a.button { display: inline-block; }
  [hidden] { display: none !important; }
  #diagram-pane h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin: 0 0 8px;
  }
  #diagram-pane h2 span { text-transform: none; letter-spacing: 0; font-weight: 400; }
  #diagram-pane h2 .hint { color: #5f6b80; }
  #diagram.hidden { display: none; }
  #diagram-toggle {
    margin-left: 8px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
    padding: 0 6px;
    cursor: pointer;
  }
  #diagram-toggle:hover { border-color: var(--accent); }
  #diagram {
    flex: 1;
    min-height: 240px;
    --pele-bg: transparent;
    --pele-fg: #d5dbe5;
    --pele-muted: #7c869a;
    --pele-line: #4c566a;
    --pele-surface: #151a25;
    --pele-surface-alt: #11151f;
    --pele-border: #2a3242;
    --pele-accent: #7aa2f7;
    --pele-critical: #ef8b8b;
    --pele-radius: 6px;
  }
  #diagram svg { max-width: 100%; height: auto; }
  #diagram .error { color: var(--critical); white-space: pre-wrap; }
  footer {
    padding: 6px 16px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    background: var(--panel);
  }
  @media (max-width: 900px) {
    main {
      grid-template-columns: 1fr;
      grid-template-rows: minmax(0, 1fr) minmax(200px, 38vh);
    }
    #left-pane { border-right: none; border-bottom: 1px solid var(--border); }
    #log-pane { max-height: 40%; }
  }
  @media (max-width: 700px) {
    #mobile-keys {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      padding: 4px 8px;
      border-top: 1px solid var(--border);
      background: var(--panel);
    }
    #mobile-keys button {
      flex: 1 1 auto;
      min-height: 30px;
      padding: 2px 8px;
      background: transparent;
      color: var(--fg);
      border: 1px solid var(--border);
      border-radius: 4px;
      font: inherit;
      font-size: 11px;
    }
    #mobile-keys button:active { background: var(--border); }
  }
  @media (max-width: 700px) {
    header { padding: 6px 10px; gap: 6px; flex-wrap: wrap; row-gap: 4px; }
    header h1 { font-size: 12px; }
    header .meta { display: none; }
    #status { font-size: 11px; }
    #app-panel { grid-template-columns: 1fr; gap: 6px; margin-bottom: 6px; }
    .app-block { padding: 6px 8px; }
    #diagram-pane { padding: 6px 8px; }
    #diagram-pane h2 { font-size: 10px; margin-bottom: 4px; }
    #diagram-pane h2 .hint { display: none; }
    .log-head { padding: 2px 8px; }
    #log { padding: 3px 8px; font-size: 10px; }
    footer { display: none; }
  }
</style>
</head>
<body>
<header>
  <h1>socialweb.computer</h1>
  <span class="meta">api <b id="server">…</b></span>
  <span id="status">starting…</span>
  <button id="retry" type="button" hidden>retry</button>
</header>
<div id="banners" hidden></div>
<main>
  <section id="left-pane">
    <div id="terminal-pane"><div id="terminal"></div></div>
    <div id="mobile-keys">
      <button type="button" data-action="ctrl-c">Ctrl-C</button>
      <button type="button" data-action="enter">Enter</button>
      <button type="button" data-action="tab">Tab</button>
      <button type="button" data-action="up">↑</button>
      <button type="button" data-action="ctrl-d">Ctrl-D</button>
    </div>
    <div id="splitter" title="drag to resize"></div>
    <div id="log-pane">
      <div class="log-head">activity log<button id="log-toggle" type="button">show</button><label><input id="log-verbose" type="checkbox" />verbose</label><button id="log-save" type="button">save</button><button id="log-clear" type="button">clear</button></div>
      <div id="log"></div>
    </div>
  </section>
  <section id="diagram-pane">
    <div id="app-panel">
      <div class="app-block">
        <h2>Requester identity</h2>
        <label><span>Mode</span>
          <select id="identity-mode">
            <option value="oauthBrowser">OAuth (your PDS)</option>
            <option value="localRepo" disabled>Local PDS (pending)</option>
          </select>
        </label>
        <label><span>Handle</span>
          <input id="identity-handle" placeholder="alice.bsky.social" autocomplete="username" />
        </label>
        <button id="identity-signin" type="button" disabled>Sign in</button>
        <button id="identity-secondary" type="button" hidden></button>
        <div id="identity-status" class="app-status">waiting for kcp…</div>
      </div>
      <div class="app-block">
        <h2>Compute</h2>
        <label><span>Comms</span>
          <select id="compute-comms">
            <option value="Firehose">Firehose: records over relays and jetstreams, no ingress</option>
            <option value="Both">Ingress: XRPC endpoints on the relay plus the streams</option>
          </select>
        </label>
        <label id="compute-agent-row" hidden><span>Agent</span>
          <input id="compute-agent" type="checkbox" checked>
          <a href="https://irc.fedfork.com" target="_blank" rel="noopener">set up your agent</a>
        </label>
        <label id="compute-guesttools-row" hidden><span>socialweb-computer in the VM (R2)</span>
          <input id="compute-guesttools" type="checkbox">
        </label>
        <label><span>Associate DID</span>
          <input id="compute-associate" type="text" placeholder="optional: did:plc:… to associate with the VM" autocomplete="off" spellcheck="false">
        </label>
        <button id="compute-request" type="button" disabled>Request VM</button>
        <button id="compute-testpeer" type="button" hidden>Connect test peer</button>
        <div id="compute-status" class="app-status">sign in to request a VM</div>
        <ul id="compute-list" class="compute-list"></ul>
        <div id="compute-ingress" class="app-status"></div>
        <div id="compute-policy" class="app-status"></div>
      </div>
    </div>
    <h2>Live API surface <span id="diagram-updated">closed</span>
      <span class="hint">click a node to describe it</span>
      <button id="diagram-toggle" type="button">show</button></h2>
    <div id="diagram" class="hidden"></div>
  </section>
</main>
<footer>
  A just-bash shell with kubectl, goat, yq and kcp running as WebAssembly in
  this tab. The Deno server only serves files; CLI HTTP happens in the browser.
  Ctrl-C cancels the running command.
</footer>

<script src="https://cdn.jsdelivr.net/npm/pele@1/dist/pele.global.js"></script>
<script type="module" src="/app.js"></script>
<div id="toast" role="status" hidden></div>
</body>
</html>