@surfishs/dsh-prompt-enhance 0.1.0 → 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 +1819 -688
- 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 +53 -45
- package/src/client/ResultPanel.tsx +136 -66
- 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 +92 -49
- 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 +378 -47
- 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,
|
|
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,69 +1504,90 @@ function ResultPanel(props) {
|
|
|
771
1504
|
}
|
|
772
1505
|
return parts.join(" \xB7 ");
|
|
773
1506
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
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 }),
|
|
778
1512
|
t("panel.title")
|
|
779
1513
|
] }),
|
|
780
|
-
/* @__PURE__ */ (0,
|
|
781
|
-
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: [
|
|
782
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
|
+
] }),
|
|
783
1521
|
" \xB7 ",
|
|
784
1522
|
t("panel.elapsed", { ms: formatMs(state.result.elapsedMs) }),
|
|
785
|
-
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: [
|
|
786
1524
|
" \xB7 ",
|
|
787
|
-
/* @__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)) }) })
|
|
788
1526
|
] })
|
|
789
1527
|
] }),
|
|
790
|
-
|
|
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
|
-
|
|
815
|
-
|
|
816
|
-
|
|
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", onClick: onRegenerate, disabled: onRegenerate === void 0, children: [
|
|
821
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RegenerateIcon, {}),
|
|
822
|
-
t("panel.regenerate")
|
|
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: [
|
|
1564
|
+
swapLabel(!regenerated, t("panel.regenerate")),
|
|
1565
|
+
swapLabel(regenerated, t("panel.regenerated"))
|
|
1566
|
+
] })
|
|
823
1567
|
] }),
|
|
824
|
-
state.phase === "error" && /* @__PURE__ */ (0,
|
|
825
|
-
state.phase === "loading" && /* @__PURE__ */ (0,
|
|
826
|
-
state.phase === "result" && /* @__PURE__ */ (0,
|
|
827
|
-
/* @__PURE__ */ (0,
|
|
828
|
-
/* @__PURE__ */ (0,
|
|
829
|
-
|
|
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: [
|
|
1574
|
+
swapLabel(copied === "idle", t("panel.copy")),
|
|
1575
|
+
swapLabel(copied === "ok", t("panel.copied")),
|
|
1576
|
+
swapLabel(copied === "failed", t("panel.copyFailed"))
|
|
1577
|
+
] })
|
|
830
1578
|
] }),
|
|
831
|
-
applied ? /* @__PURE__ */ (0,
|
|
832
|
-
/* @__PURE__ */ (0,
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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: [
|
|
1582
|
+
swapLabel(true, t("undo.undo")),
|
|
1583
|
+
swapLabel(false, t("panel.apply"))
|
|
1584
|
+
] })
|
|
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: [
|
|
1588
|
+
swapLabel(true, t("panel.apply")),
|
|
1589
|
+
swapLabel(false, t("undo.undo"))
|
|
1590
|
+
] })
|
|
837
1591
|
] })
|
|
838
1592
|
] })
|
|
839
1593
|
] })
|
|
@@ -841,7 +1595,7 @@ function ResultPanel(props) {
|
|
|
841
1595
|
}
|
|
842
1596
|
|
|
843
1597
|
// src/client/useDockAlignment.ts
|
|
844
|
-
var
|
|
1598
|
+
var import_react6 = require("react");
|
|
845
1599
|
var EDITOR_SELECTOR = 'textarea, [contenteditable="true"], [role="textbox"]';
|
|
846
1600
|
var SESSION_ANCHOR_ATTRIBUTE = "data-dsh-pe-key";
|
|
847
1601
|
var CARD_MIN_WIDTH = 360;
|
|
@@ -869,8 +1623,8 @@ function editorsIn(scope) {
|
|
|
869
1623
|
return Array.from(scope.querySelectorAll(EDITOR_SELECTOR));
|
|
870
1624
|
}
|
|
871
1625
|
function useDockAlignment(active, uiKey) {
|
|
872
|
-
const rootRef = (0,
|
|
873
|
-
(0,
|
|
1626
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
1627
|
+
(0, import_react6.useEffect)(() => {
|
|
874
1628
|
if (!active) return;
|
|
875
1629
|
const root = rootRef.current;
|
|
876
1630
|
if (root === null) return;
|
|
@@ -947,16 +1701,14 @@ function useDockAlignment(active, uiKey) {
|
|
|
947
1701
|
}
|
|
948
1702
|
|
|
949
1703
|
// src/client/ResultDock.tsx
|
|
950
|
-
var
|
|
1704
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1705
|
+
var REGENERATED_NOTICE_MS = 2500;
|
|
951
1706
|
function ResultDock(props) {
|
|
952
1707
|
const { t, sessionId, useInput, inputActions } = props;
|
|
953
1708
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
954
|
-
const panel = (0,
|
|
1709
|
+
const panel = (0, import_react7.useSyncExternalStore)(subscribe, getPanel);
|
|
1710
|
+
const settings = (0, import_react7.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
955
1711
|
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey, uiKey);
|
|
956
|
-
const [undone, setUndone] = (0, import_react5.useState)(false);
|
|
957
|
-
const [regenerated, setRegenerated] = (0, import_react5.useState)(false);
|
|
958
|
-
const [pendingRegenerate, setPendingRegenerate] = (0, import_react5.useState)(false);
|
|
959
|
-
const previousResultRef = (0, import_react5.useRef)(void 0);
|
|
960
1712
|
const draft = useInput((state) => {
|
|
961
1713
|
const value = state.draft;
|
|
962
1714
|
return typeof value === "string" ? value : "";
|
|
@@ -976,8 +1728,11 @@ function ResultDock(props) {
|
|
|
976
1728
|
);
|
|
977
1729
|
const entry = peekUndo(uiKey);
|
|
978
1730
|
const applied = entry !== void 0 && entry.applied === draft;
|
|
979
|
-
const
|
|
980
|
-
(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)(() => {
|
|
981
1736
|
const prev = prevSession.current;
|
|
982
1737
|
prevSession.current = { running: sessionRunning, queued: sessionQueued };
|
|
983
1738
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
@@ -985,7 +1740,7 @@ function ResultDock(props) {
|
|
|
985
1740
|
closePanel();
|
|
986
1741
|
}
|
|
987
1742
|
}, [phase, sessionRunning, sessionQueued, panel, uiKey]);
|
|
988
|
-
(0,
|
|
1743
|
+
(0, import_react7.useEffect)(() => {
|
|
989
1744
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
990
1745
|
const onKeyDown = (event) => {
|
|
991
1746
|
if (event.defaultPrevented || event.isComposing || event.key !== "Escape") return;
|
|
@@ -995,66 +1750,52 @@ function ResultDock(props) {
|
|
|
995
1750
|
document.addEventListener("keydown", onKeyDown);
|
|
996
1751
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
997
1752
|
}, [panel, uiKey]);
|
|
998
|
-
(0,
|
|
999
|
-
if (!
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}, [undone]);
|
|
1003
|
-
(0, import_react5.useEffect)(() => {
|
|
1004
|
-
if (!pendingRegenerate) return;
|
|
1005
|
-
if (panel === void 0 || panel.sessionId !== uiKey) {
|
|
1006
|
-
setPendingRegenerate(false);
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
if (panel.phase === "error") {
|
|
1010
|
-
setPendingRegenerate(false);
|
|
1753
|
+
(0, import_react7.useEffect)(() => {
|
|
1754
|
+
if (!pendingRegenerate.current) return;
|
|
1755
|
+
if (panel === void 0 || panel.sessionId !== uiKey || panel.phase === "error") {
|
|
1756
|
+
pendingRegenerate.current = false;
|
|
1011
1757
|
return;
|
|
1012
1758
|
}
|
|
1013
1759
|
if (panel.phase === "result" && panel.result !== previousResultRef.current) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1760
|
+
pendingRegenerate.current = false;
|
|
1761
|
+
setRegeneratedNotice(true);
|
|
1016
1762
|
}
|
|
1017
|
-
}, [panel,
|
|
1018
|
-
(0,
|
|
1019
|
-
if (!
|
|
1020
|
-
const timer = setTimeout(() =>
|
|
1021
|
-
return () => clearTimeout(timer);
|
|
1022
|
-
}, [regenerated]);
|
|
1023
|
-
(0, import_react5.useEffect)(() => {
|
|
1024
|
-
if (!pendingRegenerate) return;
|
|
1025
|
-
const timer = setTimeout(() => setPendingRegenerate(false), 15e3);
|
|
1763
|
+
}, [panel, uiKey]);
|
|
1764
|
+
(0, import_react7.useEffect)(() => {
|
|
1765
|
+
if (!regeneratedNotice) return;
|
|
1766
|
+
const timer = setTimeout(() => setRegeneratedNotice(false), REGENERATED_NOTICE_MS);
|
|
1026
1767
|
return () => clearTimeout(timer);
|
|
1027
|
-
}, [
|
|
1768
|
+
}, [regeneratedNotice]);
|
|
1028
1769
|
if (panel === void 0 || panel.sessionId !== uiKey) return null;
|
|
1029
1770
|
const apply2 = () => {
|
|
1030
1771
|
if (panel.phase !== "result" || panel.result === void 0) return;
|
|
1031
1772
|
pushUndo(uiKey, { original: draft, applied: panel.result.text });
|
|
1032
1773
|
inputActions.setDraft(panel.result.text);
|
|
1033
|
-
|
|
1034
|
-
setRegenerated(false);
|
|
1774
|
+
if (settings.autoFold) setCollapsed(uiKey, true);
|
|
1035
1775
|
};
|
|
1036
1776
|
const undo = () => {
|
|
1037
1777
|
if (entry === void 0) return;
|
|
1038
1778
|
inputActions.setDraft(entry.original);
|
|
1039
1779
|
popUndo(uiKey);
|
|
1040
|
-
|
|
1041
|
-
setRegenerated(false);
|
|
1780
|
+
if (settings.autoFold) setCollapsed(uiKey, false);
|
|
1042
1781
|
};
|
|
1043
1782
|
const regenerate = () => {
|
|
1044
1783
|
if (panel.phase !== "result") return;
|
|
1784
|
+
setRegeneratedNotice(false);
|
|
1045
1785
|
previousResultRef.current = panel.result;
|
|
1046
|
-
|
|
1047
|
-
setPendingRegenerate(true);
|
|
1786
|
+
pendingRegenerate.current = true;
|
|
1048
1787
|
runSession(uiKey);
|
|
1049
1788
|
};
|
|
1050
|
-
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)(
|
|
1051
1790
|
ResultPanel,
|
|
1052
1791
|
{
|
|
1053
1792
|
state: panel,
|
|
1054
1793
|
t,
|
|
1055
1794
|
applied,
|
|
1056
|
-
|
|
1057
|
-
|
|
1795
|
+
regenerated: regeneratedNotice,
|
|
1796
|
+
collapsed: panel.collapsed === true,
|
|
1797
|
+
onToggleCollapsed: () => setCollapsed(uiKey, panel.collapsed !== true),
|
|
1798
|
+
foldAnimation: settings.foldAnimation,
|
|
1058
1799
|
onApply: apply2,
|
|
1059
1800
|
onUndo: undo,
|
|
1060
1801
|
onRegenerate: regenerate,
|
|
@@ -1065,8 +1806,8 @@ function ResultDock(props) {
|
|
|
1065
1806
|
}
|
|
1066
1807
|
|
|
1067
1808
|
// src/client/UndoBar.tsx
|
|
1068
|
-
var
|
|
1069
|
-
var
|
|
1809
|
+
var import_react8 = require("react");
|
|
1810
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1070
1811
|
function UndoBar(props) {
|
|
1071
1812
|
const { t, sessionId, useInput, inputActions } = props;
|
|
1072
1813
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
@@ -1074,9 +1815,9 @@ function UndoBar(props) {
|
|
|
1074
1815
|
const value = state.draft;
|
|
1075
1816
|
return typeof value === "string" ? value : "";
|
|
1076
1817
|
});
|
|
1077
|
-
(0,
|
|
1818
|
+
(0, import_react8.useSyncExternalStore)(subscribe, getVersion);
|
|
1078
1819
|
const entry = peekUndo(uiKey);
|
|
1079
|
-
(0,
|
|
1820
|
+
(0, import_react8.useEffect)(() => {
|
|
1080
1821
|
if (entry !== void 0 && entry.applied !== draft) popUndo(uiKey);
|
|
1081
1822
|
}, [draft, entry, uiKey]);
|
|
1082
1823
|
const panel = getPanel();
|
|
@@ -1090,23 +1831,36 @@ function UndoBar(props) {
|
|
|
1090
1831
|
const dismiss = () => {
|
|
1091
1832
|
popUndo(uiKey);
|
|
1092
1833
|
};
|
|
1093
|
-
return /* @__PURE__ */ (0,
|
|
1094
|
-
/* @__PURE__ */ (0,
|
|
1095
|
-
/* @__PURE__ */ (0,
|
|
1096
|
-
/* @__PURE__ */ (0,
|
|
1097
|
-
/* @__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, {}),
|
|
1098
1839
|
t("undo.undo")
|
|
1099
1840
|
] }),
|
|
1100
|
-
/* @__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" })
|
|
1101
1842
|
] }) });
|
|
1102
1843
|
}
|
|
1103
1844
|
|
|
1104
1845
|
// src/client/locales.ts
|
|
1105
1846
|
var zh = {
|
|
1106
|
-
"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",
|
|
1107
1848
|
"button.busy": "\u6B63\u5728\u589E\u5F3A\u2026",
|
|
1108
|
-
"button.otherBusy": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u6B63\u5728\u589E\u5F3A\u4E2D
|
|
1109
|
-
"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",
|
|
1110
1864
|
"panel.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1111
1865
|
"panel.loading": "\u6B63\u5728\u589E\u5F3A\uFF0C\u7A0D\u5019\u2026",
|
|
1112
1866
|
"panel.streaming": "\u6B63\u5728\u751F\u6210\u2026",
|
|
@@ -1116,20 +1870,20 @@ var zh = {
|
|
|
1116
1870
|
"panel.enhanced": "\u589E\u5F3A\u7ED3\u679C",
|
|
1117
1871
|
"panel.apply": "\u56DE\u586B\u5230\u8F93\u5165\u6846",
|
|
1118
1872
|
"panel.regenerate": "\u91CD\u65B0\u751F\u6210",
|
|
1119
|
-
"panel.
|
|
1120
|
-
"panel.undoneShort": "\u5DF2\u64A4\u9500 \u2713",
|
|
1121
|
-
"panel.regeneratedShort": "\u5DF2\u91CD\u65B0\u751F\u6210 \u2713",
|
|
1122
|
-
"panel.copiedShort": "\u5DF2\u590D\u5236 \u2713",
|
|
1873
|
+
"panel.regenerated": "\u5DF2\u91CD\u65B0\u751F\u6210",
|
|
1123
1874
|
"panel.copy": "\u590D\u5236\u7ED3\u679C",
|
|
1124
1875
|
"panel.copied": "\u5DF2\u590D\u5236",
|
|
1125
1876
|
"panel.copyFailed": "\u590D\u5236\u5931\u8D25",
|
|
1126
1877
|
"panel.close": "\u5173\u95ED",
|
|
1878
|
+
"panel.collapse": "\u6298\u53E0",
|
|
1879
|
+
"panel.expand": "\u5C55\u5F00",
|
|
1127
1880
|
"panel.retry": "\u91CD\u8BD5",
|
|
1128
|
-
"panel.stale.warn": "\u8349\u7A3F\u5DF2\u6539\u52A8\uFF0C\u5F53\u524D\u7ED3\u679C\u57FA\u4E8E\
|
|
1129
|
-
"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",
|
|
1130
1883
|
"panel.model": "\u6A21\u578B\uFF1A{provider} / {model}",
|
|
1131
1884
|
"panel.elapsed": "\u8017\u65F6 {ms}",
|
|
1132
1885
|
"panel.tokens": "{total} tokens",
|
|
1886
|
+
"panel.effortDefault": "\u4E0D\u6307\u5B9A",
|
|
1133
1887
|
"panel.tokens.input": "\u8F93\u5165 {count}",
|
|
1134
1888
|
"panel.tokens.output": "\u8F93\u51FA {count}",
|
|
1135
1889
|
"panel.tokens.cacheRead": "\u7F13\u5B58\u8BFB\u53D6 {count}",
|
|
@@ -1138,17 +1892,17 @@ var zh = {
|
|
|
1138
1892
|
"undo.undo": "\u64A4\u9500",
|
|
1139
1893
|
"undo.dismiss": "\u5173\u95ED\u63D0\u793A",
|
|
1140
1894
|
"error.empty": "\u8F93\u5165\u6846\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u8F93\u5165\u8981\u589E\u5F3A\u7684\u63D0\u793A\u8BCD\u3002",
|
|
1141
|
-
"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",
|
|
1142
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",
|
|
1143
|
-
"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",
|
|
1144
1898
|
"error.phase": "\u5F53\u524D\u8F93\u5165\u6B63\u88AB\u5360\u7528\uFF08\u63D0\u4EA4\u4E2D\uFF09\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1145
|
-
"error.disabled": "\u63D0\u793A\u8BCD\u589E\u5F3A\u5DF2\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002",
|
|
1146
|
-
"error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002",
|
|
1147
|
-
"error.timeout": "\u589E\u5F3A\u8D85\u65F6\uFF08{seconds} \u79D2\uFF09\
|
|
1148
|
-
"error.unconfigured": "\
|
|
1149
|
-
"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\
|
|
1150
|
-
"error.upstream": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\
|
|
1151
|
-
"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",
|
|
1152
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",
|
|
1153
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",
|
|
1154
1908
|
"error.client.refused": "\u5BBF\u4E3B\u670D\u52A1\u62D2\u7EDD\u4E86\u8BF7\u6C42\uFF08HTTP {status}\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1156,7 +1910,7 @@ var zh = {
|
|
|
1156
1910
|
"error.client.cancelled": "\u5DF2\u53D6\u6D88\u589E\u5F3A\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1157
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",
|
|
1158
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",
|
|
1159
|
-
"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",
|
|
1160
1914
|
"error.upstream.auth": "\u9274\u6743\u5931\u8D25\uFF1A\u8BF7\u68C0\u67E5\u8BE5 provider \u7684 API Key \u914D\u7F6E\u3002",
|
|
1161
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",
|
|
1162
1916
|
"error.upstream.rateLimit": "\u6A21\u578B\u670D\u52A1\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1164,7 +1918,7 @@ var zh = {
|
|
|
1164
1918
|
"error.upstream.empty": "\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1165
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",
|
|
1166
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",
|
|
1167
|
-
"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",
|
|
1168
1922
|
"settings.summary": "\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D44\u6E90\u9650\u5236",
|
|
1169
1923
|
"settings.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1170
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",
|
|
@@ -1178,6 +1932,11 @@ var zh = {
|
|
|
1178
1932
|
"settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
|
|
1179
1933
|
"settings.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
1180
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",
|
|
1181
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",
|
|
1182
1941
|
"settings.row.enabled.label": "\u603B\u5F00\u5173",
|
|
1183
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",
|
|
@@ -1185,6 +1944,10 @@ var zh = {
|
|
|
1185
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",
|
|
1186
1945
|
"settings.row.streaming.label": "\u589E\u91CF\u5C55\u793A",
|
|
1187
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",
|
|
1188
1951
|
"settings.row.provider.label": "\u6A21\u578B\u670D\u52A1\u65B9",
|
|
1189
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",
|
|
1190
1953
|
"settings.row.model.label": "\u6A21\u578B ID",
|
|
@@ -1211,7 +1974,7 @@ var zh = {
|
|
|
1211
1974
|
"settings.row.temperature.label": "\u6E29\u5EA6",
|
|
1212
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",
|
|
1213
1976
|
"settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
|
|
1214
|
-
"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",
|
|
1215
1978
|
"settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
|
|
1216
1979
|
"settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
|
|
1217
1980
|
"settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
|
|
@@ -1236,23 +1999,36 @@ var zh = {
|
|
|
1236
1999
|
"settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
|
|
1237
2000
|
"settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
|
|
1238
2001
|
"settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
|
|
1239
|
-
"settings.reasoning.inherit": "\
|
|
2002
|
+
"settings.reasoning.inherit": "\u4E0D\u6307\u5B9A",
|
|
1240
2003
|
"settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
|
|
1241
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",
|
|
1242
|
-
"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",
|
|
1243
2006
|
"settings.reasoning.unsupported": "\u5F53\u524D\u503C\u300C{effort}\u300D\u4E0D\u5728\u8BE5\u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\u4E2D\u3002",
|
|
1244
2007
|
"settings.reasoning.current": "\u5F53\u524D\u503C\uFF1A{value}",
|
|
1245
2008
|
"settings.reasoning.currentTitle": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u6B64\u6863\u4F4D",
|
|
1246
|
-
"settings.reasoning.refresh": "\
|
|
2009
|
+
"settings.reasoning.refresh": "\u5237\u65B0",
|
|
1247
2010
|
"settings.reasoning.refreshing": "\u6B63\u5728\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u2026",
|
|
1248
2011
|
"settings.reasoning.refreshOk": "\u6863\u4F4D\u4FE1\u606F\u5DF2\u66F4\u65B0",
|
|
1249
2012
|
"settings.reasoning.refreshFailed": "\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
|
|
1250
2013
|
};
|
|
1251
2014
|
var en = {
|
|
1252
|
-
"button.title": "Enhance prompt",
|
|
2015
|
+
"button.title": "Enhance prompt \xB7 rewrite the text in the input box",
|
|
1253
2016
|
"button.busy": "Enhancing\u2026",
|
|
1254
|
-
"button.otherBusy": "Another session is enhancing right now
|
|
1255
|
-
"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.",
|
|
1256
2032
|
"panel.title": "Prompt Enhance",
|
|
1257
2033
|
"panel.loading": "Enhancing, please wait\u2026",
|
|
1258
2034
|
"panel.streaming": "Generating\u2026",
|
|
@@ -1262,20 +2038,20 @@ var en = {
|
|
|
1262
2038
|
"panel.enhanced": "Enhanced result",
|
|
1263
2039
|
"panel.apply": "Fill into input box",
|
|
1264
2040
|
"panel.regenerate": "Regenerate",
|
|
1265
|
-
"panel.
|
|
1266
|
-
"panel.undoneShort": "Undone \u2713",
|
|
1267
|
-
"panel.regeneratedShort": "Regenerated \u2713",
|
|
1268
|
-
"panel.copiedShort": "Copied \u2713",
|
|
2041
|
+
"panel.regenerated": "Regenerated",
|
|
1269
2042
|
"panel.copy": "Copy result",
|
|
1270
2043
|
"panel.copied": "Copied",
|
|
1271
2044
|
"panel.copyFailed": "Copy failed",
|
|
1272
2045
|
"panel.close": "Close",
|
|
2046
|
+
"panel.collapse": "Collapse",
|
|
2047
|
+
"panel.expand": "Expand",
|
|
1273
2048
|
"panel.retry": "Retry",
|
|
1274
|
-
"panel.stale.warn": "Draft changed \u2014 this result uses the earlier text; Apply overwrites the
|
|
1275
|
-
"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.',
|
|
1276
2051
|
"panel.model": "Model: {provider} / {model}",
|
|
1277
2052
|
"panel.elapsed": "{ms} elapsed",
|
|
1278
2053
|
"panel.tokens": "{total} tokens",
|
|
2054
|
+
"panel.effortDefault": "Not specified",
|
|
1279
2055
|
"panel.tokens.input": "Input {count}",
|
|
1280
2056
|
"panel.tokens.output": "Output {count}",
|
|
1281
2057
|
"panel.tokens.cacheRead": "Cache read {count}",
|
|
@@ -1284,17 +2060,17 @@ var en = {
|
|
|
1284
2060
|
"undo.undo": "Undo",
|
|
1285
2061
|
"undo.dismiss": "Dismiss",
|
|
1286
2062
|
"error.empty": "The input box is empty \u2014 type a prompt to enhance first.",
|
|
1287
|
-
"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.",
|
|
1288
2064
|
"error.occurrences": "The draft contains commands or file references, which are not supported yet \u2014 remove them first.",
|
|
1289
|
-
"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.",
|
|
1290
2066
|
"error.phase": "The input box is busy (submitting) \u2014 try again in a moment.",
|
|
1291
|
-
"error.disabled": "Prompt enhance is disabled in the plugin settings.",
|
|
1292
|
-
"error.rejected": "The enhance request was rejected.",
|
|
1293
|
-
"error.timeout":
|
|
1294
|
-
"error.unconfigured": "No model
|
|
1295
|
-
"error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "
|
|
1296
|
-
"error.upstream": "The model provider returned an error.
|
|
1297
|
-
"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.",
|
|
1298
2074
|
"error.client.unreachable": "Cannot reach the host service \u2014 make sure dsh web is running, then retry.",
|
|
1299
2075
|
"error.client.malformed": "The host returned data that could not be parsed. Retry; your draft is untouched.",
|
|
1300
2076
|
"error.client.refused": "The host refused the request (HTTP {status}). Retry later.",
|
|
@@ -1302,7 +2078,7 @@ var en = {
|
|
|
1302
2078
|
"error.client.cancelled": "The enhancement was cancelled; your draft is untouched.",
|
|
1303
2079
|
"error.rateLimit": "Too many requests \u2014 at most {limit} enhancements per minute; retry in {retryAfterSeconds} seconds.",
|
|
1304
2080
|
"error.concurrencyLimit": "{max} enhancements are already running \u2014 wait for one to finish, then retry.",
|
|
1305
|
-
"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.",
|
|
1306
2082
|
"error.upstream.auth": "Authentication failed \u2014 check the API key configured for this provider.",
|
|
1307
2083
|
"error.upstream.invalidCredential": "Authentication failed \u2014 the stored API key is invalid; fix it and retry.",
|
|
1308
2084
|
"error.upstream.rateLimit": "The model provider is rate-limiting; retry later.",
|
|
@@ -1310,7 +2086,7 @@ var en = {
|
|
|
1310
2086
|
"error.upstream.empty": "The model returned an empty response; retry.",
|
|
1311
2087
|
"error.upstream.contextWindow": "The input exceeds the model context window \u2014 shorten it or switch models.",
|
|
1312
2088
|
"error.upstream.toolCall": "The model requested tool calls, but prompt enhance needs plain text \u2014 switch models and retry.",
|
|
1313
|
-
"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.',
|
|
1314
2090
|
"settings.summary": "Model, context, and resource limits",
|
|
1315
2091
|
"settings.title": "Prompt enhance",
|
|
1316
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.",
|
|
@@ -1324,6 +2100,11 @@ var en = {
|
|
|
1324
2100
|
"settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
|
|
1325
2101
|
"settings.reset": "Reset to default",
|
|
1326
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.",
|
|
1327
2108
|
"settings.disconnected": "This page has no form: the host did not project its form store. The plugin keeps working with its composition config.",
|
|
1328
2109
|
"settings.row.enabled.label": "Master switch",
|
|
1329
2110
|
"settings.row.enabled.hint": "Off hides the composer button and disables the command and the shortcut.",
|
|
@@ -1331,6 +2112,10 @@ var en = {
|
|
|
1331
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.",
|
|
1332
2113
|
"settings.row.streaming.label": "Streaming display",
|
|
1333
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.",
|
|
1334
2119
|
"settings.row.provider.label": "Model provider",
|
|
1335
2120
|
"settings.row.provider.hint": "Pick a registered DSH LLM provider; leave empty to follow the current session\u2019s model.",
|
|
1336
2121
|
"settings.row.model.label": "Model id",
|
|
@@ -1357,7 +2142,7 @@ var en = {
|
|
|
1357
2142
|
"settings.row.temperature.label": "Temperature",
|
|
1358
2143
|
"settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
|
|
1359
2144
|
"settings.row.reasoningEffort.label": "Reasoning effort",
|
|
1360
|
-
"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.',
|
|
1361
2146
|
"settings.row.maxOutputTokens.label": "Output token budget",
|
|
1362
2147
|
"settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
|
|
1363
2148
|
"settings.row.maxInputChars.label": "Input character cap",
|
|
@@ -1382,14 +2167,14 @@ var en = {
|
|
|
1382
2167
|
"settings.row.shortcut.placeholder": "e.g. ctrl+alt+shift+e",
|
|
1383
2168
|
"settings.strategy.replace": "Replace the built-in strategy",
|
|
1384
2169
|
"settings.strategy.extend": "Append after the built-in strategy",
|
|
1385
|
-
"settings.reasoning.inherit": "
|
|
2170
|
+
"settings.reasoning.inherit": "Not specified",
|
|
1386
2171
|
"settings.reasoning.loading": "Reading this model\u2019s tiers\u2026",
|
|
1387
2172
|
"settings.reasoning.unavailable": "Could not read this model\u2019s tier list; your saved tier is still sent.",
|
|
1388
|
-
"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.",
|
|
1389
2174
|
"settings.reasoning.unsupported": "The current value \u201C{effort}\u201D is not one of this model\u2019s tiers.",
|
|
1390
2175
|
"settings.reasoning.current": "Current value: {value}",
|
|
1391
2176
|
"settings.reasoning.currentTitle": "This model does not declare this tier",
|
|
1392
|
-
"settings.reasoning.refresh": "
|
|
2177
|
+
"settings.reasoning.refresh": "Refresh",
|
|
1393
2178
|
"settings.reasoning.refreshing": "Loading tier info\u2026",
|
|
1394
2179
|
"settings.reasoning.refreshOk": "Tier info updated",
|
|
1395
2180
|
"settings.reasoning.refreshFailed": "Could not load tier info \u2014 please retry."
|
|
@@ -1400,9 +2185,16 @@ var NS = "dsh-prompt-enhance";
|
|
|
1400
2185
|
// src/client/styles.ts
|
|
1401
2186
|
var STYLE_ID = "dsh-prompt-enhance-styles";
|
|
1402
2187
|
var CSS = `
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
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 {
|
|
1406
2198
|
--pe-bg: var(--dsw-alias-bg-layer-1, #1f2127);
|
|
1407
2199
|
--pe-fg: var(--dsw-alias-label-primary, #e6e8ee);
|
|
1408
2200
|
--pe-fg-dim: var(--dsw-alias-label-secondary, rgba(230, 232, 238, 0.55));
|
|
@@ -1411,11 +2203,234 @@ var CSS = `
|
|
|
1411
2203
|
/* No hover token exists: a neutral grey alpha is already theme-agnostic. */
|
|
1412
2204
|
--pe-hover: rgba(127, 127, 127, 0.18);
|
|
1413
2205
|
--pe-danger: var(--dsw-alias-state-error-primary, #ffb4a8);
|
|
2206
|
+
--pe-success: var(--dsw-alias-state-success-primary, #2da44e);
|
|
1414
2207
|
--pe-warn-fg: var(--dsw-alias-state-warn-primary, #e8c07d);
|
|
1415
2208
|
/* Tints of the themed warning color, so the banner cannot keep an amber cast
|
|
1416
2209
|
from the other scheme. */
|
|
1417
2210
|
--pe-warn-border: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 35%, transparent);
|
|
1418
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;
|
|
1419
2434
|
display: flex;
|
|
1420
2435
|
flex-direction: column;
|
|
1421
2436
|
width: 100%;
|
|
@@ -1426,7 +2441,46 @@ var CSS = `
|
|
|
1426
2441
|
color: var(--pe-fg);
|
|
1427
2442
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 14px rgba(0, 0, 0, 0.05);
|
|
1428
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;
|
|
1429
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; }
|
|
1430
2484
|
.dsh-pe-head {
|
|
1431
2485
|
display: flex;
|
|
1432
2486
|
align-items: center;
|
|
@@ -1453,22 +2507,30 @@ var CSS = `
|
|
|
1453
2507
|
font-size: 11px;
|
|
1454
2508
|
opacity: 0.72;
|
|
1455
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;
|
|
1456
2516
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
color: var(--dsw-alias-state-success-primary, #2da44e);
|
|
1464
|
-
border: 1px solid currentColor;
|
|
1465
|
-
white-space: nowrap;
|
|
1466
|
-
}
|
|
1467
|
-
.dsh-pe-close {
|
|
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;
|
|
1468
2523
|
border: none; background: transparent; color: inherit; opacity: 0.6;
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
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); }
|
|
1472
2534
|
.dsh-pe-result { padding: 2px 10px 6px; }
|
|
1473
2535
|
.dsh-pe-result-text {
|
|
1474
2536
|
margin: 0;
|
|
@@ -1480,6 +2542,9 @@ var CSS = `
|
|
|
1480
2542
|
font-family: inherit;
|
|
1481
2543
|
font-size: 12.5px;
|
|
1482
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;
|
|
1483
2548
|
}
|
|
1484
2549
|
.dsh-pe-col-title {
|
|
1485
2550
|
padding: 4px 10px 2px;
|
|
@@ -1493,6 +2558,10 @@ var CSS = `
|
|
|
1493
2558
|
line-height: 1.6;
|
|
1494
2559
|
color: var(--pe-danger);
|
|
1495
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;
|
|
1496
2565
|
}
|
|
1497
2566
|
.dsh-pe-error .dsh-pe-error-detail {
|
|
1498
2567
|
margin-top: 8px;
|
|
@@ -1547,7 +2616,6 @@ var CSS = `
|
|
|
1547
2616
|
cursor: pointer;
|
|
1548
2617
|
}
|
|
1549
2618
|
.dsh-pe-btn-action.primary {
|
|
1550
|
-
min-width: 112px;
|
|
1551
2619
|
border-color: transparent;
|
|
1552
2620
|
/* Fill and label are a PAIR: the alias layer flips brand-primary from
|
|
1553
2621
|
near-black (light theme) to near-white (dark theme), so the label has to
|
|
@@ -1565,9 +2633,23 @@ var CSS = `
|
|
|
1565
2633
|
}
|
|
1566
2634
|
.dsh-pe-btn-action.plain { background: transparent; color: inherit; }
|
|
1567
2635
|
.dsh-pe-btn-action.plain:hover { background: var(--pe-hover); }
|
|
1568
|
-
|
|
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; }
|
|
1569
2643
|
.dsh-pe-btn-action:disabled { opacity: 0.45; cursor: default; }
|
|
1570
2644
|
|
|
2645
|
+
/* Both labels of the regenerate button share one cell, so the button is as wide
|
|
2646
|
+
as the longer label of the active language and a label swap can never move
|
|
2647
|
+
the footer. visibility:hidden keeps the inert label out of the accessibility
|
|
2648
|
+
tree, leaving the visible text as the button's name. */
|
|
2649
|
+
.dsh-pe-swap { display: inline-grid; }
|
|
2650
|
+
.dsh-pe-swap > * { grid-area: 1 / 1; visibility: hidden; }
|
|
2651
|
+
.dsh-pe-swap > .on { visibility: visible; }
|
|
2652
|
+
|
|
1571
2653
|
.dsh-pe-stale {
|
|
1572
2654
|
padding: 6px 10px;
|
|
1573
2655
|
font-size: 12px;
|
|
@@ -1596,6 +2678,9 @@ var CSS = `
|
|
|
1596
2678
|
.dsh-pe-btn:hover:not(:disabled) { opacity: 1; background: var(--pe-hover); }
|
|
1597
2679
|
.dsh-pe-btn.is-busy { cursor: progress; }
|
|
1598
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". */
|
|
1599
2684
|
.dsh-pe-btn.is-empty { opacity: 0.4; cursor: not-allowed; }
|
|
1600
2685
|
.dsh-pe-btn.is-empty:hover { opacity: 0.4; background: transparent; }
|
|
1601
2686
|
.dsh-pe-btn:disabled { opacity: 0.45; cursor: default; }
|
|
@@ -1609,15 +2694,19 @@ var CSS = `
|
|
|
1609
2694
|
width: fit-content;
|
|
1610
2695
|
margin-left: auto;
|
|
1611
2696
|
padding: 3px 6px 3px 10px;
|
|
1612
|
-
border: 1px solid var(--
|
|
2697
|
+
border: 1px solid var(--pe-border);
|
|
1613
2698
|
border-radius: 12px;
|
|
1614
|
-
background: var(--
|
|
2699
|
+
background: var(--pe-bg);
|
|
1615
2700
|
font-size: 12px;
|
|
1616
|
-
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;
|
|
1617
2705
|
}
|
|
1618
2706
|
.dsh-pe-undo .dsh-pe-undo-check {
|
|
1619
|
-
|
|
1620
|
-
|
|
2707
|
+
display: inline-flex;
|
|
2708
|
+
align-items: center;
|
|
2709
|
+
color: var(--pe-success);
|
|
1621
2710
|
}
|
|
1622
2711
|
.dsh-pe-undo-link {
|
|
1623
2712
|
display: inline-flex;
|
|
@@ -1626,16 +2715,14 @@ var CSS = `
|
|
|
1626
2715
|
gap: 6px;
|
|
1627
2716
|
height: 28px;
|
|
1628
2717
|
padding: 0 10px;
|
|
1629
|
-
border: 1px solid var(--
|
|
2718
|
+
border: 1px solid var(--pe-border);
|
|
1630
2719
|
border-radius: 6px;
|
|
1631
2720
|
background: transparent;
|
|
1632
2721
|
color: inherit;
|
|
1633
2722
|
font-size: 12px;
|
|
1634
2723
|
cursor: pointer;
|
|
1635
|
-
transition: background-color 120ms ease;
|
|
1636
2724
|
}
|
|
1637
|
-
.dsh-pe-undo-link:hover { background:
|
|
1638
|
-
.dsh-pe-undo-link:active { background: rgba(127, 127, 127, 0.22); }
|
|
2725
|
+
.dsh-pe-undo-link:hover { background: var(--pe-hover); }
|
|
1639
2726
|
.dsh-pe-undo-x {
|
|
1640
2727
|
display: inline-flex;
|
|
1641
2728
|
align-items: center;
|
|
@@ -1646,12 +2733,20 @@ var CSS = `
|
|
|
1646
2733
|
border-radius: 6px;
|
|
1647
2734
|
background: transparent;
|
|
1648
2735
|
color: inherit;
|
|
1649
|
-
opacity: 0.
|
|
2736
|
+
opacity: 0.6;
|
|
1650
2737
|
cursor: pointer;
|
|
1651
2738
|
padding: 0;
|
|
1652
2739
|
font-size: 12px;
|
|
1653
2740
|
}
|
|
1654
|
-
.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
|
+
}
|
|
1655
2750
|
.dsh-pe-segmented-labels [role="tab"] {
|
|
1656
2751
|
min-width: 0;
|
|
1657
2752
|
overflow: hidden;
|
|
@@ -1659,20 +2754,25 @@ var CSS = `
|
|
|
1659
2754
|
text-align: center;
|
|
1660
2755
|
white-space: nowrap;
|
|
1661
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. */
|
|
1662
2760
|
.dsh-pe-advanced {
|
|
1663
|
-
margin-top:
|
|
1664
|
-
border-top:
|
|
2761
|
+
margin-top: 4px;
|
|
2762
|
+
border-top: 0.5px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
|
|
1665
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. */
|
|
1666
2766
|
.dsh-pe-advanced > summary {
|
|
1667
2767
|
display: flex;
|
|
1668
2768
|
align-items: center;
|
|
1669
2769
|
gap: 8px;
|
|
1670
|
-
|
|
1671
|
-
padding: 0 4px;
|
|
2770
|
+
padding: 12px 0;
|
|
1672
2771
|
list-style: none;
|
|
2772
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
1673
2773
|
font-size: 13px;
|
|
1674
2774
|
font-weight: 500;
|
|
1675
|
-
|
|
2775
|
+
line-height: 20px;
|
|
1676
2776
|
cursor: pointer;
|
|
1677
2777
|
user-select: none;
|
|
1678
2778
|
}
|
|
@@ -1681,26 +2781,42 @@ var CSS = `
|
|
|
1681
2781
|
.dsh-pe-advanced > summary::before {
|
|
1682
2782
|
content: '';
|
|
1683
2783
|
flex: none;
|
|
1684
|
-
width:
|
|
1685
|
-
height:
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
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);
|
|
1689
2798
|
transition: transform 120ms ease;
|
|
1690
2799
|
}
|
|
1691
|
-
.dsh-pe-advanced[open] > summary::before { transform:
|
|
2800
|
+
.dsh-pe-advanced[open] > summary::before { transform: none; }
|
|
1692
2801
|
.dsh-pe-advanced > summary:hover {
|
|
1693
|
-
color: var(--dsw-alias-label-
|
|
1694
|
-
|
|
1695
|
-
|
|
2802
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
2803
|
+
}
|
|
2804
|
+
.dsh-pe-advanced > summary:hover::before {
|
|
2805
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
1696
2806
|
}
|
|
1697
2807
|
.dsh-pe-advanced > summary:focus-visible {
|
|
1698
2808
|
outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
|
|
1699
2809
|
outline-offset: -2px;
|
|
1700
|
-
border-radius: 6px;
|
|
1701
2810
|
}
|
|
1702
|
-
|
|
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. */
|
|
1703
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; }
|
|
1704
2820
|
.dsh-pe-chip-reset:hover:not(:disabled),
|
|
1705
2821
|
.dsh-pe-chip-refresh:hover:not(:disabled) {
|
|
1706
2822
|
--pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
|
|
@@ -1749,7 +2865,7 @@ var CSS = `
|
|
|
1749
2865
|
font-size: 12px;
|
|
1750
2866
|
cursor: pointer;
|
|
1751
2867
|
}
|
|
1752
|
-
.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)); }
|
|
1753
2869
|
.dsh-pe-save-button:disabled { opacity: 0.5; cursor: default; }
|
|
1754
2870
|
`;
|
|
1755
2871
|
function ensureStyles() {
|
|
@@ -1799,6 +2915,28 @@ function matchesShortcut(event, combo) {
|
|
|
1799
2915
|
if (combo === null) return false;
|
|
1800
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);
|
|
1801
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
|
+
}
|
|
1802
2940
|
|
|
1803
2941
|
// src/client/settings-source.ts
|
|
1804
2942
|
var RANK = {
|
|
@@ -1821,6 +2959,14 @@ function servedNamespaces(forms) {
|
|
|
1821
2959
|
return [];
|
|
1822
2960
|
}
|
|
1823
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
|
+
}
|
|
1824
2970
|
function installClientSettingsSource(ctx, options) {
|
|
1825
2971
|
let rank = RANK.none;
|
|
1826
2972
|
const adopt = (next, section) => {
|
|
@@ -1861,6 +3007,7 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1861
3007
|
unsubscribeForm = void 0;
|
|
1862
3008
|
boundId = entryId;
|
|
1863
3009
|
adoptSnapshot(RANK.configForms, form);
|
|
3010
|
+
adoptWriter(form, true);
|
|
1864
3011
|
try {
|
|
1865
3012
|
unsubscribeForm = form.subscribe?.(() => adoptSnapshot(RANK.configForms, form));
|
|
1866
3013
|
} catch {
|
|
@@ -1889,212 +3036,76 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1889
3036
|
},
|
|
1890
3037
|
"dsh-prompt-enhance: settings namespace watch"
|
|
1891
3038
|
);
|
|
1892
|
-
}
|
|
1893
|
-
} catch {
|
|
1894
|
-
}
|
|
1895
|
-
});
|
|
1896
|
-
ctx.inject(["webUiSettings"], (binderCtx) => {
|
|
1897
|
-
const binder = binderCtx.webUiSettings;
|
|
1898
|
-
if (binder === void 0 || typeof binder.bind !== "function") return;
|
|
1899
|
-
let bound;
|
|
1900
|
-
for (const namespace of options.rowIds) {
|
|
1901
|
-
try {
|
|
1902
|
-
bound = binder.bind({ namespace });
|
|
1903
|
-
} catch {
|
|
1904
|
-
bound = void 0;
|
|
1905
|
-
}
|
|
1906
|
-
if (bound !== void 0) break;
|
|
1907
|
-
}
|
|
1908
|
-
if (bound === void 0) return;
|
|
1909
|
-
adoptSnapshot(RANK.binder, bound);
|
|
1910
|
-
let unsubscribe;
|
|
1911
|
-
try {
|
|
1912
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.binder, bound));
|
|
1913
|
-
} catch {
|
|
1914
|
-
unsubscribe = void 0;
|
|
1915
|
-
}
|
|
1916
|
-
ctx.effect(
|
|
1917
|
-
() => () => {
|
|
1918
|
-
try {
|
|
1919
|
-
unsubscribe?.();
|
|
1920
|
-
} catch {
|
|
1921
|
-
}
|
|
1922
|
-
},
|
|
1923
|
-
"dsh-prompt-enhance: settings binder mirror"
|
|
1924
|
-
);
|
|
1925
|
-
});
|
|
1926
|
-
ctx.inject(["settingsScope"], (scopeCtx) => {
|
|
1927
|
-
const scopeCtxLike = scopeCtx;
|
|
1928
|
-
const scope = scopeCtxLike.settingsScope;
|
|
1929
|
-
if (scope === void 0 || typeof scope.bind !== "function") return;
|
|
1930
|
-
let bound;
|
|
1931
|
-
try {
|
|
1932
|
-
bound = scope.bind({ namespace: options.rowIds[0] ?? "dsh-prompt-enhance", decode: (value) => value });
|
|
1933
|
-
} catch {
|
|
1934
|
-
return;
|
|
1935
|
-
}
|
|
1936
|
-
adoptSnapshot(RANK.legacyScope, bound);
|
|
1937
|
-
let unsubscribe;
|
|
1938
|
-
try {
|
|
1939
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.legacyScope, bound));
|
|
1940
|
-
} catch {
|
|
1941
|
-
unsubscribe = void 0;
|
|
1942
|
-
}
|
|
1943
|
-
ctx.effect(
|
|
1944
|
-
() => () => {
|
|
1945
|
-
try {
|
|
1946
|
-
unsubscribe?.();
|
|
1947
|
-
} catch {
|
|
1948
|
-
}
|
|
1949
|
-
},
|
|
1950
|
-
"dsh-prompt-enhance: settings scope mirror"
|
|
1951
|
-
);
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
// src/client/settings-page.tsx
|
|
1956
|
-
var import_react9 = require("react");
|
|
1957
|
-
|
|
1958
|
-
// src/client/llm-catalog.ts
|
|
1959
|
-
var import_react7 = require("react");
|
|
1960
|
-
|
|
1961
|
-
// src/shared/catalog.ts
|
|
1962
|
-
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
1963
|
-
var LLM_MODELS_ENDPOINT = "/dsh-prompt-enhance/llm-models";
|
|
1964
|
-
var LLM_ROUTE_CHECK_ENDPOINT = "/dsh-prompt-enhance/llm-route-check";
|
|
1965
|
-
|
|
1966
|
-
// src/client/llm-catalog.ts
|
|
1967
|
-
async function getJson(url, signal) {
|
|
1968
|
-
try {
|
|
1969
|
-
const response = await fetch(url, { signal, headers: { accept: "application/json" } });
|
|
1970
|
-
if (!response.ok) return void 0;
|
|
1971
|
-
const body = await response.json();
|
|
1972
|
-
const envelope = body;
|
|
1973
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) return void 0;
|
|
1974
|
-
return envelope.value;
|
|
1975
|
-
} catch {
|
|
1976
|
-
return void 0;
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
function endpoint(path, params = {}) {
|
|
1980
|
-
const url = new URL(path, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
1981
|
-
for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
|
|
1982
|
-
return url;
|
|
1983
|
-
}
|
|
1984
|
-
async function fetchProviders(signal) {
|
|
1985
|
-
const value = await getJson(endpoint(LLM_PROVIDERS_ENDPOINT), signal);
|
|
1986
|
-
if (value === void 0 || !Array.isArray(value.providers)) return void 0;
|
|
1987
|
-
return value.providers.filter(
|
|
1988
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== "" && typeof entry.registered === "boolean"
|
|
1989
|
-
);
|
|
1990
|
-
}
|
|
1991
|
-
async function fetchModels(provider, signal) {
|
|
1992
|
-
const value = await getJson(endpoint(LLM_MODELS_ENDPOINT, { provider }), signal);
|
|
1993
|
-
if (value === void 0 || !Array.isArray(value.models)) return void 0;
|
|
1994
|
-
const models = value.models.filter(
|
|
1995
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== ""
|
|
1996
|
-
).map((entry) => ({
|
|
1997
|
-
id: entry.id,
|
|
1998
|
-
name: entry.name,
|
|
1999
|
-
...typeof entry.description === "string" && entry.description !== "" ? { description: entry.description } : {}
|
|
2000
|
-
}));
|
|
2001
|
-
return { models, ...typeof value.reason === "string" ? { reason: value.reason } : {} };
|
|
2002
|
-
}
|
|
2003
|
-
async function fetchRouteCheck(provider, model, signal) {
|
|
2004
|
-
const value = await getJson(endpoint(LLM_ROUTE_CHECK_ENDPOINT, { provider, model }), signal);
|
|
2005
|
-
if (value === void 0 || typeof value.available !== "boolean") return void 0;
|
|
2006
|
-
return value;
|
|
2007
|
-
}
|
|
2008
|
-
function useLlmRouting(provider, model) {
|
|
2009
|
-
const [providers, setProviders] = (0, import_react7.useState)([]);
|
|
2010
|
-
const [providersLoading, setProvidersLoading] = (0, import_react7.useState)(true);
|
|
2011
|
-
const [providersFailed, setProvidersFailed] = (0, import_react7.useState)(false);
|
|
2012
|
-
const [providersToken, setProvidersToken] = (0, import_react7.useState)(0);
|
|
2013
|
-
const [models, setModels] = (0, import_react7.useState)([]);
|
|
2014
|
-
const [modelsLoading, setModelsLoading] = (0, import_react7.useState)(false);
|
|
2015
|
-
const [modelsFailed, setModelsFailed] = (0, import_react7.useState)(false);
|
|
2016
|
-
const [modelsToken, setModelsToken] = (0, import_react7.useState)(0);
|
|
2017
|
-
const [routeChecking, setRouteChecking] = (0, import_react7.useState)(false);
|
|
2018
|
-
const [routeAvailable, setRouteAvailable] = (0, import_react7.useState)(void 0);
|
|
2019
|
-
(0, import_react7.useEffect)(() => {
|
|
2020
|
-
const controller = new AbortController();
|
|
2021
|
-
setProvidersLoading(true);
|
|
2022
|
-
setProvidersFailed(false);
|
|
2023
|
-
void fetchProviders(controller.signal).then((entries) => {
|
|
2024
|
-
if (controller.signal.aborted) return;
|
|
2025
|
-
setProvidersLoading(false);
|
|
2026
|
-
if (entries === void 0) {
|
|
2027
|
-
setProvidersFailed(true);
|
|
2028
|
-
setProviders([]);
|
|
2029
|
-
return;
|
|
2030
|
-
}
|
|
2031
|
-
setProviders(entries);
|
|
2032
|
-
});
|
|
2033
|
-
return () => controller.abort();
|
|
2034
|
-
}, [providersToken]);
|
|
2035
|
-
(0, import_react7.useEffect)(() => {
|
|
2036
|
-
if (provider === "") {
|
|
2037
|
-
setModels([]);
|
|
2038
|
-
setModelsLoading(false);
|
|
2039
|
-
setModelsFailed(false);
|
|
2040
|
-
return;
|
|
3039
|
+
}
|
|
3040
|
+
} catch {
|
|
2041
3041
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
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;
|
|
2052
3052
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
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 {
|
|
2062
3082
|
return;
|
|
2063
3083
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
failed: providersFailed,
|
|
2083
|
-
entries: providers,
|
|
2084
|
-
reload: () => setProvidersToken((token) => token + 1)
|
|
2085
|
-
},
|
|
2086
|
-
models: {
|
|
2087
|
-
loading: modelsLoading,
|
|
2088
|
-
failed: modelsFailed,
|
|
2089
|
-
entries: models,
|
|
2090
|
-
reload: () => setModelsToken((token) => token + 1)
|
|
2091
|
-
},
|
|
2092
|
-
route: { checking: routeChecking, available: routeAvailable }
|
|
2093
|
-
};
|
|
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
|
+
});
|
|
2094
3102
|
}
|
|
2095
3103
|
|
|
3104
|
+
// src/client/settings-page.tsx
|
|
3105
|
+
var import_react10 = require("react");
|
|
3106
|
+
|
|
2096
3107
|
// src/client/settings-page-spec.ts
|
|
2097
|
-
var
|
|
3108
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2098
3109
|
var SETTINGS_SECTION_SLOT = "settings.section";
|
|
2099
3110
|
var SETTINGS_SECTION_ID = "dsh-prompt-enhance";
|
|
2100
3111
|
var SETTINGS_SECTION_ORDER = 70;
|
|
@@ -2141,9 +3152,20 @@ var BASIC_ROWS = [
|
|
|
2141
3152
|
{ key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
|
|
2142
3153
|
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
2143
3154
|
{ key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
|
|
2144
|
-
{
|
|
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
|
+
}
|
|
2145
3165
|
];
|
|
2146
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" },
|
|
2147
3169
|
{ key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
|
|
2148
3170
|
{ key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
|
|
2149
3171
|
{ key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
|
|
@@ -2157,7 +3179,7 @@ var ROWS = [...BASIC_ROWS, ...ADVANCED_ROWS];
|
|
|
2157
3179
|
function descriptorOf(row) {
|
|
2158
3180
|
switch (row.kind) {
|
|
2159
3181
|
case "number":
|
|
2160
|
-
return (0,
|
|
3182
|
+
return (0, import_dsh_client_ui_primitives2.settingsNumberField)(row.key);
|
|
2161
3183
|
case "boolean":
|
|
2162
3184
|
return settingsBooleanField(row.key);
|
|
2163
3185
|
case "strategy":
|
|
@@ -2166,14 +3188,14 @@ function descriptorOf(row) {
|
|
|
2166
3188
|
STRATEGY_OPTIONS.map((option) => option.value)
|
|
2167
3189
|
);
|
|
2168
3190
|
case "reasoning":
|
|
2169
|
-
return (0,
|
|
3191
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2170
3192
|
default:
|
|
2171
|
-
return (0,
|
|
3193
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2172
3194
|
}
|
|
2173
3195
|
}
|
|
2174
3196
|
var FIELD_SPECS = ROWS.map((row) => descriptorOf(row));
|
|
2175
3197
|
function createSettingsForm(scope) {
|
|
2176
|
-
return new
|
|
3198
|
+
return new import_dsh_client_ui_primitives2.SettingsFormModel(scope, FIELD_SPECS);
|
|
2177
3199
|
}
|
|
2178
3200
|
function viewOf(snapshot, key) {
|
|
2179
3201
|
const value = snapshot[key];
|
|
@@ -2230,7 +3252,12 @@ function sectionCopy(t, chinese) {
|
|
|
2230
3252
|
saved: t("settings.saved"),
|
|
2231
3253
|
advanced: t("settings.advanced"),
|
|
2232
3254
|
reset: t("settings.reset"),
|
|
2233
|
-
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")
|
|
2234
3261
|
},
|
|
2235
3262
|
title: (row) => chinese ? `${row.key}\uFF08${t(row.label)}\uFF09` : row.key,
|
|
2236
3263
|
hint: (row) => t(row.hint),
|
|
@@ -2251,7 +3278,12 @@ function pageCopy(t) {
|
|
|
2251
3278
|
saved: t("settings.saved"),
|
|
2252
3279
|
advanced: t("settings.advanced"),
|
|
2253
3280
|
reset: t("settings.reset"),
|
|
2254
|
-
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")
|
|
2255
3287
|
},
|
|
2256
3288
|
title: (row) => t(row.label),
|
|
2257
3289
|
hint: (row) => t(row.hint),
|
|
@@ -2262,57 +3294,8 @@ function pageCopy(t) {
|
|
|
2262
3294
|
}
|
|
2263
3295
|
|
|
2264
3296
|
// src/client/settings-page-controls.tsx
|
|
2265
|
-
var
|
|
2266
|
-
var
|
|
2267
|
-
|
|
2268
|
-
// src/shared/reasoning.ts
|
|
2269
|
-
var REASONING_EFFORTS_ENDPOINT = "/dsh-prompt-enhance/reasoning-efforts";
|
|
2270
|
-
|
|
2271
|
-
// src/client/reasoning-options.ts
|
|
2272
|
-
function effortOf(value) {
|
|
2273
|
-
if (value === null || typeof value !== "object") return void 0;
|
|
2274
|
-
const record = value;
|
|
2275
|
-
if (typeof record.id !== "string" || record.id === "" || typeof record.name !== "string" || record.name === "") return void 0;
|
|
2276
|
-
return {
|
|
2277
|
-
id: record.id,
|
|
2278
|
-
name: record.name,
|
|
2279
|
-
...typeof record.description === "string" && record.description !== "" ? { description: record.description } : {}
|
|
2280
|
-
};
|
|
2281
|
-
}
|
|
2282
|
-
function capabilitiesOf(value) {
|
|
2283
|
-
if (value === null || typeof value !== "object") return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2284
|
-
const record = value;
|
|
2285
|
-
const source = record.source === "resolved" || record.source === "default" || record.source === "unavailable" ? record.source : "unavailable";
|
|
2286
|
-
const efforts = Array.isArray(record.efforts) ? record.efforts.map(effortOf).filter((effort) => effort !== void 0) : [];
|
|
2287
|
-
const reason = typeof record.reason === "string" ? record.reason : void 0;
|
|
2288
|
-
if (source !== "unavailable" && efforts.length === 0) return { efforts: [], source: "unavailable", reason: "no-efforts" };
|
|
2289
|
-
return {
|
|
2290
|
-
efforts,
|
|
2291
|
-
source,
|
|
2292
|
-
...typeof record.defaultEffort === "string" && record.defaultEffort !== "" ? { defaultEffort: record.defaultEffort } : {},
|
|
2293
|
-
...reason === void 0 ? {} : { reason }
|
|
2294
|
-
};
|
|
2295
|
-
}
|
|
2296
|
-
async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
2297
|
-
const url = new URL(REASONING_EFFORTS_ENDPOINT, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
2298
|
-
if (provider !== void 0 && model !== void 0) {
|
|
2299
|
-
url.searchParams.set("provider", provider);
|
|
2300
|
-
url.searchParams.set("model", model);
|
|
2301
|
-
}
|
|
2302
|
-
if (options.refresh === true) url.searchParams.set("refresh", "1");
|
|
2303
|
-
try {
|
|
2304
|
-
const response = await fetch(url, { signal: options.signal, headers: { accept: "application/json" } });
|
|
2305
|
-
if (!response.ok) return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2306
|
-
const body = await response.json();
|
|
2307
|
-
const envelope = body;
|
|
2308
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) {
|
|
2309
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2310
|
-
}
|
|
2311
|
-
return capabilitiesOf(envelope.value);
|
|
2312
|
-
} catch {
|
|
2313
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
3297
|
+
var import_react9 = require("react");
|
|
3298
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2316
3299
|
|
|
2317
3300
|
// src/client/settings-page-styles.ts
|
|
2318
3301
|
var ROW_STYLE = { display: "flex", flexDirection: "column", gap: 6, padding: "12px 0" };
|
|
@@ -2337,6 +3320,13 @@ var STATUS_STYLE = {
|
|
|
2337
3320
|
lineHeight: 1.5,
|
|
2338
3321
|
color: "var(--dsw-alias-label-secondary, inherit)"
|
|
2339
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
|
+
};
|
|
2340
3330
|
var CHIP_STYLE = {
|
|
2341
3331
|
display: "inline-flex",
|
|
2342
3332
|
alignItems: "center",
|
|
@@ -2355,20 +3345,34 @@ var CHIP_STYLE = {
|
|
|
2355
3345
|
};
|
|
2356
3346
|
var REFRESH_STYLE = { ...CHIP_STYLE, flex: "none" };
|
|
2357
3347
|
var RESET_STYLE = CHIP_STYLE;
|
|
2358
|
-
var
|
|
2359
|
-
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 = {
|
|
2360
3351
|
boxSizing: "border-box",
|
|
2361
3352
|
width: "100%",
|
|
2362
3353
|
height: 34,
|
|
2363
3354
|
padding: "0 12px",
|
|
2364
3355
|
border: FIELD_BORDER,
|
|
2365
3356
|
borderRadius: "var(--dsw-radius-md, 8px)",
|
|
2366
|
-
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",
|
|
2367
3372
|
font: "inherit",
|
|
2368
3373
|
fontSize: 13,
|
|
2369
|
-
lineHeight:
|
|
2370
|
-
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2371
|
-
outline: "none"
|
|
3374
|
+
lineHeight: "22px",
|
|
3375
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2372
3376
|
};
|
|
2373
3377
|
var INVALID_STYLE = {
|
|
2374
3378
|
margin: 0,
|
|
@@ -2383,7 +3387,13 @@ var WARN_STYLE = {
|
|
|
2383
3387
|
color: "var(--dsw-alias-state-error-primary, #f85149)"
|
|
2384
3388
|
};
|
|
2385
3389
|
var SELECT_STYLE = {
|
|
2386
|
-
...
|
|
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",
|
|
2387
3397
|
cursor: "pointer"
|
|
2388
3398
|
};
|
|
2389
3399
|
var SEPARATOR_STYLE = {
|
|
@@ -2393,7 +3403,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
|
|
|
2393
3403
|
var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
2394
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";
|
|
2395
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";
|
|
2396
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
3406
|
+
var PLUGIN_VERSION = true ? "0.1.2" : "0.0.0";
|
|
2397
3407
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
2398
3408
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
2399
3409
|
var HEADER_TITLE_STYLE = {
|
|
@@ -2440,28 +3450,28 @@ var HEADER_DESCRIPTION_STYLE = {
|
|
|
2440
3450
|
};
|
|
2441
3451
|
|
|
2442
3452
|
// src/client/settings-page-controls.tsx
|
|
2443
|
-
var
|
|
3453
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2444
3454
|
function OverrideActions(props) {
|
|
2445
|
-
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 });
|
|
2446
3456
|
}
|
|
2447
3457
|
function BooleanRow(props) {
|
|
2448
|
-
return /* @__PURE__ */ (0,
|
|
2449
|
-
/* @__PURE__ */ (0,
|
|
2450
|
-
/* @__PURE__ */ (0,
|
|
2451
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
2452
|
-
/* @__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") })
|
|
2453
3463
|
] }),
|
|
2454
|
-
/* @__PURE__ */ (0,
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2455
3465
|
] });
|
|
2456
3466
|
}
|
|
2457
3467
|
function ChoiceRow(props) {
|
|
2458
|
-
return /* @__PURE__ */ (0,
|
|
2459
|
-
/* @__PURE__ */ (0,
|
|
2460
|
-
/* @__PURE__ */ (0,
|
|
2461
|
-
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
|
|
2462
3472
|
] }),
|
|
2463
|
-
/* @__PURE__ */ (0,
|
|
2464
|
-
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3474
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2465
3475
|
{
|
|
2466
3476
|
id: props.id,
|
|
2467
3477
|
className: "dsh-pe-segmented-labels",
|
|
@@ -2472,23 +3482,30 @@ function ChoiceRow(props) {
|
|
|
2472
3482
|
onChange: (next) => props.onEdit(next)
|
|
2473
3483
|
}
|
|
2474
3484
|
),
|
|
2475
|
-
/* @__PURE__ */ (0,
|
|
3485
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2476
3486
|
] });
|
|
2477
3487
|
}
|
|
3488
|
+
var capabilityCache = /* @__PURE__ */ new Map();
|
|
3489
|
+
function capabilityKey(provider, model) {
|
|
3490
|
+
return `${provider}\0${model}`;
|
|
3491
|
+
}
|
|
2478
3492
|
function ReasoningRow(props) {
|
|
2479
3493
|
const pair = props.provider !== "" && props.model !== "" ? `${props.provider}/${props.model}` : "";
|
|
2480
|
-
const
|
|
2481
|
-
const
|
|
2482
|
-
const [
|
|
2483
|
-
const [
|
|
2484
|
-
const
|
|
2485
|
-
const
|
|
2486
|
-
(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)(() => {
|
|
2487
3503
|
const controller = new AbortController();
|
|
2488
3504
|
const force = forceRef.current;
|
|
2489
3505
|
forceRef.current = false;
|
|
2490
|
-
|
|
2491
|
-
|
|
3506
|
+
const known = capabilityCache.get(cacheKey);
|
|
3507
|
+
setPhase(known === void 0 ? "loading" : "ready");
|
|
3508
|
+
setCapabilities(known);
|
|
2492
3509
|
setFeedback(force ? "refreshing" : "idle");
|
|
2493
3510
|
if (feedbackTimer.current !== void 0) {
|
|
2494
3511
|
clearTimeout(feedbackTimer.current);
|
|
@@ -2506,6 +3523,7 @@ function ReasoningRow(props) {
|
|
|
2506
3523
|
if (controller.signal.aborted) return;
|
|
2507
3524
|
setCapabilities(answer);
|
|
2508
3525
|
setPhase("ready");
|
|
3526
|
+
if (answer.source !== "unavailable" || answer.reason === "no-efforts") capabilityCache.set(cacheKey, answer);
|
|
2509
3527
|
settle(answer.source === "unavailable" ? "failed" : "ok");
|
|
2510
3528
|
}).catch(() => {
|
|
2511
3529
|
if (controller.signal.aborted) return;
|
|
@@ -2520,15 +3538,20 @@ function ReasoningRow(props) {
|
|
|
2520
3538
|
feedbackTimer.current = void 0;
|
|
2521
3539
|
}
|
|
2522
3540
|
};
|
|
2523
|
-
}, [pair, refreshToken]);
|
|
2524
|
-
const
|
|
2525
|
-
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);
|
|
2526
3544
|
const noTiers = phase === "ready" && capabilities !== void 0 && capabilities.source === "unavailable" && capabilities.reason === "no-efforts";
|
|
2527
3545
|
const options = [];
|
|
2528
|
-
|
|
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) {
|
|
2529
3552
|
options.push({
|
|
2530
|
-
value:
|
|
2531
|
-
label: props.copy.interpolate("settings.reasoning.current", { value:
|
|
3553
|
+
value: current3,
|
|
3554
|
+
label: props.copy.interpolate("settings.reasoning.current", { value: current3 }),
|
|
2532
3555
|
title: props.copy.choice("settings.reasoning.currentTitle")
|
|
2533
3556
|
});
|
|
2534
3557
|
}
|
|
@@ -2541,46 +3564,42 @@ function ReasoningRow(props) {
|
|
|
2541
3564
|
});
|
|
2542
3565
|
}
|
|
2543
3566
|
}
|
|
2544
|
-
options.
|
|
2545
|
-
|
|
2546
|
-
label: props.copy.choice("settings.reasoning.inherit"),
|
|
2547
|
-
title: props.copy.choice("settings.reasoning.inherit")
|
|
2548
|
-
});
|
|
2549
|
-
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;
|
|
2550
3569
|
const refreshing = feedback === "refreshing";
|
|
2551
3570
|
const refresh = () => {
|
|
2552
3571
|
forceRef.current = true;
|
|
2553
3572
|
setRefreshToken((token) => token + 1);
|
|
2554
3573
|
};
|
|
2555
|
-
return /* @__PURE__ */ (0,
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2557
|
-
/* @__PURE__ */ (0,
|
|
2558
|
-
phase === "ready" || refreshing ? /* @__PURE__ */ (0,
|
|
2559
|
-
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
|
|
2560
3579
|
] }),
|
|
2561
|
-
/* @__PURE__ */ (0,
|
|
2562
|
-
|
|
3580
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3581
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2563
3582
|
{
|
|
2564
3583
|
id: props.id,
|
|
2565
3584
|
className: "dsh-pe-segmented-labels",
|
|
2566
|
-
value:
|
|
3585
|
+
value: selected,
|
|
2567
3586
|
options,
|
|
2568
3587
|
disabled: props.disabled,
|
|
2569
3588
|
label: props.label,
|
|
2570
3589
|
onChange: (next) => props.onEdit(next)
|
|
2571
3590
|
}
|
|
2572
3591
|
),
|
|
2573
|
-
/* @__PURE__ */ (0,
|
|
2574
|
-
phase === "loading" ? /* @__PURE__ */ (0,
|
|
2575
|
-
phase === "ready" && capabilities?.source === "unavailable" ? /* @__PURE__ */ (0,
|
|
2576
|
-
unsupported ? /* @__PURE__ */ (0,
|
|
2577
|
-
feedback === "ok" ? /* @__PURE__ */ (0,
|
|
2578
|
-
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
|
|
2579
3598
|
] });
|
|
2580
3599
|
}
|
|
2581
3600
|
function SelectControl(props) {
|
|
2582
|
-
const [focused, setFocused] = (0,
|
|
2583
|
-
return /* @__PURE__ */ (0,
|
|
3601
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2584
3603
|
"select",
|
|
2585
3604
|
{
|
|
2586
3605
|
id: props.id,
|
|
@@ -2595,50 +3614,50 @@ function SelectControl(props) {
|
|
|
2595
3614
|
);
|
|
2596
3615
|
}
|
|
2597
3616
|
function ProviderRow(props) {
|
|
2598
|
-
const
|
|
2599
|
-
const known = props.routing.providers.entries.find((entry) => entry.id ===
|
|
2600
|
-
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;
|
|
2601
3620
|
const unconfigured = known !== void 0 && !known.registered;
|
|
2602
|
-
return /* @__PURE__ */ (0,
|
|
2603
|
-
/* @__PURE__ */ (0,
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
2605
|
-
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
|
|
2606
3625
|
] }),
|
|
2607
|
-
/* @__PURE__ */ (0,
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
missing ? /* @__PURE__ */ (0,
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2611
|
-
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: [
|
|
2612
3631
|
entry.name,
|
|
2613
3632
|
props.copy.choice("settings.routing.unconfiguredSuffix")
|
|
2614
3633
|
] }, entry.id)) }) : null
|
|
2615
3634
|
] }),
|
|
2616
|
-
/* @__PURE__ */ (0,
|
|
2617
|
-
props.routing.providers.loading ? /* @__PURE__ */ (0,
|
|
2618
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2619
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2620
|
-
missing ? /* @__PURE__ */ (0,
|
|
2621
|
-
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
|
|
2622
3641
|
] });
|
|
2623
3642
|
}
|
|
2624
3643
|
function ModelRow(props) {
|
|
2625
|
-
const
|
|
3644
|
+
const current3 = props.view.text;
|
|
2626
3645
|
const provider = props.providerValue;
|
|
2627
|
-
const [customMode, setCustomMode] = (0,
|
|
2628
|
-
const known = props.routing.models.entries.some((entry) => entry.id ===
|
|
2629
|
-
const showCustom = provider !== "" && (customMode ||
|
|
2630
|
-
const pairIncomplete = provider !== "" &&
|
|
2631
|
-
const routeUnavailable = provider !== "" &&
|
|
2632
|
-
return /* @__PURE__ */ (0,
|
|
2633
|
-
/* @__PURE__ */ (0,
|
|
2634
|
-
/* @__PURE__ */ (0,
|
|
2635
|
-
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
|
|
2636
3655
|
] }),
|
|
2637
|
-
/* @__PURE__ */ (0,
|
|
3656
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2638
3657
|
SelectControl,
|
|
2639
3658
|
{
|
|
2640
3659
|
id: props.id,
|
|
2641
|
-
value: showCustom ? "__custom__" :
|
|
3660
|
+
value: showCustom ? "__custom__" : current3,
|
|
2642
3661
|
disabled: props.disabled || provider === "",
|
|
2643
3662
|
onChange: (value) => {
|
|
2644
3663
|
if (value === "__custom__") {
|
|
@@ -2649,68 +3668,131 @@ function ModelRow(props) {
|
|
|
2649
3668
|
props.onEdit(value);
|
|
2650
3669
|
},
|
|
2651
3670
|
children: [
|
|
2652
|
-
/* @__PURE__ */ (0,
|
|
2653
|
-
props.routing.models.entries.map((entry) => /* @__PURE__ */ (0,
|
|
2654
|
-
provider !== "" &&
|
|
2655
|
-
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
|
|
2656
3675
|
]
|
|
2657
3676
|
}
|
|
2658
3677
|
),
|
|
2659
|
-
showCustom ? /* @__PURE__ */ (0,
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
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
|
|
2665
3693
|
] });
|
|
2666
3694
|
}
|
|
2667
3695
|
function TextControl(props) {
|
|
2668
|
-
const [focused, setFocused] = (0,
|
|
2669
|
-
const [revealedInvalid, setRevealedInvalid] = (0,
|
|
2670
|
-
(0,
|
|
3696
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3697
|
+
const [revealedInvalid, setRevealedInvalid] = (0, import_react9.useState)(false);
|
|
3698
|
+
(0, import_react9.useEffect)(() => {
|
|
2671
3699
|
if (props.invalid !== true) setRevealedInvalid(false);
|
|
2672
3700
|
}, [props.invalid]);
|
|
2673
3701
|
const showInvalid = props.invalid === true && revealedInvalid;
|
|
2674
3702
|
const borderColor = showInvalid ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
|
|
2675
|
-
return
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
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
|
+
) })
|
|
2704
3736
|
);
|
|
2705
3737
|
}
|
|
2706
3738
|
function ValueRow(props) {
|
|
2707
|
-
const invalid = props.view.invalid;
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
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
|
|
2712
3794
|
] }),
|
|
2713
|
-
/* @__PURE__ */ (0,
|
|
3795
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2714
3796
|
TextControl,
|
|
2715
3797
|
{
|
|
2716
3798
|
id: props.id,
|
|
@@ -2719,17 +3801,24 @@ function ValueRow(props) {
|
|
|
2719
3801
|
numeric: props.numeric,
|
|
2720
3802
|
invalid,
|
|
2721
3803
|
disabled: props.disabled,
|
|
2722
|
-
onChange:
|
|
2723
|
-
|
|
3804
|
+
onChange: (text) => {
|
|
3805
|
+
setRevealed(false);
|
|
3806
|
+
props.onEdit(text);
|
|
3807
|
+
},
|
|
3808
|
+
onCommit: () => {
|
|
3809
|
+
setRevealed(true);
|
|
3810
|
+
props.onCommit?.();
|
|
3811
|
+
}
|
|
2724
3812
|
}
|
|
2725
3813
|
),
|
|
2726
|
-
/* @__PURE__ */ (0,
|
|
2727
|
-
|
|
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
|
|
2728
3817
|
] });
|
|
2729
3818
|
}
|
|
2730
3819
|
|
|
2731
3820
|
// src/client/settings-page.tsx
|
|
2732
|
-
var
|
|
3821
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2733
3822
|
function sectionTitle(getLocale) {
|
|
2734
3823
|
try {
|
|
2735
3824
|
const t = getLocale?.()?.bind(NS);
|
|
@@ -2739,23 +3828,23 @@ function sectionTitle(getLocale) {
|
|
|
2739
3828
|
}
|
|
2740
3829
|
}
|
|
2741
3830
|
function PageHeader(props) {
|
|
2742
|
-
return /* @__PURE__ */ (0,
|
|
2743
|
-
/* @__PURE__ */ (0,
|
|
2744
|
-
/* @__PURE__ */ (0,
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
2746
|
-
/* @__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 }) }),
|
|
2747
3836
|
"GitHub"
|
|
2748
3837
|
] }),
|
|
2749
|
-
/* @__PURE__ */ (0,
|
|
2750
|
-
/* @__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 }) }),
|
|
2751
3840
|
"npm"
|
|
2752
3841
|
] }),
|
|
2753
|
-
/* @__PURE__ */ (0,
|
|
3842
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { style: HEADER_VERSION_STYLE, children: [
|
|
2754
3843
|
"v",
|
|
2755
3844
|
props.version
|
|
2756
3845
|
] })
|
|
2757
3846
|
] }),
|
|
2758
|
-
/* @__PURE__ */ (0,
|
|
3847
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: HEADER_DESCRIPTION_STYLE, children: props.description })
|
|
2759
3848
|
] });
|
|
2760
3849
|
}
|
|
2761
3850
|
function SettingsRow(props) {
|
|
@@ -2772,37 +3861,55 @@ function SettingsRow(props) {
|
|
|
2772
3861
|
};
|
|
2773
3862
|
switch (props.row.kind) {
|
|
2774
3863
|
case "boolean":
|
|
2775
|
-
return /* @__PURE__ */ (0,
|
|
3864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BooleanRow, { ...shared });
|
|
2776
3865
|
case "strategy":
|
|
2777
|
-
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) })) });
|
|
2778
3867
|
case "reasoning":
|
|
2779
|
-
return /* @__PURE__ */ (0,
|
|
3868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ReasoningRow, { ...shared, provider: props.reasoningPair.provider, model: props.reasoningPair.model });
|
|
2780
3869
|
case "provider":
|
|
2781
|
-
return /* @__PURE__ */ (0,
|
|
3870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProviderRow, { ...shared, routing: props.routing });
|
|
2782
3871
|
case "model":
|
|
2783
|
-
return /* @__PURE__ */ (0,
|
|
3872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModelRow, { ...shared, routing: props.routing, providerValue: props.providerValue });
|
|
2784
3873
|
default:
|
|
2785
|
-
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
|
+
);
|
|
2786
3884
|
}
|
|
2787
3885
|
}
|
|
2788
3886
|
function SettingsRows(props) {
|
|
2789
3887
|
const provider = viewOf(props.state, "provider").text.trim();
|
|
2790
3888
|
const model = viewOf(props.state, "model").text.trim();
|
|
2791
3889
|
const routing = useLlmRouting(provider, model);
|
|
2792
|
-
const [saveState, setSaveState] = (0,
|
|
2793
|
-
const timers = (0,
|
|
2794
|
-
const savedTimer = (0,
|
|
2795
|
-
const savedValues = (0,
|
|
2796
|
-
const sequence = (0,
|
|
2797
|
-
(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)(() => {
|
|
2798
3896
|
for (const row of ROWS) {
|
|
2799
3897
|
if (!savedValues.current.has(row.key)) {
|
|
2800
3898
|
savedValues.current.set(row.key, viewOf(props.state, row.key).text);
|
|
2801
3899
|
}
|
|
2802
3900
|
}
|
|
2803
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));
|
|
2804
3907
|
const runSave = async (key, text) => {
|
|
2805
3908
|
if (props.writeField === void 0) return;
|
|
3909
|
+
if (isStagedInvalid(key, text)) {
|
|
3910
|
+
setSaveState("idle");
|
|
3911
|
+
return;
|
|
3912
|
+
}
|
|
2806
3913
|
if (savedValues.current.get(key) === text) return;
|
|
2807
3914
|
const ticket = ++sequence.current;
|
|
2808
3915
|
setSaveState("saving");
|
|
@@ -2844,20 +3951,35 @@ function SettingsRows(props) {
|
|
|
2844
3951
|
savedValues.current.set(key, fallback);
|
|
2845
3952
|
markSaved();
|
|
2846
3953
|
};
|
|
3954
|
+
const resetTargets = (key) => key === "provider" && viewOf(props.state, "model").text !== "" ? ["provider", "model"] : [key];
|
|
2847
3955
|
const resetAndSave = (key) => {
|
|
2848
|
-
|
|
2849
|
-
const
|
|
2850
|
-
|
|
2851
|
-
|
|
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
|
+
})();
|
|
2852
3964
|
};
|
|
2853
3965
|
const manualSave = async () => {
|
|
2854
3966
|
if (props.writeField === void 0) {
|
|
3967
|
+
if (hasStagedInvalid()) {
|
|
3968
|
+
setSaveState("idle");
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
2855
3971
|
props.save?.();
|
|
2856
3972
|
markSaved();
|
|
2857
3973
|
return;
|
|
2858
3974
|
}
|
|
2859
|
-
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
|
+
);
|
|
2860
3978
|
if (changed.length === 0) {
|
|
3979
|
+
if (hasStagedInvalid()) {
|
|
3980
|
+
setSaveState("idle");
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
2861
3983
|
markSaved();
|
|
2862
3984
|
return;
|
|
2863
3985
|
}
|
|
@@ -2890,10 +4012,17 @@ function SettingsRows(props) {
|
|
|
2890
4012
|
}, 800);
|
|
2891
4013
|
timers.current.set(key, timer);
|
|
2892
4014
|
};
|
|
2893
|
-
const onEdit = (key, text) => {
|
|
4015
|
+
const onEdit = (key, text, options) => {
|
|
4016
|
+
const previousProvider = key === "provider" ? viewOf(props.state, "provider").text : "";
|
|
2894
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
|
+
}
|
|
2895
4023
|
const row = ROWS.find((item) => item.key === key);
|
|
2896
|
-
const
|
|
4024
|
+
const typing = row !== void 0 && (row.kind === "text" || row.kind === "number");
|
|
4025
|
+
const debounced = options?.deferred === true || typing;
|
|
2897
4026
|
scheduleSave(key, text, !debounced);
|
|
2898
4027
|
};
|
|
2899
4028
|
const flushField = (key, text) => {
|
|
@@ -2904,7 +4033,7 @@ function SettingsRows(props) {
|
|
|
2904
4033
|
}
|
|
2905
4034
|
void runSave(key, text ?? viewOf(props.state, key).text);
|
|
2906
4035
|
};
|
|
2907
|
-
(0,
|
|
4036
|
+
(0, import_react10.useEffect)(
|
|
2908
4037
|
() => () => {
|
|
2909
4038
|
for (const timer of timers.current.values()) clearTimeout(timer);
|
|
2910
4039
|
timers.current.clear();
|
|
@@ -2916,7 +4045,7 @@ function SettingsRows(props) {
|
|
|
2916
4045
|
const renderRow = (row, index) => {
|
|
2917
4046
|
const raw = viewOf(props.state, row.key);
|
|
2918
4047
|
const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
|
|
2919
|
-
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)(
|
|
2920
4049
|
SettingsRow,
|
|
2921
4050
|
{
|
|
2922
4051
|
row,
|
|
@@ -2926,21 +4055,21 @@ function SettingsRows(props) {
|
|
|
2926
4055
|
reasoningPair: { provider, model },
|
|
2927
4056
|
routing,
|
|
2928
4057
|
providerValue: provider,
|
|
2929
|
-
onEdit: (text) => onEdit(row.key, text),
|
|
4058
|
+
onEdit: (text, options) => onEdit(row.key, text, options),
|
|
2930
4059
|
onReset: () => resetAndSave(row.key),
|
|
2931
4060
|
onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
|
|
2932
4061
|
}
|
|
2933
4062
|
) }, row.key);
|
|
2934
4063
|
};
|
|
2935
|
-
return /* @__PURE__ */ (0,
|
|
4064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsh-pe-form", children: [
|
|
2936
4065
|
BASIC_ROWS.map(renderRow),
|
|
2937
|
-
/* @__PURE__ */ (0,
|
|
2938
|
-
/* @__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 }),
|
|
2939
4068
|
ADVANCED_ROWS.map(renderRow)
|
|
2940
4069
|
] }),
|
|
2941
|
-
/* @__PURE__ */ (0,
|
|
2942
|
-
statusText === "" ? null : /* @__PURE__ */ (0,
|
|
2943
|
-
/* @__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)(
|
|
2944
4073
|
"button",
|
|
2945
4074
|
{
|
|
2946
4075
|
type: "button",
|
|
@@ -2963,15 +4092,15 @@ function SettingsSection(props) {
|
|
|
2963
4092
|
const t = translator(props.translate);
|
|
2964
4093
|
const chinese = (locale?.active ?? "zh").toLowerCase().startsWith("zh");
|
|
2965
4094
|
if (state === void 0) {
|
|
2966
|
-
return /* @__PURE__ */ (0,
|
|
4095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2967
4096
|
}
|
|
2968
4097
|
const edit = props.edit ?? (() => {
|
|
2969
4098
|
});
|
|
2970
4099
|
const resetField = props.resetField ?? (() => {
|
|
2971
4100
|
});
|
|
2972
|
-
return /* @__PURE__ */ (0,
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
2974
|
-
/* @__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 })
|
|
2975
4104
|
] });
|
|
2976
4105
|
}
|
|
2977
4106
|
function SettingsPage(props) {
|
|
@@ -2980,13 +4109,13 @@ function SettingsPage(props) {
|
|
|
2980
4109
|
const state = read === void 0 ? void 0 : read((snapshot) => snapshot);
|
|
2981
4110
|
if (props.view === "summary") return t("settings.summary");
|
|
2982
4111
|
if (state === void 0) {
|
|
2983
|
-
return /* @__PURE__ */ (0,
|
|
4112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2984
4113
|
}
|
|
2985
4114
|
const edit = props.edit ?? (() => {
|
|
2986
4115
|
});
|
|
2987
4116
|
const resetField = props.resetField ?? (() => {
|
|
2988
4117
|
});
|
|
2989
|
-
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 });
|
|
2990
4119
|
}
|
|
2991
4120
|
var SettingsPageController = class {
|
|
2992
4121
|
/**
|
|
@@ -3115,6 +4244,7 @@ function installSettingsPages(ctx, getLocale) {
|
|
|
3115
4244
|
}
|
|
3116
4245
|
|
|
3117
4246
|
// src/client/index.tsx
|
|
4247
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3118
4248
|
var inject = [];
|
|
3119
4249
|
function report(step, error) {
|
|
3120
4250
|
try {
|
|
@@ -3148,7 +4278,8 @@ function apply(ctx) {
|
|
|
3148
4278
|
if (slots === void 0) return;
|
|
3149
4279
|
return slots.inject("conversation.input.right", () => {
|
|
3150
4280
|
try {
|
|
3151
|
-
|
|
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);
|
|
3152
4283
|
} catch (error) {
|
|
3153
4284
|
return report("composer enhance button slot", error);
|
|
3154
4285
|
}
|