@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
|
@@ -33,423 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SHORTCUTS = void 0;
|
|
37
36
|
exports.SettingsView = SettingsView;
|
|
38
|
-
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
39
37
|
const lucide_react_1 = require("lucide-react");
|
|
40
38
|
const React = __importStar(require("react"));
|
|
41
39
|
const device_1 = require("../device/device");
|
|
42
|
-
const icons_1 = require("../extension/icons");
|
|
43
|
-
const web_extension_protocol_1 = require("../extension/web-extension-protocol");
|
|
44
|
-
const hooks_1 = require("../hooks");
|
|
45
40
|
const use_t_1 = require("../i18n/use-t");
|
|
46
|
-
const agent_settings_1 = require("../settings/agent-settings");
|
|
47
|
-
const navigation_1 = require("../settings/navigation");
|
|
48
|
-
const settings_protocol_1 = require("../settings/settings-protocol");
|
|
49
|
-
const workbench_1 = require("../workbench");
|
|
50
|
-
const access_view_1 = require("./access-view");
|
|
51
|
-
const agent_settings_view_1 = require("./agent-settings-view");
|
|
52
|
-
const app_nav_1 = require("./app-nav");
|
|
53
41
|
const auth_view_1 = require("./auth-view");
|
|
54
42
|
const empty_state_1 = require("./empty-state");
|
|
55
|
-
const environment_view_1 = require("./environment-view");
|
|
56
43
|
const icon_1 = require("./icon");
|
|
57
|
-
const launch_settings_1 = require("./launch-settings");
|
|
58
44
|
const list_rows_1 = require("./list-rows");
|
|
59
|
-
const model_picker_1 = require("./model-picker");
|
|
60
45
|
const phone_shell_1 = require("./phone-shell");
|
|
61
46
|
const relay_view_1 = require("./relay-view");
|
|
62
|
-
const remote_hosts_1 = require("./remote-hosts");
|
|
63
47
|
const settings_controls_1 = require("./settings-controls");
|
|
64
|
-
const
|
|
48
|
+
const settings_parts_1 = require("./settings-parts");
|
|
65
49
|
const working_directory_1 = require("./working-directory");
|
|
66
|
-
const THEMES = [
|
|
67
|
-
{ value: 'system', icon: lucide_react_1.Monitor, label: 'ta.settings.theme.system' },
|
|
68
|
-
{ value: 'light', icon: lucide_react_1.Sun, label: 'ta.settings.theme.light' },
|
|
69
|
-
{ value: 'dark', icon: lucide_react_1.Moon, label: 'ta.settings.theme.dark' },
|
|
70
|
-
];
|
|
71
|
-
const FONT_SIZES = [
|
|
72
|
-
{ value: 'small', label: 'ta.settings.fontSize.small' },
|
|
73
|
-
{ value: 'standard', label: 'ta.settings.fontSize.standard' },
|
|
74
|
-
{ value: 'large', label: 'ta.settings.fontSize.large' },
|
|
75
|
-
{ value: 'xlarge', label: 'ta.settings.fontSize.xlarge' },
|
|
76
|
-
];
|
|
77
|
-
const LANGUAGES = [
|
|
78
|
-
{ value: 'system', icon: lucide_react_1.Globe, label: 'ta.settings.language.system' },
|
|
79
|
-
{ value: 'zh-CN', label: '简体中文' },
|
|
80
|
-
{ value: 'en-US', label: 'English' },
|
|
81
|
-
];
|
|
82
|
-
const GROUP_ICONS = { model: lucide_react_1.Sparkles, conversation: lucide_react_1.MessagesSquare, context: lucide_react_1.Layers, tools: lucide_react_1.Wrench };
|
|
83
|
-
/** The keys of the page and of the message box; `Mod` is ⌘ on a Mac, Ctrl elsewhere. */
|
|
84
|
-
exports.SHORTCUTS = [
|
|
85
|
-
{ keys: 'Mod+,', label: 'ta.shortcut.settings' },
|
|
86
|
-
{ keys: 'Mod+B', label: 'ta.shortcut.sidebar' },
|
|
87
|
-
{ keys: 'Enter', label: 'ta.shortcut.send' },
|
|
88
|
-
{ keys: 'Shift+Enter', label: 'ta.shortcut.newline' },
|
|
89
|
-
{ keys: 'Alt+Enter', label: 'ta.shortcut.followUp' },
|
|
90
|
-
{ keys: 'Esc', label: 'ta.shortcut.stop' },
|
|
91
|
-
{ keys: '/', label: 'ta.shortcut.commands' },
|
|
92
|
-
{ keys: '@', label: 'ta.shortcut.files' },
|
|
93
|
-
{ keys: 'Mod+S', label: 'ta.shortcut.save' },
|
|
94
|
-
];
|
|
95
|
-
/**
|
|
96
|
-
* The packages pi loads, as the server lists them, those turned off too: the built-in ones turn off and
|
|
97
|
-
* stay; the others turn off and on, and go.
|
|
98
|
-
*/
|
|
99
|
-
function usePackages() {
|
|
100
|
-
const [workbench, bench] = (0, hooks_1.useWorkbench)();
|
|
101
|
-
const [, host] = (0, hooks_1.useWebExtensions)();
|
|
102
|
-
const [packages, setPackages] = React.useState([]);
|
|
103
|
-
const read = React.useCallback(() => bench.packages.listPackages().then(setPackages), [bench]);
|
|
104
|
-
React.useEffect(() => {
|
|
105
|
-
if (workbench.status === 'online') {
|
|
106
|
-
read().catch(() => undefined);
|
|
107
|
-
}
|
|
108
|
-
}, [workbench.status, read]);
|
|
109
|
-
const changed = async () => {
|
|
110
|
-
await host.reloadPackages();
|
|
111
|
-
await read();
|
|
112
|
-
};
|
|
113
|
-
/** By the name of a built-in package, by the id of another. */
|
|
114
|
-
const toggle = async (pkg, on) => {
|
|
115
|
-
setPackages(current => current.map(other => (other.id === pkg.id ? { ...other, enabled: on } : other)));
|
|
116
|
-
await bench.packages.setPackageEnabled(pkg.origin === 'builtin' ? pkg.name : pkg.id, on);
|
|
117
|
-
await changed();
|
|
118
|
-
};
|
|
119
|
-
const remove = async (pkg) => {
|
|
120
|
-
await bench.packages.removePackage(pkg.id);
|
|
121
|
-
await changed();
|
|
122
|
-
};
|
|
123
|
-
return { packages, toggle, remove, read };
|
|
124
|
-
}
|
|
125
|
-
const SLOTS = Array.from({ length: navigation_1.NavigationUtil.MAX_SLOTS - navigation_1.NavigationUtil.MIN_SLOTS + 1 }, (_, index) => {
|
|
126
|
-
const value = String(navigation_1.NavigationUtil.MIN_SLOTS + index);
|
|
127
|
-
return { value, label: value };
|
|
128
|
-
});
|
|
129
|
-
/** The rows of the navigation: how many pages it shows, and where each page is. */
|
|
130
|
-
function navigationRows(navigation, t) {
|
|
131
|
-
const { setting } = navigation;
|
|
132
|
-
const where = (id, byDefault) => {
|
|
133
|
-
if (setting.pinned.includes(id) && navigation.nav.some(page => page.id === id)) {
|
|
134
|
-
return t('ta.settings.navigation.pinned');
|
|
135
|
-
}
|
|
136
|
-
if (navigation.nav.some(page => page.id === id)) {
|
|
137
|
-
return t('ta.settings.navigation.inNav');
|
|
138
|
-
}
|
|
139
|
-
return t(setting.discover.includes(id) || byDefault ? 'ta.settings.navigation.folded' : 'ta.settings.navigation.overflow');
|
|
140
|
-
};
|
|
141
|
-
return [
|
|
142
|
-
(0, settings_controls_1.row)('navigation-slots', [t('ta.settings.navigation.slots'), t('ta.settings.navigation.slotsHint'), t('ta.discover')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.navigation.slots'), description: t('ta.settings.navigation.slotsHint'), stacked: true },
|
|
143
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.navigation.slots'), value: String(setting.slots), choices: SLOTS, onChange: slots => navigation.update({ ...setting, slots: Number(slots) }) }))),
|
|
144
|
-
...navigation.pages.map(page => {
|
|
145
|
-
const title = web_extension_protocol_1.WebLabelUtil.text(page.title);
|
|
146
|
-
const shown = navigation.nav.includes(page);
|
|
147
|
-
return (0, settings_controls_1.row)(`navigation:${page.id}`, [title, t('ta.settings.navigation')], React.createElement(settings_controls_1.Row, { label: title, description: where(page.id, page.discover) },
|
|
148
|
-
React.createElement(settings_controls_1.Switch, { label: `${t('ta.settings.navigation.show')} · ${title}`, checked: shown, onChange: on => (on ? navigation.pin(page.id) : navigation.fold(page.id)) })));
|
|
149
|
-
}),
|
|
150
|
-
...(navigation.pages.length === 0
|
|
151
|
-
? [(0, settings_controls_1.row)('navigation:none', [t('ta.settings.navigation.none')], React.createElement(settings_controls_1.EmptyRow, { title: t('ta.settings.navigation.none') }))]
|
|
152
|
-
: []),
|
|
153
|
-
...(navigation_1.NavigationUtil.moved(setting)
|
|
154
|
-
? [
|
|
155
|
-
(0, settings_controls_1.row)('navigation-reset', [t('ta.settings.navigation.reset')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.navigation.reset'), description: t('ta.settings.navigation.resetHint') },
|
|
156
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => navigation.update(navigation_1.NavigationUtil.reset(setting)) },
|
|
157
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.RefreshCw, size: 14 }),
|
|
158
|
-
" ",
|
|
159
|
-
t('ta.settings.navigation.resetButton')))),
|
|
160
|
-
]
|
|
161
|
-
: []),
|
|
162
|
-
];
|
|
163
|
-
}
|
|
164
|
-
/** How a package shows in a row: what it calls itself for people, else its name and the description of its package.json. */
|
|
165
|
-
function packageLabel(pkg, language) {
|
|
166
|
-
var _a, _b;
|
|
167
|
-
return {
|
|
168
|
-
title: (_a = ta_protocol_1.TaPackageTextUtil.pick(pkg.title, language)) !== null && _a !== void 0 ? _a : pkg.name,
|
|
169
|
-
summary: (_b = ta_protocol_1.TaPackageTextUtil.pick(pkg.summary, language)) !== null && _b !== void 0 ? _b : pkg.description,
|
|
170
|
-
icon: (pkg.icon && icons_1.WEB_ICONS[pkg.icon]) || lucide_react_1.Puzzle,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/** The sections of the page and of ta, by part, with their rows. */
|
|
174
|
-
function useParts(scope, onScope, onClose, onDialog) {
|
|
175
|
-
var _a;
|
|
176
|
-
const t = (0, use_t_1.useT)();
|
|
177
|
-
const language = (0, use_t_1.useLanguage)();
|
|
178
|
-
const [{ settings }, store] = (0, hooks_1.useSettings)();
|
|
179
|
-
const settingsServer = (0, hooks_1.useSettingsServer)();
|
|
180
|
-
const [workbench, bench] = (0, hooks_1.useWorkbench)();
|
|
181
|
-
const [{ extensions, cwd, views }, host] = (0, hooks_1.useWebExtensions)();
|
|
182
|
-
const navigation = (0, app_nav_1.useNavigation)(views);
|
|
183
|
-
const packageList = usePackages();
|
|
184
|
-
const builtinPackages = packageList.packages.filter(pkg => pkg.origin === 'builtin');
|
|
185
|
-
const agent = (0, agent_settings_view_1.useAgentSettings)(cwd !== null && cwd !== void 0 ? cwd : (_a = workbench.server) === null || _a === void 0 ? void 0 : _a.cwd);
|
|
186
|
-
const [, notices] = (0, hooks_1.useNotices)();
|
|
187
|
-
const access = (0, access_view_1.useAccess)();
|
|
188
|
-
const gateway = (0, environment_view_1.useGateway)();
|
|
189
|
-
// As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
|
|
190
|
-
// that pairs phones, and signs out at the foot of Me.
|
|
191
|
-
const touch = (0, device_1.useDevice)(device => device.touch);
|
|
192
|
-
const handheld = (0, device_1.useDevice)(device => device.handheld);
|
|
193
|
-
const [busy, setBusy] = React.useState(false);
|
|
194
|
-
const run = (action, done) => {
|
|
195
|
-
setBusy(true);
|
|
196
|
-
action()
|
|
197
|
-
.then(() => done && notices.notify(done, { level: 'success' }))
|
|
198
|
-
.catch(error => notices.error(error))
|
|
199
|
-
.finally(() => setBusy(false));
|
|
200
|
-
};
|
|
201
|
-
const remove = async (pkg) => {
|
|
202
|
-
const confirmed = await notices.confirm({
|
|
203
|
-
title: t('ta.packages.removeConfirm', { name: pkg.name }),
|
|
204
|
-
message: t('ta.packages.removeDetail'),
|
|
205
|
-
confirmLabel: t('ta.packages.remove'),
|
|
206
|
-
danger: true,
|
|
207
|
-
});
|
|
208
|
-
if (confirmed) {
|
|
209
|
-
run(() => packageList.remove(pkg), t('ta.packages.removed', { name: pkg.name }));
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
const toggleBuiltin = (name, on) => {
|
|
213
|
-
store.update({ builtinsOff: on ? settings.builtinsOff.filter(other => other !== name) : [...settings.builtinsOff, name] });
|
|
214
|
-
run(() => host.refresh());
|
|
215
|
-
};
|
|
216
|
-
const web = [
|
|
217
|
-
{
|
|
218
|
-
id: 'appearance',
|
|
219
|
-
title: t('ta.settings.appearance'),
|
|
220
|
-
icon: lucide_react_1.Palette,
|
|
221
|
-
rows: [
|
|
222
|
-
(0, settings_controls_1.row)('theme', [t('ta.settings.theme'), 'theme'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.theme'), stacked: true },
|
|
223
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.theme'), value: settings.theme, choices: THEMES, onChange: theme => store.update({ theme }) }))),
|
|
224
|
-
(0, settings_controls_1.row)('font-size', [t('ta.settings.fontSize'), t('ta.settings.fontSizeHint'), 'font'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.fontSize'), description: t('ta.settings.fontSizeHint'), stacked: true },
|
|
225
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.fontSize'), value: settings.fontSize, choices: FONT_SIZES, onChange: fontSize => store.update({ fontSize }) }))),
|
|
226
|
-
(0, settings_controls_1.row)('chat-font-size', [t('ta.settings.chatFontSize'), t('ta.settings.chatFontSizeHint'), 'font'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.chatFontSize'), description: t('ta.settings.chatFontSizeHint'), stacked: true },
|
|
227
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.chatFontSize'), value: settings.chatFontSize, choices: FONT_SIZES, onChange: chatFontSize => store.update({ chatFontSize }) }))),
|
|
228
|
-
(0, settings_controls_1.row)('motion', [t('ta.settings.motion'), t('ta.settings.motionHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.motion'), description: t('ta.settings.motionHint') },
|
|
229
|
-
React.createElement(settings_controls_1.Switch, { label: t('ta.settings.motion'), checked: settings.reduceMotion, onChange: reduceMotion => store.update({ reduceMotion }) }))),
|
|
230
|
-
],
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
id: 'language',
|
|
234
|
-
title: t('ta.settings.language'),
|
|
235
|
-
icon: lucide_react_1.Languages,
|
|
236
|
-
rows: [
|
|
237
|
-
(0, settings_controls_1.row)('language', [t('ta.settings.displayLanguage'), 'language'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.displayLanguage'), stacked: true },
|
|
238
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.displayLanguage'), value: settings.language, choices: LANGUAGES, onChange: language => store.update({ language }) }))),
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
id: 'navigation',
|
|
243
|
-
title: t('ta.settings.navigation'),
|
|
244
|
-
icon: lucide_react_1.Compass,
|
|
245
|
-
rows: navigationRows(navigation, t),
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
id: 'links',
|
|
249
|
-
title: t('ta.settings.links'),
|
|
250
|
-
icon: lucide_react_1.Link2,
|
|
251
|
-
rows: [
|
|
252
|
-
(0, settings_controls_1.row)('trusted-domains', [t('ta.settings.trustedDomains'), t('ta.settings.trustedDomainsHint'), ...settings.trustedDomains], React.createElement(trusted_domains_1.TrustedDomains, null)),
|
|
253
|
-
],
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
id: 'assistant',
|
|
257
|
-
title: t('ta.settings.assistant'),
|
|
258
|
-
icon: lucide_react_1.Bot,
|
|
259
|
-
rows: [
|
|
260
|
-
(0, settings_controls_1.row)('assistant-model', [t('ta.settings.assistantModel'), t('ta.settings.assistantModelHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.assistantModel'), description: t('ta.settings.assistantModelHint'), stacked: true },
|
|
261
|
-
React.createElement(model_picker_1.SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.assistantModel'), value: settings.assistantModel, onChange: assistantModel => store.update({ assistantModel }) }))),
|
|
262
|
-
(0, settings_controls_1.row)('task-model', [t('ta.settings.taskModel'), t('ta.settings.taskModelHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.taskModel'), description: t('ta.settings.taskModelHint'), stacked: true },
|
|
263
|
-
React.createElement(model_picker_1.SettingsModelPicker, { settings: settingsServer, label: t('ta.settings.taskModel'), value: settings.taskModel, onChange: taskModel => store.update({ taskModel }) }))),
|
|
264
|
-
(0, settings_controls_1.row)('confirm-tasks', [t('ta.settings.confirmTasks'), t('ta.settings.confirmTasksHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.confirmTasks'), description: t('ta.settings.confirmTasksHint') },
|
|
265
|
-
React.createElement(settings_controls_1.Switch, { label: t('ta.settings.confirmTasks'), checked: settings.confirmTasks, onChange: confirmTasks => store.update({ confirmTasks }) }))),
|
|
266
|
-
(0, settings_controls_1.row)('max-tasks', [t('ta.settings.maxTasks'), t('ta.settings.maxTasksHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.maxTasks'), description: t('ta.settings.maxTasksHint'), stacked: true },
|
|
267
|
-
React.createElement(settings_controls_1.Segmented, { label: t('ta.settings.maxTasks'), value: String(settings.maxTasks), choices: settings_protocol_1.MAX_TASKS_CHOICES.map(count => ({
|
|
268
|
-
value: String(count),
|
|
269
|
-
label: count === 0 ? t('ta.settings.maxTasksAny') : String(count),
|
|
270
|
-
})), onChange: value => store.update({ maxTasks: Number(value) }) }))),
|
|
271
|
-
],
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
id: 'voice',
|
|
275
|
-
title: t('ta.settings.voice'),
|
|
276
|
-
icon: lucide_react_1.Volume2,
|
|
277
|
-
rows: [
|
|
278
|
-
(0, settings_controls_1.row)('speak', [t('ta.settings.speak'), t('ta.settings.speakHint')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.speak'), description: t('ta.settings.speakHint') },
|
|
279
|
-
React.createElement(settings_controls_1.Switch, { label: t('ta.settings.speak'), checked: settings.speak, onChange: speak => store.update({ speak }) }))),
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
];
|
|
283
|
-
const { snapshot } = agent;
|
|
284
|
-
const locked = !!snapshot && scope === 'project' && !snapshot.projectTrusted;
|
|
285
|
-
const lead = (React.createElement(React.Fragment, null,
|
|
286
|
-
React.createElement(agent_settings_view_1.ScopeBar, { scope: scope, onScope: onScope, snapshot: snapshot }),
|
|
287
|
-
agent.offline && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.offline')),
|
|
288
|
-
!agent.offline && !snapshot && !agent.error && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.loading')),
|
|
289
|
-
locked && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.untrusted')),
|
|
290
|
-
agent.error && React.createElement("div", { className: "ta-banner ta-banner-error" }, t('ta.settings.failed', { error: agent.error }))));
|
|
291
|
-
const ta = agent_settings_1.AGENT_SETTINGS_GROUPS.map(group => { var _a; return ({
|
|
292
|
-
id: group.id,
|
|
293
|
-
title: t(group.title),
|
|
294
|
-
icon: (_a = GROUP_ICONS[group.id]) !== null && _a !== void 0 ? _a : lucide_react_1.Wrench,
|
|
295
|
-
rows: snapshot
|
|
296
|
-
? group.keys.flatMap(key => {
|
|
297
|
-
const spec = agent_settings_1.AgentSettingsUtil.spec(key);
|
|
298
|
-
if (!spec) {
|
|
299
|
-
return [];
|
|
300
|
-
}
|
|
301
|
-
const label = t(agent_settings_1.AgentSettingsUtil.label(key));
|
|
302
|
-
const hint = agent_settings_1.AgentSettingsUtil.hint(key);
|
|
303
|
-
return [
|
|
304
|
-
(0, settings_controls_1.row)(key, [label, hint && t(hint), key], React.createElement(settings_controls_1.Row, { label: label, description: hint && t(hint), modified: snapshot[scope][key] !== undefined },
|
|
305
|
-
React.createElement(agent_settings_view_1.AgentControl, { spec: spec, scope: scope, snapshot: snapshot, disabled: locked, onChange: changes => agent.update(scope, changes) }))),
|
|
306
|
-
];
|
|
307
|
-
})
|
|
308
|
-
: [],
|
|
309
|
-
}); });
|
|
310
|
-
// Those opened without installing are in Quick open, which installs or deletes them (ta-launcher.md).
|
|
311
|
-
const packages = packageList.packages.filter(pkg => pkg.origin !== 'builtin' && pkg.origin !== 'temporary');
|
|
312
|
-
const launchRows = (0, launch_settings_1.useLaunchRows)();
|
|
313
|
-
/** Why the web extension of a package did not load, if it did not. */
|
|
314
|
-
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; };
|
|
315
|
-
const reload = async () => {
|
|
316
|
-
await host.refresh();
|
|
317
|
-
await packageList.read();
|
|
318
|
-
};
|
|
319
|
-
const more = [
|
|
320
|
-
{
|
|
321
|
-
id: 'packages',
|
|
322
|
-
title: t('ta.packages'),
|
|
323
|
-
icon: lucide_react_1.Puzzle,
|
|
324
|
-
rows: [
|
|
325
|
-
(0, settings_controls_1.row)('packages', [t('ta.packages'), t('ta.packages.hint')], React.createElement(settings_controls_1.Row, { label: t('ta.packages.installed'), description: t('ta.packages.hint') },
|
|
326
|
-
React.createElement("button", { type: "button", className: "ta-button", disabled: busy, onClick: () => run(reload, t('ta.packages.reloaded')) },
|
|
327
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.RefreshCw, size: 14 }),
|
|
328
|
-
" ",
|
|
329
|
-
t('ta.packages.reload')))),
|
|
330
|
-
...packages.map(pkg => {
|
|
331
|
-
const error = failure(pkg);
|
|
332
|
-
const { title, summary, icon } = packageLabel(pkg, language);
|
|
333
|
-
return (0, settings_controls_1.row)(`package:${pkg.id}`, [title, summary, pkg.name, t('ta.packages')], React.createElement(settings_controls_1.Row, { icon: icon, label: title, description: error
|
|
334
|
-
? t('ta.packages.failed', { error })
|
|
335
|
-
: [summary, t(pkg.scope === 'project' ? 'ta.packages.scope.project' : 'ta.packages.scope.user')].filter(Boolean).join(' · ') },
|
|
336
|
-
React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.packages.remove'), disabled: busy, onClick: () => void remove(pkg) }),
|
|
337
|
-
React.createElement(settings_controls_1.Switch, { label: title, checked: pkg.enabled, disabled: busy, onChange: on => run(() => packageList.toggle(pkg, on)) })));
|
|
338
|
-
}),
|
|
339
|
-
...(packages.length === 0
|
|
340
|
-
? [(0, settings_controls_1.row)('packages:none', [t('ta.packages.none')], React.createElement(settings_controls_1.EmptyRow, { title: t('ta.packages.none'), hint: t('ta.packages.noneHint') }))]
|
|
341
|
-
: []),
|
|
342
|
-
...launchRows,
|
|
343
|
-
],
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
id: 'builtin',
|
|
347
|
-
title: t('ta.packages.builtinTitle'),
|
|
348
|
-
icon: lucide_react_1.Blocks,
|
|
349
|
-
rows: [
|
|
350
|
-
...host.builtins.map(builtin => { var _a; return (0, settings_controls_1.row)(`web:${builtin.name}`, [t(builtin.title), t(builtin.description), t('ta.packages.builtinTitle')], React.createElement(settings_controls_1.Row, { icon: (_a = builtin.icon) !== null && _a !== void 0 ? _a : lucide_react_1.Puzzle, label: t(builtin.title), description: t(builtin.description) },
|
|
351
|
-
React.createElement(settings_controls_1.Switch, { label: t(builtin.title), checked: !settings.builtinsOff.includes(builtin.name), onChange: on => toggleBuiltin(builtin.name, on) }))); }),
|
|
352
|
-
...builtinPackages.map(info => {
|
|
353
|
-
const { title, summary, icon } = packageLabel(info, language);
|
|
354
|
-
return (0, settings_controls_1.row)(`builtin:${info.name}`, [title, summary, info.name, t('ta.packages.builtinTitle')], React.createElement(settings_controls_1.Row, { icon: icon, label: title, description: summary },
|
|
355
|
-
React.createElement(settings_controls_1.Switch, { label: title, checked: info.enabled, onChange: on => run(() => packageList.toggle(info, on)) })));
|
|
356
|
-
}),
|
|
357
|
-
],
|
|
358
|
-
},
|
|
359
|
-
// Behind a gateway only: where the Ta of this account runs.
|
|
360
|
-
...(gateway.info
|
|
361
|
-
? [
|
|
362
|
-
{
|
|
363
|
-
id: 'environment',
|
|
364
|
-
title: t('ta.environment.title'),
|
|
365
|
-
icon: lucide_react_1.Cloud,
|
|
366
|
-
rows: [
|
|
367
|
-
(0, settings_controls_1.row)('environment', [t('ta.environment.title'), t('ta.environment.whereHint'), 'sandbox', 'docker'], React.createElement(environment_view_1.EnvironmentSettings, { info: gateway.info, onChange: gateway.read })),
|
|
368
|
-
],
|
|
369
|
-
},
|
|
370
|
-
]
|
|
371
|
-
: []),
|
|
372
|
-
// Only where accounts can sign in, or could: a Ta of this computer has no need of it.
|
|
373
|
-
...(access.info && (access.info.providers.length > 0 || access.info.accounts.length > 0)
|
|
374
|
-
? [
|
|
375
|
-
{
|
|
376
|
-
id: 'access',
|
|
377
|
-
title: t('ta.access.title'),
|
|
378
|
-
icon: lucide_react_1.ShieldCheck,
|
|
379
|
-
rows: [
|
|
380
|
-
(0, settings_controls_1.row)('access', [t('ta.access.title'), t('ta.access.addHint'), 'github', 'google', 'wechat'], React.createElement(access_view_1.AccessSettings, { info: access.info, onChange: access.read })),
|
|
381
|
-
],
|
|
382
|
-
},
|
|
383
|
-
]
|
|
384
|
-
: []),
|
|
385
|
-
{
|
|
386
|
-
id: 'remote',
|
|
387
|
-
title: t('ta.remote.title'),
|
|
388
|
-
icon: lucide_react_1.Server,
|
|
389
|
-
rows: [(0, settings_controls_1.row)('remote', [t('ta.remote.title'), t('ta.remote.description'), 'ssh'], React.createElement(remote_hosts_1.RemoteHosts, null))],
|
|
390
|
-
},
|
|
391
|
-
...(touch
|
|
392
|
-
? []
|
|
393
|
-
: [
|
|
394
|
-
{
|
|
395
|
-
id: 'shortcuts',
|
|
396
|
-
title: t('ta.settings.shortcuts'),
|
|
397
|
-
icon: lucide_react_1.Keyboard,
|
|
398
|
-
rows: exports.SHORTCUTS.map(shortcut => (0, settings_controls_1.row)(`key:${shortcut.keys}`, [t(shortcut.label), shortcut.keys, t('ta.settings.shortcuts')], React.createElement(settings_controls_1.Row, { label: t(shortcut.label) },
|
|
399
|
-
React.createElement(settings_controls_1.Keys, { keys: shortcut.keys })))),
|
|
400
|
-
},
|
|
401
|
-
]),
|
|
402
|
-
{
|
|
403
|
-
id: 'about',
|
|
404
|
-
title: t('ta.settings.about'),
|
|
405
|
-
icon: lucide_react_1.Info,
|
|
406
|
-
rows: workbench.server
|
|
407
|
-
? [
|
|
408
|
-
(0, settings_controls_1.row)('version', [t('ta.settings.version'), 'version'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.version') },
|
|
409
|
-
React.createElement("span", { className: "ta-path" },
|
|
410
|
-
"v",
|
|
411
|
-
workbench.server.version))),
|
|
412
|
-
(0, settings_controls_1.row)('cwd', [t('ta.settings.cwd'), workbench.server.cwd], React.createElement(settings_controls_1.Row, { label: t('ta.settings.cwd'), description: t('ta.settings.cwdDescription', { path: workbench.server.cwd }) },
|
|
413
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
|
|
414
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.FolderOpen, size: 15 }),
|
|
415
|
-
" ",
|
|
416
|
-
t('ta.settings.cwdChange')))),
|
|
417
|
-
(0, settings_controls_1.row)('accounts', [t('ta.settings.accounts'), t('ta.settings.accountsDescription')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.accounts'), description: t('ta.settings.accountsDescription') },
|
|
418
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('accounts') },
|
|
419
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.KeyRound, size: 15 }),
|
|
420
|
-
" ",
|
|
421
|
-
t('ta.settings.manageAccounts')))),
|
|
422
|
-
...(workbench_1.WorkbenchUtil.isApp() || handheld
|
|
423
|
-
? []
|
|
424
|
-
: [
|
|
425
|
-
(0, settings_controls_1.row)('relay', [t('ta.settings.relay'), t('ta.settings.relayDescription')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.relay'), description: t('ta.settings.relayDescription') },
|
|
426
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('relay') },
|
|
427
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.Smartphone, size: 15 }),
|
|
428
|
-
" ",
|
|
429
|
-
t('ta.settings.manageAccounts')))),
|
|
430
|
-
]),
|
|
431
|
-
...(handheld
|
|
432
|
-
? []
|
|
433
|
-
: [
|
|
434
|
-
(0, settings_controls_1.row)('signOut', [t('ta.settings.signOut')], React.createElement(settings_controls_1.Row, { label: t('ta.settings.signOut') },
|
|
435
|
-
React.createElement("button", { type: "button", className: "ta-button ta-danger", onClick: () => {
|
|
436
|
-
onClose();
|
|
437
|
-
bench.signOut();
|
|
438
|
-
} },
|
|
439
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.LogOut, size: 15 }),
|
|
440
|
-
" ",
|
|
441
|
-
t('ta.settings.signOut')))),
|
|
442
|
-
]),
|
|
443
|
-
]
|
|
444
|
-
: [],
|
|
445
|
-
},
|
|
446
|
-
];
|
|
447
|
-
return [
|
|
448
|
-
{ id: 'web', title: t('ta.settings.web'), sections: web },
|
|
449
|
-
{ id: 'agent', title: t('ta.settings.agent'), sections: ta, lead },
|
|
450
|
-
{ id: 'more', title: t('ta.settings.more'), sections: more },
|
|
451
|
-
];
|
|
452
|
-
}
|
|
453
50
|
const sectionId = (id) => `ta-settings-${id}`;
|
|
454
51
|
/**
|
|
455
52
|
* The settings, as a page of the main area: those of this page (kept in the browser) and those of ta
|
|
@@ -464,7 +61,7 @@ function SettingsView({ section, onClose, onMenu, onBack }) {
|
|
|
464
61
|
const [scope, setScope] = React.useState('user');
|
|
465
62
|
const [dialog, setDialog] = React.useState();
|
|
466
63
|
const closeDialog = React.useCallback(() => setDialog(undefined), []);
|
|
467
|
-
const parts = useParts(scope, setScope, onClose, setDialog);
|
|
64
|
+
const parts = (0, settings_parts_1.useParts)(scope, setScope, onClose, setDialog);
|
|
468
65
|
React.useEffect(() => {
|
|
469
66
|
const onKey = (event) => { var _a, _b; return event.key === 'Escape' && !((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'input, select, textarea')) && onClose(); };
|
|
470
67
|
window.addEventListener('keydown', onKey);
|
|
@@ -41,7 +41,7 @@ const scanner_1 = require("../device/scanner");
|
|
|
41
41
|
const hooks_1 = require("../hooks");
|
|
42
42
|
const use_t_1 = require("../i18n/use-t");
|
|
43
43
|
const style_1 = require("../style");
|
|
44
|
-
const
|
|
44
|
+
const workbench_util_1 = require("../workbench-util");
|
|
45
45
|
const dino_1 = require("./dino");
|
|
46
46
|
const host_view_1 = require("./host-view");
|
|
47
47
|
const sign_in_accounts_1 = require("./sign-in-accounts");
|
|
@@ -87,7 +87,7 @@ function useDocument() {
|
|
|
87
87
|
*/
|
|
88
88
|
function SignIn({ error }) {
|
|
89
89
|
const t = (0, use_t_1.useT)();
|
|
90
|
-
const app =
|
|
90
|
+
const app = workbench_util_1.WorkbenchUtil.isApp();
|
|
91
91
|
const way = scanner_1.Scanner.available() ? 'scan' : app ? 'pair' : 'serve';
|
|
92
92
|
// The ta serve of this page may take accounts (GitHub, Google, WeChat...); the app has none of its own.
|
|
93
93
|
const { providers, outcome } = (0, sign_in_accounts_1.useSignInWays)(!app);
|
|
@@ -103,7 +103,7 @@ function SignIn({ error }) {
|
|
|
103
103
|
? 'ta.hosts.scanHint'
|
|
104
104
|
: way === 'pair'
|
|
105
105
|
? 'ta.signin.pairHint'
|
|
106
|
-
:
|
|
106
|
+
: workbench_util_1.WorkbenchUtil.elsewhere(undefined)
|
|
107
107
|
? 'ta.signin.hintRemote'
|
|
108
108
|
: 'ta.signin.hint')),
|
|
109
109
|
!accounts && React.createElement(sign_in_picture_1.ConnectPicture, { way: way }),
|
|
@@ -55,6 +55,7 @@ exports.WEB_ICONS = Object.freeze({
|
|
|
55
55
|
LayoutDashboard: lucide_react_1.LayoutDashboard,
|
|
56
56
|
Link: lucide_react_1.Link,
|
|
57
57
|
List: lucide_react_1.List,
|
|
58
|
+
ListChecks: lucide_react_1.ListChecks,
|
|
58
59
|
ListTodo: lucide_react_1.ListTodo,
|
|
59
60
|
ListTree: lucide_react_1.ListTree,
|
|
60
61
|
ListX: lucide_react_1.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[];
|
|
@@ -57,6 +57,7 @@ const model_picker_1 = require("../components/model-picker");
|
|
|
57
57
|
const nav_places_1 = require("../components/nav-places");
|
|
58
58
|
const picture_1 = require("../components/picture");
|
|
59
59
|
const qr_view_1 = require("../components/qr-view");
|
|
60
|
+
const select_bar_1 = require("../components/select-bar");
|
|
60
61
|
const swipe_row_1 = require("../components/swipe-row");
|
|
61
62
|
const ta_avatar_1 = require("../components/ta-avatar");
|
|
62
63
|
const web_composer_1 = require("../components/web-composer");
|
|
@@ -64,6 +65,7 @@ const web_dialog_1 = require("../components/web-dialog");
|
|
|
64
65
|
const device_1 = require("../device/device");
|
|
65
66
|
const scanner_1 = require("../device/scanner");
|
|
66
67
|
const messages_1 = require("../i18n/messages");
|
|
68
|
+
const use_t_1 = require("../i18n/use-t");
|
|
67
69
|
const links_protocol_1 = require("../links/links-protocol");
|
|
68
70
|
const notices_protocol_1 = require("../notices/notices-protocol");
|
|
69
71
|
const settings_protocol_1 = require("../settings/settings-protocol");
|
|
@@ -685,6 +687,7 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
|
|
|
685
687
|
openShared: text => (run.stopped ? Promise.resolve(false) : this.openShared(text)),
|
|
686
688
|
forgetPage: id => !run.stopped && this.forgetPage(id),
|
|
687
689
|
useTasks: () => React.useSyncExternalStore(this.tasks.subscribe, this.tasks.tasks, this.tasks.tasks),
|
|
690
|
+
removeTasks: tasks => (run.stopped ? Promise.resolve(false) : web_tasks_1.WebTaskUtil.remove(tasks, this.notices, (0, use_t_1.translator)(settings.state.language))),
|
|
688
691
|
useView: id => {
|
|
689
692
|
const find = () => this.current.views.find(candidate => candidate.id === id);
|
|
690
693
|
const isShown = () => this.isShown(id);
|
|
@@ -710,6 +713,8 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
|
|
|
710
713
|
Skeleton: list_skeleton_1.ListSkeleton,
|
|
711
714
|
HostTag: host_tag_1.HostTag,
|
|
712
715
|
SwipeRow: swipe_row_1.SwipeRow,
|
|
716
|
+
SelectCheck: select_bar_1.SelectCheck,
|
|
717
|
+
SelectBar: select_bar_1.SelectBar,
|
|
713
718
|
Picture: picture_1.Picture,
|
|
714
719
|
PictureCards: picture_1.PictureCards,
|
|
715
720
|
QrCode: qr_view_1.QrView,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Translate } from '../i18n/use-t';
|
|
2
|
+
import type { TaNotices } from '../notices/notices-protocol';
|
|
3
|
+
import type { WebTask, WebTaskEntry, WebTaskRemoval, WebTaskSource } from './web-extension-api';
|
|
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
|
}
|
|
@@ -35,6 +35,30 @@ var WebTaskUtil;
|
|
|
35
35
|
return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, '0')}m`;
|
|
36
36
|
}
|
|
37
37
|
WebTaskUtil.elapsed = elapsed;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes those that can be (`remove`) once the user agrees: asked once, with the title of one or the count
|
|
40
|
+
* of many, and what deleting them does (their `removeHint`s, each once). Each failure is a notice; the
|
|
41
|
+
* others go on. Whether the user agreed.
|
|
42
|
+
*/
|
|
43
|
+
async function remove(tasks, notices, t) {
|
|
44
|
+
const removable = tasks.filter(task => task.remove);
|
|
45
|
+
if (removable.length === 0) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const hints = [...new Set(removable.map(task => { var _a; return (_a = task.removeHint) === null || _a === void 0 ? void 0 : _a.trim(); }).filter(Boolean))];
|
|
49
|
+
const agreed = await notices.confirm({
|
|
50
|
+
title: removable.length === 1 ? t('ta.task.removeTitle', { title: removable[0].title }) : t('ta.tasks.removeTitle', { count: removable.length }),
|
|
51
|
+
message: hints.join('\n') || undefined,
|
|
52
|
+
confirmLabel: t('ta.task.remove'),
|
|
53
|
+
danger: true,
|
|
54
|
+
});
|
|
55
|
+
if (!agreed) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
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)); }));
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
WebTaskUtil.remove = remove;
|
|
38
62
|
/** The tasks handed out from a conversation (its session file) in a span of time: those a turn of it started. */
|
|
39
63
|
function startedIn(tasks, origin, from, until) {
|
|
40
64
|
if (!origin) {
|