@surfishs/dsh-prompt-enhance 0.1.1 → 0.1.2
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/lib/client.js +1783 -644
- package/lib/index.js +12 -1
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
- package/src/client/ActionIcons.tsx +49 -0
- package/src/client/EnhanceButton.tsx +314 -5
- package/src/client/QuickSettingsMenu.tsx +163 -0
- package/src/client/ResultDock.tsx +14 -0
- package/src/client/ResultPanel.tsx +99 -51
- package/src/client/UndoBar.tsx +2 -2
- package/src/client/enhance-client.ts +4 -0
- package/src/client/index.tsx +8 -1
- package/src/client/llm-catalog.ts +55 -8
- package/src/client/locales.ts +90 -41
- package/src/client/quick-settings.ts +260 -0
- package/src/client/settings-page-controls.tsx +180 -48
- package/src/client/settings-page-copy.ts +10 -0
- package/src/client/settings-page-spec.ts +29 -3
- package/src/client/settings-page-styles.ts +59 -7
- package/src/client/settings-page.tsx +68 -10
- package/src/client/settings-source.ts +23 -0
- package/src/client/settings-writer.ts +51 -0
- package/src/client/settings.ts +24 -0
- package/src/client/shortcut.ts +45 -0
- package/src/client/styles.ts +370 -43
- package/src/client/ui-state.ts +16 -0
- package/src/config.ts +8 -0
- package/src/enhancer.ts +3 -0
- package/src/shared/defaults.ts +4 -0
- package/src/shared/protocol.ts +6 -0
package/lib/client.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/client/EnhanceButton.tsx
|
|
39
|
-
var
|
|
39
|
+
var import_react4 = require("react");
|
|
40
40
|
|
|
41
41
|
// src/shared/validate.ts
|
|
42
42
|
function isInvisibleCodePoint(cp) {
|
|
@@ -124,7 +124,11 @@ function parseResult(value) {
|
|
|
124
124
|
// object without it left the host setting it, the wire carrying it, and
|
|
125
125
|
// the UI never seeing it. Only `true` is ever normalized in, matching the
|
|
126
126
|
// host, which sets the field solely on a capped finish.
|
|
127
|
-
...record.truncated === true ? { truncated: true } : {}
|
|
127
|
+
...record.truncated === true ? { truncated: true } : {},
|
|
128
|
+
// Same trap as runcated above: rebuilding the object field by field
|
|
129
|
+
// drops anything not listed here, so a new result field has to be added
|
|
130
|
+
// in this exact place or the UI silently never sees it.
|
|
131
|
+
...typeof record.reasoningEffort === "string" ? { reasoningEffort: record.reasoningEffort } : {}
|
|
128
132
|
};
|
|
129
133
|
}
|
|
130
134
|
throw new EnhanceClientError({ code: "internal", params: { reason: "malformed" } });
|
|
@@ -398,6 +402,11 @@ function setStale(sessionId, stale) {
|
|
|
398
402
|
panelState = { ...panelState, stale };
|
|
399
403
|
notify();
|
|
400
404
|
}
|
|
405
|
+
function setCollapsed(sessionId, collapsed) {
|
|
406
|
+
if (panelState?.sessionId !== sessionId || panelState.collapsed === true === collapsed) return;
|
|
407
|
+
panelState = { ...panelState, collapsed };
|
|
408
|
+
notify();
|
|
409
|
+
}
|
|
401
410
|
function closePanel() {
|
|
402
411
|
abortOf(panelState);
|
|
403
412
|
if (panelState === void 0) return;
|
|
@@ -460,7 +469,11 @@ var DEFAULT_VALUES = {
|
|
|
460
469
|
streaming: true,
|
|
461
470
|
contextAware: true,
|
|
462
471
|
contextMaxMessages: 8,
|
|
463
|
-
contextMaxChars: 4e3
|
|
472
|
+
contextMaxChars: 4e3,
|
|
473
|
+
/** Play the card's expand/collapse transition. */
|
|
474
|
+
foldAnimation: true,
|
|
475
|
+
/** Fold the card after Apply, and re-open it after Undo. */
|
|
476
|
+
autoFold: true
|
|
464
477
|
};
|
|
465
478
|
|
|
466
479
|
// src/client/settings.ts
|
|
@@ -468,7 +481,13 @@ var DEFAULT_CLIENT_SETTINGS = {
|
|
|
468
481
|
enabled: DEFAULT_VALUES.enabled,
|
|
469
482
|
maxInputChars: DEFAULT_VALUES.maxInputChars,
|
|
470
483
|
shortcut: DEFAULT_VALUES.shortcut,
|
|
471
|
-
streaming: DEFAULT_VALUES.streaming
|
|
484
|
+
streaming: DEFAULT_VALUES.streaming,
|
|
485
|
+
foldAnimation: DEFAULT_VALUES.foldAnimation,
|
|
486
|
+
autoFold: DEFAULT_VALUES.autoFold,
|
|
487
|
+
reasoningEffort: DEFAULT_VALUES.reasoningEffort,
|
|
488
|
+
contextAware: DEFAULT_VALUES.contextAware,
|
|
489
|
+
provider: "",
|
|
490
|
+
model: ""
|
|
472
491
|
};
|
|
473
492
|
var listeners2 = /* @__PURE__ */ new Set();
|
|
474
493
|
var current = DEFAULT_CLIENT_SETTINGS;
|
|
@@ -492,12 +511,449 @@ function decodeClientSettings(section) {
|
|
|
492
511
|
enabled: typeof record.enabled === "boolean" ? record.enabled : DEFAULT_CLIENT_SETTINGS.enabled,
|
|
493
512
|
maxInputChars: typeof record.maxInputChars === "number" && Number.isFinite(record.maxInputChars) && record.maxInputChars > 0 ? Math.floor(record.maxInputChars) : DEFAULT_CLIENT_SETTINGS.maxInputChars,
|
|
494
513
|
shortcut: typeof record.shortcut === "string" ? record.shortcut : DEFAULT_CLIENT_SETTINGS.shortcut,
|
|
495
|
-
streaming: typeof record.streaming === "boolean" ? record.streaming : DEFAULT_CLIENT_SETTINGS.streaming
|
|
514
|
+
streaming: typeof record.streaming === "boolean" ? record.streaming : DEFAULT_CLIENT_SETTINGS.streaming,
|
|
515
|
+
foldAnimation: typeof record.foldAnimation === "boolean" ? record.foldAnimation : DEFAULT_CLIENT_SETTINGS.foldAnimation,
|
|
516
|
+
autoFold: typeof record.autoFold === "boolean" ? record.autoFold : DEFAULT_CLIENT_SETTINGS.autoFold,
|
|
517
|
+
reasoningEffort: typeof record.reasoningEffort === "string" ? record.reasoningEffort : DEFAULT_CLIENT_SETTINGS.reasoningEffort,
|
|
518
|
+
contextAware: typeof record.contextAware === "boolean" ? record.contextAware : DEFAULT_CLIENT_SETTINGS.contextAware,
|
|
519
|
+
provider: typeof record.provider === "string" ? record.provider : DEFAULT_CLIENT_SETTINGS.provider,
|
|
520
|
+
model: typeof record.model === "string" ? record.model : DEFAULT_CLIENT_SETTINGS.model
|
|
496
521
|
};
|
|
497
522
|
}
|
|
498
523
|
|
|
499
|
-
// src/client/
|
|
524
|
+
// src/client/settings-writer.ts
|
|
525
|
+
var current2;
|
|
526
|
+
var listeners3 = /* @__PURE__ */ new Set();
|
|
527
|
+
function setSettingsWriter(next) {
|
|
528
|
+
if (current2 === next) return;
|
|
529
|
+
current2 = next;
|
|
530
|
+
for (const listener of listeners3) listener();
|
|
531
|
+
}
|
|
532
|
+
function getSettingsWriter() {
|
|
533
|
+
return current2;
|
|
534
|
+
}
|
|
535
|
+
function subscribeSettingsWriter(listener) {
|
|
536
|
+
listeners3.add(listener);
|
|
537
|
+
return () => {
|
|
538
|
+
listeners3.delete(listener);
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/client/QuickSettingsMenu.tsx
|
|
543
|
+
var import_react2 = require("react");
|
|
544
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
545
|
+
|
|
546
|
+
// src/shared/reasoning.ts
|
|
547
|
+
var REASONING_EFFORTS_ENDPOINT = "/dsh-prompt-enhance/reasoning-efforts";
|
|
548
|
+
var DEEPSEEK_PROVIDER = "deepseek-official";
|
|
549
|
+
function isDeepSeekProvider(provider) {
|
|
550
|
+
return provider === DEEPSEEK_PROVIDER || provider.startsWith("deepseek");
|
|
551
|
+
}
|
|
552
|
+
var DEEPSEEK_EFFORTS = [
|
|
553
|
+
{ id: "off", name: "Off", description: "Use for simple tasks that do not need reasoning." },
|
|
554
|
+
{ id: "low", name: "Low", description: "Prefer for routine or latency-sensitive tasks." },
|
|
555
|
+
{ id: "high", name: "High", description: "The default balance for most tasks." },
|
|
556
|
+
{ id: "max", name: "Max", description: "Reserve for the hardest quality-first tasks." }
|
|
557
|
+
];
|
|
558
|
+
|
|
559
|
+
// src/client/llm-catalog.ts
|
|
500
560
|
var import_react = require("react");
|
|
561
|
+
|
|
562
|
+
// src/shared/catalog.ts
|
|
563
|
+
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
564
|
+
var LLM_MODELS_ENDPOINT = "/dsh-prompt-enhance/llm-models";
|
|
565
|
+
var LLM_ROUTE_CHECK_ENDPOINT = "/dsh-prompt-enhance/llm-route-check";
|
|
566
|
+
|
|
567
|
+
// src/client/llm-catalog.ts
|
|
568
|
+
async function getJson(url, signal) {
|
|
569
|
+
try {
|
|
570
|
+
const response = await fetch(url, { signal, headers: { accept: "application/json" } });
|
|
571
|
+
if (!response.ok) return void 0;
|
|
572
|
+
const body = await response.json();
|
|
573
|
+
const envelope = body;
|
|
574
|
+
if (envelope === null || envelope === void 0 || envelope.ok !== true) return void 0;
|
|
575
|
+
return envelope.value;
|
|
576
|
+
} catch {
|
|
577
|
+
return void 0;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
var CATALOG_TTL_MS = 6e4;
|
|
581
|
+
var providersMemo;
|
|
582
|
+
var modelsMemo = /* @__PURE__ */ new Map();
|
|
583
|
+
function endpoint(path, params = {}) {
|
|
584
|
+
const url = new URL(path, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
585
|
+
for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
|
|
586
|
+
return url;
|
|
587
|
+
}
|
|
588
|
+
async function fetchProviders(signal, options = {}) {
|
|
589
|
+
const cached = providersMemo;
|
|
590
|
+
if (options.refresh !== true && cached !== void 0 && Date.now() - cached.at <= CATALOG_TTL_MS) return cached.value;
|
|
591
|
+
const value = await getJson(endpoint(LLM_PROVIDERS_ENDPOINT), signal);
|
|
592
|
+
if (value === void 0 || !Array.isArray(value.providers)) return void 0;
|
|
593
|
+
const providers = value.providers.filter(
|
|
594
|
+
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== "" && typeof entry.registered === "boolean"
|
|
595
|
+
);
|
|
596
|
+
providersMemo = { value: providers, at: Date.now() };
|
|
597
|
+
return providers;
|
|
598
|
+
}
|
|
599
|
+
async function fetchModels(provider, signal, options = {}) {
|
|
600
|
+
const cached = modelsMemo.get(provider);
|
|
601
|
+
if (options.refresh !== true && cached !== void 0 && Date.now() - cached.at <= CATALOG_TTL_MS) return cached.value;
|
|
602
|
+
const value = await getJson(endpoint(LLM_MODELS_ENDPOINT, { provider }), signal);
|
|
603
|
+
if (value === void 0 || !Array.isArray(value.models)) return void 0;
|
|
604
|
+
const models = value.models.filter(
|
|
605
|
+
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== ""
|
|
606
|
+
).map((entry) => ({
|
|
607
|
+
id: entry.id,
|
|
608
|
+
name: entry.name,
|
|
609
|
+
...typeof entry.description === "string" && entry.description !== "" ? { description: entry.description } : {}
|
|
610
|
+
}));
|
|
611
|
+
const answer = { models, ...typeof value.reason === "string" ? { reason: value.reason } : {} };
|
|
612
|
+
if (models.length > 0) modelsMemo.set(provider, { value: answer, at: Date.now() });
|
|
613
|
+
return answer;
|
|
614
|
+
}
|
|
615
|
+
async function fetchRouteCheck(provider, model, signal) {
|
|
616
|
+
const value = await getJson(endpoint(LLM_ROUTE_CHECK_ENDPOINT, { provider, model }), signal);
|
|
617
|
+
if (value === void 0 || typeof value.available !== "boolean") return void 0;
|
|
618
|
+
return value;
|
|
619
|
+
}
|
|
620
|
+
function useLlmRouting(provider, model) {
|
|
621
|
+
const [providers, setProviders] = (0, import_react.useState)([]);
|
|
622
|
+
const [providersLoading, setProvidersLoading] = (0, import_react.useState)(true);
|
|
623
|
+
const [providersFailed, setProvidersFailed] = (0, import_react.useState)(false);
|
|
624
|
+
const [providersToken, setProvidersToken] = (0, import_react.useState)(0);
|
|
625
|
+
const [models, setModels] = (0, import_react.useState)([]);
|
|
626
|
+
const [modelsLoading, setModelsLoading] = (0, import_react.useState)(false);
|
|
627
|
+
const [modelsFailed, setModelsFailed] = (0, import_react.useState)(false);
|
|
628
|
+
const [modelsToken, setModelsToken] = (0, import_react.useState)(0);
|
|
629
|
+
const [routeChecking, setRouteChecking] = (0, import_react.useState)(false);
|
|
630
|
+
const [routeAvailable, setRouteAvailable] = (0, import_react.useState)(void 0);
|
|
631
|
+
(0, import_react.useEffect)(() => {
|
|
632
|
+
const controller = new AbortController();
|
|
633
|
+
setProvidersLoading(true);
|
|
634
|
+
setProvidersFailed(false);
|
|
635
|
+
void fetchProviders(controller.signal, { refresh: providersToken > 0 }).then((entries) => {
|
|
636
|
+
if (controller.signal.aborted) return;
|
|
637
|
+
setProvidersLoading(false);
|
|
638
|
+
if (entries === void 0) {
|
|
639
|
+
setProvidersFailed(true);
|
|
640
|
+
setProviders([]);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
setProviders(entries);
|
|
644
|
+
});
|
|
645
|
+
return () => controller.abort();
|
|
646
|
+
}, [providersToken]);
|
|
647
|
+
(0, import_react.useEffect)(() => {
|
|
648
|
+
if (provider === "") {
|
|
649
|
+
setModels([]);
|
|
650
|
+
setModelsLoading(false);
|
|
651
|
+
setModelsFailed(false);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const controller = new AbortController();
|
|
655
|
+
setModels([]);
|
|
656
|
+
setModelsLoading(true);
|
|
657
|
+
setModelsFailed(false);
|
|
658
|
+
void fetchModels(provider, controller.signal, { refresh: modelsToken > 0 }).then((answer) => {
|
|
659
|
+
if (controller.signal.aborted) return;
|
|
660
|
+
setModelsLoading(false);
|
|
661
|
+
if (answer === void 0) {
|
|
662
|
+
setModelsFailed(true);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
setModels(answer.models);
|
|
666
|
+
setModelsFailed(answer.models.length === 0);
|
|
667
|
+
});
|
|
668
|
+
return () => controller.abort();
|
|
669
|
+
}, [provider, modelsToken]);
|
|
670
|
+
(0, import_react.useEffect)(() => {
|
|
671
|
+
if (provider === "" || model === "") {
|
|
672
|
+
setRouteChecking(false);
|
|
673
|
+
setRouteAvailable(void 0);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const controller = new AbortController();
|
|
677
|
+
setRouteChecking(true);
|
|
678
|
+
setRouteAvailable(void 0);
|
|
679
|
+
const timer = setTimeout(() => {
|
|
680
|
+
void fetchRouteCheck(provider, model, controller.signal).then((answer) => {
|
|
681
|
+
if (controller.signal.aborted) return;
|
|
682
|
+
setRouteChecking(false);
|
|
683
|
+
setRouteAvailable(answer === void 0 ? false : answer.available);
|
|
684
|
+
});
|
|
685
|
+
}, 400);
|
|
686
|
+
return () => {
|
|
687
|
+
clearTimeout(timer);
|
|
688
|
+
controller.abort();
|
|
689
|
+
};
|
|
690
|
+
}, [provider, model]);
|
|
691
|
+
return {
|
|
692
|
+
providers: {
|
|
693
|
+
loading: providersLoading,
|
|
694
|
+
failed: providersFailed,
|
|
695
|
+
entries: providers,
|
|
696
|
+
reload: () => setProvidersToken((token) => token + 1)
|
|
697
|
+
},
|
|
698
|
+
models: {
|
|
699
|
+
loading: modelsLoading,
|
|
700
|
+
failed: modelsFailed,
|
|
701
|
+
entries: models,
|
|
702
|
+
reload: () => setModelsToken((token) => token + 1)
|
|
703
|
+
},
|
|
704
|
+
route: { checking: routeChecking, available: routeAvailable }
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// src/client/reasoning-options.ts
|
|
709
|
+
function effortOf(value) {
|
|
710
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
711
|
+
const record = value;
|
|
712
|
+
if (typeof record.id !== "string" || record.id === "" || typeof record.name !== "string" || record.name === "") return void 0;
|
|
713
|
+
return {
|
|
714
|
+
id: record.id,
|
|
715
|
+
name: record.name,
|
|
716
|
+
...typeof record.description === "string" && record.description !== "" ? { description: record.description } : {}
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function capabilitiesOf(value) {
|
|
720
|
+
if (value === null || typeof value !== "object") return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
721
|
+
const record = value;
|
|
722
|
+
const source = record.source === "resolved" || record.source === "default" || record.source === "unavailable" ? record.source : "unavailable";
|
|
723
|
+
const efforts = Array.isArray(record.efforts) ? record.efforts.map(effortOf).filter((effort) => effort !== void 0) : [];
|
|
724
|
+
const reason = typeof record.reason === "string" ? record.reason : void 0;
|
|
725
|
+
if (source !== "unavailable" && efforts.length === 0) return { efforts: [], source: "unavailable", reason: "no-efforts" };
|
|
726
|
+
return {
|
|
727
|
+
efforts,
|
|
728
|
+
source,
|
|
729
|
+
...typeof record.defaultEffort === "string" && record.defaultEffort !== "" ? { defaultEffort: record.defaultEffort } : {},
|
|
730
|
+
...reason === void 0 ? {} : { reason }
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
734
|
+
const url = new URL(REASONING_EFFORTS_ENDPOINT, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
735
|
+
if (provider !== void 0 && model !== void 0) {
|
|
736
|
+
url.searchParams.set("provider", provider);
|
|
737
|
+
url.searchParams.set("model", model);
|
|
738
|
+
}
|
|
739
|
+
if (options.refresh === true) url.searchParams.set("refresh", "1");
|
|
740
|
+
try {
|
|
741
|
+
const response = await fetch(url, { signal: options.signal, headers: { accept: "application/json" } });
|
|
742
|
+
if (!response.ok) return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
743
|
+
const body = await response.json();
|
|
744
|
+
const envelope = body;
|
|
745
|
+
if (envelope === null || envelope === void 0 || envelope.ok !== true) {
|
|
746
|
+
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
747
|
+
}
|
|
748
|
+
return capabilitiesOf(envelope.value);
|
|
749
|
+
} catch {
|
|
750
|
+
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/client/quick-settings.ts
|
|
755
|
+
var INHERIT_EFFORT = "inherit";
|
|
756
|
+
function effortsOf(value) {
|
|
757
|
+
if (!Array.isArray(value)) return [];
|
|
758
|
+
const out = [];
|
|
759
|
+
for (const item of value) {
|
|
760
|
+
if (item === null || typeof item !== "object") continue;
|
|
761
|
+
const record = item;
|
|
762
|
+
if (typeof record.id !== "string" || record.id === "") continue;
|
|
763
|
+
out.push({ id: record.id, name: typeof record.name === "string" && record.name !== "" ? record.name : record.id });
|
|
764
|
+
}
|
|
765
|
+
return out;
|
|
766
|
+
}
|
|
767
|
+
function staticEfforts() {
|
|
768
|
+
return DEEPSEEK_EFFORTS.map((effort) => ({ id: effort.id, name: effort.name }));
|
|
769
|
+
}
|
|
770
|
+
function menuOptionsOf(data) {
|
|
771
|
+
const options = [...data.efforts];
|
|
772
|
+
if (data.effort !== "" && data.effort !== INHERIT_EFFORT && !options.some((option) => option.id === data.effort)) {
|
|
773
|
+
const known = DEEPSEEK_EFFORTS.find((effort) => effort.id === data.effort);
|
|
774
|
+
options.push({ id: data.effort, name: known?.name ?? data.effort });
|
|
775
|
+
}
|
|
776
|
+
return options;
|
|
777
|
+
}
|
|
778
|
+
function modelDirectoryOf(ctx, sessionId) {
|
|
779
|
+
try {
|
|
780
|
+
return ctx?.modelDirectories?.directoryFor?.(sessionId);
|
|
781
|
+
} catch {
|
|
782
|
+
return void 0;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function directoryFaceOf(directory) {
|
|
786
|
+
if (directory === null || typeof directory !== "object") return void 0;
|
|
787
|
+
return directory;
|
|
788
|
+
}
|
|
789
|
+
function readDirectory(directory) {
|
|
790
|
+
const store = directory?.store;
|
|
791
|
+
let snapshot;
|
|
792
|
+
try {
|
|
793
|
+
snapshot = store?.getSnapshot?.();
|
|
794
|
+
} catch {
|
|
795
|
+
return void 0;
|
|
796
|
+
}
|
|
797
|
+
if (snapshot === null || typeof snapshot !== "object") return void 0;
|
|
798
|
+
const state = snapshot;
|
|
799
|
+
const provider = typeof state.current?.provider === "string" ? state.current.provider : void 0;
|
|
800
|
+
const model = typeof state.current?.model === "string" ? state.current.model : void 0;
|
|
801
|
+
let efforts = [];
|
|
802
|
+
if (Array.isArray(state.groups) && provider !== void 0 && model !== void 0) {
|
|
803
|
+
for (const group of state.groups) {
|
|
804
|
+
if (group === null || typeof group !== "object") continue;
|
|
805
|
+
const entry = group;
|
|
806
|
+
if (entry.id !== provider || !Array.isArray(entry.models)) continue;
|
|
807
|
+
for (const candidate of entry.models) {
|
|
808
|
+
if (candidate === null || typeof candidate !== "object") continue;
|
|
809
|
+
const record = candidate;
|
|
810
|
+
if (record.id !== model) continue;
|
|
811
|
+
efforts = effortsOf(record.reasoning?.efforts);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return { efforts, provider, model };
|
|
816
|
+
}
|
|
817
|
+
async function kickLoad(directory) {
|
|
818
|
+
const load = directory?.load;
|
|
819
|
+
if (typeof load !== "function") return;
|
|
820
|
+
try {
|
|
821
|
+
await Promise.resolve(load.call(directory));
|
|
822
|
+
} catch {
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
var FOLLOW_LABELS = { providerLabel: "", modelLabel: "" };
|
|
826
|
+
async function routeLabelsOf(provider, model) {
|
|
827
|
+
if (provider === "") return FOLLOW_LABELS;
|
|
828
|
+
const [providers, models] = await Promise.all([fetchProviders(), model === "" ? Promise.resolve(void 0) : fetchModels(provider)]);
|
|
829
|
+
return {
|
|
830
|
+
providerLabel: providers?.find((entry) => entry.id === provider)?.name ?? provider,
|
|
831
|
+
modelLabel: model === "" ? "" : models?.models.find((entry) => entry.id === model)?.name ?? model
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
async function resolveQuickSettings(input) {
|
|
835
|
+
const stored = typeof input.settings.reasoningEffort === "string" ? input.settings.reasoningEffort.trim() : "";
|
|
836
|
+
const effort = stored === "" ? "off" : stored;
|
|
837
|
+
const contextAware = input.settings.contextAware === true;
|
|
838
|
+
const provider = input.settings.provider?.trim() ?? "";
|
|
839
|
+
const model = input.settings.model?.trim() ?? "";
|
|
840
|
+
const labelsPromise = routeLabelsOf(provider, model);
|
|
841
|
+
if (provider !== "" && model !== "") {
|
|
842
|
+
const capabilities = await fetchReasoningCapabilities(provider, model);
|
|
843
|
+
const efforts = effortsOf(capabilities.efforts);
|
|
844
|
+
if (efforts.length > 0) return { efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "override" };
|
|
845
|
+
return { efforts: [], effort, contextAware, provider, model, ...await labelsPromise, source: "override", effortReason: capabilities.reason ?? "resolve-failed" };
|
|
846
|
+
}
|
|
847
|
+
const directory = modelDirectoryOf(input.ctx, input.sessionId);
|
|
848
|
+
if (directory !== void 0) {
|
|
849
|
+
const first = readDirectory(directory);
|
|
850
|
+
if (first !== void 0 && first.efforts.length > 0) return { efforts: first.efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "session" };
|
|
851
|
+
await kickLoad(directory);
|
|
852
|
+
const second = readDirectory(directory);
|
|
853
|
+
if (second !== void 0 && second.efforts.length > 0) return { efforts: second.efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "session" };
|
|
854
|
+
if (second?.provider !== void 0 && !isDeepSeekProvider(second.provider)) {
|
|
855
|
+
return { efforts: [], effort, contextAware, provider, model, ...await labelsPromise, source: "session", effortReason: "no-efforts" };
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return { efforts: staticEfforts(), effort, contextAware, provider, model, ...await labelsPromise, source: "static" };
|
|
859
|
+
}
|
|
860
|
+
async function writeQuickEffort(writer, id) {
|
|
861
|
+
try {
|
|
862
|
+
return await writer.set("reasoningEffort", id);
|
|
863
|
+
} catch {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
async function writeQuickContext(writer, next) {
|
|
868
|
+
try {
|
|
869
|
+
return await writer.set("contextAware", next);
|
|
870
|
+
} catch {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// src/client/QuickSettingsMenu.tsx
|
|
876
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
877
|
+
function MenuRow(props) {
|
|
878
|
+
const { label, checked, role, onSelect } = props;
|
|
879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role, "aria-checked": checked, className: "dsh-pe-menu-item", onClick: onSelect, children: [
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: label }),
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-mark", "aria-hidden": true, children: checked ? "\u2713" : "" })
|
|
882
|
+
] });
|
|
883
|
+
}
|
|
884
|
+
function QuickSettingsMenu(props) {
|
|
885
|
+
const { t, data, anchor, error, onPick, onToggleContext, onClose } = props;
|
|
886
|
+
const ref = (0, import_react2.useRef)(null);
|
|
887
|
+
const [pane, setPane] = (0, import_react2.useState)("root");
|
|
888
|
+
const paneRef = (0, import_react2.useRef)(null);
|
|
889
|
+
(0, import_react2.useEffect)(() => {
|
|
890
|
+
const onKeyDown = (event) => {
|
|
891
|
+
if (event.key !== "Escape") return;
|
|
892
|
+
event.preventDefault();
|
|
893
|
+
setPane((current3) => {
|
|
894
|
+
if (current3 === "effort") return "root";
|
|
895
|
+
onClose();
|
|
896
|
+
return current3;
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
const onPointerDown = (event) => {
|
|
900
|
+
const node = ref.current;
|
|
901
|
+
if (node === null) return;
|
|
902
|
+
const target = event.target;
|
|
903
|
+
if (target instanceof Node && node.contains(target)) return;
|
|
904
|
+
onClose();
|
|
905
|
+
};
|
|
906
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
907
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
908
|
+
return () => {
|
|
909
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
910
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
911
|
+
};
|
|
912
|
+
}, [onClose]);
|
|
913
|
+
(0, import_react2.useEffect)(() => {
|
|
914
|
+
if (pane !== "effort") return;
|
|
915
|
+
const checked = paneRef.current?.querySelector('[aria-checked="true"]');
|
|
916
|
+
checked?.focus();
|
|
917
|
+
}, [pane]);
|
|
918
|
+
const viewportWidth = typeof window === "undefined" ? 0 : window.innerWidth;
|
|
919
|
+
const viewportHeight = typeof window === "undefined" ? 0 : window.innerHeight;
|
|
920
|
+
const right = Math.max(8, viewportWidth - anchor.right);
|
|
921
|
+
const bottom = Math.max(8, viewportHeight - anchor.top + 8);
|
|
922
|
+
const options = menuOptionsOf(data);
|
|
923
|
+
const currentEffort = options.find((option) => option.id === data.effort);
|
|
924
|
+
const radioOptions = data.efforts.length === 0 ? [] : options;
|
|
925
|
+
const effortValue = data.effort === INHERIT_EFFORT ? t("menu.effortDefault") : currentEffort?.name ?? data.effort;
|
|
926
|
+
const providerPart = data.providerLabel === "" ? data.provider : data.providerLabel;
|
|
927
|
+
const modelPart = data.modelLabel === "" ? data.model : data.modelLabel;
|
|
928
|
+
const pinnedRoute = [providerPart, modelPart].filter((part) => part !== "").join(" / ");
|
|
929
|
+
const modelValue = pinnedRoute === "" ? t("menu.modelFollow") : pinnedRoute;
|
|
930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref, className: "dsh-pe-menu", role: "menu", "aria-label": t("menu.title"), style: { position: "fixed", right, bottom }, children: [
|
|
931
|
+
pane === "root" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-pe-menu-info", title: t("menu.modelHint"), children: [
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: t("menu.model") }),
|
|
934
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-state", children: modelValue })
|
|
935
|
+
] }),
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role: "menuitem", className: "dsh-pe-menu-item dsh-pe-menu-cell", onClick: () => setPane("effort"), children: [
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: t("menu.effort") }),
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-state", children: effortValue }),
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-chevron", "aria-hidden": true })
|
|
940
|
+
] }),
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-pe-menu-sep", role: "separator" }),
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-pe-menu-switch", children: [
|
|
943
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-switch-label", children: t("menu.context") }),
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.Switch, { className: "dsh-pe-menu-switch-input", checked: data.contextAware, label: t("menu.context"), onChange: (next) => onToggleContext(next) })
|
|
945
|
+
] })
|
|
946
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: paneRef, className: "dsh-pe-menu-group", role: "group", "aria-label": t("menu.effort"), children: [
|
|
947
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MenuRow, { role: "menuitemradio", label: t("menu.effortDefault"), checked: data.effort === INHERIT_EFFORT, onSelect: () => onPick(INHERIT_EFFORT) }),
|
|
948
|
+
radioOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MenuRow, { role: "menuitemradio", label: option.name, checked: data.effort === option.id, onSelect: () => onPick(option.id) }, option.id)),
|
|
949
|
+
radioOptions.length > 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-pe-menu-note", role: "status", children: data.effortReason === "no-efforts" ? t("menu.effortsNone") : t("menu.effortsFailed") })
|
|
950
|
+
] }),
|
|
951
|
+
error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-pe-menu-error", role: "alert", children: error })
|
|
952
|
+
] });
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// src/client/session-key.ts
|
|
956
|
+
var import_react3 = require("react");
|
|
501
957
|
var fallbackSeq = 0;
|
|
502
958
|
var zoneKeys = /* @__PURE__ */ new WeakMap();
|
|
503
959
|
function fallbackKeyOf(share) {
|
|
@@ -509,7 +965,7 @@ function fallbackKeyOf(share) {
|
|
|
509
965
|
return minted;
|
|
510
966
|
}
|
|
511
967
|
function useSessionKey(maybeSessionId, share) {
|
|
512
|
-
const fallback = (0,
|
|
968
|
+
const fallback = (0, import_react3.useRef)(void 0);
|
|
513
969
|
if (maybeSessionId !== void 0 && maybeSessionId !== "") return maybeSessionId;
|
|
514
970
|
if (fallback.current === void 0) fallback.current = fallbackKeyOf(share);
|
|
515
971
|
return fallback.current;
|
|
@@ -519,7 +975,9 @@ function serverSessionId(maybeSessionId) {
|
|
|
519
975
|
}
|
|
520
976
|
|
|
521
977
|
// src/client/EnhanceButton.tsx
|
|
522
|
-
var
|
|
978
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
979
|
+
var LONG_PRESS_MS = 600;
|
|
980
|
+
var LONG_PRESS_SLOP_PX = 6;
|
|
523
981
|
var OCCURRENCES_UNKNOWN = -1;
|
|
524
982
|
function occurrenceCountOf(value) {
|
|
525
983
|
return Array.isArray(value) ? value.length : OCCURRENCES_UNKNOWN;
|
|
@@ -534,14 +992,167 @@ function EnhanceButton(props) {
|
|
|
534
992
|
const draft = useInput((state) => stringOf(state.draft));
|
|
535
993
|
const phase = useInput((state) => state.phase);
|
|
536
994
|
const occurrenceCount = useInput((state) => occurrenceCountOf(state.occurrences));
|
|
537
|
-
const settings = (0,
|
|
538
|
-
const panel = (0,
|
|
539
|
-
const rootRef = (0,
|
|
995
|
+
const settings = (0, import_react4.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
996
|
+
const panel = (0, import_react4.useSyncExternalStore)(subscribe, getPanel);
|
|
997
|
+
const rootRef = (0, import_react4.useRef)(null);
|
|
540
998
|
const busy = panel !== void 0 && panel.sessionId === uiKey && panel.phase === "loading";
|
|
541
999
|
const anyBusy = panel !== void 0 && panel.phase === "loading";
|
|
542
1000
|
const otherBusy = anyBusy && !busy;
|
|
543
1001
|
const empty = draft.trim() === "";
|
|
544
|
-
const
|
|
1002
|
+
const writer = (0, import_react4.useSyncExternalStore)(subscribeSettingsWriter, getSettingsWriter);
|
|
1003
|
+
const [menu, setMenu] = (0, import_react4.useState)(null);
|
|
1004
|
+
const [menuError, setMenuError] = (0, import_react4.useState)(void 0);
|
|
1005
|
+
const longPressTimer = (0, import_react4.useRef)(void 0);
|
|
1006
|
+
const longPressOrigin = (0, import_react4.useRef)(null);
|
|
1007
|
+
const longPressFired = (0, import_react4.useRef)(false);
|
|
1008
|
+
const contextWrites = (0, import_react4.useRef)({ desired: null, accepted: null, inFlight: null, running: false, seq: 0, closing: false });
|
|
1009
|
+
const flushContextRef = (0, import_react4.useRef)(() => {
|
|
1010
|
+
});
|
|
1011
|
+
const applyContext = (value) => {
|
|
1012
|
+
setMenu((current3) => current3 === null ? current3 : { ...current3, data: { ...current3.data, contextAware: value } });
|
|
1013
|
+
};
|
|
1014
|
+
const kickContextWrite = (force = false) => {
|
|
1015
|
+
const state = contextWrites.current;
|
|
1016
|
+
if (writer === void 0 || state.running) return;
|
|
1017
|
+
const target = state.desired;
|
|
1018
|
+
if (target === null) return;
|
|
1019
|
+
const accepted = state.accepted ?? settings.contextAware;
|
|
1020
|
+
state.accepted = accepted;
|
|
1021
|
+
if (!force && target === accepted) {
|
|
1022
|
+
state.desired = null;
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
state.running = true;
|
|
1026
|
+
state.inFlight = target;
|
|
1027
|
+
const ticket = ++state.seq;
|
|
1028
|
+
void writeQuickContext(writer, target).then((ok) => {
|
|
1029
|
+
state.running = false;
|
|
1030
|
+
state.inFlight = null;
|
|
1031
|
+
if (ticket !== state.seq) {
|
|
1032
|
+
if (ok && state.accepted !== null) {
|
|
1033
|
+
state.desired = state.accepted;
|
|
1034
|
+
kickContextWrite(true);
|
|
1035
|
+
}
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
if (!ok) {
|
|
1039
|
+
state.desired = null;
|
|
1040
|
+
applyContext(state.accepted ?? settings.contextAware);
|
|
1041
|
+
setMenuError(t("menu.writeFailed"));
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
state.accepted = target;
|
|
1045
|
+
if (state.desired === target) state.desired = null;
|
|
1046
|
+
kickContextWrite();
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
const flushContextWrite = () => {
|
|
1050
|
+
const state = contextWrites.current;
|
|
1051
|
+
if (writer === void 0 || state.closing) return;
|
|
1052
|
+
const target = state.desired;
|
|
1053
|
+
if (target === null || target === state.inFlight) return;
|
|
1054
|
+
const accepted = state.accepted ?? settings.contextAware;
|
|
1055
|
+
const supersededValue = state.inFlight !== null;
|
|
1056
|
+
state.accepted = accepted;
|
|
1057
|
+
state.desired = null;
|
|
1058
|
+
if (!supersededValue && target === accepted) return;
|
|
1059
|
+
state.closing = true;
|
|
1060
|
+
const ticket = ++state.seq;
|
|
1061
|
+
void writeQuickContext(writer, target).then((ok) => {
|
|
1062
|
+
state.closing = false;
|
|
1063
|
+
if (!ok) {
|
|
1064
|
+
console.warn("[dsh-prompt-enhance] the contextAware write was refused while closing the quick settings card");
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
if (ticket === state.seq) state.accepted = target;
|
|
1068
|
+
});
|
|
1069
|
+
};
|
|
1070
|
+
flushContextRef.current = flushContextWrite;
|
|
1071
|
+
const dismissMenu = (0, import_react4.useCallback)(() => {
|
|
1072
|
+
flushContextRef.current();
|
|
1073
|
+
setMenu(null);
|
|
1074
|
+
}, []);
|
|
1075
|
+
const toggleContext = (next) => {
|
|
1076
|
+
if (writer === void 0) return;
|
|
1077
|
+
const state = contextWrites.current;
|
|
1078
|
+
setMenuError(void 0);
|
|
1079
|
+
applyContext(next);
|
|
1080
|
+
state.desired = next;
|
|
1081
|
+
if (state.accepted === null) state.accepted = settings.contextAware;
|
|
1082
|
+
kickContextWrite();
|
|
1083
|
+
};
|
|
1084
|
+
const reconcileEffort = (0, import_react4.useCallback)(
|
|
1085
|
+
async (data) => {
|
|
1086
|
+
if (writer === void 0) return data;
|
|
1087
|
+
if (data.effort === "" || data.effort === INHERIT_EFFORT) return data;
|
|
1088
|
+
if (data.efforts.some((effort) => effort.id === data.effort)) return data;
|
|
1089
|
+
const cleared = await writeQuickEffort(writer, INHERIT_EFFORT);
|
|
1090
|
+
if (!cleared) {
|
|
1091
|
+
console.warn("[dsh-prompt-enhance] could not clear the stored reasoning effort for the current model");
|
|
1092
|
+
return data;
|
|
1093
|
+
}
|
|
1094
|
+
return { ...data, effort: INHERIT_EFFORT };
|
|
1095
|
+
},
|
|
1096
|
+
[writer]
|
|
1097
|
+
);
|
|
1098
|
+
(0, import_react4.useEffect)(() => {
|
|
1099
|
+
const state = contextWrites.current;
|
|
1100
|
+
if (state.seq === 0 && state.desired === null) state.accepted = settings.contextAware;
|
|
1101
|
+
}, [settings.contextAware]);
|
|
1102
|
+
(0, import_react4.useEffect)(() => () => flushContextRef.current(), []);
|
|
1103
|
+
const menuOpen = menu !== null;
|
|
1104
|
+
(0, import_react4.useEffect)(() => {
|
|
1105
|
+
if (!menuOpen) return;
|
|
1106
|
+
const directory = directoryFaceOf(modelDirectoryOf(props.__ctx, sessionId));
|
|
1107
|
+
const store = directory?.store;
|
|
1108
|
+
let cancelled = false;
|
|
1109
|
+
let timer;
|
|
1110
|
+
const refresh = () => {
|
|
1111
|
+
if (cancelled) return;
|
|
1112
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1113
|
+
timer = setTimeout(() => {
|
|
1114
|
+
timer = void 0;
|
|
1115
|
+
void resolveQuickSettings({ ctx: props.__ctx, sessionId, settings }).then(async (resolved) => {
|
|
1116
|
+
const data = await reconcileEffort(resolved);
|
|
1117
|
+
if (cancelled) return;
|
|
1118
|
+
const local = contextWrites.current.desired ?? contextWrites.current.accepted;
|
|
1119
|
+
setMenu((current3) => current3 === null ? current3 : { ...current3, data: local === null ? data : { ...data, contextAware: local } });
|
|
1120
|
+
});
|
|
1121
|
+
}, 80);
|
|
1122
|
+
};
|
|
1123
|
+
const stop = store?.subscribe?.(refresh);
|
|
1124
|
+
try {
|
|
1125
|
+
void Promise.resolve(directory?.load?.()).catch(() => {
|
|
1126
|
+
});
|
|
1127
|
+
} catch {
|
|
1128
|
+
}
|
|
1129
|
+
return () => {
|
|
1130
|
+
cancelled = true;
|
|
1131
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1132
|
+
stop?.();
|
|
1133
|
+
};
|
|
1134
|
+
}, [menuOpen, props.__ctx, sessionId, settings, reconcileEffort]);
|
|
1135
|
+
const openMenu = (0, import_react4.useCallback)(
|
|
1136
|
+
async (rect) => {
|
|
1137
|
+
const anchor = { right: rect.right, top: rect.top };
|
|
1138
|
+
setMenuError(void 0);
|
|
1139
|
+
const resolved = await resolveQuickSettings({ ctx: props.__ctx, sessionId, settings });
|
|
1140
|
+
const data = await reconcileEffort(resolved);
|
|
1141
|
+
const local = contextWrites.current.desired ?? contextWrites.current.accepted;
|
|
1142
|
+
setMenu({ anchor, data: local === null ? data : { ...data, contextAware: local } });
|
|
1143
|
+
},
|
|
1144
|
+
[props.__ctx, sessionId, settings, reconcileEffort]
|
|
1145
|
+
);
|
|
1146
|
+
const pickEffort = (id) => {
|
|
1147
|
+
if (writer === void 0) return;
|
|
1148
|
+
const unchanged = menu !== null && menu.data.effort === id;
|
|
1149
|
+
dismissMenu();
|
|
1150
|
+
if (unchanged) return;
|
|
1151
|
+
void writeQuickEffort(writer, id).then((ok) => {
|
|
1152
|
+
if (!ok) console.warn("[dsh-prompt-enhance] the reasoningEffort write was refused");
|
|
1153
|
+
});
|
|
1154
|
+
};
|
|
1155
|
+
const start = (0, import_react4.useCallback)(
|
|
545
1156
|
(overrideText) => {
|
|
546
1157
|
const source = overrideText ?? draft;
|
|
547
1158
|
if (anyBusy || source.trim() === "") return;
|
|
@@ -592,49 +1203,122 @@ function EnhanceButton(props) {
|
|
|
592
1203
|
},
|
|
593
1204
|
[anyBusy, draft, occurrenceCount, phase, settings, uiKey, wireId, t]
|
|
594
1205
|
);
|
|
595
|
-
const runRef = (0,
|
|
596
|
-
(0,
|
|
1206
|
+
const runRef = (0, import_react4.useRef)(start);
|
|
1207
|
+
(0, import_react4.useEffect)(() => {
|
|
597
1208
|
runRef.current = start;
|
|
598
1209
|
});
|
|
599
|
-
(0,
|
|
1210
|
+
(0, import_react4.useEffect)(() => {
|
|
600
1211
|
const entry = {
|
|
601
1212
|
root: rootRef.current,
|
|
602
1213
|
run: (text) => runRef.current(text)
|
|
603
1214
|
};
|
|
604
1215
|
return registerSession(uiKey, entry);
|
|
605
1216
|
}, [uiKey]);
|
|
606
|
-
(0,
|
|
1217
|
+
(0, import_react4.useEffect)(() => {
|
|
607
1218
|
if (panel !== void 0 && panel.sessionId === uiKey && panel.phase === "result") {
|
|
608
1219
|
setStale(uiKey, draft !== panel.original);
|
|
609
1220
|
}
|
|
610
1221
|
}, [draft, panel, uiKey]);
|
|
1222
|
+
(0, import_react4.useEffect)(() => {
|
|
1223
|
+
if (writer === void 0 || !settings.enabled) return;
|
|
1224
|
+
const button = rootRef.current;
|
|
1225
|
+
if (button === null) return;
|
|
1226
|
+
const clearTimer = () => {
|
|
1227
|
+
if (longPressTimer.current !== void 0) {
|
|
1228
|
+
clearTimeout(longPressTimer.current);
|
|
1229
|
+
longPressTimer.current = void 0;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
const onPointerDown = (event) => {
|
|
1233
|
+
const target = event.target;
|
|
1234
|
+
if (!(target instanceof Node) || !button.contains(target)) return;
|
|
1235
|
+
clearTimer();
|
|
1236
|
+
longPressFired.current = false;
|
|
1237
|
+
longPressOrigin.current = { x: event.clientX, y: event.clientY };
|
|
1238
|
+
longPressTimer.current = setTimeout(() => {
|
|
1239
|
+
longPressTimer.current = void 0;
|
|
1240
|
+
longPressFired.current = true;
|
|
1241
|
+
void openMenu(button.getBoundingClientRect());
|
|
1242
|
+
}, LONG_PRESS_MS);
|
|
1243
|
+
};
|
|
1244
|
+
const onPointerMove = (event) => {
|
|
1245
|
+
const origin = longPressOrigin.current;
|
|
1246
|
+
if (origin === null) return;
|
|
1247
|
+
if (Math.abs(event.clientX - origin.x) > LONG_PRESS_SLOP_PX || Math.abs(event.clientY - origin.y) > LONG_PRESS_SLOP_PX) {
|
|
1248
|
+
longPressOrigin.current = null;
|
|
1249
|
+
clearTimer();
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
const onPointerUp = () => {
|
|
1253
|
+
longPressOrigin.current = null;
|
|
1254
|
+
clearTimer();
|
|
1255
|
+
};
|
|
1256
|
+
const onKeyDown = (event) => {
|
|
1257
|
+
const menuKey = event.shiftKey && event.key === "F10" || event.key === "ContextMenu";
|
|
1258
|
+
if (!menuKey) return;
|
|
1259
|
+
if (document.activeElement !== button) return;
|
|
1260
|
+
event.preventDefault();
|
|
1261
|
+
void openMenu(button.getBoundingClientRect());
|
|
1262
|
+
};
|
|
1263
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1264
|
+
document.addEventListener("pointermove", onPointerMove, true);
|
|
1265
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1266
|
+
document.addEventListener("pointercancel", onPointerUp, true);
|
|
1267
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
1268
|
+
return () => {
|
|
1269
|
+
clearTimer();
|
|
1270
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1271
|
+
document.removeEventListener("pointermove", onPointerMove, true);
|
|
1272
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1273
|
+
document.removeEventListener("pointercancel", onPointerUp, true);
|
|
1274
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
1275
|
+
};
|
|
1276
|
+
}, [writer, settings.enabled, openMenu]);
|
|
611
1277
|
if (!settings.enabled) return null;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
"
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
1278
|
+
const statusTitle = busy ? t("button.busy") : otherBusy ? t("button.otherBusy") : empty ? t("button.emptyTitle") : t("button.title");
|
|
1279
|
+
const quickHint = writer === void 0 || busy || otherBusy ? "" : t("button.quickHint");
|
|
1280
|
+
const buttonLabel = statusTitle + quickHint;
|
|
1281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1283
|
+
"button",
|
|
1284
|
+
{
|
|
1285
|
+
ref: rootRef,
|
|
1286
|
+
type: "button",
|
|
1287
|
+
"data-dsh-pe-key": uiKey,
|
|
1288
|
+
className: `dsh-pe-btn${busy ? " is-busy" : ""}${otherBusy && !empty ? " is-blocked" : ""}${empty && !busy ? " is-empty" : ""}`,
|
|
1289
|
+
title: buttonLabel,
|
|
1290
|
+
"aria-label": statusTitle,
|
|
1291
|
+
"aria-haspopup": writer === void 0 ? void 0 : "menu",
|
|
1292
|
+
onContextMenu: (event) => {
|
|
1293
|
+
if (writer === void 0) return;
|
|
1294
|
+
event.preventDefault();
|
|
1295
|
+
void openMenu(event.currentTarget.getBoundingClientRect());
|
|
1296
|
+
},
|
|
1297
|
+
"aria-disabled": empty || otherBusy || void 0,
|
|
1298
|
+
onClick: () => {
|
|
1299
|
+
if (longPressFired.current) {
|
|
1300
|
+
longPressFired.current = false;
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
start();
|
|
1304
|
+
},
|
|
1305
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-pe-btn-icon", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SparkleFishIcon, { size: 15, spinning: busy }) })
|
|
1306
|
+
}
|
|
1307
|
+
),
|
|
1308
|
+
menu === null ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(QuickSettingsMenu, { t, data: menu.data, anchor: menu.anchor, error: menuError, onPick: pickEffort, onToggleContext: toggleContext, onClose: dismissMenu })
|
|
1309
|
+
] });
|
|
626
1310
|
}
|
|
627
1311
|
|
|
628
1312
|
// src/client/ResultDock.tsx
|
|
629
|
-
var
|
|
1313
|
+
var import_react7 = require("react");
|
|
630
1314
|
|
|
631
1315
|
// src/client/ResultPanel.tsx
|
|
632
|
-
var
|
|
1316
|
+
var import_react5 = require("react");
|
|
633
1317
|
|
|
634
1318
|
// src/client/ActionIcons.tsx
|
|
635
|
-
var
|
|
1319
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
636
1320
|
function icon(paths) {
|
|
637
|
-
return /* @__PURE__ */ (0,
|
|
1321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
638
1322
|
"svg",
|
|
639
1323
|
{
|
|
640
1324
|
width: 14,
|
|
@@ -653,21 +1337,65 @@ function icon(paths) {
|
|
|
653
1337
|
);
|
|
654
1338
|
}
|
|
655
1339
|
function RegenerateIcon() {
|
|
656
|
-
return icon([/* @__PURE__ */ (0,
|
|
1340
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M21 12a9 9 0 1 1-3-6.7L21 8" }, "arc"), /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M21 3v5h-5" }, "head")]);
|
|
657
1341
|
}
|
|
658
1342
|
function CopyIcon() {
|
|
659
|
-
return icon([/* @__PURE__ */ (0,
|
|
1343
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }, "front"), /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, "back")]);
|
|
660
1344
|
}
|
|
661
1345
|
function FillIcon() {
|
|
662
|
-
return icon([/* @__PURE__ */ (0,
|
|
1346
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 3v12" }, "stem"), /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m7 10 5 5 5-5" }, "head"), /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M5 21h14" }, "tray")]);
|
|
663
1347
|
}
|
|
664
1348
|
function UndoIcon() {
|
|
665
|
-
return icon([/* @__PURE__ */ (0,
|
|
1349
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 14 4 9l5-5" }, "head"), /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H8" }, "curve")]);
|
|
1350
|
+
}
|
|
1351
|
+
function CheckIcon() {
|
|
1352
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m20 6-11 11-5-5" }, "check")]);
|
|
1353
|
+
}
|
|
1354
|
+
function XIcon() {
|
|
1355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1356
|
+
"svg",
|
|
1357
|
+
{
|
|
1358
|
+
width: 18,
|
|
1359
|
+
height: 18,
|
|
1360
|
+
viewBox: "0 0 24 24",
|
|
1361
|
+
fill: "none",
|
|
1362
|
+
stroke: "currentColor",
|
|
1363
|
+
strokeWidth: 2,
|
|
1364
|
+
strokeLinecap: "round",
|
|
1365
|
+
strokeLinejoin: "round",
|
|
1366
|
+
"aria-hidden": "true",
|
|
1367
|
+
focusable: "false",
|
|
1368
|
+
style: { display: "block", flexShrink: 0 },
|
|
1369
|
+
children: [
|
|
1370
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M6 6l12 12" }),
|
|
1371
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M18 6 6 18" })
|
|
1372
|
+
]
|
|
1373
|
+
}
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
function ChevronIcon({ open }) {
|
|
1377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1378
|
+
"svg",
|
|
1379
|
+
{
|
|
1380
|
+
width: 20,
|
|
1381
|
+
height: 20,
|
|
1382
|
+
viewBox: "0 0 24 24",
|
|
1383
|
+
fill: "none",
|
|
1384
|
+
stroke: "currentColor",
|
|
1385
|
+
strokeWidth: 2,
|
|
1386
|
+
strokeLinecap: "round",
|
|
1387
|
+
strokeLinejoin: "round",
|
|
1388
|
+
"aria-hidden": "true",
|
|
1389
|
+
focusable: "false",
|
|
1390
|
+
style: { display: "block", flexShrink: 0, transform: open ? "none" : "rotate(-90deg)" },
|
|
1391
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
1392
|
+
}
|
|
1393
|
+
);
|
|
666
1394
|
}
|
|
667
1395
|
|
|
668
1396
|
// src/client/ResultPanel.tsx
|
|
669
|
-
var
|
|
670
|
-
var retryable = (
|
|
1397
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1398
|
+
var retryable = (error) => error?.code === "upstream" || error?.code === "timeout" || error?.code === "internal" && error.params?.reason !== "cancelled";
|
|
671
1399
|
var UPSTREAM_ERROR_KEYS = {
|
|
672
1400
|
auth: "error.upstream.auth",
|
|
673
1401
|
"invalid-credential": "error.upstream.invalidCredential",
|
|
@@ -738,18 +1466,23 @@ function fallbackCopy(text) {
|
|
|
738
1466
|
function formatTokens(tokens) {
|
|
739
1467
|
return tokens.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
740
1468
|
}
|
|
1469
|
+
function capitalizeEffort(value) {
|
|
1470
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
1471
|
+
}
|
|
741
1472
|
function totalTokensOf(usage) {
|
|
742
1473
|
return usage.totalTokens ?? usage.inputTokens + usage.outputTokens + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0);
|
|
743
1474
|
}
|
|
744
1475
|
function ResultPanel(props) {
|
|
745
|
-
const { state, t, onApply, onCancel, onRetry, applied = false, onUndo, onRegenerate, regenerated = false } = props;
|
|
746
|
-
const [copied, setCopied] = (0,
|
|
747
|
-
const
|
|
1476
|
+
const { state, t, onApply, onCancel, onRetry, applied = false, onUndo, onRegenerate, regenerated = false, collapsed = false, onToggleCollapsed, foldAnimation = true } = props;
|
|
1477
|
+
const [copied, setCopied] = (0, import_react5.useState)("idle");
|
|
1478
|
+
const copyTimer = (0, import_react5.useRef)(void 0);
|
|
1479
|
+
const copy = (0, import_react5.useCallback)(() => {
|
|
748
1480
|
if (state.result === void 0) return;
|
|
749
1481
|
const text = state.result.text;
|
|
750
1482
|
const done = (ok) => {
|
|
751
1483
|
setCopied(ok ? "ok" : "failed");
|
|
752
|
-
if (
|
|
1484
|
+
if (copyTimer.current !== void 0) clearTimeout(copyTimer.current);
|
|
1485
|
+
copyTimer.current = setTimeout(() => setCopied("idle"), 2500);
|
|
753
1486
|
};
|
|
754
1487
|
if (navigator.clipboard !== void 0) {
|
|
755
1488
|
navigator.clipboard.writeText(text).then(
|
|
@@ -771,79 +1504,87 @@ function ResultPanel(props) {
|
|
|
771
1504
|
}
|
|
772
1505
|
return parts.join(" \xB7 ");
|
|
773
1506
|
};
|
|
774
|
-
const swapLabel = (active, text) => /* @__PURE__ */ (0,
|
|
775
|
-
return /* @__PURE__ */ (0,
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
777
|
-
/* @__PURE__ */ (0,
|
|
778
|
-
/* @__PURE__ */ (0,
|
|
1507
|
+
const swapLabel = (active, text) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: active ? "on" : void 0, "aria-hidden": active ? void 0 : true, children: text });
|
|
1508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: `dsh-pe-panel${collapsed ? " is-collapsed" : ""}${foldAnimation ? "" : " is-static"}`, role: "region", "aria-label": t("panel.title"), children: [
|
|
1509
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: "dsh-pe-head", children: [
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-title", children: [
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SparkleFishIcon, { size: 15 }),
|
|
779
1512
|
t("panel.title")
|
|
780
1513
|
] }),
|
|
781
|
-
/* @__PURE__ */ (0,
|
|
782
|
-
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0,
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-head-actions", children: [
|
|
1515
|
+
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-badge", children: [
|
|
783
1516
|
t("panel.model", { provider: state.result.provider, model: state.result.model }),
|
|
1517
|
+
state.result.reasoningEffort === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1518
|
+
" \xB7 ",
|
|
1519
|
+
state.result.reasoningEffort === "inherit" ? t("panel.effortDefault") : capitalizeEffort(state.result.reasoningEffort)
|
|
1520
|
+
] }),
|
|
784
1521
|
" \xB7 ",
|
|
785
1522
|
t("panel.elapsed", { ms: formatMs(state.result.elapsedMs) }),
|
|
786
|
-
state.result.usage === void 0 ? null : /* @__PURE__ */ (0,
|
|
1523
|
+
state.result.usage === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
787
1524
|
" \xB7 ",
|
|
788
|
-
/* @__PURE__ */ (0,
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { title: tokenDetail(state.result.usage), children: t("panel.tokens", { total: formatTokens(totalTokensOf(state.result.usage)) }) })
|
|
789
1526
|
] })
|
|
790
1527
|
] }),
|
|
791
|
-
/* @__PURE__ */ (0,
|
|
1528
|
+
collapsed && (state.stale === true || state.result?.truncated === true) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-warn-dot", title: state.stale === true ? t("panel.stale.warn") : t("panel.truncated"), "aria-hidden": "true", children: "\u26A0" }) : null,
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "dsh-pe-collapse", "aria-label": collapsed ? t("panel.expand") : t("panel.collapse"), "aria-expanded": !collapsed, onClick: onToggleCollapsed, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronIcon, { open: !collapsed }) }),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "dsh-pe-close", "aria-label": t("panel.close"), onClick: onCancel, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(XIcon, {}) })
|
|
792
1531
|
] })
|
|
793
1532
|
] }),
|
|
794
|
-
|
|
795
|
-
/* @__PURE__ */ (0,
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
/* @__PURE__ */ (0,
|
|
800
|
-
/* @__PURE__ */ (0,
|
|
801
|
-
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-body", "aria-hidden": collapsed || void 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-body-inner", children: [
|
|
1534
|
+
state.phase === "loading" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-loading", children: state.streaming === void 0 || state.streaming === "" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-spin", "aria-hidden": true }),
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: t("panel.loading") }),
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-hint", children: t("panel.loading.hint") })
|
|
1538
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stream", children: [
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-col-title", children: [
|
|
1540
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-spin small", "aria-hidden": true }),
|
|
1541
|
+
t("panel.streaming")
|
|
1542
|
+
] }),
|
|
1543
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: "dsh-pe-result-text", children: state.streaming })
|
|
1544
|
+
] }) }),
|
|
1545
|
+
state.phase === "error" && state.error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-error", children: state.error.localized !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: state.error.localized }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: localizedErrorMessage(t, state.error.code, state.error.params) }),
|
|
1547
|
+
state.error.message !== void 0 && state.error.message !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-error-detail", children: state.error.message })
|
|
1548
|
+
] }) }),
|
|
1549
|
+
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-result", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: "dsh-pe-result-text", children: state.result.text }) }),
|
|
1550
|
+
state.phase === "result" && state.result?.truncated === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stale", children: [
|
|
1551
|
+
"\u26A0 ",
|
|
1552
|
+
t("panel.truncated")
|
|
802
1553
|
] }),
|
|
803
|
-
/* @__PURE__ */ (0,
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
state.error.message !== void 0 && state.error.message !== "" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsh-pe-error-detail", children: state.error.message })
|
|
1554
|
+
state.phase === "result" && state.stale && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stale", children: [
|
|
1555
|
+
"\u26A0 ",
|
|
1556
|
+
t("panel.stale.warn")
|
|
1557
|
+
] })
|
|
808
1558
|
] }) }),
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
"
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
state.phase === "result" && state.stale && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-pe-stale", children: [
|
|
815
|
-
"\u26A0 ",
|
|
816
|
-
t("panel.stale.warn")
|
|
817
|
-
] }),
|
|
818
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("footer", { className: "dsh-pe-foot", children: [
|
|
819
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-grow" }),
|
|
820
|
-
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-swap", onClick: onRegenerate, disabled: onRegenerate === void 0, children: [
|
|
821
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RegenerateIcon, {}),
|
|
822
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
1559
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("footer", { className: "dsh-pe-foot", children: [
|
|
1560
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-grow" }),
|
|
1561
|
+
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: onRegenerate, disabled: onRegenerate === void 0, children: [
|
|
1562
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RegenerateIcon, {}),
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
823
1564
|
swapLabel(!regenerated, t("panel.regenerate")),
|
|
824
1565
|
swapLabel(regenerated, t("panel.regenerated"))
|
|
825
1566
|
] })
|
|
826
1567
|
] }),
|
|
827
|
-
state.phase === "error" && /* @__PURE__ */ (0,
|
|
828
|
-
state.phase === "loading" && /* @__PURE__ */ (0,
|
|
829
|
-
state.phase === "result" && /* @__PURE__ */ (0,
|
|
830
|
-
/* @__PURE__ */ (0,
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
832
|
-
/* @__PURE__ */ (0,
|
|
1568
|
+
state.phase === "error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: retryable(state.error) && onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: onRetry, children: t("panel.retry") }) }),
|
|
1569
|
+
state.phase === "loading" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: onCancel, children: t("panel.cancel") }),
|
|
1570
|
+
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: copy, children: [
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyIcon, {}),
|
|
1573
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
833
1574
|
swapLabel(copied === "idle", t("panel.copy")),
|
|
834
1575
|
swapLabel(copied === "ok", t("panel.copied")),
|
|
835
1576
|
swapLabel(copied === "failed", t("panel.copyFailed"))
|
|
836
1577
|
] })
|
|
837
1578
|
] }),
|
|
838
|
-
applied ? /* @__PURE__ */ (0,
|
|
839
|
-
/* @__PURE__ */ (0,
|
|
840
|
-
/* @__PURE__ */ (0,
|
|
1579
|
+
applied ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action primary dsh-pe-btn-floor", onClick: onUndo, disabled: onUndo === void 0, children: [
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UndoIcon, {}),
|
|
1581
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
841
1582
|
swapLabel(true, t("undo.undo")),
|
|
842
1583
|
swapLabel(false, t("panel.apply"))
|
|
843
1584
|
] })
|
|
844
|
-
] }) : /* @__PURE__ */ (0,
|
|
845
|
-
/* @__PURE__ */ (0,
|
|
846
|
-
/* @__PURE__ */ (0,
|
|
1585
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action primary dsh-pe-btn-floor", onClick: onApply, children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FillIcon, {}),
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
847
1588
|
swapLabel(true, t("panel.apply")),
|
|
848
1589
|
swapLabel(false, t("undo.undo"))
|
|
849
1590
|
] })
|
|
@@ -854,7 +1595,7 @@ function ResultPanel(props) {
|
|
|
854
1595
|
}
|
|
855
1596
|
|
|
856
1597
|
// src/client/useDockAlignment.ts
|
|
857
|
-
var
|
|
1598
|
+
var import_react6 = require("react");
|
|
858
1599
|
var EDITOR_SELECTOR = 'textarea, [contenteditable="true"], [role="textbox"]';
|
|
859
1600
|
var SESSION_ANCHOR_ATTRIBUTE = "data-dsh-pe-key";
|
|
860
1601
|
var CARD_MIN_WIDTH = 360;
|
|
@@ -882,8 +1623,8 @@ function editorsIn(scope) {
|
|
|
882
1623
|
return Array.from(scope.querySelectorAll(EDITOR_SELECTOR));
|
|
883
1624
|
}
|
|
884
1625
|
function useDockAlignment(active, uiKey) {
|
|
885
|
-
const rootRef = (0,
|
|
886
|
-
(0,
|
|
1626
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
1627
|
+
(0, import_react6.useEffect)(() => {
|
|
887
1628
|
if (!active) return;
|
|
888
1629
|
const root = rootRef.current;
|
|
889
1630
|
if (root === null) return;
|
|
@@ -960,12 +1701,13 @@ function useDockAlignment(active, uiKey) {
|
|
|
960
1701
|
}
|
|
961
1702
|
|
|
962
1703
|
// src/client/ResultDock.tsx
|
|
963
|
-
var
|
|
1704
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
964
1705
|
var REGENERATED_NOTICE_MS = 2500;
|
|
965
1706
|
function ResultDock(props) {
|
|
966
1707
|
const { t, sessionId, useInput, inputActions } = props;
|
|
967
1708
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
968
|
-
const panel = (0,
|
|
1709
|
+
const panel = (0, import_react7.useSyncExternalStore)(subscribe, getPanel);
|
|
1710
|
+
const settings = (0, import_react7.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
969
1711
|
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey, uiKey);
|
|
970
1712
|
const draft = useInput((state) => {
|
|
971
1713
|
const value = state.draft;
|
|
@@ -986,11 +1728,11 @@ function ResultDock(props) {
|
|
|
986
1728
|
);
|
|
987
1729
|
const entry = peekUndo(uiKey);
|
|
988
1730
|
const applied = entry !== void 0 && entry.applied === draft;
|
|
989
|
-
const [regeneratedNotice, setRegeneratedNotice] = (0,
|
|
990
|
-
const pendingRegenerate = (0,
|
|
991
|
-
const previousResultRef = (0,
|
|
992
|
-
const prevSession = (0,
|
|
993
|
-
(0,
|
|
1731
|
+
const [regeneratedNotice, setRegeneratedNotice] = (0, import_react7.useState)(false);
|
|
1732
|
+
const pendingRegenerate = (0, import_react7.useRef)(false);
|
|
1733
|
+
const previousResultRef = (0, import_react7.useRef)(void 0);
|
|
1734
|
+
const prevSession = (0, import_react7.useRef)({ running: sessionRunning, queued: sessionQueued });
|
|
1735
|
+
(0, import_react7.useEffect)(() => {
|
|
994
1736
|
const prev = prevSession.current;
|
|
995
1737
|
prevSession.current = { running: sessionRunning, queued: sessionQueued };
|
|
996
1738
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
@@ -998,7 +1740,7 @@ function ResultDock(props) {
|
|
|
998
1740
|
closePanel();
|
|
999
1741
|
}
|
|
1000
1742
|
}, [phase, sessionRunning, sessionQueued, panel, uiKey]);
|
|
1001
|
-
(0,
|
|
1743
|
+
(0, import_react7.useEffect)(() => {
|
|
1002
1744
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
1003
1745
|
const onKeyDown = (event) => {
|
|
1004
1746
|
if (event.defaultPrevented || event.isComposing || event.key !== "Escape") return;
|
|
@@ -1008,7 +1750,7 @@ function ResultDock(props) {
|
|
|
1008
1750
|
document.addEventListener("keydown", onKeyDown);
|
|
1009
1751
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
1010
1752
|
}, [panel, uiKey]);
|
|
1011
|
-
(0,
|
|
1753
|
+
(0, import_react7.useEffect)(() => {
|
|
1012
1754
|
if (!pendingRegenerate.current) return;
|
|
1013
1755
|
if (panel === void 0 || panel.sessionId !== uiKey || panel.phase === "error") {
|
|
1014
1756
|
pendingRegenerate.current = false;
|
|
@@ -1019,7 +1761,7 @@ function ResultDock(props) {
|
|
|
1019
1761
|
setRegeneratedNotice(true);
|
|
1020
1762
|
}
|
|
1021
1763
|
}, [panel, uiKey]);
|
|
1022
|
-
(0,
|
|
1764
|
+
(0, import_react7.useEffect)(() => {
|
|
1023
1765
|
if (!regeneratedNotice) return;
|
|
1024
1766
|
const timer = setTimeout(() => setRegeneratedNotice(false), REGENERATED_NOTICE_MS);
|
|
1025
1767
|
return () => clearTimeout(timer);
|
|
@@ -1029,11 +1771,13 @@ function ResultDock(props) {
|
|
|
1029
1771
|
if (panel.phase !== "result" || panel.result === void 0) return;
|
|
1030
1772
|
pushUndo(uiKey, { original: draft, applied: panel.result.text });
|
|
1031
1773
|
inputActions.setDraft(panel.result.text);
|
|
1774
|
+
if (settings.autoFold) setCollapsed(uiKey, true);
|
|
1032
1775
|
};
|
|
1033
1776
|
const undo = () => {
|
|
1034
1777
|
if (entry === void 0) return;
|
|
1035
1778
|
inputActions.setDraft(entry.original);
|
|
1036
1779
|
popUndo(uiKey);
|
|
1780
|
+
if (settings.autoFold) setCollapsed(uiKey, false);
|
|
1037
1781
|
};
|
|
1038
1782
|
const regenerate = () => {
|
|
1039
1783
|
if (panel.phase !== "result") return;
|
|
@@ -1042,13 +1786,16 @@ function ResultDock(props) {
|
|
|
1042
1786
|
pendingRegenerate.current = true;
|
|
1043
1787
|
runSession(uiKey);
|
|
1044
1788
|
};
|
|
1045
|
-
return /* @__PURE__ */ (0,
|
|
1789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: rootRef, className: "dsh-pe-dock", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1046
1790
|
ResultPanel,
|
|
1047
1791
|
{
|
|
1048
1792
|
state: panel,
|
|
1049
1793
|
t,
|
|
1050
1794
|
applied,
|
|
1051
1795
|
regenerated: regeneratedNotice,
|
|
1796
|
+
collapsed: panel.collapsed === true,
|
|
1797
|
+
onToggleCollapsed: () => setCollapsed(uiKey, panel.collapsed !== true),
|
|
1798
|
+
foldAnimation: settings.foldAnimation,
|
|
1052
1799
|
onApply: apply2,
|
|
1053
1800
|
onUndo: undo,
|
|
1054
1801
|
onRegenerate: regenerate,
|
|
@@ -1059,8 +1806,8 @@ function ResultDock(props) {
|
|
|
1059
1806
|
}
|
|
1060
1807
|
|
|
1061
1808
|
// src/client/UndoBar.tsx
|
|
1062
|
-
var
|
|
1063
|
-
var
|
|
1809
|
+
var import_react8 = require("react");
|
|
1810
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1064
1811
|
function UndoBar(props) {
|
|
1065
1812
|
const { t, sessionId, useInput, inputActions } = props;
|
|
1066
1813
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
@@ -1068,9 +1815,9 @@ function UndoBar(props) {
|
|
|
1068
1815
|
const value = state.draft;
|
|
1069
1816
|
return typeof value === "string" ? value : "";
|
|
1070
1817
|
});
|
|
1071
|
-
(0,
|
|
1818
|
+
(0, import_react8.useSyncExternalStore)(subscribe, getVersion);
|
|
1072
1819
|
const entry = peekUndo(uiKey);
|
|
1073
|
-
(0,
|
|
1820
|
+
(0, import_react8.useEffect)(() => {
|
|
1074
1821
|
if (entry !== void 0 && entry.applied !== draft) popUndo(uiKey);
|
|
1075
1822
|
}, [draft, entry, uiKey]);
|
|
1076
1823
|
const panel = getPanel();
|
|
@@ -1084,23 +1831,36 @@ function UndoBar(props) {
|
|
|
1084
1831
|
const dismiss = () => {
|
|
1085
1832
|
popUndo(uiKey);
|
|
1086
1833
|
};
|
|
1087
|
-
return /* @__PURE__ */ (0,
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1090
|
-
/* @__PURE__ */ (0,
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: rootRef, className: "dsh-pe-dock", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-undo", children: [
|
|
1835
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsh-pe-undo-check", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckIcon, {}) }),
|
|
1836
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: t("undo.applied") }),
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "dsh-pe-undo-link", onClick: undo, children: [
|
|
1838
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UndoIcon, {}),
|
|
1092
1839
|
t("undo.undo")
|
|
1093
1840
|
] }),
|
|
1094
|
-
/* @__PURE__ */ (0,
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "dsh-pe-undo-x", "aria-label": t("undo.dismiss"), onClick: dismiss, children: "\u2715" })
|
|
1095
1842
|
] }) });
|
|
1096
1843
|
}
|
|
1097
1844
|
|
|
1098
1845
|
// src/client/locales.ts
|
|
1099
1846
|
var zh = {
|
|
1100
|
-
"button.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1847
|
+
"button.title": "\u63D0\u793A\u8BCD\u589E\u5F3A \xB7 \u4F18\u5316\u8F93\u5165\u6846\u91CC\u7684\u6587\u5B57",
|
|
1101
1848
|
"button.busy": "\u6B63\u5728\u589E\u5F3A\u2026",
|
|
1102
|
-
"button.otherBusy": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u6B63\u5728\u589E\u5F3A\u4E2D
|
|
1103
|
-
"button.emptyTitle": "\u63D0\u793A\u8BCD\u589E\u5F3A\
|
|
1849
|
+
"button.otherBusy": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u6B63\u5728\u589E\u5F3A\u4E2D",
|
|
1850
|
+
"button.emptyTitle": "\u63D0\u793A\u8BCD\u589E\u5F3A \xB7 \u8BF7\u5148\u8F93\u5165\u8981\u4F18\u5316\u7684\u6587\u5B57",
|
|
1851
|
+
"button.quickHint": "\uFF08\u53F3\u952E\u914D\u7F6E\uFF09",
|
|
1852
|
+
"menu.title": "\u5FEB\u6377\u8BBE\u7F6E",
|
|
1853
|
+
"menu.model": "\u6A21\u578B",
|
|
1854
|
+
"menu.modelFollow": "\u8DDF\u968F\u4F1A\u8BDD",
|
|
1855
|
+
"menu.modelHint": "\u5728\u63D2\u4EF6\u8BBE\u7F6E\u9875\u4FEE\u6539",
|
|
1856
|
+
"menu.effortsNone": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D",
|
|
1857
|
+
"menu.effortsFailed": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D",
|
|
1858
|
+
"menu.effort": "\u63A8\u7406\u7B49\u7EA7",
|
|
1859
|
+
"menu.effortDefault": "\u4E0D\u6307\u5B9A",
|
|
1860
|
+
"menu.context": "\u4E0A\u4E0B\u6587\u611F\u77E5",
|
|
1861
|
+
"menu.contextOn": "\u5F00",
|
|
1862
|
+
"menu.contextOff": "\u5173",
|
|
1863
|
+
"menu.writeFailed": "\u5199\u5165\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1104
1864
|
"panel.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1105
1865
|
"panel.loading": "\u6B63\u5728\u589E\u5F3A\uFF0C\u7A0D\u5019\u2026",
|
|
1106
1866
|
"panel.streaming": "\u6B63\u5728\u751F\u6210\u2026",
|
|
@@ -1115,12 +1875,15 @@ var zh = {
|
|
|
1115
1875
|
"panel.copied": "\u5DF2\u590D\u5236",
|
|
1116
1876
|
"panel.copyFailed": "\u590D\u5236\u5931\u8D25",
|
|
1117
1877
|
"panel.close": "\u5173\u95ED",
|
|
1878
|
+
"panel.collapse": "\u6298\u53E0",
|
|
1879
|
+
"panel.expand": "\u5C55\u5F00",
|
|
1118
1880
|
"panel.retry": "\u91CD\u8BD5",
|
|
1119
|
-
"panel.stale.warn": "\u8349\u7A3F\u5DF2\u6539\u52A8\uFF0C\u5F53\u524D\u7ED3\u679C\u57FA\u4E8E\
|
|
1120
|
-
"panel.truncated": "\u8F93\u51FA\u8FBE\u5230
|
|
1881
|
+
"panel.stale.warn": "\u8349\u7A3F\u5DF2\u6539\u52A8\uFF0C\u5F53\u524D\u7ED3\u679C\u57FA\u4E8E\u65E7\u6587\u672C\u3002\u300C\u91CD\u65B0\u751F\u6210\u300D\u4F1A\u6309\u5F53\u524D\u6587\u672C\u91CD\u8DD1\uFF1B\u56DE\u586B\u4ECD\u4F1A\u8986\u76D6\u5F53\u524D\u8F93\u5165\uFF08\u53EF\u64A4\u9500\uFF09\u3002",
|
|
1882
|
+
"panel.truncated": "\u8F93\u51FA\u88AB\u622A\u65AD\uFF08\u8FBE\u5230\u8F93\u51FA\u4E0A\u9650\uFF09\uFF0C\u7ED3\u679C\u53EF\u80FD\u4E0D\u5B8C\u6574\u3002\u53EF\u5728\u8BBE\u7F6E\u91CC\u8C03\u9AD8\u300C\u8F93\u51FA token \u4E0A\u9650\u300D\u540E\u91CD\u65B0\u751F\u6210\u3002",
|
|
1121
1883
|
"panel.model": "\u6A21\u578B\uFF1A{provider} / {model}",
|
|
1122
1884
|
"panel.elapsed": "\u8017\u65F6 {ms}",
|
|
1123
1885
|
"panel.tokens": "{total} tokens",
|
|
1886
|
+
"panel.effortDefault": "\u4E0D\u6307\u5B9A",
|
|
1124
1887
|
"panel.tokens.input": "\u8F93\u5165 {count}",
|
|
1125
1888
|
"panel.tokens.output": "\u8F93\u51FA {count}",
|
|
1126
1889
|
"panel.tokens.cacheRead": "\u7F13\u5B58\u8BFB\u53D6 {count}",
|
|
@@ -1129,17 +1892,17 @@ var zh = {
|
|
|
1129
1892
|
"undo.undo": "\u64A4\u9500",
|
|
1130
1893
|
"undo.dismiss": "\u5173\u95ED\u63D0\u793A",
|
|
1131
1894
|
"error.empty": "\u8F93\u5165\u6846\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u8F93\u5165\u8981\u589E\u5F3A\u7684\u63D0\u793A\u8BCD\u3002",
|
|
1132
|
-
"error.tooLong": "\u5185\u5BB9
|
|
1895
|
+
"error.tooLong": "\u5185\u5BB9 {count} \u5B57\uFF0C\u8D85\u8FC7 {max} \u5B57\u4E0A\u9650\uFF08\u6309\u5B57\u7B26\u8BA1\uFF0C\u975E token\uFF09\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u622A\u65AD\uFF0C\u8BF7\u7CBE\u7B80\u540E\u91CD\u8BD5\u3002",
|
|
1133
1896
|
"error.occurrences": "\u8F93\u5165\u5185\u5BB9\u5305\u542B\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u6682\u4E0D\u652F\u6301\u589E\u5F3A\uFF1B\u8BF7\u5148\u79FB\u9664\u540E\u518D\u8BD5\u3002",
|
|
1134
|
-
"error.chipsUnknown": "\u65E0\u6CD5\u8BFB\u53D6\u8F93\u5165\u6846\u7684\u5F15\u7528\u72B6\u6001\
|
|
1897
|
+
"error.chipsUnknown": "\u65E0\u6CD5\u8BFB\u53D6\u8F93\u5165\u6846\u91CC\u7684\u5F15\u7528\u72B6\u6001\uFF1B\u4E3A\u907F\u514D\u8986\u76D6\u4F60\u7684\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u672C\u6B21\u5DF2\u963B\u6B62\u3002\u8BF7\u6539\u4E3A\u7EAF\u6587\u672C\u540E\u91CD\u8BD5\u3002",
|
|
1135
1898
|
"error.phase": "\u5F53\u524D\u8F93\u5165\u6B63\u88AB\u5360\u7528\uFF08\u63D0\u4EA4\u4E2D\uFF09\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1136
|
-
"error.disabled": "\u63D0\u793A\u8BCD\u589E\u5F3A\u5DF2\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002",
|
|
1137
|
-
"error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002",
|
|
1138
|
-
"error.timeout": "\u589E\u5F3A\u8D85\u65F6\uFF08{seconds} \u79D2\uFF09\
|
|
1139
|
-
"error.unconfigured": "\
|
|
1140
|
-
"error.effortUnsupported": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u6863\u4F4D\u300C{effort}\u300D\uFF0C\u8BF7\u6539\u9009\u5176\u5B83\u6863\u4F4D\uFF0C\u6216\u6539\u7528\u300C\
|
|
1141
|
-
"error.upstream": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\
|
|
1142
|
-
"error.internal": "\u589E\u5F3A\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1899
|
+
"error.disabled": "\u63D0\u793A\u8BCD\u589E\u5F3A\u5DF2\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u5173\u95ED\uFF0C\u53EF\u5728\u8BBE\u7F6E\u91CC\u91CD\u65B0\u5F00\u542F\u3002",
|
|
1900
|
+
"error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u51FA\u73B0\uFF0C\u8BF7\u68C0\u67E5\u63D2\u4EF6\u8BBE\u7F6E\u3002",
|
|
1901
|
+
"error.timeout": "\u589E\u5F3A\u8D85\u65F6\uFF08{seconds} \u79D2\uFF09\u3002\u53EF\u76F4\u63A5\u91CD\u8BD5\uFF0C\u6216\u5230\u8BBE\u7F6E\u91CC\u8C03\u9AD8\u300C\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09\u300D\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1902
|
+
"error.unconfigured": "\u8FD8\u6CA1\u786E\u5B9A\u7528\u54EA\u4E2A\u6A21\u578B\uFF1A\u8BF7\u5728\u63D2\u4EF6\u8BBE\u7F6E\u91CC\u586B\u5199 provider \u548C model\uFF08\u4E24\u9879\u90FD\u8981\u586B\uFF09\uFF0C\u6216\u5728\u5F53\u524D\u4F1A\u8BDD\u5148\u53D1\u4E00\u6761\u6D88\u606F\u4EE5\u8DDF\u968F\u4F1A\u8BDD\u6A21\u578B\u3002",
|
|
1903
|
+
"error.effortUnsupported": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u6863\u4F4D\u300C{effort}\u300D\uFF0C\u8BF7\u6539\u9009\u5176\u5B83\u6863\u4F4D\uFF0C\u6216\u6539\u7528\u300C\u4E0D\u6307\u5B9A\u300D\u3002",
|
|
1904
|
+
"error.upstream": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF1B\u82E5\u4E0B\u65B9\u6709\u8BE6\u60C5\uFF0C\u8BF7\u6309\u8BE6\u60C5\u5904\u7406\uFF0C\u5426\u5219\u53EF\u76F4\u63A5\u91CD\u8BD5\u3002\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1905
|
+
"error.internal": "\u589E\u5F3A\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u53CD\u590D\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B dsh \u8FD0\u884C\u65E5\u5FD7\u3002\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1143
1906
|
"error.client.unreachable": "\u65E0\u6CD5\u8FDE\u63A5\u5BBF\u4E3B\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 dsh web \u6B63\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002",
|
|
1144
1907
|
"error.client.malformed": "\u5BBF\u4E3B\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6CD5\u89E3\u6790\u7684\u6570\u636E\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1145
1908
|
"error.client.refused": "\u5BBF\u4E3B\u670D\u52A1\u62D2\u7EDD\u4E86\u8BF7\u6C42\uFF08HTTP {status}\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1147,7 +1910,7 @@ var zh = {
|
|
|
1147
1910
|
"error.client.cancelled": "\u5DF2\u53D6\u6D88\u589E\u5F3A\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1148
1911
|
"error.rateLimit": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF1A\u6BCF\u5206\u949F\u6700\u591A {limit} \u6B21\u589E\u5F3A\uFF0C\u8BF7\u5728 {retryAfterSeconds} \u79D2\u540E\u518D\u8BD5\u3002",
|
|
1149
1912
|
"error.concurrencyLimit": "\u5DF2\u6709 {max} \u4E2A\u589E\u5F3A\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u7B49\u5176\u4E2D\u4E00\u4E2A\u5B8C\u6210\u540E\u518D\u8BD5\u3002",
|
|
1150
|
-
"error.cooldown": "\u8FDE\u7EED {failures} \u6B21\u589E\u5F3A\u5931\u8D25\uFF0C\u5DF2\u6682\u505C\
|
|
1913
|
+
"error.cooldown": "\u8FDE\u7EED {failures} \u6B21\u589E\u5F3A\u5931\u8D25\uFF0C\u5DF2\u6682\u505C {retryAfterSeconds} \u79D2\u4EE5\u514D\u6301\u7EED\u51B2\u51FB\u6A21\u578B\u670D\u52A1\uFF1B\u53EF\u7A0D\u540E\u91CD\u8BD5\uFF0C\u6216\u5148\u68C0\u67E5\u6A21\u578B\u914D\u7F6E\u3002",
|
|
1151
1914
|
"error.upstream.auth": "\u9274\u6743\u5931\u8D25\uFF1A\u8BF7\u68C0\u67E5\u8BE5 provider \u7684 API Key \u914D\u7F6E\u3002",
|
|
1152
1915
|
"error.upstream.invalidCredential": "\u9274\u6743\u5931\u8D25\uFF1A\u5B58\u50A8\u7684 API Key \u4E0D\u53EF\u7528\uFF0C\u8BF7\u4FEE\u6B63\u540E\u91CD\u8BD5\u3002",
|
|
1153
1916
|
"error.upstream.rateLimit": "\u6A21\u578B\u670D\u52A1\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1155,7 +1918,7 @@ var zh = {
|
|
|
1155
1918
|
"error.upstream.empty": "\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1156
1919
|
"error.upstream.contextWindow": "\u8F93\u5165\u8D85\u51FA\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\uFF0C\u8BF7\u7CBE\u7B80\u539F\u6587\u6216\u66F4\u6362\u6A21\u578B\u3002",
|
|
1157
1920
|
"error.upstream.toolCall": "\u6A21\u578B\u8BF7\u6C42\u4E86\u5DE5\u5177\u8C03\u7528\uFF0C\u63D0\u793A\u8BCD\u589E\u5F3A\u53EA\u9700\u8981\u7EAF\u6587\u672C\uFF1B\u8BF7\u66F4\u6362\u6A21\u578B\u540E\u91CD\u8BD5\u3002",
|
|
1158
|
-
"error.upstream.maxTokens": "\u91CD\u5199\u7ED3\u679C\u8FBE\u5230\u8F93\u51FA\u4E0A\u9650\
|
|
1921
|
+
"error.upstream.maxTokens": "\u91CD\u5199\u7ED3\u679C\u8FBE\u5230\u300C\u8F93\u51FA token \u4E0A\u9650\u300D\uFF0C\u8BF7\u8C03\u9AD8\u8BE5\u8BBE\u7F6E\u6216\u7CBE\u7B80\u539F\u6587\u540E\u91CD\u8BD5\u3002",
|
|
1159
1922
|
"settings.summary": "\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D44\u6E90\u9650\u5236",
|
|
1160
1923
|
"settings.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1161
1924
|
"settings.description": "\u628A\u8F93\u5165\u6846\u8349\u7A3F\u6539\u5199\u4E3A\u7ED3\u6784\u5316\u63D0\u793A\u8BCD\uFF1A\u89D2\u8272\u4E0E\u76EE\u6807\u3001\u53EF\u6267\u884C\u6B65\u9AA4\u3001\u8F93\u51FA\u683C\u5F0F\u3001\u9A8C\u6536\u6807\u51C6\u3001\u8FB9\u754C\u6761\u4EF6\u3002\u539F\u6587\u4FDD\u7559\uFF0C\u5931\u8D25\u4E0D\u6539\u8349\u7A3F\uFF1B\u4FDD\u5B58\u540E\u4E0B\u4E00\u6B21\u8C03\u7528\u5373\u751F\u6548\u3002",
|
|
@@ -1169,6 +1932,11 @@ var zh = {
|
|
|
1169
1932
|
"settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
|
|
1170
1933
|
"settings.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
1171
1934
|
"settings.invalidNumber": "\u8BF7\u586B\u6570\u5B57\uFF1B\u7559\u7A7A\u8868\u793A\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
|
|
1935
|
+
"settings.record": "\u5F55\u5236",
|
|
1936
|
+
"settings.recordStop": "\u53D6\u6D88\u5F55\u5236",
|
|
1937
|
+
"settings.recordPrompt": "\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\uFF08Esc \u53D6\u6D88\uFF09",
|
|
1938
|
+
"settings.recordNeedsModifier": "\u9700\u8981\u81F3\u5C11\u6309\u4F4F ctrl / alt / meta \u4E2D\u7684\u4E00\u4E2A",
|
|
1939
|
+
"settings.invalidShortcut": "\u5199\u6CD5\u65E0\u6548\uFF0C\u5FEB\u6377\u952E\u4E0D\u4F1A\u751F\u6548\uFF1A\u9700\u5305\u542B ctrl / alt / meta \u4E2D\u81F3\u5C11\u4E00\u4E2A\uFF0C\u952E\u653E\u5728\u6700\u540E\uFF0C\u4F8B\u5982 ctrl+alt+e\u3002",
|
|
1172
1940
|
"settings.disconnected": "\u8868\u5355\u6CA1\u6709\u63A5\u901A\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u5411\u8FD9\u4E2A\u9875\u9762\u6CE8\u5165\u8868\u5355\u72B6\u6001\u3002\u63D2\u4EF6\u4ECD\u6309\u7EC4\u5408\u914D\u7F6E\u5DE5\u4F5C\u3002",
|
|
1173
1941
|
"settings.row.enabled.label": "\u603B\u5F00\u5173",
|
|
1174
1942
|
"settings.row.enabled.hint": "\u5173\u95ED\u540E\u9690\u85CF\u8F93\u5165\u6846\u7684\u589E\u5F3A\u6309\u94AE\uFF0C\u547D\u4EE4\u4E0E\u5FEB\u6377\u952E\u4E00\u5E76\u505C\u7528\u3002",
|
|
@@ -1176,6 +1944,10 @@ var zh = {
|
|
|
1176
1944
|
"settings.row.contextAware.hint": "\u8BFB\u53D6\u5F53\u524D\u4F1A\u8BDD\u6700\u8FD1\u51E0\u8F6E\u5BF9\u8BDD\u6765\u6D88\u89E3\u6307\u4EE3\u3001\u8865\u5168\u7701\u7565\uFF1B\u65E0\u5386\u53F2\u65F6\u56DE\u9000\u4E3A\u5355\u6761\u589E\u5F3A\u3002",
|
|
1177
1945
|
"settings.row.streaming.label": "\u589E\u91CF\u5C55\u793A",
|
|
1178
1946
|
"settings.row.streaming.hint": "\u6A21\u578B\u8FB9\u5199\u8FB9\u5728\u9762\u677F\u663E\u793A\uFF1B\u4EC5\u5F71\u54CD\u663E\u793A\u8282\u594F\uFF0C\u6700\u7EC8\u5199\u5165\u7684\u6587\u672C\u4E0D\u53D8\u3002",
|
|
1947
|
+
"settings.row.foldAnimation.label": "\u5361\u7247\u6298\u53E0\u52A8\u753B",
|
|
1948
|
+
"settings.row.foldAnimation.hint": "\u5C55\u5F00/\u6536\u8D77\u65F6\u64AD\u653E\u8FC7\u6E21\uFF1B\u5173\u95ED\u540E\u7ACB\u5373\u5207\u6362\u3002\u7CFB\u7EDF\u300C\u51CF\u5C11\u52A8\u6001\u6548\u679C\u300D\u504F\u597D\u59CB\u7EC8\u4F18\u5148\u3002",
|
|
1949
|
+
"settings.row.autoFold.label": "\u81EA\u52A8\u6536\u7EB3\u5361\u7247",
|
|
1950
|
+
"settings.row.autoFold.hint": "\u56DE\u586B\u5230\u8F93\u5165\u6846\u540E\u81EA\u52A8\u6536\u8D77\u5361\u7247\uFF0C\u64A4\u9500\u540E\u81EA\u52A8\u5C55\u5F00\uFF1B\u5173\u95ED\u540E\u5361\u7247\u4FDD\u6301\u5F53\u524D\u72B6\u6001\u3002",
|
|
1179
1951
|
"settings.row.provider.label": "\u6A21\u578B\u670D\u52A1\u65B9",
|
|
1180
1952
|
"settings.row.provider.hint": "\u4ECE DSH \u5DF2\u6CE8\u518C\u7684 LLM provider \u4E2D\u9009\u62E9\uFF1B\u7559\u7A7A\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\u7684\u6A21\u578B\u3002",
|
|
1181
1953
|
"settings.row.model.label": "\u6A21\u578B ID",
|
|
@@ -1202,7 +1974,7 @@ var zh = {
|
|
|
1202
1974
|
"settings.row.temperature.label": "\u6E29\u5EA6",
|
|
1203
1975
|
"settings.row.temperature.hint": "\u91C7\u6837\u6E29\u5EA6\uFF080~1\uFF0C\u6B65\u8FDB 0.05\uFF09\uFF0C\u8D8A\u4F4E\u8D8A\u5FE0\u5B9E\u539F\u6587\uFF1B\u9ED8\u8BA4 0.3\u3002",
|
|
1204
1976
|
"settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
|
|
1205
|
-
"settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\
|
|
1977
|
+
"settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u300C\u4E0D\u6307\u5B9A\u300D\u8868\u793A\u4E0D\u4F20\u8BE5\u5B57\u6BB5\u3002",
|
|
1206
1978
|
"settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
|
|
1207
1979
|
"settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
|
|
1208
1980
|
"settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
|
|
@@ -1227,23 +1999,36 @@ var zh = {
|
|
|
1227
1999
|
"settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
|
|
1228
2000
|
"settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
|
|
1229
2001
|
"settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
|
|
1230
|
-
"settings.reasoning.inherit": "\
|
|
2002
|
+
"settings.reasoning.inherit": "\u4E0D\u6307\u5B9A",
|
|
1231
2003
|
"settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
|
|
1232
2004
|
"settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u5217\u8868\uFF1B\u5DF2\u4FDD\u5B58\u7684\u6863\u4F4D\u4ECD\u4F1A\u7167\u5E38\u53D1\u9001\u3002",
|
|
1233
|
-
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\
|
|
2005
|
+
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF1B\u8C03\u7528\u65F6\u4E0D\u53D1\u9001\u6863\u4F4D\uFF0C\u7531\u63D0\u4F9B\u65B9\u51B3\u5B9A\u3002",
|
|
1234
2006
|
"settings.reasoning.unsupported": "\u5F53\u524D\u503C\u300C{effort}\u300D\u4E0D\u5728\u8BE5\u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\u4E2D\u3002",
|
|
1235
2007
|
"settings.reasoning.current": "\u5F53\u524D\u503C\uFF1A{value}",
|
|
1236
2008
|
"settings.reasoning.currentTitle": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u6B64\u6863\u4F4D",
|
|
1237
|
-
"settings.reasoning.refresh": "\
|
|
2009
|
+
"settings.reasoning.refresh": "\u5237\u65B0",
|
|
1238
2010
|
"settings.reasoning.refreshing": "\u6B63\u5728\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u2026",
|
|
1239
2011
|
"settings.reasoning.refreshOk": "\u6863\u4F4D\u4FE1\u606F\u5DF2\u66F4\u65B0",
|
|
1240
2012
|
"settings.reasoning.refreshFailed": "\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
|
|
1241
2013
|
};
|
|
1242
2014
|
var en = {
|
|
1243
|
-
"button.title": "Enhance prompt",
|
|
2015
|
+
"button.title": "Enhance prompt \xB7 rewrite the text in the input box",
|
|
1244
2016
|
"button.busy": "Enhancing\u2026",
|
|
1245
|
-
"button.otherBusy": "Another session is enhancing right now
|
|
1246
|
-
"button.emptyTitle": "Enhance prompt
|
|
2017
|
+
"button.otherBusy": "Another session is enhancing right now",
|
|
2018
|
+
"button.emptyTitle": "Enhance prompt \xB7 type the text to rewrite first",
|
|
2019
|
+
"button.quickHint": " (right-click to configure)",
|
|
2020
|
+
"menu.title": "Quick settings",
|
|
2021
|
+
"menu.model": "Model",
|
|
2022
|
+
"menu.modelFollow": "Follow session",
|
|
2023
|
+
"menu.modelHint": "Change it on the plugin settings page",
|
|
2024
|
+
"menu.effortsNone": "This model declares no reasoning tiers",
|
|
2025
|
+
"menu.effortsFailed": "Could not read this model tiers",
|
|
2026
|
+
"menu.effort": "Reasoning effort",
|
|
2027
|
+
"menu.effortDefault": "Not specified",
|
|
2028
|
+
"menu.context": "Context awareness",
|
|
2029
|
+
"menu.contextOn": "on",
|
|
2030
|
+
"menu.contextOff": "off",
|
|
2031
|
+
"menu.writeFailed": "Could not save \u2014 try again.",
|
|
1247
2032
|
"panel.title": "Prompt Enhance",
|
|
1248
2033
|
"panel.loading": "Enhancing, please wait\u2026",
|
|
1249
2034
|
"panel.streaming": "Generating\u2026",
|
|
@@ -1258,12 +2043,15 @@ var en = {
|
|
|
1258
2043
|
"panel.copied": "Copied",
|
|
1259
2044
|
"panel.copyFailed": "Copy failed",
|
|
1260
2045
|
"panel.close": "Close",
|
|
2046
|
+
"panel.collapse": "Collapse",
|
|
2047
|
+
"panel.expand": "Expand",
|
|
1261
2048
|
"panel.retry": "Retry",
|
|
1262
|
-
"panel.stale.warn": "Draft changed \u2014 this result uses the earlier text; Apply overwrites the
|
|
1263
|
-
"panel.truncated": 'Output
|
|
2049
|
+
"panel.stale.warn": "Draft changed \u2014 this result uses the earlier text. Regenerate re-runs on the current draft; Apply still overwrites the input (undoable).",
|
|
2050
|
+
"panel.truncated": 'Output was cut at the output limit, so the result may be incomplete. Raise "Output token budget" in the settings, then regenerate.',
|
|
1264
2051
|
"panel.model": "Model: {provider} / {model}",
|
|
1265
2052
|
"panel.elapsed": "{ms} elapsed",
|
|
1266
2053
|
"panel.tokens": "{total} tokens",
|
|
2054
|
+
"panel.effortDefault": "Not specified",
|
|
1267
2055
|
"panel.tokens.input": "Input {count}",
|
|
1268
2056
|
"panel.tokens.output": "Output {count}",
|
|
1269
2057
|
"panel.tokens.cacheRead": "Cache read {count}",
|
|
@@ -1272,17 +2060,17 @@ var en = {
|
|
|
1272
2060
|
"undo.undo": "Undo",
|
|
1273
2061
|
"undo.dismiss": "Dismiss",
|
|
1274
2062
|
"error.empty": "The input box is empty \u2014 type a prompt to enhance first.",
|
|
1275
|
-
"error.tooLong": "The draft is {count} characters,
|
|
2063
|
+
"error.tooLong": "The draft is {count} characters, over the {max} limit (characters, not tokens); it is never truncated automatically \u2014 please shorten it.",
|
|
1276
2064
|
"error.occurrences": "The draft contains commands or file references, which are not supported yet \u2014 remove them first.",
|
|
1277
|
-
"error.chipsUnknown": "The composer reference state could not be read
|
|
2065
|
+
"error.chipsUnknown": "The composer reference state could not be read, so the enhancement was blocked to avoid overwriting your command or file reference. Use plain text, then retry.",
|
|
1278
2066
|
"error.phase": "The input box is busy (submitting) \u2014 try again in a moment.",
|
|
1279
|
-
"error.disabled": "Prompt enhance is disabled in the plugin settings.",
|
|
1280
|
-
"error.rejected": "The enhance request was rejected.",
|
|
1281
|
-
"error.timeout":
|
|
1282
|
-
"error.unconfigured": "No model
|
|
1283
|
-
"error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "
|
|
1284
|
-
"error.upstream": "The model provider returned an error.
|
|
1285
|
-
"error.internal": "Enhancement failed. Retry;
|
|
2067
|
+
"error.disabled": "Prompt enhance is disabled in the plugin settings; re-enable it there.",
|
|
2068
|
+
"error.rejected": "The enhance request was rejected. Retry later; if it persists, check the plugin settings.",
|
|
2069
|
+
"error.timeout": 'The enhancement timed out ({seconds}s). Retry, or raise "Timeout (ms)" in the settings; your draft is untouched.',
|
|
2070
|
+
"error.unconfigured": "No model is configured for the enhancement: fill in both provider and model in the plugin settings, or send a message in the current session first to follow the session model.",
|
|
2071
|
+
"error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "Not specified".',
|
|
2072
|
+
"error.upstream": "The model provider returned an error. If there is detail below, act on it; otherwise retry. Your draft is untouched.",
|
|
2073
|
+
"error.internal": "Enhancement failed. Retry; if it keeps failing, check the dsh logs. Your draft is untouched.",
|
|
1286
2074
|
"error.client.unreachable": "Cannot reach the host service \u2014 make sure dsh web is running, then retry.",
|
|
1287
2075
|
"error.client.malformed": "The host returned data that could not be parsed. Retry; your draft is untouched.",
|
|
1288
2076
|
"error.client.refused": "The host refused the request (HTTP {status}). Retry later.",
|
|
@@ -1290,7 +2078,7 @@ var en = {
|
|
|
1290
2078
|
"error.client.cancelled": "The enhancement was cancelled; your draft is untouched.",
|
|
1291
2079
|
"error.rateLimit": "Too many requests \u2014 at most {limit} enhancements per minute; retry in {retryAfterSeconds} seconds.",
|
|
1292
2080
|
"error.concurrencyLimit": "{max} enhancements are already running \u2014 wait for one to finish, then retry.",
|
|
1293
|
-
"error.cooldown": "{failures} enhancements failed in a row; calls are paused to stop hammering the model service. Retry
|
|
2081
|
+
"error.cooldown": "{failures} enhancements failed in a row; calls are paused for {retryAfterSeconds}s to stop hammering the model service. Retry later, or check the model settings first.",
|
|
1294
2082
|
"error.upstream.auth": "Authentication failed \u2014 check the API key configured for this provider.",
|
|
1295
2083
|
"error.upstream.invalidCredential": "Authentication failed \u2014 the stored API key is invalid; fix it and retry.",
|
|
1296
2084
|
"error.upstream.rateLimit": "The model provider is rate-limiting; retry later.",
|
|
@@ -1298,7 +2086,7 @@ var en = {
|
|
|
1298
2086
|
"error.upstream.empty": "The model returned an empty response; retry.",
|
|
1299
2087
|
"error.upstream.contextWindow": "The input exceeds the model context window \u2014 shorten it or switch models.",
|
|
1300
2088
|
"error.upstream.toolCall": "The model requested tool calls, but prompt enhance needs plain text \u2014 switch models and retry.",
|
|
1301
|
-
"error.upstream.maxTokens":
|
|
2089
|
+
"error.upstream.maxTokens": 'The rewrite hit the "Output token budget" limit \u2014 raise that setting or shorten the draft, then retry.',
|
|
1302
2090
|
"settings.summary": "Model, context, and resource limits",
|
|
1303
2091
|
"settings.title": "Prompt enhance",
|
|
1304
2092
|
"settings.description": "Turns a composer draft into a structured prompt: role and goal, executable steps, output format, acceptance criteria, edge cases. The draft is preserved, failures never touch it, and saved values apply to the next call.",
|
|
@@ -1312,6 +2100,11 @@ var en = {
|
|
|
1312
2100
|
"settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
|
|
1313
2101
|
"settings.reset": "Reset to default",
|
|
1314
2102
|
"settings.invalidNumber": "Enter a number, or leave blank to use the default.",
|
|
2103
|
+
"settings.record": "Record",
|
|
2104
|
+
"settings.recordStop": "Stop recording",
|
|
2105
|
+
"settings.recordPrompt": "Press the key combination (Esc to cancel)",
|
|
2106
|
+
"settings.recordNeedsModifier": "Hold at least one of ctrl / alt / meta",
|
|
2107
|
+
"settings.invalidShortcut": "Invalid shortcut - it would never fire: use at least one of ctrl / alt / meta and put the key last, e.g. ctrl+alt+e.",
|
|
1315
2108
|
"settings.disconnected": "This page has no form: the host did not project its form store. The plugin keeps working with its composition config.",
|
|
1316
2109
|
"settings.row.enabled.label": "Master switch",
|
|
1317
2110
|
"settings.row.enabled.hint": "Off hides the composer button and disables the command and the shortcut.",
|
|
@@ -1319,6 +2112,10 @@ var en = {
|
|
|
1319
2112
|
"settings.row.contextAware.hint": "Reads the recent turns of the current conversation; falls back to a single-prompt rewrite when there is no history.",
|
|
1320
2113
|
"settings.row.streaming.label": "Streaming display",
|
|
1321
2114
|
"settings.row.streaming.hint": "Shows the rewrite while it is being written. Display only: the applied text is unchanged.",
|
|
2115
|
+
"settings.row.foldAnimation.label": "Card fold animation",
|
|
2116
|
+
"settings.row.foldAnimation.hint": 'Plays the expand/collapse transition; off switches instantly. The system "reduce motion" preference always wins.',
|
|
2117
|
+
"settings.row.autoFold.label": "Fold the card automatically",
|
|
2118
|
+
"settings.row.autoFold.hint": "Folds the card after Apply and re-opens it after Undo; off leaves the card as it is.",
|
|
1322
2119
|
"settings.row.provider.label": "Model provider",
|
|
1323
2120
|
"settings.row.provider.hint": "Pick a registered DSH LLM provider; leave empty to follow the current session\u2019s model.",
|
|
1324
2121
|
"settings.row.model.label": "Model id",
|
|
@@ -1345,7 +2142,7 @@ var en = {
|
|
|
1345
2142
|
"settings.row.temperature.label": "Temperature",
|
|
1346
2143
|
"settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
|
|
1347
2144
|
"settings.row.reasoningEffort.label": "Reasoning effort",
|
|
1348
|
-
"settings.row.reasoningEffort.hint":
|
|
2145
|
+
"settings.row.reasoningEffort.hint": 'Tier choices come from what the configured provider/model declares; custom models are read on demand. "Not specified" omits the field.',
|
|
1349
2146
|
"settings.row.maxOutputTokens.label": "Output token budget",
|
|
1350
2147
|
"settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
|
|
1351
2148
|
"settings.row.maxInputChars.label": "Input character cap",
|
|
@@ -1370,14 +2167,14 @@ var en = {
|
|
|
1370
2167
|
"settings.row.shortcut.placeholder": "e.g. ctrl+alt+shift+e",
|
|
1371
2168
|
"settings.strategy.replace": "Replace the built-in strategy",
|
|
1372
2169
|
"settings.strategy.extend": "Append after the built-in strategy",
|
|
1373
|
-
"settings.reasoning.inherit": "
|
|
2170
|
+
"settings.reasoning.inherit": "Not specified",
|
|
1374
2171
|
"settings.reasoning.loading": "Reading this model\u2019s tiers\u2026",
|
|
1375
2172
|
"settings.reasoning.unavailable": "Could not read this model\u2019s tier list; your saved tier is still sent.",
|
|
1376
|
-
"settings.reasoning.noTiers": "This model declares no reasoning tiers; calls
|
|
2173
|
+
"settings.reasoning.noTiers": "This model declares no reasoning tiers; calls omit the field and let the provider decide.",
|
|
1377
2174
|
"settings.reasoning.unsupported": "The current value \u201C{effort}\u201D is not one of this model\u2019s tiers.",
|
|
1378
2175
|
"settings.reasoning.current": "Current value: {value}",
|
|
1379
2176
|
"settings.reasoning.currentTitle": "This model does not declare this tier",
|
|
1380
|
-
"settings.reasoning.refresh": "
|
|
2177
|
+
"settings.reasoning.refresh": "Refresh",
|
|
1381
2178
|
"settings.reasoning.refreshing": "Loading tier info\u2026",
|
|
1382
2179
|
"settings.reasoning.refreshOk": "Tier info updated",
|
|
1383
2180
|
"settings.reasoning.refreshFailed": "Could not load tier info \u2014 please retry."
|
|
@@ -1388,9 +2185,16 @@ var NS = "dsh-prompt-enhance";
|
|
|
1388
2185
|
// src/client/styles.ts
|
|
1389
2186
|
var STYLE_ID = "dsh-prompt-enhance-styles";
|
|
1390
2187
|
var CSS = `
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
2188
|
+
/* One palette for everything the plugin paints into the dock: the result card
|
|
2189
|
+
and the standalone undo row are siblings, so the tokens live on their shared
|
|
2190
|
+
parent instead of on the card alone (a child could not reach its sibling's
|
|
2191
|
+
variables, which is why the undo row used to re-derive its own colors). The
|
|
2192
|
+
quick-settings menu lives in the composer slot instead, so it joins the same
|
|
2193
|
+
rule to read the same palette. */
|
|
2194
|
+
.dsh-pe-dock {
|
|
2195
|
+
width: 100%;
|
|
2196
|
+
}
|
|
2197
|
+
.dsh-pe-dock {
|
|
1394
2198
|
--pe-bg: var(--dsw-alias-bg-layer-1, #1f2127);
|
|
1395
2199
|
--pe-fg: var(--dsw-alias-label-primary, #e6e8ee);
|
|
1396
2200
|
--pe-fg-dim: var(--dsw-alias-label-secondary, rgba(230, 232, 238, 0.55));
|
|
@@ -1399,11 +2203,234 @@ var CSS = `
|
|
|
1399
2203
|
/* No hover token exists: a neutral grey alpha is already theme-agnostic. */
|
|
1400
2204
|
--pe-hover: rgba(127, 127, 127, 0.18);
|
|
1401
2205
|
--pe-danger: var(--dsw-alias-state-error-primary, #ffb4a8);
|
|
2206
|
+
--pe-success: var(--dsw-alias-state-success-primary, #2da44e);
|
|
1402
2207
|
--pe-warn-fg: var(--dsw-alias-state-warn-primary, #e8c07d);
|
|
1403
2208
|
/* Tints of the themed warning color, so the banner cannot keep an amber cast
|
|
1404
2209
|
from the other scheme. */
|
|
1405
2210
|
--pe-warn-border: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 35%, transparent);
|
|
1406
2211
|
--pe-warn-bg: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 12%, transparent);
|
|
2212
|
+
}
|
|
2213
|
+
/* Quick-settings menu, copied from the shell's own menu primitives:
|
|
2214
|
+
- the card surface is MenuSurface.module.css (radius-lg, elevation stroke,
|
|
2215
|
+
prominent shadow) with the menu fill over an opaque bg-base, so a
|
|
2216
|
+
translucent fill never shows the page through it;
|
|
2217
|
+
- rows and the trailing check are Menu.module.css (.item / .label /
|
|
2218
|
+
.separator / .check);
|
|
2219
|
+
- the check artwork is the exact check-outline regular glyph from
|
|
2220
|
+
@deepseek-ai/dsh-client-ui-primitives (16-unit viewBox, 1px stroke),
|
|
2221
|
+
painted at the shell's 14x14 check size through a mask. */
|
|
2222
|
+
.dsh-pe-menu {
|
|
2223
|
+
z-index: 1100;
|
|
2224
|
+
display: flex;
|
|
2225
|
+
flex-direction: column;
|
|
2226
|
+
box-sizing: border-box;
|
|
2227
|
+
/* The shell's model-menu card (ModelSelect.module.css .menu) is the closest
|
|
2228
|
+
relative of this card and starts at 240px, so a short value like "Off" does
|
|
2229
|
+
not leave the card cramped; the primitive's 144px floor is for plain lists. */
|
|
2230
|
+
min-width: min(240px, 100vw - 24px);
|
|
2231
|
+
max-width: min(360px, 100vw - 24px);
|
|
2232
|
+
padding: 4px;
|
|
2233
|
+
border: 0;
|
|
2234
|
+
border-radius: var(--dsw-radius-lg, 12px);
|
|
2235
|
+
--dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
|
|
2236
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2237
|
+
box-shadow: var(--dsw-elevation-prominent, 0 12px 32px rgba(0, 0, 0, 0.24));
|
|
2238
|
+
cursor: default;
|
|
2239
|
+
/* The host isolates the card so the material below never becomes a backdrop
|
|
2240
|
+
root for nested menus; matching the shell keeps the blur behaviour equal. */
|
|
2241
|
+
isolation: isolate;
|
|
2242
|
+
}
|
|
2243
|
+
/* The material, exactly as MenuSurface.module.css paints it (the host uses a
|
|
2244
|
+
child element with z-index:-1; a pseudo-element is the same layer without
|
|
2245
|
+
touching the component): menu fill + backdrop blur. */
|
|
2246
|
+
.dsh-pe-menu::before {
|
|
2247
|
+
content: '';
|
|
2248
|
+
position: absolute;
|
|
2249
|
+
inset: 0;
|
|
2250
|
+
z-index: -1;
|
|
2251
|
+
border-radius: inherit;
|
|
2252
|
+
background: var(--dsw-menu-surface-fill, rgba(255, 255, 255, 0.96));
|
|
2253
|
+
-webkit-backdrop-filter: var(--dsw-menu-backdrop-filter, blur(12px));
|
|
2254
|
+
backdrop-filter: var(--dsw-menu-backdrop-filter, blur(12px));
|
|
2255
|
+
pointer-events: none;
|
|
2256
|
+
}
|
|
2257
|
+
/* macOS: the host backs the material with an opaque layer (its .backing
|
|
2258
|
+
element) because Chromium needs opaque pixels behind page content to blur it
|
|
2259
|
+
over native vibrancy. One opaque base colour on the card is that layer here. */
|
|
2260
|
+
html[data-platform='darwin'] .dsh-pe-menu {
|
|
2261
|
+
background-color: var(--dsw-alias-bg-base, #ffffff);
|
|
2262
|
+
}
|
|
2263
|
+
.dsh-pe-menu-group { display: flex; flex-direction: column; }
|
|
2264
|
+
|
|
2265
|
+
.dsh-pe-menu-item {
|
|
2266
|
+
display: flex;
|
|
2267
|
+
align-items: center;
|
|
2268
|
+
gap: 6px;
|
|
2269
|
+
width: 100%;
|
|
2270
|
+
min-height: 34px;
|
|
2271
|
+
padding: 6px 8px;
|
|
2272
|
+
border: none;
|
|
2273
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2274
|
+
background: transparent;
|
|
2275
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2276
|
+
font: inherit;
|
|
2277
|
+
font-size: 13px;
|
|
2278
|
+
line-height: 20px;
|
|
2279
|
+
text-align: left;
|
|
2280
|
+
cursor: pointer;
|
|
2281
|
+
}
|
|
2282
|
+
.dsh-pe-menu-item:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
|
|
2283
|
+
.dsh-pe-menu-item:focus-visible { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); outline: none; }/* Folded tier cell: the shell model menu's .cell (34px, value right in
|
|
2284
|
+
tertiary, a 12px chevron in the menu-icon tone) so the card reads as one
|
|
2285
|
+
compact row until the list is opened. */
|
|
2286
|
+
.dsh-pe-menu-cell {
|
|
2287
|
+
height: 34px;
|
|
2288
|
+
min-height: 34px;
|
|
2289
|
+
padding: 0 8px;
|
|
2290
|
+
}
|
|
2291
|
+
/* Read-only route row: the cell metrics without a pointer or hover, because the
|
|
2292
|
+
value is changed on the plugin settings page, not here. */
|
|
2293
|
+
.dsh-pe-menu-info {
|
|
2294
|
+
display: flex;
|
|
2295
|
+
align-items: center;
|
|
2296
|
+
gap: 6px;
|
|
2297
|
+
min-height: 34px;
|
|
2298
|
+
padding: 0 8px;
|
|
2299
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2300
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2301
|
+
font-size: 13px;
|
|
2302
|
+
line-height: 20px;
|
|
2303
|
+
cursor: default;
|
|
2304
|
+
}
|
|
2305
|
+
.dsh-pe-menu-info .dsh-pe-menu-label { flex: 0 0 auto; }
|
|
2306
|
+
.dsh-pe-menu-info .dsh-pe-menu-state {
|
|
2307
|
+
flex: 1 1 auto;
|
|
2308
|
+
min-width: 0;
|
|
2309
|
+
margin-left: 0;
|
|
2310
|
+
overflow: hidden;
|
|
2311
|
+
text-align: right;
|
|
2312
|
+
text-overflow: ellipsis;
|
|
2313
|
+
white-space: nowrap;
|
|
2314
|
+
}
|
|
2315
|
+
.dsh-pe-menu-cell .dsh-pe-menu-label { flex: 0 0 auto; }
|
|
2316
|
+
.dsh-pe-menu-cell .dsh-pe-menu-state {
|
|
2317
|
+
flex: 1 1 auto;
|
|
2318
|
+
min-width: 0;
|
|
2319
|
+
margin-left: 0;
|
|
2320
|
+
overflow: hidden;
|
|
2321
|
+
text-align: right;
|
|
2322
|
+
text-overflow: ellipsis;
|
|
2323
|
+
white-space: nowrap;
|
|
2324
|
+
}
|
|
2325
|
+
/* The chevron is the shell's own chevron-right-outline artwork (16-unit
|
|
2326
|
+
viewBox, 1px stroke) masked at the model menu's 12px cell size; it turns to
|
|
2327
|
+
point down while the list is open. */
|
|
2328
|
+
.dsh-pe-menu-chevron {
|
|
2329
|
+
flex: none;
|
|
2330
|
+
width: 12px;
|
|
2331
|
+
height: 12px;
|
|
2332
|
+
color: var(--dsw-alias-menu-icon, var(--dsw-alias-label-tertiary, inherit));
|
|
2333
|
+
background-color: currentColor;
|
|
2334
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M6%2012L9.29289%208.70711C9.68342%208.31658%209.68342%207.68342%209.29289%207.29289L6%204'/%3E%3C/svg%3E");
|
|
2335
|
+
mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M6%2012L9.29289%208.70711C9.68342%208.31658%209.68342%207.68342%209.29289%207.29289L6%204'/%3E%3C/svg%3E");
|
|
2336
|
+
-webkit-mask-size: 16px 16px;
|
|
2337
|
+
mask-size: 16px 16px;
|
|
2338
|
+
-webkit-mask-repeat: no-repeat;
|
|
2339
|
+
mask-repeat: no-repeat;
|
|
2340
|
+
-webkit-mask-position: center;
|
|
2341
|
+
mask-position: center;
|
|
2342
|
+
transition: transform 120ms ease;
|
|
2343
|
+
}
|
|
2344
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2345
|
+
.dsh-pe-menu-chevron { transition: none; }
|
|
2346
|
+
}
|
|
2347
|
+
.dsh-pe-menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2348
|
+
.dsh-pe-menu-state { flex: none; margin-left: auto; color: var(--dsw-alias-label-tertiary, inherit); }
|
|
2349
|
+
/* The shell's check: a 14x14 icon in label-primary. The text glyph is hidden
|
|
2350
|
+
and the exact outline artwork is masked in, so the shape, weight and size
|
|
2351
|
+
are the shell's own. */
|
|
2352
|
+
.dsh-pe-menu-mark {
|
|
2353
|
+
flex: none;
|
|
2354
|
+
width: 14px;
|
|
2355
|
+
height: 14px;
|
|
2356
|
+
margin-left: auto;
|
|
2357
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2358
|
+
font-size: 0;
|
|
2359
|
+
background-color: transparent;
|
|
2360
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M2.25%208.5L5.49732%2011.7473C5.90519%2012.1552%206.57263%2012.1344%206.95426%2011.7018L13.75%204'/%3E%3C/svg%3E");
|
|
2361
|
+
mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M2.25%208.5L5.49732%2011.7473C5.90519%2012.1552%206.57263%2012.1344%206.95426%2011.7018L13.75%204'/%3E%3C/svg%3E");
|
|
2362
|
+
-webkit-mask-size: 14px 14px;
|
|
2363
|
+
mask-size: 14px 14px;
|
|
2364
|
+
-webkit-mask-repeat: no-repeat;
|
|
2365
|
+
mask-repeat: no-repeat;
|
|
2366
|
+
-webkit-mask-position: center;
|
|
2367
|
+
mask-position: center;
|
|
2368
|
+
}
|
|
2369
|
+
.dsh-pe-menu-item[aria-checked='true'] .dsh-pe-menu-mark { background-color: currentColor; }
|
|
2370
|
+
/* The context switch row, copied from the shell's TeamModeToggle row: the label
|
|
2371
|
+
on the left, the shell's own switch on the right, and the whole row (minus
|
|
2372
|
+
nothing here) as the switch's hit target. */
|
|
2373
|
+
.dsh-pe-menu-switch {
|
|
2374
|
+
position: relative;
|
|
2375
|
+
display: flex;
|
|
2376
|
+
align-items: center;
|
|
2377
|
+
justify-content: space-between;
|
|
2378
|
+
gap: 16px;
|
|
2379
|
+
min-height: 34px;
|
|
2380
|
+
padding: 0 8px;
|
|
2381
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2382
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2383
|
+
font-size: 13px;
|
|
2384
|
+
line-height: 20px;
|
|
2385
|
+
}
|
|
2386
|
+
.dsh-pe-menu-switch-label {
|
|
2387
|
+
display: inline-flex;
|
|
2388
|
+
align-items: center;
|
|
2389
|
+
gap: 4px;
|
|
2390
|
+
min-width: 0;
|
|
2391
|
+
}
|
|
2392
|
+
/* Extend the native switch hit target over the whole row. */
|
|
2393
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input { position: static; }
|
|
2394
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input::after {
|
|
2395
|
+
content: '';
|
|
2396
|
+
position: absolute;
|
|
2397
|
+
inset: 0;
|
|
2398
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2399
|
+
}
|
|
2400
|
+
.dsh-pe-menu-switch:has(.dsh-pe-menu-switch-input:focus-visible) {
|
|
2401
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
|
|
2402
|
+
}
|
|
2403
|
+
/* The shell switch animates its thumb; its track colour is driven straight by
|
|
2404
|
+
aria-checked, so both get the same 120ms transition here, and both stop when
|
|
2405
|
+
the user asks for reduced motion. */
|
|
2406
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input {
|
|
2407
|
+
transition: background-color 120ms ease;
|
|
2408
|
+
}
|
|
2409
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input > * {
|
|
2410
|
+
transition: transform 120ms ease, background-color 120ms ease;
|
|
2411
|
+
}
|
|
2412
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2413
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input,
|
|
2414
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input > * {
|
|
2415
|
+
transition: none;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
@media (hover: hover) {
|
|
2419
|
+
.dsh-pe-menu-switch:has(.dsh-pe-menu-switch-input:not(:disabled)):hover {
|
|
2420
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
.dsh-pe-menu-sep { height: 0.5px; margin: 3px 8px; background: var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.25)); }
|
|
2424
|
+
.dsh-pe-menu-error { padding: 6px 8px; font-size: 12px; color: var(--dsw-alias-state-error-primary, #e5484d); }
|
|
2425
|
+
/* Why the tier list is empty: an explanation, not an error. */
|
|
2426
|
+
.dsh-pe-menu-note {
|
|
2427
|
+
padding: 4px 8px 6px;
|
|
2428
|
+
color: var(--dsw-alias-label-tertiary, inherit);
|
|
2429
|
+
font-size: 12px;
|
|
2430
|
+
line-height: 16px;
|
|
2431
|
+
}
|
|
2432
|
+
.dsh-pe-panel {
|
|
2433
|
+
box-sizing: border-box;
|
|
1407
2434
|
display: flex;
|
|
1408
2435
|
flex-direction: column;
|
|
1409
2436
|
width: 100%;
|
|
@@ -1414,7 +2441,46 @@ var CSS = `
|
|
|
1414
2441
|
color: var(--pe-fg);
|
|
1415
2442
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 14px rgba(0, 0, 0, 0.05);
|
|
1416
2443
|
overflow: hidden;
|
|
2444
|
+
/* The card is chrome: titles, badges, banners and button labels are not
|
|
2445
|
+
content to be selected. The two blocks the user may want to copy opt back
|
|
2446
|
+
in below (.dsh-pe-result-text, .dsh-pe-error). */
|
|
2447
|
+
-webkit-user-select: none;
|
|
2448
|
+
user-select: none;
|
|
1417
2449
|
}
|
|
2450
|
+
/* The body folds along a single grid track (1fr <-> 0fr): the height animates to
|
|
2451
|
+
the content's own size, so nothing is measured in JS and the fold can never
|
|
2452
|
+
overshoot a long result. The inner clips, and once the track has closed it
|
|
2453
|
+
also leaves the paint, selection and accessibility trees. */
|
|
2454
|
+
.dsh-pe-body {
|
|
2455
|
+
display: grid;
|
|
2456
|
+
grid-template-rows: 1fr;
|
|
2457
|
+
transition: grid-template-rows 160ms ease;
|
|
2458
|
+
}
|
|
2459
|
+
.dsh-pe-body > .dsh-pe-body-inner {
|
|
2460
|
+
min-height: 0;
|
|
2461
|
+
overflow: hidden;
|
|
2462
|
+
visibility: visible;
|
|
2463
|
+
transition: visibility 0s;
|
|
2464
|
+
}
|
|
2465
|
+
.dsh-pe-panel.is-collapsed .dsh-pe-body { grid-template-rows: 0fr; }
|
|
2466
|
+
.dsh-pe-panel.is-collapsed .dsh-pe-body > .dsh-pe-body-inner {
|
|
2467
|
+
visibility: hidden;
|
|
2468
|
+
/* Hidden only after the track has finished closing, so the fold is visible
|
|
2469
|
+
the whole way down; expanding drops the delay and shows it at once. */
|
|
2470
|
+
transition: visibility 0s linear 160ms;
|
|
2471
|
+
}
|
|
2472
|
+
/* The chevron turns with the fold, so the button and the body read as one gesture. */
|
|
2473
|
+
.dsh-pe-collapse svg { transition: transform 160ms ease; }
|
|
2474
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2475
|
+
.dsh-pe-body,
|
|
2476
|
+
.dsh-pe-body > .dsh-pe-body-inner,
|
|
2477
|
+
.dsh-pe-collapse svg { transition: none; }
|
|
2478
|
+
}
|
|
2479
|
+
/* The fold animation is a setting; switching it off makes the fold instant.
|
|
2480
|
+
The OS preference above still wins for users who ask for less motion. */
|
|
2481
|
+
.dsh-pe-panel.is-static .dsh-pe-body,
|
|
2482
|
+
.dsh-pe-panel.is-static .dsh-pe-body > .dsh-pe-body-inner,
|
|
2483
|
+
.dsh-pe-panel.is-static .dsh-pe-collapse svg { transition: none; }
|
|
1418
2484
|
.dsh-pe-head {
|
|
1419
2485
|
display: flex;
|
|
1420
2486
|
align-items: center;
|
|
@@ -1441,12 +2507,30 @@ var CSS = `
|
|
|
1441
2507
|
font-size: 11px;
|
|
1442
2508
|
opacity: 0.72;
|
|
1443
2509
|
white-space: nowrap;
|
|
2510
|
+
cursor: default;
|
|
2511
|
+
/* Four segments (model, elapsed, tokens, effort) can outgrow a narrow header:
|
|
2512
|
+
shrink with an ellipsis instead of pushing the fold and close controls. */
|
|
2513
|
+
max-width: 100%;
|
|
2514
|
+
overflow: hidden;
|
|
2515
|
+
text-overflow: ellipsis;
|
|
1444
2516
|
}
|
|
1445
|
-
|
|
2517
|
+
/* The close and collapse controls share one square hit target: same box, same
|
|
2518
|
+
hover surface, so the two glyphs read as a pair instead of one looking
|
|
2519
|
+
flatter than the other. */
|
|
2520
|
+
.dsh-pe-close,
|
|
2521
|
+
.dsh-pe-collapse {
|
|
2522
|
+
box-sizing: border-box;
|
|
1446
2523
|
border: none; background: transparent; color: inherit; opacity: 0.6;
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
2524
|
+
cursor: pointer; border-radius: 4px; padding: 0;
|
|
2525
|
+
width: 22px; height: 22px; line-height: 0;
|
|
2526
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
2527
|
+
}
|
|
2528
|
+
.dsh-pe-close { font-size: 15px; }
|
|
2529
|
+
.dsh-pe-close:hover,
|
|
2530
|
+
.dsh-pe-collapse:hover { opacity: 1; background: var(--pe-hover); }
|
|
2531
|
+
/* Collapsed, the warning banners live in the hidden body; this marker stands in
|
|
2532
|
+
for them so a stale or truncated result never folds away silently. */
|
|
2533
|
+
.dsh-pe-warn-dot { font-size: 15px; line-height: 1; color: var(--pe-warn-fg); }
|
|
1450
2534
|
.dsh-pe-result { padding: 2px 10px 6px; }
|
|
1451
2535
|
.dsh-pe-result-text {
|
|
1452
2536
|
margin: 0;
|
|
@@ -1458,6 +2542,9 @@ var CSS = `
|
|
|
1458
2542
|
font-family: inherit;
|
|
1459
2543
|
font-size: 12.5px;
|
|
1460
2544
|
line-height: 1.6;
|
|
2545
|
+
/* The one block in the card the user is expected to copy by hand. */
|
|
2546
|
+
-webkit-user-select: text;
|
|
2547
|
+
user-select: text;
|
|
1461
2548
|
}
|
|
1462
2549
|
.dsh-pe-col-title {
|
|
1463
2550
|
padding: 4px 10px 2px;
|
|
@@ -1471,6 +2558,10 @@ var CSS = `
|
|
|
1471
2558
|
line-height: 1.6;
|
|
1472
2559
|
color: var(--pe-danger);
|
|
1473
2560
|
white-space: pre-wrap;
|
|
2561
|
+
/* Selectable with its detail line: the provider message is what users paste
|
|
2562
|
+
into an issue when they report a failure. */
|
|
2563
|
+
-webkit-user-select: text;
|
|
2564
|
+
user-select: text;
|
|
1474
2565
|
}
|
|
1475
2566
|
.dsh-pe-error .dsh-pe-error-detail {
|
|
1476
2567
|
margin-top: 8px;
|
|
@@ -1542,14 +2633,13 @@ var CSS = `
|
|
|
1542
2633
|
}
|
|
1543
2634
|
.dsh-pe-btn-action.plain { background: transparent; color: inherit; }
|
|
1544
2635
|
.dsh-pe-btn-action.plain:hover { background: var(--pe-hover); }
|
|
1545
|
-
/* A floor for
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
.dsh-pe-btn-swap { min-width: 96px; }
|
|
2636
|
+
/* A floor for every footer action button, so a button keeps a visible, clickable
|
|
2637
|
+
width even if its label ever collapses to nothing. The label-swap groups
|
|
2638
|
+
(.dsh-pe-swap) already make a button as wide as its longest label, and 96px is
|
|
2639
|
+
below every real content width here, so this never widens a labelled button in
|
|
2640
|
+
practice \u2014 it only bounds the empty case and keeps the single-label buttons
|
|
2641
|
+
(retry, cancel) the same size as the rest. */
|
|
2642
|
+
.dsh-pe-btn-floor { min-width: 96px; }
|
|
1553
2643
|
.dsh-pe-btn-action:disabled { opacity: 0.45; cursor: default; }
|
|
1554
2644
|
|
|
1555
2645
|
/* Both labels of the regenerate button share one cell, so the button is as wide
|
|
@@ -1588,6 +2678,9 @@ var CSS = `
|
|
|
1588
2678
|
.dsh-pe-btn:hover:not(:disabled) { opacity: 1; background: var(--pe-hover); }
|
|
1589
2679
|
.dsh-pe-btn.is-busy { cursor: progress; }
|
|
1590
2680
|
.dsh-pe-btn.is-blocked { cursor: progress; }
|
|
2681
|
+
/* Empty draft: dimmed and a forbidden pointer. The plain click really is inert
|
|
2682
|
+
here; the card stays reachable by right-click (long-press / Shift+F10) and the
|
|
2683
|
+
tooltip says so, so the cursor still marks "left click does nothing". */
|
|
1591
2684
|
.dsh-pe-btn.is-empty { opacity: 0.4; cursor: not-allowed; }
|
|
1592
2685
|
.dsh-pe-btn.is-empty:hover { opacity: 0.4; background: transparent; }
|
|
1593
2686
|
.dsh-pe-btn:disabled { opacity: 0.45; cursor: default; }
|
|
@@ -1601,15 +2694,19 @@ var CSS = `
|
|
|
1601
2694
|
width: fit-content;
|
|
1602
2695
|
margin-left: auto;
|
|
1603
2696
|
padding: 3px 6px 3px 10px;
|
|
1604
|
-
border: 1px solid var(--
|
|
2697
|
+
border: 1px solid var(--pe-border);
|
|
1605
2698
|
border-radius: 12px;
|
|
1606
|
-
background: var(--
|
|
2699
|
+
background: var(--pe-bg);
|
|
1607
2700
|
font-size: 12px;
|
|
1608
|
-
color:
|
|
2701
|
+
color: var(--pe-fg);
|
|
2702
|
+
/* The undo row is chrome too, like the card header and footer. */
|
|
2703
|
+
-webkit-user-select: none;
|
|
2704
|
+
user-select: none;
|
|
1609
2705
|
}
|
|
1610
2706
|
.dsh-pe-undo .dsh-pe-undo-check {
|
|
1611
|
-
|
|
1612
|
-
|
|
2707
|
+
display: inline-flex;
|
|
2708
|
+
align-items: center;
|
|
2709
|
+
color: var(--pe-success);
|
|
1613
2710
|
}
|
|
1614
2711
|
.dsh-pe-undo-link {
|
|
1615
2712
|
display: inline-flex;
|
|
@@ -1618,16 +2715,14 @@ var CSS = `
|
|
|
1618
2715
|
gap: 6px;
|
|
1619
2716
|
height: 28px;
|
|
1620
2717
|
padding: 0 10px;
|
|
1621
|
-
border: 1px solid var(--
|
|
2718
|
+
border: 1px solid var(--pe-border);
|
|
1622
2719
|
border-radius: 6px;
|
|
1623
2720
|
background: transparent;
|
|
1624
2721
|
color: inherit;
|
|
1625
2722
|
font-size: 12px;
|
|
1626
2723
|
cursor: pointer;
|
|
1627
|
-
transition: background-color 120ms ease;
|
|
1628
2724
|
}
|
|
1629
|
-
.dsh-pe-undo-link:hover { background:
|
|
1630
|
-
.dsh-pe-undo-link:active { background: rgba(127, 127, 127, 0.22); }
|
|
2725
|
+
.dsh-pe-undo-link:hover { background: var(--pe-hover); }
|
|
1631
2726
|
.dsh-pe-undo-x {
|
|
1632
2727
|
display: inline-flex;
|
|
1633
2728
|
align-items: center;
|
|
@@ -1638,12 +2733,20 @@ var CSS = `
|
|
|
1638
2733
|
border-radius: 6px;
|
|
1639
2734
|
background: transparent;
|
|
1640
2735
|
color: inherit;
|
|
1641
|
-
opacity: 0.
|
|
2736
|
+
opacity: 0.6;
|
|
1642
2737
|
cursor: pointer;
|
|
1643
2738
|
padding: 0;
|
|
1644
2739
|
font-size: 12px;
|
|
1645
2740
|
}
|
|
1646
|
-
.dsh-pe-undo-x:hover { opacity: 1; background: var(--
|
|
2741
|
+
.dsh-pe-undo-x:hover { opacity: 1; background: var(--pe-hover); }
|
|
2742
|
+
/* The host's segmented control slides its indicator with a 160ms transform
|
|
2743
|
+
transition. This row re-lists its options whenever a capability answer lands
|
|
2744
|
+
(loading -> ready, model switch, a cleared tier), so the pill would appear to
|
|
2745
|
+
fly in from outside the track while the option count changes under it. The
|
|
2746
|
+
selection change is the information here, not the motion. */
|
|
2747
|
+
.dsh-pe-segmented-labels > span[aria-hidden='true'] {
|
|
2748
|
+
transition: none !important;
|
|
2749
|
+
}
|
|
1647
2750
|
.dsh-pe-segmented-labels [role="tab"] {
|
|
1648
2751
|
min-width: 0;
|
|
1649
2752
|
overflow: hidden;
|
|
@@ -1651,20 +2754,25 @@ var CSS = `
|
|
|
1651
2754
|
text-align: center;
|
|
1652
2755
|
white-space: nowrap;
|
|
1653
2756
|
}
|
|
2757
|
+
/* The Advanced disclosure reads as one more settings row: same 13px/500 label
|
|
2758
|
+
tone as every row title, same vertical rhythm, and a 16px chevron drawn from
|
|
2759
|
+
the shell's chevron-down-outline artwork instead of a hand-drawn triangle. */
|
|
1654
2760
|
.dsh-pe-advanced {
|
|
1655
|
-
margin-top:
|
|
1656
|
-
border-top:
|
|
2761
|
+
margin-top: 4px;
|
|
2762
|
+
border-top: 0.5px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
|
|
1657
2763
|
}
|
|
2764
|
+
/* The shell's settings rows have no hover fill (its DisclosureRow only lifts the
|
|
2765
|
+
text tone), so the row keeps the page chrome and the glyph carries the state. */
|
|
1658
2766
|
.dsh-pe-advanced > summary {
|
|
1659
2767
|
display: flex;
|
|
1660
2768
|
align-items: center;
|
|
1661
2769
|
gap: 8px;
|
|
1662
|
-
|
|
1663
|
-
padding: 0 4px;
|
|
2770
|
+
padding: 12px 0;
|
|
1664
2771
|
list-style: none;
|
|
2772
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
1665
2773
|
font-size: 13px;
|
|
1666
2774
|
font-weight: 500;
|
|
1667
|
-
|
|
2775
|
+
line-height: 20px;
|
|
1668
2776
|
cursor: pointer;
|
|
1669
2777
|
user-select: none;
|
|
1670
2778
|
}
|
|
@@ -1673,26 +2781,42 @@ var CSS = `
|
|
|
1673
2781
|
.dsh-pe-advanced > summary::before {
|
|
1674
2782
|
content: '';
|
|
1675
2783
|
flex: none;
|
|
1676
|
-
width:
|
|
1677
|
-
height:
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
2784
|
+
width: 16px;
|
|
2785
|
+
height: 16px;
|
|
2786
|
+
color: var(--dsw-alias-label-tertiary, inherit);
|
|
2787
|
+
background-color: currentColor;
|
|
2788
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M4%206L7.29289%209.29289C7.68342%209.68342%208.31658%209.68342%208.70711%209.29289L12%206'/%3E%3C/svg%3E");
|
|
2789
|
+
mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='1'%3E%3Cpath%20d='M4%206L7.29289%209.29289C7.68342%209.68342%208.31658%209.68342%208.70711%209.29289L12%206'/%3E%3C/svg%3E");
|
|
2790
|
+
-webkit-mask-size: 16px 16px;
|
|
2791
|
+
mask-size: 16px 16px;
|
|
2792
|
+
-webkit-mask-repeat: no-repeat;
|
|
2793
|
+
mask-repeat: no-repeat;
|
|
2794
|
+
-webkit-mask-position: center;
|
|
2795
|
+
mask-position: center;
|
|
2796
|
+
/* Closed points at the collapsed content, open points down at it. */
|
|
2797
|
+
transform: rotate(-90deg);
|
|
1681
2798
|
transition: transform 120ms ease;
|
|
1682
2799
|
}
|
|
1683
|
-
.dsh-pe-advanced[open] > summary::before { transform:
|
|
2800
|
+
.dsh-pe-advanced[open] > summary::before { transform: none; }
|
|
1684
2801
|
.dsh-pe-advanced > summary:hover {
|
|
1685
|
-
color: var(--dsw-alias-label-
|
|
1686
|
-
|
|
1687
|
-
|
|
2802
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
2803
|
+
}
|
|
2804
|
+
.dsh-pe-advanced > summary:hover::before {
|
|
2805
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
1688
2806
|
}
|
|
1689
2807
|
.dsh-pe-advanced > summary:focus-visible {
|
|
1690
2808
|
outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
|
|
1691
2809
|
outline-offset: -2px;
|
|
1692
|
-
border-radius: 6px;
|
|
1693
2810
|
}
|
|
1694
|
-
|
|
2811
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2812
|
+
.dsh-pe-advanced > summary::before { transition: none; }
|
|
2813
|
+
}/* The footer already adds its own 12px top margin; after the disclosure that would
|
|
2814
|
+
double the header's bottom whitespace (12px padding + 12px margin) against the
|
|
2815
|
+
12px above it, so the two gaps are equalised here. */
|
|
1695
2816
|
.dsh-pe-advanced + .dsh-pe-form-footer { margin-top: 0; }
|
|
2817
|
+
/* Open: the first advanced row brings its own 12px top padding, so the header
|
|
2818
|
+
drops its bottom padding to keep the same rhythm between the two gaps. */
|
|
2819
|
+
.dsh-pe-advanced[open] > summary { padding-bottom: 0; }
|
|
1696
2820
|
.dsh-pe-chip-reset:hover:not(:disabled),
|
|
1697
2821
|
.dsh-pe-chip-refresh:hover:not(:disabled) {
|
|
1698
2822
|
--pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
|
|
@@ -1741,7 +2865,7 @@ var CSS = `
|
|
|
1741
2865
|
font-size: 12px;
|
|
1742
2866
|
cursor: pointer;
|
|
1743
2867
|
}
|
|
1744
|
-
.dsh-pe-save-button:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
|
|
2868
|
+
.dsh-pe-save-button:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
|
|
1745
2869
|
.dsh-pe-save-button:disabled { opacity: 0.5; cursor: default; }
|
|
1746
2870
|
`;
|
|
1747
2871
|
function ensureStyles() {
|
|
@@ -1791,6 +2915,28 @@ function matchesShortcut(event, combo) {
|
|
|
1791
2915
|
if (combo === null) return false;
|
|
1792
2916
|
return event.ctrlKey === combo.ctrl && event.altKey === combo.alt && event.shiftKey === combo.shift && event.metaKey === combo.meta && (event.code === combo.code || event.key.toLowerCase() === combo.key);
|
|
1793
2917
|
}
|
|
2918
|
+
function keyTokenOf(event) {
|
|
2919
|
+
const letter = /^Key([A-Z])$/.exec(event.code)?.[1];
|
|
2920
|
+
if (letter !== void 0) return letter.toLowerCase();
|
|
2921
|
+
const digit = /^Digit([0-9])$/.exec(event.code)?.[1];
|
|
2922
|
+
if (digit !== void 0) return digit;
|
|
2923
|
+
const fn = /^F([1-9]|1[0-2])$/.exec(event.code)?.[1];
|
|
2924
|
+
if (fn !== void 0) return `f${fn}`;
|
|
2925
|
+
const byKey = event.key.toLowerCase();
|
|
2926
|
+
return isKeyToken(byKey) ? byKey : null;
|
|
2927
|
+
}
|
|
2928
|
+
function shortcutSpecOf(event) {
|
|
2929
|
+
if (!event.ctrlKey && !event.altKey && !event.metaKey) return null;
|
|
2930
|
+
const token = keyTokenOf(event);
|
|
2931
|
+
if (token === null) return null;
|
|
2932
|
+
const parts = [];
|
|
2933
|
+
if (event.ctrlKey) parts.push("ctrl");
|
|
2934
|
+
if (event.altKey) parts.push("alt");
|
|
2935
|
+
if (event.shiftKey) parts.push("shift");
|
|
2936
|
+
if (event.metaKey) parts.push("meta");
|
|
2937
|
+
parts.push(token);
|
|
2938
|
+
return parts.join("+");
|
|
2939
|
+
}
|
|
1794
2940
|
|
|
1795
2941
|
// src/client/settings-source.ts
|
|
1796
2942
|
var RANK = {
|
|
@@ -1813,6 +2959,14 @@ function servedNamespaces(forms) {
|
|
|
1813
2959
|
return [];
|
|
1814
2960
|
}
|
|
1815
2961
|
}
|
|
2962
|
+
function adoptWriter(form, highest) {
|
|
2963
|
+
if (typeof form.set !== "function" || typeof form.unset !== "function") return;
|
|
2964
|
+
if (!highest && getSettingsWriter() !== void 0) return;
|
|
2965
|
+
setSettingsWriter({
|
|
2966
|
+
set: (field, value) => form.set?.(field, value) ?? Promise.resolve(false),
|
|
2967
|
+
unset: (field) => form.unset?.(field) ?? Promise.resolve(false)
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
1816
2970
|
function installClientSettingsSource(ctx, options) {
|
|
1817
2971
|
let rank = RANK.none;
|
|
1818
2972
|
const adopt = (next, section) => {
|
|
@@ -1853,6 +3007,7 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1853
3007
|
unsubscribeForm = void 0;
|
|
1854
3008
|
boundId = entryId;
|
|
1855
3009
|
adoptSnapshot(RANK.configForms, form);
|
|
3010
|
+
adoptWriter(form, true);
|
|
1856
3011
|
try {
|
|
1857
3012
|
unsubscribeForm = form.subscribe?.(() => adoptSnapshot(RANK.configForms, form));
|
|
1858
3013
|
} catch {
|
|
@@ -1881,212 +3036,76 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1881
3036
|
},
|
|
1882
3037
|
"dsh-prompt-enhance: settings namespace watch"
|
|
1883
3038
|
);
|
|
1884
|
-
}
|
|
1885
|
-
} catch {
|
|
1886
|
-
}
|
|
1887
|
-
});
|
|
1888
|
-
ctx.inject(["webUiSettings"], (binderCtx) => {
|
|
1889
|
-
const binder = binderCtx.webUiSettings;
|
|
1890
|
-
if (binder === void 0 || typeof binder.bind !== "function") return;
|
|
1891
|
-
let bound;
|
|
1892
|
-
for (const namespace of options.rowIds) {
|
|
1893
|
-
try {
|
|
1894
|
-
bound = binder.bind({ namespace });
|
|
1895
|
-
} catch {
|
|
1896
|
-
bound = void 0;
|
|
1897
|
-
}
|
|
1898
|
-
if (bound !== void 0) break;
|
|
1899
|
-
}
|
|
1900
|
-
if (bound === void 0) return;
|
|
1901
|
-
adoptSnapshot(RANK.binder, bound);
|
|
1902
|
-
let unsubscribe;
|
|
1903
|
-
try {
|
|
1904
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.binder, bound));
|
|
1905
|
-
} catch {
|
|
1906
|
-
unsubscribe = void 0;
|
|
1907
|
-
}
|
|
1908
|
-
ctx.effect(
|
|
1909
|
-
() => () => {
|
|
1910
|
-
try {
|
|
1911
|
-
unsubscribe?.();
|
|
1912
|
-
} catch {
|
|
1913
|
-
}
|
|
1914
|
-
},
|
|
1915
|
-
"dsh-prompt-enhance: settings binder mirror"
|
|
1916
|
-
);
|
|
1917
|
-
});
|
|
1918
|
-
ctx.inject(["settingsScope"], (scopeCtx) => {
|
|
1919
|
-
const scopeCtxLike = scopeCtx;
|
|
1920
|
-
const scope = scopeCtxLike.settingsScope;
|
|
1921
|
-
if (scope === void 0 || typeof scope.bind !== "function") return;
|
|
1922
|
-
let bound;
|
|
1923
|
-
try {
|
|
1924
|
-
bound = scope.bind({ namespace: options.rowIds[0] ?? "dsh-prompt-enhance", decode: (value) => value });
|
|
1925
|
-
} catch {
|
|
1926
|
-
return;
|
|
1927
|
-
}
|
|
1928
|
-
adoptSnapshot(RANK.legacyScope, bound);
|
|
1929
|
-
let unsubscribe;
|
|
1930
|
-
try {
|
|
1931
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.legacyScope, bound));
|
|
1932
|
-
} catch {
|
|
1933
|
-
unsubscribe = void 0;
|
|
1934
|
-
}
|
|
1935
|
-
ctx.effect(
|
|
1936
|
-
() => () => {
|
|
1937
|
-
try {
|
|
1938
|
-
unsubscribe?.();
|
|
1939
|
-
} catch {
|
|
1940
|
-
}
|
|
1941
|
-
},
|
|
1942
|
-
"dsh-prompt-enhance: settings scope mirror"
|
|
1943
|
-
);
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
// src/client/settings-page.tsx
|
|
1948
|
-
var import_react9 = require("react");
|
|
1949
|
-
|
|
1950
|
-
// src/client/llm-catalog.ts
|
|
1951
|
-
var import_react7 = require("react");
|
|
1952
|
-
|
|
1953
|
-
// src/shared/catalog.ts
|
|
1954
|
-
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
1955
|
-
var LLM_MODELS_ENDPOINT = "/dsh-prompt-enhance/llm-models";
|
|
1956
|
-
var LLM_ROUTE_CHECK_ENDPOINT = "/dsh-prompt-enhance/llm-route-check";
|
|
1957
|
-
|
|
1958
|
-
// src/client/llm-catalog.ts
|
|
1959
|
-
async function getJson(url, signal) {
|
|
1960
|
-
try {
|
|
1961
|
-
const response = await fetch(url, { signal, headers: { accept: "application/json" } });
|
|
1962
|
-
if (!response.ok) return void 0;
|
|
1963
|
-
const body = await response.json();
|
|
1964
|
-
const envelope = body;
|
|
1965
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) return void 0;
|
|
1966
|
-
return envelope.value;
|
|
1967
|
-
} catch {
|
|
1968
|
-
return void 0;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
function endpoint(path, params = {}) {
|
|
1972
|
-
const url = new URL(path, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
1973
|
-
for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
|
|
1974
|
-
return url;
|
|
1975
|
-
}
|
|
1976
|
-
async function fetchProviders(signal) {
|
|
1977
|
-
const value = await getJson(endpoint(LLM_PROVIDERS_ENDPOINT), signal);
|
|
1978
|
-
if (value === void 0 || !Array.isArray(value.providers)) return void 0;
|
|
1979
|
-
return value.providers.filter(
|
|
1980
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== "" && typeof entry.registered === "boolean"
|
|
1981
|
-
);
|
|
1982
|
-
}
|
|
1983
|
-
async function fetchModels(provider, signal) {
|
|
1984
|
-
const value = await getJson(endpoint(LLM_MODELS_ENDPOINT, { provider }), signal);
|
|
1985
|
-
if (value === void 0 || !Array.isArray(value.models)) return void 0;
|
|
1986
|
-
const models = value.models.filter(
|
|
1987
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== ""
|
|
1988
|
-
).map((entry) => ({
|
|
1989
|
-
id: entry.id,
|
|
1990
|
-
name: entry.name,
|
|
1991
|
-
...typeof entry.description === "string" && entry.description !== "" ? { description: entry.description } : {}
|
|
1992
|
-
}));
|
|
1993
|
-
return { models, ...typeof value.reason === "string" ? { reason: value.reason } : {} };
|
|
1994
|
-
}
|
|
1995
|
-
async function fetchRouteCheck(provider, model, signal) {
|
|
1996
|
-
const value = await getJson(endpoint(LLM_ROUTE_CHECK_ENDPOINT, { provider, model }), signal);
|
|
1997
|
-
if (value === void 0 || typeof value.available !== "boolean") return void 0;
|
|
1998
|
-
return value;
|
|
1999
|
-
}
|
|
2000
|
-
function useLlmRouting(provider, model) {
|
|
2001
|
-
const [providers, setProviders] = (0, import_react7.useState)([]);
|
|
2002
|
-
const [providersLoading, setProvidersLoading] = (0, import_react7.useState)(true);
|
|
2003
|
-
const [providersFailed, setProvidersFailed] = (0, import_react7.useState)(false);
|
|
2004
|
-
const [providersToken, setProvidersToken] = (0, import_react7.useState)(0);
|
|
2005
|
-
const [models, setModels] = (0, import_react7.useState)([]);
|
|
2006
|
-
const [modelsLoading, setModelsLoading] = (0, import_react7.useState)(false);
|
|
2007
|
-
const [modelsFailed, setModelsFailed] = (0, import_react7.useState)(false);
|
|
2008
|
-
const [modelsToken, setModelsToken] = (0, import_react7.useState)(0);
|
|
2009
|
-
const [routeChecking, setRouteChecking] = (0, import_react7.useState)(false);
|
|
2010
|
-
const [routeAvailable, setRouteAvailable] = (0, import_react7.useState)(void 0);
|
|
2011
|
-
(0, import_react7.useEffect)(() => {
|
|
2012
|
-
const controller = new AbortController();
|
|
2013
|
-
setProvidersLoading(true);
|
|
2014
|
-
setProvidersFailed(false);
|
|
2015
|
-
void fetchProviders(controller.signal).then((entries) => {
|
|
2016
|
-
if (controller.signal.aborted) return;
|
|
2017
|
-
setProvidersLoading(false);
|
|
2018
|
-
if (entries === void 0) {
|
|
2019
|
-
setProvidersFailed(true);
|
|
2020
|
-
setProviders([]);
|
|
2021
|
-
return;
|
|
2022
|
-
}
|
|
2023
|
-
setProviders(entries);
|
|
2024
|
-
});
|
|
2025
|
-
return () => controller.abort();
|
|
2026
|
-
}, [providersToken]);
|
|
2027
|
-
(0, import_react7.useEffect)(() => {
|
|
2028
|
-
if (provider === "") {
|
|
2029
|
-
setModels([]);
|
|
2030
|
-
setModelsLoading(false);
|
|
2031
|
-
setModelsFailed(false);
|
|
2032
|
-
return;
|
|
3039
|
+
}
|
|
3040
|
+
} catch {
|
|
2033
3041
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
3042
|
+
});
|
|
3043
|
+
ctx.inject(["webUiSettings"], (binderCtx) => {
|
|
3044
|
+
const binder = binderCtx.webUiSettings;
|
|
3045
|
+
if (binder === void 0 || typeof binder.bind !== "function") return;
|
|
3046
|
+
let bound;
|
|
3047
|
+
for (const namespace of options.rowIds) {
|
|
3048
|
+
try {
|
|
3049
|
+
bound = binder.bind({ namespace });
|
|
3050
|
+
} catch {
|
|
3051
|
+
bound = void 0;
|
|
2044
3052
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
3053
|
+
if (bound !== void 0) break;
|
|
3054
|
+
}
|
|
3055
|
+
if (bound === void 0) return;
|
|
3056
|
+
adoptSnapshot(RANK.binder, bound);
|
|
3057
|
+
adoptWriter(bound, false);
|
|
3058
|
+
let unsubscribe;
|
|
3059
|
+
try {
|
|
3060
|
+
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.binder, bound));
|
|
3061
|
+
} catch {
|
|
3062
|
+
unsubscribe = void 0;
|
|
3063
|
+
}
|
|
3064
|
+
ctx.effect(
|
|
3065
|
+
() => () => {
|
|
3066
|
+
try {
|
|
3067
|
+
unsubscribe?.();
|
|
3068
|
+
} catch {
|
|
3069
|
+
}
|
|
3070
|
+
},
|
|
3071
|
+
"dsh-prompt-enhance: settings binder mirror"
|
|
3072
|
+
);
|
|
3073
|
+
});
|
|
3074
|
+
ctx.inject(["settingsScope"], (scopeCtx) => {
|
|
3075
|
+
const scopeCtxLike = scopeCtx;
|
|
3076
|
+
const scope = scopeCtxLike.settingsScope;
|
|
3077
|
+
if (scope === void 0 || typeof scope.bind !== "function") return;
|
|
3078
|
+
let bound;
|
|
3079
|
+
try {
|
|
3080
|
+
bound = scope.bind({ namespace: options.rowIds[0] ?? "dsh-prompt-enhance", decode: (value) => value });
|
|
3081
|
+
} catch {
|
|
2054
3082
|
return;
|
|
2055
3083
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
failed: providersFailed,
|
|
2075
|
-
entries: providers,
|
|
2076
|
-
reload: () => setProvidersToken((token) => token + 1)
|
|
2077
|
-
},
|
|
2078
|
-
models: {
|
|
2079
|
-
loading: modelsLoading,
|
|
2080
|
-
failed: modelsFailed,
|
|
2081
|
-
entries: models,
|
|
2082
|
-
reload: () => setModelsToken((token) => token + 1)
|
|
2083
|
-
},
|
|
2084
|
-
route: { checking: routeChecking, available: routeAvailable }
|
|
2085
|
-
};
|
|
3084
|
+
adoptSnapshot(RANK.legacyScope, bound);
|
|
3085
|
+
adoptWriter(bound, false);
|
|
3086
|
+
let unsubscribe;
|
|
3087
|
+
try {
|
|
3088
|
+
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.legacyScope, bound));
|
|
3089
|
+
} catch {
|
|
3090
|
+
unsubscribe = void 0;
|
|
3091
|
+
}
|
|
3092
|
+
ctx.effect(
|
|
3093
|
+
() => () => {
|
|
3094
|
+
try {
|
|
3095
|
+
unsubscribe?.();
|
|
3096
|
+
} catch {
|
|
3097
|
+
}
|
|
3098
|
+
},
|
|
3099
|
+
"dsh-prompt-enhance: settings scope mirror"
|
|
3100
|
+
);
|
|
3101
|
+
});
|
|
2086
3102
|
}
|
|
2087
3103
|
|
|
3104
|
+
// src/client/settings-page.tsx
|
|
3105
|
+
var import_react10 = require("react");
|
|
3106
|
+
|
|
2088
3107
|
// src/client/settings-page-spec.ts
|
|
2089
|
-
var
|
|
3108
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2090
3109
|
var SETTINGS_SECTION_SLOT = "settings.section";
|
|
2091
3110
|
var SETTINGS_SECTION_ID = "dsh-prompt-enhance";
|
|
2092
3111
|
var SETTINGS_SECTION_ORDER = 70;
|
|
@@ -2133,9 +3152,20 @@ var BASIC_ROWS = [
|
|
|
2133
3152
|
{ key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
|
|
2134
3153
|
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
2135
3154
|
{ key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
|
|
2136
|
-
{
|
|
3155
|
+
{
|
|
3156
|
+
key: "shortcut",
|
|
3157
|
+
kind: "text",
|
|
3158
|
+
label: "settings.row.shortcut.label",
|
|
3159
|
+
hint: "settings.row.shortcut.hint",
|
|
3160
|
+
placeholder: "settings.row.shortcut.placeholder",
|
|
3161
|
+
// Empty disables the shortcut, so it is valid; anything else must parse.
|
|
3162
|
+
validate: (text) => text.trim() === "" || parseShortcut(text) !== null,
|
|
3163
|
+
recordable: true
|
|
3164
|
+
}
|
|
2137
3165
|
];
|
|
2138
3166
|
var ADVANCED_ROWS = [
|
|
3167
|
+
{ key: "foldAnimation", kind: "boolean", label: "settings.row.foldAnimation.label", hint: "settings.row.foldAnimation.hint" },
|
|
3168
|
+
{ key: "autoFold", kind: "boolean", label: "settings.row.autoFold.label", hint: "settings.row.autoFold.hint" },
|
|
2139
3169
|
{ key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
|
|
2140
3170
|
{ key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
|
|
2141
3171
|
{ key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
|
|
@@ -2149,7 +3179,7 @@ var ROWS = [...BASIC_ROWS, ...ADVANCED_ROWS];
|
|
|
2149
3179
|
function descriptorOf(row) {
|
|
2150
3180
|
switch (row.kind) {
|
|
2151
3181
|
case "number":
|
|
2152
|
-
return (0,
|
|
3182
|
+
return (0, import_dsh_client_ui_primitives2.settingsNumberField)(row.key);
|
|
2153
3183
|
case "boolean":
|
|
2154
3184
|
return settingsBooleanField(row.key);
|
|
2155
3185
|
case "strategy":
|
|
@@ -2158,14 +3188,14 @@ function descriptorOf(row) {
|
|
|
2158
3188
|
STRATEGY_OPTIONS.map((option) => option.value)
|
|
2159
3189
|
);
|
|
2160
3190
|
case "reasoning":
|
|
2161
|
-
return (0,
|
|
3191
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2162
3192
|
default:
|
|
2163
|
-
return (0,
|
|
3193
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2164
3194
|
}
|
|
2165
3195
|
}
|
|
2166
3196
|
var FIELD_SPECS = ROWS.map((row) => descriptorOf(row));
|
|
2167
3197
|
function createSettingsForm(scope) {
|
|
2168
|
-
return new
|
|
3198
|
+
return new import_dsh_client_ui_primitives2.SettingsFormModel(scope, FIELD_SPECS);
|
|
2169
3199
|
}
|
|
2170
3200
|
function viewOf(snapshot, key) {
|
|
2171
3201
|
const value = snapshot[key];
|
|
@@ -2222,7 +3252,12 @@ function sectionCopy(t, chinese) {
|
|
|
2222
3252
|
saved: t("settings.saved"),
|
|
2223
3253
|
advanced: t("settings.advanced"),
|
|
2224
3254
|
reset: t("settings.reset"),
|
|
2225
|
-
invalidNumber: t("settings.invalidNumber")
|
|
3255
|
+
invalidNumber: t("settings.invalidNumber"),
|
|
3256
|
+
invalidShortcut: t("settings.invalidShortcut"),
|
|
3257
|
+
record: t("settings.record"),
|
|
3258
|
+
recordStop: t("settings.recordStop"),
|
|
3259
|
+
recordPrompt: t("settings.recordPrompt"),
|
|
3260
|
+
recordNeedsModifier: t("settings.recordNeedsModifier")
|
|
2226
3261
|
},
|
|
2227
3262
|
title: (row) => chinese ? `${row.key}\uFF08${t(row.label)}\uFF09` : row.key,
|
|
2228
3263
|
hint: (row) => t(row.hint),
|
|
@@ -2243,7 +3278,12 @@ function pageCopy(t) {
|
|
|
2243
3278
|
saved: t("settings.saved"),
|
|
2244
3279
|
advanced: t("settings.advanced"),
|
|
2245
3280
|
reset: t("settings.reset"),
|
|
2246
|
-
invalidNumber: t("settings.invalidNumber")
|
|
3281
|
+
invalidNumber: t("settings.invalidNumber"),
|
|
3282
|
+
invalidShortcut: t("settings.invalidShortcut"),
|
|
3283
|
+
record: t("settings.record"),
|
|
3284
|
+
recordStop: t("settings.recordStop"),
|
|
3285
|
+
recordPrompt: t("settings.recordPrompt"),
|
|
3286
|
+
recordNeedsModifier: t("settings.recordNeedsModifier")
|
|
2247
3287
|
},
|
|
2248
3288
|
title: (row) => t(row.label),
|
|
2249
3289
|
hint: (row) => t(row.hint),
|
|
@@ -2254,57 +3294,8 @@ function pageCopy(t) {
|
|
|
2254
3294
|
}
|
|
2255
3295
|
|
|
2256
3296
|
// src/client/settings-page-controls.tsx
|
|
2257
|
-
var
|
|
2258
|
-
var
|
|
2259
|
-
|
|
2260
|
-
// src/shared/reasoning.ts
|
|
2261
|
-
var REASONING_EFFORTS_ENDPOINT = "/dsh-prompt-enhance/reasoning-efforts";
|
|
2262
|
-
|
|
2263
|
-
// src/client/reasoning-options.ts
|
|
2264
|
-
function effortOf(value) {
|
|
2265
|
-
if (value === null || typeof value !== "object") return void 0;
|
|
2266
|
-
const record = value;
|
|
2267
|
-
if (typeof record.id !== "string" || record.id === "" || typeof record.name !== "string" || record.name === "") return void 0;
|
|
2268
|
-
return {
|
|
2269
|
-
id: record.id,
|
|
2270
|
-
name: record.name,
|
|
2271
|
-
...typeof record.description === "string" && record.description !== "" ? { description: record.description } : {}
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
function capabilitiesOf(value) {
|
|
2275
|
-
if (value === null || typeof value !== "object") return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2276
|
-
const record = value;
|
|
2277
|
-
const source = record.source === "resolved" || record.source === "default" || record.source === "unavailable" ? record.source : "unavailable";
|
|
2278
|
-
const efforts = Array.isArray(record.efforts) ? record.efforts.map(effortOf).filter((effort) => effort !== void 0) : [];
|
|
2279
|
-
const reason = typeof record.reason === "string" ? record.reason : void 0;
|
|
2280
|
-
if (source !== "unavailable" && efforts.length === 0) return { efforts: [], source: "unavailable", reason: "no-efforts" };
|
|
2281
|
-
return {
|
|
2282
|
-
efforts,
|
|
2283
|
-
source,
|
|
2284
|
-
...typeof record.defaultEffort === "string" && record.defaultEffort !== "" ? { defaultEffort: record.defaultEffort } : {},
|
|
2285
|
-
...reason === void 0 ? {} : { reason }
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
2289
|
-
const url = new URL(REASONING_EFFORTS_ENDPOINT, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
2290
|
-
if (provider !== void 0 && model !== void 0) {
|
|
2291
|
-
url.searchParams.set("provider", provider);
|
|
2292
|
-
url.searchParams.set("model", model);
|
|
2293
|
-
}
|
|
2294
|
-
if (options.refresh === true) url.searchParams.set("refresh", "1");
|
|
2295
|
-
try {
|
|
2296
|
-
const response = await fetch(url, { signal: options.signal, headers: { accept: "application/json" } });
|
|
2297
|
-
if (!response.ok) return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2298
|
-
const body = await response.json();
|
|
2299
|
-
const envelope = body;
|
|
2300
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) {
|
|
2301
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2302
|
-
}
|
|
2303
|
-
return capabilitiesOf(envelope.value);
|
|
2304
|
-
} catch {
|
|
2305
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
3297
|
+
var import_react9 = require("react");
|
|
3298
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2308
3299
|
|
|
2309
3300
|
// src/client/settings-page-styles.ts
|
|
2310
3301
|
var ROW_STYLE = { display: "flex", flexDirection: "column", gap: 6, padding: "12px 0" };
|
|
@@ -2329,6 +3320,13 @@ var STATUS_STYLE = {
|
|
|
2329
3320
|
lineHeight: 1.5,
|
|
2330
3321
|
color: "var(--dsw-alias-label-secondary, inherit)"
|
|
2331
3322
|
};
|
|
3323
|
+
var NOTICE_STYLE = {
|
|
3324
|
+
margin: 0,
|
|
3325
|
+
fontSize: 12.5,
|
|
3326
|
+
fontWeight: 500,
|
|
3327
|
+
lineHeight: 1.5,
|
|
3328
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
3329
|
+
};
|
|
2332
3330
|
var CHIP_STYLE = {
|
|
2333
3331
|
display: "inline-flex",
|
|
2334
3332
|
alignItems: "center",
|
|
@@ -2347,20 +3345,34 @@ var CHIP_STYLE = {
|
|
|
2347
3345
|
};
|
|
2348
3346
|
var REFRESH_STYLE = { ...CHIP_STYLE, flex: "none" };
|
|
2349
3347
|
var RESET_STYLE = CHIP_STYLE;
|
|
2350
|
-
var
|
|
2351
|
-
var
|
|
3348
|
+
var RECORD_STYLE = CHIP_STYLE;
|
|
3349
|
+
var FIELD_BORDER = "1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.38))";
|
|
3350
|
+
var FIELD_BOX_STYLE = {
|
|
2352
3351
|
boxSizing: "border-box",
|
|
2353
3352
|
width: "100%",
|
|
2354
3353
|
height: 34,
|
|
2355
3354
|
padding: "0 12px",
|
|
2356
3355
|
border: FIELD_BORDER,
|
|
2357
3356
|
borderRadius: "var(--dsw-radius-md, 8px)",
|
|
2358
|
-
background: "var(--dsw-alias-bg-layer-3, transparent)"
|
|
3357
|
+
background: "var(--dsw-alias-bg-layer-3, transparent)"
|
|
3358
|
+
};
|
|
3359
|
+
var FIELD_SHELL_STYLE = {
|
|
3360
|
+
...FIELD_BOX_STYLE,
|
|
3361
|
+
display: "flex",
|
|
3362
|
+
alignItems: "center"
|
|
3363
|
+
};
|
|
3364
|
+
var FIELD_INPUT_STYLE = {
|
|
3365
|
+
flex: "1 1 auto",
|
|
3366
|
+
minWidth: 0,
|
|
3367
|
+
margin: 0,
|
|
3368
|
+
padding: 0,
|
|
3369
|
+
border: "none",
|
|
3370
|
+
outline: "none",
|
|
3371
|
+
background: "transparent",
|
|
2359
3372
|
font: "inherit",
|
|
2360
3373
|
fontSize: 13,
|
|
2361
|
-
lineHeight:
|
|
2362
|
-
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2363
|
-
outline: "none"
|
|
3374
|
+
lineHeight: "22px",
|
|
3375
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2364
3376
|
};
|
|
2365
3377
|
var INVALID_STYLE = {
|
|
2366
3378
|
margin: 0,
|
|
@@ -2375,7 +3387,13 @@ var WARN_STYLE = {
|
|
|
2375
3387
|
color: "var(--dsw-alias-state-error-primary, #f85149)"
|
|
2376
3388
|
};
|
|
2377
3389
|
var SELECT_STYLE = {
|
|
2378
|
-
...
|
|
3390
|
+
...FIELD_BOX_STYLE,
|
|
3391
|
+
paddingLeft: 9,
|
|
3392
|
+
font: "inherit",
|
|
3393
|
+
fontSize: 13,
|
|
3394
|
+
lineHeight: 1.5,
|
|
3395
|
+
color: "var(--dsw-alias-label-primary, inherit)",
|
|
3396
|
+
outline: "none",
|
|
2379
3397
|
cursor: "pointer"
|
|
2380
3398
|
};
|
|
2381
3399
|
var SEPARATOR_STYLE = {
|
|
@@ -2385,7 +3403,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
|
|
|
2385
3403
|
var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
2386
3404
|
var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
|
|
2387
3405
|
var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
|
|
2388
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
3406
|
+
var PLUGIN_VERSION = true ? "0.1.2" : "0.0.0";
|
|
2389
3407
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
2390
3408
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
2391
3409
|
var HEADER_TITLE_STYLE = {
|
|
@@ -2432,28 +3450,28 @@ var HEADER_DESCRIPTION_STYLE = {
|
|
|
2432
3450
|
};
|
|
2433
3451
|
|
|
2434
3452
|
// src/client/settings-page-controls.tsx
|
|
2435
|
-
var
|
|
3453
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2436
3454
|
function OverrideActions(props) {
|
|
2437
|
-
return /* @__PURE__ */ (0,
|
|
3455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "dsh-pe-chip-reset", style: { ...RESET_STYLE, ...props.disabled ? { opacity: 0.5, cursor: "default" } : {} }, disabled: props.disabled, onClick: props.onReset, children: props.copy.labels.reset });
|
|
2438
3456
|
}
|
|
2439
3457
|
function BooleanRow(props) {
|
|
2440
|
-
return /* @__PURE__ */ (0,
|
|
2441
|
-
/* @__PURE__ */ (0,
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2443
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
2444
|
-
/* @__PURE__ */ (0,
|
|
3458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3461
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null,
|
|
3462
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives3.Switch, { checked: props.view.text === "true", disabled: props.disabled, label: props.label, onChange: (next) => props.onEdit(next ? "true" : "false") })
|
|
2445
3463
|
] }),
|
|
2446
|
-
/* @__PURE__ */ (0,
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2447
3465
|
] });
|
|
2448
3466
|
}
|
|
2449
3467
|
function ChoiceRow(props) {
|
|
2450
|
-
return /* @__PURE__ */ (0,
|
|
2451
|
-
/* @__PURE__ */ (0,
|
|
2452
|
-
/* @__PURE__ */ (0,
|
|
2453
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3469
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3470
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3471
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2454
3472
|
] }),
|
|
2455
|
-
/* @__PURE__ */ (0,
|
|
2456
|
-
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3474
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2457
3475
|
{
|
|
2458
3476
|
id: props.id,
|
|
2459
3477
|
className: "dsh-pe-segmented-labels",
|
|
@@ -2464,23 +3482,30 @@ function ChoiceRow(props) {
|
|
|
2464
3482
|
onChange: (next) => props.onEdit(next)
|
|
2465
3483
|
}
|
|
2466
3484
|
),
|
|
2467
|
-
/* @__PURE__ */ (0,
|
|
3485
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2468
3486
|
] });
|
|
2469
3487
|
}
|
|
3488
|
+
var capabilityCache = /* @__PURE__ */ new Map();
|
|
3489
|
+
function capabilityKey(provider, model) {
|
|
3490
|
+
return `${provider}\0${model}`;
|
|
3491
|
+
}
|
|
2470
3492
|
function ReasoningRow(props) {
|
|
2471
3493
|
const pair = props.provider !== "" && props.model !== "" ? `${props.provider}/${props.model}` : "";
|
|
2472
|
-
const
|
|
2473
|
-
const
|
|
2474
|
-
const [
|
|
2475
|
-
const [
|
|
2476
|
-
const
|
|
2477
|
-
const
|
|
2478
|
-
(0,
|
|
3494
|
+
const cacheKey = capabilityKey(props.provider, props.model);
|
|
3495
|
+
const cached = capabilityCache.get(cacheKey);
|
|
3496
|
+
const [phase, setPhase] = (0, import_react9.useState)(cached === void 0 ? "loading" : "ready");
|
|
3497
|
+
const [capabilities, setCapabilities] = (0, import_react9.useState)(cached);
|
|
3498
|
+
const [refreshToken, setRefreshToken] = (0, import_react9.useState)(0);
|
|
3499
|
+
const [feedback, setFeedback] = (0, import_react9.useState)("idle");
|
|
3500
|
+
const forceRef = (0, import_react9.useRef)(false);
|
|
3501
|
+
const feedbackTimer = (0, import_react9.useRef)(void 0);
|
|
3502
|
+
(0, import_react9.useEffect)(() => {
|
|
2479
3503
|
const controller = new AbortController();
|
|
2480
3504
|
const force = forceRef.current;
|
|
2481
3505
|
forceRef.current = false;
|
|
2482
|
-
|
|
2483
|
-
|
|
3506
|
+
const known = capabilityCache.get(cacheKey);
|
|
3507
|
+
setPhase(known === void 0 ? "loading" : "ready");
|
|
3508
|
+
setCapabilities(known);
|
|
2484
3509
|
setFeedback(force ? "refreshing" : "idle");
|
|
2485
3510
|
if (feedbackTimer.current !== void 0) {
|
|
2486
3511
|
clearTimeout(feedbackTimer.current);
|
|
@@ -2498,6 +3523,7 @@ function ReasoningRow(props) {
|
|
|
2498
3523
|
if (controller.signal.aborted) return;
|
|
2499
3524
|
setCapabilities(answer);
|
|
2500
3525
|
setPhase("ready");
|
|
3526
|
+
if (answer.source !== "unavailable" || answer.reason === "no-efforts") capabilityCache.set(cacheKey, answer);
|
|
2501
3527
|
settle(answer.source === "unavailable" ? "failed" : "ok");
|
|
2502
3528
|
}).catch(() => {
|
|
2503
3529
|
if (controller.signal.aborted) return;
|
|
@@ -2512,15 +3538,20 @@ function ReasoningRow(props) {
|
|
|
2512
3538
|
feedbackTimer.current = void 0;
|
|
2513
3539
|
}
|
|
2514
3540
|
};
|
|
2515
|
-
}, [pair, refreshToken]);
|
|
2516
|
-
const
|
|
2517
|
-
const realTierKnown = phase === "ready" && capabilities !== void 0 && capabilities.source !== "unavailable" && capabilities.efforts.some((effort) => effort.id ===
|
|
3541
|
+
}, [cacheKey, pair, refreshToken]);
|
|
3542
|
+
const current3 = props.view.text;
|
|
3543
|
+
const realTierKnown = phase === "ready" && capabilities !== void 0 && capabilities.source !== "unavailable" && capabilities.efforts.some((effort) => effort.id === current3);
|
|
2518
3544
|
const noTiers = phase === "ready" && capabilities !== void 0 && capabilities.source === "unavailable" && capabilities.reason === "no-efforts";
|
|
2519
3545
|
const options = [];
|
|
2520
|
-
|
|
3546
|
+
options.push({
|
|
3547
|
+
value: "inherit",
|
|
3548
|
+
label: props.copy.choice("settings.reasoning.inherit"),
|
|
3549
|
+
title: props.copy.choice("settings.reasoning.inherit")
|
|
3550
|
+
});
|
|
3551
|
+
if (!noTiers && current3 !== "" && current3 !== "inherit" && !realTierKnown) {
|
|
2521
3552
|
options.push({
|
|
2522
|
-
value:
|
|
2523
|
-
label: props.copy.interpolate("settings.reasoning.current", { value:
|
|
3553
|
+
value: current3,
|
|
3554
|
+
label: props.copy.interpolate("settings.reasoning.current", { value: current3 }),
|
|
2524
3555
|
title: props.copy.choice("settings.reasoning.currentTitle")
|
|
2525
3556
|
});
|
|
2526
3557
|
}
|
|
@@ -2533,46 +3564,42 @@ function ReasoningRow(props) {
|
|
|
2533
3564
|
});
|
|
2534
3565
|
}
|
|
2535
3566
|
}
|
|
2536
|
-
options.
|
|
2537
|
-
|
|
2538
|
-
label: props.copy.choice("settings.reasoning.inherit"),
|
|
2539
|
-
title: props.copy.choice("settings.reasoning.inherit")
|
|
2540
|
-
});
|
|
2541
|
-
const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current2 !== "" && current2 !== "inherit" && !realTierKnown;
|
|
3567
|
+
const selected = options.some((option) => option.value === current3) ? current3 : "inherit";
|
|
3568
|
+
const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current3 !== "" && current3 !== "inherit" && !realTierKnown;
|
|
2542
3569
|
const refreshing = feedback === "refreshing";
|
|
2543
3570
|
const refresh = () => {
|
|
2544
3571
|
forceRef.current = true;
|
|
2545
3572
|
setRefreshToken((token) => token + 1);
|
|
2546
3573
|
};
|
|
2547
|
-
return /* @__PURE__ */ (0,
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2550
|
-
phase === "ready" || refreshing ? /* @__PURE__ */ (0,
|
|
2551
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3575
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3576
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3577
|
+
phase === "ready" || refreshing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "dsh-pe-chip-refresh", style: { ...REFRESH_STYLE, opacity: props.disabled || refreshing ? 0.5 : 1 }, disabled: props.disabled || refreshing, onClick: refresh, children: props.copy.choice(refreshing ? "settings.reasoning.refreshing" : "settings.reasoning.refresh") }) : null,
|
|
3578
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2552
3579
|
] }),
|
|
2553
|
-
/* @__PURE__ */ (0,
|
|
2554
|
-
|
|
3580
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3581
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2555
3582
|
{
|
|
2556
3583
|
id: props.id,
|
|
2557
3584
|
className: "dsh-pe-segmented-labels",
|
|
2558
|
-
value:
|
|
3585
|
+
value: selected,
|
|
2559
3586
|
options,
|
|
2560
3587
|
disabled: props.disabled,
|
|
2561
3588
|
label: props.label,
|
|
2562
3589
|
onChange: (next) => props.onEdit(next)
|
|
2563
3590
|
}
|
|
2564
3591
|
),
|
|
2565
|
-
/* @__PURE__ */ (0,
|
|
2566
|
-
phase === "loading" ? /* @__PURE__ */ (0,
|
|
2567
|
-
phase === "ready" && capabilities?.source === "unavailable" ? /* @__PURE__ */ (0,
|
|
2568
|
-
unsupported ? /* @__PURE__ */ (0,
|
|
2569
|
-
feedback === "ok" ? /* @__PURE__ */ (0,
|
|
2570
|
-
feedback === "failed" ? /* @__PURE__ */ (0,
|
|
3592
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3593
|
+
phase === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.reasoning.loading") }) : null,
|
|
3594
|
+
phase === "ready" && capabilities?.source === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice(noTiers ? "settings.reasoning.noTiers" : "settings.reasoning.unavailable") }) : null,
|
|
3595
|
+
unsupported ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.interpolate("settings.reasoning.unsupported", { effort: props.view.text }) }) : null,
|
|
3596
|
+
feedback === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, "aria-live": "polite", children: props.copy.choice("settings.reasoning.refreshOk") }) : null,
|
|
3597
|
+
feedback === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, "aria-live": "polite", children: props.copy.choice("settings.reasoning.refreshFailed") }) : null
|
|
2571
3598
|
] });
|
|
2572
3599
|
}
|
|
2573
3600
|
function SelectControl(props) {
|
|
2574
|
-
const [focused, setFocused] = (0,
|
|
2575
|
-
return /* @__PURE__ */ (0,
|
|
3601
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2576
3603
|
"select",
|
|
2577
3604
|
{
|
|
2578
3605
|
id: props.id,
|
|
@@ -2587,50 +3614,50 @@ function SelectControl(props) {
|
|
|
2587
3614
|
);
|
|
2588
3615
|
}
|
|
2589
3616
|
function ProviderRow(props) {
|
|
2590
|
-
const
|
|
2591
|
-
const known = props.routing.providers.entries.find((entry) => entry.id ===
|
|
2592
|
-
const missing =
|
|
3617
|
+
const current3 = props.view.text;
|
|
3618
|
+
const known = props.routing.providers.entries.find((entry) => entry.id === current3);
|
|
3619
|
+
const missing = current3 !== "" && known === void 0;
|
|
2593
3620
|
const unconfigured = known !== void 0 && !known.registered;
|
|
2594
|
-
return /* @__PURE__ */ (0,
|
|
2595
|
-
/* @__PURE__ */ (0,
|
|
2596
|
-
/* @__PURE__ */ (0,
|
|
2597
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3622
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3624
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2598
3625
|
] }),
|
|
2599
|
-
/* @__PURE__ */ (0,
|
|
2600
|
-
/* @__PURE__ */ (0,
|
|
2601
|
-
missing ? /* @__PURE__ */ (0,
|
|
2602
|
-
/* @__PURE__ */ (0,
|
|
2603
|
-
props.routing.providers.entries.some((entry) => !entry.registered) ? /* @__PURE__ */ (0,
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(SelectControl, { id: props.id, value: current3, disabled: props.disabled, onChange: (value) => props.onEdit(value), children: [
|
|
3627
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: props.copy.choice("settings.routing.followSession") }),
|
|
3628
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: current3, title: current3, children: props.copy.interpolate("settings.routing.currentProvider", { value: current3 }) }) : null,
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: props.copy.choice("settings.routing.groupRegistered"), children: props.routing.providers.entries.filter((entry) => entry.registered).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: entry.id, title: entry.id, children: entry.name }, entry.id)) }),
|
|
3630
|
+
props.routing.providers.entries.some((entry) => !entry.registered) ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: props.copy.choice("settings.routing.groupDormant"), children: props.routing.providers.entries.filter((entry) => !entry.registered).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: entry.id, disabled: true, title: props.copy.choice("settings.routing.unconfiguredTitle"), children: [
|
|
2604
3631
|
entry.name,
|
|
2605
3632
|
props.copy.choice("settings.routing.unconfiguredSuffix")
|
|
2606
3633
|
] }, entry.id)) }) : null
|
|
2607
3634
|
] }),
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
props.routing.providers.loading ? /* @__PURE__ */ (0,
|
|
2610
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2611
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2612
|
-
missing ? /* @__PURE__ */ (0,
|
|
2613
|
-
unconfigured ? /* @__PURE__ */ (0,
|
|
3635
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3636
|
+
props.routing.providers.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.providersLoading") }) : null,
|
|
3637
|
+
props.routing.providers.failed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.providersFailed") }) : null,
|
|
3638
|
+
props.routing.providers.failed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", style: REFRESH_STYLE, onClick: props.routing.providers.reload, children: props.copy.choice("settings.routing.retry") }) : null,
|
|
3639
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.interpolate("settings.routing.providerMissing", { value: current3 }) }) : null,
|
|
3640
|
+
unconfigured ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.interpolate("settings.routing.providerUnconfigured", { name: known.name }) }) : null
|
|
2614
3641
|
] });
|
|
2615
3642
|
}
|
|
2616
3643
|
function ModelRow(props) {
|
|
2617
|
-
const
|
|
3644
|
+
const current3 = props.view.text;
|
|
2618
3645
|
const provider = props.providerValue;
|
|
2619
|
-
const [customMode, setCustomMode] = (0,
|
|
2620
|
-
const known = props.routing.models.entries.some((entry) => entry.id ===
|
|
2621
|
-
const showCustom = provider !== "" && (customMode ||
|
|
2622
|
-
const pairIncomplete = provider !== "" &&
|
|
2623
|
-
const routeUnavailable = provider !== "" &&
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2627
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3646
|
+
const [customMode, setCustomMode] = (0, import_react9.useState)(false);
|
|
3647
|
+
const known = props.routing.models.entries.some((entry) => entry.id === current3);
|
|
3648
|
+
const showCustom = provider !== "" && (customMode || current3 !== "" && !known);
|
|
3649
|
+
const pairIncomplete = provider !== "" && current3 === "";
|
|
3650
|
+
const routeUnavailable = provider !== "" && current3 !== "" && props.routing.route.available === false;
|
|
3651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3652
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3653
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3654
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2628
3655
|
] }),
|
|
2629
|
-
/* @__PURE__ */ (0,
|
|
3656
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2630
3657
|
SelectControl,
|
|
2631
3658
|
{
|
|
2632
3659
|
id: props.id,
|
|
2633
|
-
value: showCustom ? "__custom__" :
|
|
3660
|
+
value: showCustom ? "__custom__" : current3,
|
|
2634
3661
|
disabled: props.disabled || provider === "",
|
|
2635
3662
|
onChange: (value) => {
|
|
2636
3663
|
if (value === "__custom__") {
|
|
@@ -2641,68 +3668,131 @@ function ModelRow(props) {
|
|
|
2641
3668
|
props.onEdit(value);
|
|
2642
3669
|
},
|
|
2643
3670
|
children: [
|
|
2644
|
-
/* @__PURE__ */ (0,
|
|
2645
|
-
props.routing.models.entries.map((entry) => /* @__PURE__ */ (0,
|
|
2646
|
-
provider !== "" &&
|
|
2647
|
-
provider !== "" ? /* @__PURE__ */ (0,
|
|
3671
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: provider === "" ? props.copy.choice("settings.routing.followSession") : props.copy.choice("settings.routing.selectModel") }),
|
|
3672
|
+
props.routing.models.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: entry.id, title: entry.id, children: entry.name }, entry.id)),
|
|
3673
|
+
provider !== "" && current3 !== "" && !known ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: current3, title: current3, children: props.copy.interpolate("settings.routing.currentModel", { value: current3 }) }) : null,
|
|
3674
|
+
provider !== "" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "__custom__", children: props.copy.choice("settings.routing.custom") }) : null
|
|
2648
3675
|
]
|
|
2649
3676
|
}
|
|
2650
3677
|
),
|
|
2651
|
-
showCustom ? /* @__PURE__ */ (0,
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3678
|
+
showCustom ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3679
|
+
TextControl,
|
|
3680
|
+
{
|
|
3681
|
+
value: current3,
|
|
3682
|
+
placeholder: props.copy.choice("settings.routing.customPlaceholder"),
|
|
3683
|
+
disabled: props.disabled,
|
|
3684
|
+
onChange: (text) => props.onEdit(text, { deferred: true }),
|
|
3685
|
+
onCommit: props.onCommit
|
|
3686
|
+
}
|
|
3687
|
+
) : null,
|
|
3688
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3689
|
+
props.routing.models.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.modelsLoading") }) : null,
|
|
3690
|
+
props.routing.models.failed && !showCustom ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.modelsFailed") }) : null,
|
|
3691
|
+
pairIncomplete ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.choice("settings.routing.pairIncomplete") }) : null,
|
|
3692
|
+
routeUnavailable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.choice("settings.routing.routeUnavailable") }) : null
|
|
2657
3693
|
] });
|
|
2658
3694
|
}
|
|
2659
3695
|
function TextControl(props) {
|
|
2660
|
-
const [focused, setFocused] = (0,
|
|
2661
|
-
const [revealedInvalid, setRevealedInvalid] = (0,
|
|
2662
|
-
(0,
|
|
3696
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3697
|
+
const [revealedInvalid, setRevealedInvalid] = (0, import_react9.useState)(false);
|
|
3698
|
+
(0, import_react9.useEffect)(() => {
|
|
2663
3699
|
if (props.invalid !== true) setRevealedInvalid(false);
|
|
2664
3700
|
}, [props.invalid]);
|
|
2665
3701
|
const showInvalid = props.invalid === true && revealedInvalid;
|
|
2666
3702
|
const borderColor = showInvalid ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
|
|
2667
|
-
return
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
3703
|
+
return (
|
|
3704
|
+
// Host primitives Input: a flex shell centers a borderless inner input, so
|
|
3705
|
+
// the text sits on the shell's center line instead of relying on a fixed
|
|
3706
|
+
// height plus a line-height to be centered by the browser.
|
|
3707
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { ...FIELD_SHELL_STYLE, ...borderColor === void 0 ? {} : { borderColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3708
|
+
"input",
|
|
3709
|
+
{
|
|
3710
|
+
id: props.id,
|
|
3711
|
+
type: "text",
|
|
3712
|
+
inputMode: props.numeric === true ? "numeric" : void 0,
|
|
3713
|
+
"aria-invalid": showInvalid || void 0,
|
|
3714
|
+
disabled: props.disabled,
|
|
3715
|
+
placeholder: props.placeholder,
|
|
3716
|
+
value: props.value,
|
|
3717
|
+
style: {
|
|
3718
|
+
...FIELD_INPUT_STYLE,
|
|
3719
|
+
...props.disabled === true ? { color: "var(--dsw-alias-label-tertiary, inherit)", cursor: "default" } : {}
|
|
3720
|
+
},
|
|
3721
|
+
onFocus: () => setFocused(true),
|
|
3722
|
+
onBlur: () => {
|
|
3723
|
+
setFocused(false);
|
|
3724
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
3725
|
+
props.onCommit?.();
|
|
3726
|
+
},
|
|
3727
|
+
onKeyDown: (event) => {
|
|
3728
|
+
if (event.key !== "Enter") return;
|
|
3729
|
+
event.preventDefault();
|
|
3730
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
3731
|
+
props.onCommit?.();
|
|
3732
|
+
},
|
|
3733
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
3734
|
+
}
|
|
3735
|
+
) })
|
|
2696
3736
|
);
|
|
2697
3737
|
}
|
|
2698
3738
|
function ValueRow(props) {
|
|
2699
|
-
const invalid = props.view.invalid;
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
3739
|
+
const invalid = props.view.invalid || props.invalidMessage !== void 0;
|
|
3740
|
+
const [revealed, setRevealed] = (0, import_react9.useState)(props.invalidMessage !== void 0);
|
|
3741
|
+
(0, import_react9.useEffect)(() => {
|
|
3742
|
+
if (props.invalidMessage === void 0) setRevealed(false);
|
|
3743
|
+
}, [props.invalidMessage]);
|
|
3744
|
+
const showMessage = invalid && (props.view.invalid || revealed);
|
|
3745
|
+
const [recording, setRecording] = (0, import_react9.useState)(false);
|
|
3746
|
+
const [recordRejected, setRecordRejected] = (0, import_react9.useState)(false);
|
|
3747
|
+
const { onEdit, onCommit } = props;
|
|
3748
|
+
(0, import_react9.useEffect)(() => {
|
|
3749
|
+
if (!recording) return;
|
|
3750
|
+
const onKeyDown = (event) => {
|
|
3751
|
+
if (event.isComposing || event.repeat) return;
|
|
3752
|
+
const key = event.key;
|
|
3753
|
+
if (key === "Control" || key === "Alt" || key === "Shift" || key === "Meta") return;
|
|
3754
|
+
if (key === "Escape" || key === "Tab") {
|
|
3755
|
+
setRecording(false);
|
|
3756
|
+
setRecordRejected(false);
|
|
3757
|
+
if (key === "Escape") event.preventDefault();
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
event.preventDefault();
|
|
3761
|
+
event.stopPropagation();
|
|
3762
|
+
const spec = shortcutSpecOf(event);
|
|
3763
|
+
if (spec === null) {
|
|
3764
|
+
setRecordRejected(true);
|
|
3765
|
+
return;
|
|
3766
|
+
}
|
|
3767
|
+
setRecording(false);
|
|
3768
|
+
setRecordRejected(false);
|
|
3769
|
+
onEdit(spec);
|
|
3770
|
+
onCommit?.();
|
|
3771
|
+
};
|
|
3772
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
3773
|
+
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
3774
|
+
}, [recording, onEdit, onCommit]);
|
|
3775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3776
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3777
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3778
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null,
|
|
3779
|
+
props.recordable === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3780
|
+
"button",
|
|
3781
|
+
{
|
|
3782
|
+
type: "button",
|
|
3783
|
+
className: "dsh-pe-chip-reset",
|
|
3784
|
+
style: RECORD_STYLE,
|
|
3785
|
+
disabled: props.disabled,
|
|
3786
|
+
"aria-pressed": recording,
|
|
3787
|
+
onClick: () => {
|
|
3788
|
+
setRecording((open) => !open);
|
|
3789
|
+
setRecordRejected(false);
|
|
3790
|
+
},
|
|
3791
|
+
children: recording ? props.copy.labels.recordStop : props.copy.labels.record
|
|
3792
|
+
}
|
|
3793
|
+
) : null
|
|
2704
3794
|
] }),
|
|
2705
|
-
/* @__PURE__ */ (0,
|
|
3795
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2706
3796
|
TextControl,
|
|
2707
3797
|
{
|
|
2708
3798
|
id: props.id,
|
|
@@ -2711,17 +3801,24 @@ function ValueRow(props) {
|
|
|
2711
3801
|
numeric: props.numeric,
|
|
2712
3802
|
invalid,
|
|
2713
3803
|
disabled: props.disabled,
|
|
2714
|
-
onChange:
|
|
2715
|
-
|
|
3804
|
+
onChange: (text) => {
|
|
3805
|
+
setRevealed(false);
|
|
3806
|
+
props.onEdit(text);
|
|
3807
|
+
},
|
|
3808
|
+
onCommit: () => {
|
|
3809
|
+
setRevealed(true);
|
|
3810
|
+
props.onCommit?.();
|
|
3811
|
+
}
|
|
2716
3812
|
}
|
|
2717
3813
|
),
|
|
2718
|
-
/* @__PURE__ */ (0,
|
|
2719
|
-
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3815
|
+
recording ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, children: recordRejected ? props.copy.labels.recordNeedsModifier : props.copy.labels.recordPrompt }) : null,
|
|
3816
|
+
showMessage ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: INVALID_STYLE, children: props.invalidMessage ?? props.copy.labels.invalidNumber }) : null
|
|
2720
3817
|
] });
|
|
2721
3818
|
}
|
|
2722
3819
|
|
|
2723
3820
|
// src/client/settings-page.tsx
|
|
2724
|
-
var
|
|
3821
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2725
3822
|
function sectionTitle(getLocale) {
|
|
2726
3823
|
try {
|
|
2727
3824
|
const t = getLocale?.()?.bind(NS);
|
|
@@ -2731,23 +3828,23 @@ function sectionTitle(getLocale) {
|
|
|
2731
3828
|
}
|
|
2732
3829
|
}
|
|
2733
3830
|
function PageHeader(props) {
|
|
2734
|
-
return /* @__PURE__ */ (0,
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
2736
|
-
/* @__PURE__ */ (0,
|
|
2737
|
-
/* @__PURE__ */ (0,
|
|
2738
|
-
/* @__PURE__ */ (0,
|
|
3831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: HEADER_STYLE, children: [
|
|
3832
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: HEADER_ROW_STYLE, children: [
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: HEADER_TITLE_STYLE, children: props.title }),
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: REPOSITORY_URL, target: "_blank", rel: "noreferrer", style: HEADER_LINK_STYLE, children: [
|
|
3835
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "currentColor", d: GITHUB_MARK }) }),
|
|
2739
3836
|
"GitHub"
|
|
2740
3837
|
] }),
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
3838
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: NPM_URL, target: "_blank", rel: "noreferrer", style: HEADER_LINK_STYLE, children: [
|
|
3839
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "currentColor", d: NPM_MARK }) }),
|
|
2743
3840
|
"npm"
|
|
2744
3841
|
] }),
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
3842
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { style: HEADER_VERSION_STYLE, children: [
|
|
2746
3843
|
"v",
|
|
2747
3844
|
props.version
|
|
2748
3845
|
] })
|
|
2749
3846
|
] }),
|
|
2750
|
-
/* @__PURE__ */ (0,
|
|
3847
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: HEADER_DESCRIPTION_STYLE, children: props.description })
|
|
2751
3848
|
] });
|
|
2752
3849
|
}
|
|
2753
3850
|
function SettingsRow(props) {
|
|
@@ -2764,37 +3861,55 @@ function SettingsRow(props) {
|
|
|
2764
3861
|
};
|
|
2765
3862
|
switch (props.row.kind) {
|
|
2766
3863
|
case "boolean":
|
|
2767
|
-
return /* @__PURE__ */ (0,
|
|
3864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BooleanRow, { ...shared });
|
|
2768
3865
|
case "strategy":
|
|
2769
|
-
return /* @__PURE__ */ (0,
|
|
3866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChoiceRow, { ...shared, options: STRATEGY_OPTIONS.map((option) => ({ value: option.value, label: props.copy.choice(option.label) })) });
|
|
2770
3867
|
case "reasoning":
|
|
2771
|
-
return /* @__PURE__ */ (0,
|
|
3868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ReasoningRow, { ...shared, provider: props.reasoningPair.provider, model: props.reasoningPair.model });
|
|
2772
3869
|
case "provider":
|
|
2773
|
-
return /* @__PURE__ */ (0,
|
|
3870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProviderRow, { ...shared, routing: props.routing });
|
|
2774
3871
|
case "model":
|
|
2775
|
-
return /* @__PURE__ */ (0,
|
|
3872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModelRow, { ...shared, routing: props.routing, providerValue: props.providerValue });
|
|
2776
3873
|
default:
|
|
2777
|
-
return /* @__PURE__ */ (0,
|
|
3874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3875
|
+
ValueRow,
|
|
3876
|
+
{
|
|
3877
|
+
...shared,
|
|
3878
|
+
numeric: props.row.kind === "number",
|
|
3879
|
+
placeholder: props.copy.placeholder(props.row),
|
|
3880
|
+
invalidMessage: props.row.validate !== void 0 && !props.row.validate(props.view.text) ? props.copy.labels.invalidShortcut : void 0,
|
|
3881
|
+
recordable: props.row.recordable === true
|
|
3882
|
+
}
|
|
3883
|
+
);
|
|
2778
3884
|
}
|
|
2779
3885
|
}
|
|
2780
3886
|
function SettingsRows(props) {
|
|
2781
3887
|
const provider = viewOf(props.state, "provider").text.trim();
|
|
2782
3888
|
const model = viewOf(props.state, "model").text.trim();
|
|
2783
3889
|
const routing = useLlmRouting(provider, model);
|
|
2784
|
-
const [saveState, setSaveState] = (0,
|
|
2785
|
-
const timers = (0,
|
|
2786
|
-
const savedTimer = (0,
|
|
2787
|
-
const savedValues = (0,
|
|
2788
|
-
const sequence = (0,
|
|
2789
|
-
(0,
|
|
3890
|
+
const [saveState, setSaveState] = (0, import_react10.useState)("idle");
|
|
3891
|
+
const timers = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
3892
|
+
const savedTimer = (0, import_react10.useRef)(void 0);
|
|
3893
|
+
const savedValues = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
3894
|
+
const sequence = (0, import_react10.useRef)(0);
|
|
3895
|
+
(0, import_react10.useEffect)(() => {
|
|
2790
3896
|
for (const row of ROWS) {
|
|
2791
3897
|
if (!savedValues.current.has(row.key)) {
|
|
2792
3898
|
savedValues.current.set(row.key, viewOf(props.state, row.key).text);
|
|
2793
3899
|
}
|
|
2794
3900
|
}
|
|
2795
3901
|
}, [props.state]);
|
|
3902
|
+
const isStagedInvalid = (key, text) => {
|
|
3903
|
+
const row = ROWS.find((item) => item.key === key);
|
|
3904
|
+
return row?.validate !== void 0 && !row.validate(text);
|
|
3905
|
+
};
|
|
3906
|
+
const hasStagedInvalid = () => ROWS.some((row) => row.validate !== void 0 && !row.validate(viewOf(props.state, row.key).text));
|
|
2796
3907
|
const runSave = async (key, text) => {
|
|
2797
3908
|
if (props.writeField === void 0) return;
|
|
3909
|
+
if (isStagedInvalid(key, text)) {
|
|
3910
|
+
setSaveState("idle");
|
|
3911
|
+
return;
|
|
3912
|
+
}
|
|
2798
3913
|
if (savedValues.current.get(key) === text) return;
|
|
2799
3914
|
const ticket = ++sequence.current;
|
|
2800
3915
|
setSaveState("saving");
|
|
@@ -2836,20 +3951,35 @@ function SettingsRows(props) {
|
|
|
2836
3951
|
savedValues.current.set(key, fallback);
|
|
2837
3952
|
markSaved();
|
|
2838
3953
|
};
|
|
3954
|
+
const resetTargets = (key) => key === "provider" && viewOf(props.state, "model").text !== "" ? ["provider", "model"] : [key];
|
|
2839
3955
|
const resetAndSave = (key) => {
|
|
2840
|
-
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
|
|
3956
|
+
const targets = resetTargets(key);
|
|
3957
|
+
for (const target of targets) {
|
|
3958
|
+
props.resetField(target);
|
|
3959
|
+
savedValues.current.set(target, defaultTextOf(target));
|
|
3960
|
+
}
|
|
3961
|
+
void (async () => {
|
|
3962
|
+
for (const target of targets) await runReset(target, defaultTextOf(target));
|
|
3963
|
+
})();
|
|
2844
3964
|
};
|
|
2845
3965
|
const manualSave = async () => {
|
|
2846
3966
|
if (props.writeField === void 0) {
|
|
3967
|
+
if (hasStagedInvalid()) {
|
|
3968
|
+
setSaveState("idle");
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
2847
3971
|
props.save?.();
|
|
2848
3972
|
markSaved();
|
|
2849
3973
|
return;
|
|
2850
3974
|
}
|
|
2851
|
-
const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter(
|
|
3975
|
+
const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter(
|
|
3976
|
+
(item) => savedValues.current.get(item.key) !== item.text && !isStagedInvalid(item.key, item.text)
|
|
3977
|
+
);
|
|
2852
3978
|
if (changed.length === 0) {
|
|
3979
|
+
if (hasStagedInvalid()) {
|
|
3980
|
+
setSaveState("idle");
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
2853
3983
|
markSaved();
|
|
2854
3984
|
return;
|
|
2855
3985
|
}
|
|
@@ -2882,10 +4012,17 @@ function SettingsRows(props) {
|
|
|
2882
4012
|
}, 800);
|
|
2883
4013
|
timers.current.set(key, timer);
|
|
2884
4014
|
};
|
|
2885
|
-
const onEdit = (key, text) => {
|
|
4015
|
+
const onEdit = (key, text, options) => {
|
|
4016
|
+
const previousProvider = key === "provider" ? viewOf(props.state, "provider").text : "";
|
|
2886
4017
|
props.edit(key, text);
|
|
4018
|
+
if (key === "provider" && text !== previousProvider && viewOf(props.state, "model").text !== "") {
|
|
4019
|
+
props.resetField("model");
|
|
4020
|
+
savedValues.current.set("model", "");
|
|
4021
|
+
void runReset("model", "");
|
|
4022
|
+
}
|
|
2887
4023
|
const row = ROWS.find((item) => item.key === key);
|
|
2888
|
-
const
|
|
4024
|
+
const typing = row !== void 0 && (row.kind === "text" || row.kind === "number");
|
|
4025
|
+
const debounced = options?.deferred === true || typing;
|
|
2889
4026
|
scheduleSave(key, text, !debounced);
|
|
2890
4027
|
};
|
|
2891
4028
|
const flushField = (key, text) => {
|
|
@@ -2896,7 +4033,7 @@ function SettingsRows(props) {
|
|
|
2896
4033
|
}
|
|
2897
4034
|
void runSave(key, text ?? viewOf(props.state, key).text);
|
|
2898
4035
|
};
|
|
2899
|
-
(0,
|
|
4036
|
+
(0, import_react10.useEffect)(
|
|
2900
4037
|
() => () => {
|
|
2901
4038
|
for (const timer of timers.current.values()) clearTimeout(timer);
|
|
2902
4039
|
timers.current.clear();
|
|
@@ -2908,7 +4045,7 @@ function SettingsRows(props) {
|
|
|
2908
4045
|
const renderRow = (row, index) => {
|
|
2909
4046
|
const raw = viewOf(props.state, row.key);
|
|
2910
4047
|
const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
4048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2912
4049
|
SettingsRow,
|
|
2913
4050
|
{
|
|
2914
4051
|
row,
|
|
@@ -2918,21 +4055,21 @@ function SettingsRows(props) {
|
|
|
2918
4055
|
reasoningPair: { provider, model },
|
|
2919
4056
|
routing,
|
|
2920
4057
|
providerValue: provider,
|
|
2921
|
-
onEdit: (text) => onEdit(row.key, text),
|
|
4058
|
+
onEdit: (text, options) => onEdit(row.key, text, options),
|
|
2922
4059
|
onReset: () => resetAndSave(row.key),
|
|
2923
4060
|
onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
|
|
2924
4061
|
}
|
|
2925
4062
|
) }, row.key);
|
|
2926
4063
|
};
|
|
2927
|
-
return /* @__PURE__ */ (0,
|
|
4064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsh-pe-form", children: [
|
|
2928
4065
|
BASIC_ROWS.map(renderRow),
|
|
2929
|
-
/* @__PURE__ */ (0,
|
|
2930
|
-
/* @__PURE__ */ (0,
|
|
4066
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "dsh-pe-advanced", children: [
|
|
4067
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children: props.copy.labels.advanced }),
|
|
2931
4068
|
ADVANCED_ROWS.map(renderRow)
|
|
2932
4069
|
] }),
|
|
2933
|
-
/* @__PURE__ */ (0,
|
|
2934
|
-
statusText === "" ? null : /* @__PURE__ */ (0,
|
|
2935
|
-
/* @__PURE__ */ (0,
|
|
4070
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "dsh-pe-form-footer", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsh-pe-save-group", children: [
|
|
4071
|
+
statusText === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dsh-pe-save-status", role: "status", "aria-live": "polite", children: statusText }),
|
|
4072
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2936
4073
|
"button",
|
|
2937
4074
|
{
|
|
2938
4075
|
type: "button",
|
|
@@ -2955,15 +4092,15 @@ function SettingsSection(props) {
|
|
|
2955
4092
|
const t = translator(props.translate);
|
|
2956
4093
|
const chinese = (locale?.active ?? "zh").toLowerCase().startsWith("zh");
|
|
2957
4094
|
if (state === void 0) {
|
|
2958
|
-
return /* @__PURE__ */ (0,
|
|
4095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2959
4096
|
}
|
|
2960
4097
|
const edit = props.edit ?? (() => {
|
|
2961
4098
|
});
|
|
2962
4099
|
const resetField = props.resetField ?? (() => {
|
|
2963
4100
|
});
|
|
2964
|
-
return /* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
4101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
4102
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PageHeader, { title: t("settings.title"), description: t("settings.description"), version: PLUGIN_VERSION }),
|
|
4103
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsRows, { copy: sectionCopy(t, chinese), state, edit, resetField, save: props.save, discard: props.discard, writeField: props.writeField })
|
|
2967
4104
|
] });
|
|
2968
4105
|
}
|
|
2969
4106
|
function SettingsPage(props) {
|
|
@@ -2972,13 +4109,13 @@ function SettingsPage(props) {
|
|
|
2972
4109
|
const state = read === void 0 ? void 0 : read((snapshot) => snapshot);
|
|
2973
4110
|
if (props.view === "summary") return t("settings.summary");
|
|
2974
4111
|
if (state === void 0) {
|
|
2975
|
-
return /* @__PURE__ */ (0,
|
|
4112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2976
4113
|
}
|
|
2977
4114
|
const edit = props.edit ?? (() => {
|
|
2978
4115
|
});
|
|
2979
4116
|
const resetField = props.resetField ?? (() => {
|
|
2980
4117
|
});
|
|
2981
|
-
return /* @__PURE__ */ (0,
|
|
4118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsRows, { copy: pageCopy(t), state, edit, resetField, save: props.save, discard: props.discard, writeField: props.writeField });
|
|
2982
4119
|
}
|
|
2983
4120
|
var SettingsPageController = class {
|
|
2984
4121
|
/**
|
|
@@ -3107,6 +4244,7 @@ function installSettingsPages(ctx, getLocale) {
|
|
|
3107
4244
|
}
|
|
3108
4245
|
|
|
3109
4246
|
// src/client/index.tsx
|
|
4247
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3110
4248
|
var inject = [];
|
|
3111
4249
|
function report(step, error) {
|
|
3112
4250
|
try {
|
|
@@ -3140,7 +4278,8 @@ function apply(ctx) {
|
|
|
3140
4278
|
if (slots === void 0) return;
|
|
3141
4279
|
return slots.inject("conversation.input.right", () => {
|
|
3142
4280
|
try {
|
|
3143
|
-
|
|
4281
|
+
const Bound = (buttonProps) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EnhanceButton, { ...buttonProps, __ctx: ctx });
|
|
4282
|
+
return slots.register({ name: "conversation.input.right", id: "dsh-prompt-enhance", order: 60, locale: NS }, Bound);
|
|
3144
4283
|
} catch (error) {
|
|
3145
4284
|
return report("composer enhance button slot", error);
|
|
3146
4285
|
}
|