@hanzo/app 0.2.21 → 0.2.23
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/Chat.js +10 -0
- package/dist/Setup.d.ts +10 -0
- package/dist/Setup.js +248 -53
- package/dist/ThinkingEffort.d.ts +1 -1
- package/dist/ThinkingEffort.js +2 -2
- package/dist/lib/chatPreferences.js +1 -1
- package/package.json +1 -1
package/dist/Chat.js
CHANGED
|
@@ -512,6 +512,16 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
512
512
|
const mind = useMind(target, anonymous ? "free" : limits?.plan);
|
|
513
513
|
catalog.current = mind.models;
|
|
514
514
|
const [chatPrefs, setChatPrefs] = useChatPreferences();
|
|
515
|
+
useEffect(() => {
|
|
516
|
+
const eff = chatPrefs.effort || "high";
|
|
517
|
+
if (eff === "low" || eff === "medium" || eff === "high") {
|
|
518
|
+
mind.pace(eff);
|
|
519
|
+
}
|
|
520
|
+
else if (eff === "xhigh" || eff === "max") {
|
|
521
|
+
mind.pace("high");
|
|
522
|
+
}
|
|
523
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
524
|
+
}, [chatPrefs.effort]);
|
|
515
525
|
const ai = useAi();
|
|
516
526
|
// In the app's frame the composer floats on the pane as a pane of its own.
|
|
517
527
|
const framed = useContext(Framed);
|
package/dist/Setup.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
export declare const LATER_KEY = "hanzo.onboarding.later";
|
|
2
|
+
export declare const GITHUB_KEY = "hanzo.onboarding.github";
|
|
3
|
+
export declare const SLACK_KEY = "hanzo.onboarding.slack";
|
|
4
|
+
export declare const GOOGLE_KEY = "hanzo.onboarding.google.v2";
|
|
5
|
+
export declare const GOOGLE_ACCOUNTS_KEY = "hanzo.onboarding.google.accounts";
|
|
6
|
+
export declare const GOOGLE_TOKENS_KEY = "hanzo.onboarding.google.tokens";
|
|
7
|
+
export declare const STEP_KEY = "hanzo.onboarding.step";
|
|
8
|
+
export declare const DEFAULT_GOOGLE_CLIENT_ID = "113591532635-s8pvqrebprkbndluhftddmdap4htvu1p.apps.googleusercontent.com";
|
|
9
|
+
export declare const GOOGLE_WORKSPACE_SCOPES: string;
|
|
10
|
+
export declare function buildGoogleWorkspaceAuthorizeUrl(origin: string, clientId?: string, state?: string): string;
|
|
1
11
|
export declare function Setup(): import("react").JSX.Element;
|
package/dist/Setup.js
CHANGED
|
@@ -1,29 +1,56 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// The 1-2-3 in-app onboarding: Connect GitHub, Connect Slack, Connect Google
|
|
3
|
+
// The 1-2-3 in-app onboarding: Connect GitHub, Connect Slack, Connect Google Workspace.
|
|
4
4
|
// Runs INSIDE the app as a compact card in the sidebar column and as an interactive
|
|
5
5
|
// popup modal dialog. Never a full-screen redirect away from the user's workspace.
|
|
6
6
|
//
|
|
7
7
|
// 1. GitHub: Sync repositories, PRs, and team repository context
|
|
8
8
|
// 2. Slack: Route notifications, agent conversations, and bot alerts
|
|
9
|
-
// 3. Google: Connect
|
|
9
|
+
// 3. Google: Connect Google Drive, Docs, Sheets, Gmail & Calendar across one or many Google accounts (personal, work, multiple orgs)
|
|
10
10
|
import { useEffect, useState } from 'react';
|
|
11
11
|
import { useI18n } from '@hanzo/i18n/react';
|
|
12
12
|
import { Box, Dialog, DialogContent, DialogTitle, SizableText, Text, XStack, YStack } from '@hanzo/ui';
|
|
13
13
|
import { useIam } from '@hanzo/iam/react';
|
|
14
|
-
import { Check, Maximize2, Sparkles, X } from 'lucide-react';
|
|
14
|
+
import { Check, Maximize2, Plus, Sparkles, X } from 'lucide-react';
|
|
15
15
|
import { ProviderMark } from './ProviderMark.js';
|
|
16
16
|
import { useKept } from './kept.js';
|
|
17
17
|
import { api } from './lib/api.js';
|
|
18
|
+
import { answers } from './lib/host.js';
|
|
18
19
|
import { scope } from './lib/session.js';
|
|
19
20
|
import { enter } from './lib/destination.js';
|
|
20
21
|
import { brand } from './where.js';
|
|
21
22
|
import { GOOD } from './lib/mix.js';
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
23
|
+
const here = () => typeof window !== 'undefined' && answers(window.location.hostname);
|
|
24
|
+
export const LATER_KEY = 'hanzo.onboarding.later';
|
|
25
|
+
export const GITHUB_KEY = 'hanzo.onboarding.github';
|
|
26
|
+
export const SLACK_KEY = 'hanzo.onboarding.slack';
|
|
27
|
+
export const GOOGLE_KEY = 'hanzo.onboarding.google.v2';
|
|
28
|
+
export const GOOGLE_ACCOUNTS_KEY = 'hanzo.onboarding.google.accounts';
|
|
29
|
+
export const GOOGLE_TOKENS_KEY = 'hanzo.onboarding.google.tokens';
|
|
30
|
+
export const STEP_KEY = 'hanzo.onboarding.step';
|
|
31
|
+
export const DEFAULT_GOOGLE_CLIENT_ID = '113591532635-s8pvqrebprkbndluhftddmdap4htvu1p.apps.googleusercontent.com';
|
|
32
|
+
export const GOOGLE_WORKSPACE_SCOPES = [
|
|
33
|
+
'openid',
|
|
34
|
+
'email',
|
|
35
|
+
'profile',
|
|
36
|
+
'https://www.googleapis.com/auth/drive',
|
|
37
|
+
'https://www.googleapis.com/auth/documents',
|
|
38
|
+
'https://www.googleapis.com/auth/spreadsheets',
|
|
39
|
+
'https://www.googleapis.com/auth/gmail.modify',
|
|
40
|
+
'https://www.googleapis.com/auth/calendar',
|
|
41
|
+
].join(' ');
|
|
42
|
+
export function buildGoogleWorkspaceAuthorizeUrl(origin, clientId = DEFAULT_GOOGLE_CLIENT_ID, state = 'gws') {
|
|
43
|
+
const cleanOrigin = origin.replace(/\/+$/, '');
|
|
44
|
+
const u = new URL('https://accounts.google.com/o/oauth2/v2/auth');
|
|
45
|
+
u.searchParams.set('client_id', clientId || DEFAULT_GOOGLE_CLIENT_ID);
|
|
46
|
+
u.searchParams.set('redirect_uri', `${cleanOrigin}/v1/iam/oauth/callback`);
|
|
47
|
+
u.searchParams.set('response_type', 'token');
|
|
48
|
+
u.searchParams.set('scope', GOOGLE_WORKSPACE_SCOPES);
|
|
49
|
+
u.searchParams.set('include_granted_scopes', 'true');
|
|
50
|
+
u.searchParams.set('prompt', 'select_account consent');
|
|
51
|
+
u.searchParams.set('state', state);
|
|
52
|
+
return u.toString();
|
|
53
|
+
}
|
|
27
54
|
/** Inline Slack Mark */
|
|
28
55
|
function SlackMark({ size = 18 }) {
|
|
29
56
|
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" })] }));
|
|
@@ -36,12 +63,59 @@ export function Setup() {
|
|
|
36
63
|
const [githubDone, setGithubDone] = useKept(GITHUB_KEY, false);
|
|
37
64
|
const [slackDone, setSlackDone] = useKept(SLACK_KEY, false);
|
|
38
65
|
const [googleDone, setGoogleDone] = useKept(GOOGLE_KEY, false);
|
|
66
|
+
const [googleAccounts, setGoogleAccounts] = useKept(GOOGLE_ACCOUNTS_KEY, []);
|
|
39
67
|
const [busy, setBusy] = useState(null);
|
|
40
68
|
const [modalOpen, setModalOpen] = useState(false);
|
|
41
69
|
const [errorMsg, setErrorMsg] = useState(null);
|
|
42
70
|
const [syncTurn, setSyncTurn] = useState(0);
|
|
43
71
|
const signed = isAuthenticated && Boolean(accessToken);
|
|
44
|
-
|
|
72
|
+
const accountList = Array.isArray(googleAccounts) ? googleAccounts : [];
|
|
73
|
+
const hasGoogle = googleDone || accountList.length > 0;
|
|
74
|
+
const addGoogleAccount = (rawEmail, tokenData) => {
|
|
75
|
+
const clean = rawEmail.trim().toLowerCase();
|
|
76
|
+
const current = Array.isArray(googleAccounts) ? googleAccounts : [];
|
|
77
|
+
const next = clean && !current.includes(clean) ? [...current, clean] : current;
|
|
78
|
+
setGoogleAccounts(next);
|
|
79
|
+
setGoogleDone(true);
|
|
80
|
+
if (typeof window !== 'undefined' && tokenData?.accessToken) {
|
|
81
|
+
try {
|
|
82
|
+
const rawTokens = window.localStorage.getItem(GOOGLE_TOKENS_KEY);
|
|
83
|
+
const parsed = rawTokens ? JSON.parse(rawTokens) : {};
|
|
84
|
+
parsed[clean || 'default'] = {
|
|
85
|
+
accessToken: tokenData.accessToken,
|
|
86
|
+
scope: tokenData.scope || GOOGLE_WORKSPACE_SCOPES,
|
|
87
|
+
connectedAt: new Date().toISOString(),
|
|
88
|
+
};
|
|
89
|
+
window.localStorage.setItem(GOOGLE_TOKENS_KEY, JSON.stringify(parsed));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// ignore storage errors
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const removeGoogleAccount = (targetEmail) => {
|
|
97
|
+
const current = Array.isArray(googleAccounts) ? googleAccounts : [];
|
|
98
|
+
const next = current.filter((a) => a !== targetEmail);
|
|
99
|
+
setGoogleAccounts(next);
|
|
100
|
+
if (next.length === 0) {
|
|
101
|
+
setGoogleDone(false);
|
|
102
|
+
}
|
|
103
|
+
if (typeof window !== 'undefined') {
|
|
104
|
+
try {
|
|
105
|
+
const rawTokens = window.localStorage.getItem(GOOGLE_TOKENS_KEY);
|
|
106
|
+
if (rawTokens) {
|
|
107
|
+
const parsed = JSON.parse(rawTokens);
|
|
108
|
+
delete parsed[targetEmail];
|
|
109
|
+
window.localStorage.setItem(GOOGLE_TOKENS_KEY, JSON.stringify(parsed));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// ignore
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
// Sync with remote workspace integrations & connectors (never from IAM login linked-accounts,
|
|
118
|
+
// because basic IAM sign-in does not grant Google Drive/Docs/Sheets/Gmail/Calendar permissions).
|
|
45
119
|
useEffect(() => {
|
|
46
120
|
if (!signed)
|
|
47
121
|
return;
|
|
@@ -66,70 +140,187 @@ export function Setup() {
|
|
|
66
140
|
if (!providers && !connectors)
|
|
67
141
|
return;
|
|
68
142
|
const connectedSet = new Set();
|
|
143
|
+
const discoveredGoogleAccounts = [];
|
|
69
144
|
if (providers) {
|
|
70
145
|
for (const p of providers) {
|
|
71
|
-
if (p.connected)
|
|
72
|
-
|
|
146
|
+
if (p.connected) {
|
|
147
|
+
const id = String(p.id);
|
|
148
|
+
connectedSet.add(id);
|
|
149
|
+
const conn = p.connection;
|
|
150
|
+
if (id === 'google' && typeof conn?.account === 'string' && conn.account.trim()) {
|
|
151
|
+
discoveredGoogleAccounts.push(conn.account.trim().toLowerCase());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
73
154
|
}
|
|
74
155
|
}
|
|
75
156
|
if (connectors) {
|
|
76
157
|
for (const c of connectors) {
|
|
77
|
-
|
|
158
|
+
const prov = String(c.provider);
|
|
159
|
+
connectedSet.add(prov);
|
|
160
|
+
if (prov === 'google' && typeof c.account === 'string' && c.account.trim()) {
|
|
161
|
+
discoveredGoogleAccounts.push(c.account.trim().toLowerCase());
|
|
162
|
+
}
|
|
78
163
|
}
|
|
79
164
|
}
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
165
|
+
const remoteGithub = connectedSet.has('github') || connectedSet.has('github-copilot');
|
|
166
|
+
const remoteSlack = connectedSet.has('slack');
|
|
167
|
+
const remoteGoogle = connectedSet.has('google') ||
|
|
83
168
|
connectedSet.has('gmail') ||
|
|
84
169
|
connectedSet.has('google-drive') ||
|
|
85
170
|
connectedSet.has('google-calendar');
|
|
86
|
-
if (
|
|
87
|
-
setGithubDone(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setGoogleDone(true);
|
|
171
|
+
if (remoteGithub)
|
|
172
|
+
setGithubDone(true);
|
|
173
|
+
if (remoteSlack)
|
|
174
|
+
setSlackDone(true);
|
|
175
|
+
if (remoteGoogle)
|
|
176
|
+
setGoogleDone(true);
|
|
177
|
+
if (discoveredGoogleAccounts.length > 0) {
|
|
178
|
+
const merged = Array.from(new Set([...accountList, ...discoveredGoogleAccounts]));
|
|
179
|
+
if (merged.length !== accountList.length) {
|
|
180
|
+
setGoogleAccounts(merged);
|
|
181
|
+
}
|
|
98
182
|
}
|
|
99
183
|
});
|
|
100
184
|
return () => {
|
|
101
185
|
live = false;
|
|
102
186
|
};
|
|
103
187
|
}, [signed, syncTurn]);
|
|
188
|
+
// Listen for postMessage completion from /auth/callback popup and focus/visibility return
|
|
104
189
|
useEffect(() => {
|
|
105
|
-
if (
|
|
190
|
+
if (typeof window === 'undefined')
|
|
106
191
|
return;
|
|
192
|
+
const onMessage = (ev) => {
|
|
193
|
+
if (ev.origin !== window.location.origin)
|
|
194
|
+
return;
|
|
195
|
+
const data = ev.data;
|
|
196
|
+
if (data?.type === 'hanzo-google-workspace-connected') {
|
|
197
|
+
addGoogleAccount(data.email || '', {
|
|
198
|
+
accessToken: data.accessToken || '',
|
|
199
|
+
scope: data.scope,
|
|
200
|
+
});
|
|
201
|
+
setSyncTurn((n) => n + 1);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
107
204
|
const onReturn = () => {
|
|
108
205
|
if (document.visibilityState === 'visible') {
|
|
109
206
|
setSyncTurn((n) => n + 1);
|
|
110
207
|
}
|
|
111
208
|
};
|
|
112
209
|
const onFocus = () => setSyncTurn((n) => n + 1);
|
|
210
|
+
window.addEventListener('message', onMessage);
|
|
113
211
|
document.addEventListener('visibilitychange', onReturn);
|
|
114
212
|
window.addEventListener('focus', onFocus);
|
|
115
213
|
return () => {
|
|
214
|
+
window.removeEventListener('message', onMessage);
|
|
116
215
|
document.removeEventListener('visibilitychange', onReturn);
|
|
117
216
|
window.removeEventListener('focus', onFocus);
|
|
118
217
|
};
|
|
119
|
-
}, [signed]);
|
|
120
|
-
const totalDone = (githubDone ? 1 : 0) + (slackDone ? 1 : 0) + (
|
|
218
|
+
}, [signed, googleAccounts]);
|
|
219
|
+
const totalDone = (githubDone ? 1 : 0) + (slackDone ? 1 : 0) + (hasGoogle ? 1 : 0);
|
|
121
220
|
const allDone = totalDone === 3;
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (step === 1 && githubDone)
|
|
125
|
-
setStep(slackDone ? 3 : 2);
|
|
126
|
-
else if (step === 2 && slackDone)
|
|
127
|
-
setStep(googleDone ? 1 : 3);
|
|
128
|
-
else if (step === 3 && googleDone && (!githubDone || !slackDone))
|
|
129
|
-
setStep(!githubDone ? 1 : 2);
|
|
130
|
-
}, [githubDone, slackDone, googleDone, step]);
|
|
221
|
+
const activeStep = step === 1 || step === 2 || step === 3 ? step : 1;
|
|
131
222
|
if (later && !modalOpen)
|
|
132
223
|
return null;
|
|
224
|
+
const completeGoogleToken = async (accessTokenValue, grantedScope, onDone) => {
|
|
225
|
+
let email = '';
|
|
226
|
+
try {
|
|
227
|
+
const userRes = await fetch('https://www.googleapis.com/oauth2/v2/userinfo', {
|
|
228
|
+
headers: { Authorization: `Bearer ${accessTokenValue}` },
|
|
229
|
+
});
|
|
230
|
+
if (userRes.ok) {
|
|
231
|
+
const userJson = (await userRes.json());
|
|
232
|
+
if (typeof userJson?.email === 'string') {
|
|
233
|
+
email = userJson.email.trim().toLowerCase();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// best-effort userinfo fetch
|
|
239
|
+
}
|
|
240
|
+
addGoogleAccount(email, {
|
|
241
|
+
accessToken: accessTokenValue,
|
|
242
|
+
scope: grantedScope || GOOGLE_WORKSPACE_SCOPES,
|
|
243
|
+
});
|
|
244
|
+
// Best-effort custody sync with backend
|
|
245
|
+
fetch(`${api()}/v1/integrations/google/connect`, {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
248
|
+
body: JSON.stringify({ token: accessTokenValue, accountId: email }),
|
|
249
|
+
}).catch(() => null);
|
|
250
|
+
onDone();
|
|
251
|
+
};
|
|
252
|
+
const openOAuthPopup = (authorizeUrl, provider, onDone) => {
|
|
253
|
+
const popup = window.open(authorizeUrl, `hanzo-oauth-${provider}`, 'width=600,height=700');
|
|
254
|
+
if (!popup) {
|
|
255
|
+
window.open(authorizeUrl, '_blank', 'noopener,noreferrer');
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
const timer = window.setInterval(() => {
|
|
259
|
+
if (popup.closed) {
|
|
260
|
+
window.clearInterval(timer);
|
|
261
|
+
setSyncTurn((n) => n + 1);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (provider === 'google') {
|
|
265
|
+
try {
|
|
266
|
+
if (popup.location.origin === window.location.origin) {
|
|
267
|
+
const hash = popup.location.hash || '';
|
|
268
|
+
if (hash.includes('access_token=') || hash.includes('error=')) {
|
|
269
|
+
const params = new URLSearchParams(hash.replace(/^#/, ''));
|
|
270
|
+
const tokenVal = params.get('access_token');
|
|
271
|
+
const scopeVal = params.get('scope');
|
|
272
|
+
window.clearInterval(timer);
|
|
273
|
+
popup.close();
|
|
274
|
+
if (tokenVal) {
|
|
275
|
+
void completeGoogleToken(tokenVal, scopeVal, onDone);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Cross-origin while user is on accounts.google.com; ignore until callback redirects to same origin
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, 250);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const resolveGoogleWorkspaceUrl = async () => {
|
|
288
|
+
let clientId = DEFAULT_GOOGLE_CLIENT_ID;
|
|
289
|
+
try {
|
|
290
|
+
const res = await fetch(`${api()}/v1/integrations/google/connect`, {
|
|
291
|
+
method: 'POST',
|
|
292
|
+
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
293
|
+
body: '{}',
|
|
294
|
+
}).catch(() => null);
|
|
295
|
+
if (res?.ok) {
|
|
296
|
+
const j = (await res.json().catch(() => null));
|
|
297
|
+
if (j?.authorizeUrl) {
|
|
298
|
+
try {
|
|
299
|
+
const parsed = new URL(j.authorizeUrl);
|
|
300
|
+
const cid = parsed.searchParams.get('client_id');
|
|
301
|
+
if (cid)
|
|
302
|
+
clientId = cid;
|
|
303
|
+
if (!here()) {
|
|
304
|
+
parsed.searchParams.set('scope', GOOGLE_WORKSPACE_SCOPES);
|
|
305
|
+
parsed.searchParams.set('access_type', 'offline');
|
|
306
|
+
parsed.searchParams.set('include_granted_scopes', 'true');
|
|
307
|
+
parsed.searchParams.set('prompt', 'select_account consent');
|
|
308
|
+
return parsed.toString();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// fall through
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
// fall through
|
|
319
|
+
}
|
|
320
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : 'https://hanzo.ai';
|
|
321
|
+
const state = `gws_${Date.now().toString(36)}`;
|
|
322
|
+
return buildGoogleWorkspaceAuthorizeUrl(origin, clientId, state);
|
|
323
|
+
};
|
|
133
324
|
const connectOAuthProvider = async (provider, label, onDone) => {
|
|
134
325
|
if (!signed) {
|
|
135
326
|
enter();
|
|
@@ -138,6 +329,11 @@ export function Setup() {
|
|
|
138
329
|
setBusy(provider);
|
|
139
330
|
setErrorMsg(null);
|
|
140
331
|
try {
|
|
332
|
+
if (provider === 'google') {
|
|
333
|
+
const googleUrl = await resolveGoogleWorkspaceUrl();
|
|
334
|
+
openOAuthPopup(googleUrl, 'google', onDone);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
141
337
|
const res = await fetch(`${api()}/v1/integrations/${provider}/connect`, {
|
|
142
338
|
method: 'POST',
|
|
143
339
|
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
@@ -160,18 +356,7 @@ export function Setup() {
|
|
|
160
356
|
}
|
|
161
357
|
const j = (await res.json());
|
|
162
358
|
if (j.authorizeUrl) {
|
|
163
|
-
|
|
164
|
-
if (!popup) {
|
|
165
|
-
window.open(j.authorizeUrl, '_blank', 'noopener,noreferrer');
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const timer = window.setInterval(() => {
|
|
169
|
-
if (popup.closed) {
|
|
170
|
-
window.clearInterval(timer);
|
|
171
|
-
setSyncTurn((n) => n + 1);
|
|
172
|
-
}
|
|
173
|
-
}, 1000);
|
|
174
|
-
}
|
|
359
|
+
openOAuthPopup(j.authorizeUrl, provider, onDone);
|
|
175
360
|
}
|
|
176
361
|
else if (j.connected) {
|
|
177
362
|
onDone();
|
|
@@ -194,9 +379,19 @@ export function Setup() {
|
|
|
194
379
|
setSlackDone(true);
|
|
195
380
|
setStep(3);
|
|
196
381
|
});
|
|
197
|
-
// 3. Connect Google (
|
|
382
|
+
// 3. Connect Google Workspace (Drive, Docs, Sheets, Gmail & Calendar; supports multiple accounts)
|
|
198
383
|
const handleConnectGoogle = () => connectOAuthProvider('google', 'Google', () => {
|
|
199
384
|
setGoogleDone(true);
|
|
200
385
|
});
|
|
201
|
-
return (_jsxs(_Fragment, { children: [_jsxs(YStack, { "data-slot": "setup", role: "region", "aria-label": t('Onboarding (1-2-3)'), gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", width: "100%", overflow: "hidden", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$1.5", minW: 0, flex: 1, children: [_jsx(Sparkles, { size: 15, color: "var(--primary)", "aria-hidden": true }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: allDone ? t('Onboarding complete') : t('Quick setup ({n}/3)', { n: totalDone }) })] }), _jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Box, { render: "button", "aria-label": t('Expand onboarding popup'), onClick: () => setModalOpen(true), p: "$1", rounded: 999, hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Maximize2, { size: 13, "aria-hidden": true, color: "$soft" }) }), _jsx(Box, { render: "button", "aria-label": t('Dismiss'), onClick: () => setLater(true), p: "$1", rounded: 999, hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(X, { size: 13, "aria-hidden": true, color: "$soft" }) })] })] }), _jsxs(XStack, { gap: "$1", width: "100%", children: [_jsx(Box, { flex: 1, height: 4, rounded: 2, bg: githubDone ? GOOD : step === 1 ? '$ink' : '$edge' }), _jsx(Box, { flex: 1, height: 4, rounded: 2, bg: slackDone ? GOOD : step === 2 ? '$ink' : '$edge' }), _jsx(Box, { flex: 1, height: 4, rounded: 2, bg: googleDone ? GOOD : step === 3 ? '$ink' : '$edge' })] }), allDone ? (_jsxs(YStack, { gap: "$2", pt: "$1", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Check, { size: 16, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$ink", fontWeight: "500", children: t('GitHub, Slack & Google connected') })] }), _jsx(Box, { render: "button", onClick: () => setLater(true), p: "$1.5", rounded: "$3", bg: "$edge", hoverStyle: { bg: '$hover' }, items: "center", justify: "center", cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "500", children: t('Done') }) })] })) : step === 1 ? (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(ProviderMark, { org: "github", size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('1. Connect GitHub') })] }), githubDone ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Sync repositories, PRs, and team repository context.') }), _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectGithub, "aria-disabled": busy === 'github', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'github' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'github' ? t('Connecting…') : githubDone ? t('Reconnect') : t('Connect GitHub') }) }), _jsx(Box, { render: "button", onClick: () => setStep(2), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Skip') }) })] })] })) : step === 2 ? (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(SlackMark, { size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('2. Connect Slack') })] }), slackDone ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Route agent notifications and chat in team channels.') }), _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectSlack, "aria-disabled": busy === 'slack', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'slack' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'slack' ? t('Connecting…') : slackDone ? t('Reconnect') : t('Connect Slack') }) }), _jsx(Box, { render: "button", onClick: () => setStep(3), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Skip') }) })] })] })) : (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(ProviderMark, { org: "google", size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('3. Connect Google') })] }), googleDone ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Sync Gmail, Calendar & Drive so Hanzo can read files, draft emails & schedule meetings.') }), _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectGoogle, "aria-disabled": busy === 'google', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'google' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'google' ? t('Connecting…') : googleDone ? t('Reconnect') : t('Connect Google') }) }), _jsx(Box, { render: "button", onClick: () => setLater(true), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Skip') }) })] })] })), errorMsg ? (_jsx(Text, { fontSize: "$1", color: "$red10", children: errorMsg })) : null] }), _jsx(Dialog, { open: modalOpen, onOpenChange: setModalOpen, children: _jsxs(DialogContent, { maxW: 520, rounded: "$6", gap: "$4", p: "$5", children: [_jsx(DialogTitle, { children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Sparkles, { size: 20, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: t('Set up {brand} in 3 steps', { brand: brand() }) })] }) }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Connect your code, team chat, and Google Workspace (Gmail, Calendar & Drive) directly inside {brand}.', { brand: brand() }) }), _jsxs(YStack, { gap: "$3", children: [_jsxs(XStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: githubDone ? GOOD : '$borderColor', bg: "$raised", items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(ProviderMark, { org: "github", size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('1. GitHub') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Sync repositories, PRs, and code context') })] })] }), githubDone ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 14, color: GOOD }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : (_jsx(Box, { render: "button", onClick: handleConnectGithub, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'github' ? t('Connecting…') : t('Connect') }) }))] }), _jsxs(XStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: slackDone ? GOOD : '$borderColor', bg: "$raised", items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(SlackMark, { size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('2. Slack') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Notifications and agent bot chat in channels') })] })] }), slackDone ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 14, color: GOOD }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : (_jsx(Box, { render: "button", onClick: handleConnectSlack, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'slack' ? t('Connecting…') : t('Connect') }) }))] }), _jsxs(XStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: googleDone ? GOOD : '$borderColor', bg: "$raised", items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(ProviderMark, { org: "google", size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('3. Google Workspace (Gmail, Calendar & Drive)') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Access Docs, Sheets, Slides, Drive files, Gmail & Calendar') })] })] }), googleDone ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 14, color: GOOD }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : (_jsx(Box, { render: "button", onClick: handleConnectGoogle, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'google' ? t('Connecting…') : t('Connect') }) }))] })] }), _jsx(XStack, { justify: "flex-end", pt: "$2", children: _jsx(Box, { render: "button", onClick: () => setModalOpen(false), px: "$4", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Close') }) }) })] }) })] }));
|
|
386
|
+
return (_jsxs(_Fragment, { children: [_jsxs(YStack, { "data-slot": "setup", role: "region", "aria-label": t('Onboarding (1-2-3)'), gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", width: "100%", overflow: "hidden", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$1.5", minW: 0, flex: 1, children: [_jsx(Sparkles, { size: 15, color: "var(--primary)", "aria-hidden": true }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: allDone ? t('Onboarding complete') : t('Quick setup ({n}/3)', { n: totalDone }) })] }), _jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Box, { render: "button", "aria-label": t('Expand onboarding popup'), onClick: () => setModalOpen(true), p: "$1", rounded: 999, hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Maximize2, { size: 13, "aria-hidden": true, color: "$soft" }) }), _jsx(Box, { render: "button", "aria-label": t('Dismiss'), onClick: () => setLater(true), p: "$1", rounded: 999, hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(X, { size: 13, "aria-hidden": true, color: "$soft" }) })] })] }), _jsxs(XStack, { gap: "$1", width: "100%", children: [_jsx(Box, { render: "button", "aria-label": t('Step 1: Connect GitHub'), onClick: () => setStep(1), flex: 1, height: 6, rounded: 3, bg: githubDone ? GOOD : activeStep === 1 ? '$ink' : '$edge', cursor: "pointer" }), _jsx(Box, { render: "button", "aria-label": t('Step 2: Connect Slack'), onClick: () => setStep(2), flex: 1, height: 6, rounded: 3, bg: slackDone ? GOOD : activeStep === 2 ? '$ink' : '$edge', cursor: "pointer" }), _jsx(Box, { render: "button", "aria-label": t('Step 3: Connect Google'), onClick: () => setStep(3), flex: 1, height: 6, rounded: 3, bg: hasGoogle ? GOOD : activeStep === 3 ? '$ink' : '$edge', cursor: "pointer" })] }), allDone ? (_jsxs(YStack, { gap: "$2", pt: "$1", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Check, { size: 16, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$ink", fontWeight: "500", children: t('GitHub, Slack & Google connected') })] }), accountList.length > 0 ? (_jsx(XStack, { gap: "$1", flexWrap: "wrap", children: accountList.map((acct) => (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$0.5", rounded: "$2", bg: "$edge", children: [_jsx(Text, { fontSize: "$1", color: "$ink", numberOfLines: 1, children: acct }), _jsx(Box, { render: "button", "aria-label": t('Remove {account}', { account: acct }), onClick: () => removeGoogleAccount(acct), cursor: "pointer", children: _jsx(X, { size: 11, color: "$soft", "aria-hidden": true }) })] }, acct))) })) : null, _jsxs(XStack, { gap: "$1.5", items: "center", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectGoogle, px: "$2.5", py: "$1", rounded: "$3", bg: "$edge", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(Plus, { size: 12, color: "$ink", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "500", color: "$ink", children: t('Add Google account') })] }) }), _jsx(Box, { render: "button", onClick: () => setLater(true), px: "$2.5", py: "$1", rounded: "$3", bg: "$edge", hoverStyle: { bg: '$hover' }, items: "center", justify: "center", cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "500", children: t('Done') }) })] })] })) : activeStep === 1 ? (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(ProviderMark, { org: "github", size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('1. Connect GitHub') })] }), githubDone ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Sync repositories, PRs, and team repository context.') }), _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectGithub, "aria-disabled": busy === 'github', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'github' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'github' ? t('Connecting…') : githubDone ? t('Reconnect') : t('Connect GitHub') }) }), _jsx(Box, { render: "button", onClick: () => setStep(2), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Skip') }) })] })] })) : activeStep === 2 ? (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(SlackMark, { size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('2. Connect Slack') })] }), slackDone ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Route agent notifications and chat in team channels.') }), _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectSlack, "aria-disabled": busy === 'slack', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'slack' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'slack' ? t('Connecting…') : slackDone ? t('Reconnect') : t('Connect Slack') }) }), _jsx(Box, { render: "button", onClick: () => setStep(3), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Skip') }) })] })] })) : (_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$1.5", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(ProviderMark, { org: "google", size: 18 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: t('3. Connect Google') })] }), hasGoogle ? (_jsxs(XStack, { items: "center", gap: "$1", shrink: 0, children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: accountList.length > 1
|
|
387
|
+
? t('{n} connected', { n: accountList.length })
|
|
388
|
+
: t('Connected') })] })) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Grant Drive, Docs, Sheets, Gmail & Calendar permissions. Add personal, work, or multiple org accounts.') }), accountList.length > 0 ? (_jsx(XStack, { gap: "$1", flexWrap: "wrap", children: accountList.map((acct) => (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$0.5", rounded: "$2", bg: "$edge", children: [_jsx(Text, { fontSize: "$1", color: "$ink", numberOfLines: 1, children: acct }), _jsx(Box, { render: "button", "aria-label": t('Remove {account}', { account: acct }), onClick: () => removeGoogleAccount(acct), cursor: "pointer", children: _jsx(X, { size: 11, color: "$soft", "aria-hidden": true }) })] }, acct))) })) : null, _jsxs(XStack, { gap: "$1.5", items: "center", pt: "$1", flexWrap: "wrap", children: [_jsx(Box, { render: "button", onClick: handleConnectGoogle, "aria-disabled": busy === 'google', px: "$2.5", py: "$1", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", opacity: busy === 'google' ? 0.6 : 1, children: _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'google'
|
|
389
|
+
? t('Connecting…')
|
|
390
|
+
: hasGoogle
|
|
391
|
+
? t('+ Add Google account')
|
|
392
|
+
: t('Connect Google') }) }), _jsx(Box, { render: "button", onClick: () => setLater(true), px: "$2", py: "$1", rounded: "$3", bg: "transparent", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$1", color: "$soft", children: hasGoogle ? t('Done') : t('Skip') }) })] })] })), errorMsg ? (_jsx(Text, { fontSize: "$1", color: "$red10", children: errorMsg })) : null] }), _jsx(Dialog, { open: modalOpen, onOpenChange: setModalOpen, children: _jsxs(DialogContent, { maxW: 520, rounded: "$6", gap: "$4", p: "$5", children: [_jsx(DialogTitle, { children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Sparkles, { size: 20, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: t('Set up {brand} in 3 steps', { brand: brand() }) })] }) }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Connect your code, team chat, and Google Workspace (Drive, Docs, Sheets, Gmail & Calendar) across personal and business orgs.', { brand: brand() }) }), _jsxs(YStack, { gap: "$3", children: [_jsxs(XStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: githubDone ? GOOD : '$borderColor', bg: "$raised", items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(ProviderMark, { org: "github", size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('1. GitHub') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Sync repositories, PRs, and code context') })] })] }), githubDone ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 14, color: GOOD }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : (_jsx(Box, { render: "button", onClick: handleConnectGithub, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'github' ? t('Connecting…') : t('Connect') }) }))] }), _jsxs(XStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: slackDone ? GOOD : '$borderColor', bg: "$raised", items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(SlackMark, { size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('2. Slack') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Notifications and agent bot chat in channels') })] })] }), slackDone ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 14, color: GOOD }), _jsx(Text, { fontSize: "$1", color: GOOD, fontWeight: "600", children: t('Connected') })] })) : (_jsx(Box, { render: "button", onClick: handleConnectSlack, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'slack' ? t('Connecting…') : t('Connect') }) }))] }), _jsxs(YStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: hasGoogle ? GOOD : '$borderColor', bg: "$raised", gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [_jsx(ProviderMark, { org: "google", size: 24 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('3. Google Workspace (Drive, Docs, Sheets, Gmail & Calendar)') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Edit Drive files, Docs, Sheets, Gmail & Calendar across personal and business accounts') })] })] }), _jsx(Box, { render: "button", onClick: handleConnectGoogle, px: "$3", py: "$1.5", rounded: "$3", bg: "var(--accent)", hoverStyle: { bg: 'var(--accent-hover)' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "var(--accent-foreground)", children: busy === 'google'
|
|
393
|
+
? t('Connecting…')
|
|
394
|
+
: hasGoogle
|
|
395
|
+
? t('+ Add account')
|
|
396
|
+
: t('Connect') }) })] }), accountList.length > 0 ? (_jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: accountList.map((acct) => (_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1", rounded: "$2", bg: "$hover", children: [_jsx(Check, { size: 12, color: GOOD, "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$ink", fontWeight: "500", children: acct }), _jsx(Box, { render: "button", "aria-label": t('Remove {account}', { account: acct }), onClick: () => removeGoogleAccount(acct), cursor: "pointer", children: _jsx(X, { size: 12, color: "$soft", "aria-hidden": true }) })] }, acct))) })) : null] })] }), _jsx(XStack, { justify: "flex-end", pt: "$2", children: _jsx(Box, { render: "button", onClick: () => setModalOpen(false), px: "$4", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Close') }) }) })] }) })] }));
|
|
202
397
|
}
|
package/dist/ThinkingEffort.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface ThinkingEffortProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
|
|
17
|
-
* - Subtle pill button
|
|
17
|
+
* - Subtle pill button showing only the active effort level ("High ⌄")
|
|
18
18
|
* - Segmented slider popover with discrete stop dots and smooth active fill
|
|
19
19
|
* - Default level: "high" across all plans
|
|
20
20
|
*/
|
package/dist/ThinkingEffort.js
CHANGED
|
@@ -15,7 +15,7 @@ export const EFFORT_STEPS = [
|
|
|
15
15
|
];
|
|
16
16
|
/**
|
|
17
17
|
* Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
|
|
18
|
-
* - Subtle pill button
|
|
18
|
+
* - Subtle pill button showing only the active effort level ("High ⌄")
|
|
19
19
|
* - Segmented slider popover with discrete stop dots and smooth active fill
|
|
20
20
|
* - Default level: "high" across all plans
|
|
21
21
|
*/
|
|
@@ -65,7 +65,7 @@ export function ThinkingEffort({ effort = DEFAULT_EFFORT, onChange, disabled = f
|
|
|
65
65
|
e.preventDefault();
|
|
66
66
|
setOpen(true);
|
|
67
67
|
}
|
|
68
|
-
}, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t(
|
|
68
|
+
}, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t(current.label) }), _jsx(ChevronDown, { size: 12, color: "var(--soft, var(--muted-foreground))", "aria-hidden": true })] }) }), _jsx(PopoverContent, { solid: true, align: "end", p: "$3", width: 260, minW: 260, maxW: 260, items: "stretch", rounded: "$4", bg: "var(--pane-fill, var(--surface-card))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-15))", boxShadow: "var(--shadow-sheet-1)", backdropFilter: "var(--pane-blur, blur(24px) saturate(190%))", children: _jsxs(YStack, { gap: "$3", width: "100%", minW: 234, maxW: 234, self: "stretch", "data-slot": "thinking-effort-card", role: "dialog", "aria-label": t('Thinking effort'), children: [_jsxs(XStack, { items: "center", justify: "center", gap: "$1", cursor: "pointer", onClick: () => {
|
|
69
69
|
if (disabled)
|
|
70
70
|
return;
|
|
71
71
|
const next = EFFORT_STEPS[(activeIndex + 1) % EFFORT_STEPS.length];
|
|
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
|
|
|
7
7
|
import { DEFAULT_EFFORT, EFFORT_STEPS } from '../ThinkingEffort.js';
|
|
8
8
|
const STORAGE_KEY = 'hanzo.chat.preferences';
|
|
9
9
|
const EVENT_NAME = 'hanzo:chat:preferences';
|
|
10
|
-
const EFFORT_SCHEMA_VERSION =
|
|
10
|
+
const EFFORT_SCHEMA_VERSION = 3;
|
|
11
11
|
const DEFAULT_PREFERENCES = {
|
|
12
12
|
showModelSelector: false,
|
|
13
13
|
allowThirdPartyModels: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
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",
|