dsh-codex-subscription 3.2.8 → 3.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -2907,8 +2907,11 @@ window.__ModuleLoader__.load({
2907
2907
  "defaultSpeedTitle": "默认速度",
2908
2908
  "composerMenuCustom": "可在模型菜单中切换速度",
2909
2909
  "composerMenuHost": "由 DSH 或其他插件提供模型菜单",
2910
- "legacyModelPicker": "自定义模型菜单",
2911
- "legacyModelPickerHint": "在输入框的模型菜单中切换速度和回答详略。关闭后,本插件让出模型菜单,订阅功能仍可使用。",
2910
+ "legacyModelPicker": "输入框模型菜单",
2911
+ "composerMenuAuto": "自动",
2912
+ "composerMenuDsh": "DSH 标准",
2913
+ "composerMenuSubscription": "订阅菜单",
2914
+ "legacyModelPickerHint": "自动模式会为其他插件的模型菜单让位。使用订阅菜单时,可在输入框切换速度和回答详略。",
2912
2915
  speedTitle: "速度",
2913
2916
  speedStandard: "标准",
2914
2917
  speedStandardHint: "标准速度",
@@ -3848,8 +3851,11 @@ window.__ModuleLoader__.load({
3848
3851
  "defaultSpeedTitle": "Default speed",
3849
3852
  "composerMenuCustom": "Speed controls in the model menu",
3850
3853
  "composerMenuHost": "Model menu provided by DSH or another plugin",
3851
- "legacyModelPicker": "Custom model menu",
3852
- "legacyModelPickerHint": "Switch speed and output detail in the composer’s model menu. Turn off to let DSH or another plugin provide the menu. Subscription features remain available.",
3854
+ "legacyModelPicker": "Composer model menu",
3855
+ "composerMenuAuto": "Auto",
3856
+ "composerMenuDsh": "DSH standard",
3857
+ "composerMenuSubscription": "Subscription",
3858
+ "legacyModelPickerHint": "Auto lets another plugin provide the model menu. The subscription menu adds speed and output detail controls.",
3853
3859
  speedTitle: "Speed",
3854
3860
  speedStandard: "Standard",
3855
3861
  speedStandardHint: "Standard speed",
@@ -4789,8 +4795,11 @@ window.__ModuleLoader__.load({
4789
4795
  "defaultSpeedTitle": "既定の速度",
4790
4796
  "composerMenuCustom": "モデルメニューで速度を切り替え",
4791
4797
  "composerMenuHost": "DSH または他のプラグインのメニューを使用",
4792
- "legacyModelPicker": "カスタムモデルメニュー",
4793
- "legacyModelPickerHint": "入力欄のモデルメニューから速度と回答の詳しさを切り替えられます。オフにするとメニューを DSH や他のプラグインに任せます。購読機能は引き続き使えます。",
4798
+ "legacyModelPicker": "入力欄のモデルメニュー",
4799
+ "composerMenuAuto": "自動",
4800
+ "composerMenuDsh": "DSH 標準",
4801
+ "composerMenuSubscription": "購読メニュー",
4802
+ "legacyModelPickerHint": "自動では他のプラグインのメニューを優先します。購読メニューでは速度と回答の詳しさを選べます。",
4794
4803
  "speedTitle": "速度",
4795
4804
  "speedStandard": "標準",
4796
4805
  "speedStandardHint": "標準速度",
@@ -5730,8 +5739,11 @@ window.__ModuleLoader__.load({
5730
5739
  "defaultSpeedTitle": "Velocidad predeterminada",
5731
5740
  "composerMenuCustom": "Control de velocidad en el menú de modelos",
5732
5741
  "composerMenuHost": "Menú de DSH u otro complemento",
5733
- "legacyModelPicker": "Menú de modelos personalizado",
5734
- "legacyModelPickerHint": "Cambia la velocidad y el nivel de detalle en el menú de modelos. Al desactivar esta opción, DSH u otro complemento se encarga del menú. Las funciones de suscripción siguen disponibles.",
5742
+ "legacyModelPicker": "Menú de modelos del cuadro de entrada",
5743
+ "composerMenuAuto": "Auto",
5744
+ "composerMenuDsh": "Estándar de DSH",
5745
+ "composerMenuSubscription": "Suscripción",
5746
+ "legacyModelPickerHint": "En modo automático se da prioridad al menú de otro complemento. El menú de suscripción permite ajustar la velocidad y el nivel de detalle.",
5735
5747
  "speedTitle": "Velocidad",
5736
5748
  "speedStandard": "Estándar",
5737
5749
  "speedStandardHint": "Velocidad estándar",
@@ -6671,8 +6683,11 @@ window.__ModuleLoader__.load({
6671
6683
  "defaultSpeedTitle": "Vitesse par défaut",
6672
6684
  "composerMenuCustom": "Réglage de la vitesse dans le menu des modèles",
6673
6685
  "composerMenuHost": "Menu fourni par DSH ou une autre extension",
6674
- "legacyModelPicker": "Menu des modèles personnalisé",
6675
- "legacyModelPickerHint": "Réglez la vitesse et le niveau de détail dans le menu des modèles. Si vous désactivez cette option, DSH ou une autre extension gère le menu. Les fonctions de l’abonnement restent disponibles.",
6686
+ "legacyModelPicker": "Menu des modèles de la zone de saisie",
6687
+ "composerMenuAuto": "Auto",
6688
+ "composerMenuDsh": "Standard DSH",
6689
+ "composerMenuSubscription": "Abonnement",
6690
+ "legacyModelPickerHint": "Le mode automatique donne la priorité au menu d’une autre extension. Le menu d’abonnement permet de régler la vitesse et le niveau de détail.",
6676
6691
  "speedTitle": "Vitesse",
6677
6692
  "speedStandard": "Standard",
6678
6693
  "speedStandardHint": "Vitesse standard",
@@ -7612,8 +7627,11 @@ window.__ModuleLoader__.load({
7612
7627
  "defaultSpeedTitle": "Standardtempo",
7613
7628
  "composerMenuCustom": "Tempowahl im Modellmenü",
7614
7629
  "composerMenuHost": "Modellmenü von DSH oder einem anderen Plugin",
7615
- "legacyModelPicker": "Benutzerdefiniertes Modellmenü",
7616
- "legacyModelPickerHint": "Ändere Tempo und Antwortlänge direkt im Modellmenü. Wenn du die Option ausschaltest, übernimmt DSH oder ein anderes Plugin das Menü. Die Abofunktionen bleiben verfügbar.",
7630
+ "legacyModelPicker": "Modellmenü im Eingabefeld",
7631
+ "composerMenuAuto": "Automatisch",
7632
+ "composerMenuDsh": "DSH-Standard",
7633
+ "composerMenuSubscription": "Abonnement",
7634
+ "legacyModelPickerHint": "Automatisch gibt dem Menü eines anderen Plugins Vorrang. Das Abonnement-Menü bietet Tempo und Antwortdetails.",
7617
7635
  "speedTitle": "Geschwindigkeit",
7618
7636
  "speedStandard": "Standard",
7619
7637
  "speedStandardHint": "Standardgeschwindigkeit",
@@ -8553,8 +8571,11 @@ window.__ModuleLoader__.load({
8553
8571
  "defaultSpeedTitle": "Скорость по умолчанию",
8554
8572
  "composerMenuCustom": "Настройка скорости в меню моделей",
8555
8573
  "composerMenuHost": "Меню DSH или другого плагина",
8556
- "legacyModelPicker": "Настраиваемое меню моделей",
8557
- "legacyModelPickerHint": "Меняйте скорость и подробность ответа в меню моделей. Если выключить настройку, меню предоставит DSH или другой плагин. Функции подписки останутся доступны.",
8574
+ "legacyModelPicker": "Меню моделей в поле ввода",
8575
+ "composerMenuAuto": "Авто",
8576
+ "composerMenuDsh": "Стандарт DSH",
8577
+ "composerMenuSubscription": "Подписка",
8578
+ "legacyModelPickerHint": "Автоматический режим отдаёт приоритет меню другого плагина. В меню подписки можно выбрать скорость и подробность ответа.",
8558
8579
  "speedTitle": "Скорость",
8559
8580
  "speedStandard": "Стандартная",
8560
8581
  "speedStandardHint": "Стандартная скорость",
@@ -9494,8 +9515,11 @@ window.__ModuleLoader__.load({
9494
9515
  "defaultSpeedTitle": "Velocidade padrão",
9495
9516
  "composerMenuCustom": "Controle de velocidade no menu de modelos",
9496
9517
  "composerMenuHost": "Menu do DSH ou de outro plugin",
9497
- "legacyModelPicker": "Menu de modelos personalizado",
9498
- "legacyModelPickerHint": "Altere a velocidade e o nível de detalhe no menu de modelos. Ao desativar, o DSH ou outro plugin assume o menu. Os recursos da assinatura continuam disponíveis.",
9518
+ "legacyModelPicker": "Menu de modelos do campo de entrada",
9519
+ "composerMenuAuto": "Automático",
9520
+ "composerMenuDsh": "Padrão do DSH",
9521
+ "composerMenuSubscription": "Assinatura",
9522
+ "legacyModelPickerHint": "O modo automático dá prioridade ao menu de outro plugin. O menu da assinatura permite ajustar a velocidade e o nível de detalhe.",
9499
9523
  "speedTitle": "Velocidade",
9500
9524
  "speedStandard": "Padrão",
9501
9525
  "speedStandardHint": "Velocidade padrão",
@@ -10479,6 +10503,12 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
10479
10503
  const FETCH_PROVIDER_FIELD = "fetchProvider";
10480
10504
  const FETCH_PROVIDER_CODEX = "codex";
10481
10505
  const normalizeFetchProvider = (value) => value === "codex" ? FETCH_PROVIDER_CODEX : "dsh";
10506
+ const COMPOSER_MODEL_PICKER_MODES = Object.freeze([
10507
+ "auto",
10508
+ "dsh",
10509
+ "legacy"
10510
+ ]);
10511
+ const normalizeComposerModelPicker = (value) => COMPOSER_MODEL_PICKER_MODES.includes(value) ? value : "auto";
10482
10512
  const SPEED_MODE_FIELD = "speedMode";
10483
10513
  const SPEED_MODE_STANDARD = "standard";
10484
10514
  const SPEED_MODE_FAST = "fast";
@@ -10703,8 +10733,8 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
10703
10733
  error: "Invalid input prediction setting"
10704
10734
  },
10705
10735
  composerModelPicker: {
10706
- choices: ["dsh", "legacy"],
10707
- default: "legacy",
10736
+ choices: COMPOSER_MODEL_PICKER_MODES,
10737
+ default: "auto",
10708
10738
  error: "Invalid composer model picker"
10709
10739
  },
10710
10740
  connectionMode: {
@@ -10856,6 +10886,8 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
10856
10886
  let subagentModels = [];
10857
10887
  let fetchRoutingAvailable = false;
10858
10888
  let restartRequired = false;
10889
+ let composerModelPickerActive = false;
10890
+ let composerModelPickerConflict = false;
10859
10891
  const sameModels = (left, right) => left.length === right.length && left.every((model, index) => JSON.stringify(model) === JSON.stringify(right[index]));
10860
10892
  const read = () => {
10861
10893
  const current = fallback ?? { status: "unavailable" };
@@ -10872,7 +10904,9 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
10872
10904
  reviewModel: value?.reviewModel === "official" ? "official" : "session",
10873
10905
  remoteControl: value?.remoteControl === "on" ? "on" : "off",
10874
10906
  composerPredictions: value?.composerPredictions === "on" ? "on" : "off",
10875
- composerModelPicker: value?.composerModelPicker === "dsh" ? "dsh" : "legacy",
10907
+ composerModelPicker: normalizeComposerModelPicker(value?.composerModelPicker),
10908
+ composerModelPickerActive,
10909
+ composerModelPickerConflict,
10876
10910
  otherModels: value?.otherModels === "off" ? "off" : "on",
10877
10911
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
10878
10912
  reasoningCache: normalizeReasoningCache(value?.reasoningCache),
@@ -10954,7 +10988,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
10954
10988
  reviewModel: value?.reviewModel === "official" ? "official" : "session",
10955
10989
  remoteControl: value?.remoteControl === "on" ? "on" : "off",
10956
10990
  composerPredictions: value?.composerPredictions === "on" ? "on" : "off",
10957
- composerModelPicker: value?.composerModelPicker === "dsh" ? "dsh" : "legacy",
10991
+ composerModelPicker: normalizeComposerModelPicker(value?.composerModelPicker),
10958
10992
  otherModels: value?.otherModels === "off" ? "off" : "on",
10959
10993
  otherModels: value?.otherModels === "off" ? "off" : "on",
10960
10994
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
@@ -11086,6 +11120,16 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
11086
11120
  },
11087
11121
  load,
11088
11122
  set,
11123
+ setComposerModelPickerActive(active) {
11124
+ if (composerModelPickerActive === active) return;
11125
+ composerModelPickerActive = active;
11126
+ publish();
11127
+ },
11128
+ setComposerModelPickerConflict(conflict) {
11129
+ if (composerModelPickerConflict === conflict) return;
11130
+ composerModelPickerConflict = conflict;
11131
+ publish();
11132
+ },
11089
11133
  retry: () => failedPatch === void 0 ? load() : set(failedPatch),
11090
11134
  refreshModels,
11091
11135
  dispose: () => {
@@ -11610,7 +11654,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
11610
11654
  }
11611
11655
  //#endregion
11612
11656
  //#region src/version.js
11613
- const PACKAGE_VERSION = "3.2.8";
11657
+ const PACKAGE_VERSION = "3.2.10";
11614
11658
  //#endregion
11615
11659
  //#region src/client-recovery.js
11616
11660
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = endpoint === "usage" || endpoint.startsWith("usage/") ? 3e4 : 1e4) {
@@ -12366,27 +12410,72 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
12366
12410
  //#endregion
12367
12411
  //#region src/client-model-picker-slot.js
12368
12412
  const slot = "conversation.input.model";
12413
+ const nativeLabel = "conversation.input.model.label";
12414
+ const priority = -1;
12415
+ const priorityOf = (entry) => entry.options.priority ?? 0;
12416
+ const native = (entry) => priorityOf(entry) === 0 && entry.children?.[nativeLabel]?.kind === "single";
12417
+ function watchComposerModelPickerConflict(manager, remote, update, onReset) {
12418
+ if (typeof manager?.listPlugins !== "function") return;
12419
+ let generation = 0;
12420
+ let disposed = false;
12421
+ const refresh = async () => {
12422
+ const current = ++generation;
12423
+ try {
12424
+ const entries = unwrap(await manager.listPlugins());
12425
+ if (disposed || current !== generation) return;
12426
+ update(entries.some((entry) => entry.moduleName === "dsh-claude-style" && entry.enabled === true));
12427
+ } catch {
12428
+ if (!disposed && current === generation) update(true);
12429
+ }
12430
+ };
12431
+ update(true);
12432
+ const unwatch = remote?.$on?.("plugin-manager/changed", refresh);
12433
+ const unwatchReset = onReset?.(refresh);
12434
+ refresh();
12435
+ return () => {
12436
+ disposed = true;
12437
+ unwatch?.();
12438
+ unwatchReset?.();
12439
+ update(false);
12440
+ };
12441
+ }
12369
12442
  function registerLegacyModelPicker(slots, preference, props, component) {
12370
12443
  return slots.inject(slot, () => {
12371
12444
  let dispose;
12445
+ let disposed = false;
12446
+ let syncing = false;
12372
12447
  const sync = () => {
12373
- const state = preference.getSnapshot();
12374
- if (state.status === "ready" && state.composerModelPicker === "legacy") {
12375
- if (!dispose && !slots.entries(slot).some((entry) => entry.options.priority === -1)) dispose = slots.register({
12448
+ if (disposed || syncing) return;
12449
+ syncing = true;
12450
+ try {
12451
+ const state = preference.getSnapshot();
12452
+ const others = slots.entries(slot).filter((entry) => entry.component !== component);
12453
+ const custom = state.composerModelPicker === "legacy" || state.composerModelPicker === "auto" && !state.composerModelPickerConflict && others.every(native);
12454
+ if (state.status === "ready" && custom && !others.some((entry) => priorityOf(entry) === priority)) dispose ??= slots.register({
12376
12455
  name: slot,
12377
- priority: -1,
12456
+ priority,
12378
12457
  inject: props
12379
12458
  }, component);
12380
- } else {
12381
- dispose?.();
12382
- dispose = void 0;
12459
+ else {
12460
+ dispose?.();
12461
+ dispose = void 0;
12462
+ }
12463
+ preference.setComposerModelPickerActive(Boolean(dispose) && !others.some((entry) => priorityOf(entry) < priority));
12464
+ } catch (error) {
12465
+ if (error?.code !== "INACTIVE_EFFECT") throw error;
12466
+ } finally {
12467
+ syncing = false;
12383
12468
  }
12384
12469
  };
12385
- sync();
12386
12470
  const unwatch = preference.subscribe(sync);
12471
+ const unwatchSlot = slots.subscribe(slot, sync);
12472
+ sync();
12387
12473
  return () => {
12474
+ disposed = true;
12388
12475
  unwatch();
12476
+ unwatchSlot();
12389
12477
  dispose?.();
12478
+ preference.setComposerModelPickerActive(false);
12390
12479
  };
12391
12480
  });
12392
12481
  }
@@ -18214,8 +18303,12 @@ void main(){
18214
18303
  function ModelsPage({ preference, t, defaultModel }) {
18215
18304
  const snapshot = usePreferenceSnapshot(preference);
18216
18305
  const loaded = snapshot.status === "ready";
18217
- const customMenu = snapshot.composerModelPicker === "legacy";
18218
- const menuDisabled = !ready(snapshot) || snapshot.saving;
18306
+ const customMenu = snapshot.composerModelPickerActive;
18307
+ const menuLabels = {
18308
+ auto: "composerMenuAuto",
18309
+ dsh: "composerMenuDsh",
18310
+ legacy: "composerMenuSubscription"
18311
+ };
18219
18312
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
18220
18313
  className: "codexSubscriptionAdvancedPreferences",
18221
18314
  children: [
@@ -18256,13 +18349,15 @@ void main(){
18256
18349
  description: t("legacyModelPickerHint"),
18257
18350
  children: t("legacyModelPicker")
18258
18351
  }), loaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, { children: t(customMenu ? "composerMenuCustom" : "composerMenuHost") }) : null]
18259
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Switch, {
18260
- checked: customMenu,
18352
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Radios, {
18353
+ snapshot,
18354
+ preference,
18355
+ field: "composerModelPicker",
18356
+ values: COMPOSER_MODEL_PICKER_MODES,
18357
+ name: "codex-model-picker",
18261
18358
  label: t("legacyModelPicker"),
18262
- disabled: menuDisabled,
18263
- onChange: (on) => {
18264
- preference.set({ composerModelPicker: on ? "legacy" : "dsh" });
18265
- }
18359
+ text: (value) => t(menuLabels[value]),
18360
+ disabled: !loaded || snapshot.saving
18266
18361
  })]
18267
18362
  }), loaded && customMenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SpeedPreference, {
18268
18363
  snapshot,
@@ -20841,11 +20936,182 @@ void main(){
20841
20936
  });
20842
20937
  }
20843
20938
  //#endregion
20939
+ //#region src/composer-prediction-layout.js
20940
+ const pixels = (value) => Number.parseFloat(value) || 0;
20941
+ /** Convert the mirror's border-box height to the editor's CSS min-height. */
20942
+ function predictionMinHeight(height, style) {
20943
+ if (!Number.isFinite(height)) return null;
20944
+ const inset = style.boxSizing === "border-box" ? 0 : pixels(style.paddingTop) + pixels(style.paddingBottom) + pixels(style.borderTopWidth) + pixels(style.borderBottomWidth);
20945
+ return Math.max(0, pixels(style.minHeight), height - inset);
20946
+ }
20947
+ function predictionAnchor(editor) {
20948
+ const scroll = editor.closest("[data-input-scroll]");
20949
+ if (!scroll) return null;
20950
+ let anchor = editor.parentElement;
20951
+ while (anchor && anchor !== scroll && getComputedStyle(anchor).display === "contents") anchor = anchor.parentElement;
20952
+ return anchor && scroll.contains(anchor) ? anchor : null;
20953
+ }
20954
+ function ownStyle(element, property) {
20955
+ const read = () => ({
20956
+ value: element.style.getPropertyValue(property),
20957
+ priority: element.style.getPropertyPriority(property)
20958
+ });
20959
+ let previous = read();
20960
+ let applied = null;
20961
+ const same = (a, b) => a?.value === b?.value && a?.priority === b?.priority;
20962
+ return {
20963
+ set(value) {
20964
+ const current = read();
20965
+ if (applied && !same(current, applied)) previous = current;
20966
+ element.style.setProperty(property, value);
20967
+ applied = read();
20968
+ },
20969
+ restore() {
20970
+ if (applied && same(read(), applied)) if (previous.value) element.style.setProperty(property, previous.value, previous.priority);
20971
+ else element.style.removeProperty(property);
20972
+ applied = null;
20973
+ previous = read();
20974
+ }
20975
+ };
20976
+ }
20977
+ const textProperties = [
20978
+ "font-family",
20979
+ "font-size",
20980
+ "font-weight",
20981
+ "font-style",
20982
+ "font-stretch",
20983
+ "font-variant",
20984
+ "font-feature-settings",
20985
+ "font-variation-settings",
20986
+ "font-kerning",
20987
+ "line-height",
20988
+ "letter-spacing",
20989
+ "word-spacing",
20990
+ "text-indent",
20991
+ "text-align",
20992
+ "text-transform",
20993
+ "text-rendering",
20994
+ "white-space",
20995
+ "word-break",
20996
+ "overflow-wrap",
20997
+ "tab-size",
20998
+ "direction",
20999
+ "writing-mode",
21000
+ "padding-top",
21001
+ "padding-right",
21002
+ "padding-bottom",
21003
+ "padding-left",
21004
+ "border-top-width",
21005
+ "border-right-width",
21006
+ "border-bottom-width",
21007
+ "border-left-width"
21008
+ ];
21009
+ /** Own only presentation and reversible height reservation; never edit the draft. */
21010
+ function attachPredictionLayout(editor, anchor, layer, onAnchorChange) {
21011
+ const height = ownStyle(editor, "min-height");
21012
+ const position = ownStyle(anchor, "position");
21013
+ let frame = 0;
21014
+ let disposed = false;
21015
+ let reanchoring = false;
21016
+ const scroll = editor.closest("[data-input-scroll]");
21017
+ const initialScroll = scroll.scrollTop;
21018
+ const card = editor.closest("[data-composer-card]");
21019
+ const placeholders = /* @__PURE__ */ new Map();
21020
+ const resize = new ResizeObserver(schedule);
21021
+ const mutations = new MutationObserver(schedule);
21022
+ function restorePlaceholders() {
21023
+ for (const lease of placeholders.values()) lease.restore();
21024
+ placeholders.clear();
21025
+ }
21026
+ function layout() {
21027
+ frame = 0;
21028
+ if (disposed) return;
21029
+ if (!editor.isConnected || !layer.isConnected) {
21030
+ dispose();
21031
+ return;
21032
+ }
21033
+ const nextAnchor = predictionAnchor(editor);
21034
+ if (nextAnchor !== anchor) {
21035
+ reanchoring = true;
21036
+ layer.style.visibility = "hidden";
21037
+ mutations.takeRecords();
21038
+ onAnchorChange(nextAnchor);
21039
+ return;
21040
+ }
21041
+ const currentScroll = scroll.scrollTop;
21042
+ height.restore();
21043
+ position.restore();
21044
+ if (getComputedStyle(anchor).position === "static") position.set("relative");
21045
+ const style = getComputedStyle(editor);
21046
+ if (!editor.offsetWidth || editor.offsetParent !== anchor) {
21047
+ layer.style.visibility = "hidden";
21048
+ restorePlaceholders();
21049
+ mutations.takeRecords();
21050
+ return;
21051
+ }
21052
+ for (const property of textProperties) layer.style.setProperty(property, style.getPropertyValue(property));
21053
+ layer.style.setProperty("--codex-prediction-ink", style.color);
21054
+ layer.style.left = `${editor.offsetLeft}px`;
21055
+ layer.style.top = `${editor.offsetTop}px`;
21056
+ layer.style.width = `${editor.offsetWidth}px`;
21057
+ const minimum = predictionMinHeight(layer.offsetHeight, style);
21058
+ if (minimum !== null) height.set(`${Math.ceil(minimum)}px`);
21059
+ layer.style.visibility = "visible";
21060
+ scroll.scrollTop = currentScroll;
21061
+ for (const placeholder of card?.querySelectorAll("[data-composer-placeholder]") ?? []) {
21062
+ if (!placeholders.has(placeholder)) placeholders.set(placeholder, ownStyle(placeholder, "visibility"));
21063
+ placeholders.get(placeholder).set("hidden");
21064
+ }
21065
+ mutations.takeRecords();
21066
+ }
21067
+ function schedule() {
21068
+ if (!disposed && !frame) frame = requestAnimationFrame(layout);
21069
+ }
21070
+ function dispose() {
21071
+ if (disposed) return;
21072
+ disposed = true;
21073
+ cancelAnimationFrame(frame);
21074
+ resize.disconnect();
21075
+ mutations.disconnect();
21076
+ window.removeEventListener("resize", schedule);
21077
+ document.fonts?.removeEventListener("loadingdone", schedule);
21078
+ editor.removeEventListener("input", dispose);
21079
+ editor.removeEventListener("compositionstart", dispose);
21080
+ layer.style.visibility = "hidden";
21081
+ height.restore();
21082
+ position.restore();
21083
+ restorePlaceholders();
21084
+ if (!reanchoring) scroll.scrollTop = initialScroll;
21085
+ }
21086
+ resize.observe(layer);
21087
+ for (let element = editor; element; element = element.parentElement) {
21088
+ resize.observe(element);
21089
+ if (element === scroll) break;
21090
+ }
21091
+ for (let element = editor; element; element = element.parentElement) mutations.observe(element, { attributes: true });
21092
+ if (card) mutations.observe(card, {
21093
+ attributes: true,
21094
+ childList: true,
21095
+ subtree: true,
21096
+ attributeFilter: [
21097
+ "class",
21098
+ "style",
21099
+ "contenteditable"
21100
+ ]
21101
+ });
21102
+ window.addEventListener("resize", schedule);
21103
+ document.fonts?.addEventListener("loadingdone", schedule);
21104
+ editor.addEventListener("input", dispose);
21105
+ editor.addEventListener("compositionstart", dispose);
21106
+ layout();
21107
+ return dispose;
21108
+ }
21109
+ //#endregion
20844
21110
  //#region src/client-predictions.jsx
20845
21111
  const PREDICTION_CSS = `
20846
- .codex-composer-prediction{position:absolute;inset:16px 20px auto;z-index:1;display:flex;align-items:baseline;gap:10px;pointer-events:none;color:var(--dsw-alias-label-tertiary,#888);font:inherit;line-height:1.5;min-width:0}
20847
- .codex-composer-prediction>span{white-space:pre-wrap;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0}
20848
- .codex-composer-prediction button{pointer-events:auto;flex:none;border:0;border-radius:4px;background:var(--dsw-alias-bg-l2,transparent);color:inherit;font:inherit;font-size:11px;padding:1px 5px;cursor:pointer}
21112
+ .codex-composer-prediction{position:absolute;z-index:1;display:block;box-sizing:border-box;border-style:solid;border-color:transparent;pointer-events:none;user-select:none;color:color-mix(in srgb,var(--codex-prediction-ink,#888) 55%,transparent);visibility:hidden;min-width:0}
21113
+ .codex-composer-prediction>span{font:inherit;color:inherit}
21114
+ .codex-composer-prediction button{display:inline-block;pointer-events:auto;border:0;border-radius:4px;background:var(--dsw-alias-bg-l2,transparent);color:inherit;font:inherit;font-size:11px;line-height:1.4;padding:1px 5px;margin-inline-start:8px;vertical-align:baseline;white-space:nowrap;cursor:pointer}
20849
21115
  `;
20850
21116
  /** The disabled path owns neither DOM nor composer event listeners. */
20851
21117
  function ComposerPrediction(props) {
@@ -20861,6 +21127,10 @@ void main(){
20861
21127
  const controller = (0, react.useMemo)(() => createComposerPredictionController(rpc), [rpc]);
20862
21128
  const snapshot = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
20863
21129
  const marker = (0, react.useRef)(null);
21130
+ const layer = (0, react.useRef)(null);
21131
+ const [target, setTarget] = (0, react.useState)(null);
21132
+ const card = target?.card;
21133
+ const editor = target?.editor;
20864
21134
  const current = (0, react.useRef)(null);
20865
21135
  const [focused, setFocused] = (0, react.useState)(false);
20866
21136
  const composing = (0, react.useRef)(false);
@@ -20884,11 +21154,51 @@ void main(){
20884
21154
  span: inputActions.captureInsertion()
20885
21155
  });
20886
21156
  const refresh = () => controller.update(environment());
20887
- const accept = () => controller.accept(inputActions, environment());
20888
- (0, react.useEffect)(() => {
21157
+ const accept = () => {
21158
+ const prediction = layer.current;
21159
+ const activeEditor = dom.current?.editor;
21160
+ if (!prediction?.isConnected || !activeEditor || activeEditor.offsetParent !== prediction.parentElement || !prediction.getClientRects().length || getComputedStyle(prediction).visibility !== "visible") return false;
21161
+ return controller.accept(inputActions, environment());
21162
+ };
21163
+ (0, react.useLayoutEffect)(() => {
20889
21164
  const card = marker.current?.closest("[data-composer-card]");
20890
- const editor = card?.querySelector("[data-composer-input][contenteditable=\"true\"]");
20891
- if (!editor) return;
21165
+ if (!card) return;
21166
+ const resolve = () => {
21167
+ const editor = card.querySelector("[data-composer-input][contenteditable=\"true\"]");
21168
+ const anchor = editor && predictionAnchor(editor);
21169
+ setTarget((previous) => previous?.editor === editor && previous?.anchor === anchor ? previous : anchor ? {
21170
+ card,
21171
+ editor,
21172
+ anchor
21173
+ } : null);
21174
+ };
21175
+ const observer = new MutationObserver(resolve);
21176
+ observer.observe(card, {
21177
+ childList: true,
21178
+ subtree: true,
21179
+ attributes: true,
21180
+ attributeFilter: ["contenteditable"]
21181
+ });
21182
+ resolve();
21183
+ return () => observer.disconnect();
21184
+ }, [sessionId]);
21185
+ (0, react.useLayoutEffect)(() => {
21186
+ if (!snapshot.prediction || !focused || !accountKey || !target?.anchor || !layer.current) return;
21187
+ const { editor, anchor } = target;
21188
+ return attachPredictionLayout(editor, anchor, layer.current, (nextAnchor) => {
21189
+ setTarget((previous) => previous?.editor === editor && previous.anchor === anchor ? {
21190
+ ...previous,
21191
+ anchor: nextAnchor
21192
+ } : previous);
21193
+ });
21194
+ }, [
21195
+ snapshot.prediction,
21196
+ focused,
21197
+ accountKey,
21198
+ target
21199
+ ]);
21200
+ (0, react.useEffect)(() => {
21201
+ if (!card || !editor) return;
20892
21202
  dom.current = {
20893
21203
  card,
20894
21204
  editor
@@ -20934,12 +21244,16 @@ void main(){
20934
21244
  document.removeEventListener("selectionchange", focus);
20935
21245
  document.removeEventListener("visibilitychange", focus);
20936
21246
  dom.current = null;
21247
+ composing.current = false;
21248
+ compositionUntil.current = 0;
20937
21249
  controller.cancel();
20938
21250
  };
20939
21251
  }, [
20940
21252
  controller,
20941
21253
  sessionId,
20942
- inputActions
21254
+ inputActions,
21255
+ card,
21256
+ editor
20943
21257
  ]);
20944
21258
  (0, react.useLayoutEffect)(() => {
20945
21259
  refresh();
@@ -20953,29 +21267,11 @@ void main(){
20953
21267
  focused
20954
21268
  ]);
20955
21269
  (0, react.useEffect)(() => () => controller.cancel(), [controller]);
20956
- (0, react.useLayoutEffect)(() => {
20957
- if (!snapshot.prediction || !focused) return;
20958
- const placeholder = marker.current?.closest("[data-composer-card]")?.querySelector("[data-composer-placeholder]");
20959
- if (!placeholder) return;
20960
- const visibility = placeholder.style.getPropertyValue("visibility");
20961
- const priority = placeholder.style.getPropertyPriority("visibility");
20962
- placeholder.style.setProperty("visibility", "hidden");
20963
- return () => {
20964
- if (placeholder.style.getPropertyValue("visibility") !== "hidden") return;
20965
- if (visibility) placeholder.style.setProperty("visibility", visibility, priority);
20966
- else placeholder.style.removeProperty("visibility");
20967
- };
20968
- }, [
20969
- snapshot.prediction,
20970
- focused,
20971
- sessionId
20972
- ]);
20973
- if (!snapshot.prediction || !focused || !accountKey) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
21270
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
20974
21271
  ref: marker,
20975
21272
  hidden: true
20976
- });
20977
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
20978
- ref: marker,
21273
+ }), snapshot.prediction && focused && accountKey && target?.anchor && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21274
+ ref: layer,
20979
21275
  className: "codex-composer-prediction",
20980
21276
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
20981
21277
  "aria-hidden": "true",
@@ -20988,7 +21284,7 @@ void main(){
20988
21284
  onClick: accept,
20989
21285
  children: "Tab"
20990
21286
  })]
20991
- });
21287
+ }), target.anchor)] });
20992
21288
  }
20993
21289
  //#endregion
20994
21290
  //#region src/client.jsx
@@ -21038,6 +21334,7 @@ void main(){
21038
21334
  }, "codex-subscription: style");
21039
21335
  const rpc = createSubscriptionRpcClient(ctx.get("connection").rpc);
21040
21336
  const preference = createPreferenceController(rpc);
21337
+ ctx.inject(["remote.pluginManager"], (scope) => scope.effect(() => watchComposerModelPickerConflict(scope.get("remote.pluginManager"), scope.get("remote"), preference.setComposerModelPickerConflict, (refresh) => scope.on("connection/reset", refresh)), "codex-subscription: composer model menu compatibility"));
21041
21338
  const quotaUsage = quotaUsageController(rpc);
21042
21339
  ctx.effect(() => {
21043
21340
  let mode = preference.getSnapshot().quickQuotaMode;