@hanzo/app 0.3.94 → 0.3.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Account.d.ts +9 -3
- package/dist/Account.js +142 -141
- package/dist/App.js +71 -37
- package/dist/Bar.js +1 -1
- package/dist/Betas.d.ts +1 -1
- package/dist/Betas.js +16 -22
- package/dist/Board.js +114 -48
- package/dist/CalScheduler.d.ts +1 -0
- package/dist/CalScheduler.js +223 -57
- package/dist/Chat.js +432 -153
- package/dist/Contacts.js +35 -31
- package/dist/ContextMenu.js +126 -42
- package/dist/Directory.js +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/Drive.js +351 -119
- package/dist/Gate.js +156 -13
- package/dist/Home.js +31 -53
- package/dist/Inbox.js +29 -15
- package/dist/InlineRename.d.ts +6 -0
- package/dist/InlineRename.js +41 -0
- package/dist/Learning.js +132 -13
- package/dist/Market.js +13 -9
- package/dist/Meet.d.ts +5 -0
- package/dist/Meet.js +75 -51
- package/dist/MoreMenu.d.ts +19 -0
- package/dist/MoreMenu.js +33 -0
- package/dist/NeedMoreUsage.js +2 -2
- package/dist/OrgSwitcher.js +6 -2
- package/dist/PreferencesDialog.js +5 -2
- package/dist/Rail.d.ts +73 -7
- package/dist/Rail.js +372 -111
- package/dist/Recents.js +77 -24
- package/dist/RightPane.js +2 -2
- package/dist/Search.d.ts +13 -1
- package/dist/Search.js +366 -50
- package/dist/Setup.js +34 -5
- package/dist/Shared.js +12 -12
- package/dist/Shell.d.ts +10 -0
- package/dist/Shell.js +258 -158
- package/dist/Sidebar.d.ts +14 -3
- package/dist/Sidebar.js +411 -129
- package/dist/SkipLink.d.ts +8 -0
- package/dist/SkipLink.js +11 -0
- package/dist/Start.js +51 -52
- package/dist/Terminals.js +159 -11
- package/dist/ToBottom.js +1 -1
- package/dist/Upgrade.d.ts +8 -3
- package/dist/Upgrade.js +194 -103
- package/dist/Usage.d.ts +1 -1
- package/dist/Usage.js +186 -82
- package/dist/WalletPill.js +8 -2
- package/dist/Work.js +162 -53
- package/dist/archive.d.ts +8 -0
- package/dist/archive.js +16 -0
- package/dist/bots/Bots.js +16 -1
- package/dist/bots/ComputerDialog.js +53 -26
- package/dist/bots/ConnectorsDialog.js +34 -15
- package/dist/bots/Make.js +5 -1
- package/dist/bots/Panel.js +37 -31
- package/dist/bots/Roster.d.ts +4 -1
- package/dist/bots/Roster.js +71 -25
- package/dist/bots/Thread.js +54 -27
- package/dist/bots/face.js +9 -3
- package/dist/bots/grid.d.ts +36 -0
- package/dist/bots/grid.js +91 -0
- package/dist/bots/ink.d.ts +1 -1
- package/dist/bots/ink.js +1 -1
- package/dist/bots/kit.d.ts +9 -4
- package/dist/bots/kit.js +3 -2
- package/dist/chord.d.ts +13 -0
- package/dist/chord.js +30 -1
- package/dist/crew.js +47 -4
- package/dist/ground.d.ts +2 -2
- package/dist/ground.js +3 -3
- package/dist/help.d.ts +7 -3
- package/dist/help.js +19 -14
- package/dist/keys.d.ts +28 -0
- package/dist/keys.js +58 -0
- package/dist/lib/arrival.d.ts +5 -0
- package/dist/lib/arrival.js +10 -0
- package/dist/lib/betas.d.ts +2 -0
- package/dist/lib/betas.js +10 -0
- package/dist/lib/branch.d.ts +11 -0
- package/dist/lib/branch.js +11 -0
- package/dist/lib/chatPreferences.d.ts +1 -1
- package/dist/lib/chatPreferences.js +1 -1
- package/dist/lib/dev-mode.d.ts +18 -0
- package/dist/lib/dev-mode.js +102 -0
- package/dist/lib/durable.d.ts +1 -1
- package/dist/lib/durable.js +1 -1
- package/dist/lib/info-hint.d.ts +7 -0
- package/dist/lib/info-hint.js +8 -0
- package/dist/lib/model-picker.d.ts +2 -0
- package/dist/lib/model-picker.js +12 -0
- package/dist/lib/owners.d.ts +5 -0
- package/dist/lib/owners.js +15 -0
- package/dist/lib/pay.d.ts +2 -0
- package/dist/lib/pay.js +4 -0
- package/dist/lib/todo.d.ts +7 -1
- package/dist/lib/todo.js +41 -29
- package/dist/look.js +39 -8
- package/dist/rail-open.d.ts +9 -0
- package/dist/rail-open.js +34 -0
- package/dist/renaming.d.ts +10 -0
- package/dist/renaming.js +25 -0
- package/dist/seek.d.ts +6 -1
- package/dist/seek.js +13 -0
- package/dist/thread.d.ts +2 -1
- package/dist/thread.js +85 -44
- package/package.json +11 -11
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** What marks the page's main area: `Split` spreads it on its pane and the skip link points at it, so the two cannot part. */
|
|
2
|
+
export declare const MAIN: {
|
|
3
|
+
readonly id: 'main-content';
|
|
4
|
+
readonly tabIndex: -1;
|
|
5
|
+
readonly render: 'main';
|
|
6
|
+
};
|
|
7
|
+
/** The first stop for the keyboard: out of the sidebar and into the page (`Split` draws `#main-content`). Off screen until focused. */
|
|
8
|
+
export declare function SkipLink(): import("react").JSX.Element;
|
package/dist/SkipLink.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
4
|
+
import { Text, XStack } from '@hanzo/gui';
|
|
5
|
+
/** What marks the page's main area: `Split` spreads it on its pane and the skip link points at it, so the two cannot part. */
|
|
6
|
+
export const MAIN = { id: 'main-content', tabIndex: -1, render: 'main' };
|
|
7
|
+
/** The first stop for the keyboard: out of the sidebar and into the page (`Split` draws `#main-content`). Off screen until focused. */
|
|
8
|
+
export function SkipLink() {
|
|
9
|
+
const { t } = useI18n();
|
|
10
|
+
return (_jsx(XStack, { render: _jsx("a", { href: `#${MAIN.id}` }), "data-slot": "skip-link", position: "fixed", t: -80, l: 12, z: "var(--z-notification)", px: "$3", py: "$2", minH: 44, items: "center", rounded: "$3", bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", boxShadow: "var(--shadow-floating)", focusStyle: { t: 12 }, focusVisibleStyle: { t: 12, outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t('Skip to main content') }) }));
|
|
11
|
+
}
|
package/dist/Start.js
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// Starting a run from here — the composer /dev's empty state promised and did
|
|
4
|
-
// not have.
|
|
5
|
-
//
|
|
6
|
-
// The pane already said "Describe it. Ship it." over "in your terminal, your
|
|
7
|
-
// editor, or right here", and `right here` was the one of the three with nothing
|
|
8
|
-
// behind it: the idle state drew install cards and no way to send. The comment
|
|
9
|
-
// that stood in for it said "there is no create-a-run route to offer: a run
|
|
10
|
-
// begins on a machine". THAT IS NO LONGER TRUE — `POST /v1/agents/coding` starts
|
|
11
|
-
// one and answers the session to watch it in, which is the row the working view
|
|
12
|
-
// already renders.
|
|
13
|
-
//
|
|
14
|
-
// WHERE IT RUNS IS THE ONE CHOICE, and it is a field rather than a fork:
|
|
15
|
-
//
|
|
16
|
-
// no target the cloud's own sandbox — what a browser gets, because a
|
|
17
|
-
// browser has no machine to offer
|
|
18
|
-
// a target a machine this org has claimed, routed by id
|
|
19
|
-
//
|
|
20
|
-
// Nothing here reads the user agent to decide. The web sends no target because
|
|
21
|
-
// it HAS none; a surface running on a claimed machine sends that machine's id.
|
|
22
|
-
// One endpoint, one field, and the answer comes back rather than being assumed —
|
|
23
|
-
// `routed` says whether a machine actually took it, so asking for one and being
|
|
24
|
-
// given a sandbox is reported instead of drawn as success.
|
|
25
3
|
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { phrase } from '@hanzo/i18n';
|
|
26
5
|
import { useI18n } from '@hanzo/i18n/react';
|
|
27
|
-
import { Text, XStack, YStack } from '@hanzo/ui';
|
|
6
|
+
import { Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Text, XStack, YStack, } from '@hanzo/ui';
|
|
28
7
|
import { Composer } from '@hanzo/ui/chat';
|
|
8
|
+
import { ArrowUpRight, Cloud, FolderOpen, Laptop } from 'lucide-react';
|
|
29
9
|
import { useOpen } from './open.js';
|
|
30
10
|
import { CodingRefusal, dispatchable, listTargets, startCoding, } from './lib/coding.js';
|
|
31
|
-
import { BAD } from './lib/mix.js';
|
|
32
11
|
import { getLocalWorkspaces, pickLocalFolder, runLocalDev, } from './lib/local-fs.js';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
height: 32,
|
|
36
|
-
rounded: 8,
|
|
37
|
-
borderWidth: 1,
|
|
38
|
-
borderColor: 'var(--white-10)',
|
|
39
|
-
bg: 'transparent',
|
|
40
|
-
color: 'inherit',
|
|
41
|
-
fontSize: '$2',
|
|
42
|
-
};
|
|
12
|
+
import { formatDeviceLabel, useDevMode } from './lib/dev-mode.js';
|
|
13
|
+
import { InfoHint } from './lib/info-hint.js';
|
|
43
14
|
const SOFT = '$soft';
|
|
44
|
-
/**
|
|
15
|
+
/** Empty target routes to Hanzo's managed cloud workspace. */
|
|
45
16
|
const SANDBOX = '';
|
|
17
|
+
const CLOUD_VALUE = '__cloud__';
|
|
18
|
+
const STARTER_PROMPTS = [
|
|
19
|
+
{
|
|
20
|
+
id: 'bugfix',
|
|
21
|
+
title: phrase('Fix a bug and add regression tests'),
|
|
22
|
+
summary: phrase('Trace the failing path, patch the root cause, and verify with focused unit tests.'),
|
|
23
|
+
prompt: phrase('Find the root cause of the failing test, implement a minimal fix, and add a regression test covering the edge case.'),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'review',
|
|
27
|
+
title: phrase('Audit a branch before shipping'),
|
|
28
|
+
summary: phrase('Inspect recent changes for race conditions, accessibility gaps, and unhandled errors.'),
|
|
29
|
+
prompt: phrase('Review the latest changes on this branch for correctness, edge cases, error handling, and accessibility issues.'),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'feature',
|
|
33
|
+
title: phrase('Build a responsive view from a spec'),
|
|
34
|
+
summary: phrase('Scaffold the layout, wire state cleanly, and verify mobile and desktop breakpoints.'),
|
|
35
|
+
prompt: phrase('Implement the requested screen with clean semantic tokens, keyboard focus states, and responsive mobile stacking.'),
|
|
36
|
+
},
|
|
37
|
+
];
|
|
46
38
|
export function Start() {
|
|
47
39
|
const { t } = useI18n();
|
|
40
|
+
const [devMode] = useDevMode();
|
|
48
41
|
const { openSession } = useOpen();
|
|
49
42
|
const [prompt, setPrompt] = useState('');
|
|
50
43
|
const [repo, setRepo] = useState('');
|
|
@@ -58,9 +51,9 @@ export function Start() {
|
|
|
58
51
|
useEffect(() => {
|
|
59
52
|
let live = true;
|
|
60
53
|
listTargets()
|
|
61
|
-
.then((
|
|
54
|
+
.then((list) => live && setTargets(list.filter(dispatchable)))
|
|
62
55
|
.catch(() => {
|
|
63
|
-
/* Listing is an enhancement here;
|
|
56
|
+
/* Listing is an enhancement here; cloud workspace needs nothing from it. */
|
|
64
57
|
});
|
|
65
58
|
setLocalWorkspaces(getLocalWorkspaces());
|
|
66
59
|
return () => {
|
|
@@ -77,11 +70,11 @@ export function Start() {
|
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
72
|
catch (e) {
|
|
80
|
-
setErr(e
|
|
73
|
+
setErr(e instanceof Error ? e.message : 'Could not pick folder');
|
|
81
74
|
}
|
|
82
75
|
return;
|
|
83
76
|
}
|
|
84
|
-
setWhere(val);
|
|
77
|
+
setWhere(val === CLOUD_VALUE ? SANDBOX : val);
|
|
85
78
|
}, []);
|
|
86
79
|
const send = useCallback(async () => {
|
|
87
80
|
const task = prompt.trim();
|
|
@@ -93,13 +86,13 @@ export function Start() {
|
|
|
93
86
|
if (where.startsWith('local:')) {
|
|
94
87
|
const localPath = where.slice(6);
|
|
95
88
|
try {
|
|
96
|
-
setLocalMsg(t('Running
|
|
89
|
+
setLocalMsg(t('Running in {path}…', { path: localPath }));
|
|
97
90
|
const res = await runLocalDev(localPath, task);
|
|
98
91
|
setPrompt('');
|
|
99
|
-
setLocalMsg(res.output?.slice(0, 300) || res.sessionId || t('Completed
|
|
92
|
+
setLocalMsg(res.output?.slice(0, 300) || res.sessionId || t('Completed.'));
|
|
100
93
|
}
|
|
101
94
|
catch (e) {
|
|
102
|
-
setErr(e
|
|
95
|
+
setErr(e instanceof Error ? e.message : t('Local run failed'));
|
|
103
96
|
}
|
|
104
97
|
finally {
|
|
105
98
|
setBusy(false);
|
|
@@ -109,13 +102,11 @@ export function Start() {
|
|
|
109
102
|
try {
|
|
110
103
|
const run = await startCoding({
|
|
111
104
|
prompt: task,
|
|
112
|
-
repo: repo.trim()
|
|
113
|
-
tool: tool
|
|
105
|
+
repo: devMode && repo.trim() ? repo.trim() : undefined,
|
|
106
|
+
tool: devMode && tool ? tool : 'dev',
|
|
114
107
|
targetId: where || undefined,
|
|
115
108
|
});
|
|
116
109
|
setPrompt('');
|
|
117
|
-
// The run is ACCEPTED, not finished. Opening its session is what puts the
|
|
118
|
-
// reader where it narrates itself, which is the view this pane replaces.
|
|
119
110
|
openSession(run.sessionId);
|
|
120
111
|
}
|
|
121
112
|
catch (e) {
|
|
@@ -124,11 +115,19 @@ export function Start() {
|
|
|
124
115
|
finally {
|
|
125
116
|
setBusy(false);
|
|
126
117
|
}
|
|
127
|
-
}, [prompt, repo, tool, where, busy, openSession, t]);
|
|
118
|
+
}, [prompt, repo, tool, where, devMode, busy, openSession, t]);
|
|
128
119
|
const isLocal = where.startsWith('local:');
|
|
129
|
-
return (_jsxs(YStack, { width: "100%", gap: "$2", children: [_jsx(Composer, { value: prompt, onChange: setPrompt, onSend: () => void send(), busy: busy, placeholder: t('Describe what to build…'), label: t('Describe what to build') }), _jsxs(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
120
|
+
return (_jsxs(YStack, { width: "100%", minW: 0, gap: "$6", children: [_jsxs(YStack, { width: "100%", minW: 0, gap: "$2.5", children: [_jsx(Composer, { value: prompt, onChange: setPrompt, onSend: () => void send(), busy: busy, placeholder: t('Describe what to build…'), label: t('Describe what to build') }), _jsxs(YStack, { width: "100%", minW: 0, gap: "$1.5", children: [_jsxs(XStack, { gap: "$2", items: "center", justify: "space-between", flexWrap: "wrap", minW: 0, children: [_jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", minW: 0, "$max-sm": { width: '100%' }, children: [_jsxs(Select, { value: where || CLOUD_VALUE, onValueChange: (v) => void handleWhereChange(v), children: [_jsx(SelectTrigger, { size: "sm", width: 196, minH: 36, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { flex: 1, width: 'auto', minW: 0, minH: 44 }, "aria-label": t('Where to run'), children: _jsx(SelectValue, { placeholder: t('Cloud workspace') }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: CLOUD_VALUE, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Cloud, { size: 13, "aria-hidden": true }), _jsx(Text, { fontFamily: "$body", fontSize: "$2", color: "$ink", children: t('Cloud workspace') })] }) }), localWorkspaces.map((ws) => (_jsx(SelectItem, { value: `local:${ws.path}`, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(FolderOpen, { size: 13, "aria-hidden": true }), _jsx(Text, { fontFamily: "$body", fontSize: "$2", color: "$ink", children: ws.name })] }) }, ws.path))), _jsx(SelectItem, { value: "action:pick-local", children: _jsx(Text, { fontFamily: "$body", fontSize: "$2", color: "$aside", children: t('Open local folder…') }) }), targets.map((tg) => {
|
|
121
|
+
const formatted = formatDeviceLabel(tg.label || tg.host || tg.id, { devMode });
|
|
122
|
+
return (_jsx(SelectItem, { value: tg.id, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Laptop, { size: 13, "aria-hidden": true }), _jsx(Text, { fontFamily: "$body", fontSize: "$2", color: "$ink", children: devMode && tg.capacity
|
|
123
|
+
? `${formatted.title} · ${tg.capacity}`
|
|
124
|
+
: formatted.title })] }) }, tg.id));
|
|
125
|
+
})] })] }), _jsx(InfoHint, { text: t('Choose whether Hanzo builds in a cloud workspace or inside a folder on your computer.'), size: 13 })] }), devMode ? (_jsxs(XStack, { gap: "$2", items: "center", flex: 1, minW: 0, justify: "flex-end", flexWrap: "wrap", "$max-sm": { width: '100%', justify: 'flex-start', flexBasis: 'auto', grow: 0 }, children: [_jsxs(Select, { value: tool, onValueChange: setTool, children: [_jsx(SelectTrigger, { size: "sm", width: 120, minH: 36, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, "aria-label": t('Runner'), children: _jsx(SelectValue, { placeholder: "Dev" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "dev", children: "Dev" }), _jsx(SelectItem, { value: "claude", children: "Claude" }), _jsx(SelectItem, { value: "codex", children: "Codex" }), _jsx(SelectItem, { value: "python", children: "Python" })] })] }), !isLocal ? (_jsx(Input, { size: "sm", "data-i18n-ltr": "", value: repo, onChangeText: setRepo, placeholder: t('owner/repo (optional)'), "aria-label": t('Repository'), borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, flex: 1, minH: 36, minW: 140, maxW: 260, "$max-sm": { maxW: '100%', minH: 44 } })) : (_jsx(Text, { fontSize: "$1", fontFamily: "$mono", color: SOFT, numberOfLines: 1, flex: 1, minW: 0, children: where.slice(6) }))] })) : null] }), err ? (_jsx(Text, { role: "alert", fontSize: "$2", color: "var(--state-error)", children: err })) : localMsg ? (_jsx(Text, { fontSize: "$2", color: "$ink", children: localMsg })) : (_jsx(Text, { fontSize: "$1", color: SOFT, children: t(isLocal
|
|
126
|
+
? 'Runs in the selected folder on your computer.'
|
|
127
|
+
: targets.length > 0 && where !== SANDBOX
|
|
128
|
+
? 'Runs on your connected computer.'
|
|
129
|
+
: 'Starts immediately in a cloud workspace.') }))] })] }), !prompt.trim() && !busy ? (_jsxs(YStack, { gap: "$2.5", role: "list", "aria-label": t('Starter prompts'), "data-slot": "start-prompts", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$soft", px: "$0.5", children: t('Starter prompts') }), _jsx(YStack, { gap: "$2.5", children: STARTER_PROMPTS.map((item) => (_jsxs(XStack, { role: "listitem", render: _jsx("button", { type: "button" }), "data-slot": "start-prompt-row", onClick: () => {
|
|
130
|
+
setPrompt(t(item.prompt));
|
|
131
|
+
setErr(null);
|
|
132
|
+
}, width: "100%", minW: 0, px: "$3.5", py: "$3", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", items: "center", justify: "space-between", gap: "$3", cursor: "pointer", transition: "quickest", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 48, px: '$3', py: '$2.5' }, children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$1", items: "flex-start", children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", text: "start", numberOfLines: 1, children: t(item.title) }), _jsx(Text, { fontSize: "$2", color: "$soft", text: "start", lineHeight: "$3", numberOfLines: 2, children: t(item.summary) })] }), _jsx(YStack, { shrink: 0, items: "center", justify: "center", children: _jsx(ArrowUpRight, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }) })] }, item.id))) })] })) : null] }));
|
|
134
133
|
}
|
package/dist/Terminals.js
CHANGED
|
@@ -1,33 +1,181 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// Tabs in the app: the terminals on the reader's linked machines and
|
|
3
|
+
// Tabs in the app: the terminals on the reader's linked machines and cloud workspaces,
|
|
4
4
|
// tiled (@hanzo/tabs `Workspace`), wired by `useFleet` with the reader's own
|
|
5
5
|
// bearer against this host's cloud. The workspace holds no token; the fleet
|
|
6
|
-
// mints each pane's address.
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { Text, YStack } from '@hanzo/gui';
|
|
6
|
+
// mints each pane's address.
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { Button, Skeleton, Text, View, XStack, YStack } from '@hanzo/ui';
|
|
10
9
|
import { useFleet, Workspace } from '@hanzo/tabs';
|
|
11
10
|
import { useI18n } from '@hanzo/i18n/react';
|
|
11
|
+
import { useIam } from '@hanzo/iam/react';
|
|
12
|
+
import { Cloud, Globe, Laptop, Monitor, SquareTerminal } from 'lucide-react';
|
|
12
13
|
import { api } from './lib/api.js';
|
|
13
|
-
import {
|
|
14
|
+
import { enter, LOGIN } from './lib/destination.js';
|
|
15
|
+
import { formatDeviceLabel, useDevMode } from './lib/dev-mode.js';
|
|
16
|
+
import { InfoHint } from './lib/info-hint.js';
|
|
17
|
+
import { bearer, named } from './lib/session.js';
|
|
18
|
+
function TerminalsSkeleton({ label }) {
|
|
19
|
+
return (_jsx(YStack, { role: "status", "aria-busy": true, "aria-label": label, flex: 1, minH: 0, minW: 0, overflowY: "auto", overflowX: "hidden", children: _jsxs(YStack, { width: "100%", maxW: 760, mx: "auto", my: "auto", px: "$5", pt: "$6", pb: "$12", "$max-sm": { px: '$3', pt: '$5', pb: '$8' }, gap: "$6", children: [_jsxs(YStack, { gap: "$2", children: [_jsx(Skeleton, { layout: "block", width: 120, height: 24, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "72%", height: 14, rounded: "$2" })] }), _jsx(View, { display: "grid", gridTemplateColumns: "repeat(3, minmax(0, 1fr))", "$max-md": { gridTemplateColumns: 'minmax(0, 1fr)' }, gap: "$3", children: [0, 1, 2].map((idx) => (_jsxs(YStack, { p: "$4", rounded: "$5", bg: "$panel", borderWidth: 1, borderColor: "$edge", gap: "$4", children: [_jsx(XStack, { items: "center", justify: "space-between", children: _jsx(Skeleton, { layout: "block", width: 34, height: 34, rounded: "$3" }) }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: 88, height: 16, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "92%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "74%", height: 13, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: "100%", height: 36, rounded: "$3" })] }, idx))) }), _jsxs(YStack, { gap: "$2", children: [_jsx(Skeleton, { layout: "block", width: 140, height: 13, rounded: "$2" }), _jsx(YStack, { p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", children: _jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", children: [_jsx(Skeleton, { layout: "block", width: 150, height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 56, height: 13, rounded: "$2" })] }) })] })] }) }));
|
|
20
|
+
}
|
|
14
21
|
export default function Terminals() {
|
|
15
22
|
const { t } = useI18n();
|
|
23
|
+
const { user } = useIam();
|
|
24
|
+
const [devMode] = useDevMode();
|
|
16
25
|
const token = bearer();
|
|
17
26
|
const fleet = useFleet(token, api());
|
|
27
|
+
const [launchingKind, setLaunchingKind] = useState(null);
|
|
28
|
+
const [launchError, setLaunchError] = useState(null);
|
|
29
|
+
const [openedWorkspace, setOpenedWorkspace] = useState(false);
|
|
30
|
+
const [pendingAction, setPendingAction] = useState(null);
|
|
31
|
+
const launching = launchingKind !== null;
|
|
32
|
+
const firstName = useMemo(() => {
|
|
33
|
+
const u = user;
|
|
34
|
+
const raw = (u?.displayName || u?.name || named()?.display || named()?.name || '').trim();
|
|
35
|
+
if (!raw || raw.includes('@'))
|
|
36
|
+
return null;
|
|
37
|
+
const first = raw.split(/\s+/)[0]?.trim();
|
|
38
|
+
return first ? first.charAt(0).toUpperCase() + first.slice(1) : null;
|
|
39
|
+
}, [user]);
|
|
40
|
+
const hosts = useMemo(() => fleet.hosts.map((h) => {
|
|
41
|
+
const rawLabel = h.label || h.machine;
|
|
42
|
+
const looksLikeMacHost = /[a-z0-9]*mac\.(local|lan|home)\b/i.test(h.machine) ||
|
|
43
|
+
/macbook|imac|mac-mini|mac-studio/i.test(rawLabel);
|
|
44
|
+
const formatted = formatDeviceLabel(h.sandbox ? 'Cloud' : rawLabel, {
|
|
45
|
+
firstName,
|
|
46
|
+
os: looksLikeMacHost ? 'darwin' : undefined,
|
|
47
|
+
kind: looksLikeMacHost ? 'laptop' : undefined,
|
|
48
|
+
devMode,
|
|
49
|
+
});
|
|
50
|
+
const detail = devMode
|
|
51
|
+
? [h.label, formatted.detail, h.machine !== formatted.title ? h.machine : ''].filter(Boolean).join(' · ')
|
|
52
|
+
: formatted.detail;
|
|
53
|
+
return {
|
|
54
|
+
...h,
|
|
55
|
+
label: formatted.title,
|
|
56
|
+
title: formatted.title,
|
|
57
|
+
detail: detail || undefined,
|
|
58
|
+
};
|
|
59
|
+
}), [fleet.hosts, firstName, devMode]);
|
|
60
|
+
const liveHosts = useMemo(() => hosts.filter((h) => (h.base || h.sandbox) && h.status !== 'offline'), [hosts]);
|
|
61
|
+
const linkedLocalHosts = useMemo(() => hosts.filter((h) => !h.sandbox), [hosts]);
|
|
62
|
+
const startWorkspace = useCallback(async (kind = 'dev') => {
|
|
63
|
+
if (!token) {
|
|
64
|
+
enter(LOGIN);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (launchingKind !== null)
|
|
68
|
+
return;
|
|
69
|
+
setLaunchingKind(kind);
|
|
70
|
+
setLaunchError(null);
|
|
71
|
+
try {
|
|
72
|
+
const machine = await fleet.launch(kind);
|
|
73
|
+
setPendingAction({
|
|
74
|
+
kind: kind === 'dev' ? 'shell' : kind === 'browser' ? 'page' : 'desktop',
|
|
75
|
+
machine,
|
|
76
|
+
});
|
|
77
|
+
setOpenedWorkspace(true);
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
setLaunchError(e instanceof Error ? e.message : t('Could not start a cloud workspace.'));
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
setLaunchingKind(null);
|
|
84
|
+
}
|
|
85
|
+
}, [token, launchingKind, fleet, t]);
|
|
18
86
|
useEffect(() => {
|
|
19
87
|
if (typeof window === 'undefined' || !fleet.read)
|
|
20
88
|
return;
|
|
21
89
|
try {
|
|
22
|
-
const lite =
|
|
23
|
-
|
|
24
|
-
|
|
90
|
+
const lite = liveHosts.map((h) => ({
|
|
91
|
+
machine: h.machine,
|
|
92
|
+
label: devMode ? h.label || h.machine : (h.title || h.machine),
|
|
93
|
+
status: h.status,
|
|
94
|
+
desktop: Boolean(h.screen),
|
|
95
|
+
}));
|
|
25
96
|
window.localStorage.setItem('hanzo.tabs.fleet', JSON.stringify(lite));
|
|
26
97
|
window.dispatchEvent(new CustomEvent('hanzo:tabs-fleet', { detail: lite }));
|
|
27
98
|
}
|
|
28
99
|
catch {
|
|
29
100
|
// ignore storage errors
|
|
30
101
|
}
|
|
31
|
-
}, [
|
|
32
|
-
|
|
102
|
+
}, [liveHosts, fleet.read, devMode]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (typeof window === 'undefined')
|
|
105
|
+
return;
|
|
106
|
+
const onTabsAction = (ev) => {
|
|
107
|
+
const detail = ev.detail;
|
|
108
|
+
if (!detail?.kind)
|
|
109
|
+
return;
|
|
110
|
+
if (liveHosts.length === 0 && !openedWorkspace) {
|
|
111
|
+
if (detail.kind === 'desktop')
|
|
112
|
+
void startWorkspace('desktop');
|
|
113
|
+
else if (detail.kind === 'page')
|
|
114
|
+
void startWorkspace('browser');
|
|
115
|
+
else if (detail.kind === 'shell' || detail.kind === 'cloud')
|
|
116
|
+
void startWorkspace('dev');
|
|
117
|
+
else
|
|
118
|
+
setOpenedWorkspace(true);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
window.addEventListener('hanzo:tabs-action', onTabsAction);
|
|
122
|
+
return () => window.removeEventListener('hanzo:tabs-action', onTabsAction);
|
|
123
|
+
}, [liveHosts.length, openedWorkspace, startWorkspace]);
|
|
124
|
+
const showCalmEmpty = (!token || (fleet.read && !fleet.error && liveHosts.length === 0)) && !openedWorkspace;
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!pendingAction || showCalmEmpty || !(fleet.read || fleet.error))
|
|
127
|
+
return;
|
|
128
|
+
const action = pendingAction;
|
|
129
|
+
if (typeof window === 'undefined')
|
|
130
|
+
return;
|
|
131
|
+
const id = window.setTimeout(() => {
|
|
132
|
+
setPendingAction(null);
|
|
133
|
+
window.dispatchEvent(new CustomEvent('hanzo:tabs-action', { detail: action }));
|
|
134
|
+
}, 0);
|
|
135
|
+
return () => window.clearTimeout(id);
|
|
136
|
+
}, [pendingAction, showCalmEmpty, fleet.read, fleet.error]);
|
|
137
|
+
const launchers = [
|
|
138
|
+
{
|
|
139
|
+
kind: 'dev',
|
|
140
|
+
title: t('Terminal'),
|
|
141
|
+
summary: t('Run commands, git, and builds in a saved Linux shell.'),
|
|
142
|
+
info: t('A cloud Linux shell for running scripts, git, builds, and local servers with files kept between sessions.'),
|
|
143
|
+
action: !token ? t('Sign in') : launchingKind === 'dev' ? t('Starting…') : t('Open terminal'),
|
|
144
|
+
primary: true,
|
|
145
|
+
icon: _jsx(SquareTerminal, { size: 17, color: "var(--foreground)", "aria-hidden": true }),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
kind: 'desktop',
|
|
149
|
+
title: t('Desktop'),
|
|
150
|
+
summary: t('View and control a full visual desktop in your browser.'),
|
|
151
|
+
info: t('A full visual cloud desktop you can view and control right inside your browser.'),
|
|
152
|
+
action: !token ? t('Sign in') : launchingKind === 'desktop' ? t('Starting…') : t('Open desktop'),
|
|
153
|
+
primary: false,
|
|
154
|
+
icon: _jsx(Monitor, { size: 17, color: "var(--foreground)", "aria-hidden": true }),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
kind: 'browser',
|
|
158
|
+
title: t('Browser'),
|
|
159
|
+
summary: t('Preview apps and browse in an isolated workspace tab.'),
|
|
160
|
+
info: t('An isolated workspace browser tab for previewing web apps, testing flows, or browsing alongside agents.'),
|
|
161
|
+
action: !token ? t('Sign in') : launchingKind === 'browser' ? t('Starting…') : t('Open browser'),
|
|
162
|
+
primary: false,
|
|
163
|
+
icon: _jsx(Globe, { size: 17, color: "var(--foreground)", "aria-hidden": true }),
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
return (_jsxs(YStack, { "data-slot": "terminals", flex: 1, minH: 0, minW: 0, bg: "$background", children: [fleet.error ? (_jsxs(XStack, { role: "alert", px: "$4", py: "$2.5", gap: "$3", items: "center", justify: "space-between", flexWrap: "wrap", bg: "$panel", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { fontSize: "$2", color: "var(--state-error)", flex: 1, minW: 0, children: devMode
|
|
167
|
+
? t('The machines could not be read: {error}', { error: fleet.error })
|
|
168
|
+
: t('Could not load your workspaces right now: {error}', { error: fleet.error }) }), _jsx(Button, { size: "sm", variant: "outline", rounded: "$3", minH: 36, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => fleet.refresh(), children: t('Try again') })] })) : null, showCalmEmpty ? (_jsx(YStack, { "data-slot": "terminals-empty", flex: 1, minH: 0, minW: 0, overflowY: "auto", overflowX: "hidden", children: _jsxs(YStack, { width: "100%", maxW: 760, mx: "auto", my: "auto", px: "$5", pt: "$6", pb: "$12", "$max-sm": { px: '$3', pt: '$5', pb: '$8' }, gap: "$6", children: [_jsxs(YStack, { gap: "$1.5", maxW: 580, children: [_jsx(Text, { render: "h1", m: 0, fontSize: "$7", lineHeight: "$8", fontWeight: "600", letterSpacing: -0.42, color: "$ink", children: t('Tabs') }), _jsx(Text, { fontSize: "$3", color: "$soft", lineHeight: "$4", children: !token
|
|
169
|
+
? t('Sign in to open a cloud terminal, visual desktop, or isolated browser tab — everything stays saved in your workspace.')
|
|
170
|
+
: t('Open a cloud terminal, visual desktop, or isolated browser tab — everything stays saved in your workspace.') })] }), launchError ? (_jsx(Text, { role: "alert", fontSize: "$2", color: "var(--state-error)", children: launchError })) : null, _jsx(View, { "data-slot": "terminals-launchers", display: "grid", gridTemplateColumns: "repeat(3, minmax(0, 1fr))", "$max-md": { gridTemplateColumns: 'minmax(0, 1fr)' }, gap: "$3", minW: 0, children: launchers.map((card) => (_jsxs(YStack, { "data-launcher": card.kind, p: "$4", rounded: "$5", bg: "$panel", borderWidth: 1, borderColor: "$edge", gap: "$4", justify: "space-between", minW: 0, transition: "quickest", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, children: [_jsxs(YStack, { gap: "$3", minW: 0, children: [_jsx(YStack, { width: 34, height: 34, rounded: "$3", bg: "$raised", borderWidth: 1, borderColor: "$edge", items: "center", justify: "center", shrink: 0, children: card.icon }), _jsxs(YStack, { gap: "$1", minW: 0, children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: card.title }), _jsx(Text, { fontSize: "$2", color: "$soft", lineHeight: "$3", children: card.summary })] })] }), _jsx(Button, { size: "sm", variant: card.primary ? 'default' : 'outline', ...(card.primary
|
|
171
|
+
? { bg: 'var(--primary)', color: 'var(--primary-foreground)', hoverStyle: { bg: 'var(--primary-hover, var(--primary))' } }
|
|
172
|
+
: { borderColor: 'var(--border-strong)' }), rounded: "$3", width: "100%", minH: 36, "$max-sm": { minH: 44 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, disabled: launching, "data-slot": card.primary ? 'terminals-empty-cta' : `terminals-launch-${card.kind}`, onClick: () => void startWorkspace(card.kind), children: card.action })] }, card.kind))) }), _jsxs(YStack, { gap: "$2.5", minW: 0, "data-slot": "terminals-environments", children: [_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$soft", children: t('Available environments') }), _jsx(InfoHint, { text: t('Cloud workspaces start on demand. Linked local computers stay ready here whenever hanzo link is running.'), size: 13, side: "top" })] }), _jsxs(YStack, { rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", overflow: "hidden", children: [_jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => void startWorkspace('dev'), disabled: launching, width: "100%", minW: 0, minH: 44, px: "$3.5", py: "$2.5", gap: "$3", items: "center", justify: "space-between", bg: "transparent", borderWidth: 0, cursor: "pointer", transition: "quickest", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, children: [_jsxs(XStack, { items: "center", gap: "$2.5", flex: 1, minW: 0, children: [_jsx(Cloud, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }), _jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", gap: "$0.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", numberOfLines: 1, text: "start", children: t('Auto (Cloud)') }), _jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, text: "start", children: t('Managed cloud workspace · persistent storage') })] })] }), _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [_jsx(YStack, { width: 7, height: 7, rounded: 9999, bg: token ? 'var(--state-online)' : '$edge', "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", children: token ? t('Ready') : t('Sign in') })] })] }), linkedLocalHosts.map((host) => {
|
|
173
|
+
const online = host.status !== 'offline';
|
|
174
|
+
return (_jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => {
|
|
175
|
+
if (online)
|
|
176
|
+
setOpenedWorkspace(true);
|
|
177
|
+
}, disabled: !online, width: "100%", minW: 0, minH: 44, px: "$3.5", py: "$2.5", gap: "$3", items: "center", justify: "space-between", bg: "transparent", borderWidth: 0, borderTopWidth: 1, borderTopColor: "$edge", cursor: online ? 'pointer' : 'default', opacity: online ? 1 : 0.65, transition: "quickest", ...(online ? { hoverStyle: { bg: '$hover' } } : null), focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, children: [_jsxs(XStack, { items: "center", gap: "$2.5", flex: 1, minW: 0, children: [_jsx(Laptop, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }), _jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", gap: "$0.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", numberOfLines: 1, text: "start", children: /^local\b/i.test(host.title || host.machine)
|
|
178
|
+
? host.title || host.machine
|
|
179
|
+
: t('Local · {name}', { name: host.title || host.machine }) }), _jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, text: "start", children: host.detail || t('Connected local machine') })] })] }), _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [_jsx(YStack, { width: 7, height: 7, rounded: 9999, bg: online ? 'var(--state-online)' : '$edge', "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", children: online ? t('Online') : t('Offline') })] })] }, host.machine));
|
|
180
|
+
}), devMode && linkedLocalHosts.length === 0 ? (_jsxs(XStack, { px: "$3.5", py: "$2.5", borderTopWidth: 1, borderTopColor: "$edge", items: "center", gap: "$2", children: [_jsx(Laptop, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Run hanzo link to connect a local machine') })] })) : null] })] })] }) })) : fleet.read || fleet.error ? (_jsx(Workspace, { hosts: hosts, mint: fleet.mint, onLaunch: fleet.launch, agent: fleet.agent })) : (_jsx(TerminalsSkeleton, { label: devMode ? t('Reading your machines…') : t('Loading your workspaces…') }))] }));
|
|
33
181
|
}
|
package/dist/ToBottom.js
CHANGED
|
@@ -54,7 +54,7 @@ export function ToBottom({ within }) {
|
|
|
54
54
|
}, [within]);
|
|
55
55
|
if (lift === null)
|
|
56
56
|
return null;
|
|
57
|
-
return (_jsx(XStack, { render: "button", "aria-label": t('Scroll to bottom'), "data-slot": "to-bottom",
|
|
57
|
+
return (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": t('Scroll to bottom'), "data-slot": "to-bottom", onClick: () => {
|
|
58
58
|
const thread = within?.querySelector('[data-slot="thread"]');
|
|
59
59
|
thread?.scrollTo({ top: thread.scrollHeight, behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' });
|
|
60
60
|
}, position: "absolute", b: lift, l: "50%", ml: -18, width: 36, height: 36, rounded: 999, items: "center", justify: "center", cursor: "pointer", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, bg: "$raised", borderWidth: 1, borderColor: "$borderColor", z: 5, children: _jsx(ArrowDown, { size: 16, "aria-hidden": true }) }));
|
package/dist/Upgrade.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ export interface Ask {
|
|
|
3
3
|
model?: string;
|
|
4
4
|
href?: string;
|
|
5
5
|
}
|
|
6
|
+
export interface UpgradeEventDetail {
|
|
7
|
+
tier?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Opens the global in-app Upgrade modal from anywhere in the signed-in shell. */
|
|
10
|
+
export declare function requestUpgrade(detail?: UpgradeEventDetail): void;
|
|
6
11
|
/** Whether a signed-in reader's organization is on the Free plan. A tier not yet read, or refused, is not Free. */
|
|
7
12
|
export declare function useFree(signedIn: boolean): boolean;
|
|
8
|
-
export declare function Upgrade({ ask, onClose }
|
|
9
|
-
ask
|
|
10
|
-
onClose
|
|
13
|
+
export declare function Upgrade({ ask, onClose }?: {
|
|
14
|
+
ask?: Ask | null;
|
|
15
|
+
onClose?: () => void;
|
|
11
16
|
}): import("react").JSX.Element;
|