dsh-client-auto-continue 0.13.0 → 0.14.0
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.md +23 -21
- package/README.zh.md +23 -21
- package/docs/screenshots/01-settings-section.png +0 -0
- package/docs/screenshots/01-settings-section.zh.png +0 -0
- package/docs/screenshots/02-settings-card.png +0 -0
- package/docs/screenshots/02-settings-card.zh.png +0 -0
- package/docs/screenshots/07-card-panels.png +0 -0
- package/docs/screenshots/07-card-panels.zh.png +0 -0
- package/docs/screenshots/08-composer-toggle.png +0 -0
- package/docs/screenshots/08-composer-toggle.zh.png +0 -0
- package/docs/screenshots/README.md +26 -27
- package/lib/client.js +363 -1110
- package/lib/client.js.map +3 -3
- package/lib/types/client/locales.d.ts +25 -15
- package/lib/types/client/settings-card.d.ts +12 -7
- package/lib/types/client/settings-form.d.ts +2 -2
- package/lib/types/client/settings-notifications.d.ts +8 -0
- package/package.json +2 -2
- package/src/client/index.ts +1 -1
- package/src/client/locales.ts +62 -42
- package/src/client/settings-card.tsx +124 -645
- package/src/client/settings-form.ts +15 -9
- package/src/client/settings-notifications.ts +42 -0
- package/src/client/styles.ts +110 -382
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* configuration section; styles live in `styles.ts` and use the DSH design
|
|
8
8
|
* tokens so the card follows the active theme.
|
|
9
9
|
*/
|
|
10
|
-
import { useEffect,
|
|
10
|
+
import { useEffect, useId, useState } from 'react';
|
|
11
11
|
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
12
12
|
import { DEFAULT_CONFIG, type AutoContinueSettings } from './engine.ts';
|
|
13
13
|
import type { ComposerToggleFace, ComposerToggleState } from './composer-toggle.tsx';
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type CardShell,
|
|
32
32
|
} from './settings-form.ts';
|
|
33
33
|
import { injectStyles } from './styles.ts';
|
|
34
|
+
import { prepareSettingsNotification, showSettingsNotification } from './settings-notifications.ts';
|
|
34
35
|
|
|
35
36
|
// Styles must land during factory materialization so the module system's
|
|
36
37
|
// style bookkeeping (HMR) owns them.
|
|
@@ -38,6 +39,10 @@ injectStyles();
|
|
|
38
39
|
|
|
39
40
|
/** What the auto-continue card renders. */
|
|
40
41
|
export interface AutoContinueSettingsCardState extends CardShell {
|
|
42
|
+
/** Committed global state; a staged edit does not pause the engine yet. */
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
/** Feedback for the last local save, including browser permission problems. */
|
|
45
|
+
notificationFeedback: SettingsCardKey | undefined;
|
|
41
46
|
paused: CardFieldState;
|
|
42
47
|
showComposerToggle: CardFieldState;
|
|
43
48
|
continueText: CardFieldState;
|
|
@@ -86,11 +91,16 @@ export class AutoContinueSettingsCardController {
|
|
|
86
91
|
private composerSaving = false;
|
|
87
92
|
private composerFailed = false;
|
|
88
93
|
private disposed = false;
|
|
94
|
+
private saveSequence = 0;
|
|
95
|
+
private notificationFeedback: SettingsCardKey | undefined;
|
|
89
96
|
|
|
90
97
|
/**
|
|
91
98
|
* @param scope - the bound settings scope for the `auto-continue` namespace.
|
|
92
99
|
*/
|
|
93
|
-
constructor(
|
|
100
|
+
constructor(
|
|
101
|
+
private readonly scope: SettingsScope<AutoContinueSettings>,
|
|
102
|
+
private readonly getLocale: () => string,
|
|
103
|
+
) {
|
|
94
104
|
this.form = new CardForm(scope, [
|
|
95
105
|
booleanField('paused'),
|
|
96
106
|
booleanField('showComposerToggle'),
|
|
@@ -130,6 +140,8 @@ export class AutoContinueSettingsCardController {
|
|
|
130
140
|
private projection(): AutoContinueSettingsCardState {
|
|
131
141
|
return {
|
|
132
142
|
...this.form.shell(),
|
|
143
|
+
enabled: !(this.scope.getSnapshot().value?.paused ?? DEFAULT_CONFIG.paused),
|
|
144
|
+
notificationFeedback: this.notificationFeedback,
|
|
133
145
|
paused: this.form.field('paused'),
|
|
134
146
|
showComposerToggle: this.form.field('showComposerToggle'),
|
|
135
147
|
continueText: this.form.field('continueText'),
|
|
@@ -168,7 +180,27 @@ export class AutoContinueSettingsCardController {
|
|
|
168
180
|
* @returns the card's snapshot and its form actions.
|
|
169
181
|
*/
|
|
170
182
|
inject(): AutoContinueSettingsCardFace {
|
|
171
|
-
return { hooks: { autoContinueSettingsCard: this.store }, ...this.form.actions() };
|
|
183
|
+
return { hooks: { autoContinueSettingsCard: this.store }, ...this.form.actions(), save: () => void this.save() };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private async save(): Promise<void> {
|
|
187
|
+
const state = this.form.shell();
|
|
188
|
+
const snapshot = this.scope.getSnapshot();
|
|
189
|
+
if (this.disposed || !state.available || !state.writable || !state.dirty || state.invalid || state.saving || snapshot.mode !== 'host') return;
|
|
190
|
+
const sequence = ++this.saveSequence;
|
|
191
|
+
const before = snapshot.value?.notify ?? DEFAULT_CONFIG.notify;
|
|
192
|
+
const target = this.form.field('notify').text;
|
|
193
|
+
// Start the permission prompt in the click handler, but save independently.
|
|
194
|
+
const permission = prepareSettingsNotification(target === '' ? DEFAULT_CONFIG.notify : target === 'true');
|
|
195
|
+
this.notificationFeedback = undefined;
|
|
196
|
+
if (!await this.form.save() || this.disposed) return;
|
|
197
|
+
const after = this.scope.getSnapshot().value?.notify ?? DEFAULT_CONFIG.notify;
|
|
198
|
+
if (!before && !after) return;
|
|
199
|
+
const result = await permission;
|
|
200
|
+
// A later save or a provider teardown makes this pending confirmation stale.
|
|
201
|
+
if (this.disposed || sequence !== this.saveSequence || (this.scope.getSnapshot().value?.notify ?? DEFAULT_CONFIG.notify) !== after) return;
|
|
202
|
+
this.notificationFeedback = showSettingsNotification(before === after ? 'saved' : after ? 'enabled' : 'disabled', this.getLocale(), result);
|
|
203
|
+
this.store.set(this.projection());
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
injectComposer(): ComposerToggleFace {
|
|
@@ -223,288 +255,63 @@ export function AutoContinueSettingsPage(props: AutoContinueSettingsCardProps) {
|
|
|
223
255
|
}
|
|
224
256
|
|
|
225
257
|
const REPOSITORY_URL = 'https://github.com/HsiangNianian/dsh-auto-continue';
|
|
226
|
-
const REPOSITORY_SLUG = 'HsiangNianian/dsh-auto-continue';
|
|
227
258
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
<path d="m3.5 6 4.5 4 4.5-4" />
|
|
244
|
-
</svg>
|
|
245
|
-
);
|
|
246
|
-
}
|
|
259
|
+
type FieldName = Exclude<keyof AutoContinueSettingsCardState, keyof CardShell | 'enabled' | 'notificationFeedback'>;
|
|
260
|
+
const groups = [
|
|
261
|
+
{ id: 'general', fields: ['paused', 'showComposerToggle', 'resumeSilentTurns', 'resumeCompletedTurns', 'notify'] },
|
|
262
|
+
{ id: 'recovery', fields: ['graceMs', 'cooldownMs', 'maxConsecutive', 'classify', 'retryableErrorPatterns', 'backoffFactor', 'backoffMaxMs'] },
|
|
263
|
+
{ id: 'startup', fields: ['scanOnBoot', 'scanLimit', 'freshMs'] },
|
|
264
|
+
{ id: 'prompts', fields: ['continueText', 'continueTextMaxTokens', 'continueTextSilent', 'continueTextLoop', 'guardPendingText', 'guardDoneText', 'loopText'] },
|
|
265
|
+
{ id: 'safety', fields: ['guardTools', 'loopGuard', 'loopShortChars', 'loopWindowMs', 'loopShortCount', 'loopRepeatText', 'loopToolRepeat'] },
|
|
266
|
+
{ id: 'status', fields: ['verbose'] },
|
|
267
|
+
] as const satisfies ReadonlyArray<{ id: string; fields: readonly FieldName[] }>;
|
|
268
|
+
type Category = typeof groups[number]['id'];
|
|
269
|
+
const textDefaults: Partial<Record<FieldName, SettingsCardKey>> = {
|
|
270
|
+
continueText: 'default.continueText', continueTextMaxTokens: 'default.continueTextMaxTokens',
|
|
271
|
+
continueTextSilent: 'default.continueTextSilent', continueTextLoop: 'default.continueTextLoop',
|
|
272
|
+
guardPendingText: 'default.guardPendingText', guardDoneText: 'default.guardDoneText', loopText: 'default.loopText',
|
|
273
|
+
};
|
|
247
274
|
|
|
248
275
|
function GitHubMark() {
|
|
249
|
-
return
|
|
250
|
-
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
251
|
-
<path d="M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" />
|
|
252
|
-
</svg>
|
|
253
|
-
);
|
|
276
|
+
return <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" /></svg>;
|
|
254
277
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
<
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
function RelayJourney(props: { t: (key: SettingsCardKey) => string }) {
|
|
266
|
-
return (
|
|
267
|
-
<span className="dshAcJourney">
|
|
268
|
-
<span className="dshAcJourneyStep dshAcJourneyInterrupted">
|
|
269
|
-
<span className="dshAcJourneyDot" aria-hidden="true" />
|
|
270
|
-
{props.t('flow.interrupted')}
|
|
271
|
-
</span>
|
|
272
|
-
<span className="dshAcJourneyLine" aria-hidden="true" />
|
|
273
|
-
<span className="dshAcJourneyStep dshAcJourneyGrace">
|
|
274
|
-
<span className="dshAcJourneyDot" aria-hidden="true" />
|
|
275
|
-
{props.t('flow.grace')}
|
|
276
|
-
</span>
|
|
277
|
-
<span className="dshAcJourneyLine" aria-hidden="true" />
|
|
278
|
-
<span className="dshAcJourneyStep dshAcJourneyContinue">
|
|
279
|
-
<span className="dshAcJourneyDot" aria-hidden="true" />
|
|
280
|
-
{props.t('flow.continue')}
|
|
281
|
-
</span>
|
|
282
|
-
</span>
|
|
283
|
-
);
|
|
278
|
+
function RepositoryInvite({ t }: { t: (key: SettingsCardKey) => string }) {
|
|
279
|
+
return <aside className="dshAcRepository">
|
|
280
|
+
<span className="dshAcStar" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.78 5.63L21 9.53l-4.5 4.39 1.06 6.2L12 17.2l-5.56 2.92 1.06-6.2L3 9.53l6.22-.9L12 3Z" /></svg></span>
|
|
281
|
+
<span className="dshAcRepositoryCopy"><strong>{t('repo.star')}</strong><span>{t('repo.note')}</span></span>
|
|
282
|
+
<a className="dshAcGithub" href={REPOSITORY_URL} target="_blank" rel="noopener noreferrer" aria-label={t('repo.aria')}>
|
|
283
|
+
<GitHubMark /><span className="dshAcGithubLong">{t('repo.link')}</span><span className="dshAcGithubShort">GitHub</span>
|
|
284
|
+
<svg className="dshAcExternal" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3h7v7M13 3 7 9M11 9v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3" /></svg>
|
|
285
|
+
</a>
|
|
286
|
+
</aside>;
|
|
284
287
|
}
|
|
285
288
|
|
|
286
|
-
/**
|
|
287
|
-
function
|
|
289
|
+
/** Controls edit the existing staged form; navigation never owns or discards drafts. */
|
|
290
|
+
function SettingField({ name, id, state, actions, disabled, t }: {
|
|
291
|
+
name: FieldName; id: string; state: CardFieldState; actions: CardActions; disabled: boolean;
|
|
288
292
|
t: (key: SettingsCardKey) => string;
|
|
289
|
-
titleKey: SettingsCardKey;
|
|
290
|
-
descriptionKey: SettingsCardKey;
|
|
291
|
-
state: CardShell;
|
|
292
|
-
onSave: () => void;
|
|
293
|
-
onDiscard: () => void;
|
|
294
|
-
children: ReactNode;
|
|
295
293
|
}) {
|
|
296
|
-
const [
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
aria-label={`${props.t(open ? 'chrome.collapse' : 'chrome.expand')}: ${title}`}
|
|
309
|
-
title={props.t(props.descriptionKey)}
|
|
310
|
-
onClick={() => setOpen(!open)}
|
|
311
|
-
>
|
|
312
|
-
<span className="dshAcRelayMark"><RelayMark /></span>
|
|
313
|
-
<span className="dshAcHeadText">
|
|
314
|
-
<span className="dshAcName">{title}</span>
|
|
315
|
-
<span className="dshAcDescription">{props.t(props.descriptionKey)}</span>
|
|
316
|
-
<RelayJourney t={props.t} />
|
|
317
|
-
</span>
|
|
318
|
-
{state.dirty ? (
|
|
319
|
-
<span className="dshAcPending" title={props.t('chrome.unsaved')}>
|
|
320
|
-
{props.t('chrome.unsaved')}
|
|
321
|
-
</span>
|
|
322
|
-
) : null}
|
|
323
|
-
<span className={open ? 'dshAcChevron dshAcChevronOpen' : 'dshAcChevron'}>
|
|
324
|
-
<ChevronMark />
|
|
325
|
-
</span>
|
|
326
|
-
</button>
|
|
327
|
-
<a
|
|
328
|
-
className="dshAcGithub"
|
|
329
|
-
href={REPOSITORY_URL}
|
|
330
|
-
target="_blank"
|
|
331
|
-
rel="noreferrer"
|
|
332
|
-
aria-label={props.t('repo.aria')}
|
|
333
|
-
>
|
|
334
|
-
<span className="dshAcGithubIcon"><GitHubMark /></span>
|
|
335
|
-
<span className="dshAcGithubText">
|
|
336
|
-
<span className="dshAcGithubAction">{props.t('repo.star')}</span>
|
|
337
|
-
<span className="dshAcGithubSlug">{REPOSITORY_SLUG}</span>
|
|
338
|
-
</span>
|
|
339
|
-
<span className="dshAcExternal"><ExternalMark /></span>
|
|
340
|
-
</a>
|
|
341
|
-
</div>
|
|
342
|
-
{open ? (
|
|
343
|
-
<div className="dshAcBody">
|
|
344
|
-
{!state.writable ? (
|
|
345
|
-
<p className="dshAcReadOnly" role="status">{props.t('chrome.readOnly')}</p>
|
|
346
|
-
) : null}
|
|
347
|
-
{props.children}
|
|
348
|
-
<div className="dshAcFooter">
|
|
349
|
-
{state.failed ? (
|
|
350
|
-
<p className="dshAcFailed" role="status">{props.t('chrome.saveFailed')}</p>
|
|
351
|
-
) : null}
|
|
352
|
-
<button
|
|
353
|
-
type="button"
|
|
354
|
-
className="dshAcDiscard"
|
|
355
|
-
disabled={!state.dirty || state.saving}
|
|
356
|
-
onClick={props.onDiscard}
|
|
357
|
-
>
|
|
358
|
-
{props.t('chrome.discard')}
|
|
359
|
-
</button>
|
|
360
|
-
<button type="button" className="dshAcSave" disabled={blocked} onClick={props.onSave}>
|
|
361
|
-
{props.t(!state.saving ? 'chrome.save' : 'chrome.saving')}
|
|
362
|
-
</button>
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
) : null}
|
|
366
|
-
</li>
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/** Props every field control needs regardless of its value type. */
|
|
371
|
-
interface FieldProps {
|
|
372
|
-
id: string;
|
|
373
|
-
label: string;
|
|
374
|
-
hint: string;
|
|
375
|
-
wide?: boolean;
|
|
376
|
-
text: string;
|
|
377
|
-
overridden: boolean;
|
|
378
|
-
invalid: boolean;
|
|
379
|
-
disabled: boolean;
|
|
380
|
-
t: (key: SettingsCardKey) => string;
|
|
381
|
-
onEdit: (text: string) => void;
|
|
382
|
-
onReset: () => void;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/** A staged value field; `numeric` only hints the keypad, which drafts a field accepts is decided by its spec. */
|
|
386
|
-
function ValueField(props: FieldProps & { numeric?: boolean; multiline?: boolean; placeholder?: string }) {
|
|
387
|
-
const className = props.invalid ? 'dshAcInput dshAcInputInvalid' : 'dshAcInput';
|
|
388
|
-
return (
|
|
389
|
-
<div className={props.wide === true ? 'dshAcField dshAcFieldWide' : 'dshAcField'}>
|
|
390
|
-
<div className="dshAcHead">
|
|
391
|
-
<label className="dshAcLabel" htmlFor={props.id}>{props.label}</label>
|
|
392
|
-
{props.overridden ? (
|
|
393
|
-
<span className="dshAcBadges">
|
|
394
|
-
<span className="dshAcBadge">{props.t('chrome.overridden')}</span>
|
|
395
|
-
<button type="button" className="dshAcReset" disabled={props.disabled} onClick={props.onReset}>
|
|
396
|
-
{props.t('chrome.reset')}
|
|
397
|
-
</button>
|
|
398
|
-
</span>
|
|
399
|
-
) : null}
|
|
400
|
-
</div>
|
|
401
|
-
{props.multiline === true ? (
|
|
402
|
-
<textarea
|
|
403
|
-
id={props.id}
|
|
404
|
-
className={`${className} dshAcTextArea`}
|
|
405
|
-
aria-invalid={props.invalid || undefined}
|
|
406
|
-
value={props.text}
|
|
407
|
-
placeholder={props.placeholder ?? ''}
|
|
408
|
-
disabled={props.disabled}
|
|
409
|
-
rows={4}
|
|
410
|
-
onChange={(event) => props.onEdit(event.target.value)}
|
|
411
|
-
/>
|
|
412
|
-
) : (
|
|
413
|
-
<input
|
|
414
|
-
id={props.id}
|
|
415
|
-
className={className}
|
|
416
|
-
type="text"
|
|
417
|
-
inputMode={props.numeric === true ? 'numeric' : undefined}
|
|
418
|
-
aria-invalid={props.invalid || undefined}
|
|
419
|
-
value={props.text}
|
|
420
|
-
placeholder={props.placeholder ?? ''}
|
|
421
|
-
disabled={props.disabled}
|
|
422
|
-
onChange={(event) => props.onEdit(event.target.value)}
|
|
423
|
-
/>
|
|
424
|
-
)}
|
|
425
|
-
<p className={props.invalid ? 'dshAcInvalid' : 'dshAcHint'}>
|
|
426
|
-
{props.invalid ? props.t('chrome.invalidNumber') : props.hint}
|
|
427
|
-
</p>
|
|
428
|
-
</div>
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/** A staged boolean field: inherit / on / off. */
|
|
433
|
-
function BooleanField(props: FieldProps) {
|
|
434
|
-
return (
|
|
435
|
-
<div className={props.wide === true ? 'dshAcField dshAcFieldWide' : 'dshAcField'}>
|
|
436
|
-
<div className="dshAcHead">
|
|
437
|
-
<label className="dshAcLabel" htmlFor={props.id}>{props.label}</label>
|
|
438
|
-
{props.overridden ? (
|
|
439
|
-
<span className="dshAcBadges">
|
|
440
|
-
<span className="dshAcBadge">{props.t('chrome.overridden')}</span>
|
|
441
|
-
<button type="button" className="dshAcReset" disabled={props.disabled} onClick={props.onReset}>
|
|
442
|
-
{props.t('chrome.reset')}
|
|
443
|
-
</button>
|
|
444
|
-
</span>
|
|
445
|
-
) : null}
|
|
446
|
-
</div>
|
|
447
|
-
<select
|
|
448
|
-
id={props.id}
|
|
449
|
-
className="dshAcSelect"
|
|
450
|
-
value={props.text}
|
|
451
|
-
disabled={props.disabled}
|
|
452
|
-
onChange={(event) => props.onEdit(event.target.value)}
|
|
453
|
-
>
|
|
454
|
-
<option value="">{props.t('chrome.inherit')}</option>
|
|
455
|
-
<option value="true">{props.t('chrome.on')}</option>
|
|
456
|
-
<option value="false">{props.t('chrome.off')}</option>
|
|
457
|
-
</select>
|
|
458
|
-
<p className="dshAcHint">{props.hint}</p>
|
|
294
|
+
const boolean = typeof DEFAULT_CONFIG[name] === 'boolean';
|
|
295
|
+
const numeric = typeof DEFAULT_CONFIG[name] === 'number';
|
|
296
|
+
const label = t(`field.${name}` as SettingsCardKey);
|
|
297
|
+
const hint = t(`field.${name}Hint` as SettingsCardKey);
|
|
298
|
+
const value = state.text === '' ? DEFAULT_CONFIG[name] : state.text === 'true';
|
|
299
|
+
const placeholderKey = textDefaults[name];
|
|
300
|
+
const placeholder = placeholderKey ? t(placeholderKey) : name === 'retryableErrorPatterns' ? t('field.retryableErrorPatternsPlaceholder') : String(DEFAULT_CONFIG[name]);
|
|
301
|
+
const common = { id, disabled, 'aria-describedby': `${id}-hint`, 'aria-invalid': state.invalid || undefined, value: state.text, onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => actions.edit(name, event.target.value) };
|
|
302
|
+
return <div className={`dshAcField${!boolean && !numeric ? ' dshAcFieldText' : ''}`} data-field={name}>
|
|
303
|
+
<div className="dshAcFieldCopy">
|
|
304
|
+
{boolean ? <span className="dshAcLabel">{label}</span> : <label className="dshAcLabel" htmlFor={id}>{label}</label>}
|
|
305
|
+
<p className={state.invalid ? 'dshAcInvalid' : 'dshAcHint'} id={`${id}-hint`}>{state.invalid ? t('chrome.invalidNumber') : hint}</p>
|
|
459
306
|
</div>
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
<div className="dshAcField dshAcFieldWide">
|
|
467
|
-
<div className="dshAcHead">
|
|
468
|
-
<span className="dshAcLabel">{props.label}</span>
|
|
469
|
-
<span className="dshAcBadges">
|
|
470
|
-
{props.overridden ? <>
|
|
471
|
-
<span className="dshAcBadge">{props.t('chrome.overridden')}</span>
|
|
472
|
-
<button type="button" className="dshAcReset" disabled={props.disabled}
|
|
473
|
-
onClick={props.onReset}>{props.t('chrome.reset')}</button>
|
|
474
|
-
</> : null}
|
|
475
|
-
<span className="dshAcSwitchTarget">
|
|
476
|
-
<NativeSwitch checked={props.text === '' ? DEFAULT_CONFIG.showComposerToggle : props.text === 'true'}
|
|
477
|
-
onChange={(checked) => props.onEdit(String(checked))} label={props.label} disabled={props.disabled} />
|
|
478
|
-
</span>
|
|
479
|
-
</span>
|
|
480
|
-
</div>
|
|
481
|
-
<p className="dshAcHint">{props.hint}</p>
|
|
307
|
+
<div className="dshAcFieldControl">
|
|
308
|
+
{state.overridden && <button type="button" className="dshAcReset" disabled={disabled} aria-label={`${t('chrome.reset')}: ${label}`} onClick={() => actions.resetField(name)}>{t('chrome.reset')}</button>}
|
|
309
|
+
{boolean ? <span className="dshAcSwitchTarget"><NativeSwitch label={label} title={hint} disabled={disabled}
|
|
310
|
+
checked={name === 'paused' ? !value : Boolean(value)} onChange={checked => actions.edit(name, String(name === 'paused' ? !checked : checked))} /></span>
|
|
311
|
+
: numeric ? <input {...common} className="dshAcInput dshAcNumber" type="text" inputMode="numeric" placeholder={placeholder} />
|
|
312
|
+
: <textarea {...common} className="dshAcInput dshAcTextArea" rows={name === 'retryableErrorPatterns' ? 3 : 2} placeholder={placeholder} />}
|
|
482
313
|
</div>
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
type SettingsSectionTone = 'handoff' | 'autoloop' | 'safety' | 'recovery' | 'loop' | 'live';
|
|
487
|
-
|
|
488
|
-
/** A real behavior group, not a decorative divider: each section maps to one phase of the relay. */
|
|
489
|
-
function SettingsSection(props: {
|
|
490
|
-
t: (key: SettingsCardKey) => string;
|
|
491
|
-
titleKey: SettingsCardKey;
|
|
492
|
-
descriptionKey: SettingsCardKey;
|
|
493
|
-
tone: SettingsSectionTone;
|
|
494
|
-
children: ReactNode;
|
|
495
|
-
}) {
|
|
496
|
-
return (
|
|
497
|
-
<section className={`dshAcFormSection dshAcFormSection-${props.tone}`}>
|
|
498
|
-
<header className="dshAcSectionHead">
|
|
499
|
-
<span className="dshAcSectionSignal" aria-hidden="true" />
|
|
500
|
-
<span className="dshAcSectionCopy">
|
|
501
|
-
<span className="dshAcSectionTitle">{props.t(props.titleKey)}</span>
|
|
502
|
-
<span className="dshAcSectionDescription">{props.t(props.descriptionKey)}</span>
|
|
503
|
-
</span>
|
|
504
|
-
</header>
|
|
505
|
-
<div className="dshAcSectionGrid">{props.children}</div>
|
|
506
|
-
</section>
|
|
507
|
-
);
|
|
314
|
+
</div>;
|
|
508
315
|
}
|
|
509
316
|
|
|
510
317
|
/** 实时面板: 今日统计 + 已暂停会话。浏览器本地状态, 每 5 秒刷新一次。 */
|
|
@@ -614,377 +421,49 @@ function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
|
|
|
614
421
|
);
|
|
615
422
|
}
|
|
616
423
|
|
|
617
|
-
/**
|
|
618
|
-
* Render the auto-continue card.
|
|
619
|
-
* @param props - locale copy, the card snapshot, and its form actions.
|
|
620
|
-
* @returns the card.
|
|
621
|
-
*/
|
|
424
|
+
/** Native category layout, with the selected B3 repository invitation beside the introduction. */
|
|
622
425
|
export function AutoContinueSettingsCard(props: AutoContinueSettingsCardProps) {
|
|
623
426
|
const { t } = props;
|
|
624
|
-
const state = props.useAutoContinueSettingsCard(
|
|
625
|
-
const
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
>
|
|
636
|
-
<div className="
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
id="auto-continue-show-composer-toggle"
|
|
655
|
-
label={t('field.showComposerToggle')}
|
|
656
|
-
hint={t('field.showComposerToggleHint')}
|
|
657
|
-
{...shared}
|
|
658
|
-
{...state.showComposerToggle}
|
|
659
|
-
onEdit={(text) => props.edit('showComposerToggle', text)}
|
|
660
|
-
onReset={() => props.resetField('showComposerToggle')}
|
|
661
|
-
/>
|
|
662
|
-
<ValueField
|
|
663
|
-
id="auto-continue-continue-text"
|
|
664
|
-
label={t('field.continueText')}
|
|
665
|
-
hint={t('field.continueTextHint')}
|
|
666
|
-
{...shared}
|
|
667
|
-
{...state.continueText}
|
|
668
|
-
onEdit={(text) => props.edit('continueText', text)}
|
|
669
|
-
placeholder={t('default.continueText')}
|
|
670
|
-
onReset={() => props.resetField('continueText')}
|
|
671
|
-
/>
|
|
672
|
-
<ValueField
|
|
673
|
-
id="auto-continue-continue-text-max-tokens"
|
|
674
|
-
label={t('field.continueTextMaxTokens')}
|
|
675
|
-
hint={t('field.continueTextMaxTokensHint')}
|
|
676
|
-
{...shared}
|
|
677
|
-
{...state.continueTextMaxTokens}
|
|
678
|
-
onEdit={(text) => props.edit('continueTextMaxTokens', text)}
|
|
679
|
-
placeholder={t('default.continueTextMaxTokens')}
|
|
680
|
-
onReset={() => props.resetField('continueTextMaxTokens')}
|
|
681
|
-
/>
|
|
682
|
-
<BooleanField
|
|
683
|
-
wide
|
|
684
|
-
id="auto-continue-resume-silent-turns"
|
|
685
|
-
label={t('field.resumeSilentTurns')}
|
|
686
|
-
hint={t('field.resumeSilentTurnsHint')}
|
|
687
|
-
{...shared}
|
|
688
|
-
{...state.resumeSilentTurns}
|
|
689
|
-
onEdit={(text) => props.edit('resumeSilentTurns', text)}
|
|
690
|
-
onReset={() => props.resetField('resumeSilentTurns')}
|
|
691
|
-
/>
|
|
692
|
-
<ValueField
|
|
693
|
-
wide
|
|
694
|
-
id="auto-continue-continue-text-silent"
|
|
695
|
-
label={t('field.continueTextSilent')}
|
|
696
|
-
hint={t('field.continueTextSilentHint')}
|
|
697
|
-
{...shared}
|
|
698
|
-
{...state.continueTextSilent}
|
|
699
|
-
onEdit={(text) => props.edit('continueTextSilent', text)}
|
|
700
|
-
placeholder={t('default.continueTextSilent')}
|
|
701
|
-
onReset={() => props.resetField('continueTextSilent')}
|
|
702
|
-
/>
|
|
703
|
-
</SettingsSection>
|
|
704
|
-
|
|
705
|
-
<SettingsSection
|
|
706
|
-
t={t}
|
|
707
|
-
titleKey="section.autoloop.title"
|
|
708
|
-
descriptionKey="section.autoloop.description"
|
|
709
|
-
tone="autoloop"
|
|
710
|
-
>
|
|
711
|
-
<BooleanField
|
|
712
|
-
wide
|
|
713
|
-
id="auto-continue-resume-completed-turns"
|
|
714
|
-
label={t('field.resumeCompletedTurns')}
|
|
715
|
-
hint={t('field.resumeCompletedTurnsHint')}
|
|
716
|
-
{...shared}
|
|
717
|
-
{...state.resumeCompletedTurns}
|
|
718
|
-
onEdit={(text) => props.edit('resumeCompletedTurns', text)}
|
|
719
|
-
onReset={() => props.resetField('resumeCompletedTurns')}
|
|
720
|
-
/>
|
|
721
|
-
<ValueField
|
|
722
|
-
wide
|
|
723
|
-
id="auto-continue-continue-text-loop"
|
|
724
|
-
label={t('field.continueTextLoop')}
|
|
725
|
-
hint={t('field.continueTextLoopHint')}
|
|
726
|
-
{...shared}
|
|
727
|
-
{...state.continueTextLoop}
|
|
728
|
-
onEdit={(text) => props.edit('continueTextLoop', text)}
|
|
729
|
-
placeholder={t('default.continueTextLoop')}
|
|
730
|
-
onReset={() => props.resetField('continueTextLoop')}
|
|
731
|
-
/>
|
|
732
|
-
</SettingsSection>
|
|
733
|
-
|
|
734
|
-
<SettingsSection
|
|
735
|
-
t={t}
|
|
736
|
-
titleKey="section.safety.title"
|
|
737
|
-
descriptionKey="section.safety.description"
|
|
738
|
-
tone="safety"
|
|
739
|
-
>
|
|
740
|
-
<BooleanField
|
|
741
|
-
wide
|
|
742
|
-
id="auto-continue-guard-tools"
|
|
743
|
-
label={t('field.guardTools')}
|
|
744
|
-
hint={t('field.guardToolsHint')}
|
|
745
|
-
{...shared}
|
|
746
|
-
{...state.guardTools}
|
|
747
|
-
onEdit={(text) => props.edit('guardTools', text)}
|
|
748
|
-
onReset={() => props.resetField('guardTools')}
|
|
749
|
-
/>
|
|
750
|
-
<ValueField
|
|
751
|
-
wide
|
|
752
|
-
id="auto-continue-guard-pending-text"
|
|
753
|
-
label={t('field.guardPendingText')}
|
|
754
|
-
hint={t('field.guardPendingTextHint')}
|
|
755
|
-
{...shared}
|
|
756
|
-
{...state.guardPendingText}
|
|
757
|
-
onEdit={(text) => props.edit('guardPendingText', text)}
|
|
758
|
-
placeholder={t('default.guardPendingText')}
|
|
759
|
-
onReset={() => props.resetField('guardPendingText')}
|
|
760
|
-
/>
|
|
761
|
-
<ValueField
|
|
762
|
-
wide
|
|
763
|
-
id="auto-continue-guard-done-text"
|
|
764
|
-
label={t('field.guardDoneText')}
|
|
765
|
-
hint={t('field.guardDoneTextHint')}
|
|
766
|
-
{...shared}
|
|
767
|
-
{...state.guardDoneText}
|
|
768
|
-
onEdit={(text) => props.edit('guardDoneText', text)}
|
|
769
|
-
placeholder={t('default.guardDoneText')}
|
|
770
|
-
onReset={() => props.resetField('guardDoneText')}
|
|
771
|
-
/>
|
|
772
|
-
<ValueField
|
|
773
|
-
id="auto-continue-grace-ms"
|
|
774
|
-
label={t('field.graceMs')}
|
|
775
|
-
hint={t('field.graceMsHint')}
|
|
776
|
-
numeric
|
|
777
|
-
{...shared}
|
|
778
|
-
{...state.graceMs}
|
|
779
|
-
onEdit={(text) => props.edit('graceMs', text)}
|
|
780
|
-
onReset={() => props.resetField('graceMs')}
|
|
781
|
-
/>
|
|
782
|
-
<ValueField
|
|
783
|
-
id="auto-continue-cooldown-ms"
|
|
784
|
-
label={t('field.cooldownMs')}
|
|
785
|
-
hint={t('field.cooldownMsHint')}
|
|
786
|
-
numeric
|
|
787
|
-
{...shared}
|
|
788
|
-
{...state.cooldownMs}
|
|
789
|
-
onEdit={(text) => props.edit('cooldownMs', text)}
|
|
790
|
-
onReset={() => props.resetField('cooldownMs')}
|
|
791
|
-
/>
|
|
792
|
-
<ValueField
|
|
793
|
-
id="auto-continue-max-consecutive"
|
|
794
|
-
label={t('field.maxConsecutive')}
|
|
795
|
-
hint={t('field.maxConsecutiveHint')}
|
|
796
|
-
numeric
|
|
797
|
-
{...shared}
|
|
798
|
-
{...state.maxConsecutive}
|
|
799
|
-
onEdit={(text) => props.edit('maxConsecutive', text)}
|
|
800
|
-
onReset={() => props.resetField('maxConsecutive')}
|
|
801
|
-
/>
|
|
802
|
-
</SettingsSection>
|
|
803
|
-
|
|
804
|
-
<SettingsSection
|
|
805
|
-
t={t}
|
|
806
|
-
titleKey="section.recovery.title"
|
|
807
|
-
descriptionKey="section.recovery.description"
|
|
808
|
-
tone="recovery"
|
|
809
|
-
>
|
|
810
|
-
<BooleanField
|
|
811
|
-
id="auto-continue-scan-on-boot"
|
|
812
|
-
label={t('field.scanOnBoot')}
|
|
813
|
-
hint={t('field.scanOnBootHint')}
|
|
814
|
-
{...shared}
|
|
815
|
-
{...state.scanOnBoot}
|
|
816
|
-
onEdit={(text) => props.edit('scanOnBoot', text)}
|
|
817
|
-
onReset={() => props.resetField('scanOnBoot')}
|
|
818
|
-
/>
|
|
819
|
-
<BooleanField
|
|
820
|
-
id="auto-continue-classify"
|
|
821
|
-
label={t('field.classify')}
|
|
822
|
-
hint={t('field.classifyHint')}
|
|
823
|
-
{...shared}
|
|
824
|
-
{...state.classify}
|
|
825
|
-
onEdit={(text) => props.edit('classify', text)}
|
|
826
|
-
onReset={() => props.resetField('classify')}
|
|
827
|
-
/>
|
|
828
|
-
<ValueField
|
|
829
|
-
id="auto-continue-scan-limit"
|
|
830
|
-
label={t('field.scanLimit')}
|
|
831
|
-
hint={t('field.scanLimitHint')}
|
|
832
|
-
numeric
|
|
833
|
-
{...shared}
|
|
834
|
-
{...state.scanLimit}
|
|
835
|
-
onEdit={(text) => props.edit('scanLimit', text)}
|
|
836
|
-
onReset={() => props.resetField('scanLimit')}
|
|
837
|
-
/>
|
|
838
|
-
<ValueField
|
|
839
|
-
id="auto-continue-fresh-ms"
|
|
840
|
-
label={t('field.freshMs')}
|
|
841
|
-
hint={t('field.freshMsHint')}
|
|
842
|
-
numeric
|
|
843
|
-
{...shared}
|
|
844
|
-
{...state.freshMs}
|
|
845
|
-
onEdit={(text) => props.edit('freshMs', text)}
|
|
846
|
-
onReset={() => props.resetField('freshMs')}
|
|
847
|
-
/>
|
|
848
|
-
<ValueField
|
|
849
|
-
wide
|
|
850
|
-
id="auto-continue-retryable-error-patterns"
|
|
851
|
-
label={t('field.retryableErrorPatterns')}
|
|
852
|
-
hint={t('field.retryableErrorPatternsHint')}
|
|
853
|
-
multiline
|
|
854
|
-
{...shared}
|
|
855
|
-
{...state.retryableErrorPatterns}
|
|
856
|
-
onEdit={(text) => props.edit('retryableErrorPatterns', text)}
|
|
857
|
-
placeholder={t('field.retryableErrorPatternsPlaceholder')}
|
|
858
|
-
onReset={() => props.resetField('retryableErrorPatterns')}
|
|
859
|
-
/>
|
|
860
|
-
<ValueField
|
|
861
|
-
id="auto-continue-backoff-factor"
|
|
862
|
-
label={t('field.backoffFactor')}
|
|
863
|
-
hint={t('field.backoffFactorHint')}
|
|
864
|
-
numeric
|
|
865
|
-
{...shared}
|
|
866
|
-
{...state.backoffFactor}
|
|
867
|
-
onEdit={(text) => props.edit('backoffFactor', text)}
|
|
868
|
-
onReset={() => props.resetField('backoffFactor')}
|
|
869
|
-
/>
|
|
870
|
-
<ValueField
|
|
871
|
-
id="auto-continue-backoff-max"
|
|
872
|
-
label={t('field.backoffMaxMs')}
|
|
873
|
-
hint={t('field.backoffMaxMsHint')}
|
|
874
|
-
numeric
|
|
875
|
-
{...shared}
|
|
876
|
-
{...state.backoffMaxMs}
|
|
877
|
-
onEdit={(text) => props.edit('backoffMaxMs', text)}
|
|
878
|
-
onReset={() => props.resetField('backoffMaxMs')}
|
|
879
|
-
/>
|
|
880
|
-
<BooleanField
|
|
881
|
-
id="auto-continue-notify"
|
|
882
|
-
label={t('field.notify')}
|
|
883
|
-
hint={t('field.notifyHint')}
|
|
884
|
-
{...shared}
|
|
885
|
-
{...state.notify}
|
|
886
|
-
onEdit={(text) => props.edit('notify', text)}
|
|
887
|
-
onReset={() => props.resetField('notify')}
|
|
888
|
-
/>
|
|
889
|
-
<BooleanField
|
|
890
|
-
id="auto-continue-verbose"
|
|
891
|
-
label={t('field.verbose')}
|
|
892
|
-
hint={t('field.verboseHint')}
|
|
893
|
-
{...shared}
|
|
894
|
-
{...state.verbose}
|
|
895
|
-
onEdit={(text) => props.edit('verbose', text)}
|
|
896
|
-
onReset={() => props.resetField('verbose')}
|
|
897
|
-
/>
|
|
898
|
-
</SettingsSection>
|
|
899
|
-
|
|
900
|
-
<SettingsSection
|
|
901
|
-
t={t}
|
|
902
|
-
titleKey="section.loop.title"
|
|
903
|
-
descriptionKey="section.loop.description"
|
|
904
|
-
tone="loop"
|
|
905
|
-
>
|
|
906
|
-
<BooleanField
|
|
907
|
-
wide
|
|
908
|
-
id="auto-continue-loop-guard"
|
|
909
|
-
label={t('field.loopGuard')}
|
|
910
|
-
hint={t('field.loopGuardHint')}
|
|
911
|
-
{...shared}
|
|
912
|
-
{...state.loopGuard}
|
|
913
|
-
onEdit={(text) => props.edit('loopGuard', text)}
|
|
914
|
-
onReset={() => props.resetField('loopGuard')}
|
|
915
|
-
/>
|
|
916
|
-
<ValueField
|
|
917
|
-
id="auto-continue-loop-short-chars"
|
|
918
|
-
label={t('field.loopShortChars')}
|
|
919
|
-
hint={t('field.loopShortCharsHint')}
|
|
920
|
-
numeric
|
|
921
|
-
{...shared}
|
|
922
|
-
{...state.loopShortChars}
|
|
923
|
-
onEdit={(text) => props.edit('loopShortChars', text)}
|
|
924
|
-
onReset={() => props.resetField('loopShortChars')}
|
|
925
|
-
/>
|
|
926
|
-
<ValueField
|
|
927
|
-
id="auto-continue-loop-window-ms"
|
|
928
|
-
label={t('field.loopWindowMs')}
|
|
929
|
-
hint={t('field.loopWindowMsHint')}
|
|
930
|
-
numeric
|
|
931
|
-
{...shared}
|
|
932
|
-
{...state.loopWindowMs}
|
|
933
|
-
onEdit={(text) => props.edit('loopWindowMs', text)}
|
|
934
|
-
onReset={() => props.resetField('loopWindowMs')}
|
|
935
|
-
/>
|
|
936
|
-
<ValueField
|
|
937
|
-
id="auto-continue-loop-short-count"
|
|
938
|
-
label={t('field.loopShortCount')}
|
|
939
|
-
hint={t('field.loopShortCountHint')}
|
|
940
|
-
numeric
|
|
941
|
-
{...shared}
|
|
942
|
-
{...state.loopShortCount}
|
|
943
|
-
onEdit={(text) => props.edit('loopShortCount', text)}
|
|
944
|
-
onReset={() => props.resetField('loopShortCount')}
|
|
945
|
-
/>
|
|
946
|
-
<ValueField
|
|
947
|
-
id="auto-continue-loop-repeat-text"
|
|
948
|
-
label={t('field.loopRepeatText')}
|
|
949
|
-
hint={t('field.loopRepeatTextHint')}
|
|
950
|
-
numeric
|
|
951
|
-
{...shared}
|
|
952
|
-
{...state.loopRepeatText}
|
|
953
|
-
onEdit={(text) => props.edit('loopRepeatText', text)}
|
|
954
|
-
onReset={() => props.resetField('loopRepeatText')}
|
|
955
|
-
/>
|
|
956
|
-
<ValueField
|
|
957
|
-
id="auto-continue-loop-tool-repeat"
|
|
958
|
-
label={t('field.loopToolRepeat')}
|
|
959
|
-
hint={t('field.loopToolRepeatHint')}
|
|
960
|
-
numeric
|
|
961
|
-
{...shared}
|
|
962
|
-
{...state.loopToolRepeat}
|
|
963
|
-
onEdit={(text) => props.edit('loopToolRepeat', text)}
|
|
964
|
-
onReset={() => props.resetField('loopToolRepeat')}
|
|
965
|
-
/>
|
|
966
|
-
<ValueField
|
|
967
|
-
wide
|
|
968
|
-
id="auto-continue-loop-text"
|
|
969
|
-
label={t('field.loopText')}
|
|
970
|
-
hint={t('field.loopTextHint')}
|
|
971
|
-
{...shared}
|
|
972
|
-
{...state.loopText}
|
|
973
|
-
onEdit={(text) => props.edit('loopText', text)}
|
|
974
|
-
placeholder={t('default.loopText')}
|
|
975
|
-
onReset={() => props.resetField('loopText')}
|
|
976
|
-
/>
|
|
977
|
-
</SettingsSection>
|
|
978
|
-
|
|
979
|
-
<SettingsSection
|
|
980
|
-
t={t}
|
|
981
|
-
titleKey="section.live.title"
|
|
982
|
-
descriptionKey="section.live.description"
|
|
983
|
-
tone="live"
|
|
984
|
-
>
|
|
985
|
-
<LivePanels t={t} />
|
|
986
|
-
</SettingsSection>
|
|
427
|
+
const state = props.useAutoContinueSettingsCard(snapshot => snapshot);
|
|
428
|
+
const [active, setActive] = useState<Category>('general');
|
|
429
|
+
const prefix = useId();
|
|
430
|
+
const group = groups.find(item => item.id === active)!;
|
|
431
|
+
if (!state.available) return null;
|
|
432
|
+
return <li className="dshAcCard">
|
|
433
|
+
<header className="dshAcHeaderFrame">
|
|
434
|
+
<div className="dshAcIntroduction"><div className="dshAcTitleLine"><h2>{t('card.title')}</h2><span className="dshAcStatus">{t(state.enabled ? 'chrome.enabled' : 'chrome.paused')}</span></div><p>{t('card.description')}</p></div>
|
|
435
|
+
<RepositoryInvite t={t} />
|
|
436
|
+
</header>
|
|
437
|
+
{!state.writable && <p className="dshAcReadOnly" role="status">{t('chrome.readOnly')}</p>}
|
|
438
|
+
<div className="dshAcLayout">
|
|
439
|
+
<div className="dshAcNav" role="tablist" aria-label={t('chrome.categories')}>
|
|
440
|
+
{groups.map((item, index) => {
|
|
441
|
+
const invalid = item.fields.some(name => state[name].invalid);
|
|
442
|
+
const title = t(`category.${item.id}.title`);
|
|
443
|
+
return <button type="button" role="tab" key={item.id} id={`${prefix}-tab-${item.id}`} data-category={item.id}
|
|
444
|
+
aria-controls={`${prefix}-panel-${item.id}`} aria-selected={active === item.id} tabIndex={active === item.id ? 0 : -1}
|
|
445
|
+
aria-label={invalid ? `${title}: ${t('chrome.invalidNumber')}` : title}
|
|
446
|
+
onClick={() => setActive(item.id)} onKeyDown={event => {
|
|
447
|
+
const offset = ['ArrowRight', 'ArrowDown'].includes(event.key) ? 1 : ['ArrowLeft', 'ArrowUp'].includes(event.key) ? -1 : 0;
|
|
448
|
+
if (!offset && event.key !== 'Home' && event.key !== 'End') return;
|
|
449
|
+
event.preventDefault();
|
|
450
|
+
const next = event.key === 'Home' ? 0 : event.key === 'End' ? groups.length - 1 : (index + offset + groups.length) % groups.length;
|
|
451
|
+
setActive(groups[next]!.id);
|
|
452
|
+
const button = event.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>('[role="tab"]')[next];
|
|
453
|
+
button?.focus();
|
|
454
|
+
button?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
455
|
+
}}>{title}{invalid && <span className="dshAcInvalidMark" aria-hidden="true">!</span>}</button>;
|
|
456
|
+
})}
|
|
987
457
|
</div>
|
|
988
|
-
|
|
989
|
-
|
|
458
|
+
<section className="dshAcCategory" role="tabpanel" id={`${prefix}-panel-${active}`} aria-labelledby={`${prefix}-tab-${active}`}>
|
|
459
|
+
<div className="dshAcCategoryHeading"><h3>{t(`category.${active}.title`)}</h3><p>{t(`category.${active}.description`)}</p></div>
|
|
460
|
+
{group.fields.map(name => <SettingField key={name} name={name} id={`${prefix}-${name}`} state={state[name]} actions={props} disabled={!state.writable} t={t} />)}
|
|
461
|
+
{active === 'status' && <LivePanels t={t} />}
|
|
462
|
+
</section>
|
|
463
|
+
</div>
|
|
464
|
+
<footer className="dshAcFooter" data-dirty={state.dirty}>
|
|
465
|
+
<p className={state.failed || state.invalid ? 'dshAcInvalid' : 'dshAcHint'} role="status">{t(state.failed ? 'chrome.saveFailed' : state.invalid ? 'chrome.invalidNumber' : state.saving ? 'chrome.saving' : state.dirty ? 'chrome.unsaved' : state.notificationFeedback ?? 'chrome.saved')}</p>
|
|
466
|
+
<div><button type="button" className="dshAcDiscard" disabled={!state.dirty || state.saving} onClick={props.discard}>{t('chrome.discard')}</button><button type="button" className="dshAcSave" disabled={!state.dirty || state.invalid || state.saving || !state.writable} onClick={props.save}>{t(state.saving ? 'chrome.saving' : 'chrome.save')}</button></div>
|
|
467
|
+
</footer>
|
|
468
|
+
</li>;
|
|
990
469
|
}
|