@bom0792/herdgate 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@
20
20
 
21
21
  import { View, div } from "gpui-kit";
22
22
  import { v_flex, h_flex, InputState, Input } from "gpui-base";
23
- import { exec, appHome, readTextFile, notify, theme, props } from "herdr";
23
+ import { exec, appHome, readTextFile, notify, theme, props, shared, setShared } from "herdr";
24
24
 
25
25
  const BASE = `${appHome()}/herdgate`;
26
26
  const SETTINGS = `${BASE}/settings.json`;
@@ -71,6 +71,15 @@ async function readJson(path) {
71
71
  export default class Herdgate extends View {
72
72
  init(_props, cx) {
73
73
  this.h = cx.focus_handle();
74
+ // The shipped tabs mod renders its panel buttons from shared("workspace.panels")
75
+ // (the welcome may have fixed it to ["files","changes"] — the layout clone's new
76
+ // default never applies then). Self-heal: join the list once, keeping whatever
77
+ // the person chose.
78
+ {
79
+ const panels = shared("workspace.panels");
80
+ const list = Array.isArray(panels) ? panels : ["files", "changes"];
81
+ if (!list.includes("herdgate")) setShared("workspace.panels", [...list, "herdgate"]);
82
+ }
74
83
  this.settings = { cloud: "", root: "", name: "" };
75
84
  this.paired = false;
76
85
  this.cloud = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bom0792/herdgate",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "Cloud relay hub for herdr-core: every machine dials out, phones and browsers follow (PWA + SSH leg, E2E payloads).",
5
5
  "type": "module",
6
6
  "engines": {
package/src/web/app.js CHANGED
@@ -11,7 +11,7 @@
11
11
  // - the token lives in localStorage on this device and is never sent anywhere but the
12
12
  // cloud's own WS endpoint.
13
13
 
14
- const BUILD = "v0.9.2";
14
+ const BUILD = "v0.9.8";
15
15
 
16
16
  const $ = (id) => document.getElementById(id);
17
17
  const TOKEN_KEY = "herdgate.token";
@@ -742,6 +742,33 @@ $("signin-form").addEventListener("submit", (event) => {
742
742
  connect();
743
743
  });
744
744
 
745
+ // Approve a new machine: the owner types the code its herdgate panel shows.
746
+ $("addmachine").addEventListener("submit", async (event) => {
747
+ event.preventDefault();
748
+ const code = $("addmachine-code").value.trim();
749
+ const noteEl = $("addmachine-note");
750
+ noteEl.hidden = false;
751
+ noteEl.className = "muted small";
752
+ noteEl.textContent = "approving…";
753
+ try {
754
+ const r = await fetch(`${cloudBase()}/v1/agent/approve`, {
755
+ method: "POST",
756
+ headers: { "content-type": "application/json", authorization: `Bearer ${state.token}` },
757
+ body: JSON.stringify({ code }),
758
+ });
759
+ if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error ?? `HTTP ${r.status}`);
760
+ $("addmachine-code").value = "";
761
+ noteEl.textContent = "approved — the machine appears when its publisher connects";
762
+ // A fresh hello lists the new room (rooms come from hello).
763
+ state.closedByUs = true;
764
+ state.ws?.close();
765
+ connect();
766
+ } catch (e) {
767
+ noteEl.className = "error small";
768
+ noteEl.textContent = String(e.message ?? e);
769
+ }
770
+ });
771
+
745
772
  $("menu").addEventListener("click", () => {
746
773
  $("cloud").value = state.cloud;
747
774
  $("settings").showModal();
Binary file
@@ -39,6 +39,12 @@
39
39
  <p id="rooms-empty" class="muted" hidden>
40
40
  No machine is paired yet. Pair one from Herdr — its plugin or app panel prints a code.
41
41
  </p>
42
+ <form id="addmachine" autocomplete="off">
43
+ <label for="addmachine-code">Add a machine — enter the code its herdgate panel shows</label>
44
+ <input id="addmachine-code" type="text" inputmode="text" autocomplete="off" placeholder="pairing code" required />
45
+ <button type="submit">Approve</button>
46
+ </form>
47
+ <p id="addmachine-note" class="muted small" hidden></p>
42
48
  <p id="build" class="muted small"></p>
43
49
  </section>
44
50
 
package/src/web/sw.js CHANGED
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // Bump VERSION when a shell file changes; old caches are dropped on activate.
5
5
 
6
- const VERSION = "herdgate-v8";
6
+ const VERSION = "herdgate-v9";
7
7
  const SHELL = ["/", "/app.css", "/e2e.js", "/app.js", "/app.webmanifest", "/icons/icon.svg"];
8
8
 
9
9
  self.addEventListener("install", (event) => {