@hanzo/app 0.3.8 → 0.3.10

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.
package/dist/Account.js CHANGED
@@ -43,7 +43,7 @@ import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuC
43
43
  import { api } from './lib/api.js';
44
44
  import { createOrg, say } from './lib/org.js';
45
45
  import { list } from './lib/list.js';
46
- import { choose, org as current, orgs, pick, renew, scope, superAdmin } from './lib/session.js';
46
+ import { choose, org as current, orgs, renew, reopen, scope, superAdmin } from './lib/session.js';
47
47
  import { ENTRY, settings } from './lib/host.js';
48
48
  import { leave } from './dev.js';
49
49
  import { payUrl } from './lib/pay.js';
@@ -277,12 +277,11 @@ function Create({ open, onOpenChange }) {
277
277
  catch {
278
278
  /* the next load simply says nothing */
279
279
  }
280
- pick(org);
281
280
  renew();
282
281
  // The app again, where the person is, in the new organization. Not `/`: on
283
282
  // hanzo.ai that is the landing for everyone (owner, 2026-10-29), so a
284
283
  // person who made an organization from /chat was left on the marketing page.
285
- window.location.reload();
284
+ reopen(org);
286
285
  }
287
286
  catch (e) {
288
287
  setRefused(say(e, t));
@@ -310,8 +309,7 @@ export function Made() {
310
309
  return sessionStorage.removeItem(MADE);
311
310
  // Still out of the token: go on working where the person was.
312
311
  if (kept.from && current() !== kept.from && orgs().includes(kept.from)) {
313
- pick(kept.from);
314
- return window.location.reload();
312
+ return reopen(kept.from);
315
313
  }
316
314
  setMade({ org: kept.org, name: kept.name || kept.org });
317
315
  }
package/dist/Gate.js CHANGED
@@ -44,7 +44,7 @@ import { useHostname } from './lib/hostname.js';
44
44
  import { useHydrated } from './lib/hydrated.js';
45
45
  import { api } from './lib/api.js';
46
46
  import { usePersonal, useTier } from './lib/tier.js';
47
- import { CHOOSE, ORG, assumed, bearer, hasSession, org, orgs as claimed, pick, renew, role, scope, superAdmin, support } from './lib/session.js';
47
+ import { CHOOSE, ORG, assumed, bearer, hasSession, org, orgs as claimed, pick, renew, reopen, role, scope, superAdmin, support } from './lib/session.js';
48
48
  import { matches, refusal, slugify } from './lib/orgname.js';
49
49
  import { team as workspace } from './lib/host.js';
50
50
  import { checkoutUrl, money } from './lib/pay.js';
@@ -713,8 +713,7 @@ function Found({ onClose }) {
713
713
  throw new Error(t('{org} is made, and it is still called {org}: {reason}', { org: made, reason: say(err, t) }));
714
714
  });
715
715
  }
716
- pick(made);
717
- window.location.reload();
716
+ reopen(made);
718
717
  }
719
718
  catch (err) {
720
719
  setRefused(say(err, t));
package/dist/Setup.d.ts CHANGED
@@ -3,6 +3,23 @@ export declare const GITHUB_KEY = "hanzo.onboarding.github";
3
3
  export declare const SLACK_KEY = "hanzo.onboarding.slack";
4
4
  export declare const STEP_KEY = "hanzo.onboarding.step";
5
5
  export declare const PLUGIN_KEY = "hanzo.onboarding.plugin";
6
+ /** What GET /v1/provider (the org's providers) and GET /v1/connection (the reader's own) say is connected. */
7
+ export interface Linked {
8
+ /** Provider ids connected, by either. */
9
+ ids: Set<string>;
10
+ /** Google addresses either names. */
11
+ google: string[];
12
+ /** GitHub, as Projects reads it: the org's App, or the reader's own link (`github-user`). */
13
+ github: boolean;
14
+ /** The reader's own GitHub link: theirs to drop, where the org's App is an org admin's. */
15
+ own: boolean;
16
+ /** Both answered, so a provider missing from them is not connected. */
17
+ whole: boolean;
18
+ }
19
+ /** Null when neither answered. /v1/connection lists `connections`; nothing else is read from it. */
20
+ export declare function linked(providersData: unknown, connectionsData: unknown): Linked | null;
21
+ /** Where Disconnect lets go of GitHub: the reader's own link, or the org's App accounts. */
22
+ export declare const leaving: (own: boolean) => "/v1/provider/github/disconnect" | "/v1/provider/github/user/disconnect";
6
23
  export declare function Setup({ go }?: {
7
24
  go?: (address: string) => void;
8
25
  }): import("react").JSX.Element;
package/dist/Setup.js CHANGED
@@ -40,6 +40,43 @@ export const STEP_KEY = 'hanzo.onboarding.step';
40
40
  export const PLUGIN_KEY = 'hanzo.onboarding.plugin';
41
41
  /** Where plugins and connectors live: Dev's Customize. */
42
42
  const PLUGINS = '-/customize/plugins';
43
+ /** Null when neither answered. /v1/connection lists `connections`; nothing else is read from it. */
44
+ export function linked(providersData, connectionsData) {
45
+ const providers = providersData?.providers;
46
+ const connections = connectionsData?.connections;
47
+ const fromProviders = Array.isArray(providers) ? providers : null;
48
+ const fromConnections = Array.isArray(connections) ? connections : null;
49
+ if (!fromProviders && !fromConnections)
50
+ return null;
51
+ const ids = new Set();
52
+ const google = [];
53
+ const address = (id, account) => {
54
+ if (id === 'google' && typeof account === 'string' && account.trim())
55
+ google.push(account.trim().toLowerCase());
56
+ };
57
+ for (const p of fromProviders ?? []) {
58
+ if (!p.connected)
59
+ continue;
60
+ const id = String(p.id);
61
+ ids.add(id);
62
+ address(id, p.connection?.account);
63
+ }
64
+ for (const c of fromConnections ?? []) {
65
+ const id = String(c.provider);
66
+ ids.add(id);
67
+ address(id, c.account);
68
+ }
69
+ const own = ids.has('github-user');
70
+ return {
71
+ ids,
72
+ google,
73
+ github: own || ids.has('github') || ids.has('github-copilot'),
74
+ own,
75
+ whole: Boolean(fromProviders && fromConnections),
76
+ };
77
+ }
78
+ /** Where Disconnect lets go of GitHub: the reader's own link, or the org's App accounts. */
79
+ export const leaving = (own) => (own ? '/v1/provider/github/user/disconnect' : '/v1/provider/github/disconnect');
43
80
  /** Inline Slack Mark */
44
81
  function SlackMark({ size = 18 }) {
45
82
  return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 54 54", fill: "none", "aria-hidden": true, children: [_jsx("path", { d: "M11.379 33.9993C11.379 37.1358 8.84512 39.6507 5.7276 39.6507C2.61008 39.6507 0.0572205 37.1168 0.0572205 33.9993C0.0572205 30.8817 2.5911 28.3479 5.70862 28.3479H11.36V33.9993H11.379Z", fill: "#E01E5A" }), _jsx("path", { d: "M14.1962 33.9997C14.1962 30.8632 16.7301 28.3483 19.8476 28.3483C22.9651 28.3483 25.499 30.8822 25.499 33.9997V48.1353C25.499 51.2718 22.9651 53.7867 19.8476 53.7867C16.7301 53.7867 14.1962 51.2718 14.1962 48.1353V33.9997Z", fill: "#E01E5A" }), _jsx("path", { d: "M19.8662 11.2673C16.7296 11.2673 14.2148 8.73347 14.2148 5.61594C14.2148 2.49842 16.7486 -0.0354538 19.8662 -0.0354538C22.9837 -0.0354538 25.5175 2.49842 25.5175 5.61594V11.2673H19.8662Z", fill: "#36C5F0" }), _jsx("path", { d: "M19.8682 14.1334C23.0047 14.1334 25.5196 16.6673 25.5196 19.7848C25.5196 22.9023 22.9857 25.4362 19.8682 25.4362H5.67566C2.53916 25.4362 0.0242615 22.9023 0.0242615 19.7848C0.0242615 16.6673 2.55814 14.1334 5.67566 14.1334H19.8682Z", fill: "#36C5F0" }), _jsx("path", { d: "M42.5323 19.7853C42.5323 16.6488 45.0662 14.1339 48.1837 14.1339C51.3012 14.1339 53.8351 16.6678 53.8351 19.7853C53.8351 22.9028 51.3012 25.4367 48.1837 25.4367H42.5323V19.7853Z", fill: "#2EB67D" }), _jsx("path", { d: "M39.7126 19.7934C39.7126 22.9299 37.1787 25.4448 34.0612 25.4448C30.9436 25.4448 28.4098 22.911 28.4098 19.7934V5.61986C28.4098 2.48336 30.9436 -0.0315399 34.0612 -0.0315399C37.1787 -0.0315399 39.7126 2.48336 39.7126 5.61986V19.7934Z", fill: "#2EB67D" }), _jsx("path", { d: "M34.0376 42.482C37.1741 42.482 39.689 45.0158 39.689 48.1334C39.689 51.2509 37.1552 53.7848 34.0376 53.7848C30.9201 53.7848 28.3862 51.2509 28.3862 48.1334V42.482H34.0376Z", fill: "#ECB22E" }), _jsx("path", { d: "M34.0381 39.6507C30.9016 39.6507 28.3867 37.1168 28.3867 33.9993C28.3867 30.8818 30.9206 28.3479 34.0381 28.3479H48.2306C51.3671 28.3479 53.882 30.8818 53.882 33.9993C53.882 37.1168 51.3482 39.6507 48.2306 39.6507H34.0381Z", fill: "#ECB22E" })] }));
@@ -61,6 +98,7 @@ export function Setup({ go } = {}) {
61
98
  const [errorMsg, setErrorMsg] = useState(null);
62
99
  // A first press on Disconnect asks; the second lets go of GitHub.
63
100
  const [dropping, setDropping] = useState(false);
101
+ const [githubOwn, setGithubOwn] = useState(false);
64
102
  const [syncTurn, setSyncTurn] = useState(0);
65
103
  const signed = isAuthenticated && Boolean(accessToken);
66
104
  const accountList = Array.isArray(googleAccounts) ? googleAccounts : [];
@@ -105,7 +143,7 @@ export function Setup({ go } = {}) {
105
143
  fetch(`${api()}/v1/tool/mcp/servers`, { headers: auth })
106
144
  .then((r) => (r.ok ? r.json() : null))
107
145
  .catch(() => null),
108
- ]).then(([integrationsData, connectorsData, pluginsData, serversData]) => {
146
+ ]).then(([integrationsData, connectionsData, pluginsData, serversData]) => {
109
147
  if (!live)
110
148
  return;
111
149
  // A plugin the org built, or an MCP server it added: Customize's own lists.
@@ -113,45 +151,22 @@ export function Setup({ go } = {}) {
113
151
  const added = Array.isArray(serversData?.servers) ? serversData.servers.length : 0;
114
152
  if (built + added > 0)
115
153
  setPluginDone(true);
116
- const providers = Array.isArray(integrationsData?.providers)
117
- ? integrationsData.providers
118
- : null;
119
- const connectors = Array.isArray(connectorsData?.connectors)
120
- ? connectorsData.connectors
121
- : null;
122
- if (!providers && !connectors)
154
+ const found = linked(integrationsData, connectionsData);
155
+ if (!found)
123
156
  return;
124
- const connectedSet = new Set();
125
- const discoveredGoogleAccounts = [];
126
- if (providers) {
127
- for (const p of providers) {
128
- if (p.connected) {
129
- const id = String(p.id);
130
- connectedSet.add(id);
131
- const conn = p.connection;
132
- if (id === 'google' && typeof conn?.account === 'string' && conn.account.trim()) {
133
- discoveredGoogleAccounts.push(conn.account.trim().toLowerCase());
134
- }
135
- }
136
- }
137
- }
138
- if (connectors) {
139
- for (const c of connectors) {
140
- const prov = String(c.provider);
141
- connectedSet.add(prov);
142
- if (prov === 'google' && typeof c.account === 'string' && c.account.trim()) {
143
- discoveredGoogleAccounts.push(c.account.trim().toLowerCase());
144
- }
145
- }
146
- }
147
- const remoteGithub = connectedSet.has('github') || connectedSet.has('github-copilot');
157
+ const connectedSet = found.ids;
158
+ const discoveredGoogleAccounts = found.google;
148
159
  const remoteSlack = connectedSet.has('slack');
149
160
  const remoteGoogle = connectedSet.has('google') ||
150
161
  connectedSet.has('gmail') ||
151
162
  connectedSet.has('google-drive') ||
152
163
  connectedSet.has('google-calendar');
153
- if (remoteGithub)
154
- setGithubDone(true);
164
+ // GitHub follows what is connected, both ways, so a Disconnect on Projects
165
+ // reads here too; a half answer only ever adds it.
166
+ if (found.whole || found.github)
167
+ setGithubDone(found.github);
168
+ if (found.whole || found.own)
169
+ setGithubOwn(found.own);
155
170
  if (remoteSlack)
156
171
  setSlackDone(true);
157
172
  if (remoteGoogle)
@@ -283,7 +298,8 @@ export function Setup({ go } = {}) {
283
298
  setGithubDone(true);
284
299
  setStep(slackDone ? 3 : 2);
285
300
  });
286
- // Let go of the org's GitHub accounts, so another can be connected. The platform
301
+ // Let go of GitHub, so another account can be connected, as Projects does: the
302
+ // reader's own link first, else the org's GitHub accounts. For those the platform
287
303
  // also removes its App from an account no other organization uses, so the next
288
304
  // connect is a fresh install. An org admin's act: anyone else is told so.
289
305
  const handleDisconnectGithub = async () => {
@@ -294,13 +310,13 @@ export function Setup({ go } = {}) {
294
310
  setBusy('github');
295
311
  setErrorMsg(null);
296
312
  try {
297
- const res = await fetch(`${api()}/v1/provider/github/disconnect`, {
313
+ const res = await fetch(`${api()}${leaving(githubOwn)}`, {
298
314
  method: 'POST',
299
315
  headers: { ...scope(), 'Content-Type': 'application/json' },
300
316
  body: '{}',
301
317
  });
302
318
  if (!res.ok) {
303
- setErrorMsg(res.status === 403
319
+ setErrorMsg(res.status === 403 && !githubOwn
304
320
  ? t('Only an organization admin can disconnect GitHub.')
305
321
  : t('Could not disconnect {provider} right now. Please try again.', { provider: 'GitHub' }));
306
322
  return;
@@ -188,6 +188,15 @@ export declare const ORG = "hanzo:org";
188
188
  * answers, so the gate does not ask for it again.
189
189
  */
190
190
  export declare function pick(o: string): void;
191
+ /**
192
+ * Open the app again in this organization: the SDK's selection, written and
193
+ * NOT announced, then the reload. For an organization the token in memory does
194
+ * not name yet (one just made, one stepped into): announced, the rooms remount
195
+ * before the reload under that token, and @hanzo/iam's provider, finding the
196
+ * organization missing from it, writes the token's first organization back over
197
+ * the choice (useOrganizations), so the reload opened the wrong one.
198
+ */
199
+ export declare function reopen(o: string): void;
191
200
  /** Fired on `window` to open the organization chooser over the shell. */
192
201
  export declare const CHOOSE = "hanzo:org:choose";
193
202
  /** Open the chooser (`Gate`): every organization of the person's, and every one for a SuperAdmin. */
@@ -459,13 +459,28 @@ export const ORG = 'hanzo:org';
459
459
  * answers, so the gate does not ask for it again.
460
460
  */
461
461
  export function pick(o) {
462
+ keep(o);
463
+ window.dispatchEvent(new Event(ORG));
464
+ }
465
+ function keep(o) {
462
466
  try {
463
467
  window.localStorage.setItem(`${PREFIX}current_org`, o);
464
468
  }
465
469
  catch {
466
470
  /* the choice lives only in this page */
467
471
  }
468
- window.dispatchEvent(new Event(ORG));
472
+ }
473
+ /**
474
+ * Open the app again in this organization: the SDK's selection, written and
475
+ * NOT announced, then the reload. For an organization the token in memory does
476
+ * not name yet (one just made, one stepped into): announced, the rooms remount
477
+ * before the reload under that token, and @hanzo/iam's provider, finding the
478
+ * organization missing from it, writes the token's first organization back over
479
+ * the choice (useOrganizations), so the reload opened the wrong one.
480
+ */
481
+ export function reopen(o) {
482
+ keep(o);
483
+ window.location.reload();
469
484
  }
470
485
  /** Fired on `window` to open the organization chooser over the shell. */
471
486
  export const CHOOSE = 'hanzo:org:choose';
@@ -518,8 +533,7 @@ export async function support(org) {
518
533
  throw new Error(body?.msg || `IAM answered ${res.status}.`);
519
534
  tokens().setItem(ACCESS, next);
520
535
  tokens().setItem(EXPIRES, String(exp * 1000));
521
- pick(org ?? opened(next)[0] ?? '');
522
- window.location.reload();
536
+ reopen(org ?? opened(next)[0] ?? '');
523
537
  }
524
538
  /**
525
539
  * Leave support mode when IAM cannot answer the step out: the stored token is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",