@hanzo/app 0.2.20 → 0.2.22
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/Drive.js +95 -16
- package/dist/Setup.js +87 -30
- package/dist/ThinkingEffort.d.ts +1 -1
- package/dist/ThinkingEffort.js +2 -2
- package/dist/lib/chatPreferences.js +1 -1
- package/dist/lib/local-fs.d.ts +6 -0
- package/dist/lib/local-fs.js +36 -0
- 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/Drive.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { ArrowRight, ChevronDown, ChevronRight, Clock, Cloud, Download, File as FileIcon, FileArchive, FileAudio, FileCode, FileImage, FilePlus, FileText, FileVideo, Folder, FolderInput, FolderPlus, HardDrive, Laptop, ListTree, MessageSquare, LayoutGrid, List, MoreHorizontal, PanelLeft, Plus, Search, Trash2, Upload, } from 'lucide-react';
|
|
4
|
+
import { ArrowRight, ChevronDown, ChevronRight, Clock, Cloud, Download, File as FileIcon, FileArchive, FileAudio, FileCode, FileImage, FilePlus, FileText, FileVideo, Folder, FolderGit2, FolderInput, FolderPlus, HardDrive, Laptop, ListTree, MessageSquare, LayoutGrid, List, MoreHorizontal, PanelLeft, Plus, Search, Trash2, Upload, } from 'lucide-react';
|
|
5
5
|
import { Box, Button, Text, View, XStack, YStack } from '@hanzo/ui';
|
|
6
6
|
import { useIam, useOrganizations } from '@hanzo/iam/react';
|
|
7
7
|
import { useAi } from './lib/ai.js';
|
|
@@ -11,7 +11,7 @@ import { useRooms } from './host.js';
|
|
|
11
11
|
import { org } from './lib/session.js';
|
|
12
12
|
import { Badge, Contents, Hits } from './Contents.js';
|
|
13
13
|
import { Editor } from './Editor.js';
|
|
14
|
-
import { createLocalDir, createLocalFile, deleteLocalPath, getActiveWorkspace, getLocalWorkspaces, listLocalEntries, pickLocalFolder, removeLocalWorkspace, setActiveWorkspace, subscribeLocalFs, } from './lib/local-fs.js';
|
|
14
|
+
import { cloneRemoteRepo, createLocalDir, createLocalFile, deleteLocalPath, getActiveWorkspace, getLocalWorkspaces, importLocalFile, listLocalEntries, pickLocalFile, pickLocalFolder, removeLocalWorkspace, setActiveWorkspace, subscribeLocalFs, } from './lib/local-fs.js';
|
|
15
15
|
import { weigh as size } from './lib/attach.js';
|
|
16
16
|
import { dropped, filesIn, forget, pool, register, search, settled, slug, upload, } from './lib/files.js';
|
|
17
17
|
import { checkoutUrl } from './lib/pay.js';
|
|
@@ -420,8 +420,55 @@ export function Drive() {
|
|
|
420
420
|
setEditingFile({ path: filePath, name: clean });
|
|
421
421
|
})
|
|
422
422
|
.catch((e) => setFailed(blame(e)));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (!client || !activeBucket)
|
|
426
|
+
return;
|
|
427
|
+
void run(`Creating ${clean}`, () => putBytes(client, activeBucket, `${prefix}${clean}`, new Blob([''])));
|
|
428
|
+
setNaming(null);
|
|
429
|
+
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries]);
|
|
430
|
+
const handleCloneRepo = useCallback((repoUrl) => {
|
|
431
|
+
const clean = repoUrl.trim();
|
|
432
|
+
if (!clean)
|
|
433
|
+
return;
|
|
434
|
+
setNaming(null);
|
|
435
|
+
void run(`Cloning ${clean}`, async () => {
|
|
436
|
+
const ws = await cloneRemoteRepo(clean);
|
|
437
|
+
setNavSection('local');
|
|
438
|
+
setActiveWorkspace(ws);
|
|
439
|
+
setLocalPrefix('');
|
|
440
|
+
loadLocalEntries();
|
|
441
|
+
});
|
|
442
|
+
}, [run, loadLocalEntries]);
|
|
443
|
+
const handleOpenLocalFile = useCallback(async () => {
|
|
444
|
+
try {
|
|
445
|
+
const selected = await pickLocalFile();
|
|
446
|
+
if (selected) {
|
|
447
|
+
const fileName = selected.split(/[/\\]/).pop() || 'file';
|
|
448
|
+
setEditingFile({ path: selected, name: fileName });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
catch (e) {
|
|
452
|
+
setFailed(blame(e));
|
|
453
|
+
}
|
|
454
|
+
}, []);
|
|
455
|
+
const handleImportLocalFile = useCallback(async () => {
|
|
456
|
+
if (!activeWs)
|
|
457
|
+
return;
|
|
458
|
+
try {
|
|
459
|
+
const selected = await pickLocalFile();
|
|
460
|
+
if (selected) {
|
|
461
|
+
const targetDir = localPrefix
|
|
462
|
+
? `${activeWs.path}/${localPrefix}`.replace(/\/+/g, '/')
|
|
463
|
+
: activeWs.path;
|
|
464
|
+
await importLocalFile(selected, targetDir);
|
|
465
|
+
loadLocalEntries();
|
|
466
|
+
}
|
|
423
467
|
}
|
|
424
|
-
|
|
468
|
+
catch (e) {
|
|
469
|
+
setFailed(blame(e));
|
|
470
|
+
}
|
|
471
|
+
}, [activeWs, localPrefix, loadLocalEntries]);
|
|
425
472
|
const handleRename = useCallback((entry, to) => {
|
|
426
473
|
const clean = to.trim().replace(/^\/+|\/+$/g, '');
|
|
427
474
|
if (!clean || !client || !activeBucket || entry.isDir)
|
|
@@ -571,7 +618,23 @@ export function Drive() {
|
|
|
571
618
|
setLocalPrefix('');
|
|
572
619
|
}
|
|
573
620
|
});
|
|
574
|
-
}, children: [_jsx(FolderInput, { size: 14 }), "Open local folder\u2026"] })
|
|
621
|
+
}, children: [_jsx(FolderInput, { size: 14 }), "Open local folder\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
622
|
+
setNewMenuOpen(false);
|
|
623
|
+
setMenu(false);
|
|
624
|
+
void handleOpenLocalFile();
|
|
625
|
+
}, children: [_jsx(FileText, { size: 14 }), "Open local file\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
626
|
+
setNewMenuOpen(false);
|
|
627
|
+
setMenu(false);
|
|
628
|
+
void handleImportLocalFile();
|
|
629
|
+
}, children: [_jsx(Upload, { size: 14 }), "Import local file\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
630
|
+
setNewMenuOpen(false);
|
|
631
|
+
setMenu(false);
|
|
632
|
+
setNaming({ kind: 'clone', value: '' });
|
|
633
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), "Clone remote repo\u2026"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { ...ITEM, onClick: () => {
|
|
634
|
+
setNewMenuOpen(false);
|
|
635
|
+
setMenu(false);
|
|
636
|
+
setNaming({ kind: 'file', value: '' });
|
|
637
|
+
}, children: [_jsx(FilePlus, { size: 14 }), "New file"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
575
638
|
setNewMenuOpen(false);
|
|
576
639
|
setMenu(false);
|
|
577
640
|
setNaming({ kind: 'folder', value: '' });
|
|
@@ -583,7 +646,11 @@ export function Drive() {
|
|
|
583
646
|
setNewMenuOpen(false);
|
|
584
647
|
setMenu(false);
|
|
585
648
|
folderInputRef.current?.click();
|
|
586
|
-
}, children: [_jsx(FolderInput, { size: 14 }), "Folder upload"] })
|
|
649
|
+
}, children: [_jsx(FolderInput, { size: 14 }), "Folder upload"] }), _jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
650
|
+
setNewMenuOpen(false);
|
|
651
|
+
setMenu(false);
|
|
652
|
+
setNaming({ kind: 'clone', value: '' });
|
|
653
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), "Clone remote repo\u2026"] })] })) })) : null] }), _jsx(YStack, { gap: "$1", children: [
|
|
587
654
|
{ id: 'my-drive', label: 'My Drive', icon: HardDrive },
|
|
588
655
|
{ id: 'local', label: 'Local Folders', icon: Laptop },
|
|
589
656
|
{ id: 'recent', label: 'Recent', icon: Clock },
|
|
@@ -628,34 +695,46 @@ export function Drive() {
|
|
|
628
695
|
['list', 'List View', List],
|
|
629
696
|
['grid', 'Grid View', LayoutGrid],
|
|
630
697
|
['details', 'Details View', MoreHorizontal],
|
|
631
|
-
].map(([mode, label, Icon]) => (_jsx(Button, { variant: viewMode === mode ? 'secondary' : 'ghost', size: "icon-sm", color: viewMode === mode ? '$ink' : '$soft', onClick: () => setViewMode(mode), "aria-label": label, "aria-pressed": viewMode === mode, title: label, children: _jsx(Icon, { size: 14 }) }, mode))) })] }), naming ? (_jsxs(XStack, { items: "center", gap: "$3", py: 10, px: 14, rounded: 8, borderWidth: 1, borderColor: "var(--border-control)", bg: "$panel", children: [naming.kind === 'file' ? (_jsx(FileCode, { size: 16, color: "var(--primary)" })) : (_jsx(Folder, { size: 16, color: "var(--foreground)" })), _jsx(Text, { render: _jsx("input", { autoFocus: true, value: naming.value, onChange: (e) => setNaming({ ...naming, value: e.target.value }), onKeyDown: (e) => {
|
|
698
|
+
].map(([mode, label, Icon]) => (_jsx(Button, { variant: viewMode === mode ? 'secondary' : 'ghost', size: "icon-sm", color: viewMode === mode ? '$ink' : '$soft', onClick: () => setViewMode(mode), "aria-label": label, "aria-pressed": viewMode === mode, title: label, children: _jsx(Icon, { size: 14 }) }, mode))) })] }), naming ? (_jsxs(XStack, { items: "center", gap: "$3", py: 10, px: 14, rounded: 8, borderWidth: 1, borderColor: "var(--border-control)", bg: "$panel", children: [naming.kind === 'file' ? (_jsx(FileCode, { size: 16, color: "var(--primary)" })) : naming.kind === 'clone' ? (_jsx(FolderGit2, { size: 16, color: "var(--primary)" })) : (_jsx(Folder, { size: 16, color: "var(--foreground)" })), _jsx(Text, { render: _jsx("input", { autoFocus: true, value: naming.value, onChange: (e) => setNaming({ ...naming, value: e.target.value }), onKeyDown: (e) => {
|
|
632
699
|
if (e.key === 'Escape')
|
|
633
700
|
setNaming(null);
|
|
634
701
|
if (e.key === 'Enter') {
|
|
635
702
|
if (naming.kind === 'file')
|
|
636
703
|
handleCreateFile(naming.value);
|
|
704
|
+
else if (naming.kind === 'clone')
|
|
705
|
+
handleCloneRepo(naming.value);
|
|
637
706
|
else
|
|
638
707
|
handleCreateFolder(naming.value);
|
|
639
708
|
}
|
|
640
|
-
}, placeholder: naming.kind === 'file'
|
|
709
|
+
}, placeholder: naming.kind === 'file'
|
|
710
|
+
? 'File name (e.g. index.ts)'
|
|
711
|
+
: naming.kind === 'clone'
|
|
712
|
+
? 'owner/repo or Git URL (e.g. hanzoai/desktop)'
|
|
713
|
+
: 'Folder name', "aria-label": naming.kind === 'file'
|
|
714
|
+
? 'File name'
|
|
715
|
+
: naming.kind === 'clone'
|
|
716
|
+
? 'Clone remote repository'
|
|
717
|
+
: 'Folder name' }), ...BARE }), _jsx(Button, { variant: "primary", size: "sm", onClick: () => {
|
|
641
718
|
if (naming.kind === 'file')
|
|
642
719
|
handleCreateFile(naming.value);
|
|
720
|
+
else if (naming.kind === 'clone')
|
|
721
|
+
handleCloneRepo(naming.value);
|
|
643
722
|
else
|
|
644
723
|
handleCreateFolder(naming.value);
|
|
645
|
-
}, children:
|
|
724
|
+
}, children: naming.kind === 'clone' ? 'Clone' : 'Create' }), _jsx(Button, { variant: "ghost", size: "sm", color: "$soft", onClick: () => setNaming(null), children: "Cancel" })] })) : null, editingFile ? (_jsx(Editor, { filePath: editingFile.path, fileName: editingFile.name, onClose: () => {
|
|
646
725
|
setEditingFile(null);
|
|
647
726
|
loadLocalEntries();
|
|
648
727
|
}, onAskInChat: () => {
|
|
649
728
|
setEditingFile(null);
|
|
650
729
|
router.push('/chat');
|
|
651
|
-
} })) : null, busy ? (_jsxs(Text, { fontSize: "$2", color: "$soft", "data-slot": "drive-busy", children: [busy, "\u2026"] })) : null, hits && hits.length ? _jsx(Hits, { hits: hits, onOpen: (p) => showContents(p.file.id, p.section.id) }) : null, navSection === 'local' ? (!activeWs ? (_jsxs(YStack, { py: 60, px: 24, items: "center", justify: "center", gap: "$4", borderWidth: 1, borderStyle: "dashed", borderColor: "$borderColor", rounded: 12, bg: "$panel", children: [_jsx(Laptop, { size: 40, color: "var(--primary)" }), _jsxs(YStack, { items: "center", gap: "$1", maxW: 460, children: [_jsx(Text, { fontSize: 18, fontWeight: "600", color: "$ink", text: "center", children: "No local folder opened" }), _jsx(Text, { fontSize: 13, color: "$soft", text: "center", children: "Open a local folder on your computer to browse, create, edit, and save files directly in Hanzo Desktop." })] }), _jsxs(Button, { onClick: () => {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
730
|
+
} })) : null, busy ? (_jsxs(Text, { fontSize: "$2", color: "$soft", "data-slot": "drive-busy", children: [busy, "\u2026"] })) : null, hits && hits.length ? _jsx(Hits, { hits: hits, onOpen: (p) => showContents(p.file.id, p.section.id) }) : null, navSection === 'local' ? (!activeWs ? (_jsxs(YStack, { py: 60, px: 24, items: "center", justify: "center", gap: "$4", borderWidth: 1, borderStyle: "dashed", borderColor: "$borderColor", rounded: 12, bg: "$panel", children: [_jsx(Laptop, { size: 40, color: "var(--primary)" }), _jsxs(YStack, { items: "center", gap: "$1", maxW: 460, children: [_jsx(Text, { fontSize: 18, fontWeight: "600", color: "$ink", text: "center", children: "No local folder opened" }), _jsx(Text, { fontSize: 13, color: "$soft", text: "center", children: "Open a local folder on your computer to browse, create, edit, and save files directly in Hanzo Desktop." })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { onClick: () => {
|
|
731
|
+
void pickLocalFolder().then((ws) => {
|
|
732
|
+
if (ws) {
|
|
733
|
+
setNavSection('local');
|
|
734
|
+
setLocalPrefix('');
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
}, children: [_jsx(FolderPlus, { size: 16 }), "Open Local Folder\u2026"] }), _jsxs(Button, { variant: "outline", onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 16 }), "Clone Remote Repo\u2026"] })] })] })) : (_jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { items: "center", justify: "space-between", pb: "$1", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children: localPrefix ? `Folder: ${localPrefix}` : 'Root Files & Directories' }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'file', value: '' }), children: [_jsx(FilePlus, { size: 13 }), "New file"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'folder', value: '' }), children: [_jsx(FolderPlus, { size: 13 }), "New folder"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => void handleImportLocalFile(), children: [_jsx(Upload, { size: 13 }), "Import file"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 13 }), "Clone repo"] })] })] }), _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { ...HEAD, children: "Name" }), _jsx(Text, { ...HEAD, children: "Type" }), _jsx(Text, { ...HEAD, children: "Updated" }), _jsx(Text, { ...HEAD, children: "Size" }), _jsx(View, {})] }), !localEntries || localEntries.length === 0 ? (_jsx(Text, { py: 36, px: 16, text: "center", fontSize: "$2", color: "$faint", children: "Empty folder" })) : (localEntries.map((e) => {
|
|
659
738
|
const ext = e.name.split('.').pop() || '';
|
|
660
739
|
return (_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$borderColor", transition: "100ms", hoverStyle: { bg: '$hover' }, onClick: () => {
|
|
661
740
|
if (e.isDir) {
|
package/dist/Setup.js
CHANGED
|
@@ -14,11 +14,13 @@ import { useIam } from '@hanzo/iam/react';
|
|
|
14
14
|
import { Check, Maximize2, Sparkles, X } from 'lucide-react';
|
|
15
15
|
import { ProviderMark } from './ProviderMark.js';
|
|
16
16
|
import { useKept } from './kept.js';
|
|
17
|
-
import { api } from './lib/api.js';
|
|
17
|
+
import { api, CLIENT } 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';
|
|
23
|
+
const here = () => typeof window !== 'undefined' && answers(window.location.hostname);
|
|
22
24
|
const LATER_KEY = 'hanzo.onboarding.later';
|
|
23
25
|
const GITHUB_KEY = 'hanzo.onboarding.github';
|
|
24
26
|
const SLACK_KEY = 'hanzo.onboarding.slack';
|
|
@@ -30,7 +32,7 @@ function SlackMark({ size = 18 }) {
|
|
|
30
32
|
}
|
|
31
33
|
export function Setup() {
|
|
32
34
|
const { t } = useI18n();
|
|
33
|
-
const { isAuthenticated, accessToken } = useIam();
|
|
35
|
+
const { isAuthenticated, accessToken, sdk } = useIam();
|
|
34
36
|
const [later, setLater] = useKept(LATER_KEY, false);
|
|
35
37
|
const [step, setStep] = useKept(STEP_KEY, 1);
|
|
36
38
|
const [githubDone, setGithubDone] = useKept(GITHUB_KEY, false);
|
|
@@ -41,7 +43,7 @@ export function Setup() {
|
|
|
41
43
|
const [errorMsg, setErrorMsg] = useState(null);
|
|
42
44
|
const [syncTurn, setSyncTurn] = useState(0);
|
|
43
45
|
const signed = isAuthenticated && Boolean(accessToken);
|
|
44
|
-
// Sync with remote integrations &
|
|
46
|
+
// Sync with remote integrations, connectors & linked IAM accounts when authenticated or returning from OAuth tab/popup
|
|
45
47
|
useEffect(() => {
|
|
46
48
|
if (!signed)
|
|
47
49
|
return;
|
|
@@ -54,7 +56,10 @@ export function Setup() {
|
|
|
54
56
|
fetch(`${api()}/v1/integrations/connectors`, { headers: auth })
|
|
55
57
|
.then((r) => (r.ok ? r.json() : null))
|
|
56
58
|
.catch(() => null),
|
|
57
|
-
|
|
59
|
+
fetch(`${api()}/v1/iam/linked-accounts`, { headers: auth })
|
|
60
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
61
|
+
.catch(() => null),
|
|
62
|
+
]).then(([integrationsData, connectorsData, linkedData]) => {
|
|
58
63
|
if (!live)
|
|
59
64
|
return;
|
|
60
65
|
const providers = Array.isArray(integrationsData?.providers)
|
|
@@ -63,7 +68,10 @@ export function Setup() {
|
|
|
63
68
|
const connectors = Array.isArray(connectorsData?.connectors)
|
|
64
69
|
? connectorsData.connectors
|
|
65
70
|
: null;
|
|
66
|
-
|
|
71
|
+
const linkedAccounts = Array.isArray(linkedData?.data)
|
|
72
|
+
? linkedData.data
|
|
73
|
+
: null;
|
|
74
|
+
if (!providers && !connectors && !linkedAccounts)
|
|
67
75
|
return;
|
|
68
76
|
const connectedSet = new Set();
|
|
69
77
|
if (providers) {
|
|
@@ -77,25 +85,24 @@ export function Setup() {
|
|
|
77
85
|
connectedSet.add(String(c.provider));
|
|
78
86
|
}
|
|
79
87
|
}
|
|
88
|
+
if (linkedAccounts) {
|
|
89
|
+
for (const l of linkedAccounts) {
|
|
90
|
+
if (l.provider)
|
|
91
|
+
connectedSet.add(String(l.provider).toLowerCase());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
80
94
|
const hasGithub = connectedSet.has('github') || connectedSet.has('github-copilot');
|
|
81
95
|
const hasSlack = connectedSet.has('slack');
|
|
82
96
|
const hasGoogle = connectedSet.has('google') ||
|
|
83
97
|
connectedSet.has('gmail') ||
|
|
84
98
|
connectedSet.has('google-drive') ||
|
|
85
99
|
connectedSet.has('google-calendar');
|
|
86
|
-
if (
|
|
87
|
-
setGithubDone(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (hasGithub)
|
|
93
|
-
setGithubDone(true);
|
|
94
|
-
if (hasSlack)
|
|
95
|
-
setSlackDone(true);
|
|
96
|
-
if (hasGoogle)
|
|
97
|
-
setGoogleDone(true);
|
|
98
|
-
}
|
|
100
|
+
if (hasGithub)
|
|
101
|
+
setGithubDone(true);
|
|
102
|
+
if (hasSlack)
|
|
103
|
+
setSlackDone(true);
|
|
104
|
+
if (hasGoogle)
|
|
105
|
+
setGoogleDone(true);
|
|
99
106
|
});
|
|
100
107
|
return () => {
|
|
101
108
|
live = false;
|
|
@@ -130,6 +137,58 @@ export function Setup() {
|
|
|
130
137
|
}, [githubDone, slackDone, googleDone, step]);
|
|
131
138
|
if (later && !modalOpen)
|
|
132
139
|
return null;
|
|
140
|
+
const openOAuthPopup = (authorizeUrl, provider) => {
|
|
141
|
+
const popup = window.open(authorizeUrl, `hanzo-oauth-${provider}`, 'width=600,height=700');
|
|
142
|
+
if (!popup) {
|
|
143
|
+
window.open(authorizeUrl, '_blank', 'noopener,noreferrer');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const timer = window.setInterval(() => {
|
|
147
|
+
if (popup.closed) {
|
|
148
|
+
window.clearInterval(timer);
|
|
149
|
+
setSyncTurn((n) => n + 1);
|
|
150
|
+
}
|
|
151
|
+
}, 1000);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const connectGoogleViaIam = async (onDone) => {
|
|
155
|
+
try {
|
|
156
|
+
const linkOrigin = here() && typeof window !== 'undefined' ? window.location.origin : api();
|
|
157
|
+
const returnUri = typeof window !== 'undefined' ? `${window.location.origin}/auth/callback` : 'https://hanzo.ai/auth/callback';
|
|
158
|
+
const linkRes = await fetch(`${linkOrigin}/v1/iam/link`, {
|
|
159
|
+
method: 'POST',
|
|
160
|
+
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
161
|
+
body: JSON.stringify({
|
|
162
|
+
provider: 'provider-google',
|
|
163
|
+
clientId: CLIENT,
|
|
164
|
+
returnUri,
|
|
165
|
+
}),
|
|
166
|
+
}).catch(() => null);
|
|
167
|
+
if (linkRes?.ok) {
|
|
168
|
+
const linkJson = (await linkRes.json().catch(() => null));
|
|
169
|
+
if (linkJson?.status === 'ok' && typeof linkJson.data === 'string' && linkJson.data) {
|
|
170
|
+
return linkJson.data;
|
|
171
|
+
}
|
|
172
|
+
if (linkJson?.msg && linkJson.msg.toLowerCase().includes('already connected')) {
|
|
173
|
+
onDone();
|
|
174
|
+
return 'done';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (sdk && typeof sdk.getSigninUrl === 'function') {
|
|
178
|
+
const signinHref = await sdk.getSigninUrl({ additionalParams: { provider: 'provider-google' } });
|
|
179
|
+
const url = new URL(signinHref);
|
|
180
|
+
if (here() && typeof window !== 'undefined') {
|
|
181
|
+
url.protocol = window.location.protocol;
|
|
182
|
+
url.host = window.location.host;
|
|
183
|
+
}
|
|
184
|
+
return url.href;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// fall through
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
};
|
|
133
192
|
const connectOAuthProvider = async (provider, label, onDone) => {
|
|
134
193
|
if (!signed) {
|
|
135
194
|
enter();
|
|
@@ -138,6 +197,15 @@ export function Setup() {
|
|
|
138
197
|
setBusy(provider);
|
|
139
198
|
setErrorMsg(null);
|
|
140
199
|
try {
|
|
200
|
+
if (provider === 'google') {
|
|
201
|
+
const iamResult = await connectGoogleViaIam(onDone);
|
|
202
|
+
if (iamResult === 'done')
|
|
203
|
+
return;
|
|
204
|
+
if (iamResult) {
|
|
205
|
+
openOAuthPopup(iamResult, 'google');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
141
209
|
const res = await fetch(`${api()}/v1/integrations/${provider}/connect`, {
|
|
142
210
|
method: 'POST',
|
|
143
211
|
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
@@ -160,18 +228,7 @@ export function Setup() {
|
|
|
160
228
|
}
|
|
161
229
|
const j = (await res.json());
|
|
162
230
|
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
|
-
}
|
|
231
|
+
openOAuthPopup(j.authorizeUrl, provider);
|
|
175
232
|
}
|
|
176
233
|
else if (j.connected) {
|
|
177
234
|
onDone();
|
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/dist/lib/local-fs.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ export declare function addLocalWorkspace(path: string, name?: string): LocalWor
|
|
|
37
37
|
export declare function removeLocalWorkspace(idOrPath: string): void;
|
|
38
38
|
/** Open native dialog to pick a local folder */
|
|
39
39
|
export declare function pickLocalFolder(): Promise<LocalWorkspace | null>;
|
|
40
|
+
/** Open native dialog to pick a local file to view or edit */
|
|
41
|
+
export declare function pickLocalFile(): Promise<string | null>;
|
|
42
|
+
/** Clone a remote repository to local machine and register as a workspace */
|
|
43
|
+
export declare function cloneRemoteRepo(repo: string, targetDir?: string): Promise<LocalWorkspace>;
|
|
44
|
+
/** Import an existing local file into the active workspace directory */
|
|
45
|
+
export declare function importLocalFile(sourcePath: string, targetDir: string): Promise<LocalEntry>;
|
|
40
46
|
/** List entries in a local directory */
|
|
41
47
|
export declare function listLocalEntries(dirPath: string): Promise<LocalEntry[]>;
|
|
42
48
|
/** Read text content of a local file */
|
package/dist/lib/local-fs.js
CHANGED
|
@@ -152,6 +152,42 @@ export async function pickLocalFolder() {
|
|
|
152
152
|
}
|
|
153
153
|
return null;
|
|
154
154
|
}
|
|
155
|
+
/** Open native dialog to pick a local file to view or edit */
|
|
156
|
+
export async function pickLocalFile() {
|
|
157
|
+
if (isTauri()) {
|
|
158
|
+
try {
|
|
159
|
+
const selected = await tauriInvoke('local_workspace_open_file_dialog');
|
|
160
|
+
if (selected && typeof selected === 'string') {
|
|
161
|
+
return selected;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
console.warn('local_workspace_open_file_dialog failed:', e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
/** Clone a remote repository to local machine and register as a workspace */
|
|
171
|
+
export async function cloneRemoteRepo(repo, targetDir) {
|
|
172
|
+
if (isTauri()) {
|
|
173
|
+
const res = await tauriInvoke('local_workspace_clone_repo', {
|
|
174
|
+
repo,
|
|
175
|
+
targetDir,
|
|
176
|
+
});
|
|
177
|
+
return addLocalWorkspace(res.path, res.name);
|
|
178
|
+
}
|
|
179
|
+
throw new Error('Cloning remote repositories locally requires Hanzo Desktop');
|
|
180
|
+
}
|
|
181
|
+
/** Import an existing local file into the active workspace directory */
|
|
182
|
+
export async function importLocalFile(sourcePath, targetDir) {
|
|
183
|
+
if (isTauri()) {
|
|
184
|
+
return await tauriInvoke('local_workspace_import_file', {
|
|
185
|
+
sourcePath,
|
|
186
|
+
targetDir,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
throw new Error('Importing files requires Hanzo Desktop');
|
|
190
|
+
}
|
|
155
191
|
/** List entries in a local directory */
|
|
156
192
|
export async function listLocalEntries(dirPath) {
|
|
157
193
|
if (isTauri()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
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",
|