@hanzo/app 0.2.64 → 0.2.66

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/Me.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/Orgs.js CHANGED
@@ -44,7 +44,7 @@ import { useHost } 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';
@@ -714,8 +714,7 @@ function Found({ onClose }) {
714
714
  throw new Error(t('{org} is made, and it is still called {org}: {reason}', { org: made, reason: say(err, t) }));
715
715
  });
716
716
  }
717
- pick(made);
718
- window.location.reload();
717
+ reopen(made);
719
718
  }
720
719
  catch (err) {
721
720
  setRefused(say(err, t));
package/dist/Setup.d.ts CHANGED
@@ -3,6 +3,29 @@ 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";
23
+ /**
24
+ * Said on the window when GitHub's connection changes, here or on Projects and
25
+ * Settings (@hanzo/build, which says and hears the same name), so each reads it
26
+ * again without a reload. Setup hears its own word too.
27
+ */
28
+ export declare const GITHUB_CHANGED = "hanzo:github";
6
29
  export declare function Setup({ go }?: {
7
30
  go?: (address: string) => void;
8
31
  }): import("react").JSX.Element;
package/dist/Setup.js CHANGED
@@ -40,6 +40,50 @@ 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');
80
+ /**
81
+ * Said on the window when GitHub's connection changes, here or on Projects and
82
+ * Settings (@hanzo/build, which says and hears the same name), so each reads it
83
+ * again without a reload. Setup hears its own word too.
84
+ */
85
+ export const GITHUB_CHANGED = 'hanzo:github';
86
+ const changed = () => window.dispatchEvent(new Event(GITHUB_CHANGED));
43
87
  /** Inline Slack Mark */
44
88
  function SlackMark({ size = 18 }) {
45
89
  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 +105,7 @@ export function Setup({ go } = {}) {
61
105
  const [errorMsg, setErrorMsg] = useState(null);
62
106
  // A first press on Disconnect asks; the second lets go of GitHub.
63
107
  const [dropping, setDropping] = useState(false);
108
+ const [githubOwn, setGithubOwn] = useState(false);
64
109
  const [syncTurn, setSyncTurn] = useState(0);
65
110
  const signed = isAuthenticated && Boolean(accessToken);
66
111
  const accountList = Array.isArray(googleAccounts) ? googleAccounts : [];
@@ -105,7 +150,7 @@ export function Setup({ go } = {}) {
105
150
  fetch(`${api()}/v1/tool/mcp/servers`, { headers: auth })
106
151
  .then((r) => (r.ok ? r.json() : null))
107
152
  .catch(() => null),
108
- ]).then(([integrationsData, connectorsData, pluginsData, serversData]) => {
153
+ ]).then(([integrationsData, connectionsData, pluginsData, serversData]) => {
109
154
  if (!live)
110
155
  return;
111
156
  // A plugin the org built, or an MCP server it added: Customize's own lists.
@@ -113,45 +158,22 @@ export function Setup({ go } = {}) {
113
158
  const added = Array.isArray(serversData?.servers) ? serversData.servers.length : 0;
114
159
  if (built + added > 0)
115
160
  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)
161
+ const found = linked(integrationsData, connectionsData);
162
+ if (!found)
123
163
  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');
164
+ const connectedSet = found.ids;
165
+ const discoveredGoogleAccounts = found.google;
148
166
  const remoteSlack = connectedSet.has('slack');
149
167
  const remoteGoogle = connectedSet.has('google') ||
150
168
  connectedSet.has('gmail') ||
151
169
  connectedSet.has('google-drive') ||
152
170
  connectedSet.has('google-calendar');
153
- if (remoteGithub)
154
- setGithubDone(true);
171
+ // GitHub follows what is connected, both ways, so a Disconnect on Projects
172
+ // reads here too; a half answer only ever adds it.
173
+ if (found.whole || found.github)
174
+ setGithubDone(found.github);
175
+ if (found.whole || found.own)
176
+ setGithubOwn(found.own);
155
177
  if (remoteSlack)
156
178
  setSlackDone(true);
157
179
  if (remoteGoogle)
@@ -167,7 +189,8 @@ export function Setup({ go } = {}) {
167
189
  live = false;
168
190
  };
169
191
  }, [signed, syncTurn]);
170
- // Listen for postMessage completion from /auth/callback popup and focus/visibility return
192
+ // Listen for postMessage completion from /auth/callback popup, focus/visibility return,
193
+ // and GitHub changed on this page (here, on Projects or in Settings)
171
194
  useEffect(() => {
172
195
  if (typeof window === 'undefined')
173
196
  return;
@@ -189,13 +212,16 @@ export function Setup({ go } = {}) {
189
212
  }
190
213
  };
191
214
  const onFocus = () => setSyncTurn((n) => n + 1);
215
+ const onGithub = () => setSyncTurn((n) => n + 1);
192
216
  window.addEventListener('message', onMessage);
193
217
  document.addEventListener('visibilitychange', onReturn);
194
218
  window.addEventListener('focus', onFocus);
219
+ window.addEventListener(GITHUB_CHANGED, onGithub);
195
220
  return () => {
196
221
  window.removeEventListener('message', onMessage);
197
222
  document.removeEventListener('visibilitychange', onReturn);
198
223
  window.removeEventListener('focus', onFocus);
224
+ window.removeEventListener(GITHUB_CHANGED, onGithub);
199
225
  };
200
226
  }, [signed, googleAccounts]);
201
227
  const totalDone = (githubDone ? 1 : 0) + (slackDone ? 1 : 0) + (pluginDone ? 1 : 0);
@@ -211,13 +237,17 @@ export function Setup({ go } = {}) {
211
237
  return;
212
238
  }
213
239
  // The return page hands the answer back and closes the popup (lib/oauth);
214
- // a popup closed without one still re-reads what is connected.
240
+ // a popup closed without one still re-reads what is connected. GitHub's is
241
+ // said on the page, so Projects reads it too.
215
242
  awaitAnswer(popup, provider, (answer) => {
216
243
  if (answer?.ok)
217
244
  onDone();
218
245
  else if (answer)
219
246
  setErrorMsg(t('Could not connect {provider} right now. Please try again.', { provider: label }));
220
- setSyncTurn((n) => n + 1);
247
+ if (provider === 'github')
248
+ changed();
249
+ else
250
+ setSyncTurn((n) => n + 1);
221
251
  });
222
252
  };
223
253
  const connectOAuthProvider = async (provider, label, onDone) => {
@@ -283,7 +313,8 @@ export function Setup({ go } = {}) {
283
313
  setGithubDone(true);
284
314
  setStep(slackDone ? 3 : 2);
285
315
  });
286
- // Let go of the org's GitHub accounts, so another can be connected. The platform
316
+ // Let go of GitHub, so another account can be connected, as Projects does: the
317
+ // reader's own link first, else the org's GitHub accounts. For those the platform
287
318
  // also removes its App from an account no other organization uses, so the next
288
319
  // connect is a fresh install. An org admin's act: anyone else is told so.
289
320
  const handleDisconnectGithub = async () => {
@@ -294,20 +325,21 @@ export function Setup({ go } = {}) {
294
325
  setBusy('github');
295
326
  setErrorMsg(null);
296
327
  try {
297
- const res = await fetch(`${api()}/v1/provider/github/disconnect`, {
328
+ const res = await fetch(`${api()}${leaving(githubOwn)}`, {
298
329
  method: 'POST',
299
330
  headers: { ...scope(), 'Content-Type': 'application/json' },
300
331
  body: '{}',
301
332
  });
302
333
  if (!res.ok) {
303
- setErrorMsg(res.status === 403
334
+ setErrorMsg(res.status === 403 && !githubOwn
304
335
  ? t('Only an organization admin can disconnect GitHub.')
305
336
  : t('Could not disconnect {provider} right now. Please try again.', { provider: 'GitHub' }));
306
337
  return;
307
338
  }
308
339
  setGithubDone(false);
309
340
  setStep(1);
310
- setSyncTurn((n) => n + 1);
341
+ // Projects reads it again, and so does this card.
342
+ changed();
311
343
  }
312
344
  catch {
313
345
  setErrorMsg(t('Could not disconnect {provider} right now. Please try again.', { provider: 'GitHub' }));
package/dist/chord.d.ts CHANGED
@@ -9,6 +9,8 @@ export interface Press {
9
9
  shiftKey: boolean;
10
10
  repeat?: boolean;
11
11
  isComposing?: boolean;
12
+ /** Something on the page already answered the press. */
13
+ defaultPrevented?: boolean;
12
14
  target: EventTarget | null;
13
15
  }
14
16
  /** Whether a key pressed on `target` is typing: a field, a picker, or text that edits itself. */
@@ -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 room. */
192
201
  export declare const CHOOSE = "hanzo:org:choose";
193
202
  /** Open the chooser (`Orgs`): 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 room. */
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/dist/seek.d.ts CHANGED
@@ -35,5 +35,8 @@ export declare function rank<T extends Hit>(rows: T[], query: string, cap?: numb
35
35
  * first, ties in the order given.
36
36
  */
37
37
  export declare function find<T extends Hit>(query: string, recent: T[], idle: Group<T>[], all: Group<T>[]): Group<T>[];
38
- /** Whether a key press opens the palette: ⌘K or Ctrl+K, once a press, from anywhere, a field included. */
38
+ /**
39
+ * Whether a key press opens the palette: ⌘K or Ctrl+K, once a press, from anywhere, a field included,
40
+ * unless something on the page already answered it (Dev's composer opens its own commands and claims it).
41
+ */
39
42
  export declare const summons: (e: Press) => boolean;
package/dist/seek.js CHANGED
@@ -76,5 +76,8 @@ export function find(query, recent, idle, all) {
76
76
  .sort((a, b) => b.best - a.best || a.i - b.i)
77
77
  .map((x) => x.g);
78
78
  }
79
- /** Whether a key press opens the palette: ⌘K or Ctrl+K, once a press, from anywhere, a field included. */
80
- export const summons = (e) => (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && !e.repeat && !e.isComposing && (e.key ?? '').toLowerCase() === 'k';
79
+ /**
80
+ * Whether a key press opens the palette: ⌘K or Ctrl+K, once a press, from anywhere, a field included,
81
+ * unless something on the page already answered it (Dev's composer opens its own commands and claims it).
82
+ */
83
+ export const summons = (e) => !e.defaultPrevented && (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && !e.repeat && !e.isComposing && (e.key ?? '').toLowerCase() === 'k';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.2.64",
3
+ "version": "0.2.66",
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",