@klarkxy/dsh-current-title 0.2.3 → 0.2.5

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.
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let react = require("react");
3
3
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
4
+ let react_dom = require("react-dom");
4
5
  let react_jsx_runtime = require("react/jsx-runtime");
5
6
  //#region ../dsh-plugin-kit/src/client-utils.ts
6
7
  /** Fixed pause for failing background reads; manual work is never replayed. */
@@ -477,6 +478,29 @@ ${scope} {
477
478
  & .dsh-ui-select:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }
478
479
  & .dsh-ui-select[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }
479
480
 
481
+ /* --- Native textarea. The primitives ship no textarea either, so a settings
482
+ * prompt keeps the platform element and the same field shell as the select:
483
+ * 0.5px l4, radius-md, layer-3, 13/1.5 type. It grows vertically instead of
484
+ * locking to the select's 34px row. --- */
485
+ & .dsh-ui-textarea {
486
+ box-sizing: border-box;
487
+ width: 100%;
488
+ min-width: 0;
489
+ resize: vertical;
490
+ padding: 8px 12px;
491
+ border: 0.5px solid var(--dsw-alias-border-l4);
492
+ border-radius: var(--dsw-radius-md);
493
+ background: var(--dsw-alias-bg-layer-3);
494
+ font: inherit;
495
+ font-size: 13px;
496
+ line-height: 1.5;
497
+ color: var(--dsw-alias-label-primary);
498
+ }
499
+ & .dsh-ui-textarea:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }
500
+ & .dsh-ui-textarea:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }
501
+ & .dsh-ui-textarea::placeholder { color: var(--dsw-alias-label-dimmed); }
502
+ & .dsh-ui-textarea[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }
503
+
480
504
  /* Long panels scroll inside themselves instead of growing the host page. */
481
505
  & .dsh-ui-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
482
506
  & .dsh-ui-panel-wide { max-width: 100%; }
@@ -644,6 +668,965 @@ function createModelSettingsSubscriber(ctx, namespace) {
644
668
  } });
645
669
  }
646
670
  //#endregion
671
+ //#region ../dsh-model-route/src/catalog.ts
672
+ /** Both services are required: Cordis checks the nested namespace separately. */
673
+ const MODEL_CATALOG_INJECT = ["remote", "remote.session"];
674
+ function asRecord(value) {
675
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
676
+ }
677
+ function asText(value) {
678
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
679
+ }
680
+ /** A useful diagnostic even when a transport rejects with a plain object. */
681
+ function modelCatalogErrorMessage(value) {
682
+ if (value instanceof Error && value.message) return value.message;
683
+ return asText(asRecord(value)?.message) ?? asText(value) ?? "Unable to load the model catalog.";
684
+ }
685
+ /**
686
+ * Validate and unwrap a successful catalog without discarding provider failures
687
+ * or newer host metadata. Names and metadata remain optional for older hosts.
688
+ * A broken response is never presented as a successfully loaded empty menu.
689
+ */
690
+ function checkedModelCatalog(value) {
691
+ const envelope = asRecord(value);
692
+ if (envelope?.ok === false) throw new Error(modelCatalogErrorMessage(envelope.error ?? envelope));
693
+ const root = envelope?.ok === true ? asRecord(envelope.value) : envelope;
694
+ const malformed = (field) => {
695
+ throw new Error(`Invalid model catalog: ${field}.`);
696
+ };
697
+ if (!root || !Array.isArray(root.groups)) return malformed("groups must be an array");
698
+ for (const value of root.groups) {
699
+ const group = asRecord(value);
700
+ if (!group || !asText(group.id) || !Array.isArray(group.models)) return malformed("each group needs an id and models array");
701
+ for (const value of group.models) {
702
+ const model = asRecord(value);
703
+ if (!model || !asText(model.id)) return malformed("each model needs an id");
704
+ if (model.reasoning !== void 0) {
705
+ const reasoning = asRecord(model.reasoning);
706
+ if (!reasoning || !Array.isArray(reasoning.efforts) || reasoning.efforts.some((value) => !parseEffort(value))) return malformed("reasoning efforts must be an array of identified efforts");
707
+ }
708
+ }
709
+ }
710
+ if (root.failures !== void 0 && (!Array.isArray(root.failures) || root.failures.some((value) => {
711
+ const failure = asRecord(value);
712
+ return !failure || !asText(failure.id) || typeof failure.name !== "string" || typeof failure.message !== "string";
713
+ }))) return malformed("failures must be an array of provider failures");
714
+ return root;
715
+ }
716
+ /** Read through the injected session namespace; absence and rejection are errors. */
717
+ async function readModelCatalog(client) {
718
+ const session = client.remote?.session;
719
+ if (typeof session?.modelCatalog !== "function") throw new Error("Model catalog unavailable: inject both remote and remote.session.");
720
+ return checkedModelCatalog(await session.modelCatalog());
721
+ }
722
+ /** Provider failures are partial results, not a transport failure. */
723
+ function modelCatalogFailures(value) {
724
+ try {
725
+ return checkedModelCatalog(value).failures ?? [];
726
+ } catch {
727
+ return [];
728
+ }
729
+ }
730
+ function parseEffort(value) {
731
+ const row = asRecord(value);
732
+ const id = row ? asText(row.id) : void 0;
733
+ if (!id) return void 0;
734
+ return {
735
+ id,
736
+ name: row ? asText(row.name) ?? id : id
737
+ };
738
+ }
739
+ /** Parse the host session catalog into flat choices, keeping a saved route selectable. */
740
+ function parseModelMenuChoices(value, bound) {
741
+ const envelope = asRecord(value);
742
+ const root = (envelope && envelope.ok === true ? asRecord(envelope.value) : void 0) ?? envelope ?? {};
743
+ const groups = Array.isArray(root.groups) ? root.groups : [];
744
+ const choices = [];
745
+ for (const group of groups) {
746
+ const groupRow = asRecord(group);
747
+ const provider = groupRow ? asText(groupRow.id) : void 0;
748
+ if (!provider || !groupRow || !Array.isArray(groupRow.models)) continue;
749
+ const providerName = asText(groupRow.name) ?? provider;
750
+ for (const entry of groupRow.models) {
751
+ const modelRow = asRecord(entry);
752
+ const model = modelRow ? asText(modelRow.id) : void 0;
753
+ if (!model || !modelRow) continue;
754
+ const name = asText(modelRow.name) ?? model;
755
+ const reasoning = asRecord(modelRow.reasoning);
756
+ const efforts = reasoning && Array.isArray(reasoning.efforts) ? reasoning.efforts.flatMap((effort) => {
757
+ const parsed = parseEffort(effort);
758
+ return parsed ? [parsed] : [];
759
+ }) : [];
760
+ choices.push({
761
+ provider,
762
+ model,
763
+ label: `${providerName} / ${name}`,
764
+ efforts
765
+ });
766
+ }
767
+ }
768
+ if (bound?.provider && bound.model && !choices.some((item) => item.provider === bound.provider && item.model === bound.model)) choices.push({
769
+ provider: bound.provider,
770
+ model: bound.model,
771
+ label: `${bound.provider} / ${bound.model}`,
772
+ efforts: []
773
+ });
774
+ return choices;
775
+ }
776
+ /** Reasoning-effort options for one choice; the saved value stays selectable. */
777
+ function modelMenuEffortOptions(choice, current) {
778
+ const listed = (choice?.efforts ?? []).map((item) => ({ ...item }));
779
+ if (current && !listed.some((item) => item.id === current)) listed.push({
780
+ id: current,
781
+ name: current
782
+ });
783
+ return listed;
784
+ }
785
+ //#endregion
786
+ //#region ../dsh-model-route/src/menu.ts
787
+ /** Localize standard effort ids only when the provider has not supplied a display name. */
788
+ function modelMenuEffortLabel(effort, locale) {
789
+ if (effort.name !== effort.id) return effort.name;
790
+ return {
791
+ off: ["关闭", "Off"],
792
+ none: ["无", "None"],
793
+ minimal: ["最低", "Minimal"],
794
+ low: ["低", "Low"],
795
+ medium: ["中", "Medium"],
796
+ high: ["高", "High"],
797
+ xhigh: ["极高", "Extra high"],
798
+ max: ["最高", "Maximum"],
799
+ ultra: ["超高", "Ultra"]
800
+ }[effort.id]?.[locale?.toLowerCase().startsWith("zh") ? 0 : 1] ?? effort.name;
801
+ }
802
+ /** The short model label shown inside a provider group. */
803
+ function modelMenuShortName(choice) {
804
+ const sep = choice.label.indexOf(" / ");
805
+ return sep > 0 ? choice.label.slice(sep + 3) : choice.model;
806
+ }
807
+ /** Group catalog choices by provider and filter them by a case-insensitive query. */
808
+ function groupModelMenuChoices(choices, query) {
809
+ const needle = query.trim().toLowerCase();
810
+ const matched = needle ? choices.filter((choice) => choice.label.toLowerCase().includes(needle) || choice.model.toLowerCase().includes(needle) || choice.provider.toLowerCase().includes(needle)) : choices;
811
+ const groups = [];
812
+ for (const choice of matched) {
813
+ const sep = choice.label.indexOf(" / ");
814
+ const name = sep > 0 ? choice.label.slice(0, sep) : choice.provider;
815
+ const last = groups.at(-1);
816
+ if (last && last.provider === choice.provider) last.items.push(choice);
817
+ else groups.push({
818
+ provider: choice.provider,
819
+ name,
820
+ items: [choice]
821
+ });
822
+ }
823
+ return groups;
824
+ }
825
+ //#endregion
826
+ //#region ../dsh-model-route/src/catalog-ui.tsx
827
+ /**
828
+ * Latest refresh wins, including retries while a previous request is pending.
829
+ * Keep load stable (for example with useCallback); changing it invalidates the
830
+ * previous source and fetches again, so switching clients cannot publish stale data.
831
+ */
832
+ function useModelCatalog(load, options = {}) {
833
+ const enabled = options.enabled !== false;
834
+ const enabledRef = (0, react.useRef)(enabled);
835
+ enabledRef.current = enabled;
836
+ const live = (0, react.useRef)(false);
837
+ const source = (0, react.useRef)(load);
838
+ const revision = (0, react.useRef)(0);
839
+ const [state, setState] = (0, react.useState)(() => {
840
+ try {
841
+ return {
842
+ catalog: options.initialCatalog === void 0 ? void 0 : checkedModelCatalog(options.initialCatalog),
843
+ loading: enabled,
844
+ error: ""
845
+ };
846
+ } catch (error) {
847
+ return {
848
+ catalog: void 0,
849
+ loading: enabled,
850
+ error: modelCatalogErrorMessage(error)
851
+ };
852
+ }
853
+ });
854
+ const refresh = (0, react.useCallback)(async () => {
855
+ if (!live.current || !enabledRef.current) return;
856
+ const request = ++revision.current;
857
+ setState((previous) => ({
858
+ ...previous,
859
+ loading: true,
860
+ error: ""
861
+ }));
862
+ try {
863
+ const catalog = checkedModelCatalog(await load());
864
+ if (live.current && request === revision.current) setState({
865
+ catalog,
866
+ loading: false,
867
+ error: ""
868
+ });
869
+ } catch (error) {
870
+ if (live.current && request === revision.current) setState((previous) => ({
871
+ ...previous,
872
+ loading: false,
873
+ error: modelCatalogErrorMessage(error)
874
+ }));
875
+ }
876
+ }, [load, enabled]);
877
+ (0, react.useEffect)(() => {
878
+ live.current = true;
879
+ if (source.current !== load) {
880
+ source.current = load;
881
+ setState({
882
+ catalog: void 0,
883
+ loading: enabled,
884
+ error: ""
885
+ });
886
+ }
887
+ if (enabled) refresh();
888
+ else setState((previous) => ({
889
+ ...previous,
890
+ loading: false
891
+ }));
892
+ return () => {
893
+ live.current = false;
894
+ ++revision.current;
895
+ };
896
+ }, [enabled, refresh]);
897
+ (0, react.useEffect)(() => {
898
+ if (!enabled) return;
899
+ const reload = () => {
900
+ refresh();
901
+ };
902
+ if (typeof window !== "undefined") window.addEventListener("focus", reload);
903
+ let unsubscribe;
904
+ try {
905
+ unsubscribe = options.subscribe?.(reload);
906
+ } catch (error) {
907
+ setState((previous) => ({
908
+ ...previous,
909
+ error: modelCatalogErrorMessage(error)
910
+ }));
911
+ }
912
+ return () => {
913
+ if (typeof window !== "undefined") window.removeEventListener("focus", reload);
914
+ unsubscribe?.();
915
+ };
916
+ }, [
917
+ enabled,
918
+ refresh,
919
+ options.subscribe
920
+ ]);
921
+ const choices = (0, react.useMemo)(() => parseModelMenuChoices(state.catalog), [state.catalog]);
922
+ const failures = (0, react.useMemo)(() => state.catalog === void 0 ? [] : modelCatalogFailures(state.catalog), [state.catalog]);
923
+ return {
924
+ ...state,
925
+ choices,
926
+ failures,
927
+ refresh
928
+ };
929
+ }
930
+ /** Also accepts a mapped state from a caller that owns broader async orchestration. */
931
+ function ModelCatalogStatus({ state, locale }) {
932
+ const zh = locale?.toLowerCase().startsWith("zh") === true;
933
+ const copy = zh ? {
934
+ loading: "正在加载模型…",
935
+ error: "模型列表加载失败",
936
+ partial: "部分提供商的模型未能加载",
937
+ retry: "重试"
938
+ } : {
939
+ loading: "Loading models…",
940
+ error: "Unable to load models",
941
+ partial: "Some providers could not load their models",
942
+ retry: "Retry"
943
+ };
944
+ if (!state.loading && !state.error && state.failures.length === 0) return null;
945
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
946
+ className: "dsh-model-catalog-status",
947
+ lang: zh ? "zh" : "en",
948
+ children: [
949
+ state.loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
950
+ role: "status",
951
+ children: copy.loading
952
+ }) : null,
953
+ state.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
954
+ role: "alert",
955
+ children: [
956
+ copy.error,
957
+ ": ",
958
+ state.error
959
+ ]
960
+ }) : null,
961
+ state.failures.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
962
+ role: "status",
963
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: copy.partial }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: state.failures.map((failure, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { children: [
964
+ failure.name || failure.id,
965
+ ": ",
966
+ failure.message
967
+ ] }, `${failure.id}:${index}`)) })]
968
+ }) : null,
969
+ state.error || state.failures.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
970
+ type: "button",
971
+ size: "sm",
972
+ disabled: state.loading,
973
+ onClick: () => {
974
+ state.refresh();
975
+ },
976
+ children: copy.retry
977
+ }) : null
978
+ ]
979
+ });
980
+ }
981
+ //#endregion
982
+ //#region ../dsh-model-route/src/ui.tsx
983
+ /**
984
+ * ModelMenu: the standard editor of one model-route field — the visible half
985
+ * of the x-model-route contract. A feature plugin's settings page renders it
986
+ * for its own marked field; the model hub renders one per detected field.
987
+ *
988
+ * It is a plugin-side copy of the host's composer model picker
989
+ * (dsh-client-ui-model-selection's ModelSelect), rebuilt from the official
990
+ * primitives and the published bundle's behavior: one card that opens on the
991
+ * root pane (Model / Effort cells), drills into the provider-grouped,
992
+ * searchable model list or the effort list, and Escapes back before closing.
993
+ * Sticky group headings, subsequence ranking, highlight walking and focus
994
+ * hand-back all match the host. SYNC POINT: when the host's ModelSelect or
995
+ * ModelSelect.module.css changes, this copy must be re-transcribed; styles
996
+ * below may only reference --dsw-* theme tokens, never literal colors.
997
+ *
998
+ * It statically imports the primitives, so only browser clients should load
999
+ * this entry; host code and node tests use the core entry (`./index.ts`).
1000
+ */
1001
+ /** Unplaced portal card: hidden but laid out at a fixed origin so measurements are real. */
1002
+ const MEASURE_STYLE = {
1003
+ visibility: "hidden",
1004
+ left: 0,
1005
+ top: 0
1006
+ };
1007
+ function ModelMenu(props) {
1008
+ const language = props.locale?.toLowerCase().startsWith("zh") ? "zh" : "en";
1009
+ const copy = language === "zh" ? {
1010
+ model: "模型",
1011
+ effort: "思考强度",
1012
+ default: "默认",
1013
+ search: "搜索模型…",
1014
+ empty: "没有匹配的模型",
1015
+ clear: "清除搜索"
1016
+ } : {
1017
+ model: "Model",
1018
+ effort: "Reasoning",
1019
+ default: "Default",
1020
+ search: "Search models…",
1021
+ empty: "No matching models",
1022
+ clear: "Clear search"
1023
+ };
1024
+ const { open, onOpenChange, anchor, choices, selected, onPick, leading = [], onPickLeading, efforts = [], selectedEffort, onPickEffort, modelLabel = copy.model, modelValue = "—", effortLabel = copy.effort, effortValue, defaultEffortLabel = copy.default, searchPlaceholder = copy.search, emptyLabel = copy.empty, clearSearchLabel = copy.clear, className, listClassName } = props;
1025
+ const rootRef = (0, react.useRef)(null);
1026
+ const openRef = (0, react.useRef)(open);
1027
+ openRef.current = open;
1028
+ const pendingOpenRef = (0, react.useRef)(false);
1029
+ const pendingRestoreFocus = (0, react.useRef)(false);
1030
+ const [requestedOpen, setRequestedOpen] = (0, react.useState)(false);
1031
+ const menuRef = (0, react.useRef)(null);
1032
+ const groupsRef = (0, react.useRef)(null);
1033
+ const searchRef = (0, react.useRef)(null);
1034
+ const itemRefs = (0, react.useRef)([]);
1035
+ const paneFocus = (0, react.useRef)(null);
1036
+ const [pane, setPane] = (0, react.useState)("root");
1037
+ const [query, setQuery] = (0, react.useState)("");
1038
+ const [highlightedIndex, setHighlightedIndex] = (0, react.useState)(null);
1039
+ const [menuPos, setMenuPos] = (0, react.useState)(null);
1040
+ const id = (0, react.useId)();
1041
+ const showSearch = choices.length > 4;
1042
+ const effortRows = (0, react.useMemo)(() => [{
1043
+ id: "",
1044
+ name: defaultEffortLabel
1045
+ }, ...efforts.map((effort) => ({
1046
+ ...effort,
1047
+ name: modelMenuEffortLabel(effort, language)
1048
+ }))], [
1049
+ defaultEffortLabel,
1050
+ efforts,
1051
+ language
1052
+ ]);
1053
+ const filteredGroups = (0, react.useMemo)(() => groupModelMenuChoices(choices, "").map((group) => ({
1054
+ ...group,
1055
+ items: (0, _deepseek_ai_dsh_client_ui_primitives.rankByName)(group.items.map((choice) => ({
1056
+ choice,
1057
+ name: modelMenuShortName(choice),
1058
+ label: choice.model
1059
+ })), showSearch ? query.trim() : "")
1060
+ })).filter((group) => group.items.length > 0), [
1061
+ choices,
1062
+ query,
1063
+ showSearch
1064
+ ]);
1065
+ const visibleModels = (0, react.useMemo)(() => filteredGroups.flatMap((group) => group.items.map((item) => item.choice)), [filteredGroups]);
1066
+ const currentVisibleIndex = visibleModels.findIndex((choice) => choice.provider === selected?.provider && choice.model === selected.model);
1067
+ const activeModelIndex = Math.min(highlightedIndex ?? Math.max(0, currentVisibleIndex), visibleModels.length - 1);
1068
+ const changeOpen = (next) => {
1069
+ if (openRef.current === next) return;
1070
+ openRef.current = next;
1071
+ onOpenChange(next);
1072
+ };
1073
+ const requestOpen = () => {
1074
+ if (open || pendingOpenRef.current) return;
1075
+ pendingOpenRef.current = true;
1076
+ pendingRestoreFocus.current = false;
1077
+ setRequestedOpen(true);
1078
+ };
1079
+ const close = (restoreFocus = false) => {
1080
+ const active = document.activeElement;
1081
+ pendingRestoreFocus.current = restoreFocus && (active === document.body || rootRef.current?.contains(active) === true || menuRef.current?.contains(active) === true);
1082
+ changeOpen(false);
1083
+ };
1084
+ const drill = (next) => {
1085
+ setQuery("");
1086
+ setHighlightedIndex(null);
1087
+ paneFocus.current = "drill";
1088
+ setPane(next);
1089
+ };
1090
+ /** Leave a drilled pane for the root one, handing the keyboard back to its cell. */
1091
+ const back = (from) => {
1092
+ paneFocus.current = from;
1093
+ setPane("root");
1094
+ };
1095
+ const moveFocus = (offset) => {
1096
+ const items = itemRefs.current.filter((item) => item !== null && !item.disabled);
1097
+ if (!items.length) return;
1098
+ const active = items.findIndex((item) => item === document.activeElement);
1099
+ items[active === -1 ? offset > 0 ? 0 : items.length - 1 : (active + offset + items.length) % items.length]?.focus();
1100
+ };
1101
+ (0, react.useLayoutEffect)(() => {
1102
+ if (open || !pendingRestoreFocus.current) return;
1103
+ const active = document.activeElement;
1104
+ if (active !== document.body && !rootRef.current?.contains(active)) {
1105
+ pendingRestoreFocus.current = false;
1106
+ return;
1107
+ }
1108
+ const trigger = rootRef.current?.querySelector("button");
1109
+ if (!trigger || trigger.disabled) return;
1110
+ trigger.focus();
1111
+ if (document.activeElement === trigger) pendingRestoreFocus.current = false;
1112
+ });
1113
+ (0, react.useEffect)(() => {
1114
+ if (open || !pendingRestoreFocus.current) return;
1115
+ const cancelOutside = (event) => {
1116
+ if (event.target instanceof Node && !rootRef.current?.contains(event.target)) pendingRestoreFocus.current = false;
1117
+ };
1118
+ document.addEventListener("focusin", cancelOutside);
1119
+ document.addEventListener("pointerdown", cancelOutside);
1120
+ return () => {
1121
+ document.removeEventListener("focusin", cancelOutside);
1122
+ document.removeEventListener("pointerdown", cancelOutside);
1123
+ };
1124
+ });
1125
+ (0, react.useEffect)(() => {
1126
+ if (!requestedOpen) return;
1127
+ pendingOpenRef.current = false;
1128
+ setRequestedOpen(false);
1129
+ if (!open) changeOpen(true);
1130
+ }, [requestedOpen, open]);
1131
+ (0, react.useEffect)(() => {
1132
+ if (!open) return;
1133
+ setPane("root");
1134
+ setQuery("");
1135
+ setHighlightedIndex(null);
1136
+ }, [open]);
1137
+ (0, react.useEffect)(() => {
1138
+ if (!open) return;
1139
+ const closeOutside = (event) => {
1140
+ const target = event.target;
1141
+ if (rootRef.current?.contains(target) || menuRef.current?.contains(target)) return;
1142
+ changeOpen(false);
1143
+ };
1144
+ document.addEventListener("mousedown", closeOutside);
1145
+ return () => document.removeEventListener("mousedown", closeOutside);
1146
+ }, [open, onOpenChange]);
1147
+ (0, react.useEffect)(() => {
1148
+ const intent = paneFocus.current;
1149
+ if (!open || menuPos === null || intent === null) return;
1150
+ if (intent !== "drill" && pane !== "root") return;
1151
+ paneFocus.current = null;
1152
+ if (intent === "drill") {
1153
+ if (pane === "model" && showSearch) {
1154
+ searchRef.current?.focus();
1155
+ return;
1156
+ }
1157
+ (menuRef.current?.querySelector("[role=\"menuitemradio\"][aria-checked=\"true\"]:not([disabled])") ?? itemRefs.current.find((item) => item !== null && !item.disabled))?.focus();
1158
+ return;
1159
+ }
1160
+ itemRefs.current[intent === "effort" ? 1 : 0]?.focus();
1161
+ }, [
1162
+ open,
1163
+ pane,
1164
+ showSearch,
1165
+ menuPos
1166
+ ]);
1167
+ (0, react.useEffect)(() => {
1168
+ const viewport = groupsRef.current;
1169
+ if (viewport === null) return;
1170
+ return (0, _deepseek_ai_dsh_client_ui_primitives.observeStickyMenuGroups)(viewport);
1171
+ }, [
1172
+ open,
1173
+ pane,
1174
+ filteredGroups
1175
+ ]);
1176
+ (0, react.useLayoutEffect)(() => {
1177
+ if (open && pane === "model" && activeModelIndex >= 0) itemRefs.current[leading.length + activeModelIndex]?.scrollIntoView({ block: "nearest" });
1178
+ }, [
1179
+ open,
1180
+ pane,
1181
+ activeModelIndex,
1182
+ visibleModels,
1183
+ leading.length
1184
+ ]);
1185
+ (0, react.useLayoutEffect)(() => {
1186
+ if (!open) {
1187
+ setMenuPos(null);
1188
+ return;
1189
+ }
1190
+ const place = () => {
1191
+ const rect = rootRef.current?.getBoundingClientRect();
1192
+ if (!rect) return;
1193
+ const margin = 12, lw = menuRef.current?.offsetWidth ?? 0, lh = menuRef.current?.offsetHeight ?? 0;
1194
+ let x = rect.right - lw, y = rect.top - 8 - lh;
1195
+ if (lw > 0) x = Math.min(Math.max(x, margin), window.innerWidth - lw - margin);
1196
+ if (lh > 0) y = Math.min(Math.max(y, margin), window.innerHeight - lh - margin);
1197
+ setMenuPos({
1198
+ left: x,
1199
+ top: y
1200
+ });
1201
+ };
1202
+ place();
1203
+ window.addEventListener("scroll", place, true);
1204
+ window.addEventListener("resize", place);
1205
+ return () => {
1206
+ window.removeEventListener("scroll", place, true);
1207
+ window.removeEventListener("resize", place);
1208
+ };
1209
+ }, [
1210
+ open,
1211
+ pane,
1212
+ choices,
1213
+ query
1214
+ ]);
1215
+ function onKeyDown(event) {
1216
+ if (event.defaultPrevented || event.nativeEvent.isComposing) return;
1217
+ if (!open && [
1218
+ "Enter",
1219
+ " ",
1220
+ "ArrowDown",
1221
+ "ArrowUp"
1222
+ ].includes(event.key)) {
1223
+ const button = event.target instanceof Element ? event.target.closest("button") : null;
1224
+ if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return;
1225
+ event.preventDefault();
1226
+ paneFocus.current = "model";
1227
+ requestOpen();
1228
+ return;
1229
+ }
1230
+ if (event.key === "Escape" && open) {
1231
+ event.preventDefault();
1232
+ if (pane !== "root") back(pane);
1233
+ else close(true);
1234
+ return;
1235
+ }
1236
+ if (!open) return;
1237
+ if (pane === "model" && showSearch && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
1238
+ event.preventDefault();
1239
+ if (visibleModels.length > 0) {
1240
+ setHighlightedIndex((activeModelIndex + (event.key === "ArrowDown" ? 1 : -1) + visibleModels.length) % visibleModels.length);
1241
+ searchRef.current?.focus();
1242
+ }
1243
+ return;
1244
+ }
1245
+ if (pane === "model" && showSearch && event.target instanceof HTMLInputElement && (event.key === "Enter" || event.key === "Tab" && !event.shiftKey)) {
1246
+ if (event.key === "Tab" && visibleModels.length === 0) return;
1247
+ event.preventDefault();
1248
+ const highlighted = visibleModels[activeModelIndex];
1249
+ if (highlighted) {
1250
+ onPick({
1251
+ provider: highlighted.provider,
1252
+ model: highlighted.model
1253
+ });
1254
+ close(true);
1255
+ }
1256
+ return;
1257
+ }
1258
+ if (event.key === "Tab") {
1259
+ if (event.shiftKey) {
1260
+ event.preventDefault();
1261
+ if (pane !== "root") back(pane);
1262
+ else close(true);
1263
+ return;
1264
+ }
1265
+ const focused = document.activeElement;
1266
+ const rows = itemRefs.current.filter((item) => item !== null);
1267
+ if (focused instanceof HTMLButtonElement && rows.includes(focused)) {
1268
+ event.preventDefault();
1269
+ focused.click();
1270
+ return;
1271
+ }
1272
+ if (pane === "model" && showSearch) {
1273
+ event.preventDefault();
1274
+ setHighlightedIndex(null);
1275
+ searchRef.current?.focus();
1276
+ }
1277
+ return;
1278
+ }
1279
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1280
+ event.preventDefault();
1281
+ moveFocus(event.key === "ArrowDown" ? 1 : -1);
1282
+ }
1283
+ }
1284
+ function onBlur(event) {
1285
+ if (event.relatedTarget instanceof Node && (rootRef.current?.contains(event.relatedTarget) || menuRef.current?.contains(event.relatedTarget))) return;
1286
+ if (open) changeOpen(false);
1287
+ }
1288
+ itemRefs.current = [];
1289
+ let itemIndex = 0;
1290
+ let modelIndex = 0;
1291
+ const itemRef = () => {
1292
+ const at = itemIndex++;
1293
+ return (node) => {
1294
+ itemRefs.current[at] = node;
1295
+ };
1296
+ };
1297
+ const menu = open && typeof document !== "undefined" ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.MenuSurface, {
1298
+ ref: menuRef,
1299
+ id: `${id}-menu`,
1300
+ className: `dsh-model-menu-menu${listClassName ? ` ${listClassName}` : ""}`,
1301
+ style: menuPos ?? MEASURE_STYLE,
1302
+ role: pane === "model" ? "group" : "menu",
1303
+ "aria-label": modelLabel,
1304
+ lang: language,
1305
+ children: [
1306
+ pane === "root" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1307
+ ref: itemRef(),
1308
+ type: "button",
1309
+ role: "menuitem",
1310
+ className: "dsh-model-menu-cell",
1311
+ onClick: () => drill("model"),
1312
+ children: [
1313
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1314
+ className: "dsh-model-menu-cellLabel",
1315
+ children: modelLabel
1316
+ }),
1317
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1318
+ className: "dsh-model-menu-cellValue",
1319
+ children: modelValue
1320
+ }),
1321
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { className: "dsh-model-menu-cellChevron" })
1322
+ ]
1323
+ }), efforts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1324
+ ref: itemRef(),
1325
+ type: "button",
1326
+ role: "menuitem",
1327
+ className: "dsh-model-menu-cell",
1328
+ onClick: () => drill("effort"),
1329
+ children: [
1330
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1331
+ className: "dsh-model-menu-cellLabel",
1332
+ children: effortLabel
1333
+ }),
1334
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1335
+ className: "dsh-model-menu-cellValue",
1336
+ children: effortValue ?? effortRows.find((row) => row.id === (selectedEffort ?? ""))?.name ?? defaultEffortLabel
1337
+ }),
1338
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { className: "dsh-model-menu-cellChevron" })
1339
+ ]
1340
+ }) : null] }) : null,
1341
+ pane === "model" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1342
+ showSearch ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1343
+ className: "dsh-model-menu-searchRow",
1344
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
1345
+ ref: searchRef,
1346
+ className: `dsh-model-menu-search${query !== "" ? " dsh-model-menu-searchWithQuery" : ""}`,
1347
+ type: "text",
1348
+ role: "searchbox",
1349
+ "aria-label": searchPlaceholder,
1350
+ "aria-controls": `${id}-models`,
1351
+ "aria-activedescendant": activeModelIndex < 0 ? void 0 : `${id}-model-${activeModelIndex}`,
1352
+ placeholder: searchPlaceholder,
1353
+ value: query,
1354
+ onChange: (event) => {
1355
+ setQuery(event.target.value);
1356
+ setHighlightedIndex(0);
1357
+ }
1358
+ }), query !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1359
+ type: "button",
1360
+ className: "dsh-model-menu-searchClear",
1361
+ "aria-label": clearSearchLabel,
1362
+ onClick: () => {
1363
+ setQuery("");
1364
+ setHighlightedIndex(null);
1365
+ searchRef.current?.focus();
1366
+ },
1367
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseFillRegular, {})
1368
+ }) : null]
1369
+ }) : null,
1370
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1371
+ ref: groupsRef,
1372
+ id: `${id}-models`,
1373
+ className: "dsh-model-menu-groups scrollable",
1374
+ role: "menu",
1375
+ "aria-label": modelLabel,
1376
+ hidden: filteredGroups.length === 0,
1377
+ children: [leading.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1378
+ className: "dsh-model-menu-leading",
1379
+ children: leading.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1380
+ ref: itemRef(),
1381
+ type: "button",
1382
+ role: "menuitemradio",
1383
+ "aria-checked": item.selected === true,
1384
+ className: `dsh-model-menu-option${item.selected === true ? " dsh-model-menu-selected" : ""}`,
1385
+ onClick: () => {
1386
+ onPickLeading?.(item.id);
1387
+ close(true);
1388
+ },
1389
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1390
+ className: "dsh-model-menu-optionCopy",
1391
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1392
+ className: "dsh-model-menu-modelName",
1393
+ children: item.label
1394
+ })
1395
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1396
+ className: "dsh-model-menu-check",
1397
+ children: item.selected === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : null
1398
+ })]
1399
+ }, item.id))
1400
+ }) : null, filteredGroups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuGroup, {
1401
+ label: group.name,
1402
+ children: group.items.map((item) => {
1403
+ const index = modelIndex++;
1404
+ const choice = item.choice;
1405
+ const checked = selected?.provider === choice.provider && selected.model === choice.model;
1406
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1407
+ ref: itemRef(),
1408
+ type: "button",
1409
+ role: "menuitemradio",
1410
+ "aria-checked": checked,
1411
+ id: `${id}-model-${index}`,
1412
+ tabIndex: showSearch ? -1 : 0,
1413
+ onFocus: () => setHighlightedIndex(index),
1414
+ "data-highlighted": index === activeModelIndex ? "" : void 0,
1415
+ className: `dsh-model-menu-option dsh-model-menu-modelOption${checked ? " dsh-model-menu-selected" : ""}${index === activeModelIndex ? " dsh-model-menu-optionActive" : ""}`,
1416
+ onMouseMove: index === activeModelIndex ? void 0 : () => {
1417
+ if (showSearch) setHighlightedIndex(index);
1418
+ else itemRefs.current[leading.length + index]?.focus();
1419
+ },
1420
+ title: choice.label,
1421
+ onClick: () => {
1422
+ onPick({
1423
+ provider: choice.provider,
1424
+ model: choice.model
1425
+ });
1426
+ close(true);
1427
+ },
1428
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1429
+ className: "dsh-model-menu-optionCopy",
1430
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1431
+ className: "dsh-model-menu-modelName",
1432
+ children: modelMenuShortName(choice)
1433
+ })
1434
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1435
+ className: "dsh-model-menu-check",
1436
+ children: checked ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : null
1437
+ })]
1438
+ }, `${choice.provider}/${choice.model}`);
1439
+ })
1440
+ }, group.provider))]
1441
+ }),
1442
+ filteredGroups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1443
+ className: "dsh-model-menu-empty",
1444
+ role: "status",
1445
+ children: emptyLabel
1446
+ }) : null
1447
+ ] }) : null,
1448
+ pane === "effort" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: effortRows.map((row) => {
1449
+ const checked = (selectedEffort ?? "") === row.id;
1450
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1451
+ ref: itemRef(),
1452
+ type: "button",
1453
+ role: "menuitemradio",
1454
+ "aria-checked": checked,
1455
+ className: `dsh-model-menu-option${checked ? " dsh-model-menu-selected" : ""}`,
1456
+ onClick: () => {
1457
+ onPickEffort?.(row.id || void 0);
1458
+ close(true);
1459
+ },
1460
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1461
+ className: "dsh-model-menu-optionCopy",
1462
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1463
+ className: "dsh-model-menu-modelName",
1464
+ children: row.name
1465
+ })
1466
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1467
+ className: "dsh-model-menu-check",
1468
+ children: checked ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : null
1469
+ })]
1470
+ }, row.id || "__default");
1471
+ }) }) : null
1472
+ ]
1473
+ }), document.body) : null;
1474
+ const trigger = (0, react.isValidElement)(anchor) ? (0, react.cloneElement)(anchor, {
1475
+ "aria-haspopup": "menu",
1476
+ "aria-expanded": open,
1477
+ "aria-controls": open ? `${id}-menu` : void 0
1478
+ }) : anchor;
1479
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1480
+ ref: rootRef,
1481
+ className: `dsh-model-menu-root${className ? ` ${className}` : ""}`,
1482
+ onKeyDown,
1483
+ onBlur,
1484
+ onClick: (event) => {
1485
+ if (event.defaultPrevented) return;
1486
+ const button = event.target instanceof Element ? event.target.closest("button") : null;
1487
+ if (!(button instanceof HTMLButtonElement) || button.disabled || !rootRef.current?.contains(button)) return;
1488
+ requestOpen();
1489
+ },
1490
+ onMouseDown: (event) => {
1491
+ if (event.target instanceof Element && menuRef.current?.contains(event.target) && event.target.closest("button") !== null) event.preventDefault();
1492
+ },
1493
+ children: [trigger, menu]
1494
+ });
1495
+ }
1496
+ /**
1497
+ * ModelMenu styles, transcribed from the official ModelSelect.module.css (the
1498
+ * published dsh-client-ui-model-selection bundle): card capped at
1499
+ * min(360px, 100vh - 96px), 34px option cells at 13/18 with 5px 7px padding,
1500
+ * 34px root cells at 13/20, a borderless 12px search row with a clear button,
1501
+ * sticky group headings (MenuGroup's own CSS), and the l1-stroke prominent
1502
+ * elevation at portal z-index 1100. The trigger mirrors the composer's 28px
1503
+ * model pill, chevron rotating open. MenuSurface paints fill and backdrop.
1504
+ * Only --dsw-* theme tokens may appear here — a literal color is a bug.
1505
+ */
1506
+ const modelMenuCss = `
1507
+ .dsh-model-menu-root { min-width: 0; position: relative; display: inline-flex; }
1508
+ .dsh-model-menu-trigger {
1509
+ border-radius: var(--dsw-radius-sm);
1510
+ min-width: 0;
1511
+ max-width: min(360px, 45cqw);
1512
+ height: 28px;
1513
+ color: var(--dsw-alias-label-secondary);
1514
+ cursor: pointer;
1515
+ background: none;
1516
+ border: none;
1517
+ outline: none;
1518
+ align-items: center;
1519
+ gap: 4px;
1520
+ padding: 0 4px 0 8px;
1521
+ font-size: 13px;
1522
+ font-weight: 400;
1523
+ line-height: 20px;
1524
+ display: flex;
1525
+ }
1526
+ .dsh-model-menu-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
1527
+ .dsh-model-menu-trigger:focus-visible:not([data-selection-focus]) { box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
1528
+ .dsh-model-menu-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }
1529
+ .dsh-model-menu-triggerLabel { text-overflow: ellipsis; white-space: nowrap; min-width: 0; overflow: hidden; }
1530
+ .dsh-model-menu-triggerEffort { text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--dsw-alias-label-caption); flex-shrink: 1000; overflow: hidden; }
1531
+ .dsh-model-menu-chevron { color: var(--dsw-alias-label-caption); flex: none; transition: transform 0.12s; }
1532
+ .dsh-model-menu-chevronOpen { transform: rotate(180deg); }
1533
+ .dsh-model-menu-menu {
1534
+ z-index: 1100;
1535
+ --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
1536
+ width: max-content;
1537
+ min-width: min(240px, 100vw - 32px);
1538
+ max-width: min(420px, 100vw - 32px);
1539
+ max-height: min(360px, 100vh - 96px);
1540
+ box-shadow: var(--dsw-elevation-prominent);
1541
+ color: var(--dsw-alias-label-primary);
1542
+ --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
1543
+ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
1544
+ border: 0;
1545
+ flex-direction: column;
1546
+ padding: 4px;
1547
+ display: flex;
1548
+ position: fixed;
1549
+ overflow: hidden;
1550
+ }
1551
+ .dsh-model-menu-status, .dsh-model-menu-empty { color: var(--dsw-alias-label-tertiary); padding: 8px; font-size: 12px; line-height: 18px; }
1552
+ .dsh-model-menu-searchRow { flex-shrink: 0; margin: 2px 0 3px; position: relative; }
1553
+ .dsh-model-menu-searchRow .dsh-model-menu-search { border-radius: var(--dsw-radius-md); background: none; border: 0 solid transparent; height: auto; padding: 5px 7px; display: flex; }
1554
+ .dsh-model-menu-searchRow .dsh-model-menu-search:focus-within { border-color: transparent; }
1555
+ .dsh-model-menu-searchWithQuery { padding-right: 34px; }
1556
+ .dsh-model-menu-searchRow .dsh-model-menu-search input { padding: 0; font-size: 12px; line-height: normal; }
1557
+ .dsh-model-menu-searchRow .dsh-model-menu-search input::placeholder { color: var(--dsw-alias-label-caption); }
1558
+ .dsh-model-menu-searchClear {
1559
+ width: 24px;
1560
+ height: 24px;
1561
+ color: var(--dsw-alias-label-secondary);
1562
+ cursor: pointer;
1563
+ background: none;
1564
+ border: none;
1565
+ border-radius: 50%;
1566
+ justify-content: center;
1567
+ align-items: center;
1568
+ padding: 0;
1569
+ display: inline-flex;
1570
+ position: absolute;
1571
+ top: 50%;
1572
+ right: 4px;
1573
+ transform: translateY(-50%);
1574
+ }
1575
+ .dsh-model-menu-searchClear:hover, .dsh-model-menu-searchClear:focus-visible { background: var(--dsw-alias-interactive-bg-hover); outline: none; }
1576
+ .dsh-model-menu-groups { min-height: 0; overflow-y: auto; }
1577
+ .dsh-model-menu-leading { border-bottom: 0.5px solid var(--dsw-alias-border-l2); margin-bottom: 3px; padding-bottom: 3px; }
1578
+ .dsh-model-menu-option {
1579
+ box-sizing: border-box;
1580
+ border-radius: var(--dsw-radius-md);
1581
+ width: auto;
1582
+ min-width: 100%;
1583
+ min-height: 34px;
1584
+ color: inherit;
1585
+ text-align: left;
1586
+ cursor: pointer;
1587
+ background: none;
1588
+ border: none;
1589
+ outline: none;
1590
+ align-items: center;
1591
+ gap: 6px;
1592
+ padding: 5px 7px;
1593
+ display: flex;
1594
+ }
1595
+ .dsh-model-menu-option:not(.dsh-model-menu-modelOption):hover:not(:disabled),
1596
+ .dsh-model-menu-option:focus-visible,
1597
+ .dsh-model-menu-optionActive:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
1598
+ .dsh-model-menu-modelOption:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
1599
+ .dsh-model-menu-selected { background: none; }
1600
+ .dsh-model-menu-option:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }
1601
+ .dsh-model-menu-optionCopy { flex-direction: column; flex: 1; min-width: 0; display: flex; }
1602
+ .dsh-model-menu-modelName { color: inherit; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 400; line-height: 18px; overflow: hidden; }
1603
+ .dsh-model-menu-check { color: var(--dsw-alias-label-primary); flex: 0 0 14px; place-items: center; display: grid; }
1604
+ .dsh-model-menu-check svg { width: 14px; height: 14px; }
1605
+ .dsh-model-menu-cell {
1606
+ box-sizing: border-box;
1607
+ border-radius: var(--dsw-radius-md);
1608
+ width: auto;
1609
+ min-width: 100%;
1610
+ height: 34px;
1611
+ color: var(--dsw-alias-label-primary);
1612
+ cursor: pointer;
1613
+ text-align: left;
1614
+ background: none;
1615
+ border: none;
1616
+ outline: none;
1617
+ align-items: center;
1618
+ gap: 6px;
1619
+ padding: 0 8px;
1620
+ font-size: 13px;
1621
+ line-height: 20px;
1622
+ display: flex;
1623
+ }
1624
+ .dsh-model-menu-cell:hover, .dsh-model-menu-cell:focus-visible { background: var(--dsw-alias-interactive-bg-hover); }
1625
+ .dsh-model-menu-cellLabel { white-space: nowrap; flex: none; }
1626
+ .dsh-model-menu-cellValue { text-overflow: ellipsis; white-space: nowrap; text-align: right; min-width: 0; color: var(--dsw-alias-label-tertiary); flex: auto; overflow: hidden; }
1627
+ .dsh-model-menu-cellChevron { width: 12px; height: 12px; color: var(--dsw-alias-menu-icon); flex: none; }
1628
+ `;
1629
+ //#endregion
647
1630
  //#region src/contracts.ts
648
1631
  const RPC_CHANNEL = "/dsh-current-title";
649
1632
  const TITLE_CLIENT_SERVICE = "dshCurrentTitleClient";
@@ -652,6 +1635,8 @@ const TITLE_CLIENT_SERVICE = "dshCurrentTitleClient";
652
1635
  const titleCopy = {
653
1636
  zh: {
654
1637
  label: "自动标题",
1638
+ session: "当前会话",
1639
+ noSession: "没有打开的会话。打开一个会话后,可以在这里查看并重新生成标题。",
655
1640
  pinned: "已手动命名",
656
1641
  generating: "正在生成标题…",
657
1642
  regenerate: "重新生成",
@@ -671,10 +1656,13 @@ const titleCopy = {
671
1656
  retry: "重试",
672
1657
  externalChange: "设置已在别处修改。提示词草稿已保留,请重新加载后确认。",
673
1658
  syncUnavailable: "自动刷新不可用,请手动重新加载设置。",
674
- reload: "重新加载(丢弃草稿)"
1659
+ reload: "重新加载(丢弃草稿)",
1660
+ defaults: "默认设置"
675
1661
  },
676
1662
  en: {
677
1663
  label: "Auto Title",
1664
+ session: "Current session",
1665
+ noSession: "No session is open. Open one to see its title and regenerate it here.",
678
1666
  pinned: "Renamed manually",
679
1667
  generating: "Generating title…",
680
1668
  regenerate: "Regenerate",
@@ -694,7 +1682,8 @@ const titleCopy = {
694
1682
  retry: "Retry",
695
1683
  externalChange: "Settings changed elsewhere. Prompt draft preserved; reload and review.",
696
1684
  syncUnavailable: "Automatic refresh unavailable; reload settings manually.",
697
- reload: "Reload (discard draft)"
1685
+ reload: "Reload (discard draft)",
1686
+ defaults: "Default settings"
698
1687
  }
699
1688
  };
700
1689
  /** Only plugin-owned defaults are translated; model output and remote diagnostics stay intact. */
@@ -841,44 +1830,12 @@ const name = "dsh-current-title-client";
841
1830
  const inject = [
842
1831
  "slots",
843
1832
  "connection",
844
- "remote",
845
- "remote.session",
1833
+ ...MODEL_CATALOG_INJECT,
846
1834
  "sessions",
847
1835
  "locale",
848
1836
  "uiWorkspace",
849
1837
  "uiSession"
850
1838
  ];
851
- function catalogChoices(value, selected) {
852
- const envelope = value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
853
- const root = (envelope?.ok === true && envelope.value && typeof envelope.value === "object" && !Array.isArray(envelope.value) ? envelope.value : void 0) ?? envelope ?? {};
854
- const groups = Array.isArray(root.groups) ? root.groups : [];
855
- const choices = [];
856
- for (const group of groups) {
857
- if (!group || typeof group !== "object") continue;
858
- const row = group;
859
- const provider = typeof row.id === "string" ? row.id : "";
860
- const providerName = typeof row.name === "string" && row.name ? row.name : provider;
861
- if (!provider || !Array.isArray(row.models)) continue;
862
- for (const model of row.models) {
863
- if (!model || typeof model !== "object") continue;
864
- const item = model;
865
- const id = typeof item.id === "string" ? item.id : "";
866
- if (!id) continue;
867
- const name = typeof item.name === "string" && item.name ? item.name : id;
868
- choices.push({
869
- provider,
870
- model: id,
871
- label: `${providerName} / ${name}`
872
- });
873
- }
874
- }
875
- if (selected.provider && selected.model && !choices.some((item) => item.provider === selected.provider && item.model === selected.model)) choices.push({
876
- provider: selected.provider,
877
- model: selected.model,
878
- label: `${selected.provider} / ${selected.model}`
879
- });
880
- return choices;
881
- }
882
1839
  function TitleSettings(props) {
883
1840
  const seat = useNativeSeat(props.client);
884
1841
  const sessionId = seat.sessionId;
@@ -889,7 +1846,10 @@ function TitleSettings(props) {
889
1846
  const [note, setNote] = (0, react.useState)("");
890
1847
  const [error, setError] = (0, react.useState)("");
891
1848
  const [prompt, setPrompt] = (0, react.useState)(void 0);
892
- const [choices, setChoices] = (0, react.useState)([]);
1849
+ const catalogState = useModelCatalog((0, react.useCallback)(() => readModelCatalog(props.client), [props.client]), { subscribe: (0, react.useCallback)((change) => props.client.connection.generation?.subscribe(change), [props.client]) });
1850
+ const { refresh: refreshCatalog } = catalogState;
1851
+ const choices = parseModelMenuChoices(catalogState.catalog, status?.settings?.model);
1852
+ const [menuOpen, setMenuOpen] = (0, react.useState)(false);
893
1853
  const [externalChange, setExternalChange] = (0, react.useState)(false);
894
1854
  const [syncError, setSyncError] = (0, react.useState)("");
895
1855
  const [loadingSettings, setLoadingSettings] = (0, react.useState)(true);
@@ -932,26 +1892,6 @@ function TitleSettings(props) {
932
1892
  work,
933
1893
  readGate
934
1894
  ]);
935
- (0, react.useEffect)(() => {
936
- const catalog = props.client.remote?.session?.modelCatalog;
937
- if (!catalog) return void 0;
938
- let live = true;
939
- catalog().then((value) => {
940
- if (live) setChoices(catalogChoices(value, status?.settings.model ?? {
941
- provider: "",
942
- model: ""
943
- }));
944
- }).catch(() => {
945
- if (live) setChoices([]);
946
- });
947
- return () => {
948
- live = false;
949
- };
950
- }, [
951
- props.client,
952
- status?.settings.model.provider,
953
- status?.settings.model.model
954
- ]);
955
1895
  (0, react.useEffect)(() => {
956
1896
  const generation = work.beginLoad();
957
1897
  reading.current = true;
@@ -1053,6 +1993,7 @@ function TitleSettings(props) {
1053
1993
  const stop = props.subscribeSettings?.(() => {
1054
1994
  if (!live) return;
1055
1995
  setSyncError("");
1996
+ refreshCatalog();
1056
1997
  if (dirty.current && !busyRef.current) {
1057
1998
  external.current = true;
1058
1999
  setExternalChange(true);
@@ -1065,17 +2006,25 @@ function TitleSettings(props) {
1065
2006
  live = false;
1066
2007
  stop?.();
1067
2008
  };
1068
- }, [props.subscribeSettings, props.client]);
1069
- const savedPrompt = status?.settings.prompt ?? "";
1070
- const savedModel = status?.settings.model ?? {
2009
+ }, [
2010
+ props.subscribeSettings,
2011
+ props.client,
2012
+ refreshCatalog
2013
+ ]);
2014
+ const savedPrompt = status?.settings?.prompt ?? "";
2015
+ const savedModel = status?.settings?.model ?? {
1071
2016
  provider: "",
1072
2017
  model: ""
1073
2018
  };
1074
- const selectableChoices = choices.some((choice) => choice.provider === savedModel.provider && choice.model === savedModel.model) ? choices : [...choices, ...catalogChoices({}, savedModel)];
1075
- const modelKey = savedModel.provider && savedModel.model ? `${savedModel.provider}\u001f${savedModel.model}` : "";
2019
+ const follow = !savedModel.provider || !savedModel.model;
2020
+ const selectedModel = follow ? void 0 : choices.find((choice) => choice.provider === savedModel.provider && choice.model === savedModel.model);
2021
+ const efforts = follow ? [] : modelMenuEffortOptions(selectedModel, savedModel.reasoningEffort);
2022
+ const currentLabel = follow ? text.modelDefault : selectedModel?.label ?? `${savedModel.provider} / ${savedModel.model}`;
2023
+ const selectedEffort = efforts.find((item) => item.id === (savedModel.reasoningEffort || ""));
2024
+ const effortName = selectedEffort ? modelMenuEffortLabel(selectedEffort, seat.locale) : void 0;
1076
2025
  const title = status?.session?.title;
1077
2026
  const pinned = status?.session?.pinned === true;
1078
- const weOwn = status?.support.weOwn === true;
2027
+ const weOwn = status?.support?.weOwn === true;
1079
2028
  const canRegenerate = Boolean(sessionId) && weOwn && !busy && !loadingSettings;
1080
2029
  function saveSettings(patch) {
1081
2030
  if (!status || busyRef.current || reading.current || external.current) return;
@@ -1109,221 +2058,266 @@ function TitleSettings(props) {
1109
2058
  className: "dsh-ui-hint",
1110
2059
  children: text.loading
1111
2060
  }) : null,
1112
- title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1113
- translate: "no",
1114
- className: "dsh-ui-title dsh-ui-wrap",
1115
- children: title
1116
- }) : null,
1117
- pinned ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1118
- className: "dsh-ui-meta",
1119
- children: text.pinned
1120
- }) : null,
1121
- status?.session?.generating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1122
- role: "status",
1123
- className: "dsh-ui-hint",
1124
- children: text.generating
1125
- }) : null,
1126
- status && !weOwn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1127
- role: "status",
1128
- className: "dsh-ui-hint",
1129
- children: [text.inactive, status.support.limitation ? ` ${titleMessage(status.support.limitation, seat.locale)}` : ""]
1130
- }) : null,
1131
- error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1132
- role: "alert",
1133
- className: "dsh-ui-error dsh-ui-wrap",
1134
- children: titleMessage(error, seat.locale)
1135
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1136
- variant: "outline",
1137
- size: "sm",
1138
- disabled: busy,
1139
- onClick: () => {
1140
- readGate.reset();
1141
- refreshStatus();
1142
- },
1143
- children: text.retry
1144
- })] }) : null,
1145
- note ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1146
- role: "status",
1147
- className: "dsh-ui-notice",
1148
- children: titleMessage(note, seat.locale)
1149
- }) : null,
1150
- externalChange ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1151
- role: "alert",
1152
- className: "dsh-ui-error",
1153
- children: text.externalChange
1154
- }) : null,
1155
- syncError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1156
- role: "status",
1157
- className: "dsh-ui-hint",
1158
- children: text.syncUnavailable
1159
- }) : null,
1160
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1161
- className: "dsh-ui-actions",
1162
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1163
- variant: "ghost",
1164
- size: "sm",
1165
- disabled: busy || loadingSettings,
1166
- onClick: () => {
1167
- setPrompt(void 0);
1168
- dirty.current = false;
1169
- external.current = false;
1170
- setExternalChange(false);
1171
- readGate.reset();
1172
- syncRef.current();
1173
- },
1174
- children: text.reload
1175
- }), sessionId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1176
- variant: "outline",
1177
- size: "md",
1178
- disabled: !canRegenerate,
1179
- onClick: () => {
1180
- if (!sessionId) return;
1181
- readGate.reset();
1182
- const token = work.beginRequest();
1183
- setError("");
1184
- setNote("");
1185
- runTitleRegenerateFlow({
1186
- call,
1187
- sessionId,
1188
- isCurrent: () => work.isRequest(token),
1189
- failedMessage: messages.failed,
1190
- onBusy: changeBusy,
1191
- onStatus: setStatus,
1192
- onError: setError,
1193
- onMarker: commitMarker
1194
- });
1195
- },
1196
- children: text.regenerate
1197
- }) : null]
1198
- }),
1199
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1200
- className: "dsh-ui-field",
2061
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
2062
+ className: "dsh-ui-card",
2063
+ "data-testid": "current-title-session",
1201
2064
  children: [
1202
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1203
- className: "dsh-ui-label",
1204
- children: text.prompt
2065
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2066
+ className: "dsh-ui-heading",
2067
+ children: text.session
1205
2068
  }),
1206
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
1207
- className: "ct-prompt",
1208
- value: status ? promptFieldValue(prompt, savedPrompt) : "",
1209
- maxLength: 4e3,
1210
- rows: 5,
1211
- disabled: busy || loadingSettings || !status,
1212
- onChange: (event) => {
1213
- dirty.current = true;
1214
- setPrompt(event.target.value);
1215
- setNote("");
2069
+ title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2070
+ translate: "no",
2071
+ className: "dsh-ui-title dsh-ui-wrap",
2072
+ children: title
2073
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2074
+ className: "dsh-ui-hint",
2075
+ children: text.noSession
2076
+ }),
2077
+ pinned ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2078
+ className: "dsh-ui-meta",
2079
+ children: text.pinned
2080
+ }) : null,
2081
+ status?.session?.generating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2082
+ role: "status",
2083
+ className: "dsh-ui-hint",
2084
+ children: text.generating
2085
+ }) : null,
2086
+ status && !weOwn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2087
+ role: "status",
2088
+ className: "dsh-ui-hint",
2089
+ children: [text.inactive, status.support?.limitation ? ` ${titleMessage(status.support.limitation, seat.locale)}` : ""]
2090
+ }) : null,
2091
+ error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2092
+ role: "alert",
2093
+ className: "dsh-ui-error dsh-ui-wrap",
2094
+ children: titleMessage(error, seat.locale)
2095
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2096
+ variant: "outline",
2097
+ size: "sm",
2098
+ disabled: busy,
2099
+ onClick: () => {
2100
+ readGate.reset();
2101
+ refreshStatus();
1216
2102
  },
1217
- onBlur: () => {
1218
- if (!status || busyRef.current || reading.current || external.current) return;
1219
- const next = promptToSave(prompt, savedPrompt);
1220
- if (next === void 0) {
1221
- dirty.current = false;
2103
+ children: text.retry
2104
+ })] }) : null,
2105
+ note ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2106
+ role: "status",
2107
+ className: "dsh-ui-notice",
2108
+ children: titleMessage(note, seat.locale)
2109
+ }) : null,
2110
+ externalChange ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2111
+ role: "alert",
2112
+ className: "dsh-ui-error",
2113
+ children: text.externalChange
2114
+ }) : null,
2115
+ syncError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2116
+ role: "status",
2117
+ className: "dsh-ui-hint",
2118
+ children: text.syncUnavailable
2119
+ }) : null,
2120
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2121
+ className: "dsh-ui-actions",
2122
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2123
+ variant: "ghost",
2124
+ size: "sm",
2125
+ disabled: busy || loadingSettings,
2126
+ onClick: () => {
1222
2127
  setPrompt(void 0);
1223
- return;
1224
- }
1225
- readGate.reset();
1226
- const token = work.beginRequest();
1227
- setError("");
1228
- runTitleSettingsSave({
1229
- call,
1230
- prompt: next,
1231
- expectedRevision: status.settings.revision,
1232
- isCurrent: () => work.isRequest(token),
1233
- savedMessage: messages.saved,
1234
- failedMessage: messages.failed,
1235
- onBusy: changeBusy,
1236
- onSettings: (settings) => {
1237
- setStatus((current) => current ? {
1238
- ...current,
1239
- settings
1240
- } : current);
1241
- dirty.current = false;
1242
- setPrompt(void 0);
2128
+ dirty.current = false;
2129
+ external.current = false;
2130
+ setExternalChange(false);
2131
+ readGate.reset();
2132
+ syncRef.current();
2133
+ },
2134
+ children: text.reload
2135
+ }), sessionId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2136
+ variant: "outline",
2137
+ size: "md",
2138
+ disabled: !canRegenerate,
2139
+ onClick: () => {
2140
+ if (!sessionId) return;
2141
+ readGate.reset();
2142
+ const token = work.beginRequest();
2143
+ setError("");
2144
+ setNote("");
2145
+ runTitleRegenerateFlow({
2146
+ call,
2147
+ sessionId,
2148
+ isCurrent: () => work.isRequest(token),
2149
+ failedMessage: messages.failed,
2150
+ onBusy: changeBusy,
2151
+ onStatus: setStatus,
2152
+ onError: setError,
2153
+ onMarker: commitMarker
2154
+ });
2155
+ },
2156
+ children: text.regenerate
2157
+ }) : null]
2158
+ })
2159
+ ]
2160
+ }),
2161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2162
+ className: "dsh-ui-section",
2163
+ "data-testid": "current-title-defaults",
2164
+ children: [
2165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2166
+ className: "dsh-ui-heading",
2167
+ children: text.defaults
2168
+ }),
2169
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2170
+ className: "dsh-ui-field",
2171
+ children: [
2172
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2173
+ className: "dsh-ui-label",
2174
+ children: text.prompt
2175
+ }),
2176
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
2177
+ className: "dsh-ui-textarea ct-prompt",
2178
+ value: status ? promptFieldValue(prompt, savedPrompt) : "",
2179
+ maxLength: 4e3,
2180
+ rows: 5,
2181
+ disabled: busy || loadingSettings || !status,
2182
+ onChange: (event) => {
2183
+ dirty.current = true;
2184
+ setPrompt(event.target.value);
2185
+ setNote("");
1243
2186
  },
1244
- onNote: setNote,
1245
- onError: setError
1246
- });
1247
- }
2187
+ onBlur: () => {
2188
+ if (!status || busyRef.current || reading.current || external.current) return;
2189
+ const next = promptToSave(prompt, savedPrompt);
2190
+ if (next === void 0) {
2191
+ dirty.current = false;
2192
+ setPrompt(void 0);
2193
+ return;
2194
+ }
2195
+ readGate.reset();
2196
+ const token = work.beginRequest();
2197
+ setError("");
2198
+ runTitleSettingsSave({
2199
+ call,
2200
+ prompt: next,
2201
+ expectedRevision: status.settings.revision,
2202
+ isCurrent: () => work.isRequest(token),
2203
+ savedMessage: messages.saved,
2204
+ failedMessage: messages.failed,
2205
+ onBusy: changeBusy,
2206
+ onSettings: (settings) => {
2207
+ setStatus((current) => current ? {
2208
+ ...current,
2209
+ settings
2210
+ } : current);
2211
+ dirty.current = false;
2212
+ setPrompt(void 0);
2213
+ },
2214
+ onNote: setNote,
2215
+ onError: setError
2216
+ });
2217
+ }
2218
+ }),
2219
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2220
+ className: "dsh-ui-help",
2221
+ children: text.promptHint
2222
+ })
2223
+ ]
1248
2224
  }),
1249
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1250
- className: "dsh-ui-help",
1251
- children: text.promptHint
2225
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2226
+ className: "dsh-ui-field",
2227
+ children: [
2228
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2229
+ className: "dsh-ui-label",
2230
+ children: text.model
2231
+ }),
2232
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelCatalogStatus, {
2233
+ state: catalogState,
2234
+ locale: seat.locale
2235
+ }),
2236
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelMenu, {
2237
+ locale: seat.locale,
2238
+ open: menuOpen && Boolean(status) && !busy && !loadingSettings,
2239
+ onOpenChange: (next) => setMenuOpen(next && Boolean(status) && !busy && !loadingSettings),
2240
+ listClassName: "ct-root",
2241
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2242
+ type: "button",
2243
+ className: "dsh-model-menu-trigger",
2244
+ disabled: busy || loadingSettings || !status,
2245
+ "aria-label": `${text.model}: ${currentLabel}`,
2246
+ children: [
2247
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2248
+ className: "dsh-model-menu-triggerLabel",
2249
+ children: currentLabel
2250
+ }),
2251
+ !follow && efforts.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2252
+ className: "dsh-model-menu-triggerEffort",
2253
+ children: effortName ?? text.modelDefault
2254
+ }) : null,
2255
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { className: `dsh-model-menu-chevron${menuOpen ? " dsh-model-menu-chevronOpen" : ""}` })
2256
+ ]
2257
+ }),
2258
+ choices,
2259
+ selected: follow ? void 0 : {
2260
+ provider: savedModel.provider,
2261
+ model: savedModel.model
2262
+ },
2263
+ onPick: (picked) => saveSettings({ model: {
2264
+ provider: picked.provider,
2265
+ model: picked.model
2266
+ } }),
2267
+ leading: [{
2268
+ id: "default",
2269
+ label: text.modelDefault,
2270
+ selected: follow
2271
+ }],
2272
+ onPickLeading: () => saveSettings({ model: {
2273
+ provider: "",
2274
+ model: ""
2275
+ } }),
2276
+ efforts,
2277
+ selectedEffort: savedModel.reasoningEffort || "",
2278
+ onPickEffort: (effort) => saveSettings({ model: follow ? {
2279
+ provider: "",
2280
+ model: ""
2281
+ } : {
2282
+ provider: savedModel.provider,
2283
+ model: savedModel.model,
2284
+ ...effort ? { reasoningEffort: effort } : {}
2285
+ } }),
2286
+ modelLabel: text.model,
2287
+ modelValue: currentLabel,
2288
+ defaultEffortLabel: text.modelDefault
2289
+ })
2290
+ ]
2291
+ }),
2292
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2293
+ className: "dsh-ui-field",
2294
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2295
+ className: "dsh-ui-label",
2296
+ children: text.cadence
2297
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
2298
+ className: "dsh-ui-select",
2299
+ value: status?.settings?.cadence ?? "all-prompts",
2300
+ disabled: busy || loadingSettings || !status,
2301
+ onChange: (event) => {
2302
+ saveSettings({ cadence: event.target.value === "first-prompt" ? "first-prompt" : "all-prompts" });
2303
+ },
2304
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2305
+ value: "all-prompts",
2306
+ children: text.cadenceAll
2307
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2308
+ value: "first-prompt",
2309
+ children: text.cadenceFirst
2310
+ })]
2311
+ })]
1252
2312
  })
1253
2313
  ]
1254
- }),
1255
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1256
- className: "dsh-ui-field",
1257
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1258
- className: "dsh-ui-label",
1259
- children: text.model
1260
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1261
- className: "dsh-ui-select",
1262
- value: modelKey,
1263
- disabled: busy || loadingSettings || !status,
1264
- onChange: (event) => {
1265
- const value = event.target.value;
1266
- const choice = selectableChoices.find((item) => `${item.provider}\u001f${item.model}` === value);
1267
- saveSettings({ model: choice ? {
1268
- provider: choice.provider,
1269
- model: choice.model
1270
- } : {
1271
- provider: "",
1272
- model: ""
1273
- } });
1274
- },
1275
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1276
- value: "",
1277
- children: text.modelDefault
1278
- }), selectableChoices.map((choice) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1279
- value: `${choice.provider}\u001f${choice.model}`,
1280
- children: choice.label
1281
- }, `${choice.provider}\u001f${choice.model}`))]
1282
- })]
1283
- }),
1284
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1285
- className: "dsh-ui-field",
1286
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1287
- className: "dsh-ui-label",
1288
- children: text.cadence
1289
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1290
- className: "dsh-ui-select",
1291
- value: status?.settings.cadence ?? "all-prompts",
1292
- disabled: busy || loadingSettings || !status,
1293
- onChange: (event) => {
1294
- saveSettings({ cadence: event.target.value === "first-prompt" ? "first-prompt" : "all-prompts" });
1295
- },
1296
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1297
- value: "all-prompts",
1298
- children: text.cadenceAll
1299
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1300
- value: "first-prompt",
1301
- children: text.cadenceFirst
1302
- })]
1303
- })]
1304
2314
  })
1305
2315
  ]
1306
2316
  });
1307
2317
  }
1308
- const styles = `${officialUiCss("ct-root")}
2318
+ const styles = `${officialUiCss("ct-root")}${modelMenuCss}
1309
2319
  .ct-root { max-width: 760px; }
1310
- .ct-prompt {
1311
- box-sizing: border-box;
1312
- width: 100%;
1313
- min-width: 0;
1314
- min-height: 96px;
1315
- resize: vertical;
1316
- padding: 8px 12px;
1317
- border: 0.5px solid var(--dsw-alias-border-l4);
1318
- border-radius: var(--dsw-radius-md);
1319
- background: var(--dsw-alias-bg-layer-3);
1320
- font: inherit;
1321
- font-size: 13px;
1322
- line-height: 1.5;
1323
- color: var(--dsw-alias-label-primary);
1324
- }
1325
- .ct-prompt:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }
1326
- .ct-prompt::placeholder { color: var(--dsw-alias-label-dimmed); }
2320
+ .ct-prompt { min-height: 96px; }
1327
2321
  `;
1328
2322
  function apply(ctx) {
1329
2323
  const client = ctx;