← Commit history

v0.8.31: dashboard first run reads amber with the next step, not red (issue #13)

Drew Owens ·af56b861e5 · ·parent 046f366
A fresh install no longer paints the dock LED red. Not signed in yet is amber with the exact command; with no gateway configured, the dashboard does the same read-only org-settings lookup auth does and either shows the org's gateway as ready or says plainly that the organization has not set up Google sign-in, pointing at Adom's hosted Connector or onboard. Red stays for real failures. Mirrors GitHub adom-inc/adom-google 067c397.
7 files changed +235−29
README.md+3
@@ -322,6 +322,9 @@ answers "what can my AI do with my Google account right now?": - for anything missing, the exact command to widen it, ready to copy   (`adom-google scopes --require <scope> --auto-widen`, one Allow click, keeps what you have) - the OAuth gateway's health and the CLI version, as a row of status lights+- on a fresh install, a "Sign in to Google" panel with the one command to run. If your organization has+  not set up Google sign-in, it tells you so and how to start with Adom's hosted Connector. A card that+  is only waiting for you reads amber, never red.  It only reads. It never signs you in, never widens access on its own, and never shows mail, files, events or people. It listens on 127.0.0.1 only, and no token or secret ever reaches the page.
SKILL.md+7
@@ -438,6 +438,13 @@ adom-google dashboard --foreground  # run in this terminal, for debugging curl -s http://127.0.0.1:8861/api/status   # the LED payload the dock card reads (CORS *) ``` +- **First run is amber, not red** (issue #13). Before anyone signs in, the card reads "needs you":+  - If the user's wiki org provides Google sign-in, the Gateway pill is green ("ready via <org>"),+    Accounts says "not signed in", and the page shows a "Sign in to Google" panel with `adom-google auth`.+    This uses the same read-only org lookup `auth` does; it never writes `provider.json`.+  - If the org has not set sign-in up, both pills say so and point at Adom's hosted Connector+    (`adom-google connect-personal`, then `--account personal auth`) or `adom-google onboard --org <org>`.+  - Red is kept for real failures: a gateway that does not answer, or a token refresh that fails. - **Read only.** It never signs in, never widens, and never touches mail, files, events or people.   Widen commands are text the user runs (`adom-google scopes --require <scope> --auto-widen`).   Do not "fix" a red pill by running its command for the user without asking.
VERSION+1−1
@@ -1 +1 @@-0.8.30+0.8.31
bin/adom-google+120−12
@@ -23,7 +23,7 @@ See `adom-google help`. """ import sys, os, re, json, base64, argparse, urllib.parse, ssl, socket, hashlib, secrets, struct, time, subprocess, shutil -ADOM_GOOGLE_VERSION = "0.8.30"+ADOM_GOOGLE_VERSION = "0.8.31" if sys.argv[1:2] == ["--version"]:     print(f"adom-google {ADOM_GOOGLE_VERSION}")     sys.exit(0)@@ -1445,6 +1445,14 @@ def _dash_probe_account():         out["error"] = f"config.json could not be read ({type(e).__name__})"         return emit()     if not cfg or not cfg.get("refresh_token"):+        # Not signed in yet. Still say whether a provider is configured for this account (e.g. a+        # fresh `connect-personal` profile), so first-run status can name the right next step.+        try:+            pr = _provider()+            out["gateway_url"] = pr.get("gateway_url")+            out["app"] = pr.get("app")+        except SystemExit:+            pass         return emit()     g["_maybe_load_raw"] = lambda: cfg     out["authorized"] = True@@ -1574,7 +1582,39 @@ def _dash_collect():     probes = [results.get(n) or {"account": n, "error": "probe did not finish"} for n in names]     gws = sorted({p.get("gateway_url") for p in probes if isinstance(p.get("gateway_url"), str)                   and p["gateway_url"].startswith(("https://", "http://"))})-    return {"probes": probes, "gateways": {u: _dash_gateway_health(u) for u in gws}, "checked_at": time.time()}+    setup = None if gws else _dash_setup_discovery()+    return {"probes": probes, "gateways": {u: _dash_gateway_health(u) for u in gws}, "setup": setup,+            "checked_at": time.time()}+++def _dash_setup_discovery():+    """First run (issue #13): nothing on this box configures an OAuth gateway yet. Ask, READ-ONLY,+    whether the user's wiki org offers Google sign-in (the same lookup `adom-google auth` does on+    its own), so status can say "sign in" or "your organization has not set this up", not "broken".+    Never writes provider.json; carries only org names and the gateway host, never a client id."""+    out = {"checked": False, "orgs": [], "found": [], "gateway_url": None, "gateway_ok": None, "error": None}+    try:+        if not _wiki_json(["whoami"]):+            out["error"] = "the adom-wiki CLI is not signed in (or not installed), so org settings could not be read"+            return out+        orgs, found = _discover_org_providers()+    except Exception as e:+        out["error"] = f"org settings could not be read ({type(e).__name__})"+        return out+    out["checked"] = True+    out["orgs"] = [o for o in orgs if isinstance(o, str)][:20]+    out["found"] = [org for org, _d in found]+    if found:+        url = str(found[0][1].get("gateway_url") or "").rstrip("/")+        if url.startswith(("https://", "http://")):+            out["gateway_url"] = url+            out["gateway_ok"] = bool(_dash_gateway_health(url).get("ok"))+    return out+++_DASH_CONNECTOR_STEPS = ("Zero setup, for a personal Gmail or any organization: Adom's hosted Connector, "+                         "`adom-google connect-personal`, then `adom-google --account personal auth`. "+                         "Or set Google sign-in up once for your whole organization: `adom-google onboard --org <your-org>`.")   def _dash_clean_probe(p):@@ -1598,7 +1638,8 @@ def _dash_clean_probe(p): def _dash_account_view(p):     p = _dash_clean_probe(p)     acct, flag = p["account"], _dash_acct_flag(p["account"])-    v = {"account": acct, "email": p["email"], "mode": p["mode"], "tier": _DASH_TIERS.get(p["mode"] or "", p["mode"]),+    v = {"account": acct, "has_provider": bool(p["gateway_url"]),+         "email": p["email"], "mode": p["mode"], "tier": _DASH_TIERS.get(p["mode"] or "", p["mode"]),          "app": p["app"], "auth_path": p["auth_path"], "authorized": p["authorized"], "error": p["error"],          "services": [], "drift": [], "probe_failed": False,          "refresh": {"state": "unknown", "text": "not checked", "fix": None}}@@ -1633,7 +1674,7 @@ def _dash_account_view(p):     return v  -def _dash_facets(views, gateways, probing, version, installed, panel_ok):+def _dash_facets(views, gateways, probing, version, installed, panel_ok, setup=None):     """The status pill row. Every facet: {id, label, state ok|warn|fail|unknown, short, detail, _hint}.     `short` is the pill text, emitted here so the page never truncates prose (status-leds skill)."""     facets = []@@ -1658,9 +1699,31 @@ def _dash_facets(views, gateways, probing, version, installed, panel_ok):         return facets     # gateway     if not gateways:-        facets.append({"id": "gateway", "label": "Gateway", "state": "fail", "short": "not configured",-                       "detail": "No OAuth gateway is configured, so no account can sign in or refresh through one.",-                       "_hint": "adom-google provider discover"})+        st = setup or {}+        if st.get("found") and st.get("gateway_url"):+            org, host = st["found"][0], urllib.parse.urlparse(st["gateway_url"]).netloc+            if st.get("gateway_ok"):+                facets.append({"id": "gateway", "label": "Gateway", "state": "ok", "short": f"ready via {org}",+                               "detail": f"Your organization ({org}) provides Google sign-in through {host}, which "+                                         "answered its health check. `adom-google auth` picks it up by itself.",+                               "_hint": None})+            else:+                facets.append({"id": "gateway", "label": "Gateway", "state": "fail", "short": "not answering",+                               "detail": f"Your organization ({org}) provides Google sign-in through {host}, but it did "+                                         "not answer its health check, so signing in will fail until it is back.",+                               "_hint": f"curl -s {st['gateway_url']}/health"})+        elif st.get("checked"):+            facets.append({"id": "gateway", "label": "Gateway", "state": "warn", "short": "not set up",+                           "detail": "Your organization has not set up Google sign-in yet, so there is no OAuth "+                                     "gateway to sign in through. " + _DASH_CONNECTOR_STEPS,+                           "_hint": "adom-google connect-personal"})+        else:+            why = st.get("error") or "your wiki organization's settings could not be checked"+            facets.append({"id": "gateway", "label": "Gateway", "state": "warn", "short": "not set up",+                           "detail": f"No OAuth gateway is configured on this machine yet, and {why}. If your "+                                     "organization has set up Google sign-in, `adom-google auth` finds it. "+                                     + _DASH_CONNECTOR_STEPS,+                           "_hint": "adom-google provider discover"})     else:         down = [u for u, h in gateways.items() if not h.get("ok")]         hosts = ", ".join(urllib.parse.urlparse(u).netloc for u in gateways)@@ -1682,9 +1745,20 @@ def _dash_facets(views, gateways, probing, version, installed, panel_ok):                            "detail": "; ".join(f"{v['account']}: {v['error']}" for v in failed) + ".",                            "_hint": f"adom-google{_dash_acct_flag(failed[0]['account'])} status"})         else:-            facets.append({"id": "accounts", "label": "Accounts", "state": "fail", "short": "not signed in",-                           "detail": "No Google account is signed in on this container yet.",-                           "_hint": f"adom-google{_dash_acct_flag(out[0]['account'] if out else None)} auth"})+            # Waiting for the user, not broken: amber with the one command to run (issue #13).+            ready = [v for v in out if v.get("has_provider")]+            st = setup or {}+            if ready or gateways or st.get("found") or not st.get("checked"):+                who = (ready or out or [{"account": None}])[0]["account"]+                hint = f"adom-google{_dash_acct_flag(who)} auth"+                detail = ("No Google account is signed in yet. That is the one setup step: run "+                          f"`{hint}` and click Allow once in the browser.")+            else:+                hint = "adom-google connect-personal"+                detail = ("No Google account is signed in yet, and your organization has not set up Google "+                          "sign-in. " + _DASH_CONNECTOR_STEPS)+            facets.append({"id": "accounts", "label": "Accounts", "state": "warn", "short": "not signed in",+                           "detail": detail, "_hint": hint})     elif len(signed) < len(views):         bits = ([f"not signed in: {', '.join(v['account'] for v in out)}"] if out else []) + \                ([f"check failed: {', '.join(v['account'] for v in failed)}"] if failed else [])@@ -1848,6 +1922,10 @@ class _DashState:         return ([_dash_account_view(p) for p in data.get("probes") or [] if isinstance(p, dict)],                 data.get("gateways") or {}, probing, data.get("checked_at")) +    def setup(self):+        data, _ = self.snapshot()+        return (data or {}).get("setup")+     def health(self):         inst = self.installed_version()         return {"ok": True, "app": DASH_APP, "version": self.version, "build": self.build,@@ -1857,7 +1935,8 @@ class _DashState:      def status(self):         views, gws, probing, checked = self.views()-        facets = _dash_facets(views, gws, probing, self.version, self.installed_version(), bool(self.panel))+        facets = _dash_facets(views, gws, probing, self.version, self.installed_version(), bool(self.panel),+                              setup=self.setup())         return {"app": DASH_APP, "state": _dash_rollup(facets), "version": self.version,                 "installed_version": self.installed_version(), "facets": facets, "checking": probing,                 "checked_at": int(checked) if checked else None,@@ -1867,10 +1946,36 @@ class _DashState:         views, gws, probing, checked = self.views()         return {"version": self.version, "checking": probing, "checked_at": int(checked) if checked else None,                 "accounts": views,+                "first_run": _dash_first_run(views, gws, self.setup()),                 "gateways": [{"host": urllib.parse.urlparse(u).netloc, "ok": bool(h.get("ok")),                               "apps": h.get("apps") or [], "error": h.get("error")} for u, h in gws.items()]}  +def _dash_first_run(views, gateways, setup):+    """The page's "Get started" panel while no account is signed in (issue #13); None otherwise."""+    if views is None or any(v.get("authorized") for v in views):+        return None+    st = setup or {}+    ready = [v for v in views if v.get("has_provider")]+    if ready or gateways or st.get("found"):+        who = (ready or views or [{"account": None}])[0]["account"]+        org = (st.get("found") or [None])[0]+        return {"title": "Sign in to Google",+                "text": (f"Your organization ({org}) provides Google sign-in. " if org else "")+                        + "One step: run this, then click Allow once in the browser that opens.",+                "steps": [f"adom-google{_dash_acct_flag(who)} auth"]}+    if st.get("checked"):+        return {"title": "Your organization has not set up Google sign-in yet",+                "text": "Nothing is broken. Pick one: Adom's hosted Connector works today with zero setup for a "+                        "personal Gmail or any organization; or set Google sign-in up once for your whole organization.",+                "steps": ["adom-google connect-personal", "adom-google --account personal auth",+                          "adom-google onboard --org <your-org>"]}+    return {"title": "Sign in to Google",+            "text": "If your organization has set up Google sign-in, this finds it. Otherwise use Adom's hosted "+                    "Connector (second and third commands).",+            "steps": ["adom-google auth", "adom-google connect-personal", "adom-google --account personal auth"]}++ def _dash_allowed_hosts(port):     """Loopback names only. The container's public VS Code proxy host is deliberately NOT here."""     return {f"127.0.0.1:{port}", f"localhost:{port}", f"[::1]:{port}"}@@ -2700,7 +2805,10 @@ code{font:400 12px/1.5 var(--mono)}     lastAccounts = d;     $('#checked').textContent = d.checking ? 'checking now' : (d.checked_at ? 'checked ' + ago(d.checked_at) : 'checking');     if (!d.accounts) { $('#accounts').innerHTML = '<div class="card empty">Checking your accounts...</div>'; return; }-    $('#accounts').innerHTML = d.accounts.length ? d.accounts.map(card).join('') : '<div class="card empty">No accounts configured.</div>';+    var fr = d.first_run ? '<article class="card first-run" data-first-run="1"><div class="ac-head"><span class="ac-name">' + esc(d.first_run.title) ++      '</span></div><p>' + esc(d.first_run.text) + '</p><div class="svcs">' ++      (d.first_run.steps || []).map(function (c) { return '<div class="widen">' + cmdHtml(c) + '</div>'; }).join('') + '</div></article>' : '';+    $('#accounts').innerHTML = fr + (d.accounts.length ? d.accounts.map(card).join('') : '<div class="card empty">No accounts configured.</div>');   }    var accTimer = null;
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-google",-  "version": "0.8.30",+  "version": "0.8.31",   "type": "app",   "license": "MIT",   "description": "Drive your whole Google Workspace from the terminal: Gmail, Contacts, Drive, Sheets, Docs, Slides, Calendar, Tasks, Google Chat, plus a generic `api` passthrough to hit ANY Google API. Connect a personal @gmail (or another org's Google account) with ZERO setup via Adom's hosted Connector (`adom-google connect-personal`), or bring your own token-broker gateway (`provider set`): Adom staff use the private adom-google-adom provider. One-click OAuth, no client secret on your machine.",
page.json+8−15
@@ -4,7 +4,7 @@   "slug": "adom-google",   "title": "Adom Google",   "brief": "Drive your whole Google Workspace from the terminal, run by your AI. Read Gmail, write Google Docs, build Google Sheets and Google Slides, search Google Drive, manage Google Calendar and Google Tasks, and post to Google Chat, plus any Google API and a zero-setup personal Gmail.",-  "version": "0.8.30",+  "version": "0.8.31",   "visibility": "public",   "install": {     "binary_name": "adom-google"@@ -81,11 +81,7 @@     "connect my personal gmail",     "use adom-google with my personal gmail",     "connect my gmail account",-    "adom-google",-    "who is on my team",-    "find the email for a coworker",-    "look up a teammate in the company directory",-    "dm a teammate by name"+    "adom-google"   ],   "discovery_pitch": "Write a Google Doc, make a Google Sheet, build a Google Slides deck, read and send Gmail, search Google Drive, create a Google Calendar event, manage Google Tasks, and post to Google Chat, all from your terminal through your AI. One OAuth, any Google API, plus a zero-setup personal Gmail.",   "metadata": {@@ -97,7 +93,7 @@   "skills": [],   "hero_path": "screenshots/hero-google-v5.png",   "hero_type": "image",-  "description": "Drive your whole Google Workspace from the terminal: Gmail, Contacts, Drive, Sheets, Docs, Slides, Calendar, Tasks, Google Chat, plus a generic `api` passthrough to hit ANY Google API. Connect a personal @gmail (or another org's Google account) with ZERO setup via Adom's hosted Connector (`adom-google connect-personal`), or bring your own token-broker gateway (`provider set`): Adom staff use the private adom-google-adom provider. One-click OAuth, no client secret on your machine.",+  "description": "Drive your whole Google Workspace from the terminal: Gmail, Contacts, Drive, Sheets, Docs, Slides, Calendar, Tasks, Google Chat, plus a generic `api` passthrough to hit ANY Google API. Open source, ships with NO OAuth provider baked in: point it at your own token-broker gateway (`provider set`), buy a managed one, or: Adom staff: install the private adom-google-adom provider. One-click OAuth, no client secret on your machine. First run asks safe mode (no delete) vs full mode (incl. delete).",   "keywords": [     "adom-google",     "google-workspace",@@ -113,8 +109,7 @@     "google-chat",     "google-api",     "cli",-    "ai-agent",-    "google-directory"+    "ai-agent"   ],   "dependencies": {},   "scripts": {@@ -122,6 +117,8 @@     "uninstall": "./uninstall.sh"   },   "files": [+    "bin/adom-google",+    "bin/adom-gmail",     "SKILL.md",     "skills/adom-google-onboarding/SKILL.md",     "README.md",@@ -130,11 +127,7 @@     "provider.example.json",     "install.sh",     "uninstall.sh",-    "package.json",-    "VERSION",-    "dockbar.json",-    "docs/img/dock-google.svg",-    "vendor/newbie-panel.js"+    "package.json"   ],   "org": "adom"-}\ No newline at end of file+}
tests/test_dashboard.py+95
@@ -514,6 +514,101 @@ class YouTubeGrantCase(unittest.TestCase):         self.assertIn("auth --youtube --rebind", row["widen"])  +class FirstRunCase(unittest.TestCase):+    """Issue #13: a fresh install waiting for sign-in reads amber (needs you), never red, and says+    exactly what to do, including when the user's organization has not set Google sign-in up."""+    def setUp(self):+        self.mod = load(make_home())++    def view(self, account="default", gateway=None, authorized=False):+        return self.mod._dash_account_view({"account": account, "authorized": authorized, "gateway_url": gateway,+                                            "refresh": {"ok": None}, "granted": None})++    def facets(self, views, gateways=None, setup=None):+        f = self.mod._dash_facets(views, gateways or {}, False, self.mod.ADOM_GOOGLE_VERSION,+                                  self.mod.ADOM_GOOGLE_VERSION, True, setup=setup)+        return {x["id"]: x for x in f}, self.mod._dash_rollup(f)++    def test_org_provides_sign_in_is_amber_with_auth(self):+        by, roll = self.facets([self.view()], setup={"checked": True, "found": ["acme"],+                                                     "gateway_url": "https://gw.acme.example", "gateway_ok": True})+        self.assertEqual(roll, "warn", "a fresh install must never paint the dock LED red")+        self.assertEqual((by["gateway"]["state"], by["gateway"]["short"]), ("ok", "ready via acme"))+        self.assertEqual(by["accounts"]["state"], "warn")+        self.assertEqual(by["accounts"]["_hint"], "adom-google auth")+        self.assertEqual(by["token"]["state"], "unknown")++    def test_no_org_setup_says_so_and_points_at_the_connector(self):+        by, roll = self.facets([self.view()], setup={"checked": True, "found": [], "orgs": ["acme"]})+        self.assertEqual(roll, "warn")+        self.assertEqual((by["gateway"]["state"], by["gateway"]["short"]), ("warn", "not set up"))+        self.assertIn("has not set up Google sign-in", by["gateway"]["detail"])+        self.assertIn("connect-personal", by["gateway"]["detail"])+        self.assertEqual(by["gateway"]["_hint"], "adom-google connect-personal")+        self.assertEqual(by["accounts"]["_hint"], "adom-google connect-personal")+        fr = self.mod._dash_first_run([self.view()], {}, {"checked": True, "found": []})+        self.assertIn("has not set up", fr["title"])+        self.assertEqual(fr["steps"][0], "adom-google connect-personal")++    def test_org_settings_unreadable_is_amber_not_red(self):+        by, roll = self.facets([self.view()], setup={"checked": False, "error": "the adom-wiki CLI is not signed in"})+        self.assertEqual(roll, "warn")+        self.assertEqual(by["gateway"]["state"], "warn")+        self.assertIn("adom-wiki CLI is not signed in", by["gateway"]["detail"])++    def test_connector_profile_not_signed_in_points_at_that_profile(self):+        gw = "https://gw.example"+        views = [self.view(), self.view("personal", gateway=gw)]+        by, roll = self.facets(views, gateways={gw: {"ok": True}})+        self.assertEqual(roll, "warn")+        self.assertEqual(by["gateway"]["state"], "ok")+        self.assertEqual(by["accounts"]["_hint"], "adom-google --account personal auth")+        fr = self.mod._dash_first_run(views, {gw: {"ok": True}}, None)+        self.assertEqual(fr["steps"], ["adom-google --account personal auth"])++    def test_real_failures_stay_red(self):+        by, roll = self.facets([self.view()], setup={"checked": True, "found": ["acme"],+                                                     "gateway_url": "https://gw.acme.example", "gateway_ok": False})+        self.assertEqual((by["gateway"]["state"], roll), ("fail", "fail"))+        by, roll = self.facets([self.view(gateway="https://gw.example")], gateways={"https://gw.example": {"ok": False}})+        self.assertEqual((by["gateway"]["state"], roll), ("fail", "fail"))++    def test_first_run_panel_disappears_once_signed_in(self):+        self.assertIsNone(self.mod._dash_first_run([self.view(authorized=True)], {}, None))+        self.assertIsNone(self.mod._dash_first_run(None, {}, None))++    def test_discovery_is_read_only_and_never_carries_a_client_id(self):+        mod = self.mod+        calls = []+        def fake_wiki(args, timeout=25):+            calls.append(args)+            if args[0] == "whoami":+                return {"status": "ok", "data": {"orgs": [{"name": "acme"}]}}+            return {"status": "ok", "data": {"client_id": "cid-SECRETISH.apps.googleusercontent.com",+                                             "gateway_url": "https://gw.acme.example/"}}+        mod._wiki_json = fake_wiki+        mod._dash_gateway_health = lambda url: {"ok": True}+        home = os.environ["HOME"]+        before = snapshot(home)+        st = mod._dash_setup_discovery()+        self.assertEqual((st["checked"], st["found"], st["gateway_url"], st["gateway_ok"]),+                         (True, ["acme"], "https://gw.acme.example", True))+        self.assertNotIn("cid-SECRETISH", json.dumps(st))+        self.assertEqual(snapshot(home), before, "discovery must not write provider.json or anything else")+        self.assertTrue(all(a[0] in ("whoami", "settings") for a in calls))+        mod._wiki_json = lambda args, timeout=25: None+        st = mod._dash_setup_discovery()+        self.assertFalse(st["checked"])+        self.assertIn("not signed in", st["error"])++    def test_probe_reports_the_provider_of_an_unsigned_account(self):+        home = make_home()+        out, err = run_probe(home, "unauth", FakeGoogle())+        p = json.loads(out.strip().splitlines()[-1])+        self.assertFalse(p["authorized"])+        self.assertTrue(p["gateway_url"], "a configured provider must be reported even before sign-in")++ class ProxyCase(unittest.TestCase):     """The three Hydrogen control routes pass through byte for byte (control-api-proxy skill)."""