gent-link 0.2.12

Connect Codex and Claude Code chats across machines with the Gent CLI and desktop companion.
(() => {
  const dashboards = window.gentDashboards;
  const {byId, notice} = window.gentUI;
  const close = byId("close-tray");
  const content = byId("dashboard-content");
  let shown = false, snapshot = null, reveal = null;
  dashboards.mount(content, {tray: true});

  function visible(next) {
    shown = next;
    reveal?.cancel();
    reveal = null;
    dashboards.visible(next);
    if (next) {
      if (snapshot) {
        dashboards.receive(snapshot);
        if (matchMedia("(prefers-reduced-motion: no-preference)").matches) {
          reveal = content.animate([
            {opacity: 0.84, clipPath: "inset(8px round 6px)"},
            {opacity: 1, clipPath: "inset(0 round 0px)"}
          ], {duration: 120, easing: "ease-out"});
        }
      } else dashboards.refresh();
      close.focus({preventScroll: true});
    }
    snapshot = null;
  }

  function dismiss() {
    if (!shown) return;
    visible(false);
    window.gent.closeTray().catch(() => {
      if (!shown) visible(true);
      notice("bridge-error", "Could not close the dashboard panel.", true);
    });
  }
  close.addEventListener("click", dismiss);
  window.addEventListener("keydown", event => {
    if (event.key === "Escape" && !event.defaultPrevented) {
      event.preventDefault();
      dismiss();
    }
  });
  window.addEventListener("gent-message", ({detail: m}) => {
    if (m?.page === "tray_dashboard") {
      if (shown) dashboards.receive(m);
      // Native sends the opening snapshot before visibility. Never mount a
      // board document (or run its scripts) while the panel is hidden.
      else if (Array.isArray(m.rows) || m.read_failed) snapshot = m;
    }
    if (typeof m?.visible === "boolean" && (!m.visible || !shown)) visible(m.visible);
  });
  if (window.gent) {
    window.gent.ready().catch(() => notice("bridge-error", "Could not connect to Gent Desktop.", true));
  } else {
    close.disabled = true;
    notice("bridge-error", "Open this panel from Gent Desktop.", true);
  }
})();