@surfishs/dsh-prompt-enhance 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +153 -44
- package/README.md +151 -42
- package/docs/images/panel-en-915.png +0 -0
- package/docs/images/panel.png +0 -0
- package/lib/client.js +1963 -647
- package/lib/index.js +57 -13
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
- package/src/client/ActionIcons.tsx +49 -0
- package/src/client/EnhanceButton.tsx +314 -5
- package/src/client/QuickSettingsMenu.tsx +163 -0
- package/src/client/ResultDock.tsx +14 -0
- package/src/client/ResultPanel.tsx +157 -52
- package/src/client/UndoBar.tsx +2 -2
- package/src/client/enhance-client.ts +42 -0
- package/src/client/index.tsx +8 -1
- package/src/client/llm-catalog.ts +55 -8
- package/src/client/locales.ts +101 -41
- package/src/client/quick-settings.ts +260 -0
- package/src/client/settings-page-controls.tsx +180 -48
- package/src/client/settings-page-copy.ts +10 -0
- package/src/client/settings-page-spec.ts +29 -3
- package/src/client/settings-page-styles.ts +59 -7
- package/src/client/settings-page.tsx +68 -10
- package/src/client/settings-source.ts +23 -0
- package/src/client/settings-writer.ts +51 -0
- package/src/client/settings.ts +24 -0
- package/src/client/shortcut.ts +45 -0
- package/src/client/styles.ts +476 -43
- package/src/client/ui-state.ts +16 -0
- package/src/config.ts +8 -0
- package/src/context.ts +87 -7
- package/src/enhancer.ts +3 -0
- package/src/orchestrate.ts +24 -5
- package/src/shared/defaults.ts +4 -0
- package/src/shared/protocol.ts +26 -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) {
|
|
@@ -109,10 +109,28 @@ function parseUsage(value) {
|
|
|
109
109
|
...cacheWriteTokens === void 0 ? {} : { cacheWriteTokens }
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
function parseContextUsage(value) {
|
|
113
|
+
const record = value;
|
|
114
|
+
if (record === null || typeof record !== "object") return void 0;
|
|
115
|
+
const integer = (field) => typeof field === "number" && Number.isInteger(field) && field >= 0;
|
|
116
|
+
if (!integer(record.usedTurns) || !integer(record.maxTurns) || !integer(record.usedChars) || !integer(record.maxChars) || !integer(record.droppedTurns) || record.limitedBy !== null && record.limitedBy !== "turns" && record.limitedBy !== "chars" || typeof record.cutTurn !== "boolean") {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
usedTurns: record.usedTurns,
|
|
121
|
+
maxTurns: record.maxTurns,
|
|
122
|
+
usedChars: record.usedChars,
|
|
123
|
+
maxChars: record.maxChars,
|
|
124
|
+
droppedTurns: record.droppedTurns,
|
|
125
|
+
limitedBy: record.limitedBy,
|
|
126
|
+
cutTurn: record.cutTurn
|
|
127
|
+
};
|
|
128
|
+
}
|
|
112
129
|
function parseResult(value) {
|
|
113
130
|
const record = value;
|
|
114
131
|
if (record !== null && typeof record === "object" && typeof record.text === "string" && record.text !== "" && typeof record.provider === "string" && record.provider !== "" && typeof record.model === "string" && record.model !== "" && typeof record.elapsedMs === "number" && Number.isFinite(record.elapsedMs)) {
|
|
115
132
|
const usage = parseUsage(record.usage);
|
|
133
|
+
const context = parseContextUsage(record.context);
|
|
116
134
|
return {
|
|
117
135
|
text: record.text,
|
|
118
136
|
provider: record.provider,
|
|
@@ -124,7 +142,12 @@ function parseResult(value) {
|
|
|
124
142
|
// object without it left the host setting it, the wire carrying it, and
|
|
125
143
|
// the UI never seeing it. Only `true` is ever normalized in, matching the
|
|
126
144
|
// host, which sets the field solely on a capped finish.
|
|
127
|
-
...record.truncated === true ? { truncated: true } : {}
|
|
145
|
+
...record.truncated === true ? { truncated: true } : {},
|
|
146
|
+
// Same trap as runcated above: rebuilding the object field by field
|
|
147
|
+
// drops anything not listed here, so a new result field has to be added
|
|
148
|
+
// in this exact place or the UI silently never sees it.
|
|
149
|
+
...typeof record.reasoningEffort === "string" ? { reasoningEffort: record.reasoningEffort } : {},
|
|
150
|
+
...context === void 0 ? {} : { context }
|
|
128
151
|
};
|
|
129
152
|
}
|
|
130
153
|
throw new EnhanceClientError({ code: "internal", params: { reason: "malformed" } });
|
|
@@ -398,6 +421,11 @@ function setStale(sessionId, stale) {
|
|
|
398
421
|
panelState = { ...panelState, stale };
|
|
399
422
|
notify();
|
|
400
423
|
}
|
|
424
|
+
function setCollapsed(sessionId, collapsed) {
|
|
425
|
+
if (panelState?.sessionId !== sessionId || panelState.collapsed === true === collapsed) return;
|
|
426
|
+
panelState = { ...panelState, collapsed };
|
|
427
|
+
notify();
|
|
428
|
+
}
|
|
401
429
|
function closePanel() {
|
|
402
430
|
abortOf(panelState);
|
|
403
431
|
if (panelState === void 0) return;
|
|
@@ -460,7 +488,11 @@ var DEFAULT_VALUES = {
|
|
|
460
488
|
streaming: true,
|
|
461
489
|
contextAware: true,
|
|
462
490
|
contextMaxMessages: 8,
|
|
463
|
-
contextMaxChars: 4e3
|
|
491
|
+
contextMaxChars: 4e3,
|
|
492
|
+
/** Play the card's expand/collapse transition. */
|
|
493
|
+
foldAnimation: true,
|
|
494
|
+
/** Fold the card after Apply, and re-open it after Undo. */
|
|
495
|
+
autoFold: true
|
|
464
496
|
};
|
|
465
497
|
|
|
466
498
|
// src/client/settings.ts
|
|
@@ -468,7 +500,13 @@ var DEFAULT_CLIENT_SETTINGS = {
|
|
|
468
500
|
enabled: DEFAULT_VALUES.enabled,
|
|
469
501
|
maxInputChars: DEFAULT_VALUES.maxInputChars,
|
|
470
502
|
shortcut: DEFAULT_VALUES.shortcut,
|
|
471
|
-
streaming: DEFAULT_VALUES.streaming
|
|
503
|
+
streaming: DEFAULT_VALUES.streaming,
|
|
504
|
+
foldAnimation: DEFAULT_VALUES.foldAnimation,
|
|
505
|
+
autoFold: DEFAULT_VALUES.autoFold,
|
|
506
|
+
reasoningEffort: DEFAULT_VALUES.reasoningEffort,
|
|
507
|
+
contextAware: DEFAULT_VALUES.contextAware,
|
|
508
|
+
provider: "",
|
|
509
|
+
model: ""
|
|
472
510
|
};
|
|
473
511
|
var listeners2 = /* @__PURE__ */ new Set();
|
|
474
512
|
var current = DEFAULT_CLIENT_SETTINGS;
|
|
@@ -492,12 +530,449 @@ function decodeClientSettings(section) {
|
|
|
492
530
|
enabled: typeof record.enabled === "boolean" ? record.enabled : DEFAULT_CLIENT_SETTINGS.enabled,
|
|
493
531
|
maxInputChars: typeof record.maxInputChars === "number" && Number.isFinite(record.maxInputChars) && record.maxInputChars > 0 ? Math.floor(record.maxInputChars) : DEFAULT_CLIENT_SETTINGS.maxInputChars,
|
|
494
532
|
shortcut: typeof record.shortcut === "string" ? record.shortcut : DEFAULT_CLIENT_SETTINGS.shortcut,
|
|
495
|
-
streaming: typeof record.streaming === "boolean" ? record.streaming : DEFAULT_CLIENT_SETTINGS.streaming
|
|
533
|
+
streaming: typeof record.streaming === "boolean" ? record.streaming : DEFAULT_CLIENT_SETTINGS.streaming,
|
|
534
|
+
foldAnimation: typeof record.foldAnimation === "boolean" ? record.foldAnimation : DEFAULT_CLIENT_SETTINGS.foldAnimation,
|
|
535
|
+
autoFold: typeof record.autoFold === "boolean" ? record.autoFold : DEFAULT_CLIENT_SETTINGS.autoFold,
|
|
536
|
+
reasoningEffort: typeof record.reasoningEffort === "string" ? record.reasoningEffort : DEFAULT_CLIENT_SETTINGS.reasoningEffort,
|
|
537
|
+
contextAware: typeof record.contextAware === "boolean" ? record.contextAware : DEFAULT_CLIENT_SETTINGS.contextAware,
|
|
538
|
+
provider: typeof record.provider === "string" ? record.provider : DEFAULT_CLIENT_SETTINGS.provider,
|
|
539
|
+
model: typeof record.model === "string" ? record.model : DEFAULT_CLIENT_SETTINGS.model
|
|
496
540
|
};
|
|
497
541
|
}
|
|
498
542
|
|
|
499
|
-
// src/client/
|
|
543
|
+
// src/client/settings-writer.ts
|
|
544
|
+
var current2;
|
|
545
|
+
var listeners3 = /* @__PURE__ */ new Set();
|
|
546
|
+
function setSettingsWriter(next) {
|
|
547
|
+
if (current2 === next) return;
|
|
548
|
+
current2 = next;
|
|
549
|
+
for (const listener of listeners3) listener();
|
|
550
|
+
}
|
|
551
|
+
function getSettingsWriter() {
|
|
552
|
+
return current2;
|
|
553
|
+
}
|
|
554
|
+
function subscribeSettingsWriter(listener) {
|
|
555
|
+
listeners3.add(listener);
|
|
556
|
+
return () => {
|
|
557
|
+
listeners3.delete(listener);
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/client/QuickSettingsMenu.tsx
|
|
562
|
+
var import_react2 = require("react");
|
|
563
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
564
|
+
|
|
565
|
+
// src/shared/reasoning.ts
|
|
566
|
+
var REASONING_EFFORTS_ENDPOINT = "/dsh-prompt-enhance/reasoning-efforts";
|
|
567
|
+
var DEEPSEEK_PROVIDER = "deepseek-official";
|
|
568
|
+
function isDeepSeekProvider(provider) {
|
|
569
|
+
return provider === DEEPSEEK_PROVIDER || provider.startsWith("deepseek");
|
|
570
|
+
}
|
|
571
|
+
var DEEPSEEK_EFFORTS = [
|
|
572
|
+
{ id: "off", name: "Off", description: "Use for simple tasks that do not need reasoning." },
|
|
573
|
+
{ id: "low", name: "Low", description: "Prefer for routine or latency-sensitive tasks." },
|
|
574
|
+
{ id: "high", name: "High", description: "The default balance for most tasks." },
|
|
575
|
+
{ id: "max", name: "Max", description: "Reserve for the hardest quality-first tasks." }
|
|
576
|
+
];
|
|
577
|
+
|
|
578
|
+
// src/client/llm-catalog.ts
|
|
500
579
|
var import_react = require("react");
|
|
580
|
+
|
|
581
|
+
// src/shared/catalog.ts
|
|
582
|
+
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
583
|
+
var LLM_MODELS_ENDPOINT = "/dsh-prompt-enhance/llm-models";
|
|
584
|
+
var LLM_ROUTE_CHECK_ENDPOINT = "/dsh-prompt-enhance/llm-route-check";
|
|
585
|
+
|
|
586
|
+
// src/client/llm-catalog.ts
|
|
587
|
+
async function getJson(url, signal) {
|
|
588
|
+
try {
|
|
589
|
+
const response = await fetch(url, { signal, headers: { accept: "application/json" } });
|
|
590
|
+
if (!response.ok) return void 0;
|
|
591
|
+
const body = await response.json();
|
|
592
|
+
const envelope = body;
|
|
593
|
+
if (envelope === null || envelope === void 0 || envelope.ok !== true) return void 0;
|
|
594
|
+
return envelope.value;
|
|
595
|
+
} catch {
|
|
596
|
+
return void 0;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
var CATALOG_TTL_MS = 6e4;
|
|
600
|
+
var providersMemo;
|
|
601
|
+
var modelsMemo = /* @__PURE__ */ new Map();
|
|
602
|
+
function endpoint(path, params = {}) {
|
|
603
|
+
const url = new URL(path, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
604
|
+
for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
|
|
605
|
+
return url;
|
|
606
|
+
}
|
|
607
|
+
async function fetchProviders(signal, options = {}) {
|
|
608
|
+
const cached = providersMemo;
|
|
609
|
+
if (options.refresh !== true && cached !== void 0 && Date.now() - cached.at <= CATALOG_TTL_MS) return cached.value;
|
|
610
|
+
const value = await getJson(endpoint(LLM_PROVIDERS_ENDPOINT), signal);
|
|
611
|
+
if (value === void 0 || !Array.isArray(value.providers)) return void 0;
|
|
612
|
+
const providers = value.providers.filter(
|
|
613
|
+
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== "" && typeof entry.registered === "boolean"
|
|
614
|
+
);
|
|
615
|
+
providersMemo = { value: providers, at: Date.now() };
|
|
616
|
+
return providers;
|
|
617
|
+
}
|
|
618
|
+
async function fetchModels(provider, signal, options = {}) {
|
|
619
|
+
const cached = modelsMemo.get(provider);
|
|
620
|
+
if (options.refresh !== true && cached !== void 0 && Date.now() - cached.at <= CATALOG_TTL_MS) return cached.value;
|
|
621
|
+
const value = await getJson(endpoint(LLM_MODELS_ENDPOINT, { provider }), signal);
|
|
622
|
+
if (value === void 0 || !Array.isArray(value.models)) return void 0;
|
|
623
|
+
const models = value.models.filter(
|
|
624
|
+
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== ""
|
|
625
|
+
).map((entry) => ({
|
|
626
|
+
id: entry.id,
|
|
627
|
+
name: entry.name,
|
|
628
|
+
...typeof entry.description === "string" && entry.description !== "" ? { description: entry.description } : {}
|
|
629
|
+
}));
|
|
630
|
+
const answer = { models, ...typeof value.reason === "string" ? { reason: value.reason } : {} };
|
|
631
|
+
if (models.length > 0) modelsMemo.set(provider, { value: answer, at: Date.now() });
|
|
632
|
+
return answer;
|
|
633
|
+
}
|
|
634
|
+
async function fetchRouteCheck(provider, model, signal) {
|
|
635
|
+
const value = await getJson(endpoint(LLM_ROUTE_CHECK_ENDPOINT, { provider, model }), signal);
|
|
636
|
+
if (value === void 0 || typeof value.available !== "boolean") return void 0;
|
|
637
|
+
return value;
|
|
638
|
+
}
|
|
639
|
+
function useLlmRouting(provider, model) {
|
|
640
|
+
const [providers, setProviders] = (0, import_react.useState)([]);
|
|
641
|
+
const [providersLoading, setProvidersLoading] = (0, import_react.useState)(true);
|
|
642
|
+
const [providersFailed, setProvidersFailed] = (0, import_react.useState)(false);
|
|
643
|
+
const [providersToken, setProvidersToken] = (0, import_react.useState)(0);
|
|
644
|
+
const [models, setModels] = (0, import_react.useState)([]);
|
|
645
|
+
const [modelsLoading, setModelsLoading] = (0, import_react.useState)(false);
|
|
646
|
+
const [modelsFailed, setModelsFailed] = (0, import_react.useState)(false);
|
|
647
|
+
const [modelsToken, setModelsToken] = (0, import_react.useState)(0);
|
|
648
|
+
const [routeChecking, setRouteChecking] = (0, import_react.useState)(false);
|
|
649
|
+
const [routeAvailable, setRouteAvailable] = (0, import_react.useState)(void 0);
|
|
650
|
+
(0, import_react.useEffect)(() => {
|
|
651
|
+
const controller = new AbortController();
|
|
652
|
+
setProvidersLoading(true);
|
|
653
|
+
setProvidersFailed(false);
|
|
654
|
+
void fetchProviders(controller.signal, { refresh: providersToken > 0 }).then((entries) => {
|
|
655
|
+
if (controller.signal.aborted) return;
|
|
656
|
+
setProvidersLoading(false);
|
|
657
|
+
if (entries === void 0) {
|
|
658
|
+
setProvidersFailed(true);
|
|
659
|
+
setProviders([]);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
setProviders(entries);
|
|
663
|
+
});
|
|
664
|
+
return () => controller.abort();
|
|
665
|
+
}, [providersToken]);
|
|
666
|
+
(0, import_react.useEffect)(() => {
|
|
667
|
+
if (provider === "") {
|
|
668
|
+
setModels([]);
|
|
669
|
+
setModelsLoading(false);
|
|
670
|
+
setModelsFailed(false);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const controller = new AbortController();
|
|
674
|
+
setModels([]);
|
|
675
|
+
setModelsLoading(true);
|
|
676
|
+
setModelsFailed(false);
|
|
677
|
+
void fetchModels(provider, controller.signal, { refresh: modelsToken > 0 }).then((answer) => {
|
|
678
|
+
if (controller.signal.aborted) return;
|
|
679
|
+
setModelsLoading(false);
|
|
680
|
+
if (answer === void 0) {
|
|
681
|
+
setModelsFailed(true);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
setModels(answer.models);
|
|
685
|
+
setModelsFailed(answer.models.length === 0);
|
|
686
|
+
});
|
|
687
|
+
return () => controller.abort();
|
|
688
|
+
}, [provider, modelsToken]);
|
|
689
|
+
(0, import_react.useEffect)(() => {
|
|
690
|
+
if (provider === "" || model === "") {
|
|
691
|
+
setRouteChecking(false);
|
|
692
|
+
setRouteAvailable(void 0);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const controller = new AbortController();
|
|
696
|
+
setRouteChecking(true);
|
|
697
|
+
setRouteAvailable(void 0);
|
|
698
|
+
const timer = setTimeout(() => {
|
|
699
|
+
void fetchRouteCheck(provider, model, controller.signal).then((answer) => {
|
|
700
|
+
if (controller.signal.aborted) return;
|
|
701
|
+
setRouteChecking(false);
|
|
702
|
+
setRouteAvailable(answer === void 0 ? false : answer.available);
|
|
703
|
+
});
|
|
704
|
+
}, 400);
|
|
705
|
+
return () => {
|
|
706
|
+
clearTimeout(timer);
|
|
707
|
+
controller.abort();
|
|
708
|
+
};
|
|
709
|
+
}, [provider, model]);
|
|
710
|
+
return {
|
|
711
|
+
providers: {
|
|
712
|
+
loading: providersLoading,
|
|
713
|
+
failed: providersFailed,
|
|
714
|
+
entries: providers,
|
|
715
|
+
reload: () => setProvidersToken((token) => token + 1)
|
|
716
|
+
},
|
|
717
|
+
models: {
|
|
718
|
+
loading: modelsLoading,
|
|
719
|
+
failed: modelsFailed,
|
|
720
|
+
entries: models,
|
|
721
|
+
reload: () => setModelsToken((token) => token + 1)
|
|
722
|
+
},
|
|
723
|
+
route: { checking: routeChecking, available: routeAvailable }
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/client/reasoning-options.ts
|
|
728
|
+
function effortOf(value) {
|
|
729
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
730
|
+
const record = value;
|
|
731
|
+
if (typeof record.id !== "string" || record.id === "" || typeof record.name !== "string" || record.name === "") return void 0;
|
|
732
|
+
return {
|
|
733
|
+
id: record.id,
|
|
734
|
+
name: record.name,
|
|
735
|
+
...typeof record.description === "string" && record.description !== "" ? { description: record.description } : {}
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function capabilitiesOf(value) {
|
|
739
|
+
if (value === null || typeof value !== "object") return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
740
|
+
const record = value;
|
|
741
|
+
const source = record.source === "resolved" || record.source === "default" || record.source === "unavailable" ? record.source : "unavailable";
|
|
742
|
+
const efforts = Array.isArray(record.efforts) ? record.efforts.map(effortOf).filter((effort) => effort !== void 0) : [];
|
|
743
|
+
const reason = typeof record.reason === "string" ? record.reason : void 0;
|
|
744
|
+
if (source !== "unavailable" && efforts.length === 0) return { efforts: [], source: "unavailable", reason: "no-efforts" };
|
|
745
|
+
return {
|
|
746
|
+
efforts,
|
|
747
|
+
source,
|
|
748
|
+
...typeof record.defaultEffort === "string" && record.defaultEffort !== "" ? { defaultEffort: record.defaultEffort } : {},
|
|
749
|
+
...reason === void 0 ? {} : { reason }
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
753
|
+
const url = new URL(REASONING_EFFORTS_ENDPOINT, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
754
|
+
if (provider !== void 0 && model !== void 0) {
|
|
755
|
+
url.searchParams.set("provider", provider);
|
|
756
|
+
url.searchParams.set("model", model);
|
|
757
|
+
}
|
|
758
|
+
if (options.refresh === true) url.searchParams.set("refresh", "1");
|
|
759
|
+
try {
|
|
760
|
+
const response = await fetch(url, { signal: options.signal, headers: { accept: "application/json" } });
|
|
761
|
+
if (!response.ok) return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
762
|
+
const body = await response.json();
|
|
763
|
+
const envelope = body;
|
|
764
|
+
if (envelope === null || envelope === void 0 || envelope.ok !== true) {
|
|
765
|
+
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
766
|
+
}
|
|
767
|
+
return capabilitiesOf(envelope.value);
|
|
768
|
+
} catch {
|
|
769
|
+
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// src/client/quick-settings.ts
|
|
774
|
+
var INHERIT_EFFORT = "inherit";
|
|
775
|
+
function effortsOf(value) {
|
|
776
|
+
if (!Array.isArray(value)) return [];
|
|
777
|
+
const out = [];
|
|
778
|
+
for (const item of value) {
|
|
779
|
+
if (item === null || typeof item !== "object") continue;
|
|
780
|
+
const record = item;
|
|
781
|
+
if (typeof record.id !== "string" || record.id === "") continue;
|
|
782
|
+
out.push({ id: record.id, name: typeof record.name === "string" && record.name !== "" ? record.name : record.id });
|
|
783
|
+
}
|
|
784
|
+
return out;
|
|
785
|
+
}
|
|
786
|
+
function staticEfforts() {
|
|
787
|
+
return DEEPSEEK_EFFORTS.map((effort) => ({ id: effort.id, name: effort.name }));
|
|
788
|
+
}
|
|
789
|
+
function menuOptionsOf(data) {
|
|
790
|
+
const options = [...data.efforts];
|
|
791
|
+
if (data.effort !== "" && data.effort !== INHERIT_EFFORT && !options.some((option) => option.id === data.effort)) {
|
|
792
|
+
const known = DEEPSEEK_EFFORTS.find((effort) => effort.id === data.effort);
|
|
793
|
+
options.push({ id: data.effort, name: known?.name ?? data.effort });
|
|
794
|
+
}
|
|
795
|
+
return options;
|
|
796
|
+
}
|
|
797
|
+
function modelDirectoryOf(ctx, sessionId) {
|
|
798
|
+
try {
|
|
799
|
+
return ctx?.modelDirectories?.directoryFor?.(sessionId);
|
|
800
|
+
} catch {
|
|
801
|
+
return void 0;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function directoryFaceOf(directory) {
|
|
805
|
+
if (directory === null || typeof directory !== "object") return void 0;
|
|
806
|
+
return directory;
|
|
807
|
+
}
|
|
808
|
+
function readDirectory(directory) {
|
|
809
|
+
const store = directory?.store;
|
|
810
|
+
let snapshot;
|
|
811
|
+
try {
|
|
812
|
+
snapshot = store?.getSnapshot?.();
|
|
813
|
+
} catch {
|
|
814
|
+
return void 0;
|
|
815
|
+
}
|
|
816
|
+
if (snapshot === null || typeof snapshot !== "object") return void 0;
|
|
817
|
+
const state = snapshot;
|
|
818
|
+
const provider = typeof state.current?.provider === "string" ? state.current.provider : void 0;
|
|
819
|
+
const model = typeof state.current?.model === "string" ? state.current.model : void 0;
|
|
820
|
+
let efforts = [];
|
|
821
|
+
if (Array.isArray(state.groups) && provider !== void 0 && model !== void 0) {
|
|
822
|
+
for (const group of state.groups) {
|
|
823
|
+
if (group === null || typeof group !== "object") continue;
|
|
824
|
+
const entry = group;
|
|
825
|
+
if (entry.id !== provider || !Array.isArray(entry.models)) continue;
|
|
826
|
+
for (const candidate of entry.models) {
|
|
827
|
+
if (candidate === null || typeof candidate !== "object") continue;
|
|
828
|
+
const record = candidate;
|
|
829
|
+
if (record.id !== model) continue;
|
|
830
|
+
efforts = effortsOf(record.reasoning?.efforts);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return { efforts, provider, model };
|
|
835
|
+
}
|
|
836
|
+
async function kickLoad(directory) {
|
|
837
|
+
const load = directory?.load;
|
|
838
|
+
if (typeof load !== "function") return;
|
|
839
|
+
try {
|
|
840
|
+
await Promise.resolve(load.call(directory));
|
|
841
|
+
} catch {
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
var FOLLOW_LABELS = { providerLabel: "", modelLabel: "" };
|
|
845
|
+
async function routeLabelsOf(provider, model) {
|
|
846
|
+
if (provider === "") return FOLLOW_LABELS;
|
|
847
|
+
const [providers, models] = await Promise.all([fetchProviders(), model === "" ? Promise.resolve(void 0) : fetchModels(provider)]);
|
|
848
|
+
return {
|
|
849
|
+
providerLabel: providers?.find((entry) => entry.id === provider)?.name ?? provider,
|
|
850
|
+
modelLabel: model === "" ? "" : models?.models.find((entry) => entry.id === model)?.name ?? model
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
async function resolveQuickSettings(input) {
|
|
854
|
+
const stored = typeof input.settings.reasoningEffort === "string" ? input.settings.reasoningEffort.trim() : "";
|
|
855
|
+
const effort = stored === "" ? "off" : stored;
|
|
856
|
+
const contextAware = input.settings.contextAware === true;
|
|
857
|
+
const provider = input.settings.provider?.trim() ?? "";
|
|
858
|
+
const model = input.settings.model?.trim() ?? "";
|
|
859
|
+
const labelsPromise = routeLabelsOf(provider, model);
|
|
860
|
+
if (provider !== "" && model !== "") {
|
|
861
|
+
const capabilities = await fetchReasoningCapabilities(provider, model);
|
|
862
|
+
const efforts = effortsOf(capabilities.efforts);
|
|
863
|
+
if (efforts.length > 0) return { efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "override" };
|
|
864
|
+
return { efforts: [], effort, contextAware, provider, model, ...await labelsPromise, source: "override", effortReason: capabilities.reason ?? "resolve-failed" };
|
|
865
|
+
}
|
|
866
|
+
const directory = modelDirectoryOf(input.ctx, input.sessionId);
|
|
867
|
+
if (directory !== void 0) {
|
|
868
|
+
const first = readDirectory(directory);
|
|
869
|
+
if (first !== void 0 && first.efforts.length > 0) return { efforts: first.efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "session" };
|
|
870
|
+
await kickLoad(directory);
|
|
871
|
+
const second = readDirectory(directory);
|
|
872
|
+
if (second !== void 0 && second.efforts.length > 0) return { efforts: second.efforts, effort, contextAware, provider, model, ...await labelsPromise, source: "session" };
|
|
873
|
+
if (second?.provider !== void 0 && !isDeepSeekProvider(second.provider)) {
|
|
874
|
+
return { efforts: [], effort, contextAware, provider, model, ...await labelsPromise, source: "session", effortReason: "no-efforts" };
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return { efforts: staticEfforts(), effort, contextAware, provider, model, ...await labelsPromise, source: "static" };
|
|
878
|
+
}
|
|
879
|
+
async function writeQuickEffort(writer, id) {
|
|
880
|
+
try {
|
|
881
|
+
return await writer.set("reasoningEffort", id);
|
|
882
|
+
} catch {
|
|
883
|
+
return false;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
async function writeQuickContext(writer, next) {
|
|
887
|
+
try {
|
|
888
|
+
return await writer.set("contextAware", next);
|
|
889
|
+
} catch {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// src/client/QuickSettingsMenu.tsx
|
|
895
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
896
|
+
function MenuRow(props) {
|
|
897
|
+
const { label, checked, role, onSelect } = props;
|
|
898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role, "aria-checked": checked, className: "dsh-pe-menu-item", onClick: onSelect, children: [
|
|
899
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: label }),
|
|
900
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-mark", "aria-hidden": true, children: checked ? "\u2713" : "" })
|
|
901
|
+
] });
|
|
902
|
+
}
|
|
903
|
+
function QuickSettingsMenu(props) {
|
|
904
|
+
const { t, data, anchor, error, onPick, onToggleContext, onClose } = props;
|
|
905
|
+
const ref = (0, import_react2.useRef)(null);
|
|
906
|
+
const [pane, setPane] = (0, import_react2.useState)("root");
|
|
907
|
+
const paneRef = (0, import_react2.useRef)(null);
|
|
908
|
+
(0, import_react2.useEffect)(() => {
|
|
909
|
+
const onKeyDown = (event) => {
|
|
910
|
+
if (event.key !== "Escape") return;
|
|
911
|
+
event.preventDefault();
|
|
912
|
+
setPane((current3) => {
|
|
913
|
+
if (current3 === "effort") return "root";
|
|
914
|
+
onClose();
|
|
915
|
+
return current3;
|
|
916
|
+
});
|
|
917
|
+
};
|
|
918
|
+
const onPointerDown = (event) => {
|
|
919
|
+
const node = ref.current;
|
|
920
|
+
if (node === null) return;
|
|
921
|
+
const target = event.target;
|
|
922
|
+
if (target instanceof Node && node.contains(target)) return;
|
|
923
|
+
onClose();
|
|
924
|
+
};
|
|
925
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
926
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
927
|
+
return () => {
|
|
928
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
929
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
930
|
+
};
|
|
931
|
+
}, [onClose]);
|
|
932
|
+
(0, import_react2.useEffect)(() => {
|
|
933
|
+
if (pane !== "effort") return;
|
|
934
|
+
const checked = paneRef.current?.querySelector('[aria-checked="true"]');
|
|
935
|
+
checked?.focus();
|
|
936
|
+
}, [pane]);
|
|
937
|
+
const viewportWidth = typeof window === "undefined" ? 0 : window.innerWidth;
|
|
938
|
+
const viewportHeight = typeof window === "undefined" ? 0 : window.innerHeight;
|
|
939
|
+
const right = Math.max(8, viewportWidth - anchor.right);
|
|
940
|
+
const bottom = Math.max(8, viewportHeight - anchor.top + 8);
|
|
941
|
+
const options = menuOptionsOf(data);
|
|
942
|
+
const currentEffort = options.find((option) => option.id === data.effort);
|
|
943
|
+
const radioOptions = data.efforts.length === 0 ? [] : options;
|
|
944
|
+
const effortValue = data.effort === INHERIT_EFFORT ? t("menu.effortDefault") : currentEffort?.name ?? data.effort;
|
|
945
|
+
const providerPart = data.providerLabel === "" ? data.provider : data.providerLabel;
|
|
946
|
+
const modelPart = data.modelLabel === "" ? data.model : data.modelLabel;
|
|
947
|
+
const pinnedRoute = [providerPart, modelPart].filter((part) => part !== "").join(" / ");
|
|
948
|
+
const modelValue = pinnedRoute === "" ? t("menu.modelFollow") : pinnedRoute;
|
|
949
|
+
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: [
|
|
950
|
+
pane === "root" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-pe-menu-info", title: t("menu.modelHint"), children: [
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: t("menu.model") }),
|
|
953
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-state", children: modelValue })
|
|
954
|
+
] }),
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role: "menuitem", className: "dsh-pe-menu-item dsh-pe-menu-cell", onClick: () => setPane("effort"), children: [
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-label", children: t("menu.effort") }),
|
|
957
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-state", children: effortValue }),
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-chevron", "aria-hidden": true })
|
|
959
|
+
] }),
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-pe-menu-sep", role: "separator" }),
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-pe-menu-switch", children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-pe-menu-switch-label", children: t("menu.context") }),
|
|
963
|
+
/* @__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) })
|
|
964
|
+
] })
|
|
965
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: paneRef, className: "dsh-pe-menu-group", role: "group", "aria-label": t("menu.effort"), children: [
|
|
966
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MenuRow, { role: "menuitemradio", label: t("menu.effortDefault"), checked: data.effort === INHERIT_EFFORT, onSelect: () => onPick(INHERIT_EFFORT) }),
|
|
967
|
+
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)),
|
|
968
|
+
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") })
|
|
969
|
+
] }),
|
|
970
|
+
error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-pe-menu-error", role: "alert", children: error })
|
|
971
|
+
] });
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// src/client/session-key.ts
|
|
975
|
+
var import_react3 = require("react");
|
|
501
976
|
var fallbackSeq = 0;
|
|
502
977
|
var zoneKeys = /* @__PURE__ */ new WeakMap();
|
|
503
978
|
function fallbackKeyOf(share) {
|
|
@@ -509,7 +984,7 @@ function fallbackKeyOf(share) {
|
|
|
509
984
|
return minted;
|
|
510
985
|
}
|
|
511
986
|
function useSessionKey(maybeSessionId, share) {
|
|
512
|
-
const fallback = (0,
|
|
987
|
+
const fallback = (0, import_react3.useRef)(void 0);
|
|
513
988
|
if (maybeSessionId !== void 0 && maybeSessionId !== "") return maybeSessionId;
|
|
514
989
|
if (fallback.current === void 0) fallback.current = fallbackKeyOf(share);
|
|
515
990
|
return fallback.current;
|
|
@@ -519,7 +994,9 @@ function serverSessionId(maybeSessionId) {
|
|
|
519
994
|
}
|
|
520
995
|
|
|
521
996
|
// src/client/EnhanceButton.tsx
|
|
522
|
-
var
|
|
997
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
998
|
+
var LONG_PRESS_MS = 600;
|
|
999
|
+
var LONG_PRESS_SLOP_PX = 6;
|
|
523
1000
|
var OCCURRENCES_UNKNOWN = -1;
|
|
524
1001
|
function occurrenceCountOf(value) {
|
|
525
1002
|
return Array.isArray(value) ? value.length : OCCURRENCES_UNKNOWN;
|
|
@@ -534,17 +1011,170 @@ function EnhanceButton(props) {
|
|
|
534
1011
|
const draft = useInput((state) => stringOf(state.draft));
|
|
535
1012
|
const phase = useInput((state) => state.phase);
|
|
536
1013
|
const occurrenceCount = useInput((state) => occurrenceCountOf(state.occurrences));
|
|
537
|
-
const settings = (0,
|
|
538
|
-
const panel = (0,
|
|
539
|
-
const rootRef = (0,
|
|
1014
|
+
const settings = (0, import_react4.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
1015
|
+
const panel = (0, import_react4.useSyncExternalStore)(subscribe, getPanel);
|
|
1016
|
+
const rootRef = (0, import_react4.useRef)(null);
|
|
540
1017
|
const busy = panel !== void 0 && panel.sessionId === uiKey && panel.phase === "loading";
|
|
541
1018
|
const anyBusy = panel !== void 0 && panel.phase === "loading";
|
|
542
1019
|
const otherBusy = anyBusy && !busy;
|
|
543
1020
|
const empty = draft.trim() === "";
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
1021
|
+
const writer = (0, import_react4.useSyncExternalStore)(subscribeSettingsWriter, getSettingsWriter);
|
|
1022
|
+
const [menu, setMenu] = (0, import_react4.useState)(null);
|
|
1023
|
+
const [menuError, setMenuError] = (0, import_react4.useState)(void 0);
|
|
1024
|
+
const longPressTimer = (0, import_react4.useRef)(void 0);
|
|
1025
|
+
const longPressOrigin = (0, import_react4.useRef)(null);
|
|
1026
|
+
const longPressFired = (0, import_react4.useRef)(false);
|
|
1027
|
+
const contextWrites = (0, import_react4.useRef)({ desired: null, accepted: null, inFlight: null, running: false, seq: 0, closing: false });
|
|
1028
|
+
const flushContextRef = (0, import_react4.useRef)(() => {
|
|
1029
|
+
});
|
|
1030
|
+
const applyContext = (value) => {
|
|
1031
|
+
setMenu((current3) => current3 === null ? current3 : { ...current3, data: { ...current3.data, contextAware: value } });
|
|
1032
|
+
};
|
|
1033
|
+
const kickContextWrite = (force = false) => {
|
|
1034
|
+
const state = contextWrites.current;
|
|
1035
|
+
if (writer === void 0 || state.running) return;
|
|
1036
|
+
const target = state.desired;
|
|
1037
|
+
if (target === null) return;
|
|
1038
|
+
const accepted = state.accepted ?? settings.contextAware;
|
|
1039
|
+
state.accepted = accepted;
|
|
1040
|
+
if (!force && target === accepted) {
|
|
1041
|
+
state.desired = null;
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
state.running = true;
|
|
1045
|
+
state.inFlight = target;
|
|
1046
|
+
const ticket = ++state.seq;
|
|
1047
|
+
void writeQuickContext(writer, target).then((ok) => {
|
|
1048
|
+
state.running = false;
|
|
1049
|
+
state.inFlight = null;
|
|
1050
|
+
if (ticket !== state.seq) {
|
|
1051
|
+
if (ok && state.accepted !== null) {
|
|
1052
|
+
state.desired = state.accepted;
|
|
1053
|
+
kickContextWrite(true);
|
|
1054
|
+
}
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
if (!ok) {
|
|
1058
|
+
state.desired = null;
|
|
1059
|
+
applyContext(state.accepted ?? settings.contextAware);
|
|
1060
|
+
setMenuError(t("menu.writeFailed"));
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
state.accepted = target;
|
|
1064
|
+
if (state.desired === target) state.desired = null;
|
|
1065
|
+
kickContextWrite();
|
|
1066
|
+
});
|
|
1067
|
+
};
|
|
1068
|
+
const flushContextWrite = () => {
|
|
1069
|
+
const state = contextWrites.current;
|
|
1070
|
+
if (writer === void 0 || state.closing) return;
|
|
1071
|
+
const target = state.desired;
|
|
1072
|
+
if (target === null || target === state.inFlight) return;
|
|
1073
|
+
const accepted = state.accepted ?? settings.contextAware;
|
|
1074
|
+
const supersededValue = state.inFlight !== null;
|
|
1075
|
+
state.accepted = accepted;
|
|
1076
|
+
state.desired = null;
|
|
1077
|
+
if (!supersededValue && target === accepted) return;
|
|
1078
|
+
state.closing = true;
|
|
1079
|
+
const ticket = ++state.seq;
|
|
1080
|
+
void writeQuickContext(writer, target).then((ok) => {
|
|
1081
|
+
state.closing = false;
|
|
1082
|
+
if (!ok) {
|
|
1083
|
+
console.warn("[dsh-prompt-enhance] the contextAware write was refused while closing the quick settings card");
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (ticket === state.seq) state.accepted = target;
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
flushContextRef.current = flushContextWrite;
|
|
1090
|
+
const dismissMenu = (0, import_react4.useCallback)(() => {
|
|
1091
|
+
flushContextRef.current();
|
|
1092
|
+
setMenu(null);
|
|
1093
|
+
}, []);
|
|
1094
|
+
const toggleContext = (next) => {
|
|
1095
|
+
if (writer === void 0) return;
|
|
1096
|
+
const state = contextWrites.current;
|
|
1097
|
+
setMenuError(void 0);
|
|
1098
|
+
applyContext(next);
|
|
1099
|
+
state.desired = next;
|
|
1100
|
+
if (state.accepted === null) state.accepted = settings.contextAware;
|
|
1101
|
+
kickContextWrite();
|
|
1102
|
+
};
|
|
1103
|
+
const reconcileEffort = (0, import_react4.useCallback)(
|
|
1104
|
+
async (data) => {
|
|
1105
|
+
if (writer === void 0) return data;
|
|
1106
|
+
if (data.effort === "" || data.effort === INHERIT_EFFORT) return data;
|
|
1107
|
+
if (data.efforts.some((effort) => effort.id === data.effort)) return data;
|
|
1108
|
+
const cleared = await writeQuickEffort(writer, INHERIT_EFFORT);
|
|
1109
|
+
if (!cleared) {
|
|
1110
|
+
console.warn("[dsh-prompt-enhance] could not clear the stored reasoning effort for the current model");
|
|
1111
|
+
return data;
|
|
1112
|
+
}
|
|
1113
|
+
return { ...data, effort: INHERIT_EFFORT };
|
|
1114
|
+
},
|
|
1115
|
+
[writer]
|
|
1116
|
+
);
|
|
1117
|
+
(0, import_react4.useEffect)(() => {
|
|
1118
|
+
const state = contextWrites.current;
|
|
1119
|
+
if (state.seq === 0 && state.desired === null) state.accepted = settings.contextAware;
|
|
1120
|
+
}, [settings.contextAware]);
|
|
1121
|
+
(0, import_react4.useEffect)(() => () => flushContextRef.current(), []);
|
|
1122
|
+
const menuOpen = menu !== null;
|
|
1123
|
+
(0, import_react4.useEffect)(() => {
|
|
1124
|
+
if (!menuOpen) return;
|
|
1125
|
+
const directory = directoryFaceOf(modelDirectoryOf(props.__ctx, sessionId));
|
|
1126
|
+
const store = directory?.store;
|
|
1127
|
+
let cancelled = false;
|
|
1128
|
+
let timer;
|
|
1129
|
+
const refresh = () => {
|
|
1130
|
+
if (cancelled) return;
|
|
1131
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1132
|
+
timer = setTimeout(() => {
|
|
1133
|
+
timer = void 0;
|
|
1134
|
+
void resolveQuickSettings({ ctx: props.__ctx, sessionId, settings }).then(async (resolved) => {
|
|
1135
|
+
const data = await reconcileEffort(resolved);
|
|
1136
|
+
if (cancelled) return;
|
|
1137
|
+
const local = contextWrites.current.desired ?? contextWrites.current.accepted;
|
|
1138
|
+
setMenu((current3) => current3 === null ? current3 : { ...current3, data: local === null ? data : { ...data, contextAware: local } });
|
|
1139
|
+
});
|
|
1140
|
+
}, 80);
|
|
1141
|
+
};
|
|
1142
|
+
const stop = store?.subscribe?.(refresh);
|
|
1143
|
+
try {
|
|
1144
|
+
void Promise.resolve(directory?.load?.()).catch(() => {
|
|
1145
|
+
});
|
|
1146
|
+
} catch {
|
|
1147
|
+
}
|
|
1148
|
+
return () => {
|
|
1149
|
+
cancelled = true;
|
|
1150
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1151
|
+
stop?.();
|
|
1152
|
+
};
|
|
1153
|
+
}, [menuOpen, props.__ctx, sessionId, settings, reconcileEffort]);
|
|
1154
|
+
const openMenu = (0, import_react4.useCallback)(
|
|
1155
|
+
async (rect) => {
|
|
1156
|
+
const anchor = { right: rect.right, top: rect.top };
|
|
1157
|
+
setMenuError(void 0);
|
|
1158
|
+
const resolved = await resolveQuickSettings({ ctx: props.__ctx, sessionId, settings });
|
|
1159
|
+
const data = await reconcileEffort(resolved);
|
|
1160
|
+
const local = contextWrites.current.desired ?? contextWrites.current.accepted;
|
|
1161
|
+
setMenu({ anchor, data: local === null ? data : { ...data, contextAware: local } });
|
|
1162
|
+
},
|
|
1163
|
+
[props.__ctx, sessionId, settings, reconcileEffort]
|
|
1164
|
+
);
|
|
1165
|
+
const pickEffort = (id) => {
|
|
1166
|
+
if (writer === void 0) return;
|
|
1167
|
+
const unchanged = menu !== null && menu.data.effort === id;
|
|
1168
|
+
dismissMenu();
|
|
1169
|
+
if (unchanged) return;
|
|
1170
|
+
void writeQuickEffort(writer, id).then((ok) => {
|
|
1171
|
+
if (!ok) console.warn("[dsh-prompt-enhance] the reasoningEffort write was refused");
|
|
1172
|
+
});
|
|
1173
|
+
};
|
|
1174
|
+
const start = (0, import_react4.useCallback)(
|
|
1175
|
+
(overrideText) => {
|
|
1176
|
+
const source = overrideText ?? draft;
|
|
1177
|
+
if (anyBusy || source.trim() === "") return;
|
|
548
1178
|
if (!settings.enabled) {
|
|
549
1179
|
const disabled = t("error.disabled");
|
|
550
1180
|
openError(uiKey, draft, { code: "rejected", localized: disabled });
|
|
@@ -592,49 +1222,122 @@ function EnhanceButton(props) {
|
|
|
592
1222
|
},
|
|
593
1223
|
[anyBusy, draft, occurrenceCount, phase, settings, uiKey, wireId, t]
|
|
594
1224
|
);
|
|
595
|
-
const runRef = (0,
|
|
596
|
-
(0,
|
|
1225
|
+
const runRef = (0, import_react4.useRef)(start);
|
|
1226
|
+
(0, import_react4.useEffect)(() => {
|
|
597
1227
|
runRef.current = start;
|
|
598
1228
|
});
|
|
599
|
-
(0,
|
|
1229
|
+
(0, import_react4.useEffect)(() => {
|
|
600
1230
|
const entry = {
|
|
601
1231
|
root: rootRef.current,
|
|
602
1232
|
run: (text) => runRef.current(text)
|
|
603
1233
|
};
|
|
604
1234
|
return registerSession(uiKey, entry);
|
|
605
1235
|
}, [uiKey]);
|
|
606
|
-
(0,
|
|
1236
|
+
(0, import_react4.useEffect)(() => {
|
|
607
1237
|
if (panel !== void 0 && panel.sessionId === uiKey && panel.phase === "result") {
|
|
608
1238
|
setStale(uiKey, draft !== panel.original);
|
|
609
1239
|
}
|
|
610
1240
|
}, [draft, panel, uiKey]);
|
|
1241
|
+
(0, import_react4.useEffect)(() => {
|
|
1242
|
+
if (writer === void 0 || !settings.enabled) return;
|
|
1243
|
+
const button = rootRef.current;
|
|
1244
|
+
if (button === null) return;
|
|
1245
|
+
const clearTimer = () => {
|
|
1246
|
+
if (longPressTimer.current !== void 0) {
|
|
1247
|
+
clearTimeout(longPressTimer.current);
|
|
1248
|
+
longPressTimer.current = void 0;
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
const onPointerDown = (event) => {
|
|
1252
|
+
const target = event.target;
|
|
1253
|
+
if (!(target instanceof Node) || !button.contains(target)) return;
|
|
1254
|
+
clearTimer();
|
|
1255
|
+
longPressFired.current = false;
|
|
1256
|
+
longPressOrigin.current = { x: event.clientX, y: event.clientY };
|
|
1257
|
+
longPressTimer.current = setTimeout(() => {
|
|
1258
|
+
longPressTimer.current = void 0;
|
|
1259
|
+
longPressFired.current = true;
|
|
1260
|
+
void openMenu(button.getBoundingClientRect());
|
|
1261
|
+
}, LONG_PRESS_MS);
|
|
1262
|
+
};
|
|
1263
|
+
const onPointerMove = (event) => {
|
|
1264
|
+
const origin = longPressOrigin.current;
|
|
1265
|
+
if (origin === null) return;
|
|
1266
|
+
if (Math.abs(event.clientX - origin.x) > LONG_PRESS_SLOP_PX || Math.abs(event.clientY - origin.y) > LONG_PRESS_SLOP_PX) {
|
|
1267
|
+
longPressOrigin.current = null;
|
|
1268
|
+
clearTimer();
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
const onPointerUp = () => {
|
|
1272
|
+
longPressOrigin.current = null;
|
|
1273
|
+
clearTimer();
|
|
1274
|
+
};
|
|
1275
|
+
const onKeyDown = (event) => {
|
|
1276
|
+
const menuKey = event.shiftKey && event.key === "F10" || event.key === "ContextMenu";
|
|
1277
|
+
if (!menuKey) return;
|
|
1278
|
+
if (document.activeElement !== button) return;
|
|
1279
|
+
event.preventDefault();
|
|
1280
|
+
void openMenu(button.getBoundingClientRect());
|
|
1281
|
+
};
|
|
1282
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1283
|
+
document.addEventListener("pointermove", onPointerMove, true);
|
|
1284
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1285
|
+
document.addEventListener("pointercancel", onPointerUp, true);
|
|
1286
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
1287
|
+
return () => {
|
|
1288
|
+
clearTimer();
|
|
1289
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1290
|
+
document.removeEventListener("pointermove", onPointerMove, true);
|
|
1291
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1292
|
+
document.removeEventListener("pointercancel", onPointerUp, true);
|
|
1293
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
1294
|
+
};
|
|
1295
|
+
}, [writer, settings.enabled, openMenu]);
|
|
611
1296
|
if (!settings.enabled) return null;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
"
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
1297
|
+
const statusTitle = busy ? t("button.busy") : otherBusy ? t("button.otherBusy") : empty ? t("button.emptyTitle") : t("button.title");
|
|
1298
|
+
const quickHint = writer === void 0 || busy || otherBusy ? "" : t("button.quickHint");
|
|
1299
|
+
const buttonLabel = statusTitle + quickHint;
|
|
1300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1302
|
+
"button",
|
|
1303
|
+
{
|
|
1304
|
+
ref: rootRef,
|
|
1305
|
+
type: "button",
|
|
1306
|
+
"data-dsh-pe-key": uiKey,
|
|
1307
|
+
className: `dsh-pe-btn${busy ? " is-busy" : ""}${otherBusy && !empty ? " is-blocked" : ""}${empty && !busy ? " is-empty" : ""}`,
|
|
1308
|
+
title: buttonLabel,
|
|
1309
|
+
"aria-label": statusTitle,
|
|
1310
|
+
"aria-haspopup": writer === void 0 ? void 0 : "menu",
|
|
1311
|
+
onContextMenu: (event) => {
|
|
1312
|
+
if (writer === void 0) return;
|
|
1313
|
+
event.preventDefault();
|
|
1314
|
+
void openMenu(event.currentTarget.getBoundingClientRect());
|
|
1315
|
+
},
|
|
1316
|
+
"aria-disabled": empty || otherBusy || void 0,
|
|
1317
|
+
onClick: () => {
|
|
1318
|
+
if (longPressFired.current) {
|
|
1319
|
+
longPressFired.current = false;
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
start();
|
|
1323
|
+
},
|
|
1324
|
+
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 }) })
|
|
1325
|
+
}
|
|
1326
|
+
),
|
|
1327
|
+
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 })
|
|
1328
|
+
] });
|
|
626
1329
|
}
|
|
627
1330
|
|
|
628
1331
|
// src/client/ResultDock.tsx
|
|
629
|
-
var
|
|
1332
|
+
var import_react7 = require("react");
|
|
630
1333
|
|
|
631
1334
|
// src/client/ResultPanel.tsx
|
|
632
|
-
var
|
|
1335
|
+
var import_react5 = require("react");
|
|
633
1336
|
|
|
634
1337
|
// src/client/ActionIcons.tsx
|
|
635
|
-
var
|
|
1338
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
636
1339
|
function icon(paths) {
|
|
637
|
-
return /* @__PURE__ */ (0,
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
638
1341
|
"svg",
|
|
639
1342
|
{
|
|
640
1343
|
width: 14,
|
|
@@ -653,21 +1356,65 @@ function icon(paths) {
|
|
|
653
1356
|
);
|
|
654
1357
|
}
|
|
655
1358
|
function RegenerateIcon() {
|
|
656
|
-
return icon([/* @__PURE__ */ (0,
|
|
1359
|
+
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
1360
|
}
|
|
658
1361
|
function CopyIcon() {
|
|
659
|
-
return icon([/* @__PURE__ */ (0,
|
|
1362
|
+
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
1363
|
}
|
|
661
1364
|
function FillIcon() {
|
|
662
|
-
return icon([/* @__PURE__ */ (0,
|
|
1365
|
+
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
1366
|
}
|
|
664
1367
|
function UndoIcon() {
|
|
665
|
-
return icon([/* @__PURE__ */ (0,
|
|
1368
|
+
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")]);
|
|
1369
|
+
}
|
|
1370
|
+
function CheckIcon() {
|
|
1371
|
+
return icon([/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m20 6-11 11-5-5" }, "check")]);
|
|
1372
|
+
}
|
|
1373
|
+
function XIcon() {
|
|
1374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1375
|
+
"svg",
|
|
1376
|
+
{
|
|
1377
|
+
width: 18,
|
|
1378
|
+
height: 18,
|
|
1379
|
+
viewBox: "0 0 24 24",
|
|
1380
|
+
fill: "none",
|
|
1381
|
+
stroke: "currentColor",
|
|
1382
|
+
strokeWidth: 2,
|
|
1383
|
+
strokeLinecap: "round",
|
|
1384
|
+
strokeLinejoin: "round",
|
|
1385
|
+
"aria-hidden": "true",
|
|
1386
|
+
focusable: "false",
|
|
1387
|
+
style: { display: "block", flexShrink: 0 },
|
|
1388
|
+
children: [
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M6 6l12 12" }),
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M18 6 6 18" })
|
|
1391
|
+
]
|
|
1392
|
+
}
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1395
|
+
function ChevronIcon({ open }) {
|
|
1396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1397
|
+
"svg",
|
|
1398
|
+
{
|
|
1399
|
+
width: 20,
|
|
1400
|
+
height: 20,
|
|
1401
|
+
viewBox: "0 0 24 24",
|
|
1402
|
+
fill: "none",
|
|
1403
|
+
stroke: "currentColor",
|
|
1404
|
+
strokeWidth: 2,
|
|
1405
|
+
strokeLinecap: "round",
|
|
1406
|
+
strokeLinejoin: "round",
|
|
1407
|
+
"aria-hidden": "true",
|
|
1408
|
+
focusable: "false",
|
|
1409
|
+
style: { display: "block", flexShrink: 0, transform: open ? "none" : "rotate(-90deg)" },
|
|
1410
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
1411
|
+
}
|
|
1412
|
+
);
|
|
666
1413
|
}
|
|
667
1414
|
|
|
668
1415
|
// src/client/ResultPanel.tsx
|
|
669
|
-
var
|
|
670
|
-
var retryable = (
|
|
1416
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1417
|
+
var retryable = (error) => error?.code === "upstream" || error?.code === "timeout" || error?.code === "internal" && error.params?.reason !== "cancelled";
|
|
671
1418
|
var UPSTREAM_ERROR_KEYS = {
|
|
672
1419
|
auth: "error.upstream.auth",
|
|
673
1420
|
"invalid-credential": "error.upstream.invalidCredential",
|
|
@@ -738,18 +1485,64 @@ function fallbackCopy(text) {
|
|
|
738
1485
|
function formatTokens(tokens) {
|
|
739
1486
|
return tokens.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
740
1487
|
}
|
|
1488
|
+
function capitalizeEffort(value) {
|
|
1489
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
1490
|
+
}
|
|
741
1491
|
function totalTokensOf(usage) {
|
|
742
1492
|
return usage.totalTokens ?? usage.inputTokens + usage.outputTokens + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0);
|
|
743
1493
|
}
|
|
1494
|
+
function ContextUsageInfo(props) {
|
|
1495
|
+
const { usage, t } = props;
|
|
1496
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
1497
|
+
const limited = usage !== void 0 && (usage.cutTurn || usage.limitedBy === "chars");
|
|
1498
|
+
const percent = usage !== void 0 && usage.maxChars > 0 ? Math.round(usage.usedChars / usage.maxChars * 100) : 0;
|
|
1499
|
+
const stats = usage === void 0 ? t("panel.contextUnused") : t("panel.contextStats", {
|
|
1500
|
+
turns: usage.usedTurns,
|
|
1501
|
+
maxTurns: usage.maxTurns,
|
|
1502
|
+
chars: formatTokens(usage.usedChars),
|
|
1503
|
+
maxChars: formatTokens(usage.maxChars),
|
|
1504
|
+
percent
|
|
1505
|
+
});
|
|
1506
|
+
const reason = usage === void 0 ? "" : usage.cutTurn ? t("panel.contextCut") : usage.limitedBy === "chars" ? t("panel.contextCharsLimited") : "";
|
|
1507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-context-wrap", children: [
|
|
1508
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1509
|
+
"button",
|
|
1510
|
+
{
|
|
1511
|
+
type: "button",
|
|
1512
|
+
className: `dsh-pe-context${limited ? " is-limited" : ""}`,
|
|
1513
|
+
"aria-label": t("panel.contextUsage"),
|
|
1514
|
+
"aria-expanded": open,
|
|
1515
|
+
onMouseEnter: () => setOpen(true),
|
|
1516
|
+
onMouseLeave: () => setOpen(false),
|
|
1517
|
+
onFocus: () => setOpen(true),
|
|
1518
|
+
onBlur: () => setOpen(false),
|
|
1519
|
+
onClick: () => setOpen((value) => !value),
|
|
1520
|
+
onKeyDown: (event) => {
|
|
1521
|
+
if (event.key === "Escape") setOpen(false);
|
|
1522
|
+
},
|
|
1523
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "dsh-pe-context-icon", viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "2.2", y: "3.4", width: "11.6", height: "9.2", rx: "2.2", fill: "none", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.2 6.6h5.6M5.2 9.2h3.8", fill: "none", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
1526
|
+
] })
|
|
1527
|
+
}
|
|
1528
|
+
),
|
|
1529
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { role: "tooltip", className: "dsh-pe-context-tip", children: [
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-context-stats", children: stats }),
|
|
1531
|
+
reason !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-context-reason", children: reason })
|
|
1532
|
+
] })
|
|
1533
|
+
] });
|
|
1534
|
+
}
|
|
744
1535
|
function ResultPanel(props) {
|
|
745
|
-
const { state, t, onApply, onCancel, onRetry, applied = false, onUndo, onRegenerate, regenerated = false } = props;
|
|
746
|
-
const [copied, setCopied] = (0,
|
|
747
|
-
const
|
|
1536
|
+
const { state, t, onApply, onCancel, onRetry, applied = false, onUndo, onRegenerate, regenerated = false, collapsed = false, onToggleCollapsed, foldAnimation = true } = props;
|
|
1537
|
+
const [copied, setCopied] = (0, import_react5.useState)("idle");
|
|
1538
|
+
const copyTimer = (0, import_react5.useRef)(void 0);
|
|
1539
|
+
const copy = (0, import_react5.useCallback)(() => {
|
|
748
1540
|
if (state.result === void 0) return;
|
|
749
1541
|
const text = state.result.text;
|
|
750
1542
|
const done = (ok) => {
|
|
751
1543
|
setCopied(ok ? "ok" : "failed");
|
|
752
|
-
if (
|
|
1544
|
+
if (copyTimer.current !== void 0) clearTimeout(copyTimer.current);
|
|
1545
|
+
copyTimer.current = setTimeout(() => setCopied("idle"), 2500);
|
|
753
1546
|
};
|
|
754
1547
|
if (navigator.clipboard !== void 0) {
|
|
755
1548
|
navigator.clipboard.writeText(text).then(
|
|
@@ -771,79 +1564,88 @@ function ResultPanel(props) {
|
|
|
771
1564
|
}
|
|
772
1565
|
return parts.join(" \xB7 ");
|
|
773
1566
|
};
|
|
774
|
-
const swapLabel = (active, text) => /* @__PURE__ */ (0,
|
|
775
|
-
return /* @__PURE__ */ (0,
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
777
|
-
/* @__PURE__ */ (0,
|
|
778
|
-
/* @__PURE__ */ (0,
|
|
1567
|
+
const swapLabel = (active, text) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: active ? "on" : void 0, "aria-hidden": active ? void 0 : true, children: text });
|
|
1568
|
+
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: [
|
|
1569
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: "dsh-pe-head", children: [
|
|
1570
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-title", children: [
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SparkleFishIcon, { size: 15 }),
|
|
779
1572
|
t("panel.title")
|
|
780
1573
|
] }),
|
|
781
|
-
/* @__PURE__ */ (0,
|
|
782
|
-
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0,
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-head-actions", children: [
|
|
1575
|
+
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-badge", children: [
|
|
783
1576
|
t("panel.model", { provider: state.result.provider, model: state.result.model }),
|
|
1577
|
+
state.result.reasoningEffort === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1578
|
+
" \xB7 ",
|
|
1579
|
+
state.result.reasoningEffort === "inherit" ? t("panel.effortDefault") : capitalizeEffort(state.result.reasoningEffort)
|
|
1580
|
+
] }),
|
|
784
1581
|
" \xB7 ",
|
|
785
1582
|
t("panel.elapsed", { ms: formatMs(state.result.elapsedMs) }),
|
|
786
|
-
state.result.usage === void 0 ? null : /* @__PURE__ */ (0,
|
|
1583
|
+
state.result.usage === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
787
1584
|
" \xB7 ",
|
|
788
|
-
/* @__PURE__ */ (0,
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { title: tokenDetail(state.result.usage), children: t("panel.tokens", { total: formatTokens(totalTokensOf(state.result.usage)) }) })
|
|
789
1586
|
] })
|
|
790
1587
|
] }),
|
|
791
|
-
/* @__PURE__ */ (0,
|
|
1588
|
+
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,
|
|
1589
|
+
/* @__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 }) }),
|
|
1590
|
+
/* @__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
1591
|
] })
|
|
793
1592
|
] }),
|
|
794
|
-
|
|
795
|
-
/* @__PURE__ */ (0,
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
/* @__PURE__ */ (0,
|
|
800
|
-
/* @__PURE__ */ (0,
|
|
801
|
-
|
|
1593
|
+
/* @__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: [
|
|
1594
|
+
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: [
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-spin", "aria-hidden": true }),
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: t("panel.loading") }),
|
|
1597
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-hint", children: t("panel.loading.hint") })
|
|
1598
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stream", children: [
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-col-title", children: [
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-spin small", "aria-hidden": true }),
|
|
1601
|
+
t("panel.streaming")
|
|
1602
|
+
] }),
|
|
1603
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: "dsh-pe-result-text", children: state.streaming })
|
|
1604
|
+
] }) }),
|
|
1605
|
+
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: [
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: localizedErrorMessage(t, state.error.code, state.error.params) }),
|
|
1607
|
+
state.error.message !== void 0 && state.error.message !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dsh-pe-error-detail", children: state.error.message })
|
|
1608
|
+
] }) }),
|
|
1609
|
+
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 }) }),
|
|
1610
|
+
state.phase === "result" && state.result?.truncated === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stale", children: [
|
|
1611
|
+
"\u26A0 ",
|
|
1612
|
+
t("panel.truncated")
|
|
802
1613
|
] }),
|
|
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 })
|
|
1614
|
+
state.phase === "result" && state.stale && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsh-pe-stale", children: [
|
|
1615
|
+
"\u26A0 ",
|
|
1616
|
+
t("panel.stale.warn")
|
|
1617
|
+
] })
|
|
808
1618
|
] }) }),
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
"
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
"\u26A0 ",
|
|
816
|
-
t("panel.stale.warn")
|
|
817
|
-
] }),
|
|
818
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("footer", { className: "dsh-pe-foot", children: [
|
|
819
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-grow" }),
|
|
820
|
-
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-swap", onClick: onRegenerate, disabled: onRegenerate === void 0, children: [
|
|
821
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RegenerateIcon, {}),
|
|
822
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
1619
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("footer", { className: "dsh-pe-foot", children: [
|
|
1620
|
+
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ContextUsageInfo, { usage: state.result?.context, t }),
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-grow" }),
|
|
1622
|
+
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: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RegenerateIcon, {}),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
823
1625
|
swapLabel(!regenerated, t("panel.regenerate")),
|
|
824
1626
|
swapLabel(regenerated, t("panel.regenerated"))
|
|
825
1627
|
] })
|
|
826
1628
|
] }),
|
|
827
|
-
state.phase === "error" && /* @__PURE__ */ (0,
|
|
828
|
-
state.phase === "loading" && /* @__PURE__ */ (0,
|
|
829
|
-
state.phase === "result" && /* @__PURE__ */ (0,
|
|
830
|
-
/* @__PURE__ */ (0,
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
832
|
-
/* @__PURE__ */ (0,
|
|
1629
|
+
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") }) }),
|
|
1630
|
+
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") }),
|
|
1631
|
+
state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1632
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: copy, children: [
|
|
1633
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyIcon, {}),
|
|
1634
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
833
1635
|
swapLabel(copied === "idle", t("panel.copy")),
|
|
834
1636
|
swapLabel(copied === "ok", t("panel.copied")),
|
|
835
1637
|
swapLabel(copied === "failed", t("panel.copyFailed"))
|
|
836
1638
|
] })
|
|
837
1639
|
] }),
|
|
838
|
-
applied ? /* @__PURE__ */ (0,
|
|
839
|
-
/* @__PURE__ */ (0,
|
|
840
|
-
/* @__PURE__ */ (0,
|
|
1640
|
+
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: [
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UndoIcon, {}),
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
841
1643
|
swapLabel(true, t("undo.undo")),
|
|
842
1644
|
swapLabel(false, t("panel.apply"))
|
|
843
1645
|
] })
|
|
844
|
-
] }) : /* @__PURE__ */ (0,
|
|
845
|
-
/* @__PURE__ */ (0,
|
|
846
|
-
/* @__PURE__ */ (0,
|
|
1646
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action primary dsh-pe-btn-floor", onClick: onApply, children: [
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FillIcon, {}),
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-swap", children: [
|
|
847
1649
|
swapLabel(true, t("panel.apply")),
|
|
848
1650
|
swapLabel(false, t("undo.undo"))
|
|
849
1651
|
] })
|
|
@@ -854,7 +1656,7 @@ function ResultPanel(props) {
|
|
|
854
1656
|
}
|
|
855
1657
|
|
|
856
1658
|
// src/client/useDockAlignment.ts
|
|
857
|
-
var
|
|
1659
|
+
var import_react6 = require("react");
|
|
858
1660
|
var EDITOR_SELECTOR = 'textarea, [contenteditable="true"], [role="textbox"]';
|
|
859
1661
|
var SESSION_ANCHOR_ATTRIBUTE = "data-dsh-pe-key";
|
|
860
1662
|
var CARD_MIN_WIDTH = 360;
|
|
@@ -882,8 +1684,8 @@ function editorsIn(scope) {
|
|
|
882
1684
|
return Array.from(scope.querySelectorAll(EDITOR_SELECTOR));
|
|
883
1685
|
}
|
|
884
1686
|
function useDockAlignment(active, uiKey) {
|
|
885
|
-
const rootRef = (0,
|
|
886
|
-
(0,
|
|
1687
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
1688
|
+
(0, import_react6.useEffect)(() => {
|
|
887
1689
|
if (!active) return;
|
|
888
1690
|
const root = rootRef.current;
|
|
889
1691
|
if (root === null) return;
|
|
@@ -960,12 +1762,13 @@ function useDockAlignment(active, uiKey) {
|
|
|
960
1762
|
}
|
|
961
1763
|
|
|
962
1764
|
// src/client/ResultDock.tsx
|
|
963
|
-
var
|
|
1765
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
964
1766
|
var REGENERATED_NOTICE_MS = 2500;
|
|
965
1767
|
function ResultDock(props) {
|
|
966
1768
|
const { t, sessionId, useInput, inputActions } = props;
|
|
967
1769
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
968
|
-
const panel = (0,
|
|
1770
|
+
const panel = (0, import_react7.useSyncExternalStore)(subscribe, getPanel);
|
|
1771
|
+
const settings = (0, import_react7.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
969
1772
|
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey, uiKey);
|
|
970
1773
|
const draft = useInput((state) => {
|
|
971
1774
|
const value = state.draft;
|
|
@@ -986,11 +1789,11 @@ function ResultDock(props) {
|
|
|
986
1789
|
);
|
|
987
1790
|
const entry = peekUndo(uiKey);
|
|
988
1791
|
const applied = entry !== void 0 && entry.applied === draft;
|
|
989
|
-
const [regeneratedNotice, setRegeneratedNotice] = (0,
|
|
990
|
-
const pendingRegenerate = (0,
|
|
991
|
-
const previousResultRef = (0,
|
|
992
|
-
const prevSession = (0,
|
|
993
|
-
(0,
|
|
1792
|
+
const [regeneratedNotice, setRegeneratedNotice] = (0, import_react7.useState)(false);
|
|
1793
|
+
const pendingRegenerate = (0, import_react7.useRef)(false);
|
|
1794
|
+
const previousResultRef = (0, import_react7.useRef)(void 0);
|
|
1795
|
+
const prevSession = (0, import_react7.useRef)({ running: sessionRunning, queued: sessionQueued });
|
|
1796
|
+
(0, import_react7.useEffect)(() => {
|
|
994
1797
|
const prev = prevSession.current;
|
|
995
1798
|
prevSession.current = { running: sessionRunning, queued: sessionQueued };
|
|
996
1799
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
@@ -998,7 +1801,7 @@ function ResultDock(props) {
|
|
|
998
1801
|
closePanel();
|
|
999
1802
|
}
|
|
1000
1803
|
}, [phase, sessionRunning, sessionQueued, panel, uiKey]);
|
|
1001
|
-
(0,
|
|
1804
|
+
(0, import_react7.useEffect)(() => {
|
|
1002
1805
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
1003
1806
|
const onKeyDown = (event) => {
|
|
1004
1807
|
if (event.defaultPrevented || event.isComposing || event.key !== "Escape") return;
|
|
@@ -1008,7 +1811,7 @@ function ResultDock(props) {
|
|
|
1008
1811
|
document.addEventListener("keydown", onKeyDown);
|
|
1009
1812
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
1010
1813
|
}, [panel, uiKey]);
|
|
1011
|
-
(0,
|
|
1814
|
+
(0, import_react7.useEffect)(() => {
|
|
1012
1815
|
if (!pendingRegenerate.current) return;
|
|
1013
1816
|
if (panel === void 0 || panel.sessionId !== uiKey || panel.phase === "error") {
|
|
1014
1817
|
pendingRegenerate.current = false;
|
|
@@ -1019,7 +1822,7 @@ function ResultDock(props) {
|
|
|
1019
1822
|
setRegeneratedNotice(true);
|
|
1020
1823
|
}
|
|
1021
1824
|
}, [panel, uiKey]);
|
|
1022
|
-
(0,
|
|
1825
|
+
(0, import_react7.useEffect)(() => {
|
|
1023
1826
|
if (!regeneratedNotice) return;
|
|
1024
1827
|
const timer = setTimeout(() => setRegeneratedNotice(false), REGENERATED_NOTICE_MS);
|
|
1025
1828
|
return () => clearTimeout(timer);
|
|
@@ -1029,11 +1832,13 @@ function ResultDock(props) {
|
|
|
1029
1832
|
if (panel.phase !== "result" || panel.result === void 0) return;
|
|
1030
1833
|
pushUndo(uiKey, { original: draft, applied: panel.result.text });
|
|
1031
1834
|
inputActions.setDraft(panel.result.text);
|
|
1835
|
+
if (settings.autoFold) setCollapsed(uiKey, true);
|
|
1032
1836
|
};
|
|
1033
1837
|
const undo = () => {
|
|
1034
1838
|
if (entry === void 0) return;
|
|
1035
1839
|
inputActions.setDraft(entry.original);
|
|
1036
1840
|
popUndo(uiKey);
|
|
1841
|
+
if (settings.autoFold) setCollapsed(uiKey, false);
|
|
1037
1842
|
};
|
|
1038
1843
|
const regenerate = () => {
|
|
1039
1844
|
if (panel.phase !== "result") return;
|
|
@@ -1042,13 +1847,16 @@ function ResultDock(props) {
|
|
|
1042
1847
|
pendingRegenerate.current = true;
|
|
1043
1848
|
runSession(uiKey);
|
|
1044
1849
|
};
|
|
1045
|
-
return /* @__PURE__ */ (0,
|
|
1850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: rootRef, className: "dsh-pe-dock", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1046
1851
|
ResultPanel,
|
|
1047
1852
|
{
|
|
1048
1853
|
state: panel,
|
|
1049
1854
|
t,
|
|
1050
1855
|
applied,
|
|
1051
1856
|
regenerated: regeneratedNotice,
|
|
1857
|
+
collapsed: panel.collapsed === true,
|
|
1858
|
+
onToggleCollapsed: () => setCollapsed(uiKey, panel.collapsed !== true),
|
|
1859
|
+
foldAnimation: settings.foldAnimation,
|
|
1052
1860
|
onApply: apply2,
|
|
1053
1861
|
onUndo: undo,
|
|
1054
1862
|
onRegenerate: regenerate,
|
|
@@ -1059,8 +1867,8 @@ function ResultDock(props) {
|
|
|
1059
1867
|
}
|
|
1060
1868
|
|
|
1061
1869
|
// src/client/UndoBar.tsx
|
|
1062
|
-
var
|
|
1063
|
-
var
|
|
1870
|
+
var import_react8 = require("react");
|
|
1871
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1064
1872
|
function UndoBar(props) {
|
|
1065
1873
|
const { t, sessionId, useInput, inputActions } = props;
|
|
1066
1874
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
@@ -1068,9 +1876,9 @@ function UndoBar(props) {
|
|
|
1068
1876
|
const value = state.draft;
|
|
1069
1877
|
return typeof value === "string" ? value : "";
|
|
1070
1878
|
});
|
|
1071
|
-
(0,
|
|
1879
|
+
(0, import_react8.useSyncExternalStore)(subscribe, getVersion);
|
|
1072
1880
|
const entry = peekUndo(uiKey);
|
|
1073
|
-
(0,
|
|
1881
|
+
(0, import_react8.useEffect)(() => {
|
|
1074
1882
|
if (entry !== void 0 && entry.applied !== draft) popUndo(uiKey);
|
|
1075
1883
|
}, [draft, entry, uiKey]);
|
|
1076
1884
|
const panel = getPanel();
|
|
@@ -1084,23 +1892,36 @@ function UndoBar(props) {
|
|
|
1084
1892
|
const dismiss = () => {
|
|
1085
1893
|
popUndo(uiKey);
|
|
1086
1894
|
};
|
|
1087
|
-
return /* @__PURE__ */ (0,
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1090
|
-
/* @__PURE__ */ (0,
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1895
|
+
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: [
|
|
1896
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsh-pe-undo-check", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckIcon, {}) }),
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: t("undo.applied") }),
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "dsh-pe-undo-link", onClick: undo, children: [
|
|
1899
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UndoIcon, {}),
|
|
1092
1900
|
t("undo.undo")
|
|
1093
1901
|
] }),
|
|
1094
|
-
/* @__PURE__ */ (0,
|
|
1902
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "dsh-pe-undo-x", "aria-label": t("undo.dismiss"), onClick: dismiss, children: "\u2715" })
|
|
1095
1903
|
] }) });
|
|
1096
1904
|
}
|
|
1097
1905
|
|
|
1098
1906
|
// src/client/locales.ts
|
|
1099
1907
|
var zh = {
|
|
1100
|
-
"button.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1908
|
+
"button.title": "\u63D0\u793A\u8BCD\u589E\u5F3A \xB7 \u4F18\u5316\u8F93\u5165\u6846\u91CC\u7684\u6587\u5B57",
|
|
1101
1909
|
"button.busy": "\u6B63\u5728\u589E\u5F3A\u2026",
|
|
1102
|
-
"button.otherBusy": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u6B63\u5728\u589E\u5F3A\u4E2D
|
|
1103
|
-
"button.emptyTitle": "\u63D0\u793A\u8BCD\u589E\u5F3A\
|
|
1910
|
+
"button.otherBusy": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u6B63\u5728\u589E\u5F3A\u4E2D",
|
|
1911
|
+
"button.emptyTitle": "\u63D0\u793A\u8BCD\u589E\u5F3A \xB7 \u8BF7\u5148\u8F93\u5165\u8981\u4F18\u5316\u7684\u6587\u5B57",
|
|
1912
|
+
"button.quickHint": "\uFF08\u53F3\u952E\u914D\u7F6E\uFF09",
|
|
1913
|
+
"menu.title": "\u5FEB\u6377\u8BBE\u7F6E",
|
|
1914
|
+
"menu.model": "\u6A21\u578B",
|
|
1915
|
+
"menu.modelFollow": "\u8DDF\u968F\u4F1A\u8BDD",
|
|
1916
|
+
"menu.modelHint": "\u5728\u63D2\u4EF6\u8BBE\u7F6E\u9875\u4FEE\u6539",
|
|
1917
|
+
"menu.effortsNone": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D",
|
|
1918
|
+
"menu.effortsFailed": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D",
|
|
1919
|
+
"menu.effort": "\u63A8\u7406\u7B49\u7EA7",
|
|
1920
|
+
"menu.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
|
|
1921
|
+
"menu.context": "\u4E0A\u4E0B\u6587\u611F\u77E5",
|
|
1922
|
+
"menu.contextOn": "\u5F00",
|
|
1923
|
+
"menu.contextOff": "\u5173",
|
|
1924
|
+
"menu.writeFailed": "\u5199\u5165\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1104
1925
|
"panel.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1105
1926
|
"panel.loading": "\u6B63\u5728\u589E\u5F3A\uFF0C\u7A0D\u5019\u2026",
|
|
1106
1927
|
"panel.streaming": "\u6B63\u5728\u751F\u6210\u2026",
|
|
@@ -1115,12 +1936,20 @@ var zh = {
|
|
|
1115
1936
|
"panel.copied": "\u5DF2\u590D\u5236",
|
|
1116
1937
|
"panel.copyFailed": "\u590D\u5236\u5931\u8D25",
|
|
1117
1938
|
"panel.close": "\u5173\u95ED",
|
|
1939
|
+
"panel.collapse": "\u6298\u53E0",
|
|
1940
|
+
"panel.expand": "\u5C55\u5F00",
|
|
1118
1941
|
"panel.retry": "\u91CD\u8BD5",
|
|
1119
|
-
"panel.stale.warn": "\u8349\u7A3F\u5DF2\u6539\u52A8\uFF0C\u5F53\u524D\u7ED3\u679C\u57FA\u4E8E\
|
|
1120
|
-
"panel.truncated": "\u8F93\u51FA\u8FBE\u5230
|
|
1942
|
+
"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",
|
|
1943
|
+
"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",
|
|
1944
|
+
"panel.contextUsage": "\u4E0A\u4E0B\u6587\u7528\u91CF",
|
|
1945
|
+
"panel.contextStats": "\u4E0A\u4E0B\u6587 {turns}/{maxTurns} \u6761 \xB7 {chars}/{maxChars} \u5B57\uFF08{percent}%\uFF09",
|
|
1946
|
+
"panel.contextCharsLimited": "\u5DF2\u8FBE\u5B57\u6570\u4E0A\u9650\uFF0C\u8F83\u65E9\u5185\u5BB9\u672A\u53D1\u9001",
|
|
1947
|
+
"panel.contextCut": "\u5DF2\u8FBE\u5B57\u6570\u4E0A\u9650\uFF0C\u6700\u65B0\u4E00\u6761\u4EC5\u53D1\u9001\u4E86\u5F00\u5934",
|
|
1948
|
+
"panel.contextUnused": "\u672C\u6B21\u672A\u4F7F\u7528\u4E0A\u4E0B\u6587",
|
|
1121
1949
|
"panel.model": "\u6A21\u578B\uFF1A{provider} / {model}",
|
|
1122
1950
|
"panel.elapsed": "\u8017\u65F6 {ms}",
|
|
1123
1951
|
"panel.tokens": "{total} tokens",
|
|
1952
|
+
"panel.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
|
|
1124
1953
|
"panel.tokens.input": "\u8F93\u5165 {count}",
|
|
1125
1954
|
"panel.tokens.output": "\u8F93\u51FA {count}",
|
|
1126
1955
|
"panel.tokens.cacheRead": "\u7F13\u5B58\u8BFB\u53D6 {count}",
|
|
@@ -1129,17 +1958,17 @@ var zh = {
|
|
|
1129
1958
|
"undo.undo": "\u64A4\u9500",
|
|
1130
1959
|
"undo.dismiss": "\u5173\u95ED\u63D0\u793A",
|
|
1131
1960
|
"error.empty": "\u8F93\u5165\u6846\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u8F93\u5165\u8981\u589E\u5F3A\u7684\u63D0\u793A\u8BCD\u3002",
|
|
1132
|
-
"error.tooLong": "\u5185\u5BB9
|
|
1961
|
+
"error.tooLong": "\u5185\u5BB9 {count} \u5B57\uFF0C\u8D85\u8FC7 {max} \u5B57\u4E0A\u9650\uFF08\u6309\u5B57\u7B26\u8BA1\uFF0C\u975E token\uFF09\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u622A\u65AD\uFF0C\u8BF7\u7CBE\u7B80\u540E\u91CD\u8BD5\u3002",
|
|
1133
1962
|
"error.occurrences": "\u8F93\u5165\u5185\u5BB9\u5305\u542B\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u6682\u4E0D\u652F\u6301\u589E\u5F3A\uFF1B\u8BF7\u5148\u79FB\u9664\u540E\u518D\u8BD5\u3002",
|
|
1134
|
-
"error.chipsUnknown": "\u65E0\u6CD5\u8BFB\u53D6\u8F93\u5165\u6846\u7684\u5F15\u7528\u72B6\u6001\
|
|
1963
|
+
"error.chipsUnknown": "\u65E0\u6CD5\u8BFB\u53D6\u8F93\u5165\u6846\u91CC\u7684\u5F15\u7528\u72B6\u6001\uFF1B\u4E3A\u907F\u514D\u8986\u76D6\u4F60\u7684\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u672C\u6B21\u5DF2\u963B\u6B62\u3002\u8BF7\u6539\u4E3A\u7EAF\u6587\u672C\u540E\u91CD\u8BD5\u3002",
|
|
1135
1964
|
"error.phase": "\u5F53\u524D\u8F93\u5165\u6B63\u88AB\u5360\u7528\uFF08\u63D0\u4EA4\u4E2D\uFF09\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1136
|
-
"error.disabled": "\u63D0\u793A\u8BCD\u589E\u5F3A\u5DF2\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002",
|
|
1137
|
-
"error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002",
|
|
1138
|
-
"error.timeout": "\u589E\u5F3A\u8D85\u65F6\uFF08{seconds} \u79D2\uFF09\
|
|
1139
|
-
"error.unconfigured": "\
|
|
1140
|
-
"error.effortUnsupported": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u6863\u4F4D\u300C{effort}\u300D\uFF0C\u8BF7\u6539\u9009\u5176\u5B83\u6863\u4F4D\uFF0C\u6216\u6539\u7528\u300C\
|
|
1141
|
-
"error.upstream": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\
|
|
1142
|
-
"error.internal": "\u589E\u5F3A\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1965
|
+
"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",
|
|
1966
|
+
"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",
|
|
1967
|
+
"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",
|
|
1968
|
+
"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",
|
|
1969
|
+
"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\u6A21\u578B\u9ED8\u8BA4\u300D\u3002",
|
|
1970
|
+
"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",
|
|
1971
|
+
"error.internal": "\u589E\u5F3A\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u53CD\u590D\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B dsh \u8FD0\u884C\u65E5\u5FD7\u3002\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1143
1972
|
"error.client.unreachable": "\u65E0\u6CD5\u8FDE\u63A5\u5BBF\u4E3B\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 dsh web \u6B63\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002",
|
|
1144
1973
|
"error.client.malformed": "\u5BBF\u4E3B\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6CD5\u89E3\u6790\u7684\u6570\u636E\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1145
1974
|
"error.client.refused": "\u5BBF\u4E3B\u670D\u52A1\u62D2\u7EDD\u4E86\u8BF7\u6C42\uFF08HTTP {status}\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1147,7 +1976,7 @@ var zh = {
|
|
|
1147
1976
|
"error.client.cancelled": "\u5DF2\u53D6\u6D88\u589E\u5F3A\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
|
|
1148
1977
|
"error.rateLimit": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF1A\u6BCF\u5206\u949F\u6700\u591A {limit} \u6B21\u589E\u5F3A\uFF0C\u8BF7\u5728 {retryAfterSeconds} \u79D2\u540E\u518D\u8BD5\u3002",
|
|
1149
1978
|
"error.concurrencyLimit": "\u5DF2\u6709 {max} \u4E2A\u589E\u5F3A\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u7B49\u5176\u4E2D\u4E00\u4E2A\u5B8C\u6210\u540E\u518D\u8BD5\u3002",
|
|
1150
|
-
"error.cooldown": "\u8FDE\u7EED {failures} \u6B21\u589E\u5F3A\u5931\u8D25\uFF0C\u5DF2\u6682\u505C\
|
|
1979
|
+
"error.cooldown": "\u8FDE\u7EED {failures} \u6B21\u589E\u5F3A\u5931\u8D25\uFF0C\u5DF2\u6682\u505C {retryAfterSeconds} \u79D2\u4EE5\u514D\u6301\u7EED\u51B2\u51FB\u6A21\u578B\u670D\u52A1\uFF1B\u53EF\u7A0D\u540E\u91CD\u8BD5\uFF0C\u6216\u5148\u68C0\u67E5\u6A21\u578B\u914D\u7F6E\u3002",
|
|
1151
1980
|
"error.upstream.auth": "\u9274\u6743\u5931\u8D25\uFF1A\u8BF7\u68C0\u67E5\u8BE5 provider \u7684 API Key \u914D\u7F6E\u3002",
|
|
1152
1981
|
"error.upstream.invalidCredential": "\u9274\u6743\u5931\u8D25\uFF1A\u5B58\u50A8\u7684 API Key \u4E0D\u53EF\u7528\uFF0C\u8BF7\u4FEE\u6B63\u540E\u91CD\u8BD5\u3002",
|
|
1153
1982
|
"error.upstream.rateLimit": "\u6A21\u578B\u670D\u52A1\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
@@ -1155,7 +1984,7 @@ var zh = {
|
|
|
1155
1984
|
"error.upstream.empty": "\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1156
1985
|
"error.upstream.contextWindow": "\u8F93\u5165\u8D85\u51FA\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\uFF0C\u8BF7\u7CBE\u7B80\u539F\u6587\u6216\u66F4\u6362\u6A21\u578B\u3002",
|
|
1157
1986
|
"error.upstream.toolCall": "\u6A21\u578B\u8BF7\u6C42\u4E86\u5DE5\u5177\u8C03\u7528\uFF0C\u63D0\u793A\u8BCD\u589E\u5F3A\u53EA\u9700\u8981\u7EAF\u6587\u672C\uFF1B\u8BF7\u66F4\u6362\u6A21\u578B\u540E\u91CD\u8BD5\u3002",
|
|
1158
|
-
"error.upstream.maxTokens": "\u91CD\u5199\u7ED3\u679C\u8FBE\u5230\u8F93\u51FA\u4E0A\u9650\
|
|
1987
|
+
"error.upstream.maxTokens": "\u91CD\u5199\u7ED3\u679C\u8FBE\u5230\u300C\u8F93\u51FA token \u4E0A\u9650\u300D\uFF0C\u8BF7\u8C03\u9AD8\u8BE5\u8BBE\u7F6E\u6216\u7CBE\u7B80\u539F\u6587\u540E\u91CD\u8BD5\u3002",
|
|
1159
1988
|
"settings.summary": "\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D44\u6E90\u9650\u5236",
|
|
1160
1989
|
"settings.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
1161
1990
|
"settings.description": "\u628A\u8F93\u5165\u6846\u8349\u7A3F\u6539\u5199\u4E3A\u7ED3\u6784\u5316\u63D0\u793A\u8BCD\uFF1A\u89D2\u8272\u4E0E\u76EE\u6807\u3001\u53EF\u6267\u884C\u6B65\u9AA4\u3001\u8F93\u51FA\u683C\u5F0F\u3001\u9A8C\u6536\u6807\u51C6\u3001\u8FB9\u754C\u6761\u4EF6\u3002\u539F\u6587\u4FDD\u7559\uFF0C\u5931\u8D25\u4E0D\u6539\u8349\u7A3F\uFF1B\u4FDD\u5B58\u540E\u4E0B\u4E00\u6B21\u8C03\u7528\u5373\u751F\u6548\u3002",
|
|
@@ -1169,6 +1998,11 @@ var zh = {
|
|
|
1169
1998
|
"settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
|
|
1170
1999
|
"settings.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
1171
2000
|
"settings.invalidNumber": "\u8BF7\u586B\u6570\u5B57\uFF1B\u7559\u7A7A\u8868\u793A\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
|
|
2001
|
+
"settings.record": "\u5F55\u5236",
|
|
2002
|
+
"settings.recordStop": "\u53D6\u6D88\u5F55\u5236",
|
|
2003
|
+
"settings.recordPrompt": "\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\uFF08Esc \u53D6\u6D88\uFF09",
|
|
2004
|
+
"settings.recordNeedsModifier": "\u9700\u8981\u81F3\u5C11\u6309\u4F4F ctrl / alt / meta \u4E2D\u7684\u4E00\u4E2A",
|
|
2005
|
+
"settings.invalidShortcut": "\u5199\u6CD5\u65E0\u6548\uFF0C\u5FEB\u6377\u952E\u4E0D\u4F1A\u751F\u6548\uFF1A\u9700\u5305\u542B ctrl / alt / meta \u4E2D\u81F3\u5C11\u4E00\u4E2A\uFF0C\u952E\u653E\u5728\u6700\u540E\uFF0C\u4F8B\u5982 ctrl+alt+e\u3002",
|
|
1172
2006
|
"settings.disconnected": "\u8868\u5355\u6CA1\u6709\u63A5\u901A\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u5411\u8FD9\u4E2A\u9875\u9762\u6CE8\u5165\u8868\u5355\u72B6\u6001\u3002\u63D2\u4EF6\u4ECD\u6309\u7EC4\u5408\u914D\u7F6E\u5DE5\u4F5C\u3002",
|
|
1173
2007
|
"settings.row.enabled.label": "\u603B\u5F00\u5173",
|
|
1174
2008
|
"settings.row.enabled.hint": "\u5173\u95ED\u540E\u9690\u85CF\u8F93\u5165\u6846\u7684\u589E\u5F3A\u6309\u94AE\uFF0C\u547D\u4EE4\u4E0E\u5FEB\u6377\u952E\u4E00\u5E76\u505C\u7528\u3002",
|
|
@@ -1176,6 +2010,10 @@ var zh = {
|
|
|
1176
2010
|
"settings.row.contextAware.hint": "\u8BFB\u53D6\u5F53\u524D\u4F1A\u8BDD\u6700\u8FD1\u51E0\u8F6E\u5BF9\u8BDD\u6765\u6D88\u89E3\u6307\u4EE3\u3001\u8865\u5168\u7701\u7565\uFF1B\u65E0\u5386\u53F2\u65F6\u56DE\u9000\u4E3A\u5355\u6761\u589E\u5F3A\u3002",
|
|
1177
2011
|
"settings.row.streaming.label": "\u589E\u91CF\u5C55\u793A",
|
|
1178
2012
|
"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",
|
|
2013
|
+
"settings.row.foldAnimation.label": "\u5361\u7247\u6298\u53E0\u52A8\u753B",
|
|
2014
|
+
"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",
|
|
2015
|
+
"settings.row.autoFold.label": "\u81EA\u52A8\u6536\u7EB3\u5361\u7247",
|
|
2016
|
+
"settings.row.autoFold.hint": "\u56DE\u586B\u5230\u8F93\u5165\u6846\u540E\u81EA\u52A8\u6536\u8D77\u5361\u7247\uFF0C\u64A4\u9500\u540E\u81EA\u52A8\u5C55\u5F00\uFF1B\u5173\u95ED\u540E\u5361\u7247\u4FDD\u6301\u5F53\u524D\u72B6\u6001\u3002",
|
|
1179
2017
|
"settings.row.provider.label": "\u6A21\u578B\u670D\u52A1\u65B9",
|
|
1180
2018
|
"settings.row.provider.hint": "\u4ECE DSH \u5DF2\u6CE8\u518C\u7684 LLM provider \u4E2D\u9009\u62E9\uFF1B\u7559\u7A7A\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\u7684\u6A21\u578B\u3002",
|
|
1181
2019
|
"settings.row.model.label": "\u6A21\u578B ID",
|
|
@@ -1202,7 +2040,7 @@ var zh = {
|
|
|
1202
2040
|
"settings.row.temperature.label": "\u6E29\u5EA6",
|
|
1203
2041
|
"settings.row.temperature.hint": "\u91C7\u6837\u6E29\u5EA6\uFF080~1\uFF0C\u6B65\u8FDB 0.05\uFF09\uFF0C\u8D8A\u4F4E\u8D8A\u5FE0\u5B9E\u539F\u6587\uFF1B\u9ED8\u8BA4 0.3\u3002",
|
|
1204
2042
|
"settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
|
|
1205
|
-
"settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\
|
|
2043
|
+
"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\u6A21\u578B\u9ED8\u8BA4\u300D\u8868\u793A\u4E0D\u53D1\u9001\u8BE5\u5B57\u6BB5\uFF0C\u7531\u63D0\u4F9B\u65B9\u4F7F\u7528\u9ED8\u8BA4\u6863\u3002",
|
|
1206
2044
|
"settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
|
|
1207
2045
|
"settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
|
|
1208
2046
|
"settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
|
|
@@ -1227,23 +2065,36 @@ var zh = {
|
|
|
1227
2065
|
"settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
|
|
1228
2066
|
"settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
|
|
1229
2067
|
"settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
|
|
1230
|
-
"settings.reasoning.inherit": "\
|
|
2068
|
+
"settings.reasoning.inherit": "\u6A21\u578B\u9ED8\u8BA4",
|
|
1231
2069
|
"settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
|
|
1232
2070
|
"settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u5217\u8868\uFF1B\u5DF2\u4FDD\u5B58\u7684\u6863\u4F4D\u4ECD\u4F1A\u7167\u5E38\u53D1\u9001\u3002",
|
|
1233
|
-
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\
|
|
2071
|
+
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF1B\u8C03\u7528\u65F6\u4E0D\u53D1\u9001\u6863\u4F4D\uFF0C\u7531\u63D0\u4F9B\u65B9\u51B3\u5B9A\u3002",
|
|
1234
2072
|
"settings.reasoning.unsupported": "\u5F53\u524D\u503C\u300C{effort}\u300D\u4E0D\u5728\u8BE5\u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\u4E2D\u3002",
|
|
1235
2073
|
"settings.reasoning.current": "\u5F53\u524D\u503C\uFF1A{value}",
|
|
1236
2074
|
"settings.reasoning.currentTitle": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u6B64\u6863\u4F4D",
|
|
1237
|
-
"settings.reasoning.refresh": "\
|
|
2075
|
+
"settings.reasoning.refresh": "\u5237\u65B0",
|
|
1238
2076
|
"settings.reasoning.refreshing": "\u6B63\u5728\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u2026",
|
|
1239
2077
|
"settings.reasoning.refreshOk": "\u6863\u4F4D\u4FE1\u606F\u5DF2\u66F4\u65B0",
|
|
1240
2078
|
"settings.reasoning.refreshFailed": "\u83B7\u53D6\u6863\u4F4D\u4FE1\u606F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
|
|
1241
2079
|
};
|
|
1242
2080
|
var en = {
|
|
1243
|
-
"button.title": "Enhance prompt",
|
|
2081
|
+
"button.title": "Enhance prompt \xB7 rewrite the text in the input box",
|
|
1244
2082
|
"button.busy": "Enhancing\u2026",
|
|
1245
|
-
"button.otherBusy": "Another session is enhancing right now
|
|
1246
|
-
"button.emptyTitle": "Enhance prompt
|
|
2083
|
+
"button.otherBusy": "Another session is enhancing right now",
|
|
2084
|
+
"button.emptyTitle": "Enhance prompt \xB7 type the text to rewrite first",
|
|
2085
|
+
"button.quickHint": " (right-click to configure)",
|
|
2086
|
+
"menu.title": "Quick settings",
|
|
2087
|
+
"menu.model": "Model",
|
|
2088
|
+
"menu.modelFollow": "Follow session",
|
|
2089
|
+
"menu.modelHint": "Change it on the plugin settings page",
|
|
2090
|
+
"menu.effortsNone": "This model declares no reasoning tiers",
|
|
2091
|
+
"menu.effortsFailed": "Could not read this model tiers",
|
|
2092
|
+
"menu.effort": "Reasoning effort",
|
|
2093
|
+
"menu.effortDefault": "Model default",
|
|
2094
|
+
"menu.context": "Context awareness",
|
|
2095
|
+
"menu.contextOn": "on",
|
|
2096
|
+
"menu.contextOff": "off",
|
|
2097
|
+
"menu.writeFailed": "Could not save \u2014 try again.",
|
|
1247
2098
|
"panel.title": "Prompt Enhance",
|
|
1248
2099
|
"panel.loading": "Enhancing, please wait\u2026",
|
|
1249
2100
|
"panel.streaming": "Generating\u2026",
|
|
@@ -1258,12 +2109,20 @@ var en = {
|
|
|
1258
2109
|
"panel.copied": "Copied",
|
|
1259
2110
|
"panel.copyFailed": "Copy failed",
|
|
1260
2111
|
"panel.close": "Close",
|
|
2112
|
+
"panel.collapse": "Collapse",
|
|
2113
|
+
"panel.expand": "Expand",
|
|
1261
2114
|
"panel.retry": "Retry",
|
|
1262
|
-
"panel.stale.warn": "Draft changed \u2014 this result uses the earlier text; Apply overwrites the
|
|
1263
|
-
"panel.truncated": 'Output
|
|
2115
|
+
"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).",
|
|
2116
|
+
"panel.truncated": 'Output was cut at the output limit, so the result may be incomplete. Raise "Output token budget" in the settings, then regenerate.',
|
|
2117
|
+
"panel.contextUsage": "Context usage",
|
|
2118
|
+
"panel.contextStats": "Context {turns}/{maxTurns} turns \xB7 {chars}/{maxChars} chars ({percent}%)",
|
|
2119
|
+
"panel.contextCharsLimited": "Character cap reached; earlier turns were not sent",
|
|
2120
|
+
"panel.contextCut": "Character limit reached; only the opening of the latest turn was sent",
|
|
2121
|
+
"panel.contextUnused": "No conversation context was used for this call",
|
|
1264
2122
|
"panel.model": "Model: {provider} / {model}",
|
|
1265
2123
|
"panel.elapsed": "{ms} elapsed",
|
|
1266
2124
|
"panel.tokens": "{total} tokens",
|
|
2125
|
+
"panel.effortDefault": "Model default",
|
|
1267
2126
|
"panel.tokens.input": "Input {count}",
|
|
1268
2127
|
"panel.tokens.output": "Output {count}",
|
|
1269
2128
|
"panel.tokens.cacheRead": "Cache read {count}",
|
|
@@ -1272,17 +2131,17 @@ var en = {
|
|
|
1272
2131
|
"undo.undo": "Undo",
|
|
1273
2132
|
"undo.dismiss": "Dismiss",
|
|
1274
2133
|
"error.empty": "The input box is empty \u2014 type a prompt to enhance first.",
|
|
1275
|
-
"error.tooLong": "The draft is {count} characters,
|
|
2134
|
+
"error.tooLong": "The draft is {count} characters, over the {max} limit (characters, not tokens); it is never truncated automatically \u2014 please shorten it.",
|
|
1276
2135
|
"error.occurrences": "The draft contains commands or file references, which are not supported yet \u2014 remove them first.",
|
|
1277
|
-
"error.chipsUnknown": "The composer reference state could not be read
|
|
2136
|
+
"error.chipsUnknown": "The composer reference state could not be read, so the enhancement was blocked to avoid overwriting your command or file reference. Use plain text, then retry.",
|
|
1278
2137
|
"error.phase": "The input box is busy (submitting) \u2014 try again in a moment.",
|
|
1279
|
-
"error.disabled": "Prompt enhance is disabled in the plugin settings.",
|
|
1280
|
-
"error.rejected": "The enhance request was rejected.",
|
|
1281
|
-
"error.timeout":
|
|
1282
|
-
"error.unconfigured": "No model
|
|
1283
|
-
"error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "
|
|
1284
|
-
"error.upstream": "The model provider returned an error.
|
|
1285
|
-
"error.internal": "Enhancement failed. Retry;
|
|
2138
|
+
"error.disabled": "Prompt enhance is disabled in the plugin settings; re-enable it there.",
|
|
2139
|
+
"error.rejected": "The enhance request was rejected. Retry later; if it persists, check the plugin settings.",
|
|
2140
|
+
"error.timeout": 'The enhancement timed out ({seconds}s). Retry, or raise "Timeout (ms)" in the settings; your draft is untouched.',
|
|
2141
|
+
"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.",
|
|
2142
|
+
"error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "Model default".',
|
|
2143
|
+
"error.upstream": "The model provider returned an error. If there is detail below, act on it; otherwise retry. Your draft is untouched.",
|
|
2144
|
+
"error.internal": "Enhancement failed. Retry; if it keeps failing, check the dsh logs. Your draft is untouched.",
|
|
1286
2145
|
"error.client.unreachable": "Cannot reach the host service \u2014 make sure dsh web is running, then retry.",
|
|
1287
2146
|
"error.client.malformed": "The host returned data that could not be parsed. Retry; your draft is untouched.",
|
|
1288
2147
|
"error.client.refused": "The host refused the request (HTTP {status}). Retry later.",
|
|
@@ -1290,7 +2149,7 @@ var en = {
|
|
|
1290
2149
|
"error.client.cancelled": "The enhancement was cancelled; your draft is untouched.",
|
|
1291
2150
|
"error.rateLimit": "Too many requests \u2014 at most {limit} enhancements per minute; retry in {retryAfterSeconds} seconds.",
|
|
1292
2151
|
"error.concurrencyLimit": "{max} enhancements are already running \u2014 wait for one to finish, then retry.",
|
|
1293
|
-
"error.cooldown": "{failures} enhancements failed in a row; calls are paused to stop hammering the model service. Retry
|
|
2152
|
+
"error.cooldown": "{failures} enhancements failed in a row; calls are paused for {retryAfterSeconds}s to stop hammering the model service. Retry later, or check the model settings first.",
|
|
1294
2153
|
"error.upstream.auth": "Authentication failed \u2014 check the API key configured for this provider.",
|
|
1295
2154
|
"error.upstream.invalidCredential": "Authentication failed \u2014 the stored API key is invalid; fix it and retry.",
|
|
1296
2155
|
"error.upstream.rateLimit": "The model provider is rate-limiting; retry later.",
|
|
@@ -1298,7 +2157,7 @@ var en = {
|
|
|
1298
2157
|
"error.upstream.empty": "The model returned an empty response; retry.",
|
|
1299
2158
|
"error.upstream.contextWindow": "The input exceeds the model context window \u2014 shorten it or switch models.",
|
|
1300
2159
|
"error.upstream.toolCall": "The model requested tool calls, but prompt enhance needs plain text \u2014 switch models and retry.",
|
|
1301
|
-
"error.upstream.maxTokens":
|
|
2160
|
+
"error.upstream.maxTokens": 'The rewrite hit the "Output token budget" limit \u2014 raise that setting or shorten the draft, then retry.',
|
|
1302
2161
|
"settings.summary": "Model, context, and resource limits",
|
|
1303
2162
|
"settings.title": "Prompt enhance",
|
|
1304
2163
|
"settings.description": "Turns a composer draft into a structured prompt: role and goal, executable steps, output format, acceptance criteria, edge cases. The draft is preserved, failures never touch it, and saved values apply to the next call.",
|
|
@@ -1312,6 +2171,11 @@ var en = {
|
|
|
1312
2171
|
"settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
|
|
1313
2172
|
"settings.reset": "Reset to default",
|
|
1314
2173
|
"settings.invalidNumber": "Enter a number, or leave blank to use the default.",
|
|
2174
|
+
"settings.record": "Record",
|
|
2175
|
+
"settings.recordStop": "Stop recording",
|
|
2176
|
+
"settings.recordPrompt": "Press the key combination (Esc to cancel)",
|
|
2177
|
+
"settings.recordNeedsModifier": "Hold at least one of ctrl / alt / meta",
|
|
2178
|
+
"settings.invalidShortcut": "Invalid shortcut - it would never fire: use at least one of ctrl / alt / meta and put the key last, e.g. ctrl+alt+e.",
|
|
1315
2179
|
"settings.disconnected": "This page has no form: the host did not project its form store. The plugin keeps working with its composition config.",
|
|
1316
2180
|
"settings.row.enabled.label": "Master switch",
|
|
1317
2181
|
"settings.row.enabled.hint": "Off hides the composer button and disables the command and the shortcut.",
|
|
@@ -1319,6 +2183,10 @@ var en = {
|
|
|
1319
2183
|
"settings.row.contextAware.hint": "Reads the recent turns of the current conversation; falls back to a single-prompt rewrite when there is no history.",
|
|
1320
2184
|
"settings.row.streaming.label": "Streaming display",
|
|
1321
2185
|
"settings.row.streaming.hint": "Shows the rewrite while it is being written. Display only: the applied text is unchanged.",
|
|
2186
|
+
"settings.row.foldAnimation.label": "Card fold animation",
|
|
2187
|
+
"settings.row.foldAnimation.hint": 'Plays the expand/collapse transition; off switches instantly. The system "reduce motion" preference always wins.',
|
|
2188
|
+
"settings.row.autoFold.label": "Fold the card automatically",
|
|
2189
|
+
"settings.row.autoFold.hint": "Folds the card after Apply and re-opens it after Undo; off leaves the card as it is.",
|
|
1322
2190
|
"settings.row.provider.label": "Model provider",
|
|
1323
2191
|
"settings.row.provider.hint": "Pick a registered DSH LLM provider; leave empty to follow the current session\u2019s model.",
|
|
1324
2192
|
"settings.row.model.label": "Model id",
|
|
@@ -1345,7 +2213,7 @@ var en = {
|
|
|
1345
2213
|
"settings.row.temperature.label": "Temperature",
|
|
1346
2214
|
"settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
|
|
1347
2215
|
"settings.row.reasoningEffort.label": "Reasoning effort",
|
|
1348
|
-
"settings.row.reasoningEffort.hint":
|
|
2216
|
+
"settings.row.reasoningEffort.hint": 'Tier choices come from what the configured provider/model declares; custom models are read on demand. "Model default" means the field is omitted and the provider applies its default.',
|
|
1349
2217
|
"settings.row.maxOutputTokens.label": "Output token budget",
|
|
1350
2218
|
"settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
|
|
1351
2219
|
"settings.row.maxInputChars.label": "Input character cap",
|
|
@@ -1370,14 +2238,14 @@ var en = {
|
|
|
1370
2238
|
"settings.row.shortcut.placeholder": "e.g. ctrl+alt+shift+e",
|
|
1371
2239
|
"settings.strategy.replace": "Replace the built-in strategy",
|
|
1372
2240
|
"settings.strategy.extend": "Append after the built-in strategy",
|
|
1373
|
-
"settings.reasoning.inherit": "
|
|
2241
|
+
"settings.reasoning.inherit": "Model default",
|
|
1374
2242
|
"settings.reasoning.loading": "Reading this model\u2019s tiers\u2026",
|
|
1375
2243
|
"settings.reasoning.unavailable": "Could not read this model\u2019s tier list; your saved tier is still sent.",
|
|
1376
|
-
"settings.reasoning.noTiers": "This model declares no reasoning tiers; calls
|
|
2244
|
+
"settings.reasoning.noTiers": "This model declares no reasoning tiers; calls omit the field and let the provider decide.",
|
|
1377
2245
|
"settings.reasoning.unsupported": "The current value \u201C{effort}\u201D is not one of this model\u2019s tiers.",
|
|
1378
2246
|
"settings.reasoning.current": "Current value: {value}",
|
|
1379
2247
|
"settings.reasoning.currentTitle": "This model does not declare this tier",
|
|
1380
|
-
"settings.reasoning.refresh": "
|
|
2248
|
+
"settings.reasoning.refresh": "Refresh",
|
|
1381
2249
|
"settings.reasoning.refreshing": "Loading tier info\u2026",
|
|
1382
2250
|
"settings.reasoning.refreshOk": "Tier info updated",
|
|
1383
2251
|
"settings.reasoning.refreshFailed": "Could not load tier info \u2014 please retry."
|
|
@@ -1388,9 +2256,16 @@ var NS = "dsh-prompt-enhance";
|
|
|
1388
2256
|
// src/client/styles.ts
|
|
1389
2257
|
var STYLE_ID = "dsh-prompt-enhance-styles";
|
|
1390
2258
|
var CSS = `
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
2259
|
+
/* One palette for everything the plugin paints into the dock: the result card
|
|
2260
|
+
and the standalone undo row are siblings, so the tokens live on their shared
|
|
2261
|
+
parent instead of on the card alone (a child could not reach its sibling's
|
|
2262
|
+
variables, which is why the undo row used to re-derive its own colors). The
|
|
2263
|
+
quick-settings menu lives in the composer slot instead, so it joins the same
|
|
2264
|
+
rule to read the same palette. */
|
|
2265
|
+
.dsh-pe-dock {
|
|
2266
|
+
width: 100%;
|
|
2267
|
+
}
|
|
2268
|
+
.dsh-pe-dock {
|
|
1394
2269
|
--pe-bg: var(--dsw-alias-bg-layer-1, #1f2127);
|
|
1395
2270
|
--pe-fg: var(--dsw-alias-label-primary, #e6e8ee);
|
|
1396
2271
|
--pe-fg-dim: var(--dsw-alias-label-secondary, rgba(230, 232, 238, 0.55));
|
|
@@ -1399,11 +2274,234 @@ var CSS = `
|
|
|
1399
2274
|
/* No hover token exists: a neutral grey alpha is already theme-agnostic. */
|
|
1400
2275
|
--pe-hover: rgba(127, 127, 127, 0.18);
|
|
1401
2276
|
--pe-danger: var(--dsw-alias-state-error-primary, #ffb4a8);
|
|
2277
|
+
--pe-success: var(--dsw-alias-state-success-primary, #2da44e);
|
|
1402
2278
|
--pe-warn-fg: var(--dsw-alias-state-warn-primary, #e8c07d);
|
|
1403
2279
|
/* Tints of the themed warning color, so the banner cannot keep an amber cast
|
|
1404
2280
|
from the other scheme. */
|
|
1405
2281
|
--pe-warn-border: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 35%, transparent);
|
|
1406
2282
|
--pe-warn-bg: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 12%, transparent);
|
|
2283
|
+
}
|
|
2284
|
+
/* Quick-settings menu, copied from the shell's own menu primitives:
|
|
2285
|
+
- the card surface is MenuSurface.module.css (radius-lg, elevation stroke,
|
|
2286
|
+
prominent shadow) with the menu fill over an opaque bg-base, so a
|
|
2287
|
+
translucent fill never shows the page through it;
|
|
2288
|
+
- rows and the trailing check are Menu.module.css (.item / .label /
|
|
2289
|
+
.separator / .check);
|
|
2290
|
+
- the check artwork is the exact check-outline regular glyph from
|
|
2291
|
+
@deepseek-ai/dsh-client-ui-primitives (16-unit viewBox, 1px stroke),
|
|
2292
|
+
painted at the shell's 14x14 check size through a mask. */
|
|
2293
|
+
.dsh-pe-menu {
|
|
2294
|
+
z-index: 1100;
|
|
2295
|
+
display: flex;
|
|
2296
|
+
flex-direction: column;
|
|
2297
|
+
box-sizing: border-box;
|
|
2298
|
+
/* The shell's model-menu card (ModelSelect.module.css .menu) is the closest
|
|
2299
|
+
relative of this card and starts at 240px, so a short value like "Off" does
|
|
2300
|
+
not leave the card cramped; the primitive's 144px floor is for plain lists. */
|
|
2301
|
+
min-width: min(240px, 100vw - 24px);
|
|
2302
|
+
max-width: min(360px, 100vw - 24px);
|
|
2303
|
+
padding: 4px;
|
|
2304
|
+
border: 0;
|
|
2305
|
+
border-radius: var(--dsw-radius-lg, 12px);
|
|
2306
|
+
--dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
|
|
2307
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2308
|
+
box-shadow: var(--dsw-elevation-prominent, 0 12px 32px rgba(0, 0, 0, 0.24));
|
|
2309
|
+
cursor: default;
|
|
2310
|
+
/* The host isolates the card so the material below never becomes a backdrop
|
|
2311
|
+
root for nested menus; matching the shell keeps the blur behaviour equal. */
|
|
2312
|
+
isolation: isolate;
|
|
2313
|
+
}
|
|
2314
|
+
/* The material, exactly as MenuSurface.module.css paints it (the host uses a
|
|
2315
|
+
child element with z-index:-1; a pseudo-element is the same layer without
|
|
2316
|
+
touching the component): menu fill + backdrop blur. */
|
|
2317
|
+
.dsh-pe-menu::before {
|
|
2318
|
+
content: '';
|
|
2319
|
+
position: absolute;
|
|
2320
|
+
inset: 0;
|
|
2321
|
+
z-index: -1;
|
|
2322
|
+
border-radius: inherit;
|
|
2323
|
+
background: var(--dsw-menu-surface-fill, rgba(255, 255, 255, 0.96));
|
|
2324
|
+
-webkit-backdrop-filter: var(--dsw-menu-backdrop-filter, blur(12px));
|
|
2325
|
+
backdrop-filter: var(--dsw-menu-backdrop-filter, blur(12px));
|
|
2326
|
+
pointer-events: none;
|
|
2327
|
+
}
|
|
2328
|
+
/* macOS: the host backs the material with an opaque layer (its .backing
|
|
2329
|
+
element) because Chromium needs opaque pixels behind page content to blur it
|
|
2330
|
+
over native vibrancy. One opaque base colour on the card is that layer here. */
|
|
2331
|
+
html[data-platform='darwin'] .dsh-pe-menu {
|
|
2332
|
+
background-color: var(--dsw-alias-bg-base, #ffffff);
|
|
2333
|
+
}
|
|
2334
|
+
.dsh-pe-menu-group { display: flex; flex-direction: column; }
|
|
2335
|
+
|
|
2336
|
+
.dsh-pe-menu-item {
|
|
2337
|
+
display: flex;
|
|
2338
|
+
align-items: center;
|
|
2339
|
+
gap: 6px;
|
|
2340
|
+
width: 100%;
|
|
2341
|
+
min-height: 34px;
|
|
2342
|
+
padding: 6px 8px;
|
|
2343
|
+
border: none;
|
|
2344
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2345
|
+
background: transparent;
|
|
2346
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2347
|
+
font: inherit;
|
|
2348
|
+
font-size: 13px;
|
|
2349
|
+
line-height: 20px;
|
|
2350
|
+
text-align: left;
|
|
2351
|
+
cursor: pointer;
|
|
2352
|
+
}
|
|
2353
|
+
.dsh-pe-menu-item:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
|
|
2354
|
+
.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
|
|
2355
|
+
tertiary, a 12px chevron in the menu-icon tone) so the card reads as one
|
|
2356
|
+
compact row until the list is opened. */
|
|
2357
|
+
.dsh-pe-menu-cell {
|
|
2358
|
+
height: 34px;
|
|
2359
|
+
min-height: 34px;
|
|
2360
|
+
padding: 0 8px;
|
|
2361
|
+
}
|
|
2362
|
+
/* Read-only route row: the cell metrics without a pointer or hover, because the
|
|
2363
|
+
value is changed on the plugin settings page, not here. */
|
|
2364
|
+
.dsh-pe-menu-info {
|
|
2365
|
+
display: flex;
|
|
2366
|
+
align-items: center;
|
|
2367
|
+
gap: 6px;
|
|
2368
|
+
min-height: 34px;
|
|
2369
|
+
padding: 0 8px;
|
|
2370
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2371
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2372
|
+
font-size: 13px;
|
|
2373
|
+
line-height: 20px;
|
|
2374
|
+
cursor: default;
|
|
2375
|
+
}
|
|
2376
|
+
.dsh-pe-menu-info .dsh-pe-menu-label { flex: 0 0 auto; }
|
|
2377
|
+
.dsh-pe-menu-info .dsh-pe-menu-state {
|
|
2378
|
+
flex: 1 1 auto;
|
|
2379
|
+
min-width: 0;
|
|
2380
|
+
margin-left: 0;
|
|
2381
|
+
overflow: hidden;
|
|
2382
|
+
text-align: right;
|
|
2383
|
+
text-overflow: ellipsis;
|
|
2384
|
+
white-space: nowrap;
|
|
2385
|
+
}
|
|
2386
|
+
.dsh-pe-menu-cell .dsh-pe-menu-label { flex: 0 0 auto; }
|
|
2387
|
+
.dsh-pe-menu-cell .dsh-pe-menu-state {
|
|
2388
|
+
flex: 1 1 auto;
|
|
2389
|
+
min-width: 0;
|
|
2390
|
+
margin-left: 0;
|
|
2391
|
+
overflow: hidden;
|
|
2392
|
+
text-align: right;
|
|
2393
|
+
text-overflow: ellipsis;
|
|
2394
|
+
white-space: nowrap;
|
|
2395
|
+
}
|
|
2396
|
+
/* The chevron is the shell's own chevron-right-outline artwork (16-unit
|
|
2397
|
+
viewBox, 1px stroke) masked at the model menu's 12px cell size; it turns to
|
|
2398
|
+
point down while the list is open. */
|
|
2399
|
+
.dsh-pe-menu-chevron {
|
|
2400
|
+
flex: none;
|
|
2401
|
+
width: 12px;
|
|
2402
|
+
height: 12px;
|
|
2403
|
+
color: var(--dsw-alias-menu-icon, var(--dsw-alias-label-tertiary, inherit));
|
|
2404
|
+
background-color: currentColor;
|
|
2405
|
+
-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");
|
|
2406
|
+
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");
|
|
2407
|
+
-webkit-mask-size: 16px 16px;
|
|
2408
|
+
mask-size: 16px 16px;
|
|
2409
|
+
-webkit-mask-repeat: no-repeat;
|
|
2410
|
+
mask-repeat: no-repeat;
|
|
2411
|
+
-webkit-mask-position: center;
|
|
2412
|
+
mask-position: center;
|
|
2413
|
+
transition: transform 120ms ease;
|
|
2414
|
+
}
|
|
2415
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2416
|
+
.dsh-pe-menu-chevron { transition: none; }
|
|
2417
|
+
}
|
|
2418
|
+
.dsh-pe-menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2419
|
+
.dsh-pe-menu-state { flex: none; margin-left: auto; color: var(--dsw-alias-label-tertiary, inherit); }
|
|
2420
|
+
/* The shell's check: a 14x14 icon in label-primary. The text glyph is hidden
|
|
2421
|
+
and the exact outline artwork is masked in, so the shape, weight and size
|
|
2422
|
+
are the shell's own. */
|
|
2423
|
+
.dsh-pe-menu-mark {
|
|
2424
|
+
flex: none;
|
|
2425
|
+
width: 14px;
|
|
2426
|
+
height: 14px;
|
|
2427
|
+
margin-left: auto;
|
|
2428
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2429
|
+
font-size: 0;
|
|
2430
|
+
background-color: transparent;
|
|
2431
|
+
-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");
|
|
2432
|
+
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");
|
|
2433
|
+
-webkit-mask-size: 14px 14px;
|
|
2434
|
+
mask-size: 14px 14px;
|
|
2435
|
+
-webkit-mask-repeat: no-repeat;
|
|
2436
|
+
mask-repeat: no-repeat;
|
|
2437
|
+
-webkit-mask-position: center;
|
|
2438
|
+
mask-position: center;
|
|
2439
|
+
}
|
|
2440
|
+
.dsh-pe-menu-item[aria-checked='true'] .dsh-pe-menu-mark { background-color: currentColor; }
|
|
2441
|
+
/* The context switch row, copied from the shell's TeamModeToggle row: the label
|
|
2442
|
+
on the left, the shell's own switch on the right, and the whole row (minus
|
|
2443
|
+
nothing here) as the switch's hit target. */
|
|
2444
|
+
.dsh-pe-menu-switch {
|
|
2445
|
+
position: relative;
|
|
2446
|
+
display: flex;
|
|
2447
|
+
align-items: center;
|
|
2448
|
+
justify-content: space-between;
|
|
2449
|
+
gap: 16px;
|
|
2450
|
+
min-height: 34px;
|
|
2451
|
+
padding: 0 8px;
|
|
2452
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2453
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
2454
|
+
font-size: 13px;
|
|
2455
|
+
line-height: 20px;
|
|
2456
|
+
}
|
|
2457
|
+
.dsh-pe-menu-switch-label {
|
|
2458
|
+
display: inline-flex;
|
|
2459
|
+
align-items: center;
|
|
2460
|
+
gap: 4px;
|
|
2461
|
+
min-width: 0;
|
|
2462
|
+
}
|
|
2463
|
+
/* Extend the native switch hit target over the whole row. */
|
|
2464
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input { position: static; }
|
|
2465
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input::after {
|
|
2466
|
+
content: '';
|
|
2467
|
+
position: absolute;
|
|
2468
|
+
inset: 0;
|
|
2469
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
2470
|
+
}
|
|
2471
|
+
.dsh-pe-menu-switch:has(.dsh-pe-menu-switch-input:focus-visible) {
|
|
2472
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
|
|
2473
|
+
}
|
|
2474
|
+
/* The shell switch animates its thumb; its track colour is driven straight by
|
|
2475
|
+
aria-checked, so both get the same 120ms transition here, and both stop when
|
|
2476
|
+
the user asks for reduced motion. */
|
|
2477
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input {
|
|
2478
|
+
transition: background-color 120ms ease;
|
|
2479
|
+
}
|
|
2480
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input > * {
|
|
2481
|
+
transition: transform 120ms ease, background-color 120ms ease;
|
|
2482
|
+
}
|
|
2483
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2484
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input,
|
|
2485
|
+
.dsh-pe-menu-switch .dsh-pe-menu-switch-input > * {
|
|
2486
|
+
transition: none;
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
@media (hover: hover) {
|
|
2490
|
+
.dsh-pe-menu-switch:has(.dsh-pe-menu-switch-input:not(:disabled)):hover {
|
|
2491
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
.dsh-pe-menu-sep { height: 0.5px; margin: 3px 8px; background: var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.25)); }
|
|
2495
|
+
.dsh-pe-menu-error { padding: 6px 8px; font-size: 12px; color: var(--dsw-alias-state-error-primary, #e5484d); }
|
|
2496
|
+
/* Why the tier list is empty: an explanation, not an error. */
|
|
2497
|
+
.dsh-pe-menu-note {
|
|
2498
|
+
padding: 4px 8px 6px;
|
|
2499
|
+
color: var(--dsw-alias-label-tertiary, inherit);
|
|
2500
|
+
font-size: 12px;
|
|
2501
|
+
line-height: 16px;
|
|
2502
|
+
}
|
|
2503
|
+
.dsh-pe-panel {
|
|
2504
|
+
box-sizing: border-box;
|
|
1407
2505
|
display: flex;
|
|
1408
2506
|
flex-direction: column;
|
|
1409
2507
|
width: 100%;
|
|
@@ -1414,7 +2512,46 @@ var CSS = `
|
|
|
1414
2512
|
color: var(--pe-fg);
|
|
1415
2513
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 14px rgba(0, 0, 0, 0.05);
|
|
1416
2514
|
overflow: hidden;
|
|
2515
|
+
/* The card is chrome: titles, badges, banners and button labels are not
|
|
2516
|
+
content to be selected. The two blocks the user may want to copy opt back
|
|
2517
|
+
in below (.dsh-pe-result-text, .dsh-pe-error). */
|
|
2518
|
+
-webkit-user-select: none;
|
|
2519
|
+
user-select: none;
|
|
1417
2520
|
}
|
|
2521
|
+
/* The body folds along a single grid track (1fr <-> 0fr): the height animates to
|
|
2522
|
+
the content's own size, so nothing is measured in JS and the fold can never
|
|
2523
|
+
overshoot a long result. The inner clips, and once the track has closed it
|
|
2524
|
+
also leaves the paint, selection and accessibility trees. */
|
|
2525
|
+
.dsh-pe-body {
|
|
2526
|
+
display: grid;
|
|
2527
|
+
grid-template-rows: 1fr;
|
|
2528
|
+
transition: grid-template-rows 160ms ease;
|
|
2529
|
+
}
|
|
2530
|
+
.dsh-pe-body > .dsh-pe-body-inner {
|
|
2531
|
+
min-height: 0;
|
|
2532
|
+
overflow: hidden;
|
|
2533
|
+
visibility: visible;
|
|
2534
|
+
transition: visibility 0s;
|
|
2535
|
+
}
|
|
2536
|
+
.dsh-pe-panel.is-collapsed .dsh-pe-body { grid-template-rows: 0fr; }
|
|
2537
|
+
.dsh-pe-panel.is-collapsed .dsh-pe-body > .dsh-pe-body-inner {
|
|
2538
|
+
visibility: hidden;
|
|
2539
|
+
/* Hidden only after the track has finished closing, so the fold is visible
|
|
2540
|
+
the whole way down; expanding drops the delay and shows it at once. */
|
|
2541
|
+
transition: visibility 0s linear 160ms;
|
|
2542
|
+
}
|
|
2543
|
+
/* The chevron turns with the fold, so the button and the body read as one gesture. */
|
|
2544
|
+
.dsh-pe-collapse svg { transition: transform 160ms ease; }
|
|
2545
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2546
|
+
.dsh-pe-body,
|
|
2547
|
+
.dsh-pe-body > .dsh-pe-body-inner,
|
|
2548
|
+
.dsh-pe-collapse svg { transition: none; }
|
|
2549
|
+
}
|
|
2550
|
+
/* The fold animation is a setting; switching it off makes the fold instant.
|
|
2551
|
+
The OS preference above still wins for users who ask for less motion. */
|
|
2552
|
+
.dsh-pe-panel.is-static .dsh-pe-body,
|
|
2553
|
+
.dsh-pe-panel.is-static .dsh-pe-body > .dsh-pe-body-inner,
|
|
2554
|
+
.dsh-pe-panel.is-static .dsh-pe-collapse svg { transition: none; }
|
|
1418
2555
|
.dsh-pe-head {
|
|
1419
2556
|
display: flex;
|
|
1420
2557
|
align-items: center;
|
|
@@ -1441,12 +2578,30 @@ var CSS = `
|
|
|
1441
2578
|
font-size: 11px;
|
|
1442
2579
|
opacity: 0.72;
|
|
1443
2580
|
white-space: nowrap;
|
|
2581
|
+
cursor: default;
|
|
2582
|
+
/* Four segments (model, elapsed, tokens, effort) can outgrow a narrow header:
|
|
2583
|
+
shrink with an ellipsis instead of pushing the fold and close controls. */
|
|
2584
|
+
max-width: 100%;
|
|
2585
|
+
overflow: hidden;
|
|
2586
|
+
text-overflow: ellipsis;
|
|
1444
2587
|
}
|
|
1445
|
-
|
|
2588
|
+
/* The close and collapse controls share one square hit target: same box, same
|
|
2589
|
+
hover surface, so the two glyphs read as a pair instead of one looking
|
|
2590
|
+
flatter than the other. */
|
|
2591
|
+
.dsh-pe-close,
|
|
2592
|
+
.dsh-pe-collapse {
|
|
2593
|
+
box-sizing: border-box;
|
|
1446
2594
|
border: none; background: transparent; color: inherit; opacity: 0.6;
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
2595
|
+
cursor: pointer; border-radius: 4px; padding: 0;
|
|
2596
|
+
width: 22px; height: 22px; line-height: 0;
|
|
2597
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
2598
|
+
}
|
|
2599
|
+
.dsh-pe-close { font-size: 15px; }
|
|
2600
|
+
.dsh-pe-close:hover,
|
|
2601
|
+
.dsh-pe-collapse:hover { opacity: 1; background: var(--pe-hover); }
|
|
2602
|
+
/* Collapsed, the warning banners live in the hidden body; this marker stands in
|
|
2603
|
+
for them so a stale or truncated result never folds away silently. */
|
|
2604
|
+
.dsh-pe-warn-dot { font-size: 15px; line-height: 1; color: var(--pe-warn-fg); }
|
|
1450
2605
|
.dsh-pe-result { padding: 2px 10px 6px; }
|
|
1451
2606
|
.dsh-pe-result-text {
|
|
1452
2607
|
margin: 0;
|
|
@@ -1458,6 +2613,9 @@ var CSS = `
|
|
|
1458
2613
|
font-family: inherit;
|
|
1459
2614
|
font-size: 12.5px;
|
|
1460
2615
|
line-height: 1.6;
|
|
2616
|
+
/* The one block in the card the user is expected to copy by hand. */
|
|
2617
|
+
-webkit-user-select: text;
|
|
2618
|
+
user-select: text;
|
|
1461
2619
|
}
|
|
1462
2620
|
.dsh-pe-col-title {
|
|
1463
2621
|
padding: 4px 10px 2px;
|
|
@@ -1471,6 +2629,10 @@ var CSS = `
|
|
|
1471
2629
|
line-height: 1.6;
|
|
1472
2630
|
color: var(--pe-danger);
|
|
1473
2631
|
white-space: pre-wrap;
|
|
2632
|
+
/* Selectable with its detail line: the provider message is what users paste
|
|
2633
|
+
into an issue when they report a failure. */
|
|
2634
|
+
-webkit-user-select: text;
|
|
2635
|
+
user-select: text;
|
|
1474
2636
|
}
|
|
1475
2637
|
.dsh-pe-error .dsh-pe-error-detail {
|
|
1476
2638
|
margin-top: 8px;
|
|
@@ -1507,6 +2669,112 @@ var CSS = `
|
|
|
1507
2669
|
border-top: 1px solid var(--pe-separator);
|
|
1508
2670
|
}
|
|
1509
2671
|
.dsh-pe-foot .dsh-pe-grow { flex: 1; }
|
|
2672
|
+
|
|
2673
|
+
/* The context-usage button sits at the quiet end of the footer, opposite the
|
|
2674
|
+
actions. Its tooltip opens upward into the card body, so no portal is needed
|
|
2675
|
+
and the card's own overflow clipping stays out of the way. */
|
|
2676
|
+
.dsh-pe-context-wrap {
|
|
2677
|
+
position: relative;
|
|
2678
|
+
display: inline-flex;
|
|
2679
|
+
}
|
|
2680
|
+
.dsh-pe-context {
|
|
2681
|
+
box-sizing: border-box;
|
|
2682
|
+
display: inline-flex;
|
|
2683
|
+
flex: none;
|
|
2684
|
+
align-items: center;
|
|
2685
|
+
justify-content: center;
|
|
2686
|
+
width: 28px;
|
|
2687
|
+
height: 28px;
|
|
2688
|
+
padding: 0;
|
|
2689
|
+
border: 0;
|
|
2690
|
+
border-radius: 8px;
|
|
2691
|
+
background: transparent;
|
|
2692
|
+
/* The glyph carries the state on its own: grey when the window is healthy,
|
|
2693
|
+
amber when it had to cut something. The precise counts stay in the
|
|
2694
|
+
tooltip. */
|
|
2695
|
+
--pe-context-accent: var(--dsw-alias-label-tertiary, #8a8a8a);
|
|
2696
|
+
color: var(--pe-context-accent);
|
|
2697
|
+
cursor: default;
|
|
2698
|
+
}
|
|
2699
|
+
.dsh-pe-context:hover { background: var(--pe-hover); }
|
|
2700
|
+
.dsh-pe-context.is-limited {
|
|
2701
|
+
--pe-context-accent: #b45309;
|
|
2702
|
+
color: var(--pe-context-accent);
|
|
2703
|
+
}
|
|
2704
|
+
/* The warning lives in the glyph alone by default; the amber tint appears on
|
|
2705
|
+
hover or keyboard focus, matching the plain state's on-demand background. */
|
|
2706
|
+
.dsh-pe-context.is-limited:hover,
|
|
2707
|
+
.dsh-pe-context.is-limited:focus-visible {
|
|
2708
|
+
background: rgba(180, 83, 9, 0.1);
|
|
2709
|
+
}
|
|
2710
|
+
.dsh-pe-context-icon {
|
|
2711
|
+
position: relative;
|
|
2712
|
+
z-index: 1;
|
|
2713
|
+
display: block;
|
|
2714
|
+
width: 20px;
|
|
2715
|
+
height: 20px;
|
|
2716
|
+
color: var(--pe-context-accent);
|
|
2717
|
+
}
|
|
2718
|
+
.dsh-pe-context-tip {
|
|
2719
|
+
position: absolute;
|
|
2720
|
+
left: 0;
|
|
2721
|
+
bottom: calc(100% + 8px);
|
|
2722
|
+
z-index: 5;
|
|
2723
|
+
display: flex;
|
|
2724
|
+
flex-direction: column;
|
|
2725
|
+
gap: 2px;
|
|
2726
|
+
box-sizing: border-box;
|
|
2727
|
+
width: max-content;
|
|
2728
|
+
max-width: min(340px, calc(100vw - 40px));
|
|
2729
|
+
padding: 6px 10px;
|
|
2730
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
2731
|
+
background: var(--dsw-alias-tooltip-bg, #2f2f2f);
|
|
2732
|
+
color: var(--dsw-alias-tooltip-label, #ffffff);
|
|
2733
|
+
font-size: 13px;
|
|
2734
|
+
line-height: 20px;
|
|
2735
|
+
font-variant-numeric: tabular-nums;
|
|
2736
|
+
white-space: normal;
|
|
2737
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
|
|
2738
|
+
pointer-events: none;
|
|
2739
|
+
animation: dsh-pe-context-tip-in 140ms ease-out;
|
|
2740
|
+
}
|
|
2741
|
+
/* The bubble needs an anchor: it floats above the icon and would otherwise
|
|
2742
|
+
read as disconnected from the footer. */
|
|
2743
|
+
.dsh-pe-context-tip::after {
|
|
2744
|
+
content: '';
|
|
2745
|
+
position: absolute;
|
|
2746
|
+
left: 12px;
|
|
2747
|
+
bottom: -5px;
|
|
2748
|
+
width: 0;
|
|
2749
|
+
height: 0;
|
|
2750
|
+
border-left: 5px solid transparent;
|
|
2751
|
+
border-right: 5px solid transparent;
|
|
2752
|
+
border-top: 5px solid var(--dsw-alias-tooltip-bg, #2f2f2f);
|
|
2753
|
+
}
|
|
2754
|
+
@keyframes dsh-pe-context-tip-in {
|
|
2755
|
+
from {
|
|
2756
|
+
opacity: 0;
|
|
2757
|
+
transform: translateY(2px);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2761
|
+
.dsh-pe-context-tip { animation: none; }
|
|
2762
|
+
}
|
|
2763
|
+
/* The stats line is one unit: a wrap that leaves the percentage alone reads
|
|
2764
|
+
as a layout bug. The reason line may wrap freely. */
|
|
2765
|
+
.dsh-pe-context-tip .dsh-pe-context-stats { white-space: nowrap; }
|
|
2766
|
+
.dsh-pe-context-tip .dsh-pe-context-reason { color: #f2c185; }
|
|
2767
|
+
/* Narrow viewports: the card itself is close to the viewport width, so the
|
|
2768
|
+
fixed tooltip width would clip. Give it a viewport-relative cap and let the
|
|
2769
|
+
stats line wrap instead of overflowing. */
|
|
2770
|
+
@media (max-width: 560px) {
|
|
2771
|
+
.dsh-pe-context-tip {
|
|
2772
|
+
min-width: 0;
|
|
2773
|
+
width: 230px;
|
|
2774
|
+
max-width: calc(100vw - 40px);
|
|
2775
|
+
}
|
|
2776
|
+
.dsh-pe-context-tip .dsh-pe-context-stats { white-space: normal; }
|
|
2777
|
+
}
|
|
1510
2778
|
.dsh-pe-btn-action {
|
|
1511
2779
|
box-sizing: border-box;
|
|
1512
2780
|
display: inline-flex;
|
|
@@ -1542,14 +2810,13 @@ var CSS = `
|
|
|
1542
2810
|
}
|
|
1543
2811
|
.dsh-pe-btn-action.plain { background: transparent; color: inherit; }
|
|
1544
2812
|
.dsh-pe-btn-action.plain:hover { background: var(--pe-hover); }
|
|
1545
|
-
/* A floor for
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
.dsh-pe-btn-swap { min-width: 96px; }
|
|
2813
|
+
/* A floor for every footer action button, so a button keeps a visible, clickable
|
|
2814
|
+
width even if its label ever collapses to nothing. The label-swap groups
|
|
2815
|
+
(.dsh-pe-swap) already make a button as wide as its longest label, and 96px is
|
|
2816
|
+
below every real content width here, so this never widens a labelled button in
|
|
2817
|
+
practice \u2014 it only bounds the empty case and keeps the single-label buttons
|
|
2818
|
+
(retry, cancel) the same size as the rest. */
|
|
2819
|
+
.dsh-pe-btn-floor { min-width: 96px; }
|
|
1553
2820
|
.dsh-pe-btn-action:disabled { opacity: 0.45; cursor: default; }
|
|
1554
2821
|
|
|
1555
2822
|
/* Both labels of the regenerate button share one cell, so the button is as wide
|
|
@@ -1588,6 +2855,9 @@ var CSS = `
|
|
|
1588
2855
|
.dsh-pe-btn:hover:not(:disabled) { opacity: 1; background: var(--pe-hover); }
|
|
1589
2856
|
.dsh-pe-btn.is-busy { cursor: progress; }
|
|
1590
2857
|
.dsh-pe-btn.is-blocked { cursor: progress; }
|
|
2858
|
+
/* Empty draft: dimmed and a forbidden pointer. The plain click really is inert
|
|
2859
|
+
here; the card stays reachable by right-click (long-press / Shift+F10) and the
|
|
2860
|
+
tooltip says so, so the cursor still marks "left click does nothing". */
|
|
1591
2861
|
.dsh-pe-btn.is-empty { opacity: 0.4; cursor: not-allowed; }
|
|
1592
2862
|
.dsh-pe-btn.is-empty:hover { opacity: 0.4; background: transparent; }
|
|
1593
2863
|
.dsh-pe-btn:disabled { opacity: 0.45; cursor: default; }
|
|
@@ -1601,15 +2871,19 @@ var CSS = `
|
|
|
1601
2871
|
width: fit-content;
|
|
1602
2872
|
margin-left: auto;
|
|
1603
2873
|
padding: 3px 6px 3px 10px;
|
|
1604
|
-
border: 1px solid var(--
|
|
2874
|
+
border: 1px solid var(--pe-border);
|
|
1605
2875
|
border-radius: 12px;
|
|
1606
|
-
background: var(--
|
|
2876
|
+
background: var(--pe-bg);
|
|
1607
2877
|
font-size: 12px;
|
|
1608
|
-
color:
|
|
2878
|
+
color: var(--pe-fg);
|
|
2879
|
+
/* The undo row is chrome too, like the card header and footer. */
|
|
2880
|
+
-webkit-user-select: none;
|
|
2881
|
+
user-select: none;
|
|
1609
2882
|
}
|
|
1610
2883
|
.dsh-pe-undo .dsh-pe-undo-check {
|
|
1611
|
-
|
|
1612
|
-
|
|
2884
|
+
display: inline-flex;
|
|
2885
|
+
align-items: center;
|
|
2886
|
+
color: var(--pe-success);
|
|
1613
2887
|
}
|
|
1614
2888
|
.dsh-pe-undo-link {
|
|
1615
2889
|
display: inline-flex;
|
|
@@ -1618,16 +2892,14 @@ var CSS = `
|
|
|
1618
2892
|
gap: 6px;
|
|
1619
2893
|
height: 28px;
|
|
1620
2894
|
padding: 0 10px;
|
|
1621
|
-
border: 1px solid var(--
|
|
2895
|
+
border: 1px solid var(--pe-border);
|
|
1622
2896
|
border-radius: 6px;
|
|
1623
2897
|
background: transparent;
|
|
1624
2898
|
color: inherit;
|
|
1625
2899
|
font-size: 12px;
|
|
1626
2900
|
cursor: pointer;
|
|
1627
|
-
transition: background-color 120ms ease;
|
|
1628
2901
|
}
|
|
1629
|
-
.dsh-pe-undo-link:hover { background:
|
|
1630
|
-
.dsh-pe-undo-link:active { background: rgba(127, 127, 127, 0.22); }
|
|
2902
|
+
.dsh-pe-undo-link:hover { background: var(--pe-hover); }
|
|
1631
2903
|
.dsh-pe-undo-x {
|
|
1632
2904
|
display: inline-flex;
|
|
1633
2905
|
align-items: center;
|
|
@@ -1638,12 +2910,20 @@ var CSS = `
|
|
|
1638
2910
|
border-radius: 6px;
|
|
1639
2911
|
background: transparent;
|
|
1640
2912
|
color: inherit;
|
|
1641
|
-
opacity: 0.
|
|
2913
|
+
opacity: 0.6;
|
|
1642
2914
|
cursor: pointer;
|
|
1643
2915
|
padding: 0;
|
|
1644
2916
|
font-size: 12px;
|
|
1645
2917
|
}
|
|
1646
|
-
.dsh-pe-undo-x:hover { opacity: 1; background: var(--
|
|
2918
|
+
.dsh-pe-undo-x:hover { opacity: 1; background: var(--pe-hover); }
|
|
2919
|
+
/* The host's segmented control slides its indicator with a 160ms transform
|
|
2920
|
+
transition. This row re-lists its options whenever a capability answer lands
|
|
2921
|
+
(loading -> ready, model switch, a cleared tier), so the pill would appear to
|
|
2922
|
+
fly in from outside the track while the option count changes under it. The
|
|
2923
|
+
selection change is the information here, not the motion. */
|
|
2924
|
+
.dsh-pe-segmented-labels > span[aria-hidden='true'] {
|
|
2925
|
+
transition: none !important;
|
|
2926
|
+
}
|
|
1647
2927
|
.dsh-pe-segmented-labels [role="tab"] {
|
|
1648
2928
|
min-width: 0;
|
|
1649
2929
|
overflow: hidden;
|
|
@@ -1651,20 +2931,25 @@ var CSS = `
|
|
|
1651
2931
|
text-align: center;
|
|
1652
2932
|
white-space: nowrap;
|
|
1653
2933
|
}
|
|
2934
|
+
/* The Advanced disclosure reads as one more settings row: same 13px/500 label
|
|
2935
|
+
tone as every row title, same vertical rhythm, and a 16px chevron drawn from
|
|
2936
|
+
the shell's chevron-down-outline artwork instead of a hand-drawn triangle. */
|
|
1654
2937
|
.dsh-pe-advanced {
|
|
1655
|
-
margin-top:
|
|
1656
|
-
border-top:
|
|
2938
|
+
margin-top: 4px;
|
|
2939
|
+
border-top: 0.5px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
|
|
1657
2940
|
}
|
|
2941
|
+
/* The shell's settings rows have no hover fill (its DisclosureRow only lifts the
|
|
2942
|
+
text tone), so the row keeps the page chrome and the glyph carries the state. */
|
|
1658
2943
|
.dsh-pe-advanced > summary {
|
|
1659
2944
|
display: flex;
|
|
1660
2945
|
align-items: center;
|
|
1661
2946
|
gap: 8px;
|
|
1662
|
-
|
|
1663
|
-
padding: 0 4px;
|
|
2947
|
+
padding: 12px 0;
|
|
1664
2948
|
list-style: none;
|
|
2949
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
1665
2950
|
font-size: 13px;
|
|
1666
2951
|
font-weight: 500;
|
|
1667
|
-
|
|
2952
|
+
line-height: 20px;
|
|
1668
2953
|
cursor: pointer;
|
|
1669
2954
|
user-select: none;
|
|
1670
2955
|
}
|
|
@@ -1673,26 +2958,42 @@ var CSS = `
|
|
|
1673
2958
|
.dsh-pe-advanced > summary::before {
|
|
1674
2959
|
content: '';
|
|
1675
2960
|
flex: none;
|
|
1676
|
-
width:
|
|
1677
|
-
height:
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
2961
|
+
width: 16px;
|
|
2962
|
+
height: 16px;
|
|
2963
|
+
color: var(--dsw-alias-label-tertiary, inherit);
|
|
2964
|
+
background-color: currentColor;
|
|
2965
|
+
-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");
|
|
2966
|
+
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");
|
|
2967
|
+
-webkit-mask-size: 16px 16px;
|
|
2968
|
+
mask-size: 16px 16px;
|
|
2969
|
+
-webkit-mask-repeat: no-repeat;
|
|
2970
|
+
mask-repeat: no-repeat;
|
|
2971
|
+
-webkit-mask-position: center;
|
|
2972
|
+
mask-position: center;
|
|
2973
|
+
/* Closed points at the collapsed content, open points down at it. */
|
|
2974
|
+
transform: rotate(-90deg);
|
|
1681
2975
|
transition: transform 120ms ease;
|
|
1682
2976
|
}
|
|
1683
|
-
.dsh-pe-advanced[open] > summary::before { transform:
|
|
2977
|
+
.dsh-pe-advanced[open] > summary::before { transform: none; }
|
|
1684
2978
|
.dsh-pe-advanced > summary:hover {
|
|
1685
|
-
color: var(--dsw-alias-label-
|
|
1686
|
-
|
|
1687
|
-
|
|
2979
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
2980
|
+
}
|
|
2981
|
+
.dsh-pe-advanced > summary:hover::before {
|
|
2982
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
1688
2983
|
}
|
|
1689
2984
|
.dsh-pe-advanced > summary:focus-visible {
|
|
1690
2985
|
outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
|
|
1691
2986
|
outline-offset: -2px;
|
|
1692
|
-
border-radius: 6px;
|
|
1693
2987
|
}
|
|
1694
|
-
|
|
2988
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2989
|
+
.dsh-pe-advanced > summary::before { transition: none; }
|
|
2990
|
+
}/* The footer already adds its own 12px top margin; after the disclosure that would
|
|
2991
|
+
double the header's bottom whitespace (12px padding + 12px margin) against the
|
|
2992
|
+
12px above it, so the two gaps are equalised here. */
|
|
1695
2993
|
.dsh-pe-advanced + .dsh-pe-form-footer { margin-top: 0; }
|
|
2994
|
+
/* Open: the first advanced row brings its own 12px top padding, so the header
|
|
2995
|
+
drops its bottom padding to keep the same rhythm between the two gaps. */
|
|
2996
|
+
.dsh-pe-advanced[open] > summary { padding-bottom: 0; }
|
|
1696
2997
|
.dsh-pe-chip-reset:hover:not(:disabled),
|
|
1697
2998
|
.dsh-pe-chip-refresh:hover:not(:disabled) {
|
|
1698
2999
|
--pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
|
|
@@ -1741,7 +3042,7 @@ var CSS = `
|
|
|
1741
3042
|
font-size: 12px;
|
|
1742
3043
|
cursor: pointer;
|
|
1743
3044
|
}
|
|
1744
|
-
.dsh-pe-save-button:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
|
|
3045
|
+
.dsh-pe-save-button:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
|
|
1745
3046
|
.dsh-pe-save-button:disabled { opacity: 0.5; cursor: default; }
|
|
1746
3047
|
`;
|
|
1747
3048
|
function ensureStyles() {
|
|
@@ -1791,6 +3092,28 @@ function matchesShortcut(event, combo) {
|
|
|
1791
3092
|
if (combo === null) return false;
|
|
1792
3093
|
return event.ctrlKey === combo.ctrl && event.altKey === combo.alt && event.shiftKey === combo.shift && event.metaKey === combo.meta && (event.code === combo.code || event.key.toLowerCase() === combo.key);
|
|
1793
3094
|
}
|
|
3095
|
+
function keyTokenOf(event) {
|
|
3096
|
+
const letter = /^Key([A-Z])$/.exec(event.code)?.[1];
|
|
3097
|
+
if (letter !== void 0) return letter.toLowerCase();
|
|
3098
|
+
const digit = /^Digit([0-9])$/.exec(event.code)?.[1];
|
|
3099
|
+
if (digit !== void 0) return digit;
|
|
3100
|
+
const fn = /^F([1-9]|1[0-2])$/.exec(event.code)?.[1];
|
|
3101
|
+
if (fn !== void 0) return `f${fn}`;
|
|
3102
|
+
const byKey = event.key.toLowerCase();
|
|
3103
|
+
return isKeyToken(byKey) ? byKey : null;
|
|
3104
|
+
}
|
|
3105
|
+
function shortcutSpecOf(event) {
|
|
3106
|
+
if (!event.ctrlKey && !event.altKey && !event.metaKey) return null;
|
|
3107
|
+
const token = keyTokenOf(event);
|
|
3108
|
+
if (token === null) return null;
|
|
3109
|
+
const parts = [];
|
|
3110
|
+
if (event.ctrlKey) parts.push("ctrl");
|
|
3111
|
+
if (event.altKey) parts.push("alt");
|
|
3112
|
+
if (event.shiftKey) parts.push("shift");
|
|
3113
|
+
if (event.metaKey) parts.push("meta");
|
|
3114
|
+
parts.push(token);
|
|
3115
|
+
return parts.join("+");
|
|
3116
|
+
}
|
|
1794
3117
|
|
|
1795
3118
|
// src/client/settings-source.ts
|
|
1796
3119
|
var RANK = {
|
|
@@ -1813,6 +3136,14 @@ function servedNamespaces(forms) {
|
|
|
1813
3136
|
return [];
|
|
1814
3137
|
}
|
|
1815
3138
|
}
|
|
3139
|
+
function adoptWriter(form, highest) {
|
|
3140
|
+
if (typeof form.set !== "function" || typeof form.unset !== "function") return;
|
|
3141
|
+
if (!highest && getSettingsWriter() !== void 0) return;
|
|
3142
|
+
setSettingsWriter({
|
|
3143
|
+
set: (field, value) => form.set?.(field, value) ?? Promise.resolve(false),
|
|
3144
|
+
unset: (field) => form.unset?.(field) ?? Promise.resolve(false)
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
1816
3147
|
function installClientSettingsSource(ctx, options) {
|
|
1817
3148
|
let rank = RANK.none;
|
|
1818
3149
|
const adopt = (next, section) => {
|
|
@@ -1853,6 +3184,7 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1853
3184
|
unsubscribeForm = void 0;
|
|
1854
3185
|
boundId = entryId;
|
|
1855
3186
|
adoptSnapshot(RANK.configForms, form);
|
|
3187
|
+
adoptWriter(form, true);
|
|
1856
3188
|
try {
|
|
1857
3189
|
unsubscribeForm = form.subscribe?.(() => adoptSnapshot(RANK.configForms, form));
|
|
1858
3190
|
} catch {
|
|
@@ -1881,212 +3213,76 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1881
3213
|
},
|
|
1882
3214
|
"dsh-prompt-enhance: settings namespace watch"
|
|
1883
3215
|
);
|
|
1884
|
-
}
|
|
1885
|
-
} catch {
|
|
1886
|
-
}
|
|
1887
|
-
});
|
|
1888
|
-
ctx.inject(["webUiSettings"], (binderCtx) => {
|
|
1889
|
-
const binder = binderCtx.webUiSettings;
|
|
1890
|
-
if (binder === void 0 || typeof binder.bind !== "function") return;
|
|
1891
|
-
let bound;
|
|
1892
|
-
for (const namespace of options.rowIds) {
|
|
1893
|
-
try {
|
|
1894
|
-
bound = binder.bind({ namespace });
|
|
1895
|
-
} catch {
|
|
1896
|
-
bound = void 0;
|
|
1897
|
-
}
|
|
1898
|
-
if (bound !== void 0) break;
|
|
1899
|
-
}
|
|
1900
|
-
if (bound === void 0) return;
|
|
1901
|
-
adoptSnapshot(RANK.binder, bound);
|
|
1902
|
-
let unsubscribe;
|
|
1903
|
-
try {
|
|
1904
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.binder, bound));
|
|
1905
|
-
} catch {
|
|
1906
|
-
unsubscribe = void 0;
|
|
1907
|
-
}
|
|
1908
|
-
ctx.effect(
|
|
1909
|
-
() => () => {
|
|
1910
|
-
try {
|
|
1911
|
-
unsubscribe?.();
|
|
1912
|
-
} catch {
|
|
1913
|
-
}
|
|
1914
|
-
},
|
|
1915
|
-
"dsh-prompt-enhance: settings binder mirror"
|
|
1916
|
-
);
|
|
1917
|
-
});
|
|
1918
|
-
ctx.inject(["settingsScope"], (scopeCtx) => {
|
|
1919
|
-
const scopeCtxLike = scopeCtx;
|
|
1920
|
-
const scope = scopeCtxLike.settingsScope;
|
|
1921
|
-
if (scope === void 0 || typeof scope.bind !== "function") return;
|
|
1922
|
-
let bound;
|
|
1923
|
-
try {
|
|
1924
|
-
bound = scope.bind({ namespace: options.rowIds[0] ?? "dsh-prompt-enhance", decode: (value) => value });
|
|
1925
|
-
} catch {
|
|
1926
|
-
return;
|
|
1927
|
-
}
|
|
1928
|
-
adoptSnapshot(RANK.legacyScope, bound);
|
|
1929
|
-
let unsubscribe;
|
|
1930
|
-
try {
|
|
1931
|
-
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.legacyScope, bound));
|
|
1932
|
-
} catch {
|
|
1933
|
-
unsubscribe = void 0;
|
|
1934
|
-
}
|
|
1935
|
-
ctx.effect(
|
|
1936
|
-
() => () => {
|
|
1937
|
-
try {
|
|
1938
|
-
unsubscribe?.();
|
|
1939
|
-
} catch {
|
|
1940
|
-
}
|
|
1941
|
-
},
|
|
1942
|
-
"dsh-prompt-enhance: settings scope mirror"
|
|
1943
|
-
);
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
// src/client/settings-page.tsx
|
|
1948
|
-
var import_react9 = require("react");
|
|
1949
|
-
|
|
1950
|
-
// src/client/llm-catalog.ts
|
|
1951
|
-
var import_react7 = require("react");
|
|
1952
|
-
|
|
1953
|
-
// src/shared/catalog.ts
|
|
1954
|
-
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
1955
|
-
var LLM_MODELS_ENDPOINT = "/dsh-prompt-enhance/llm-models";
|
|
1956
|
-
var LLM_ROUTE_CHECK_ENDPOINT = "/dsh-prompt-enhance/llm-route-check";
|
|
1957
|
-
|
|
1958
|
-
// src/client/llm-catalog.ts
|
|
1959
|
-
async function getJson(url, signal) {
|
|
1960
|
-
try {
|
|
1961
|
-
const response = await fetch(url, { signal, headers: { accept: "application/json" } });
|
|
1962
|
-
if (!response.ok) return void 0;
|
|
1963
|
-
const body = await response.json();
|
|
1964
|
-
const envelope = body;
|
|
1965
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) return void 0;
|
|
1966
|
-
return envelope.value;
|
|
1967
|
-
} catch {
|
|
1968
|
-
return void 0;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
function endpoint(path, params = {}) {
|
|
1972
|
-
const url = new URL(path, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
1973
|
-
for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
|
|
1974
|
-
return url;
|
|
1975
|
-
}
|
|
1976
|
-
async function fetchProviders(signal) {
|
|
1977
|
-
const value = await getJson(endpoint(LLM_PROVIDERS_ENDPOINT), signal);
|
|
1978
|
-
if (value === void 0 || !Array.isArray(value.providers)) return void 0;
|
|
1979
|
-
return value.providers.filter(
|
|
1980
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== "" && typeof entry.registered === "boolean"
|
|
1981
|
-
);
|
|
1982
|
-
}
|
|
1983
|
-
async function fetchModels(provider, signal) {
|
|
1984
|
-
const value = await getJson(endpoint(LLM_MODELS_ENDPOINT, { provider }), signal);
|
|
1985
|
-
if (value === void 0 || !Array.isArray(value.models)) return void 0;
|
|
1986
|
-
const models = value.models.filter(
|
|
1987
|
-
(entry) => entry !== null && typeof entry === "object" && typeof entry.id === "string" && entry.id !== "" && typeof entry.name === "string" && entry.name !== ""
|
|
1988
|
-
).map((entry) => ({
|
|
1989
|
-
id: entry.id,
|
|
1990
|
-
name: entry.name,
|
|
1991
|
-
...typeof entry.description === "string" && entry.description !== "" ? { description: entry.description } : {}
|
|
1992
|
-
}));
|
|
1993
|
-
return { models, ...typeof value.reason === "string" ? { reason: value.reason } : {} };
|
|
1994
|
-
}
|
|
1995
|
-
async function fetchRouteCheck(provider, model, signal) {
|
|
1996
|
-
const value = await getJson(endpoint(LLM_ROUTE_CHECK_ENDPOINT, { provider, model }), signal);
|
|
1997
|
-
if (value === void 0 || typeof value.available !== "boolean") return void 0;
|
|
1998
|
-
return value;
|
|
1999
|
-
}
|
|
2000
|
-
function useLlmRouting(provider, model) {
|
|
2001
|
-
const [providers, setProviders] = (0, import_react7.useState)([]);
|
|
2002
|
-
const [providersLoading, setProvidersLoading] = (0, import_react7.useState)(true);
|
|
2003
|
-
const [providersFailed, setProvidersFailed] = (0, import_react7.useState)(false);
|
|
2004
|
-
const [providersToken, setProvidersToken] = (0, import_react7.useState)(0);
|
|
2005
|
-
const [models, setModels] = (0, import_react7.useState)([]);
|
|
2006
|
-
const [modelsLoading, setModelsLoading] = (0, import_react7.useState)(false);
|
|
2007
|
-
const [modelsFailed, setModelsFailed] = (0, import_react7.useState)(false);
|
|
2008
|
-
const [modelsToken, setModelsToken] = (0, import_react7.useState)(0);
|
|
2009
|
-
const [routeChecking, setRouteChecking] = (0, import_react7.useState)(false);
|
|
2010
|
-
const [routeAvailable, setRouteAvailable] = (0, import_react7.useState)(void 0);
|
|
2011
|
-
(0, import_react7.useEffect)(() => {
|
|
2012
|
-
const controller = new AbortController();
|
|
2013
|
-
setProvidersLoading(true);
|
|
2014
|
-
setProvidersFailed(false);
|
|
2015
|
-
void fetchProviders(controller.signal).then((entries) => {
|
|
2016
|
-
if (controller.signal.aborted) return;
|
|
2017
|
-
setProvidersLoading(false);
|
|
2018
|
-
if (entries === void 0) {
|
|
2019
|
-
setProvidersFailed(true);
|
|
2020
|
-
setProviders([]);
|
|
2021
|
-
return;
|
|
2022
|
-
}
|
|
2023
|
-
setProviders(entries);
|
|
2024
|
-
});
|
|
2025
|
-
return () => controller.abort();
|
|
2026
|
-
}, [providersToken]);
|
|
2027
|
-
(0, import_react7.useEffect)(() => {
|
|
2028
|
-
if (provider === "") {
|
|
2029
|
-
setModels([]);
|
|
2030
|
-
setModelsLoading(false);
|
|
2031
|
-
setModelsFailed(false);
|
|
2032
|
-
return;
|
|
3216
|
+
}
|
|
3217
|
+
} catch {
|
|
2033
3218
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
3219
|
+
});
|
|
3220
|
+
ctx.inject(["webUiSettings"], (binderCtx) => {
|
|
3221
|
+
const binder = binderCtx.webUiSettings;
|
|
3222
|
+
if (binder === void 0 || typeof binder.bind !== "function") return;
|
|
3223
|
+
let bound;
|
|
3224
|
+
for (const namespace of options.rowIds) {
|
|
3225
|
+
try {
|
|
3226
|
+
bound = binder.bind({ namespace });
|
|
3227
|
+
} catch {
|
|
3228
|
+
bound = void 0;
|
|
2044
3229
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
3230
|
+
if (bound !== void 0) break;
|
|
3231
|
+
}
|
|
3232
|
+
if (bound === void 0) return;
|
|
3233
|
+
adoptSnapshot(RANK.binder, bound);
|
|
3234
|
+
adoptWriter(bound, false);
|
|
3235
|
+
let unsubscribe;
|
|
3236
|
+
try {
|
|
3237
|
+
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.binder, bound));
|
|
3238
|
+
} catch {
|
|
3239
|
+
unsubscribe = void 0;
|
|
3240
|
+
}
|
|
3241
|
+
ctx.effect(
|
|
3242
|
+
() => () => {
|
|
3243
|
+
try {
|
|
3244
|
+
unsubscribe?.();
|
|
3245
|
+
} catch {
|
|
3246
|
+
}
|
|
3247
|
+
},
|
|
3248
|
+
"dsh-prompt-enhance: settings binder mirror"
|
|
3249
|
+
);
|
|
3250
|
+
});
|
|
3251
|
+
ctx.inject(["settingsScope"], (scopeCtx) => {
|
|
3252
|
+
const scopeCtxLike = scopeCtx;
|
|
3253
|
+
const scope = scopeCtxLike.settingsScope;
|
|
3254
|
+
if (scope === void 0 || typeof scope.bind !== "function") return;
|
|
3255
|
+
let bound;
|
|
3256
|
+
try {
|
|
3257
|
+
bound = scope.bind({ namespace: options.rowIds[0] ?? "dsh-prompt-enhance", decode: (value) => value });
|
|
3258
|
+
} catch {
|
|
2054
3259
|
return;
|
|
2055
3260
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
failed: providersFailed,
|
|
2075
|
-
entries: providers,
|
|
2076
|
-
reload: () => setProvidersToken((token) => token + 1)
|
|
2077
|
-
},
|
|
2078
|
-
models: {
|
|
2079
|
-
loading: modelsLoading,
|
|
2080
|
-
failed: modelsFailed,
|
|
2081
|
-
entries: models,
|
|
2082
|
-
reload: () => setModelsToken((token) => token + 1)
|
|
2083
|
-
},
|
|
2084
|
-
route: { checking: routeChecking, available: routeAvailable }
|
|
2085
|
-
};
|
|
3261
|
+
adoptSnapshot(RANK.legacyScope, bound);
|
|
3262
|
+
adoptWriter(bound, false);
|
|
3263
|
+
let unsubscribe;
|
|
3264
|
+
try {
|
|
3265
|
+
unsubscribe = bound.subscribe?.(() => adoptSnapshot(RANK.legacyScope, bound));
|
|
3266
|
+
} catch {
|
|
3267
|
+
unsubscribe = void 0;
|
|
3268
|
+
}
|
|
3269
|
+
ctx.effect(
|
|
3270
|
+
() => () => {
|
|
3271
|
+
try {
|
|
3272
|
+
unsubscribe?.();
|
|
3273
|
+
} catch {
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3276
|
+
"dsh-prompt-enhance: settings scope mirror"
|
|
3277
|
+
);
|
|
3278
|
+
});
|
|
2086
3279
|
}
|
|
2087
3280
|
|
|
3281
|
+
// src/client/settings-page.tsx
|
|
3282
|
+
var import_react10 = require("react");
|
|
3283
|
+
|
|
2088
3284
|
// src/client/settings-page-spec.ts
|
|
2089
|
-
var
|
|
3285
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2090
3286
|
var SETTINGS_SECTION_SLOT = "settings.section";
|
|
2091
3287
|
var SETTINGS_SECTION_ID = "dsh-prompt-enhance";
|
|
2092
3288
|
var SETTINGS_SECTION_ORDER = 70;
|
|
@@ -2133,9 +3329,20 @@ var BASIC_ROWS = [
|
|
|
2133
3329
|
{ key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
|
|
2134
3330
|
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
2135
3331
|
{ key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
|
|
2136
|
-
{
|
|
3332
|
+
{
|
|
3333
|
+
key: "shortcut",
|
|
3334
|
+
kind: "text",
|
|
3335
|
+
label: "settings.row.shortcut.label",
|
|
3336
|
+
hint: "settings.row.shortcut.hint",
|
|
3337
|
+
placeholder: "settings.row.shortcut.placeholder",
|
|
3338
|
+
// Empty disables the shortcut, so it is valid; anything else must parse.
|
|
3339
|
+
validate: (text) => text.trim() === "" || parseShortcut(text) !== null,
|
|
3340
|
+
recordable: true
|
|
3341
|
+
}
|
|
2137
3342
|
];
|
|
2138
3343
|
var ADVANCED_ROWS = [
|
|
3344
|
+
{ key: "foldAnimation", kind: "boolean", label: "settings.row.foldAnimation.label", hint: "settings.row.foldAnimation.hint" },
|
|
3345
|
+
{ key: "autoFold", kind: "boolean", label: "settings.row.autoFold.label", hint: "settings.row.autoFold.hint" },
|
|
2139
3346
|
{ key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
|
|
2140
3347
|
{ key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
|
|
2141
3348
|
{ key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
|
|
@@ -2149,7 +3356,7 @@ var ROWS = [...BASIC_ROWS, ...ADVANCED_ROWS];
|
|
|
2149
3356
|
function descriptorOf(row) {
|
|
2150
3357
|
switch (row.kind) {
|
|
2151
3358
|
case "number":
|
|
2152
|
-
return (0,
|
|
3359
|
+
return (0, import_dsh_client_ui_primitives2.settingsNumberField)(row.key);
|
|
2153
3360
|
case "boolean":
|
|
2154
3361
|
return settingsBooleanField(row.key);
|
|
2155
3362
|
case "strategy":
|
|
@@ -2158,14 +3365,14 @@ function descriptorOf(row) {
|
|
|
2158
3365
|
STRATEGY_OPTIONS.map((option) => option.value)
|
|
2159
3366
|
);
|
|
2160
3367
|
case "reasoning":
|
|
2161
|
-
return (0,
|
|
3368
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2162
3369
|
default:
|
|
2163
|
-
return (0,
|
|
3370
|
+
return (0, import_dsh_client_ui_primitives2.settingsTextField)(row.key);
|
|
2164
3371
|
}
|
|
2165
3372
|
}
|
|
2166
3373
|
var FIELD_SPECS = ROWS.map((row) => descriptorOf(row));
|
|
2167
3374
|
function createSettingsForm(scope) {
|
|
2168
|
-
return new
|
|
3375
|
+
return new import_dsh_client_ui_primitives2.SettingsFormModel(scope, FIELD_SPECS);
|
|
2169
3376
|
}
|
|
2170
3377
|
function viewOf(snapshot, key) {
|
|
2171
3378
|
const value = snapshot[key];
|
|
@@ -2222,7 +3429,12 @@ function sectionCopy(t, chinese) {
|
|
|
2222
3429
|
saved: t("settings.saved"),
|
|
2223
3430
|
advanced: t("settings.advanced"),
|
|
2224
3431
|
reset: t("settings.reset"),
|
|
2225
|
-
invalidNumber: t("settings.invalidNumber")
|
|
3432
|
+
invalidNumber: t("settings.invalidNumber"),
|
|
3433
|
+
invalidShortcut: t("settings.invalidShortcut"),
|
|
3434
|
+
record: t("settings.record"),
|
|
3435
|
+
recordStop: t("settings.recordStop"),
|
|
3436
|
+
recordPrompt: t("settings.recordPrompt"),
|
|
3437
|
+
recordNeedsModifier: t("settings.recordNeedsModifier")
|
|
2226
3438
|
},
|
|
2227
3439
|
title: (row) => chinese ? `${row.key}\uFF08${t(row.label)}\uFF09` : row.key,
|
|
2228
3440
|
hint: (row) => t(row.hint),
|
|
@@ -2243,7 +3455,12 @@ function pageCopy(t) {
|
|
|
2243
3455
|
saved: t("settings.saved"),
|
|
2244
3456
|
advanced: t("settings.advanced"),
|
|
2245
3457
|
reset: t("settings.reset"),
|
|
2246
|
-
invalidNumber: t("settings.invalidNumber")
|
|
3458
|
+
invalidNumber: t("settings.invalidNumber"),
|
|
3459
|
+
invalidShortcut: t("settings.invalidShortcut"),
|
|
3460
|
+
record: t("settings.record"),
|
|
3461
|
+
recordStop: t("settings.recordStop"),
|
|
3462
|
+
recordPrompt: t("settings.recordPrompt"),
|
|
3463
|
+
recordNeedsModifier: t("settings.recordNeedsModifier")
|
|
2247
3464
|
},
|
|
2248
3465
|
title: (row) => t(row.label),
|
|
2249
3466
|
hint: (row) => t(row.hint),
|
|
@@ -2254,57 +3471,8 @@ function pageCopy(t) {
|
|
|
2254
3471
|
}
|
|
2255
3472
|
|
|
2256
3473
|
// src/client/settings-page-controls.tsx
|
|
2257
|
-
var
|
|
2258
|
-
var
|
|
2259
|
-
|
|
2260
|
-
// src/shared/reasoning.ts
|
|
2261
|
-
var REASONING_EFFORTS_ENDPOINT = "/dsh-prompt-enhance/reasoning-efforts";
|
|
2262
|
-
|
|
2263
|
-
// src/client/reasoning-options.ts
|
|
2264
|
-
function effortOf(value) {
|
|
2265
|
-
if (value === null || typeof value !== "object") return void 0;
|
|
2266
|
-
const record = value;
|
|
2267
|
-
if (typeof record.id !== "string" || record.id === "" || typeof record.name !== "string" || record.name === "") return void 0;
|
|
2268
|
-
return {
|
|
2269
|
-
id: record.id,
|
|
2270
|
-
name: record.name,
|
|
2271
|
-
...typeof record.description === "string" && record.description !== "" ? { description: record.description } : {}
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
function capabilitiesOf(value) {
|
|
2275
|
-
if (value === null || typeof value !== "object") return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2276
|
-
const record = value;
|
|
2277
|
-
const source = record.source === "resolved" || record.source === "default" || record.source === "unavailable" ? record.source : "unavailable";
|
|
2278
|
-
const efforts = Array.isArray(record.efforts) ? record.efforts.map(effortOf).filter((effort) => effort !== void 0) : [];
|
|
2279
|
-
const reason = typeof record.reason === "string" ? record.reason : void 0;
|
|
2280
|
-
if (source !== "unavailable" && efforts.length === 0) return { efforts: [], source: "unavailable", reason: "no-efforts" };
|
|
2281
|
-
return {
|
|
2282
|
-
efforts,
|
|
2283
|
-
source,
|
|
2284
|
-
...typeof record.defaultEffort === "string" && record.defaultEffort !== "" ? { defaultEffort: record.defaultEffort } : {},
|
|
2285
|
-
...reason === void 0 ? {} : { reason }
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
2289
|
-
const url = new URL(REASONING_EFFORTS_ENDPOINT, globalThis.location?.origin ?? "http://127.0.0.1");
|
|
2290
|
-
if (provider !== void 0 && model !== void 0) {
|
|
2291
|
-
url.searchParams.set("provider", provider);
|
|
2292
|
-
url.searchParams.set("model", model);
|
|
2293
|
-
}
|
|
2294
|
-
if (options.refresh === true) url.searchParams.set("refresh", "1");
|
|
2295
|
-
try {
|
|
2296
|
-
const response = await fetch(url, { signal: options.signal, headers: { accept: "application/json" } });
|
|
2297
|
-
if (!response.ok) return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2298
|
-
const body = await response.json();
|
|
2299
|
-
const envelope = body;
|
|
2300
|
-
if (envelope === null || envelope === void 0 || envelope.ok !== true) {
|
|
2301
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2302
|
-
}
|
|
2303
|
-
return capabilitiesOf(envelope.value);
|
|
2304
|
-
} catch {
|
|
2305
|
-
return { efforts: [], source: "unavailable", reason: "resolve-failed" };
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
3474
|
+
var import_react9 = require("react");
|
|
3475
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2308
3476
|
|
|
2309
3477
|
// src/client/settings-page-styles.ts
|
|
2310
3478
|
var ROW_STYLE = { display: "flex", flexDirection: "column", gap: 6, padding: "12px 0" };
|
|
@@ -2329,6 +3497,13 @@ var STATUS_STYLE = {
|
|
|
2329
3497
|
lineHeight: 1.5,
|
|
2330
3498
|
color: "var(--dsw-alias-label-secondary, inherit)"
|
|
2331
3499
|
};
|
|
3500
|
+
var NOTICE_STYLE = {
|
|
3501
|
+
margin: 0,
|
|
3502
|
+
fontSize: 12.5,
|
|
3503
|
+
fontWeight: 500,
|
|
3504
|
+
lineHeight: 1.5,
|
|
3505
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
3506
|
+
};
|
|
2332
3507
|
var CHIP_STYLE = {
|
|
2333
3508
|
display: "inline-flex",
|
|
2334
3509
|
alignItems: "center",
|
|
@@ -2347,20 +3522,34 @@ var CHIP_STYLE = {
|
|
|
2347
3522
|
};
|
|
2348
3523
|
var REFRESH_STYLE = { ...CHIP_STYLE, flex: "none" };
|
|
2349
3524
|
var RESET_STYLE = CHIP_STYLE;
|
|
2350
|
-
var
|
|
2351
|
-
var
|
|
3525
|
+
var RECORD_STYLE = CHIP_STYLE;
|
|
3526
|
+
var FIELD_BORDER = "1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.38))";
|
|
3527
|
+
var FIELD_BOX_STYLE = {
|
|
2352
3528
|
boxSizing: "border-box",
|
|
2353
3529
|
width: "100%",
|
|
2354
3530
|
height: 34,
|
|
2355
3531
|
padding: "0 12px",
|
|
2356
3532
|
border: FIELD_BORDER,
|
|
2357
3533
|
borderRadius: "var(--dsw-radius-md, 8px)",
|
|
2358
|
-
background: "var(--dsw-alias-bg-layer-3, transparent)"
|
|
3534
|
+
background: "var(--dsw-alias-bg-layer-3, transparent)"
|
|
3535
|
+
};
|
|
3536
|
+
var FIELD_SHELL_STYLE = {
|
|
3537
|
+
...FIELD_BOX_STYLE,
|
|
3538
|
+
display: "flex",
|
|
3539
|
+
alignItems: "center"
|
|
3540
|
+
};
|
|
3541
|
+
var FIELD_INPUT_STYLE = {
|
|
3542
|
+
flex: "1 1 auto",
|
|
3543
|
+
minWidth: 0,
|
|
3544
|
+
margin: 0,
|
|
3545
|
+
padding: 0,
|
|
3546
|
+
border: "none",
|
|
3547
|
+
outline: "none",
|
|
3548
|
+
background: "transparent",
|
|
2359
3549
|
font: "inherit",
|
|
2360
3550
|
fontSize: 13,
|
|
2361
|
-
lineHeight:
|
|
2362
|
-
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2363
|
-
outline: "none"
|
|
3551
|
+
lineHeight: "22px",
|
|
3552
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
2364
3553
|
};
|
|
2365
3554
|
var INVALID_STYLE = {
|
|
2366
3555
|
margin: 0,
|
|
@@ -2375,7 +3564,13 @@ var WARN_STYLE = {
|
|
|
2375
3564
|
color: "var(--dsw-alias-state-error-primary, #f85149)"
|
|
2376
3565
|
};
|
|
2377
3566
|
var SELECT_STYLE = {
|
|
2378
|
-
...
|
|
3567
|
+
...FIELD_BOX_STYLE,
|
|
3568
|
+
paddingLeft: 9,
|
|
3569
|
+
font: "inherit",
|
|
3570
|
+
fontSize: 13,
|
|
3571
|
+
lineHeight: 1.5,
|
|
3572
|
+
color: "var(--dsw-alias-label-primary, inherit)",
|
|
3573
|
+
outline: "none",
|
|
2379
3574
|
cursor: "pointer"
|
|
2380
3575
|
};
|
|
2381
3576
|
var SEPARATOR_STYLE = {
|
|
@@ -2385,7 +3580,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
|
|
|
2385
3580
|
var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
2386
3581
|
var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
|
|
2387
3582
|
var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
|
|
2388
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
3583
|
+
var PLUGIN_VERSION = true ? "0.1.3" : "0.0.0";
|
|
2389
3584
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
2390
3585
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
2391
3586
|
var HEADER_TITLE_STYLE = {
|
|
@@ -2432,28 +3627,28 @@ var HEADER_DESCRIPTION_STYLE = {
|
|
|
2432
3627
|
};
|
|
2433
3628
|
|
|
2434
3629
|
// src/client/settings-page-controls.tsx
|
|
2435
|
-
var
|
|
3630
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2436
3631
|
function OverrideActions(props) {
|
|
2437
|
-
return /* @__PURE__ */ (0,
|
|
3632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "dsh-pe-chip-reset", style: { ...RESET_STYLE, ...props.disabled ? { opacity: 0.5, cursor: "default" } : {} }, disabled: props.disabled, onClick: props.onReset, children: props.copy.labels.reset });
|
|
2438
3633
|
}
|
|
2439
3634
|
function BooleanRow(props) {
|
|
2440
|
-
return /* @__PURE__ */ (0,
|
|
2441
|
-
/* @__PURE__ */ (0,
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2443
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
2444
|
-
/* @__PURE__ */ (0,
|
|
3635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3636
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3637
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3638
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null,
|
|
3639
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives3.Switch, { checked: props.view.text === "true", disabled: props.disabled, label: props.label, onChange: (next) => props.onEdit(next ? "true" : "false") })
|
|
2445
3640
|
] }),
|
|
2446
|
-
/* @__PURE__ */ (0,
|
|
3641
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2447
3642
|
] });
|
|
2448
3643
|
}
|
|
2449
3644
|
function ChoiceRow(props) {
|
|
2450
|
-
return /* @__PURE__ */ (0,
|
|
2451
|
-
/* @__PURE__ */ (0,
|
|
2452
|
-
/* @__PURE__ */ (0,
|
|
2453
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3646
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3647
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3648
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2454
3649
|
] }),
|
|
2455
|
-
/* @__PURE__ */ (0,
|
|
2456
|
-
|
|
3650
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3651
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2457
3652
|
{
|
|
2458
3653
|
id: props.id,
|
|
2459
3654
|
className: "dsh-pe-segmented-labels",
|
|
@@ -2464,23 +3659,30 @@ function ChoiceRow(props) {
|
|
|
2464
3659
|
onChange: (next) => props.onEdit(next)
|
|
2465
3660
|
}
|
|
2466
3661
|
),
|
|
2467
|
-
/* @__PURE__ */ (0,
|
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint })
|
|
2468
3663
|
] });
|
|
2469
3664
|
}
|
|
3665
|
+
var capabilityCache = /* @__PURE__ */ new Map();
|
|
3666
|
+
function capabilityKey(provider, model) {
|
|
3667
|
+
return `${provider}\0${model}`;
|
|
3668
|
+
}
|
|
2470
3669
|
function ReasoningRow(props) {
|
|
2471
3670
|
const pair = props.provider !== "" && props.model !== "" ? `${props.provider}/${props.model}` : "";
|
|
2472
|
-
const
|
|
2473
|
-
const
|
|
2474
|
-
const [
|
|
2475
|
-
const [
|
|
2476
|
-
const
|
|
2477
|
-
const
|
|
2478
|
-
(0,
|
|
3671
|
+
const cacheKey = capabilityKey(props.provider, props.model);
|
|
3672
|
+
const cached = capabilityCache.get(cacheKey);
|
|
3673
|
+
const [phase, setPhase] = (0, import_react9.useState)(cached === void 0 ? "loading" : "ready");
|
|
3674
|
+
const [capabilities, setCapabilities] = (0, import_react9.useState)(cached);
|
|
3675
|
+
const [refreshToken, setRefreshToken] = (0, import_react9.useState)(0);
|
|
3676
|
+
const [feedback, setFeedback] = (0, import_react9.useState)("idle");
|
|
3677
|
+
const forceRef = (0, import_react9.useRef)(false);
|
|
3678
|
+
const feedbackTimer = (0, import_react9.useRef)(void 0);
|
|
3679
|
+
(0, import_react9.useEffect)(() => {
|
|
2479
3680
|
const controller = new AbortController();
|
|
2480
3681
|
const force = forceRef.current;
|
|
2481
3682
|
forceRef.current = false;
|
|
2482
|
-
|
|
2483
|
-
|
|
3683
|
+
const known = capabilityCache.get(cacheKey);
|
|
3684
|
+
setPhase(known === void 0 ? "loading" : "ready");
|
|
3685
|
+
setCapabilities(known);
|
|
2484
3686
|
setFeedback(force ? "refreshing" : "idle");
|
|
2485
3687
|
if (feedbackTimer.current !== void 0) {
|
|
2486
3688
|
clearTimeout(feedbackTimer.current);
|
|
@@ -2498,6 +3700,7 @@ function ReasoningRow(props) {
|
|
|
2498
3700
|
if (controller.signal.aborted) return;
|
|
2499
3701
|
setCapabilities(answer);
|
|
2500
3702
|
setPhase("ready");
|
|
3703
|
+
if (answer.source !== "unavailable" || answer.reason === "no-efforts") capabilityCache.set(cacheKey, answer);
|
|
2501
3704
|
settle(answer.source === "unavailable" ? "failed" : "ok");
|
|
2502
3705
|
}).catch(() => {
|
|
2503
3706
|
if (controller.signal.aborted) return;
|
|
@@ -2512,15 +3715,20 @@ function ReasoningRow(props) {
|
|
|
2512
3715
|
feedbackTimer.current = void 0;
|
|
2513
3716
|
}
|
|
2514
3717
|
};
|
|
2515
|
-
}, [pair, refreshToken]);
|
|
2516
|
-
const
|
|
2517
|
-
const realTierKnown = phase === "ready" && capabilities !== void 0 && capabilities.source !== "unavailable" && capabilities.efforts.some((effort) => effort.id ===
|
|
3718
|
+
}, [cacheKey, pair, refreshToken]);
|
|
3719
|
+
const current3 = props.view.text;
|
|
3720
|
+
const realTierKnown = phase === "ready" && capabilities !== void 0 && capabilities.source !== "unavailable" && capabilities.efforts.some((effort) => effort.id === current3);
|
|
2518
3721
|
const noTiers = phase === "ready" && capabilities !== void 0 && capabilities.source === "unavailable" && capabilities.reason === "no-efforts";
|
|
2519
3722
|
const options = [];
|
|
2520
|
-
|
|
3723
|
+
options.push({
|
|
3724
|
+
value: "inherit",
|
|
3725
|
+
label: props.copy.choice("settings.reasoning.inherit"),
|
|
3726
|
+
title: props.copy.choice("settings.reasoning.inherit")
|
|
3727
|
+
});
|
|
3728
|
+
if (!noTiers && current3 !== "" && current3 !== "inherit" && !realTierKnown) {
|
|
2521
3729
|
options.push({
|
|
2522
|
-
value:
|
|
2523
|
-
label: props.copy.interpolate("settings.reasoning.current", { value:
|
|
3730
|
+
value: current3,
|
|
3731
|
+
label: props.copy.interpolate("settings.reasoning.current", { value: current3 }),
|
|
2524
3732
|
title: props.copy.choice("settings.reasoning.currentTitle")
|
|
2525
3733
|
});
|
|
2526
3734
|
}
|
|
@@ -2533,46 +3741,42 @@ function ReasoningRow(props) {
|
|
|
2533
3741
|
});
|
|
2534
3742
|
}
|
|
2535
3743
|
}
|
|
2536
|
-
options.
|
|
2537
|
-
|
|
2538
|
-
label: props.copy.choice("settings.reasoning.inherit"),
|
|
2539
|
-
title: props.copy.choice("settings.reasoning.inherit")
|
|
2540
|
-
});
|
|
2541
|
-
const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current2 !== "" && current2 !== "inherit" && !realTierKnown;
|
|
3744
|
+
const selected = options.some((option) => option.value === current3) ? current3 : "inherit";
|
|
3745
|
+
const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current3 !== "" && current3 !== "inherit" && !realTierKnown;
|
|
2542
3746
|
const refreshing = feedback === "refreshing";
|
|
2543
3747
|
const refresh = () => {
|
|
2544
3748
|
forceRef.current = true;
|
|
2545
3749
|
setRefreshToken((token) => token + 1);
|
|
2546
3750
|
};
|
|
2547
|
-
return /* @__PURE__ */ (0,
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2550
|
-
phase === "ready" || refreshing ? /* @__PURE__ */ (0,
|
|
2551
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3752
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3753
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: LABEL_STYLE, children: props.label }),
|
|
3754
|
+
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,
|
|
3755
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2552
3756
|
] }),
|
|
2553
|
-
/* @__PURE__ */ (0,
|
|
2554
|
-
|
|
3757
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3758
|
+
import_dsh_client_ui_primitives3.SegmentedControl,
|
|
2555
3759
|
{
|
|
2556
3760
|
id: props.id,
|
|
2557
3761
|
className: "dsh-pe-segmented-labels",
|
|
2558
|
-
value:
|
|
3762
|
+
value: selected,
|
|
2559
3763
|
options,
|
|
2560
3764
|
disabled: props.disabled,
|
|
2561
3765
|
label: props.label,
|
|
2562
3766
|
onChange: (next) => props.onEdit(next)
|
|
2563
3767
|
}
|
|
2564
3768
|
),
|
|
2565
|
-
/* @__PURE__ */ (0,
|
|
2566
|
-
phase === "loading" ? /* @__PURE__ */ (0,
|
|
2567
|
-
phase === "ready" && capabilities?.source === "unavailable" ? /* @__PURE__ */ (0,
|
|
2568
|
-
unsupported ? /* @__PURE__ */ (0,
|
|
2569
|
-
feedback === "ok" ? /* @__PURE__ */ (0,
|
|
2570
|
-
feedback === "failed" ? /* @__PURE__ */ (0,
|
|
3769
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3770
|
+
phase === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.reasoning.loading") }) : null,
|
|
3771
|
+
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,
|
|
3772
|
+
unsupported ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.interpolate("settings.reasoning.unsupported", { effort: props.view.text }) }) : null,
|
|
3773
|
+
feedback === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, "aria-live": "polite", children: props.copy.choice("settings.reasoning.refreshOk") }) : null,
|
|
3774
|
+
feedback === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, "aria-live": "polite", children: props.copy.choice("settings.reasoning.refreshFailed") }) : null
|
|
2571
3775
|
] });
|
|
2572
3776
|
}
|
|
2573
3777
|
function SelectControl(props) {
|
|
2574
|
-
const [focused, setFocused] = (0,
|
|
2575
|
-
return /* @__PURE__ */ (0,
|
|
3778
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2576
3780
|
"select",
|
|
2577
3781
|
{
|
|
2578
3782
|
id: props.id,
|
|
@@ -2587,50 +3791,50 @@ function SelectControl(props) {
|
|
|
2587
3791
|
);
|
|
2588
3792
|
}
|
|
2589
3793
|
function ProviderRow(props) {
|
|
2590
|
-
const
|
|
2591
|
-
const known = props.routing.providers.entries.find((entry) => entry.id ===
|
|
2592
|
-
const missing =
|
|
3794
|
+
const current3 = props.view.text;
|
|
3795
|
+
const known = props.routing.providers.entries.find((entry) => entry.id === current3);
|
|
3796
|
+
const missing = current3 !== "" && known === void 0;
|
|
2593
3797
|
const unconfigured = known !== void 0 && !known.registered;
|
|
2594
|
-
return /* @__PURE__ */ (0,
|
|
2595
|
-
/* @__PURE__ */ (0,
|
|
2596
|
-
/* @__PURE__ */ (0,
|
|
2597
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3800
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3801
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2598
3802
|
] }),
|
|
2599
|
-
/* @__PURE__ */ (0,
|
|
2600
|
-
/* @__PURE__ */ (0,
|
|
2601
|
-
missing ? /* @__PURE__ */ (0,
|
|
2602
|
-
/* @__PURE__ */ (0,
|
|
2603
|
-
props.routing.providers.entries.some((entry) => !entry.registered) ? /* @__PURE__ */ (0,
|
|
3803
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(SelectControl, { id: props.id, value: current3, disabled: props.disabled, onChange: (value) => props.onEdit(value), children: [
|
|
3804
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: props.copy.choice("settings.routing.followSession") }),
|
|
3805
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: current3, title: current3, children: props.copy.interpolate("settings.routing.currentProvider", { value: current3 }) }) : null,
|
|
3806
|
+
/* @__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)) }),
|
|
3807
|
+
props.routing.providers.entries.some((entry) => !entry.registered) ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: props.copy.choice("settings.routing.groupDormant"), children: props.routing.providers.entries.filter((entry) => !entry.registered).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: entry.id, disabled: true, title: props.copy.choice("settings.routing.unconfiguredTitle"), children: [
|
|
2604
3808
|
entry.name,
|
|
2605
3809
|
props.copy.choice("settings.routing.unconfiguredSuffix")
|
|
2606
3810
|
] }, entry.id)) }) : null
|
|
2607
3811
|
] }),
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
props.routing.providers.loading ? /* @__PURE__ */ (0,
|
|
2610
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2611
|
-
props.routing.providers.failed ? /* @__PURE__ */ (0,
|
|
2612
|
-
missing ? /* @__PURE__ */ (0,
|
|
2613
|
-
unconfigured ? /* @__PURE__ */ (0,
|
|
3812
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3813
|
+
props.routing.providers.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.providersLoading") }) : null,
|
|
3814
|
+
props.routing.providers.failed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.providersFailed") }) : null,
|
|
3815
|
+
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,
|
|
3816
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.interpolate("settings.routing.providerMissing", { value: current3 }) }) : null,
|
|
3817
|
+
unconfigured ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.interpolate("settings.routing.providerUnconfigured", { name: known.name }) }) : null
|
|
2614
3818
|
] });
|
|
2615
3819
|
}
|
|
2616
3820
|
function ModelRow(props) {
|
|
2617
|
-
const
|
|
3821
|
+
const current3 = props.view.text;
|
|
2618
3822
|
const provider = props.providerValue;
|
|
2619
|
-
const [customMode, setCustomMode] = (0,
|
|
2620
|
-
const known = props.routing.models.entries.some((entry) => entry.id ===
|
|
2621
|
-
const showCustom = provider !== "" && (customMode ||
|
|
2622
|
-
const pairIncomplete = provider !== "" &&
|
|
2623
|
-
const routeUnavailable = provider !== "" &&
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2627
|
-
props.view.overridden ? /* @__PURE__ */ (0,
|
|
3823
|
+
const [customMode, setCustomMode] = (0, import_react9.useState)(false);
|
|
3824
|
+
const known = props.routing.models.entries.some((entry) => entry.id === current3);
|
|
3825
|
+
const showCustom = provider !== "" && (customMode || current3 !== "" && !known);
|
|
3826
|
+
const pairIncomplete = provider !== "" && current3 === "";
|
|
3827
|
+
const routeUnavailable = provider !== "" && current3 !== "" && props.routing.route.available === false;
|
|
3828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3829
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3830
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3831
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null
|
|
2628
3832
|
] }),
|
|
2629
|
-
/* @__PURE__ */ (0,
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2630
3834
|
SelectControl,
|
|
2631
3835
|
{
|
|
2632
3836
|
id: props.id,
|
|
2633
|
-
value: showCustom ? "__custom__" :
|
|
3837
|
+
value: showCustom ? "__custom__" : current3,
|
|
2634
3838
|
disabled: props.disabled || provider === "",
|
|
2635
3839
|
onChange: (value) => {
|
|
2636
3840
|
if (value === "__custom__") {
|
|
@@ -2641,68 +3845,131 @@ function ModelRow(props) {
|
|
|
2641
3845
|
props.onEdit(value);
|
|
2642
3846
|
},
|
|
2643
3847
|
children: [
|
|
2644
|
-
/* @__PURE__ */ (0,
|
|
2645
|
-
props.routing.models.entries.map((entry) => /* @__PURE__ */ (0,
|
|
2646
|
-
provider !== "" &&
|
|
2647
|
-
provider !== "" ? /* @__PURE__ */ (0,
|
|
3848
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: provider === "" ? props.copy.choice("settings.routing.followSession") : props.copy.choice("settings.routing.selectModel") }),
|
|
3849
|
+
props.routing.models.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: entry.id, title: entry.id, children: entry.name }, entry.id)),
|
|
3850
|
+
provider !== "" && current3 !== "" && !known ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: current3, title: current3, children: props.copy.interpolate("settings.routing.currentModel", { value: current3 }) }) : null,
|
|
3851
|
+
provider !== "" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "__custom__", children: props.copy.choice("settings.routing.custom") }) : null
|
|
2648
3852
|
]
|
|
2649
3853
|
}
|
|
2650
3854
|
),
|
|
2651
|
-
showCustom ? /* @__PURE__ */ (0,
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3855
|
+
showCustom ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3856
|
+
TextControl,
|
|
3857
|
+
{
|
|
3858
|
+
value: current3,
|
|
3859
|
+
placeholder: props.copy.choice("settings.routing.customPlaceholder"),
|
|
3860
|
+
disabled: props.disabled,
|
|
3861
|
+
onChange: (text) => props.onEdit(text, { deferred: true }),
|
|
3862
|
+
onCommit: props.onCommit
|
|
3863
|
+
}
|
|
3864
|
+
) : null,
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3866
|
+
props.routing.models.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.modelsLoading") }) : null,
|
|
3867
|
+
props.routing.models.failed && !showCustom ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: STATUS_STYLE, children: props.copy.choice("settings.routing.modelsFailed") }) : null,
|
|
3868
|
+
pairIncomplete ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.choice("settings.routing.pairIncomplete") }) : null,
|
|
3869
|
+
routeUnavailable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: WARN_STYLE, children: props.copy.choice("settings.routing.routeUnavailable") }) : null
|
|
2657
3870
|
] });
|
|
2658
3871
|
}
|
|
2659
3872
|
function TextControl(props) {
|
|
2660
|
-
const [focused, setFocused] = (0,
|
|
2661
|
-
const [revealedInvalid, setRevealedInvalid] = (0,
|
|
2662
|
-
(0,
|
|
3873
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3874
|
+
const [revealedInvalid, setRevealedInvalid] = (0, import_react9.useState)(false);
|
|
3875
|
+
(0, import_react9.useEffect)(() => {
|
|
2663
3876
|
if (props.invalid !== true) setRevealedInvalid(false);
|
|
2664
3877
|
}, [props.invalid]);
|
|
2665
3878
|
const showInvalid = props.invalid === true && revealedInvalid;
|
|
2666
3879
|
const borderColor = showInvalid ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
|
|
2667
|
-
return
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
3880
|
+
return (
|
|
3881
|
+
// Host primitives Input: a flex shell centers a borderless inner input, so
|
|
3882
|
+
// the text sits on the shell's center line instead of relying on a fixed
|
|
3883
|
+
// height plus a line-height to be centered by the browser.
|
|
3884
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { ...FIELD_SHELL_STYLE, ...borderColor === void 0 ? {} : { borderColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3885
|
+
"input",
|
|
3886
|
+
{
|
|
3887
|
+
id: props.id,
|
|
3888
|
+
type: "text",
|
|
3889
|
+
inputMode: props.numeric === true ? "numeric" : void 0,
|
|
3890
|
+
"aria-invalid": showInvalid || void 0,
|
|
3891
|
+
disabled: props.disabled,
|
|
3892
|
+
placeholder: props.placeholder,
|
|
3893
|
+
value: props.value,
|
|
3894
|
+
style: {
|
|
3895
|
+
...FIELD_INPUT_STYLE,
|
|
3896
|
+
...props.disabled === true ? { color: "var(--dsw-alias-label-tertiary, inherit)", cursor: "default" } : {}
|
|
3897
|
+
},
|
|
3898
|
+
onFocus: () => setFocused(true),
|
|
3899
|
+
onBlur: () => {
|
|
3900
|
+
setFocused(false);
|
|
3901
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
3902
|
+
props.onCommit?.();
|
|
3903
|
+
},
|
|
3904
|
+
onKeyDown: (event) => {
|
|
3905
|
+
if (event.key !== "Enter") return;
|
|
3906
|
+
event.preventDefault();
|
|
3907
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
3908
|
+
props.onCommit?.();
|
|
3909
|
+
},
|
|
3910
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
3911
|
+
}
|
|
3912
|
+
) })
|
|
2696
3913
|
);
|
|
2697
3914
|
}
|
|
2698
3915
|
function ValueRow(props) {
|
|
2699
|
-
const invalid = props.view.invalid;
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
3916
|
+
const invalid = props.view.invalid || props.invalidMessage !== void 0;
|
|
3917
|
+
const [revealed, setRevealed] = (0, import_react9.useState)(props.invalidMessage !== void 0);
|
|
3918
|
+
(0, import_react9.useEffect)(() => {
|
|
3919
|
+
if (props.invalidMessage === void 0) setRevealed(false);
|
|
3920
|
+
}, [props.invalidMessage]);
|
|
3921
|
+
const showMessage = invalid && (props.view.invalid || revealed);
|
|
3922
|
+
const [recording, setRecording] = (0, import_react9.useState)(false);
|
|
3923
|
+
const [recordRejected, setRecordRejected] = (0, import_react9.useState)(false);
|
|
3924
|
+
const { onEdit, onCommit } = props;
|
|
3925
|
+
(0, import_react9.useEffect)(() => {
|
|
3926
|
+
if (!recording) return;
|
|
3927
|
+
const onKeyDown = (event) => {
|
|
3928
|
+
if (event.isComposing || event.repeat) return;
|
|
3929
|
+
const key = event.key;
|
|
3930
|
+
if (key === "Control" || key === "Alt" || key === "Shift" || key === "Meta") return;
|
|
3931
|
+
if (key === "Escape" || key === "Tab") {
|
|
3932
|
+
setRecording(false);
|
|
3933
|
+
setRecordRejected(false);
|
|
3934
|
+
if (key === "Escape") event.preventDefault();
|
|
3935
|
+
return;
|
|
3936
|
+
}
|
|
3937
|
+
event.preventDefault();
|
|
3938
|
+
event.stopPropagation();
|
|
3939
|
+
const spec = shortcutSpecOf(event);
|
|
3940
|
+
if (spec === null) {
|
|
3941
|
+
setRecordRejected(true);
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
setRecording(false);
|
|
3945
|
+
setRecordRejected(false);
|
|
3946
|
+
onEdit(spec);
|
|
3947
|
+
onCommit?.();
|
|
3948
|
+
};
|
|
3949
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
3950
|
+
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
3951
|
+
}, [recording, onEdit, onCommit]);
|
|
3952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: ROW_STYLE, children: [
|
|
3953
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: HEAD_STYLE, children: [
|
|
3954
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: props.id, style: LABEL_STYLE, children: props.label }),
|
|
3955
|
+
props.view.overridden ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverrideActions, { copy: props.copy, disabled: props.disabled, onReset: props.onReset }) : null,
|
|
3956
|
+
props.recordable === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3957
|
+
"button",
|
|
3958
|
+
{
|
|
3959
|
+
type: "button",
|
|
3960
|
+
className: "dsh-pe-chip-reset",
|
|
3961
|
+
style: RECORD_STYLE,
|
|
3962
|
+
disabled: props.disabled,
|
|
3963
|
+
"aria-pressed": recording,
|
|
3964
|
+
onClick: () => {
|
|
3965
|
+
setRecording((open) => !open);
|
|
3966
|
+
setRecordRejected(false);
|
|
3967
|
+
},
|
|
3968
|
+
children: recording ? props.copy.labels.recordStop : props.copy.labels.record
|
|
3969
|
+
}
|
|
3970
|
+
) : null
|
|
2704
3971
|
] }),
|
|
2705
|
-
/* @__PURE__ */ (0,
|
|
3972
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2706
3973
|
TextControl,
|
|
2707
3974
|
{
|
|
2708
3975
|
id: props.id,
|
|
@@ -2711,17 +3978,24 @@ function ValueRow(props) {
|
|
|
2711
3978
|
numeric: props.numeric,
|
|
2712
3979
|
invalid,
|
|
2713
3980
|
disabled: props.disabled,
|
|
2714
|
-
onChange:
|
|
2715
|
-
|
|
3981
|
+
onChange: (text) => {
|
|
3982
|
+
setRevealed(false);
|
|
3983
|
+
props.onEdit(text);
|
|
3984
|
+
},
|
|
3985
|
+
onCommit: () => {
|
|
3986
|
+
setRevealed(true);
|
|
3987
|
+
props.onCommit?.();
|
|
3988
|
+
}
|
|
2716
3989
|
}
|
|
2717
3990
|
),
|
|
2718
|
-
/* @__PURE__ */ (0,
|
|
2719
|
-
|
|
3991
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
3992
|
+
recording ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: NOTICE_STYLE, children: recordRejected ? props.copy.labels.recordNeedsModifier : props.copy.labels.recordPrompt }) : null,
|
|
3993
|
+
showMessage ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: INVALID_STYLE, children: props.invalidMessage ?? props.copy.labels.invalidNumber }) : null
|
|
2720
3994
|
] });
|
|
2721
3995
|
}
|
|
2722
3996
|
|
|
2723
3997
|
// src/client/settings-page.tsx
|
|
2724
|
-
var
|
|
3998
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2725
3999
|
function sectionTitle(getLocale) {
|
|
2726
4000
|
try {
|
|
2727
4001
|
const t = getLocale?.()?.bind(NS);
|
|
@@ -2731,23 +4005,23 @@ function sectionTitle(getLocale) {
|
|
|
2731
4005
|
}
|
|
2732
4006
|
}
|
|
2733
4007
|
function PageHeader(props) {
|
|
2734
|
-
return /* @__PURE__ */ (0,
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
2736
|
-
/* @__PURE__ */ (0,
|
|
2737
|
-
/* @__PURE__ */ (0,
|
|
2738
|
-
/* @__PURE__ */ (0,
|
|
4008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: HEADER_STYLE, children: [
|
|
4009
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: HEADER_ROW_STYLE, children: [
|
|
4010
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: HEADER_TITLE_STYLE, children: props.title }),
|
|
4011
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: REPOSITORY_URL, target: "_blank", rel: "noreferrer", style: HEADER_LINK_STYLE, children: [
|
|
4012
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "currentColor", d: GITHUB_MARK }) }),
|
|
2739
4013
|
"GitHub"
|
|
2740
4014
|
] }),
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
4015
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: NPM_URL, target: "_blank", rel: "noreferrer", style: HEADER_LINK_STYLE, children: [
|
|
4016
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "currentColor", d: NPM_MARK }) }),
|
|
2743
4017
|
"npm"
|
|
2744
4018
|
] }),
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
4019
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { style: HEADER_VERSION_STYLE, children: [
|
|
2746
4020
|
"v",
|
|
2747
4021
|
props.version
|
|
2748
4022
|
] })
|
|
2749
4023
|
] }),
|
|
2750
|
-
/* @__PURE__ */ (0,
|
|
4024
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: HEADER_DESCRIPTION_STYLE, children: props.description })
|
|
2751
4025
|
] });
|
|
2752
4026
|
}
|
|
2753
4027
|
function SettingsRow(props) {
|
|
@@ -2764,37 +4038,55 @@ function SettingsRow(props) {
|
|
|
2764
4038
|
};
|
|
2765
4039
|
switch (props.row.kind) {
|
|
2766
4040
|
case "boolean":
|
|
2767
|
-
return /* @__PURE__ */ (0,
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BooleanRow, { ...shared });
|
|
2768
4042
|
case "strategy":
|
|
2769
|
-
return /* @__PURE__ */ (0,
|
|
4043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChoiceRow, { ...shared, options: STRATEGY_OPTIONS.map((option) => ({ value: option.value, label: props.copy.choice(option.label) })) });
|
|
2770
4044
|
case "reasoning":
|
|
2771
|
-
return /* @__PURE__ */ (0,
|
|
4045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ReasoningRow, { ...shared, provider: props.reasoningPair.provider, model: props.reasoningPair.model });
|
|
2772
4046
|
case "provider":
|
|
2773
|
-
return /* @__PURE__ */ (0,
|
|
4047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProviderRow, { ...shared, routing: props.routing });
|
|
2774
4048
|
case "model":
|
|
2775
|
-
return /* @__PURE__ */ (0,
|
|
4049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModelRow, { ...shared, routing: props.routing, providerValue: props.providerValue });
|
|
2776
4050
|
default:
|
|
2777
|
-
return /* @__PURE__ */ (0,
|
|
4051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4052
|
+
ValueRow,
|
|
4053
|
+
{
|
|
4054
|
+
...shared,
|
|
4055
|
+
numeric: props.row.kind === "number",
|
|
4056
|
+
placeholder: props.copy.placeholder(props.row),
|
|
4057
|
+
invalidMessage: props.row.validate !== void 0 && !props.row.validate(props.view.text) ? props.copy.labels.invalidShortcut : void 0,
|
|
4058
|
+
recordable: props.row.recordable === true
|
|
4059
|
+
}
|
|
4060
|
+
);
|
|
2778
4061
|
}
|
|
2779
4062
|
}
|
|
2780
4063
|
function SettingsRows(props) {
|
|
2781
4064
|
const provider = viewOf(props.state, "provider").text.trim();
|
|
2782
4065
|
const model = viewOf(props.state, "model").text.trim();
|
|
2783
4066
|
const routing = useLlmRouting(provider, model);
|
|
2784
|
-
const [saveState, setSaveState] = (0,
|
|
2785
|
-
const timers = (0,
|
|
2786
|
-
const savedTimer = (0,
|
|
2787
|
-
const savedValues = (0,
|
|
2788
|
-
const sequence = (0,
|
|
2789
|
-
(0,
|
|
4067
|
+
const [saveState, setSaveState] = (0, import_react10.useState)("idle");
|
|
4068
|
+
const timers = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
4069
|
+
const savedTimer = (0, import_react10.useRef)(void 0);
|
|
4070
|
+
const savedValues = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
4071
|
+
const sequence = (0, import_react10.useRef)(0);
|
|
4072
|
+
(0, import_react10.useEffect)(() => {
|
|
2790
4073
|
for (const row of ROWS) {
|
|
2791
4074
|
if (!savedValues.current.has(row.key)) {
|
|
2792
4075
|
savedValues.current.set(row.key, viewOf(props.state, row.key).text);
|
|
2793
4076
|
}
|
|
2794
4077
|
}
|
|
2795
4078
|
}, [props.state]);
|
|
4079
|
+
const isStagedInvalid = (key, text) => {
|
|
4080
|
+
const row = ROWS.find((item) => item.key === key);
|
|
4081
|
+
return row?.validate !== void 0 && !row.validate(text);
|
|
4082
|
+
};
|
|
4083
|
+
const hasStagedInvalid = () => ROWS.some((row) => row.validate !== void 0 && !row.validate(viewOf(props.state, row.key).text));
|
|
2796
4084
|
const runSave = async (key, text) => {
|
|
2797
4085
|
if (props.writeField === void 0) return;
|
|
4086
|
+
if (isStagedInvalid(key, text)) {
|
|
4087
|
+
setSaveState("idle");
|
|
4088
|
+
return;
|
|
4089
|
+
}
|
|
2798
4090
|
if (savedValues.current.get(key) === text) return;
|
|
2799
4091
|
const ticket = ++sequence.current;
|
|
2800
4092
|
setSaveState("saving");
|
|
@@ -2836,20 +4128,35 @@ function SettingsRows(props) {
|
|
|
2836
4128
|
savedValues.current.set(key, fallback);
|
|
2837
4129
|
markSaved();
|
|
2838
4130
|
};
|
|
4131
|
+
const resetTargets = (key) => key === "provider" && viewOf(props.state, "model").text !== "" ? ["provider", "model"] : [key];
|
|
2839
4132
|
const resetAndSave = (key) => {
|
|
2840
|
-
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
|
|
4133
|
+
const targets = resetTargets(key);
|
|
4134
|
+
for (const target of targets) {
|
|
4135
|
+
props.resetField(target);
|
|
4136
|
+
savedValues.current.set(target, defaultTextOf(target));
|
|
4137
|
+
}
|
|
4138
|
+
void (async () => {
|
|
4139
|
+
for (const target of targets) await runReset(target, defaultTextOf(target));
|
|
4140
|
+
})();
|
|
2844
4141
|
};
|
|
2845
4142
|
const manualSave = async () => {
|
|
2846
4143
|
if (props.writeField === void 0) {
|
|
4144
|
+
if (hasStagedInvalid()) {
|
|
4145
|
+
setSaveState("idle");
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
2847
4148
|
props.save?.();
|
|
2848
4149
|
markSaved();
|
|
2849
4150
|
return;
|
|
2850
4151
|
}
|
|
2851
|
-
const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter(
|
|
4152
|
+
const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter(
|
|
4153
|
+
(item) => savedValues.current.get(item.key) !== item.text && !isStagedInvalid(item.key, item.text)
|
|
4154
|
+
);
|
|
2852
4155
|
if (changed.length === 0) {
|
|
4156
|
+
if (hasStagedInvalid()) {
|
|
4157
|
+
setSaveState("idle");
|
|
4158
|
+
return;
|
|
4159
|
+
}
|
|
2853
4160
|
markSaved();
|
|
2854
4161
|
return;
|
|
2855
4162
|
}
|
|
@@ -2882,10 +4189,17 @@ function SettingsRows(props) {
|
|
|
2882
4189
|
}, 800);
|
|
2883
4190
|
timers.current.set(key, timer);
|
|
2884
4191
|
};
|
|
2885
|
-
const onEdit = (key, text) => {
|
|
4192
|
+
const onEdit = (key, text, options) => {
|
|
4193
|
+
const previousProvider = key === "provider" ? viewOf(props.state, "provider").text : "";
|
|
2886
4194
|
props.edit(key, text);
|
|
4195
|
+
if (key === "provider" && text !== previousProvider && viewOf(props.state, "model").text !== "") {
|
|
4196
|
+
props.resetField("model");
|
|
4197
|
+
savedValues.current.set("model", "");
|
|
4198
|
+
void runReset("model", "");
|
|
4199
|
+
}
|
|
2887
4200
|
const row = ROWS.find((item) => item.key === key);
|
|
2888
|
-
const
|
|
4201
|
+
const typing = row !== void 0 && (row.kind === "text" || row.kind === "number");
|
|
4202
|
+
const debounced = options?.deferred === true || typing;
|
|
2889
4203
|
scheduleSave(key, text, !debounced);
|
|
2890
4204
|
};
|
|
2891
4205
|
const flushField = (key, text) => {
|
|
@@ -2896,7 +4210,7 @@ function SettingsRows(props) {
|
|
|
2896
4210
|
}
|
|
2897
4211
|
void runSave(key, text ?? viewOf(props.state, key).text);
|
|
2898
4212
|
};
|
|
2899
|
-
(0,
|
|
4213
|
+
(0, import_react10.useEffect)(
|
|
2900
4214
|
() => () => {
|
|
2901
4215
|
for (const timer of timers.current.values()) clearTimeout(timer);
|
|
2902
4216
|
timers.current.clear();
|
|
@@ -2908,7 +4222,7 @@ function SettingsRows(props) {
|
|
|
2908
4222
|
const renderRow = (row, index) => {
|
|
2909
4223
|
const raw = viewOf(props.state, row.key);
|
|
2910
4224
|
const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
4225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2912
4226
|
SettingsRow,
|
|
2913
4227
|
{
|
|
2914
4228
|
row,
|
|
@@ -2918,21 +4232,21 @@ function SettingsRows(props) {
|
|
|
2918
4232
|
reasoningPair: { provider, model },
|
|
2919
4233
|
routing,
|
|
2920
4234
|
providerValue: provider,
|
|
2921
|
-
onEdit: (text) => onEdit(row.key, text),
|
|
4235
|
+
onEdit: (text, options) => onEdit(row.key, text, options),
|
|
2922
4236
|
onReset: () => resetAndSave(row.key),
|
|
2923
4237
|
onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
|
|
2924
4238
|
}
|
|
2925
4239
|
) }, row.key);
|
|
2926
4240
|
};
|
|
2927
|
-
return /* @__PURE__ */ (0,
|
|
4241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsh-pe-form", children: [
|
|
2928
4242
|
BASIC_ROWS.map(renderRow),
|
|
2929
|
-
/* @__PURE__ */ (0,
|
|
2930
|
-
/* @__PURE__ */ (0,
|
|
4243
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "dsh-pe-advanced", children: [
|
|
4244
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children: props.copy.labels.advanced }),
|
|
2931
4245
|
ADVANCED_ROWS.map(renderRow)
|
|
2932
4246
|
] }),
|
|
2933
|
-
/* @__PURE__ */ (0,
|
|
2934
|
-
statusText === "" ? null : /* @__PURE__ */ (0,
|
|
2935
|
-
/* @__PURE__ */ (0,
|
|
4247
|
+
/* @__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: [
|
|
4248
|
+
statusText === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dsh-pe-save-status", role: "status", "aria-live": "polite", children: statusText }),
|
|
4249
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2936
4250
|
"button",
|
|
2937
4251
|
{
|
|
2938
4252
|
type: "button",
|
|
@@ -2955,15 +4269,15 @@ function SettingsSection(props) {
|
|
|
2955
4269
|
const t = translator(props.translate);
|
|
2956
4270
|
const chinese = (locale?.active ?? "zh").toLowerCase().startsWith("zh");
|
|
2957
4271
|
if (state === void 0) {
|
|
2958
|
-
return /* @__PURE__ */ (0,
|
|
4272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2959
4273
|
}
|
|
2960
4274
|
const edit = props.edit ?? (() => {
|
|
2961
4275
|
});
|
|
2962
4276
|
const resetField = props.resetField ?? (() => {
|
|
2963
4277
|
});
|
|
2964
|
-
return /* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
4278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
4279
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PageHeader, { title: t("settings.title"), description: t("settings.description"), version: PLUGIN_VERSION }),
|
|
4280
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsRows, { copy: sectionCopy(t, chinese), state, edit, resetField, save: props.save, discard: props.discard, writeField: props.writeField })
|
|
2967
4281
|
] });
|
|
2968
4282
|
}
|
|
2969
4283
|
function SettingsPage(props) {
|
|
@@ -2972,13 +4286,13 @@ function SettingsPage(props) {
|
|
|
2972
4286
|
const state = read === void 0 ? void 0 : read((snapshot) => snapshot);
|
|
2973
4287
|
if (props.view === "summary") return t("settings.summary");
|
|
2974
4288
|
if (state === void 0) {
|
|
2975
|
-
return /* @__PURE__ */ (0,
|
|
4289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.6 }, children: t("settings.disconnected") });
|
|
2976
4290
|
}
|
|
2977
4291
|
const edit = props.edit ?? (() => {
|
|
2978
4292
|
});
|
|
2979
4293
|
const resetField = props.resetField ?? (() => {
|
|
2980
4294
|
});
|
|
2981
|
-
return /* @__PURE__ */ (0,
|
|
4295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsRows, { copy: pageCopy(t), state, edit, resetField, save: props.save, discard: props.discard, writeField: props.writeField });
|
|
2982
4296
|
}
|
|
2983
4297
|
var SettingsPageController = class {
|
|
2984
4298
|
/**
|
|
@@ -3107,6 +4421,7 @@ function installSettingsPages(ctx, getLocale) {
|
|
|
3107
4421
|
}
|
|
3108
4422
|
|
|
3109
4423
|
// src/client/index.tsx
|
|
4424
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3110
4425
|
var inject = [];
|
|
3111
4426
|
function report(step, error) {
|
|
3112
4427
|
try {
|
|
@@ -3140,7 +4455,8 @@ function apply(ctx) {
|
|
|
3140
4455
|
if (slots === void 0) return;
|
|
3141
4456
|
return slots.inject("conversation.input.right", () => {
|
|
3142
4457
|
try {
|
|
3143
|
-
|
|
4458
|
+
const Bound = (buttonProps) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EnhanceButton, { ...buttonProps, __ctx: ctx });
|
|
4459
|
+
return slots.register({ name: "conversation.input.right", id: "dsh-prompt-enhance", order: 60, locale: NS }, Bound);
|
|
3144
4460
|
} catch (error) {
|
|
3145
4461
|
return report("composer enhance button slot", error);
|
|
3146
4462
|
}
|