@galda/cli 0.10.14 → 0.10.15

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.
Files changed (2) hide show
  1. package/app/index.html +19 -15
  2. package/package.json +1 -1
package/app/index.html CHANGED
@@ -5792,7 +5792,7 @@ function bootDisconnected(info){
5792
5792
  + '<p>Galda runs on your own machine. Run this where you use Claude Code or Codex — this board comes alive the moment it connects, no refresh needed:</p>'
5793
5793
  + '<div class="cg-cmd"><code>npx @galda/cli</code><button class="cg-copy">Copy</button></div>'
5794
5794
  + '<p class="cg-who">Signed in as <b></b></p>'
5795
- + '<p class="cg-switch">Wrong account? <a href="/logout">Switch account →</a></p>'
5795
+ + '<p class="cg-switch">Already running Galda under a different account? Run <code>npx @galda/cli --signin</code> and pick this one. Or <a href="/logout">switch this browser →</a></p>'
5796
5796
  + '<div class="cg-wait"><i></i>WAITING FOR THIS DEVICE</div></div>';
5797
5797
  document.body.appendChild(ov);
5798
5798
  ov.querySelector('.cg-who b').textContent = email || 'your account';
@@ -5814,20 +5814,24 @@ function bootDisconnected(info){
5814
5814
  const cw = document.getElementById('composerWrap');
5815
5815
  if (cw) cw.addEventListener('mousedown', (e) => { if (e.target.closest('#appsel, #modelsel, #effortsel')) return; gate(e); });
5816
5816
 
5817
- // Come alive automatically: while this device's engine is offline the relay
5818
- // 503s every engine-backed path (only /, /theme.css, /fonts.css are served);
5819
- // the instant the agent connects, the same path is proxied to the live engine
5820
- // (200). So we probe an engine-only endpoint by STATUS and reload when it stops
5821
- // 503-ing. We must NOT decide this by fetching `/` and grepping its HTML for a
5822
- // sentinel: this very poll's source contains the string '__GALDA_DISCONNECTED',
5823
- // so it is baked into every proxied copy of the page — the match is ALWAYS
5824
- // "found", the reload never fires, and the tab stays stuck on the connect
5825
- // screen forever ("npx said done but nothing happens"). (fix: status, not body)
5826
- setInterval(() => {
5827
- fetch('/api/state', { cache: 'no-store', credentials: 'same-origin' })
5828
- .then((r) => { if (r.status !== 503) location.reload(); })
5829
- .catch(() => {});
5830
- }, 4000);
5817
+ // Come alive automatically WITHOUT polling-and-reloading (Masa 2026-07-16).
5818
+ // The relay pushes a 'connected' event over SSE the instant THIS account's agent
5819
+ // is STABLY online (debounced on the relay side), and we reload exactly once on
5820
+ // that edge. Event-driven + debounced makes a reload loop structurally
5821
+ // impossible: a flapping agent never reaches the stable-connect edge, so it
5822
+ // shows "reconnecting" instead of triggering reloads. This replaces the old
5823
+ // `setInterval` + `if (status !== 503) reload` poll, which amplified any agent
5824
+ // flap into an infinite reload (the ~10-failure "無限ループ").
5825
+ const cgWait = ov.querySelector('.cg-wait');
5826
+ try {
5827
+ const es = new EventSource('/presence');
5828
+ es.addEventListener('presence', (e) => {
5829
+ let d; try { d = JSON.parse(e.data); } catch { return; }
5830
+ if (d.state === 'connected') { es.close(); location.reload(); } // one reload, only on a stable connect
5831
+ else if (cgWait) cgWait.innerHTML = '<i></i>WAITING FOR THIS DEVICE';
5832
+ });
5833
+ window.addEventListener('beforeunload', () => { try { es.close(); } catch {} });
5834
+ } catch { /* no EventSource (ancient browser) → stay on the gate; never loops */ }
5831
5835
  }
5832
5836
 
5833
5837
  async function boot(){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galda/cli",
3
- "version": "0.10.14",
3
+ "version": "0.10.15",
4
4
  "type": "module",
5
5
  "description": "Galda - hand off work to your Claude Code, get proof back. Runs on your existing subscription, no extra API cost.",
6
6
  "scripts": {