@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
|
@@ -1,418 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Blocks, Bot, ChevronLeft, Cloud, Compass, FolderOpen, Globe, Info, Keyboard, KeyRound, Languages, Layers, Link2, LogOut, Menu, MessagesSquare, Monitor, Moon, Palette, Puzzle, RefreshCw, Search, Server, ShieldCheck, Smartphone, Sparkles, Sun, Trash2, Volume2, Wrench, X, } from 'lucide-react';
|
|
1
|
+
import { ChevronLeft, Menu, Search, X } from 'lucide-react';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import { useDevice } from '../device/device.js';
|
|
5
|
-
import {
|
|
6
|
-
import { WebLabelUtil } from '../extension/web-extension-protocol.js';
|
|
7
|
-
import { useNotices, useSettings, useSettingsServer, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
8
|
-
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
9
|
-
import { AGENT_SETTINGS_GROUPS, AgentSettingsUtil } from '../settings/agent-settings.js';
|
|
10
|
-
import { NavigationUtil } from '../settings/navigation.js';
|
|
11
|
-
import { MAX_TASKS_CHOICES } from '../settings/settings-protocol.js';
|
|
12
|
-
import { WorkbenchUtil } from '../workbench.js';
|
|
13
|
-
import { AccessSettings, useAccess } from './access-view.js';
|
|
14
|
-
import { AgentControl, ScopeBar, useAgentSettings } from './agent-settings-view.js';
|
|
15
|
-
import { useNavigation } from './app-nav.js';
|
|
4
|
+
import { useT } from '../i18n/use-t.js';
|
|
16
5
|
import { AuthDialog } from './auth-view.js';
|
|
17
6
|
import { EmptyState } from './empty-state.js';
|
|
18
|
-
import { EnvironmentSettings, useGateway } from './environment-view.js';
|
|
19
7
|
import { Icon, IconButton } from './icon.js';
|
|
20
|
-
import { useLaunchRows } from './launch-settings.js';
|
|
21
8
|
import { ListGroup, ListRow } from './list-rows.js';
|
|
22
|
-
import { SettingsModelPicker } from './model-picker.js';
|
|
23
9
|
import { PhoneStack } from './phone-shell.js';
|
|
24
10
|
import { RelayDialog } from './relay-view.js';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { TrustedDomains } from './trusted-domains.js';
|
|
11
|
+
import { SettingsViewUtil } from './settings-controls.js';
|
|
12
|
+
import { useParts } from './settings-parts.js';
|
|
28
13
|
import { WorkingDirectoryPicker } from './working-directory.js';
|
|
29
|
-
const THEMES = [
|
|
30
|
-
{ value: 'system', icon: Monitor, label: 'ta.settings.theme.system' },
|
|
31
|
-
{ value: 'light', icon: Sun, label: 'ta.settings.theme.light' },
|
|
32
|
-
{ value: 'dark', icon: Moon, label: 'ta.settings.theme.dark' },
|
|
33
|
-
];
|
|
34
|
-
const FONT_SIZES = [
|
|
35
|
-
{ value: 'small', label: 'ta.settings.fontSize.small' },
|
|
36
|
-
{ value: 'standard', label: 'ta.settings.fontSize.standard' },
|
|
37
|
-
{ value: 'large', label: 'ta.settings.fontSize.large' },
|
|
38
|
-
{ value: 'xlarge', label: 'ta.settings.fontSize.xlarge' },
|
|
39
|
-
];
|
|
40
|
-
const LANGUAGES = [
|
|
41
|
-
{ value: 'system', icon: Globe, label: 'ta.settings.language.system' },
|
|
42
|
-
{ value: 'zh-CN', label: '简体中文' },
|
|
43
|
-
{ value: 'en-US', label: 'English' },
|
|
44
|
-
];
|
|
45
|
-
const GROUP_ICONS = { model: Sparkles, conversation: MessagesSquare, context: Layers, tools: Wrench };
|
|
46
|
-
/** The keys of the page and of the message box; `Mod` is ⌘ on a Mac, Ctrl elsewhere. */
|
|
47
|
-
export const SHORTCUTS = [
|
|
48
|
-
{ keys: 'Mod+,', label: 'ta.shortcut.settings' },
|
|
49
|
-
{ keys: 'Mod+B', label: 'ta.shortcut.sidebar' },
|
|
50
|
-
{ keys: 'Enter', label: 'ta.shortcut.send' },
|
|
51
|
-
{ keys: 'Shift+Enter', label: 'ta.shortcut.newline' },
|
|
52
|
-
{ keys: 'Alt+Enter', label: 'ta.shortcut.followUp' },
|
|
53
|
-
{ keys: 'Esc', label: 'ta.shortcut.stop' },
|
|
54
|
-
{ keys: '/', label: 'ta.shortcut.commands' },
|
|
55
|
-
{ keys: '@', label: 'ta.shortcut.files' },
|
|
56
|
-
{ keys: 'Mod+S', label: 'ta.shortcut.save' },
|
|
57
|
-
];
|
|
58
|
-
/**
|
|
59
|
-
* The packages pi loads, as the server lists them, those turned off too: the built-in ones turn off and
|
|
60
|
-
* stay; the others turn off and on, and go.
|
|
61
|
-
*/
|
|
62
|
-
function usePackages() {
|
|
63
|
-
const [workbench, bench] = useWorkbench();
|
|
64
|
-
const [, host] = useWebExtensions();
|
|
65
|
-
const [packages, setPackages] = React.useState([]);
|
|
66
|
-
const read = React.useCallback(() => bench.packages.listPackages().then(setPackages), [bench]);
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
if (workbench.status === 'online') {
|
|
69
|
-
read().catch(() => undefined);
|
|
70
|
-
}
|
|
71
|
-
}, [workbench.status, read]);
|
|
72
|
-
const changed = async () => {
|
|
73
|
-
await host.reloadPackages();
|
|
74
|
-
await read();
|
|
75
|
-
};
|
|
76
|
-
/** By the name of a built-in package, by the id of another. */
|
|
77
|
-
const toggle = async (pkg, on) => {
|
|
78
|
-
setPackages(current => current.map(other => (other.id === pkg.id ? { ...other, enabled: on } : other)));
|
|
79
|
-
await bench.packages.setPackageEnabled(pkg.origin === 'builtin' ? pkg.name : pkg.id, on);
|
|
80
|
-
await changed();
|
|
81
|
-
};
|
|
82
|
-
const remove = async (pkg) => {
|
|
83
|
-
await bench.packages.removePackage(pkg.id);
|
|
84
|
-
await changed();
|
|
85
|
-
};
|
|
86
|
-
return { packages, toggle, remove, read };
|
|
87
|
-
}
|
|
88
|
-
const SLOTS = Array.from({ length: NavigationUtil.MAX_SLOTS - NavigationUtil.MIN_SLOTS + 1 }, (_, index) => {
|
|
89
|
-
const value = String(NavigationUtil.MIN_SLOTS + index);
|
|
90
|
-
return { value, label: value };
|
|
91
|
-
});
|
|
92
|
-
/** The rows of the navigation: how many pages it shows, and where each page is. */
|
|
93
|
-
function navigationRows(navigation, t) {
|
|
94
|
-
const { setting } = navigation;
|
|
95
|
-
const where = (id, byDefault) => {
|
|
96
|
-
if (setting.pinned.includes(id) && navigation.nav.some(page => page.id === id)) {
|
|
97
|
-
return t('ta.settings.navigation.pinned');
|
|
98
|
-
}
|
|
99
|
-
if (navigation.nav.some(page => page.id === id)) {
|
|
100
|
-
return t('ta.settings.navigation.inNav');
|
|
101
|
-
}
|
|
102
|
-
return t(setting.discover.includes(id) || byDefault ? 'ta.settings.navigation.folded' : 'ta.settings.navigation.overflow');
|
|
103
|
-
};
|
|
104
|
-
return [
|
|
105
|
-
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 },
|
|
106
|
-
React.createElement(Segmented, { label: t('ta.settings.navigation.slots'), value: String(setting.slots), choices: SLOTS, onChange: slots => navigation.update({ ...setting, slots: Number(slots) }) }))),
|
|
107
|
-
...navigation.pages.map(page => {
|
|
108
|
-
const title = WebLabelUtil.text(page.title);
|
|
109
|
-
const shown = navigation.nav.includes(page);
|
|
110
|
-
return row(`navigation:${page.id}`, [title, t('ta.settings.navigation')], React.createElement(Row, { label: title, description: where(page.id, page.discover) },
|
|
111
|
-
React.createElement(Switch, { label: `${t('ta.settings.navigation.show')} · ${title}`, checked: shown, onChange: on => (on ? navigation.pin(page.id) : navigation.fold(page.id)) })));
|
|
112
|
-
}),
|
|
113
|
-
...(navigation.pages.length === 0
|
|
114
|
-
? [row('navigation:none', [t('ta.settings.navigation.none')], React.createElement(EmptyRow, { title: t('ta.settings.navigation.none') }))]
|
|
115
|
-
: []),
|
|
116
|
-
...(NavigationUtil.moved(setting)
|
|
117
|
-
? [
|
|
118
|
-
row('navigation-reset', [t('ta.settings.navigation.reset')], React.createElement(Row, { label: t('ta.settings.navigation.reset'), description: t('ta.settings.navigation.resetHint') },
|
|
119
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => navigation.update(NavigationUtil.reset(setting)) },
|
|
120
|
-
React.createElement(Icon, { icon: RefreshCw, size: 14 }),
|
|
121
|
-
" ",
|
|
122
|
-
t('ta.settings.navigation.resetButton')))),
|
|
123
|
-
]
|
|
124
|
-
: []),
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
/** How a package shows in a row: what it calls itself for people, else its name and the description of its package.json. */
|
|
128
|
-
function packageLabel(pkg, language) {
|
|
129
|
-
var _a, _b;
|
|
130
|
-
return {
|
|
131
|
-
title: (_a = TaPackageTextUtil.pick(pkg.title, language)) !== null && _a !== void 0 ? _a : pkg.name,
|
|
132
|
-
summary: (_b = TaPackageTextUtil.pick(pkg.summary, language)) !== null && _b !== void 0 ? _b : pkg.description,
|
|
133
|
-
icon: (pkg.icon && WEB_ICONS[pkg.icon]) || Puzzle,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/** The sections of the page and of ta, by part, with their rows. */
|
|
137
|
-
function useParts(scope, onScope, onClose, onDialog) {
|
|
138
|
-
var _a;
|
|
139
|
-
const t = useT();
|
|
140
|
-
const language = useLanguage();
|
|
141
|
-
const [{ settings }, store] = useSettings();
|
|
142
|
-
const settingsServer = useSettingsServer();
|
|
143
|
-
const [workbench, bench] = useWorkbench();
|
|
144
|
-
const [{ extensions, cwd, views }, host] = useWebExtensions();
|
|
145
|
-
const navigation = useNavigation(views);
|
|
146
|
-
const packageList = usePackages();
|
|
147
|
-
const builtinPackages = packageList.packages.filter(pkg => pkg.origin === 'builtin');
|
|
148
|
-
const agent = useAgentSettings(cwd !== null && cwd !== void 0 ? cwd : (_a = workbench.server) === null || _a === void 0 ? void 0 : _a.cwd);
|
|
149
|
-
const [, notices] = useNotices();
|
|
150
|
-
const access = useAccess();
|
|
151
|
-
const gateway = useGateway();
|
|
152
|
-
// As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
|
|
153
|
-
// that pairs phones, and signs out at the foot of Me.
|
|
154
|
-
const touch = useDevice(device => device.touch);
|
|
155
|
-
const handheld = useDevice(device => device.handheld);
|
|
156
|
-
const [busy, setBusy] = React.useState(false);
|
|
157
|
-
const run = (action, done) => {
|
|
158
|
-
setBusy(true);
|
|
159
|
-
action()
|
|
160
|
-
.then(() => done && notices.notify(done, { level: 'success' }))
|
|
161
|
-
.catch(error => notices.error(error))
|
|
162
|
-
.finally(() => setBusy(false));
|
|
163
|
-
};
|
|
164
|
-
const remove = async (pkg) => {
|
|
165
|
-
const confirmed = await notices.confirm({
|
|
166
|
-
title: t('ta.packages.removeConfirm', { name: pkg.name }),
|
|
167
|
-
message: t('ta.packages.removeDetail'),
|
|
168
|
-
confirmLabel: t('ta.packages.remove'),
|
|
169
|
-
danger: true,
|
|
170
|
-
});
|
|
171
|
-
if (confirmed) {
|
|
172
|
-
run(() => packageList.remove(pkg), t('ta.packages.removed', { name: pkg.name }));
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const toggleBuiltin = (name, on) => {
|
|
176
|
-
store.update({ builtinsOff: on ? settings.builtinsOff.filter(other => other !== name) : [...settings.builtinsOff, name] });
|
|
177
|
-
run(() => host.refresh());
|
|
178
|
-
};
|
|
179
|
-
const web = [
|
|
180
|
-
{
|
|
181
|
-
id: 'appearance',
|
|
182
|
-
title: t('ta.settings.appearance'),
|
|
183
|
-
icon: Palette,
|
|
184
|
-
rows: [
|
|
185
|
-
row('theme', [t('ta.settings.theme'), 'theme'], React.createElement(Row, { label: t('ta.settings.theme'), stacked: true },
|
|
186
|
-
React.createElement(Segmented, { label: t('ta.settings.theme'), value: settings.theme, choices: THEMES, onChange: theme => store.update({ theme }) }))),
|
|
187
|
-
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 },
|
|
188
|
-
React.createElement(Segmented, { label: t('ta.settings.fontSize'), value: settings.fontSize, choices: FONT_SIZES, onChange: fontSize => store.update({ fontSize }) }))),
|
|
189
|
-
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 },
|
|
190
|
-
React.createElement(Segmented, { label: t('ta.settings.chatFontSize'), value: settings.chatFontSize, choices: FONT_SIZES, onChange: chatFontSize => store.update({ chatFontSize }) }))),
|
|
191
|
-
row('motion', [t('ta.settings.motion'), t('ta.settings.motionHint')], React.createElement(Row, { label: t('ta.settings.motion'), description: t('ta.settings.motionHint') },
|
|
192
|
-
React.createElement(Switch, { label: t('ta.settings.motion'), checked: settings.reduceMotion, onChange: reduceMotion => store.update({ reduceMotion }) }))),
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
id: 'language',
|
|
197
|
-
title: t('ta.settings.language'),
|
|
198
|
-
icon: Languages,
|
|
199
|
-
rows: [
|
|
200
|
-
row('language', [t('ta.settings.displayLanguage'), 'language'], React.createElement(Row, { label: t('ta.settings.displayLanguage'), stacked: true },
|
|
201
|
-
React.createElement(Segmented, { label: t('ta.settings.displayLanguage'), value: settings.language, choices: LANGUAGES, onChange: language => store.update({ language }) }))),
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
id: 'navigation',
|
|
206
|
-
title: t('ta.settings.navigation'),
|
|
207
|
-
icon: Compass,
|
|
208
|
-
rows: navigationRows(navigation, t),
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
id: 'links',
|
|
212
|
-
title: t('ta.settings.links'),
|
|
213
|
-
icon: Link2,
|
|
214
|
-
rows: [
|
|
215
|
-
row('trusted-domains', [t('ta.settings.trustedDomains'), t('ta.settings.trustedDomainsHint'), ...settings.trustedDomains], React.createElement(TrustedDomains, null)),
|
|
216
|
-
],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: 'assistant',
|
|
220
|
-
title: t('ta.settings.assistant'),
|
|
221
|
-
icon: Bot,
|
|
222
|
-
rows: [
|
|
223
|
-
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 },
|
|
224
|
-
React.createElement(SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.assistantModel'), value: settings.assistantModel, onChange: assistantModel => store.update({ assistantModel }) }))),
|
|
225
|
-
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 },
|
|
226
|
-
React.createElement(SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.taskModel'), value: settings.taskModel, onChange: taskModel => store.update({ taskModel }) }))),
|
|
227
|
-
row('confirm-tasks', [t('ta.settings.confirmTasks'), t('ta.settings.confirmTasksHint')], React.createElement(Row, { label: t('ta.settings.confirmTasks'), description: t('ta.settings.confirmTasksHint') },
|
|
228
|
-
React.createElement(Switch, { label: t('ta.settings.confirmTasks'), checked: settings.confirmTasks, onChange: confirmTasks => store.update({ confirmTasks }) }))),
|
|
229
|
-
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 },
|
|
230
|
-
React.createElement(Segmented, { label: t('ta.settings.maxTasks'), value: String(settings.maxTasks), choices: MAX_TASKS_CHOICES.map(count => ({
|
|
231
|
-
value: String(count),
|
|
232
|
-
label: count === 0 ? t('ta.settings.maxTasksAny') : String(count),
|
|
233
|
-
})), onChange: value => store.update({ maxTasks: Number(value) }) }))),
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
id: 'voice',
|
|
238
|
-
title: t('ta.settings.voice'),
|
|
239
|
-
icon: Volume2,
|
|
240
|
-
rows: [
|
|
241
|
-
row('speak', [t('ta.settings.speak'), t('ta.settings.speakHint')], React.createElement(Row, { label: t('ta.settings.speak'), description: t('ta.settings.speakHint') },
|
|
242
|
-
React.createElement(Switch, { label: t('ta.settings.speak'), checked: settings.speak, onChange: speak => store.update({ speak }) }))),
|
|
243
|
-
],
|
|
244
|
-
},
|
|
245
|
-
];
|
|
246
|
-
const { snapshot } = agent;
|
|
247
|
-
const locked = !!snapshot && scope === 'project' && !snapshot.projectTrusted;
|
|
248
|
-
const lead = (React.createElement(React.Fragment, null,
|
|
249
|
-
React.createElement(ScopeBar, { scope: scope, onScope: onScope, snapshot: snapshot }),
|
|
250
|
-
agent.offline && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.offline')),
|
|
251
|
-
!agent.offline && !snapshot && !agent.error && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.loading')),
|
|
252
|
-
locked && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.untrusted')),
|
|
253
|
-
agent.error && React.createElement("div", { className: "ta-banner ta-banner-error" }, t('ta.settings.failed', { error: agent.error }))));
|
|
254
|
-
const ta = AGENT_SETTINGS_GROUPS.map(group => { var _a; return ({
|
|
255
|
-
id: group.id,
|
|
256
|
-
title: t(group.title),
|
|
257
|
-
icon: (_a = GROUP_ICONS[group.id]) !== null && _a !== void 0 ? _a : Wrench,
|
|
258
|
-
rows: snapshot
|
|
259
|
-
? group.keys.flatMap(key => {
|
|
260
|
-
const spec = AgentSettingsUtil.spec(key);
|
|
261
|
-
if (!spec) {
|
|
262
|
-
return [];
|
|
263
|
-
}
|
|
264
|
-
const label = t(AgentSettingsUtil.label(key));
|
|
265
|
-
const hint = AgentSettingsUtil.hint(key);
|
|
266
|
-
return [
|
|
267
|
-
row(key, [label, hint && t(hint), key], React.createElement(Row, { label: label, description: hint && t(hint), modified: snapshot[scope][key] !== undefined },
|
|
268
|
-
React.createElement(AgentControl, { spec: spec, scope: scope, snapshot: snapshot, disabled: locked, onChange: changes => agent.update(scope, changes) }))),
|
|
269
|
-
];
|
|
270
|
-
})
|
|
271
|
-
: [],
|
|
272
|
-
}); });
|
|
273
|
-
// Those opened without installing are in Quick open, which installs or deletes them (ta-launcher.md).
|
|
274
|
-
const packages = packageList.packages.filter(pkg => pkg.origin !== 'builtin' && pkg.origin !== 'temporary');
|
|
275
|
-
const launchRows = useLaunchRows();
|
|
276
|
-
/** Why the web extension of a package did not load, if it did not. */
|
|
277
|
-
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; };
|
|
278
|
-
const reload = async () => {
|
|
279
|
-
await host.refresh();
|
|
280
|
-
await packageList.read();
|
|
281
|
-
};
|
|
282
|
-
const more = [
|
|
283
|
-
{
|
|
284
|
-
id: 'packages',
|
|
285
|
-
title: t('ta.packages'),
|
|
286
|
-
icon: Puzzle,
|
|
287
|
-
rows: [
|
|
288
|
-
row('packages', [t('ta.packages'), t('ta.packages.hint')], React.createElement(Row, { label: t('ta.packages.installed'), description: t('ta.packages.hint') },
|
|
289
|
-
React.createElement("button", { type: "button", className: "ta-button", disabled: busy, onClick: () => run(reload, t('ta.packages.reloaded')) },
|
|
290
|
-
React.createElement(Icon, { icon: RefreshCw, size: 14 }),
|
|
291
|
-
" ",
|
|
292
|
-
t('ta.packages.reload')))),
|
|
293
|
-
...packages.map(pkg => {
|
|
294
|
-
const error = failure(pkg);
|
|
295
|
-
const { title, summary, icon } = packageLabel(pkg, language);
|
|
296
|
-
return row(`package:${pkg.id}`, [title, summary, pkg.name, t('ta.packages')], React.createElement(Row, { icon: icon, label: title, description: error
|
|
297
|
-
? t('ta.packages.failed', { error })
|
|
298
|
-
: [summary, t(pkg.scope === 'project' ? 'ta.packages.scope.project' : 'ta.packages.scope.user')].filter(Boolean).join(' · ') },
|
|
299
|
-
React.createElement(IconButton, { icon: Trash2, label: t('ta.packages.remove'), disabled: busy, onClick: () => void remove(pkg) }),
|
|
300
|
-
React.createElement(Switch, { label: title, checked: pkg.enabled, disabled: busy, onChange: on => run(() => packageList.toggle(pkg, on)) })));
|
|
301
|
-
}),
|
|
302
|
-
...(packages.length === 0
|
|
303
|
-
? [row('packages:none', [t('ta.packages.none')], React.createElement(EmptyRow, { title: t('ta.packages.none'), hint: t('ta.packages.noneHint') }))]
|
|
304
|
-
: []),
|
|
305
|
-
...launchRows,
|
|
306
|
-
],
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
id: 'builtin',
|
|
310
|
-
title: t('ta.packages.builtinTitle'),
|
|
311
|
-
icon: Blocks,
|
|
312
|
-
rows: [
|
|
313
|
-
...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) },
|
|
314
|
-
React.createElement(Switch, { label: t(builtin.title), checked: !settings.builtinsOff.includes(builtin.name), onChange: on => toggleBuiltin(builtin.name, on) }))); }),
|
|
315
|
-
...builtinPackages.map(info => {
|
|
316
|
-
const { title, summary, icon } = packageLabel(info, language);
|
|
317
|
-
return row(`builtin:${info.name}`, [title, summary, info.name, t('ta.packages.builtinTitle')], React.createElement(Row, { icon: icon, label: title, description: summary },
|
|
318
|
-
React.createElement(Switch, { label: title, checked: info.enabled, onChange: on => run(() => packageList.toggle(info, on)) })));
|
|
319
|
-
}),
|
|
320
|
-
],
|
|
321
|
-
},
|
|
322
|
-
// Behind a gateway only: where the Ta of this account runs.
|
|
323
|
-
...(gateway.info
|
|
324
|
-
? [
|
|
325
|
-
{
|
|
326
|
-
id: 'environment',
|
|
327
|
-
title: t('ta.environment.title'),
|
|
328
|
-
icon: Cloud,
|
|
329
|
-
rows: [
|
|
330
|
-
row('environment', [t('ta.environment.title'), t('ta.environment.whereHint'), 'sandbox', 'docker'], React.createElement(EnvironmentSettings, { info: gateway.info, onChange: gateway.read })),
|
|
331
|
-
],
|
|
332
|
-
},
|
|
333
|
-
]
|
|
334
|
-
: []),
|
|
335
|
-
// Only where accounts can sign in, or could: a Ta of this computer has no need of it.
|
|
336
|
-
...(access.info && (access.info.providers.length > 0 || access.info.accounts.length > 0)
|
|
337
|
-
? [
|
|
338
|
-
{
|
|
339
|
-
id: 'access',
|
|
340
|
-
title: t('ta.access.title'),
|
|
341
|
-
icon: ShieldCheck,
|
|
342
|
-
rows: [
|
|
343
|
-
row('access', [t('ta.access.title'), t('ta.access.addHint'), 'github', 'google', 'wechat'], React.createElement(AccessSettings, { info: access.info, onChange: access.read })),
|
|
344
|
-
],
|
|
345
|
-
},
|
|
346
|
-
]
|
|
347
|
-
: []),
|
|
348
|
-
{
|
|
349
|
-
id: 'remote',
|
|
350
|
-
title: t('ta.remote.title'),
|
|
351
|
-
icon: Server,
|
|
352
|
-
rows: [row('remote', [t('ta.remote.title'), t('ta.remote.description'), 'ssh'], React.createElement(RemoteHosts, null))],
|
|
353
|
-
},
|
|
354
|
-
...(touch
|
|
355
|
-
? []
|
|
356
|
-
: [
|
|
357
|
-
{
|
|
358
|
-
id: 'shortcuts',
|
|
359
|
-
title: t('ta.settings.shortcuts'),
|
|
360
|
-
icon: Keyboard,
|
|
361
|
-
rows: SHORTCUTS.map(shortcut => row(`key:${shortcut.keys}`, [t(shortcut.label), shortcut.keys, t('ta.settings.shortcuts')], React.createElement(Row, { label: t(shortcut.label) },
|
|
362
|
-
React.createElement(Keys, { keys: shortcut.keys })))),
|
|
363
|
-
},
|
|
364
|
-
]),
|
|
365
|
-
{
|
|
366
|
-
id: 'about',
|
|
367
|
-
title: t('ta.settings.about'),
|
|
368
|
-
icon: Info,
|
|
369
|
-
rows: workbench.server
|
|
370
|
-
? [
|
|
371
|
-
row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version') },
|
|
372
|
-
React.createElement("span", { className: "ta-path" },
|
|
373
|
-
"v",
|
|
374
|
-
workbench.server.version))),
|
|
375
|
-
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 }) },
|
|
376
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
|
|
377
|
-
React.createElement(Icon, { icon: FolderOpen, size: 15 }),
|
|
378
|
-
" ",
|
|
379
|
-
t('ta.settings.cwdChange')))),
|
|
380
|
-
row('accounts', [t('ta.settings.accounts'), t('ta.settings.accountsDescription')], React.createElement(Row, { label: t('ta.settings.accounts'), description: t('ta.settings.accountsDescription') },
|
|
381
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('accounts') },
|
|
382
|
-
React.createElement(Icon, { icon: KeyRound, size: 15 }),
|
|
383
|
-
" ",
|
|
384
|
-
t('ta.settings.manageAccounts')))),
|
|
385
|
-
...(WorkbenchUtil.isApp() || handheld
|
|
386
|
-
? []
|
|
387
|
-
: [
|
|
388
|
-
row('relay', [t('ta.settings.relay'), t('ta.settings.relayDescription')], React.createElement(Row, { label: t('ta.settings.relay'), description: t('ta.settings.relayDescription') },
|
|
389
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('relay') },
|
|
390
|
-
React.createElement(Icon, { icon: Smartphone, size: 15 }),
|
|
391
|
-
" ",
|
|
392
|
-
t('ta.settings.manageAccounts')))),
|
|
393
|
-
]),
|
|
394
|
-
...(handheld
|
|
395
|
-
? []
|
|
396
|
-
: [
|
|
397
|
-
row('signOut', [t('ta.settings.signOut')], React.createElement(Row, { label: t('ta.settings.signOut') },
|
|
398
|
-
React.createElement("button", { type: "button", className: "ta-button ta-danger", onClick: () => {
|
|
399
|
-
onClose();
|
|
400
|
-
bench.signOut();
|
|
401
|
-
} },
|
|
402
|
-
React.createElement(Icon, { icon: LogOut, size: 15 }),
|
|
403
|
-
" ",
|
|
404
|
-
t('ta.settings.signOut')))),
|
|
405
|
-
]),
|
|
406
|
-
]
|
|
407
|
-
: [],
|
|
408
|
-
},
|
|
409
|
-
];
|
|
410
|
-
return [
|
|
411
|
-
{ id: 'web', title: t('ta.settings.web'), sections: web },
|
|
412
|
-
{ id: 'agent', title: t('ta.settings.agent'), sections: ta, lead },
|
|
413
|
-
{ id: 'more', title: t('ta.settings.more'), sections: more },
|
|
414
|
-
];
|
|
415
|
-
}
|
|
416
14
|
const sectionId = (id) => `ta-settings-${id}`;
|
|
417
15
|
/**
|
|
418
16
|
* The settings, as a page of the main area: those of this page (kept in the browser) and those of ta
|
|
@@ -4,7 +4,7 @@ import { Scanner } from '../device/scanner.js';
|
|
|
4
4
|
import { usePwa, useSettings } from '../hooks.js';
|
|
5
5
|
import { useT } from '../i18n/use-t.js';
|
|
6
6
|
import { STYLE } from '../style.js';
|
|
7
|
-
import { WorkbenchUtil } from '../workbench.js';
|
|
7
|
+
import { WorkbenchUtil } from '../workbench-util.js';
|
|
8
8
|
import { dinoFavicon } from './dino.js';
|
|
9
9
|
import { AddHostPanel } from './host-view.js';
|
|
10
10
|
import { SignInAccounts, useSignInWays } from './sign-in-accounts.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlarmClock, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, BellOff, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, Clipboard, Clock, Code, Columns2, Copy, CopyMinus, CornerUpLeft, Crown, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, House, Image, LayoutDashboard, Link, List, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Undo2, Unplug, Upload, User, UserPlus, Users, WholeWord, X, } from 'lucide-react';
|
|
1
|
+
import { AlarmClock, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, BellOff, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, Clipboard, Clock, Code, Columns2, Copy, CopyMinus, CornerUpLeft, Crown, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, House, Image, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Undo2, Unplug, Upload, User, UserPlus, Users, WholeWord, X, } from 'lucide-react';
|
|
2
2
|
/** The icons a web extension gets as `pi.ui.icons`; names are lucide's. Only add: removing one breaks extensions. */
|
|
3
3
|
export const WEB_ICONS = Object.freeze({
|
|
4
4
|
AlarmClock,
|
|
@@ -52,6 +52,7 @@ export const WEB_ICONS = Object.freeze({
|
|
|
52
52
|
LayoutDashboard,
|
|
53
53
|
Link,
|
|
54
54
|
List,
|
|
55
|
+
ListChecks,
|
|
55
56
|
ListTodo,
|
|
56
57
|
ListTree,
|
|
57
58
|
ListX,
|
|
@@ -275,6 +275,11 @@ export interface WebExtensionUI {
|
|
|
275
275
|
useView(id: string): WebViewInfo | undefined;
|
|
276
276
|
/** A React hook: the tasks of every extension (registerTasks), the double's too; the same array until one changes. */
|
|
277
277
|
useTasks(): readonly WebTaskEntry[];
|
|
278
|
+
/**
|
|
279
|
+
* Deletes tasks (`WebTask.remove`) once the user agrees, asked once for all of them (the title of one, the
|
|
280
|
+
* count of many, and what their `removeHint`s say); a failure is a notice. Resolves whether the user agreed.
|
|
281
|
+
*/
|
|
282
|
+
removeTasks(tasks: readonly WebTaskRemoval[]): Promise<boolean>;
|
|
278
283
|
/** ta: the dinosaur of the Cell logo; `mark`, one or two characters, tells agents apart. */
|
|
279
284
|
readonly Avatar: React.ComponentType<{
|
|
280
285
|
mood?: Mood;
|
|
@@ -313,6 +318,13 @@ export interface WebExtensionUI {
|
|
|
313
318
|
* it. Elsewhere, and without actions, it is the row alone (a right click or a long press is its menu).
|
|
314
319
|
*/
|
|
315
320
|
readonly SwipeRow: React.ComponentType<WebSwipeRowProps>;
|
|
321
|
+
/**
|
|
322
|
+
* Several rows of a list chosen at once, as the multiple selection of WeChat: the round mark a row shows at
|
|
323
|
+
* its start while the list is selecting (`SelectCheck`), and the bar under the list (`SelectBar`) with
|
|
324
|
+
* Select all, how many are chosen, their actions (Delete) and Done. One look for every list.
|
|
325
|
+
*/
|
|
326
|
+
readonly SelectCheck: React.ComponentType<WebSelectCheckProps>;
|
|
327
|
+
readonly SelectBar: React.ComponentType<WebSelectBarProps>;
|
|
316
328
|
/** A small picture as the pictures of Ta: an SVG whose shapes take the classes `ta-pic-*` (WebPictureProps). */
|
|
317
329
|
readonly Picture: React.ComponentType<WebPictureProps>;
|
|
318
330
|
/** Choices as pictures in a row, as the suggestions of an empty conversation: a click picks one. */
|
|
@@ -524,7 +536,7 @@ export interface WebEmptyProps {
|
|
|
524
536
|
/** Under the text: a button. */
|
|
525
537
|
children?: React.ReactNode;
|
|
526
538
|
}
|
|
527
|
-
/** An action behind a row a finger swiped (WebExtensionUI.SwipeRow): a word, as WeChat's. */
|
|
539
|
+
/** An action behind a row a finger swiped (WebExtensionUI.SwipeRow), or for the rows selected (SelectBar): a word, as WeChat's. */
|
|
528
540
|
export interface WebSwipeAction {
|
|
529
541
|
key: string;
|
|
530
542
|
label: string;
|
|
@@ -538,6 +550,22 @@ export interface WebSwipeRowProps {
|
|
|
538
550
|
className?: string;
|
|
539
551
|
children?: React.ReactNode;
|
|
540
552
|
}
|
|
553
|
+
export interface WebSelectCheckProps {
|
|
554
|
+
checked: boolean;
|
|
555
|
+
/** A row that cannot be chosen (nothing to do with it): a faint mark. */
|
|
556
|
+
disabled?: boolean;
|
|
557
|
+
}
|
|
558
|
+
export interface WebSelectBarProps {
|
|
559
|
+
/** How many are chosen, of how many could be. */
|
|
560
|
+
count: number;
|
|
561
|
+
total: number;
|
|
562
|
+
/** Chooses every row (`true`), or none. */
|
|
563
|
+
onSelectAll(all: boolean): void;
|
|
564
|
+
/** The list stops selecting. */
|
|
565
|
+
onDone(): void;
|
|
566
|
+
/** What can be done with those chosen: disabled while none is. */
|
|
567
|
+
actions: WebSwipeAction[];
|
|
568
|
+
}
|
|
541
569
|
export interface WebSkeletonProps {
|
|
542
570
|
/** How many rows, at most 6; 6 unless told. */
|
|
543
571
|
rows?: number;
|
|
@@ -797,7 +825,16 @@ export interface WebTask {
|
|
|
797
825
|
open(): void;
|
|
798
826
|
/** Its …, read each time it opens: stop it, take it over, keep its agents. */
|
|
799
827
|
menu?(): WebMenuItem[][];
|
|
828
|
+
/**
|
|
829
|
+
* Deletes it without asking, a running one stopped first: what its delete in `menu` does once the user
|
|
830
|
+
* agreed. The lists ask (`ui.removeTasks`) and call it, for a row swiped on a phone or for many selected.
|
|
831
|
+
*/
|
|
832
|
+
remove?(): Promise<void>;
|
|
833
|
+
/** What deleting it does besides, said when the user is asked: what stays, and where. */
|
|
834
|
+
removeHint?: string;
|
|
800
835
|
}
|
|
836
|
+
/** What deleting a task reads of it: its menu deletes it this way too, before it is listed. */
|
|
837
|
+
export type WebTaskRemoval = Pick<WebTask, 'title' | 'remove' | 'removeHint'>;
|
|
801
838
|
/** The tasks of an extension. `tasks` gives the same objects for what did not change, and is called again after `subscribe`'s listener. */
|
|
802
839
|
export interface WebTaskSource {
|
|
803
840
|
tasks(): readonly WebTask[];
|
|
@@ -21,6 +21,7 @@ import { SettingsModelPicker } from '../components/model-picker.js';
|
|
|
21
21
|
import { places } from '../components/nav-places.js';
|
|
22
22
|
import { Picture, PictureCards } from '../components/picture.js';
|
|
23
23
|
import { QrView } from '../components/qr-view.js';
|
|
24
|
+
import { SelectBar, SelectCheck } from '../components/select-bar.js';
|
|
24
25
|
import { SwipeRow } from '../components/swipe-row.js';
|
|
25
26
|
import { TaAvatar } from '../components/ta-avatar.js';
|
|
26
27
|
import { WebComposer } from '../components/web-composer.js';
|
|
@@ -28,6 +29,7 @@ import { WebDialog } from '../components/web-dialog.js';
|
|
|
28
29
|
import { Device, useDevice } from '../device/device.js';
|
|
29
30
|
import { Scanner } from '../device/scanner.js';
|
|
30
31
|
import { message as messageOf } from '../i18n/messages.js';
|
|
32
|
+
import { translator } from '../i18n/use-t.js';
|
|
31
33
|
import { TaLinks } from '../links/links-protocol.js';
|
|
32
34
|
import { TaNotices } from '../notices/notices-protocol.js';
|
|
33
35
|
import { TaSettings } from '../settings/settings-protocol.js';
|
|
@@ -42,7 +44,7 @@ import { BuiltinWebExtension, TaWebExtensions, WebLabelUtil, } from './web-exten
|
|
|
42
44
|
import { WebOnDemand } from './web-on-demand.js';
|
|
43
45
|
import { WebPagesUtil } from './web-pages.js';
|
|
44
46
|
import { WebSharing } from './web-sharing.js';
|
|
45
|
-
import { WebTaskBoard } from './web-tasks.js';
|
|
47
|
+
import { WebTaskBoard, WebTaskUtil } from './web-tasks.js';
|
|
46
48
|
import { WebExtensionUtil, WebViewUtil } from './web-view-util.js';
|
|
47
49
|
const DEFAULT_ORDER = 100;
|
|
48
50
|
const FILE_DRAG = Object.freeze({ set: FileDragUtil.set, has: FileDragUtil.has, get: FileDragUtil.get, paths: FileDragUtil.paths });
|
|
@@ -649,6 +651,7 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
|
|
|
649
651
|
openShared: text => (run.stopped ? Promise.resolve(false) : this.openShared(text)),
|
|
650
652
|
forgetPage: id => !run.stopped && this.forgetPage(id),
|
|
651
653
|
useTasks: () => React.useSyncExternalStore(this.tasks.subscribe, this.tasks.tasks, this.tasks.tasks),
|
|
654
|
+
removeTasks: tasks => (run.stopped ? Promise.resolve(false) : WebTaskUtil.remove(tasks, this.notices, translator(settings.state.language))),
|
|
652
655
|
useView: id => {
|
|
653
656
|
const find = () => this.current.views.find(candidate => candidate.id === id);
|
|
654
657
|
const isShown = () => this.isShown(id);
|
|
@@ -674,6 +677,8 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
|
|
|
674
677
|
Skeleton: ListSkeleton,
|
|
675
678
|
HostTag,
|
|
676
679
|
SwipeRow,
|
|
680
|
+
SelectCheck,
|
|
681
|
+
SelectBar,
|
|
677
682
|
Picture,
|
|
678
683
|
PictureCards,
|
|
679
684
|
QrCode: QrView,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Translate } from '../i18n/use-t.js';
|
|
2
|
+
import type { TaNotices } from '../notices/notices-protocol.js';
|
|
3
|
+
import type { WebTask, WebTaskEntry, WebTaskRemoval, WebTaskSource } from './web-extension-api.js';
|
|
2
4
|
/** A source of tasks and the extension that registered it. */
|
|
3
5
|
export interface WebTaskSourceEntry {
|
|
4
6
|
/** The name of the extension: `assistant`, `@celljs/ta-channels`. */
|
|
@@ -18,6 +20,12 @@ export declare namespace WebTaskUtil {
|
|
|
18
20
|
function groups(tasks: readonly WebTaskEntry[]): WebTaskGroups;
|
|
19
21
|
/** `12s`, `3m 05s`, `1h 02m`: from its start to its end, or to now. */
|
|
20
22
|
function elapsed(task: Pick<WebTask, 'startedAt' | 'endedAt'>, now: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Deletes those that can be (`remove`) once the user agrees: asked once, with the title of one or the count
|
|
25
|
+
* of many, and what deleting them does (their `removeHint`s, each once). Each failure is a notice; the
|
|
26
|
+
* others go on. Whether the user agreed.
|
|
27
|
+
*/
|
|
28
|
+
function remove(tasks: readonly WebTaskRemoval[], notices: Pick<TaNotices, 'confirm' | 'error'>, t: Translate): Promise<boolean>;
|
|
21
29
|
/** The tasks handed out from a conversation (its session file) in a span of time: those a turn of it started. */
|
|
22
30
|
function startedIn(tasks: readonly WebTaskEntry[], origin: string | undefined, from: number, until: number): WebTaskEntry[];
|
|
23
31
|
}
|
|
@@ -32,6 +32,30 @@ export var WebTaskUtil;
|
|
|
32
32
|
return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, '0')}m`;
|
|
33
33
|
}
|
|
34
34
|
WebTaskUtil.elapsed = elapsed;
|
|
35
|
+
/**
|
|
36
|
+
* Deletes those that can be (`remove`) once the user agrees: asked once, with the title of one or the count
|
|
37
|
+
* of many, and what deleting them does (their `removeHint`s, each once). Each failure is a notice; the
|
|
38
|
+
* others go on. Whether the user agreed.
|
|
39
|
+
*/
|
|
40
|
+
async function remove(tasks, notices, t) {
|
|
41
|
+
const removable = tasks.filter(task => task.remove);
|
|
42
|
+
if (removable.length === 0) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const hints = [...new Set(removable.map(task => { var _a; return (_a = task.removeHint) === null || _a === void 0 ? void 0 : _a.trim(); }).filter(Boolean))];
|
|
46
|
+
const agreed = await notices.confirm({
|
|
47
|
+
title: removable.length === 1 ? t('ta.task.removeTitle', { title: removable[0].title }) : t('ta.tasks.removeTitle', { count: removable.length }),
|
|
48
|
+
message: hints.join('\n') || undefined,
|
|
49
|
+
confirmLabel: t('ta.task.remove'),
|
|
50
|
+
danger: true,
|
|
51
|
+
});
|
|
52
|
+
if (!agreed) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
await Promise.all(removable.map(task => { var _a; return (_a = task.remove) === null || _a === void 0 ? void 0 : _a.call(task).catch(error => void notices.error(error)); }));
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
WebTaskUtil.remove = remove;
|
|
35
59
|
/** The tasks handed out from a conversation (its session file) in a span of time: those a turn of it started. */
|
|
36
60
|
function startedIn(tasks, origin, from, until) {
|
|
37
61
|
if (!origin) {
|
package/esm/browser/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SessionState, SessionStore } from '@celljs/ta-client';
|
|
2
2
|
import type { TaSettingsServer } from '@celljs/ta-protocol';
|
|
3
|
-
import type { WebTaskEntry } from './extension/web-extension-api.js';
|
|
3
|
+
import type { WebTaskEntry, WebTaskRemoval } from './extension/web-extension-api.js';
|
|
4
4
|
import { TaWebExtensions, type WebExtensionsState } from './extension/web-extension-protocol.js';
|
|
5
5
|
import { type LinksState, TaLinks } from './links/links-protocol.js';
|
|
6
6
|
import { type NoticesState, TaNotices } from './notices/notices-protocol.js';
|
|
@@ -19,6 +19,8 @@ export declare function useOpenLink(cwd: string | undefined): (target: LinkTarge
|
|
|
19
19
|
export declare function useWebExtensions(): [WebExtensionsState, TaWebExtensions];
|
|
20
20
|
/** The tasks of every web extension, the double's too: only a change of them draws again. */
|
|
21
21
|
export declare function useTasks(): readonly WebTaskEntry[];
|
|
22
|
+
/** Deletes tasks once the user agrees, asked once for all (WebTaskUtil.remove, `ui.removeTasks` of web extensions): whether they agreed. */
|
|
23
|
+
export declare function useRemoveTasks(): (tasks: readonly WebTaskRemoval[]) => Promise<boolean>;
|
|
22
24
|
/** A value of the page kept at its tier (TaState), and how to change it. `spec` should be one object for the value, not made again each render. */
|
|
23
25
|
export declare function usePersisted<T>(spec: StateSpec<T>): [T, (value: T | ((previous: T) => T)) => void];
|
|
24
26
|
/** The state of a session, drawn at most once a frame while a model streams. */
|