@celljs/ta-web 4.9.0 → 4.9.1
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/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/assistant/assistant-extension.js +13 -5
- package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-source.js +2 -0
- package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
- package/esm/browser/assistant/assistant-task-util.js +8 -0
- package/esm/browser/assistant/assistant-tasks.js +3 -2
- package/esm/browser/assistant/assistant.d.ts +20 -0
- package/esm/browser/assistant/assistant.js +45 -1
- package/esm/browser/assistant/task-views.d.ts +40 -6
- package/esm/browser/assistant/task-views.js +73 -21
- package/esm/browser/avatar/dino-avatar.d.ts +3 -4
- package/esm/browser/avatar/dino-avatar.js +4 -178
- package/esm/browser/avatar/dino-face.d.ts +19 -0
- package/esm/browser/avatar/dino-face.js +142 -0
- package/esm/browser/avatar/dino-geometry.d.ts +11 -0
- package/esm/browser/avatar/dino-geometry.js +38 -0
- package/esm/browser/avatar/dino-kinds.d.ts +15 -0
- package/esm/browser/avatar/dino-kinds.js +544 -0
- package/esm/browser/avatar/dino-motion.js +1 -1
- package/esm/browser/avatar/dino-shape.d.ts +80 -0
- package/esm/browser/avatar/dino-shape.js +113 -0
- package/esm/browser/avatar/dino-species.d.ts +1 -61
- package/esm/browser/avatar/dino-species.js +2 -653
- package/esm/browser/components/access-view.js +1 -1
- package/esm/browser/components/account-menu.js +1 -1
- package/esm/browser/components/app-shell-hooks.d.ts +47 -0
- package/esm/browser/components/app-shell-hooks.js +165 -0
- package/esm/browser/components/app-view.js +6 -151
- package/esm/browser/components/auth-view.js +1 -1
- package/esm/browser/components/composer.js +17 -10
- package/esm/browser/components/dino.js +1 -1
- package/esm/browser/components/folder-picker.js +4 -1
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/host-view.js +1 -1
- package/esm/browser/components/select-bar.d.ts +9 -0
- package/esm/browser/components/select-bar.js +24 -0
- package/esm/browser/components/settings-choices.d.ts +35 -0
- package/esm/browser/components/settings-choices.js +117 -0
- package/esm/browser/components/settings-parts.d.ts +21 -0
- package/esm/browser/components/settings-parts.js +300 -0
- package/esm/browser/components/settings-view.d.ts +0 -6
- package/esm/browser/components/settings-view.js +4 -406
- package/esm/browser/components/workbench-view.js +1 -1
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-extension-api.d.ts +38 -1
- package/esm/browser/extension/web-extensions.js +6 -1
- package/esm/browser/extension/web-tasks.d.ts +9 -1
- package/esm/browser/extension/web-tasks.js +24 -0
- package/esm/browser/hooks.d.ts +3 -1
- package/esm/browser/hooks.js +8 -0
- package/esm/browser/i18n/locales.d.ts +6 -1
- package/esm/browser/i18n/messages.d.ts +5 -0
- package/esm/browser/i18n/messages.js +10 -0
- package/esm/browser/style/device.js +16 -0
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +1 -0
- package/esm/browser/style/tasks.d.ts +1 -1
- package/esm/browser/style/tasks.js +2 -0
- package/esm/browser/workbench-util.d.ts +61 -0
- package/esm/browser/workbench-util.js +138 -0
- package/esm/browser/workbench.d.ts +1 -37
- package/esm/browser/workbench.js +2 -136
- package/lib/browser/assistant/assistant-extension.js +13 -5
- package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-source.js +2 -0
- package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
- package/lib/browser/assistant/assistant-task-util.js +8 -0
- package/lib/browser/assistant/assistant-tasks.js +2 -1
- package/lib/browser/assistant/assistant.d.ts +20 -0
- package/lib/browser/assistant/assistant.js +45 -1
- package/lib/browser/assistant/task-views.d.ts +40 -6
- package/lib/browser/assistant/task-views.js +74 -21
- package/lib/browser/avatar/dino-avatar.d.ts +3 -4
- package/lib/browser/avatar/dino-avatar.js +27 -202
- package/lib/browser/avatar/dino-face.d.ts +20 -0
- package/lib/browser/avatar/dino-face.js +148 -0
- package/lib/browser/avatar/dino-geometry.d.ts +12 -0
- package/lib/browser/avatar/dino-geometry.js +47 -0
- package/lib/browser/avatar/dino-kinds.d.ts +16 -0
- package/lib/browser/avatar/dino-kinds.js +547 -0
- package/lib/browser/avatar/dino-motion.js +2 -2
- package/lib/browser/avatar/dino-shape.d.ts +81 -0
- package/lib/browser/avatar/dino-shape.js +126 -0
- package/lib/browser/avatar/dino-species.d.ts +1 -61
- package/lib/browser/avatar/dino-species.js +34 -687
- package/lib/browser/components/access-view.js +2 -2
- package/lib/browser/components/account-menu.js +2 -2
- package/lib/browser/components/app-shell-hooks.d.ts +48 -0
- package/lib/browser/components/app-shell-hooks.js +207 -0
- package/lib/browser/components/app-view.js +16 -161
- package/lib/browser/components/auth-view.js +3 -3
- package/lib/browser/components/composer.js +17 -10
- package/lib/browser/components/dino.js +3 -3
- package/lib/browser/components/folder-picker.js +4 -1
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/host-view.js +5 -5
- package/lib/browser/components/select-bar.d.ts +10 -0
- package/lib/browser/components/select-bar.js +61 -0
- package/lib/browser/components/settings-choices.d.ts +36 -0
- package/lib/browser/components/settings-choices.js +156 -0
- package/lib/browser/components/settings-parts.d.ts +22 -0
- package/lib/browser/components/settings-parts.js +336 -0
- package/lib/browser/components/settings-view.d.ts +0 -6
- package/lib/browser/components/settings-view.js +2 -405
- package/lib/browser/components/workbench-view.js +3 -3
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-extension-api.d.ts +38 -1
- package/lib/browser/extension/web-extensions.js +5 -0
- package/lib/browser/extension/web-tasks.d.ts +9 -1
- package/lib/browser/extension/web-tasks.js +24 -0
- package/lib/browser/hooks.d.ts +3 -1
- package/lib/browser/hooks.js +9 -0
- package/lib/browser/i18n/locales.d.ts +6 -1
- package/lib/browser/i18n/messages.d.ts +5 -0
- package/lib/browser/i18n/messages.js +10 -0
- package/lib/browser/style/device.js +16 -0
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +1 -0
- package/lib/browser/style/tasks.d.ts +1 -1
- package/lib/browser/style/tasks.js +2 -0
- package/lib/browser/workbench-util.d.ts +62 -0
- package/lib/browser/workbench-util.js +144 -0
- package/lib/browser/workbench.d.ts +1 -37
- package/lib/browser/workbench.js +24 -159
- package/package.json +7 -7
|
@@ -5,7 +5,7 @@ import { ScanError, Scanner } from '../device/scanner.js';
|
|
|
5
5
|
import { useNotices, useWorkbench } from '../hooks.js';
|
|
6
6
|
import { HostUtil } from '../hosts.js';
|
|
7
7
|
import { useT } from '../i18n/use-t.js';
|
|
8
|
-
import { WorkbenchError, WorkbenchUtil } from '../workbench.js';
|
|
8
|
+
import { WorkbenchError, WorkbenchUtil } from '../workbench-util.js';
|
|
9
9
|
import { Callout } from './callout.js';
|
|
10
10
|
import { ChatListUtil } from './chat-list.js';
|
|
11
11
|
import { useContextMenu } from './context-menu.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { WebSelectBarProps, WebSelectCheckProps } from '../extension/web-extension-api.js';
|
|
3
|
+
/** The round mark at the start of a row while its list is selecting, as WeChat's: filled once chosen. */
|
|
4
|
+
export declare function SelectCheck({ checked, disabled }: WebSelectCheckProps): React.JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* Under a list that is selecting: Select all (or none, once all are), how many are chosen, what can be done
|
|
7
|
+
* with them and Done. Every list of the page and of web extensions (`ui.SelectBar`) takes it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SelectBar({ count, total, onSelectAll, onDone, actions }: WebSelectBarProps): React.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Check } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useT } from '../i18n/use-t.js';
|
|
4
|
+
import { Icon } from './icon.js';
|
|
5
|
+
/** The round mark at the start of a row while its list is selecting, as WeChat's: filled once chosen. */
|
|
6
|
+
export function SelectCheck({ checked, disabled }) {
|
|
7
|
+
return (React.createElement("span", { className: "ta-select-check", "data-checked": checked ? '' : undefined, "data-disabled": disabled ? '' : undefined, "aria-hidden": "true" }, checked && React.createElement(Icon, { icon: Check, size: 12 })));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Under a list that is selecting: Select all (or none, once all are), how many are chosen, what can be done
|
|
11
|
+
* with them and Done. Every list of the page and of web extensions (`ui.SelectBar`) takes it.
|
|
12
|
+
*/
|
|
13
|
+
export function SelectBar({ count, total, onSelectAll, onDone, actions }) {
|
|
14
|
+
const t = useT();
|
|
15
|
+
const all = total > 0 && count >= total;
|
|
16
|
+
return (React.createElement("div", { className: "ta-select-bar", role: "toolbar", "aria-label": t('ta.select.count', { count }) },
|
|
17
|
+
React.createElement("button", { type: "button", className: "ta-select-bar-all", disabled: total === 0, onClick: () => onSelectAll(!all) },
|
|
18
|
+
React.createElement(SelectCheck, { checked: all }),
|
|
19
|
+
t('ta.select.all')),
|
|
20
|
+
React.createElement("span", { className: "ta-select-bar-count", "aria-live": "polite" }, t('ta.select.count', { count })),
|
|
21
|
+
actions.map(action => (React.createElement("button", { key: action.key, type: "button", className: `ta-button ta-select-bar-action${action.danger ? ' ta-danger' : ''}`, disabled: count === 0, onClick: action.run }, action.label))),
|
|
22
|
+
React.createElement("button", { type: "button", className: "ta-button ta-select-bar-done", onClick: onDone }, t('ta.select.done'))));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=select-bar.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type TaPackageInfo } from '@celljs/ta-protocol';
|
|
2
|
+
import { type LucideIcon } from 'lucide-react';
|
|
3
|
+
import type { MessageId } from '../i18n/messages.js';
|
|
4
|
+
import type { useT } from '../i18n/use-t.js';
|
|
5
|
+
import type { FontSize, LanguageSetting, ThemeSetting } from '../settings/settings-protocol.js';
|
|
6
|
+
import type { Navigation } from './nav-places.js';
|
|
7
|
+
import { type Choice, type RowEntry } from './settings-controls.js';
|
|
8
|
+
export declare const THEMES: Choice<ThemeSetting>[];
|
|
9
|
+
export declare const FONT_SIZES: Choice<FontSize>[];
|
|
10
|
+
export declare const LANGUAGES: Choice<LanguageSetting>[];
|
|
11
|
+
export declare const GROUP_ICONS: Record<string, LucideIcon>;
|
|
12
|
+
/** The keys of the page and of the message box; `Mod` is ⌘ on a Mac, Ctrl elsewhere. */
|
|
13
|
+
export declare const SHORTCUTS: {
|
|
14
|
+
keys: string;
|
|
15
|
+
label: MessageId;
|
|
16
|
+
}[];
|
|
17
|
+
/**
|
|
18
|
+
* The packages pi loads, as the server lists them, those turned off too: the built-in ones turn off and
|
|
19
|
+
* stay; the others turn off and on, and go.
|
|
20
|
+
*/
|
|
21
|
+
export declare function usePackages(): {
|
|
22
|
+
packages: TaPackageInfo[];
|
|
23
|
+
toggle: (pkg: TaPackageInfo, on: boolean) => Promise<void>;
|
|
24
|
+
remove: (pkg: TaPackageInfo) => Promise<void>;
|
|
25
|
+
read: () => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
export declare const SLOTS: Choice<string>[];
|
|
28
|
+
/** The rows of the navigation: how many pages it shows, and where each page is. */
|
|
29
|
+
export declare function navigationRows(navigation: Navigation, t: ReturnType<typeof useT>): RowEntry[];
|
|
30
|
+
/** How a package shows in a row: what it calls itself for people, else its name and the description of its package.json. */
|
|
31
|
+
export declare function packageLabel(pkg: TaPackageInfo, language: string): {
|
|
32
|
+
title: string;
|
|
33
|
+
summary: string | undefined;
|
|
34
|
+
icon: import("../index.js").WebIcon;
|
|
35
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { TaPackageTextUtil } from '@celljs/ta-protocol';
|
|
2
|
+
import { Globe, Layers, MessagesSquare, Monitor, Moon, Puzzle, RefreshCw, Sparkles, Sun, Wrench } from 'lucide-react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { WEB_ICONS } from '../extension/icons.js';
|
|
5
|
+
import { WebLabelUtil } from '../extension/web-extension-protocol.js';
|
|
6
|
+
import { useWebExtensions, useWorkbench } from '../hooks.js';
|
|
7
|
+
import { NavigationUtil } from '../settings/navigation.js';
|
|
8
|
+
import { Icon } from './icon.js';
|
|
9
|
+
import { EmptyRow, Row, row, Segmented, Switch } from './settings-controls.js';
|
|
10
|
+
export const THEMES = [
|
|
11
|
+
{ value: 'system', icon: Monitor, label: 'ta.settings.theme.system' },
|
|
12
|
+
{ value: 'light', icon: Sun, label: 'ta.settings.theme.light' },
|
|
13
|
+
{ value: 'dark', icon: Moon, label: 'ta.settings.theme.dark' },
|
|
14
|
+
];
|
|
15
|
+
export const FONT_SIZES = [
|
|
16
|
+
{ value: 'small', label: 'ta.settings.fontSize.small' },
|
|
17
|
+
{ value: 'standard', label: 'ta.settings.fontSize.standard' },
|
|
18
|
+
{ value: 'large', label: 'ta.settings.fontSize.large' },
|
|
19
|
+
{ value: 'xlarge', label: 'ta.settings.fontSize.xlarge' },
|
|
20
|
+
];
|
|
21
|
+
export const LANGUAGES = [
|
|
22
|
+
{ value: 'system', icon: Globe, label: 'ta.settings.language.system' },
|
|
23
|
+
{ value: 'zh-CN', label: '简体中文' },
|
|
24
|
+
{ value: 'en-US', label: 'English' },
|
|
25
|
+
];
|
|
26
|
+
export const GROUP_ICONS = { model: Sparkles, conversation: MessagesSquare, context: Layers, tools: Wrench };
|
|
27
|
+
/** The keys of the page and of the message box; `Mod` is ⌘ on a Mac, Ctrl elsewhere. */
|
|
28
|
+
export const SHORTCUTS = [
|
|
29
|
+
{ keys: 'Mod+,', label: 'ta.shortcut.settings' },
|
|
30
|
+
{ keys: 'Mod+B', label: 'ta.shortcut.sidebar' },
|
|
31
|
+
{ keys: 'Enter', label: 'ta.shortcut.send' },
|
|
32
|
+
{ keys: 'Shift+Enter', label: 'ta.shortcut.newline' },
|
|
33
|
+
{ keys: 'Alt+Enter', label: 'ta.shortcut.followUp' },
|
|
34
|
+
{ keys: 'Esc', label: 'ta.shortcut.stop' },
|
|
35
|
+
{ keys: '/', label: 'ta.shortcut.commands' },
|
|
36
|
+
{ keys: '@', label: 'ta.shortcut.files' },
|
|
37
|
+
{ keys: 'Mod+S', label: 'ta.shortcut.save' },
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* The packages pi loads, as the server lists them, those turned off too: the built-in ones turn off and
|
|
41
|
+
* stay; the others turn off and on, and go.
|
|
42
|
+
*/
|
|
43
|
+
export function usePackages() {
|
|
44
|
+
const [workbench, bench] = useWorkbench();
|
|
45
|
+
const [, host] = useWebExtensions();
|
|
46
|
+
const [packages, setPackages] = React.useState([]);
|
|
47
|
+
const read = React.useCallback(() => bench.packages.listPackages().then(setPackages), [bench]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (workbench.status === 'online') {
|
|
50
|
+
read().catch(() => undefined);
|
|
51
|
+
}
|
|
52
|
+
}, [workbench.status, read]);
|
|
53
|
+
const changed = async () => {
|
|
54
|
+
await host.reloadPackages();
|
|
55
|
+
await read();
|
|
56
|
+
};
|
|
57
|
+
/** By the name of a built-in package, by the id of another. */
|
|
58
|
+
const toggle = async (pkg, on) => {
|
|
59
|
+
setPackages(current => current.map(other => (other.id === pkg.id ? { ...other, enabled: on } : other)));
|
|
60
|
+
await bench.packages.setPackageEnabled(pkg.origin === 'builtin' ? pkg.name : pkg.id, on);
|
|
61
|
+
await changed();
|
|
62
|
+
};
|
|
63
|
+
const remove = async (pkg) => {
|
|
64
|
+
await bench.packages.removePackage(pkg.id);
|
|
65
|
+
await changed();
|
|
66
|
+
};
|
|
67
|
+
return { packages, toggle, remove, read };
|
|
68
|
+
}
|
|
69
|
+
export const SLOTS = Array.from({ length: NavigationUtil.MAX_SLOTS - NavigationUtil.MIN_SLOTS + 1 }, (_, index) => {
|
|
70
|
+
const value = String(NavigationUtil.MIN_SLOTS + index);
|
|
71
|
+
return { value, label: value };
|
|
72
|
+
});
|
|
73
|
+
/** The rows of the navigation: how many pages it shows, and where each page is. */
|
|
74
|
+
export function navigationRows(navigation, t) {
|
|
75
|
+
const { setting } = navigation;
|
|
76
|
+
const where = (id, byDefault) => {
|
|
77
|
+
if (setting.pinned.includes(id) && navigation.nav.some(page => page.id === id)) {
|
|
78
|
+
return t('ta.settings.navigation.pinned');
|
|
79
|
+
}
|
|
80
|
+
if (navigation.nav.some(page => page.id === id)) {
|
|
81
|
+
return t('ta.settings.navigation.inNav');
|
|
82
|
+
}
|
|
83
|
+
return t(setting.discover.includes(id) || byDefault ? 'ta.settings.navigation.folded' : 'ta.settings.navigation.overflow');
|
|
84
|
+
};
|
|
85
|
+
return [
|
|
86
|
+
row('navigation-slots', [t('ta.settings.navigation.slots'), t('ta.settings.navigation.slotsHint'), t('ta.discover')], React.createElement(Row, { label: t('ta.settings.navigation.slots'), description: t('ta.settings.navigation.slotsHint'), stacked: true },
|
|
87
|
+
React.createElement(Segmented, { label: t('ta.settings.navigation.slots'), value: String(setting.slots), choices: SLOTS, onChange: slots => navigation.update({ ...setting, slots: Number(slots) }) }))),
|
|
88
|
+
...navigation.pages.map(page => {
|
|
89
|
+
const title = WebLabelUtil.text(page.title);
|
|
90
|
+
const shown = navigation.nav.includes(page);
|
|
91
|
+
return row(`navigation:${page.id}`, [title, t('ta.settings.navigation')], React.createElement(Row, { label: title, description: where(page.id, page.discover) },
|
|
92
|
+
React.createElement(Switch, { label: `${t('ta.settings.navigation.show')} · ${title}`, checked: shown, onChange: on => (on ? navigation.pin(page.id) : navigation.fold(page.id)) })));
|
|
93
|
+
}),
|
|
94
|
+
...(navigation.pages.length === 0
|
|
95
|
+
? [row('navigation:none', [t('ta.settings.navigation.none')], React.createElement(EmptyRow, { title: t('ta.settings.navigation.none') }))]
|
|
96
|
+
: []),
|
|
97
|
+
...(NavigationUtil.moved(setting)
|
|
98
|
+
? [
|
|
99
|
+
row('navigation-reset', [t('ta.settings.navigation.reset')], React.createElement(Row, { label: t('ta.settings.navigation.reset'), description: t('ta.settings.navigation.resetHint') },
|
|
100
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => navigation.update(NavigationUtil.reset(setting)) },
|
|
101
|
+
React.createElement(Icon, { icon: RefreshCw, size: 14 }),
|
|
102
|
+
" ",
|
|
103
|
+
t('ta.settings.navigation.resetButton')))),
|
|
104
|
+
]
|
|
105
|
+
: []),
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
/** How a package shows in a row: what it calls itself for people, else its name and the description of its package.json. */
|
|
109
|
+
export function packageLabel(pkg, language) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
return {
|
|
112
|
+
title: (_a = TaPackageTextUtil.pick(pkg.title, language)) !== null && _a !== void 0 ? _a : pkg.name,
|
|
113
|
+
summary: (_b = TaPackageTextUtil.pick(pkg.summary, language)) !== null && _b !== void 0 ? _b : pkg.description,
|
|
114
|
+
icon: (pkg.icon && WEB_ICONS[pkg.icon]) || Puzzle,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=settings-choices.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TaSettingsScope } from '@celljs/ta-protocol';
|
|
2
|
+
import { type LucideIcon } from 'lucide-react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { type RowEntry } from './settings-controls.js';
|
|
5
|
+
export interface SectionEntry {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
icon: LucideIcon;
|
|
9
|
+
rows: RowEntry[];
|
|
10
|
+
}
|
|
11
|
+
export interface Part {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
sections: SectionEntry[];
|
|
15
|
+
/** Drawn above its sections, whatever the search, and on a phone above each: the scope of the settings of ta. */
|
|
16
|
+
lead?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/** What a row of the settings opens over them. */
|
|
19
|
+
export type SettingsDialog = 'accounts' | 'directory' | 'relay';
|
|
20
|
+
/** The sections of the page and of ta, by part, with their rows. */
|
|
21
|
+
export declare function useParts(scope: TaSettingsScope, onScope: (scope: TaSettingsScope) => void, onClose: () => void, onDialog: (dialog: SettingsDialog) => void): Part[];
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, Palette, Puzzle, RefreshCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useDevice } from '../device/device.js';
|
|
4
|
+
import { useNotices, useSettings, useSettingsServer, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
5
|
+
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
6
|
+
import { AGENT_SETTINGS_GROUPS, AgentSettingsUtil } from '../settings/agent-settings.js';
|
|
7
|
+
import { MAX_TASKS_CHOICES } from '../settings/settings-protocol.js';
|
|
8
|
+
import { WorkbenchUtil } from '../workbench-util.js';
|
|
9
|
+
import { AccessSettings, useAccess } from './access-view.js';
|
|
10
|
+
import { AgentControl, ScopeBar, useAgentSettings } from './agent-settings-view.js';
|
|
11
|
+
import { useNavigation } from './app-nav.js';
|
|
12
|
+
import { EnvironmentSettings, useGateway } from './environment-view.js';
|
|
13
|
+
import { Icon, IconButton } from './icon.js';
|
|
14
|
+
import { useLaunchRows } from './launch-settings.js';
|
|
15
|
+
import { SettingsModelPicker } from './model-picker.js';
|
|
16
|
+
import { RemoteHosts } from './remote-hosts.js';
|
|
17
|
+
import { EmptyRow, Keys, Row, row, Segmented, Switch } from './settings-controls.js';
|
|
18
|
+
import { TrustedDomains } from './trusted-domains.js';
|
|
19
|
+
import { FONT_SIZES, GROUP_ICONS, LANGUAGES, navigationRows, packageLabel, SHORTCUTS, THEMES, usePackages } from './settings-choices.js';
|
|
20
|
+
/** The sections of the page and of ta, by part, with their rows. */
|
|
21
|
+
export function useParts(scope, onScope, onClose, onDialog) {
|
|
22
|
+
var _a;
|
|
23
|
+
const t = useT();
|
|
24
|
+
const language = useLanguage();
|
|
25
|
+
const [{ settings }, store] = useSettings();
|
|
26
|
+
const settingsServer = useSettingsServer();
|
|
27
|
+
const [workbench, bench] = useWorkbench();
|
|
28
|
+
const [{ extensions, cwd, views }, host] = useWebExtensions();
|
|
29
|
+
const navigation = useNavigation(views);
|
|
30
|
+
const packageList = usePackages();
|
|
31
|
+
const builtinPackages = packageList.packages.filter(pkg => pkg.origin === 'builtin');
|
|
32
|
+
const agent = useAgentSettings(cwd !== null && cwd !== void 0 ? cwd : (_a = workbench.server) === null || _a === void 0 ? void 0 : _a.cwd);
|
|
33
|
+
const [, notices] = useNotices();
|
|
34
|
+
const access = useAccess();
|
|
35
|
+
const gateway = useGateway();
|
|
36
|
+
// As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
|
|
37
|
+
// that pairs phones, and signs out at the foot of Me.
|
|
38
|
+
const touch = useDevice(device => device.touch);
|
|
39
|
+
const handheld = useDevice(device => device.handheld);
|
|
40
|
+
const [busy, setBusy] = React.useState(false);
|
|
41
|
+
const run = (action, done) => {
|
|
42
|
+
setBusy(true);
|
|
43
|
+
action()
|
|
44
|
+
.then(() => done && notices.notify(done, { level: 'success' }))
|
|
45
|
+
.catch(error => notices.error(error))
|
|
46
|
+
.finally(() => setBusy(false));
|
|
47
|
+
};
|
|
48
|
+
const remove = async (pkg) => {
|
|
49
|
+
const confirmed = await notices.confirm({
|
|
50
|
+
title: t('ta.packages.removeConfirm', { name: pkg.name }),
|
|
51
|
+
message: t('ta.packages.removeDetail'),
|
|
52
|
+
confirmLabel: t('ta.packages.remove'),
|
|
53
|
+
danger: true,
|
|
54
|
+
});
|
|
55
|
+
if (confirmed) {
|
|
56
|
+
run(() => packageList.remove(pkg), t('ta.packages.removed', { name: pkg.name }));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const toggleBuiltin = (name, on) => {
|
|
60
|
+
store.update({ builtinsOff: on ? settings.builtinsOff.filter(other => other !== name) : [...settings.builtinsOff, name] });
|
|
61
|
+
run(() => host.refresh());
|
|
62
|
+
};
|
|
63
|
+
const web = [
|
|
64
|
+
{
|
|
65
|
+
id: 'appearance',
|
|
66
|
+
title: t('ta.settings.appearance'),
|
|
67
|
+
icon: Palette,
|
|
68
|
+
rows: [
|
|
69
|
+
row('theme', [t('ta.settings.theme'), 'theme'], React.createElement(Row, { label: t('ta.settings.theme'), stacked: true },
|
|
70
|
+
React.createElement(Segmented, { label: t('ta.settings.theme'), value: settings.theme, choices: THEMES, onChange: theme => store.update({ theme }) }))),
|
|
71
|
+
row('font-size', [t('ta.settings.fontSize'), t('ta.settings.fontSizeHint'), 'font'], React.createElement(Row, { label: t('ta.settings.fontSize'), description: t('ta.settings.fontSizeHint'), stacked: true },
|
|
72
|
+
React.createElement(Segmented, { label: t('ta.settings.fontSize'), value: settings.fontSize, choices: FONT_SIZES, onChange: fontSize => store.update({ fontSize }) }))),
|
|
73
|
+
row('chat-font-size', [t('ta.settings.chatFontSize'), t('ta.settings.chatFontSizeHint'), 'font'], React.createElement(Row, { label: t('ta.settings.chatFontSize'), description: t('ta.settings.chatFontSizeHint'), stacked: true },
|
|
74
|
+
React.createElement(Segmented, { label: t('ta.settings.chatFontSize'), value: settings.chatFontSize, choices: FONT_SIZES, onChange: chatFontSize => store.update({ chatFontSize }) }))),
|
|
75
|
+
row('motion', [t('ta.settings.motion'), t('ta.settings.motionHint')], React.createElement(Row, { label: t('ta.settings.motion'), description: t('ta.settings.motionHint') },
|
|
76
|
+
React.createElement(Switch, { label: t('ta.settings.motion'), checked: settings.reduceMotion, onChange: reduceMotion => store.update({ reduceMotion }) }))),
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'language',
|
|
81
|
+
title: t('ta.settings.language'),
|
|
82
|
+
icon: Languages,
|
|
83
|
+
rows: [
|
|
84
|
+
row('language', [t('ta.settings.displayLanguage'), 'language'], React.createElement(Row, { label: t('ta.settings.displayLanguage'), stacked: true },
|
|
85
|
+
React.createElement(Segmented, { label: t('ta.settings.displayLanguage'), value: settings.language, choices: LANGUAGES, onChange: language => store.update({ language }) }))),
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'navigation',
|
|
90
|
+
title: t('ta.settings.navigation'),
|
|
91
|
+
icon: Compass,
|
|
92
|
+
rows: navigationRows(navigation, t),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'links',
|
|
96
|
+
title: t('ta.settings.links'),
|
|
97
|
+
icon: Link2,
|
|
98
|
+
rows: [
|
|
99
|
+
row('trusted-domains', [t('ta.settings.trustedDomains'), t('ta.settings.trustedDomainsHint'), ...settings.trustedDomains], React.createElement(TrustedDomains, null)),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'assistant',
|
|
104
|
+
title: t('ta.settings.assistant'),
|
|
105
|
+
icon: Bot,
|
|
106
|
+
rows: [
|
|
107
|
+
row('assistant-model', [t('ta.settings.assistantModel'), t('ta.settings.assistantModelHint')], React.createElement(Row, { label: t('ta.settings.assistantModel'), description: t('ta.settings.assistantModelHint'), stacked: true },
|
|
108
|
+
React.createElement(SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.assistantModel'), value: settings.assistantModel, onChange: assistantModel => store.update({ assistantModel }) }))),
|
|
109
|
+
row('task-model', [t('ta.settings.taskModel'), t('ta.settings.taskModelHint')], React.createElement(Row, { label: t('ta.settings.taskModel'), description: t('ta.settings.taskModelHint'), stacked: true },
|
|
110
|
+
React.createElement(SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.taskModel'), value: settings.taskModel, onChange: taskModel => store.update({ taskModel }) }))),
|
|
111
|
+
row('confirm-tasks', [t('ta.settings.confirmTasks'), t('ta.settings.confirmTasksHint')], React.createElement(Row, { label: t('ta.settings.confirmTasks'), description: t('ta.settings.confirmTasksHint') },
|
|
112
|
+
React.createElement(Switch, { label: t('ta.settings.confirmTasks'), checked: settings.confirmTasks, onChange: confirmTasks => store.update({ confirmTasks }) }))),
|
|
113
|
+
row('max-tasks', [t('ta.settings.maxTasks'), t('ta.settings.maxTasksHint')], React.createElement(Row, { label: t('ta.settings.maxTasks'), description: t('ta.settings.maxTasksHint'), stacked: true },
|
|
114
|
+
React.createElement(Segmented, { label: t('ta.settings.maxTasks'), value: String(settings.maxTasks), choices: MAX_TASKS_CHOICES.map(count => ({
|
|
115
|
+
value: String(count),
|
|
116
|
+
label: count === 0 ? t('ta.settings.maxTasksAny') : String(count),
|
|
117
|
+
})), onChange: value => store.update({ maxTasks: Number(value) }) }))),
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 'voice',
|
|
122
|
+
title: t('ta.settings.voice'),
|
|
123
|
+
icon: Volume2,
|
|
124
|
+
rows: [
|
|
125
|
+
row('speak', [t('ta.settings.speak'), t('ta.settings.speakHint')], React.createElement(Row, { label: t('ta.settings.speak'), description: t('ta.settings.speakHint') },
|
|
126
|
+
React.createElement(Switch, { label: t('ta.settings.speak'), checked: settings.speak, onChange: speak => store.update({ speak }) }))),
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
const { snapshot } = agent;
|
|
131
|
+
const locked = !!snapshot && scope === 'project' && !snapshot.projectTrusted;
|
|
132
|
+
const lead = (React.createElement(React.Fragment, null,
|
|
133
|
+
React.createElement(ScopeBar, { scope: scope, onScope: onScope, snapshot: snapshot }),
|
|
134
|
+
agent.offline && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.offline')),
|
|
135
|
+
!agent.offline && !snapshot && !agent.error && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.loading')),
|
|
136
|
+
locked && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.untrusted')),
|
|
137
|
+
agent.error && React.createElement("div", { className: "ta-banner ta-banner-error" }, t('ta.settings.failed', { error: agent.error }))));
|
|
138
|
+
const ta = AGENT_SETTINGS_GROUPS.map(group => { var _a; return ({
|
|
139
|
+
id: group.id,
|
|
140
|
+
title: t(group.title),
|
|
141
|
+
icon: (_a = GROUP_ICONS[group.id]) !== null && _a !== void 0 ? _a : Wrench,
|
|
142
|
+
rows: snapshot
|
|
143
|
+
? group.keys.flatMap(key => {
|
|
144
|
+
const spec = AgentSettingsUtil.spec(key);
|
|
145
|
+
if (!spec) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const label = t(AgentSettingsUtil.label(key));
|
|
149
|
+
const hint = AgentSettingsUtil.hint(key);
|
|
150
|
+
return [
|
|
151
|
+
row(key, [label, hint && t(hint), key], React.createElement(Row, { label: label, description: hint && t(hint), modified: snapshot[scope][key] !== undefined },
|
|
152
|
+
React.createElement(AgentControl, { spec: spec, scope: scope, snapshot: snapshot, disabled: locked, onChange: changes => agent.update(scope, changes) }))),
|
|
153
|
+
];
|
|
154
|
+
})
|
|
155
|
+
: [],
|
|
156
|
+
}); });
|
|
157
|
+
// Those opened without installing are in Quick open, which installs or deletes them (ta-launcher.md).
|
|
158
|
+
const packages = packageList.packages.filter(pkg => pkg.origin !== 'builtin' && pkg.origin !== 'temporary');
|
|
159
|
+
const launchRows = useLaunchRows();
|
|
160
|
+
/** Why the web extension of a package did not load, if it did not. */
|
|
161
|
+
const failure = (pkg) => { var _a; return (_a = extensions.find(extension => { var _a; return ((_a = extension.info) === null || _a === void 0 ? void 0 : _a.source) === pkg.source && extension.error; })) === null || _a === void 0 ? void 0 : _a.error; };
|
|
162
|
+
const reload = async () => {
|
|
163
|
+
await host.refresh();
|
|
164
|
+
await packageList.read();
|
|
165
|
+
};
|
|
166
|
+
const more = [
|
|
167
|
+
{
|
|
168
|
+
id: 'packages',
|
|
169
|
+
title: t('ta.packages'),
|
|
170
|
+
icon: Puzzle,
|
|
171
|
+
rows: [
|
|
172
|
+
row('packages', [t('ta.packages'), t('ta.packages.hint')], React.createElement(Row, { label: t('ta.packages.installed'), description: t('ta.packages.hint') },
|
|
173
|
+
React.createElement("button", { type: "button", className: "ta-button", disabled: busy, onClick: () => run(reload, t('ta.packages.reloaded')) },
|
|
174
|
+
React.createElement(Icon, { icon: RefreshCw, size: 14 }),
|
|
175
|
+
" ",
|
|
176
|
+
t('ta.packages.reload')))),
|
|
177
|
+
...packages.map(pkg => {
|
|
178
|
+
const error = failure(pkg);
|
|
179
|
+
const { title, summary, icon } = packageLabel(pkg, language);
|
|
180
|
+
return row(`package:${pkg.id}`, [title, summary, pkg.name, t('ta.packages')], React.createElement(Row, { icon: icon, label: title, description: error
|
|
181
|
+
? t('ta.packages.failed', { error })
|
|
182
|
+
: [summary, t(pkg.scope === 'project' ? 'ta.packages.scope.project' : 'ta.packages.scope.user')].filter(Boolean).join(' · ') },
|
|
183
|
+
React.createElement(IconButton, { icon: Trash2, label: t('ta.packages.remove'), disabled: busy, onClick: () => void remove(pkg) }),
|
|
184
|
+
React.createElement(Switch, { label: title, checked: pkg.enabled, disabled: busy, onChange: on => run(() => packageList.toggle(pkg, on)) })));
|
|
185
|
+
}),
|
|
186
|
+
...(packages.length === 0
|
|
187
|
+
? [row('packages:none', [t('ta.packages.none')], React.createElement(EmptyRow, { title: t('ta.packages.none'), hint: t('ta.packages.noneHint') }))]
|
|
188
|
+
: []),
|
|
189
|
+
...launchRows,
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: 'builtin',
|
|
194
|
+
title: t('ta.packages.builtinTitle'),
|
|
195
|
+
icon: Blocks,
|
|
196
|
+
rows: [
|
|
197
|
+
...host.builtins.map(builtin => { var _a; return row(`web:${builtin.name}`, [t(builtin.title), t(builtin.description), t('ta.packages.builtinTitle')], React.createElement(Row, { icon: (_a = builtin.icon) !== null && _a !== void 0 ? _a : Puzzle, label: t(builtin.title), description: t(builtin.description) },
|
|
198
|
+
React.createElement(Switch, { label: t(builtin.title), checked: !settings.builtinsOff.includes(builtin.name), onChange: on => toggleBuiltin(builtin.name, on) }))); }),
|
|
199
|
+
...builtinPackages.map(info => {
|
|
200
|
+
const { title, summary, icon } = packageLabel(info, language);
|
|
201
|
+
return row(`builtin:${info.name}`, [title, summary, info.name, t('ta.packages.builtinTitle')], React.createElement(Row, { icon: icon, label: title, description: summary },
|
|
202
|
+
React.createElement(Switch, { label: title, checked: info.enabled, onChange: on => run(() => packageList.toggle(info, on)) })));
|
|
203
|
+
}),
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
// Behind a gateway only: where the Ta of this account runs.
|
|
207
|
+
...(gateway.info
|
|
208
|
+
? [
|
|
209
|
+
{
|
|
210
|
+
id: 'environment',
|
|
211
|
+
title: t('ta.environment.title'),
|
|
212
|
+
icon: Cloud,
|
|
213
|
+
rows: [
|
|
214
|
+
row('environment', [t('ta.environment.title'), t('ta.environment.whereHint'), 'sandbox', 'docker'], React.createElement(EnvironmentSettings, { info: gateway.info, onChange: gateway.read })),
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
]
|
|
218
|
+
: []),
|
|
219
|
+
// Only where accounts can sign in, or could: a Ta of this computer has no need of it.
|
|
220
|
+
...(access.info && (access.info.providers.length > 0 || access.info.accounts.length > 0)
|
|
221
|
+
? [
|
|
222
|
+
{
|
|
223
|
+
id: 'access',
|
|
224
|
+
title: t('ta.access.title'),
|
|
225
|
+
icon: ShieldCheck,
|
|
226
|
+
rows: [
|
|
227
|
+
row('access', [t('ta.access.title'), t('ta.access.addHint'), 'github', 'google', 'wechat'], React.createElement(AccessSettings, { info: access.info, onChange: access.read })),
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
]
|
|
231
|
+
: []),
|
|
232
|
+
{
|
|
233
|
+
id: 'remote',
|
|
234
|
+
title: t('ta.remote.title'),
|
|
235
|
+
icon: Server,
|
|
236
|
+
rows: [row('remote', [t('ta.remote.title'), t('ta.remote.description'), 'ssh'], React.createElement(RemoteHosts, null))],
|
|
237
|
+
},
|
|
238
|
+
...(touch
|
|
239
|
+
? []
|
|
240
|
+
: [
|
|
241
|
+
{
|
|
242
|
+
id: 'shortcuts',
|
|
243
|
+
title: t('ta.settings.shortcuts'),
|
|
244
|
+
icon: Keyboard,
|
|
245
|
+
rows: SHORTCUTS.map(shortcut => row(`key:${shortcut.keys}`, [t(shortcut.label), shortcut.keys, t('ta.settings.shortcuts')], React.createElement(Row, { label: t(shortcut.label) },
|
|
246
|
+
React.createElement(Keys, { keys: shortcut.keys })))),
|
|
247
|
+
},
|
|
248
|
+
]),
|
|
249
|
+
{
|
|
250
|
+
id: 'about',
|
|
251
|
+
title: t('ta.settings.about'),
|
|
252
|
+
icon: Info,
|
|
253
|
+
rows: workbench.server
|
|
254
|
+
? [
|
|
255
|
+
row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version') },
|
|
256
|
+
React.createElement("span", { className: "ta-path" },
|
|
257
|
+
"v",
|
|
258
|
+
workbench.server.version))),
|
|
259
|
+
row('cwd', [t('ta.settings.cwd'), workbench.server.cwd], React.createElement(Row, { label: t('ta.settings.cwd'), description: t('ta.settings.cwdDescription', { path: workbench.server.cwd }) },
|
|
260
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
|
|
261
|
+
React.createElement(Icon, { icon: FolderOpen, size: 15 }),
|
|
262
|
+
" ",
|
|
263
|
+
t('ta.settings.cwdChange')))),
|
|
264
|
+
row('accounts', [t('ta.settings.accounts'), t('ta.settings.accountsDescription')], React.createElement(Row, { label: t('ta.settings.accounts'), description: t('ta.settings.accountsDescription') },
|
|
265
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('accounts') },
|
|
266
|
+
React.createElement(Icon, { icon: KeyRound, size: 15 }),
|
|
267
|
+
" ",
|
|
268
|
+
t('ta.settings.manageAccounts')))),
|
|
269
|
+
...(WorkbenchUtil.isApp() || handheld
|
|
270
|
+
? []
|
|
271
|
+
: [
|
|
272
|
+
row('relay', [t('ta.settings.relay'), t('ta.settings.relayDescription')], React.createElement(Row, { label: t('ta.settings.relay'), description: t('ta.settings.relayDescription') },
|
|
273
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('relay') },
|
|
274
|
+
React.createElement(Icon, { icon: Smartphone, size: 15 }),
|
|
275
|
+
" ",
|
|
276
|
+
t('ta.settings.manageAccounts')))),
|
|
277
|
+
]),
|
|
278
|
+
...(handheld
|
|
279
|
+
? []
|
|
280
|
+
: [
|
|
281
|
+
row('signOut', [t('ta.settings.signOut')], React.createElement(Row, { label: t('ta.settings.signOut') },
|
|
282
|
+
React.createElement("button", { type: "button", className: "ta-button ta-danger", onClick: () => {
|
|
283
|
+
onClose();
|
|
284
|
+
bench.signOut();
|
|
285
|
+
} },
|
|
286
|
+
React.createElement(Icon, { icon: LogOut, size: 15 }),
|
|
287
|
+
" ",
|
|
288
|
+
t('ta.settings.signOut')))),
|
|
289
|
+
]),
|
|
290
|
+
]
|
|
291
|
+
: [],
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
return [
|
|
295
|
+
{ id: 'web', title: t('ta.settings.web'), sections: web },
|
|
296
|
+
{ id: 'agent', title: t('ta.settings.agent'), sections: ta, lead },
|
|
297
|
+
{ id: 'more', title: t('ta.settings.more'), sections: more },
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=settings-parts.js.map
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MessageId } from '../i18n/messages.js';
|
|
3
2
|
/** A section of the settings view: `appearance`, `model`, `packages`, ... */
|
|
4
3
|
export type SettingsSection = string;
|
|
5
|
-
/** The keys of the page and of the message box; `Mod` is ⌘ on a Mac, Ctrl elsewhere. */
|
|
6
|
-
export declare const SHORTCUTS: {
|
|
7
|
-
keys: string;
|
|
8
|
-
label: MessageId;
|
|
9
|
-
}[];
|
|
10
4
|
export interface SettingsViewProps {
|
|
11
5
|
/** The section to show first. */
|
|
12
6
|
section?: SettingsSection;
|