codex-overleaf-link 2.3.4 → 2.3.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.
@@ -4454,7 +4454,7 @@ ${block}`;
4454
4454
  contextReadFailed: "Could not read files: {message}",
4455
4455
  contextNoFiles: "No usable text files were read from this Overleaf project.",
4456
4456
  contextSelectedFiles: "Added {count} @file items. Future tasks will focus on them first.",
4457
- contextDefaultWholeProject: "Default is the whole project. Add @file; @compile-log and @current-section are available as context options.",
4457
+ contextDefaultWholeProject: "Default is the whole project. Choose files or add @compile-log. For a section, name it in your request.",
4458
4458
  preloadProjectContextTitle: "Preload project context",
4459
4459
  preloadProjectContextDescription: "Fetch the exact project file list in the background after an Overleaf project becomes idle.",
4460
4460
  contextResourceTitle: "{path} (non-text resource, shown only as project structure for now)",
@@ -4974,7 +4974,7 @@ ${block}`;
4974
4974
  contextReadFailed: "\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A{message}",
4975
4975
  contextNoFiles: "\u6CA1\u6709\u4ECE\u5F53\u524D Overleaf \u9879\u76EE\u8BFB\u53D6\u5230\u53EF\u7528\u6587\u672C\u6587\u4EF6\u3002",
4976
4976
  contextSelectedFiles: "\u5DF2\u6DFB\u52A0 {count} \u4E2A @file\uFF1B\u540E\u7EED\u4EFB\u52A1\u4F1A\u4F18\u5148\u56F4\u7ED5\u5B83\u4EEC\u3002",
4977
- contextDefaultWholeProject: "\u9ED8\u8BA4\u4F7F\u7528\u6574\u4E2A\u9879\u76EE\u3002\u53EF\u6DFB\u52A0 @file\uFF1B@compile-log \u548C @current-section \u5C06\u4F5C\u4E3A\u540E\u7EED\u4E0A\u4E0B\u6587\u80FD\u529B\u3002",
4977
+ contextDefaultWholeProject: "\u9ED8\u8BA4\u4F7F\u7528\u6574\u4E2A\u9879\u76EE\u3002\u53EF\u9009\u62E9\u6587\u4EF6\u6216\u6DFB\u52A0 @compile-log\uFF1B\u5904\u7406\u7AE0\u8282\u65F6\u8BF7\u5728\u8BF7\u6C42\u4E2D\u6CE8\u660E\u7AE0\u8282\u540D\u79F0\u3002",
4978
4978
  preloadProjectContextTitle: "\u9884\u52A0\u8F7D\u9879\u76EE\u4E0A\u4E0B\u6587",
4979
4979
  preloadProjectContextDescription: "Overleaf \u9879\u76EE\u8FDB\u5165\u7A7A\u95F2\u72B6\u6001\u540E\uFF0C\u5728\u540E\u53F0\u8BFB\u53D6\u7CBE\u786E\u7684\u9879\u76EE\u6587\u4EF6\u5217\u8868\u3002",
4980
4980
  contextResourceTitle: "{path}\uFF08\u975E\u6587\u672C\u8D44\u6E90\uFF0C\u5F53\u524D\u53EA\u4F5C\u4E3A\u9879\u76EE\u7ED3\u6784\u663E\u793A\uFF09",
@@ -5519,6 +5519,275 @@ ${block}`;
5519
5519
  });
5520
5520
  }).call(globalThis, void 0, void 0, void 0);
5521
5521
  (function runClassicContentModule14(module, exports, require2) {
5522
+ (function(root, factory) {
5523
+ const api = factory();
5524
+ if (typeof module === "object" && module.exports) module.exports = api;
5525
+ if (root) root.CodexOverleafGlobalPreferences = api;
5526
+ })(typeof globalThis !== "undefined" ? globalThis : this, function() {
5527
+ "use strict";
5528
+ const STORAGE_KEY = "codexOverleafGlobalPrefsV1";
5529
+ const LEGACY_KEY = "codexOverleafPrefs";
5530
+ const READ_MESSAGE = "codex-overleaf/global-preferences/read";
5531
+ const PATCH_MESSAGE = "codex-overleaf/global-preferences/patch";
5532
+ const DEFAULTS = Object.freeze({
5533
+ theme: "dark",
5534
+ locale: "en",
5535
+ preloadProjectContext: true,
5536
+ loadCodexLocalSkills: true,
5537
+ loadCodexOverleafSkills: true
5538
+ });
5539
+ const FIELDS = Object.freeze([...Object.keys(DEFAULTS), "codexOverleafSkillEnabled"]);
5540
+ function validSkillId(id) {
5541
+ return /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/.test(id) && !["__proto__", "prototype", "constructor"].includes(id) && !id.includes("..");
5542
+ }
5543
+ function pick(value = {}) {
5544
+ const skills = {};
5545
+ for (const [id, enabled] of Object.entries(value.codexOverleafSkillEnabled || {}).slice(0, 200)) {
5546
+ if (validSkillId(id) && typeof enabled === "boolean") skills[id] = enabled;
5547
+ }
5548
+ return {
5549
+ theme: ["dark", "light", "auto"].includes(value.theme) ? value.theme : "dark",
5550
+ locale: value.locale === "zh" ? "zh" : "en",
5551
+ preloadProjectContext: value.preloadProjectContext !== false,
5552
+ loadCodexLocalSkills: value.loadCodexLocalSkills !== false,
5553
+ loadCodexOverleafSkills: value.loadCodexOverleafSkills !== false,
5554
+ codexOverleafSkillEnabled: skills
5555
+ };
5556
+ }
5557
+ function validatePatch(value) {
5558
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid global preference patch.");
5559
+ const patch = {};
5560
+ for (const [key, item] of Object.entries(value)) {
5561
+ if (!FIELDS.includes(key)) throw new Error("Unknown global preference: " + key);
5562
+ if (key === "theme" && !["dark", "light", "auto"].includes(item) || key === "locale" && !["en", "zh"].includes(item) || typeof DEFAULTS[key] === "boolean" && typeof item !== "boolean") {
5563
+ throw new Error("Invalid global preference: " + key);
5564
+ }
5565
+ if (key === "codexOverleafSkillEnabled") {
5566
+ if (!item || typeof item !== "object" || Array.isArray(item) || Object.keys(item).length > 200) {
5567
+ throw new Error("Invalid skill preference map.");
5568
+ }
5569
+ for (const [id, enabled] of Object.entries(item)) {
5570
+ if (!validSkillId(id) || typeof enabled !== "boolean") throw new Error("Invalid skill preference.");
5571
+ }
5572
+ patch[key] = { ...item };
5573
+ } else patch[key] = item;
5574
+ }
5575
+ return patch;
5576
+ }
5577
+ function applyPatch(values, patch) {
5578
+ return { ...pick(values), ...patch, codexOverleafSkillEnabled: {
5579
+ ...pick(values).codexOverleafSkillEnabled,
5580
+ ...patch.codexOverleafSkillEnabled || {}
5581
+ } };
5582
+ }
5583
+ function changedKeys(left, right) {
5584
+ return FIELDS.filter((key) => JSON.stringify(left[key]) !== JSON.stringify(right[key]));
5585
+ }
5586
+ function validateSnapshot(value) {
5587
+ if (!value || value.schemaVersion !== 1 || !Number.isSafeInteger(value.revision) || value.revision < 1) {
5588
+ throw new Error("Invalid global preference revision.");
5589
+ }
5590
+ validatePatch(value.values);
5591
+ if (!FIELDS.every((key) => Object.hasOwn(value.values, key))) throw new Error("Incomplete global preferences.");
5592
+ return { schemaVersion: 1, revision: value.revision, values: pick(value.values) };
5593
+ }
5594
+ function createStore(storage) {
5595
+ let tail = Promise.resolve();
5596
+ function serial(work) {
5597
+ const pending = tail.then(work);
5598
+ tail = pending.catch(() => {
5599
+ });
5600
+ return pending;
5601
+ }
5602
+ async function read() {
5603
+ const stored = await storage.get([STORAGE_KEY, LEGACY_KEY]);
5604
+ if (stored[STORAGE_KEY] !== void 0) return validateSnapshot(stored[STORAGE_KEY]);
5605
+ const snapshot = { schemaVersion: 1, revision: 1, values: pick(stored[LEGACY_KEY] || {}) };
5606
+ await storage.set({ [STORAGE_KEY]: snapshot });
5607
+ return snapshot;
5608
+ }
5609
+ return Object.freeze({
5610
+ read: () => serial(read),
5611
+ patch: (input) => serial(async () => {
5612
+ const patch = validatePatch(input);
5613
+ const previous = await read();
5614
+ const values = applyPatch(previous.values, patch);
5615
+ if (Object.keys(values.codexOverleafSkillEnabled).length > 200) throw new Error("Too many skill preferences.");
5616
+ if (!changedKeys(previous.values, values).length) return previous;
5617
+ const snapshot = { schemaVersion: 1, revision: previous.revision + 1, values };
5618
+ await storage.set({ [STORAGE_KEY]: snapshot });
5619
+ return snapshot;
5620
+ })
5621
+ });
5622
+ }
5623
+ function installBackground(chromeApi) {
5624
+ const store = createStore(chromeApi.storage?.local);
5625
+ chromeApi.runtime.onMessage.addListener((message, sender, respond) => {
5626
+ if (![READ_MESSAGE, PATCH_MESSAGE].includes(message?.type)) return void 0;
5627
+ let allowed = false;
5628
+ try {
5629
+ const url = new URL(sender?.tab?.url || "");
5630
+ allowed = sender.id === chromeApi.runtime.id && url.protocol === "https:" && ["overleaf.com", "www.overleaf.com"].includes(url.hostname) && /^\/project(?:\/|$)/.test(url.pathname);
5631
+ } catch (_error) {
5632
+ }
5633
+ if (!allowed) {
5634
+ respond({ ok: false, error: { message: "Global preferences require an Overleaf tab." } });
5635
+ return false;
5636
+ }
5637
+ const pending = message.type === READ_MESSAGE ? store.read() : store.patch(message.patch);
5638
+ pending.then((result) => respond({ ok: true, result }), (error) => respond({ ok: false, error: { message: error.message } }));
5639
+ return true;
5640
+ });
5641
+ return store;
5642
+ }
5643
+ return Object.freeze({
5644
+ STORAGE_KEY,
5645
+ LEGACY_KEY,
5646
+ READ_MESSAGE,
5647
+ PATCH_MESSAGE,
5648
+ FIELDS,
5649
+ pick,
5650
+ validatePatch,
5651
+ validateSnapshot,
5652
+ applyPatch,
5653
+ changedKeys,
5654
+ createStore,
5655
+ installBackground
5656
+ });
5657
+ });
5658
+ }).call(globalThis, void 0, void 0, void 0);
5659
+ (function runClassicContentModule15(module, exports, require2) {
5660
+ (function(root, factory) {
5661
+ if (typeof module === "object" && module.exports) module.exports = factory(require2("../shared/globalPreferences"));
5662
+ else root.CodexOverleafModuleRegistry.define("GlobalPreferencesController", ["GlobalPreferences"], factory);
5663
+ })(typeof globalThis !== "undefined" ? globalThis : this, function(Preferences) {
5664
+ "use strict";
5665
+ const CONTROLS = Object.freeze({
5666
+ theme: "[data-theme-select]",
5667
+ locale: "[data-language-select]",
5668
+ preloadProjectContext: "[data-preload-project-context]",
5669
+ loadCodexLocalSkills: "[data-load-codex-local-skills]",
5670
+ loadCodexOverleafSkills: "[data-load-codex-overleaf-skills]"
5671
+ });
5672
+ function create(options2) {
5673
+ const chromeApi = options2.chromeApi;
5674
+ const fallback = Preferences.pick(options2.getState?.() || {});
5675
+ let snapshot = null;
5676
+ let loading = null;
5677
+ let subscribed = false;
5678
+ let disposed = false;
5679
+ let lastError = null;
5680
+ let tail = Promise.resolve();
5681
+ const pending = [];
5682
+ function view() {
5683
+ return pending.reduce((values, operation) => Preferences.applyPatch(values, operation.patch), snapshot?.values || fallback);
5684
+ }
5685
+ function render(force = false) {
5686
+ if (disposed) return;
5687
+ const previous = options2.getState?.() || {};
5688
+ const values = view();
5689
+ const changed = Preferences.changedKeys(Preferences.pick(previous), values);
5690
+ options2.setState?.({ ...previous, ...values });
5691
+ const panel = options2.getPanel?.();
5692
+ if (!panel) return;
5693
+ for (const [field, selector] of Object.entries(CONTROLS)) {
5694
+ const control = panel.querySelector(selector);
5695
+ if (!control) continue;
5696
+ if (typeof values[field] === "boolean") control.checked = values[field];
5697
+ else if (control.value !== values[field]) control.value = values[field];
5698
+ }
5699
+ if (force || changed.includes("theme")) options2.applyTheme?.(values.theme);
5700
+ if (changed.includes("locale")) options2.applyLocale?.();
5701
+ if (force || changed.includes("preloadProjectContext")) options2.onPreloadChange?.(values.preloadProjectContext);
5702
+ if (changed.some((key) => key === "codexOverleafSkillEnabled" || key.startsWith("loadCodex"))) options2.onSkillsChange?.();
5703
+ }
5704
+ function accept(value) {
5705
+ const next = Preferences.validateSnapshot(value);
5706
+ lastError = null;
5707
+ if (!snapshot || next.revision > snapshot.revision) {
5708
+ snapshot = next;
5709
+ render();
5710
+ }
5711
+ return snapshot;
5712
+ }
5713
+ async function request(type, patch) {
5714
+ const response = await chromeApi.runtime.sendMessage({ type, ...patch ? { patch } : {} });
5715
+ if (!response?.ok) throw new Error(response?.error?.message || "Global preferences are unavailable.");
5716
+ return response.result;
5717
+ }
5718
+ function onStorageChange(changes, area) {
5719
+ if (disposed || area !== "local" || !changes[Preferences.STORAGE_KEY]?.newValue) return;
5720
+ try {
5721
+ accept(changes[Preferences.STORAGE_KEY].newValue);
5722
+ } catch (error) {
5723
+ reportError(error);
5724
+ }
5725
+ }
5726
+ function reportError(error) {
5727
+ lastError = error;
5728
+ options2.onError?.(error);
5729
+ }
5730
+ async function initialize() {
5731
+ if (!subscribed) {
5732
+ chromeApi.storage.onChanged.addListener(onStorageChange);
5733
+ subscribed = true;
5734
+ }
5735
+ if (snapshot) return snapshot;
5736
+ if (!loading) {
5737
+ loading = request(Preferences.READ_MESSAGE).then(accept).catch((error) => {
5738
+ reportError(error);
5739
+ return null;
5740
+ }).finally(() => {
5741
+ loading = null;
5742
+ });
5743
+ }
5744
+ return loading;
5745
+ }
5746
+ function update(input) {
5747
+ const patch = Preferences.validatePatch(input);
5748
+ if (!Preferences.changedKeys(view(), Preferences.applyPatch(view(), patch)).length) return pending.length ? tail : Promise.resolve(snapshot);
5749
+ const operation = { patch };
5750
+ pending.push(operation);
5751
+ render();
5752
+ const result = tail.catch(() => {
5753
+ }).then(() => request(Preferences.PATCH_MESSAGE, patch)).then(Preferences.validateSnapshot).then((value) => {
5754
+ accept(value);
5755
+ pending.splice(pending.indexOf(operation), 1);
5756
+ render();
5757
+ return snapshot;
5758
+ }, (error) => {
5759
+ pending.splice(pending.indexOf(operation), 1);
5760
+ render();
5761
+ reportError(error);
5762
+ throw error;
5763
+ });
5764
+ tail = result;
5765
+ return result;
5766
+ }
5767
+ function handleInput(event) {
5768
+ const field = Object.keys(CONTROLS).find((key) => event?.target?.matches?.(CONTROLS[key]));
5769
+ if (!field) return null;
5770
+ return update({ [field]: ["theme", "locale"].includes(field) ? event.target.value : Boolean(event.target.checked) });
5771
+ }
5772
+ return Object.freeze({
5773
+ initialize,
5774
+ update,
5775
+ handleInput,
5776
+ overlay: (state) => snapshot || pending.length ? { ...state, ...view() } : state,
5777
+ refreshView: () => {
5778
+ if (snapshot) render(true);
5779
+ if (lastError) options2.onError?.(lastError);
5780
+ },
5781
+ destroy() {
5782
+ disposed = true;
5783
+ if (subscribed) chromeApi.storage.onChanged.removeListener(onStorageChange);
5784
+ }
5785
+ });
5786
+ }
5787
+ return Object.freeze({ create });
5788
+ });
5789
+ }).call(globalThis, void 0, void 0, void 0);
5790
+ (function runClassicContentModule16(module, exports, require2) {
5522
5791
  (function initCodexOverleafRunExecutionSnapshotCodec(root, factory) {
5523
5792
  if (typeof module === "object" && module.exports) {
5524
5793
  module.exports = factory();
@@ -5678,7 +5947,7 @@ ${block}`;
5678
5947
  };
5679
5948
  });
5680
5949
  }).call(globalThis, void 0, void 0, void 0);
5681
- (function runClassicContentModule15(module, exports, require2) {
5950
+ (function runClassicContentModule17(module, exports, require2) {
5682
5951
  (function initCodexOverleafRunExecutionSnapshot(root, factory) {
5683
5952
  if (typeof module === "object" && module.exports) {
5684
5953
  module.exports = factory(require2("./providerProfiles"), require2("./runExecutionSnapshotCodec"));
@@ -5848,7 +6117,7 @@ ${block}`;
5848
6117
  };
5849
6118
  });
5850
6119
  }).call(globalThis, void 0, void 0, void 0);
5851
- (function runClassicContentModule16(module, exports, require2) {
6120
+ (function runClassicContentModule18(module, exports, require2) {
5852
6121
  (function(root, factory) {
5853
6122
  var api = factory();
5854
6123
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -6027,7 +6296,7 @@ ${block}`;
6027
6296
  });
6028
6297
  });
6029
6298
  }).call(globalThis, void 0, void 0, void 0);
6030
- (function runClassicContentModule17(module, exports, require2) {
6299
+ (function runClassicContentModule19(module, exports, require2) {
6031
6300
  (function(root, factory) {
6032
6301
  if (typeof module === "object" && module.exports) {
6033
6302
  module.exports = factory(require2("./scopedPersistenceQueuePolicy"));
@@ -6100,7 +6369,7 @@ ${block}`;
6100
6369
  });
6101
6370
  });
6102
6371
  }).call(globalThis, void 0, void 0, void 0);
6103
- (function runClassicContentModule18(module, exports, require2) {
6372
+ (function runClassicContentModule20(module, exports, require2) {
6104
6373
  (function(root, factory) {
6105
6374
  if (typeof module === "object" && module.exports) {
6106
6375
  module.exports = factory();
@@ -6157,7 +6426,7 @@ ${block}`;
6157
6426
  });
6158
6427
  });
6159
6428
  }).call(globalThis, void 0, void 0, void 0);
6160
- (function runClassicContentModule19(module, exports, require2) {
6429
+ (function runClassicContentModule21(module, exports, require2) {
6161
6430
  (function(root, factory) {
6162
6431
  if (typeof module === "object" && module.exports) {
6163
6432
  module.exports = factory(
@@ -6381,7 +6650,7 @@ ${block}`;
6381
6650
  });
6382
6651
  });
6383
6652
  }).call(globalThis, void 0, void 0, void 0);
6384
- (function runClassicContentModule20(module, exports, require2) {
6653
+ (function runClassicContentModule22(module, exports, require2) {
6385
6654
  (function initCodexOverleafRunInputQueue(root, factory) {
6386
6655
  if (typeof module === "object" && module.exports) {
6387
6656
  module.exports = factory(require2("./runExecutionSnapshot"));
@@ -6651,7 +6920,7 @@ ${block}`;
6651
6920
  };
6652
6921
  });
6653
6922
  }).call(globalThis, void 0, void 0, void 0);
6654
- (function runClassicContentModule21(module, exports, require2) {
6923
+ (function runClassicContentModule23(module, exports, require2) {
6655
6924
  (function initCodexOverleafSettlementFacts(root, factory) {
6656
6925
  if (typeof module === "object" && module.exports) {
6657
6926
  module.exports = factory(require2("./failureReasons"));
@@ -6943,7 +7212,7 @@ ${block}`;
6943
7212
  };
6944
7213
  });
6945
7214
  }).call(globalThis, void 0, void 0, void 0);
6946
- (function runClassicContentModule22(module, exports, require2) {
7215
+ (function runClassicContentModule24(module, exports, require2) {
6947
7216
  (function initCodexOverleafWritebackEvidenceProjection(root, factory) {
6948
7217
  const api = factory();
6949
7218
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -7076,7 +7345,7 @@ ${block}`;
7076
7345
  });
7077
7346
  });
7078
7347
  }).call(globalThis, void 0, void 0, void 0);
7079
- (function runClassicContentModule23(module, exports, require2) {
7348
+ (function runClassicContentModule25(module, exports, require2) {
7080
7349
  (function initCodexOverleafWritebackOperationEvidence(root, factory) {
7081
7350
  if (typeof module === "object" && module.exports) {
7082
7351
  module.exports = factory();
@@ -7215,7 +7484,7 @@ ${block}`;
7215
7484
  };
7216
7485
  });
7217
7486
  }).call(globalThis, void 0, void 0, void 0);
7218
- (function runClassicContentModule24(module, exports, require2) {
7487
+ (function runClassicContentModule26(module, exports, require2) {
7219
7488
  (function initCodexOverleafWritebackSettlement(root, factory) {
7220
7489
  if (typeof module === "object" && module.exports) {
7221
7490
  module.exports = factory(
@@ -7838,7 +8107,7 @@ ${block}`;
7838
8107
  };
7839
8108
  });
7840
8109
  }).call(globalThis, void 0, void 0, void 0);
7841
- (function runClassicContentModule25(module, exports, require2) {
8110
+ (function runClassicContentModule27(module, exports, require2) {
7842
8111
  (function initSessionState(root, factory) {
7843
8112
  if (typeof module === "object" && module.exports) {
7844
8113
  module.exports = factory(
@@ -9157,7 +9426,7 @@ ${block}`;
9157
9426
  };
9158
9427
  });
9159
9428
  }).call(globalThis, void 0, void 0, void 0);
9160
- (function runClassicContentModule26(module, exports, require2) {
9429
+ (function runClassicContentModule28(module, exports, require2) {
9161
9430
  (function initStorageKeys(root, factory) {
9162
9431
  if (typeof module === "object" && module.exports) {
9163
9432
  module.exports = factory();
@@ -9185,7 +9454,7 @@ ${block}`;
9185
9454
  };
9186
9455
  });
9187
9456
  }).call(globalThis, void 0, void 0, void 0);
9188
- (function runClassicContentModule27(module, exports, require2) {
9457
+ (function runClassicContentModule29(module, exports, require2) {
9189
9458
  (function initStaleGuard(root, factory) {
9190
9459
  if (typeof module === "object" && module.exports) {
9191
9460
  module.exports = factory();
@@ -9336,7 +9605,7 @@ ${block}`;
9336
9605
  };
9337
9606
  });
9338
9607
  }).call(globalThis, void 0, void 0, void 0);
9339
- (function runClassicContentModule28(module, exports, require2) {
9608
+ (function runClassicContentModule30(module, exports, require2) {
9340
9609
  (function initStorageRunActions(root, factory) {
9341
9610
  if (typeof module === "object" && module.exports) {
9342
9611
  module.exports = factory();
@@ -9465,7 +9734,7 @@ ${block}`;
9465
9734
  };
9466
9735
  });
9467
9736
  }).call(globalThis, void 0, void 0, void 0);
9468
- (function runClassicContentModule29(module, exports, require2) {
9737
+ (function runClassicContentModule31(module, exports, require2) {
9469
9738
  (function initStorageSessionClaims(root, factory) {
9470
9739
  var api = factory();
9471
9740
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -9531,7 +9800,7 @@ ${block}`;
9531
9800
  return Object.freeze({ createSessionClaimer });
9532
9801
  });
9533
9802
  }).call(globalThis, void 0, void 0, void 0);
9534
- (function runClassicContentModule30(module, exports, require2) {
9803
+ (function runClassicContentModule32(module, exports, require2) {
9535
9804
  (function initStorageDb(root, factory) {
9536
9805
  if (typeof module === "object" && module.exports) {
9537
9806
  module.exports = factory(
@@ -10756,7 +11025,7 @@ ${block}`;
10756
11025
  };
10757
11026
  });
10758
11027
  }).call(globalThis, void 0, void 0, void 0);
10759
- (function runClassicContentModule31(module, exports, require2) {
11028
+ (function runClassicContentModule33(module, exports, require2) {
10760
11029
  (function initStorageMigration(root, factory) {
10761
11030
  if (typeof module === "object" && module.exports) {
10762
11031
  module.exports = factory(require2("./storageDb"));
@@ -11211,7 +11480,7 @@ ${block}`;
11211
11480
  };
11212
11481
  });
11213
11482
  }).call(globalThis, void 0, void 0, void 0);
11214
- (function runClassicContentModule32(module, exports, require2) {
11483
+ (function runClassicContentModule34(module, exports, require2) {
11215
11484
  (function initCompileAdapter(root, factory) {
11216
11485
  if (typeof module === "object" && module.exports) {
11217
11486
  module.exports = factory();
@@ -11354,7 +11623,7 @@ ${block}`;
11354
11623
  };
11355
11624
  });
11356
11625
  }).call(globalThis, void 0, void 0, void 0);
11357
- (function runClassicContentModule33(module, exports, require2) {
11626
+ (function runClassicContentModule35(module, exports, require2) {
11358
11627
  (function initCodexOverleafCompatibility(root, factory) {
11359
11628
  if (typeof module === "object" && module.exports) {
11360
11629
  module.exports = factory();
@@ -11368,7 +11637,7 @@ ${block}`;
11368
11637
  const MIN_NATIVE_VERSION = "1.0.0";
11369
11638
  const MIN_COMPATIBLE_NATIVE_VERSION = "1.0.0";
11370
11639
  const MIN_COMPATIBLE_EXTENSION_VERSION = "1.0.0";
11371
- const BUILD_TARGET_VERSION = "2.3.4";
11640
+ const BUILD_TARGET_VERSION = "2.3.5";
11372
11641
  const DEFAULT_CHROME_EXTENSION_ID = "illdpneeeopfffmiepaejglgmhpmdhdc";
11373
11642
  const REQUIRED_CAPABILITIES = Object.freeze([
11374
11643
  "bridgePing",
@@ -11664,7 +11933,7 @@ ${block}`;
11664
11933
  };
11665
11934
  });
11666
11935
  }).call(globalThis, void 0, void 0, void 0);
11667
- (function runClassicContentModule34(module, exports, require2) {
11936
+ (function runClassicContentModule36(module, exports, require2) {
11668
11937
  (function(root, factory) {
11669
11938
  var api = factory();
11670
11939
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -11795,7 +12064,7 @@ ${block}`;
11795
12064
  });
11796
12065
  });
11797
12066
  }).call(globalThis, void 0, void 0, void 0);
11798
- (function runClassicContentModule35(module, exports, require2) {
12067
+ (function runClassicContentModule37(module, exports, require2) {
11799
12068
  (function initCodexOverleafManagedUpdateProjection(root) {
11800
12069
  "use strict";
11801
12070
  const PHASE_ALIASES = Object.freeze({
@@ -12101,7 +12370,7 @@ ${block}`;
12101
12370
  });
12102
12371
  })(typeof window !== "undefined" ? window : globalThis);
12103
12372
  }).call(globalThis, void 0, void 0, void 0);
12104
- (function runClassicContentModule36(module, exports, require2) {
12373
+ (function runClassicContentModule38(module, exports, require2) {
12105
12374
  (function initGovernanceRules(root, factory) {
12106
12375
  if (typeof module === "object" && module.exports) {
12107
12376
  let projectFiles = null;
@@ -12318,7 +12587,7 @@ ${block}`;
12318
12587
  };
12319
12588
  });
12320
12589
  }).call(globalThis, void 0, void 0, void 0);
12321
- (function runClassicContentModule37(module, exports, require2) {
12590
+ (function runClassicContentModule39(module, exports, require2) {
12322
12591
  (function initSensitiveScan(root, factory) {
12323
12592
  if (typeof module === "object" && module.exports) {
12324
12593
  module.exports = factory();
@@ -12428,7 +12697,7 @@ ${block}`;
12428
12697
  };
12429
12698
  });
12430
12699
  }).call(globalThis, void 0, void 0, void 0);
12431
- (function runClassicContentModule38(module, exports, require2) {
12700
+ (function runClassicContentModule40(module, exports, require2) {
12432
12701
  (function initAuditRecords(root, factory) {
12433
12702
  if (typeof module === "object" && module.exports) {
12434
12703
  module.exports = factory();
@@ -12954,7 +13223,7 @@ ${block}`;
12954
13223
  };
12955
13224
  });
12956
13225
  }).call(globalThis, void 0, void 0, void 0);
12957
- (function runClassicContentModule39(module, exports, require2) {
13226
+ (function runClassicContentModule41(module, exports, require2) {
12958
13227
  (function initCodexOverleafNativeChannel(root, factory) {
12959
13228
  if (typeof module === "object" && module.exports) {
12960
13229
  module.exports = factory();
@@ -13033,7 +13302,7 @@ ${block}`;
13033
13302
  };
13034
13303
  });
13035
13304
  }).call(globalThis, void 0, void 0, void 0);
13036
- (function runClassicContentModule40(module, exports, require2) {
13305
+ (function runClassicContentModule42(module, exports, require2) {
13037
13306
  (function initCodexOverleafPageBridgeClient(root, factory) {
13038
13307
  const api = factory();
13039
13308
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -13236,7 +13505,7 @@ ${block}`;
13236
13505
  });
13237
13506
  });
13238
13507
  }).call(globalThis, void 0, void 0, void 0);
13239
- (function runClassicContentModule41(module, exports, require2) {
13508
+ (function runClassicContentModule43(module, exports, require2) {
13240
13509
  (function initCodexOverleafNativeCompatibilityController(root, factory) {
13241
13510
  const api = factory();
13242
13511
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -13515,7 +13784,7 @@ ${block}`;
13515
13784
  return Object.freeze({ create });
13516
13785
  });
13517
13786
  }).call(globalThis, void 0, void 0, void 0);
13518
- (function runClassicContentModule42(module, exports, require2) {
13787
+ (function runClassicContentModule44(module, exports, require2) {
13519
13788
  (function initCodexOverleafWritebackController(root, factory) {
13520
13789
  if (typeof module === "object" && module.exports) {
13521
13790
  module.exports = factory();
@@ -13780,7 +14049,7 @@ ${block}`;
13780
14049
  };
13781
14050
  });
13782
14051
  }).call(globalThis, void 0, void 0, void 0);
13783
- (function runClassicContentModule43(module, exports, require2) {
14052
+ (function runClassicContentModule45(module, exports, require2) {
13784
14053
  (function initCodexOverleafAssetTransferBroker(root, factory) {
13785
14054
  const api = factory();
13786
14055
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -13942,7 +14211,7 @@ ${block}`;
13942
14211
  return { create, mergeApplyResults };
13943
14212
  });
13944
14213
  }).call(globalThis, void 0, void 0, void 0);
13945
- (function runClassicContentModule44(module, exports, require2) {
14214
+ (function runClassicContentModule46(module, exports, require2) {
13946
14215
  (function initCodexOverleafReviewHunks(root, factory) {
13947
14216
  if (typeof module === "object" && module.exports) {
13948
14217
  module.exports = factory();
@@ -14161,7 +14430,7 @@ ${block}`;
14161
14430
  };
14162
14431
  });
14163
14432
  }).call(globalThis, void 0, void 0, void 0);
14164
- (function runClassicContentModule45(module, exports, require2) {
14433
+ (function runClassicContentModule47(module, exports, require2) {
14165
14434
  (function initCodexOverleafDiffReviewPanel(root, factory) {
14166
14435
  if (typeof module === "object" && module.exports) {
14167
14436
  module.exports = factory(require2("./reviewHunks"));
@@ -14888,7 +15157,7 @@ ${block}`;
14888
15157
  };
14889
15158
  });
14890
15159
  }).call(globalThis, void 0, void 0, void 0);
14891
- (function runClassicContentModule46(module, exports, require2) {
15160
+ (function runClassicContentModule48(module, exports, require2) {
14892
15161
  (function initCodexOverleafContextTray(root, factory) {
14893
15162
  if (typeof module === "object" && module.exports) {
14894
15163
  module.exports = factory(require2("../shared/projectFiles"));
@@ -15636,7 +15905,7 @@ ${block}`;
15636
15905
  };
15637
15906
  });
15638
15907
  }).call(globalThis, void 0, void 0, void 0);
15639
- (function runClassicContentModule47(module, exports, require2) {
15908
+ (function runClassicContentModule49(module, exports, require2) {
15640
15909
  (function initCodexOverleafLocalSkillsPanel(root, factory) {
15641
15910
  if (typeof module === "object" && module.exports) {
15642
15911
  module.exports = factory();
@@ -15867,7 +16136,7 @@ ${block}`;
15867
16136
  };
15868
16137
  });
15869
16138
  }).call(globalThis, void 0, void 0, void 0);
15870
- (function runClassicContentModule48(module, exports, require2) {
16139
+ (function runClassicContentModule50(module, exports, require2) {
15871
16140
  (function initCodexOverleafRunController(root, factory) {
15872
16141
  if (typeof module === "object" && module.exports) {
15873
16142
  module.exports = factory();
@@ -16097,7 +16366,7 @@ ${block}`;
16097
16366
  };
16098
16367
  });
16099
16368
  }).call(globalThis, void 0, void 0, void 0);
16100
- (function runClassicContentModule49(module, exports, require2) {
16369
+ (function runClassicContentModule51(module, exports, require2) {
16101
16370
  (function initCodexOverleafMirrorHealth(root, factory) {
16102
16371
  if (typeof module === "object" && module.exports) {
16103
16372
  module.exports = factory();
@@ -16181,7 +16450,7 @@ ${block}`;
16181
16450
  };
16182
16451
  });
16183
16452
  }).call(globalThis, void 0, void 0, void 0);
16184
- (function runClassicContentModule50(module, exports, require2) {
16453
+ (function runClassicContentModule52(module, exports, require2) {
16185
16454
  (function initCodexOverleafOtWarmMirrorController(root, factory) {
16186
16455
  if (typeof module === "object" && module.exports) {
16187
16456
  module.exports = factory();
@@ -16334,7 +16603,7 @@ ${block}`;
16334
16603
  };
16335
16604
  });
16336
16605
  }).call(globalThis, void 0, void 0, void 0);
16337
- (function runClassicContentModule51(module, exports, require2) {
16606
+ (function runClassicContentModule53(module, exports, require2) {
16338
16607
  (function initComposerAttachments(global) {
16339
16608
  "use strict";
16340
16609
  function createComposerAttachmentController(options2 = {}) {
@@ -16794,7 +17063,7 @@ ${block}`;
16794
17063
  };
16795
17064
  })(window);
16796
17065
  }).call(globalThis, void 0, void 0, void 0);
16797
- (function runClassicContentModule52(module, exports, require2) {
17066
+ (function runClassicContentModule54(module, exports, require2) {
16798
17067
  (function initCodexOverleafPanelRenderer() {
16799
17068
  "use strict";
16800
17069
  const ROOT_CLASS = "codex-overleaf-panel-mounted";
@@ -17089,7 +17358,8 @@ ${block}`;
17089
17358
  const doc = panel.ownerDocument || document;
17090
17359
  return new Promise((resolve) => {
17091
17360
  let settled = false;
17092
- const overlay = doc.createElement("div");
17361
+ const returnFocus = doc.activeElement;
17362
+ const overlay = doc.createElement("dialog");
17093
17363
  overlay.className = "codex-plugin-confirm";
17094
17364
  overlay.setAttribute("data-plugin-confirm", "true");
17095
17365
  overlay.setAttribute("role", "dialog");
@@ -17131,12 +17401,15 @@ ${block}`;
17131
17401
  card.append(head, body, actions);
17132
17402
  overlay.append(card);
17133
17403
  panel.append(overlay);
17404
+ overlay.showModal?.();
17134
17405
  const cleanup = (value) => {
17135
17406
  if (settled) return;
17136
17407
  settled = true;
17137
17408
  activeResolve = null;
17138
17409
  doc.removeEventListener("keydown", onKeydown, true);
17410
+ overlay.close?.();
17139
17411
  overlay.remove();
17412
+ returnFocus?.focus?.();
17140
17413
  resolve(value);
17141
17414
  };
17142
17415
  activeResolve = cleanup;
@@ -17157,6 +17430,10 @@ ${block}`;
17157
17430
  overlay.addEventListener("click", (event) => {
17158
17431
  if (event.target === overlay) cleanup(false);
17159
17432
  });
17433
+ overlay.addEventListener("cancel", (event) => {
17434
+ event.preventDefault();
17435
+ cleanup(false);
17436
+ });
17160
17437
  cancel.addEventListener("click", () => cleanup(false));
17161
17438
  confirm.addEventListener("click", () => cleanup(true));
17162
17439
  doc.addEventListener("keydown", onKeydown, true);
@@ -17187,7 +17464,7 @@ ${block}`;
17187
17464
  };
17188
17465
  })();
17189
17466
  }).call(globalThis, void 0, void 0, void 0);
17190
- (function runClassicContentModule53(module, exports, require2) {
17467
+ (function runClassicContentModule55(module, exports, require2) {
17191
17468
  (function initCodexOverleafSessionPanel() {
17192
17469
  "use strict";
17193
17470
  function create(options2 = {}) {
@@ -17423,7 +17700,7 @@ ${block}`;
17423
17700
  };
17424
17701
  })();
17425
17702
  }).call(globalThis, void 0, void 0, void 0);
17426
- (function runClassicContentModule54(module, exports, require2) {
17703
+ (function runClassicContentModule56(module, exports, require2) {
17427
17704
  (function initCodexOverleafSettingsPanel() {
17428
17705
  "use strict";
17429
17706
  function codexIcon(name) {
@@ -17666,10 +17943,13 @@ ${block}`;
17666
17943
  for (const selector of ["[data-governance-readonly-patterns]", "[data-governance-writable-patterns]", "[data-sensitive-check-enabled]", "[data-sensitive-confirm-allowed]", "[data-preload-project-context]", "[data-load-codex-local-skills]", "[data-load-codex-overleaf-skills]", "[data-theme-select]", "[data-language-select]"]) {
17667
17944
  const element = container.querySelector(selector);
17668
17945
  element?.addEventListener?.("change", (event) => {
17669
- instance.callbacks.onInputChange?.(event);
17670
- flashSaved(instance, event);
17946
+ Promise.resolve(instance.callbacks.onInputChange?.(event)).then(() => flashSaved(instance, event)).catch(() => {
17947
+ });
17948
+ });
17949
+ element?.addEventListener?.("input", (event) => {
17950
+ Promise.resolve(instance.callbacks.onInputChange?.(event)).catch(() => {
17951
+ });
17671
17952
  });
17672
- element?.addEventListener?.("input", (event) => instance.callbacks.onInputChange?.(event));
17673
17953
  }
17674
17954
  for (const selector of ["[data-governance-readonly-patterns]", "[data-governance-writable-patterns]"]) {
17675
17955
  const element = container.querySelector(selector);
@@ -17938,7 +18218,7 @@ ${block}`;
17938
18218
  };
17939
18219
  })();
17940
18220
  }).call(globalThis, void 0, void 0, void 0);
17941
- (function runClassicContentModule55(module, exports, require2) {
18221
+ (function runClassicContentModule57(module, exports, require2) {
17942
18222
  (function initCodexOverleafProviderSettingsDialog() {
17943
18223
  "use strict";
17944
18224
  const CODEX_BLOSSOM_PATH = "M13.798 23.976a5.7 5.7 0 0 1-2.26-.456 6.1 6.1 0 0 1-1.903-1.27 5.7 5.7 0 0 1-1.88.311 5.75 5.75 0 0 1-2.95-.79 6.2 6.2 0 0 1-2.188-2.159q-.81-1.366-.809-3.045 0-.695.19-1.51a6.4 6.4 0 0 1-1.475-2.038A5.95 5.95 0 0 1 0 10.573Q0 9.278.547 8.08q.547-1.2 1.523-2.062a5.5 5.5 0 0 1 2.307-1.223A5.7 5.7 0 0 1 5.472 2.35 6.1 6.1 0 0 1 7.565.623 5.8 5.8 0 0 1 10.206 0q1.19 0 2.26.456a6.1 6.1 0 0 1 1.903 1.27 5.7 5.7 0 0 1 1.88-.311q1.594 0 2.95.79a6 6 0 0 1 2.165 2.159q.832 1.366.832 3.045 0 .695-.19 1.51a6.3 6.3 0 0 1 1.475 2.062q.523 1.15.523 2.422a5.9 5.9 0 0 1-.547 2.493q-.547 1.2-1.546 2.086a5.4 5.4 0 0 1-2.284 1.199 5.56 5.56 0 0 1-1.118 2.445 5.9 5.9 0 0 1-2.07 1.727 5.8 5.8 0 0 1-2.64.623m-5.876-2.997q1.19 0 2.07-.504l4.472-2.589a.53.53 0 0 0 .238-.455v-2.062L8.945 18.7a.96.96 0 0 1-1.047 0l-4.496-2.613a.7.7 0 0 1-.024.168v.287q0 1.224.571 2.254a4.24 4.24 0 0 0 1.642 1.583q1.047.6 2.331.599m.238-3.908a.6.6 0 0 0 .262.072q.118 0 .238-.072l1.784-1.031-5.734-3.357q-.522-.312-.523-.935V6.545a4.3 4.3 0 0 0-1.903 1.63 4.25 4.25 0 0 0-.714 2.398q0 1.176.595 2.254.594 1.08 1.546 1.63zm5.638 5.323q1.26 0 2.284-.576a4.3 4.3 0 0 0 1.618-1.582q.595-1.008.595-2.254v-5.179a.47.47 0 0 0-.238-.431l-1.808-1.055v6.689q0 .624-.524.935l-4.496 2.613a4.3 4.3 0 0 0 2.57.84m.904-8.776v-3.26l-2.688-1.535-2.712 1.535v3.26l2.712 1.535zM7.756 5.97q0-.623.523-.935l4.496-2.613a4.3 4.3 0 0 0-2.569-.84q-1.26 0-2.284.576A4.3 4.3 0 0 0 6.304 3.74q-.57 1.008-.57 2.254v5.155q0 .287.237.455l1.785 1.055zM19.84 17.43a4.16 4.16 0 0 0 1.88-1.63 4.33 4.33 0 0 0 .713-2.397q0-1.176-.595-2.254-.594-1.08-1.546-1.63l-4.449-2.59q-.143-.096-.261-.072a.46.46 0 0 0-.238.072L13.56 7.936l5.758 3.38a.9.9 0 0 1 .38.384q.143.216.143.528zM15.059 5.25q.524-.335 1.047 0l4.52 2.662V7.48q0-1.15-.57-2.181A4.14 4.14 0 0 0 18.46 3.62q-1.023-.623-2.379-.623-1.19 0-2.07.503L9.54 6.09a.53.53 0 0 0-.238.455v2.062z";
@@ -17984,12 +18264,13 @@ ${block}`;
17984
18264
  if (instance.root) {
17985
18265
  return instance.root;
17986
18266
  }
17987
- const root = instance.document.createElement("div");
18267
+ const root = instance.document.createElement("dialog");
17988
18268
  root.className = "codex-provider-dialog-root";
18269
+ root.setAttribute("aria-labelledby", "codex-provider-dialog-title");
17989
18270
  root.hidden = true;
17990
18271
  root.innerHTML = `
17991
18272
  <div class="codex-provider-dialog-backdrop" data-provider-backdrop></div>
17992
- <section class="codex-provider-dialog" role="dialog" aria-modal="true" aria-labelledby="codex-provider-dialog-title">
18273
+ <section class="codex-provider-dialog">
17993
18274
  <header class="codex-provider-dialog-head">
17994
18275
  <div class="codex-provider-dialog-heading">
17995
18276
  <div class="codex-provider-dialog-titleline">
@@ -18016,6 +18297,10 @@ ${block}`;
18016
18297
  root.addEventListener("input", (event) => handleInput(instance, event));
18017
18298
  root.addEventListener("change", (event) => handleInput(instance, event));
18018
18299
  root.addEventListener("keydown", (event) => handleKeydown(instance, event));
18300
+ root.addEventListener("cancel", (event) => {
18301
+ event.preventDefault();
18302
+ requestClose(instance);
18303
+ });
18019
18304
  root.addEventListener("mousedown", (event) => event.stopPropagation());
18020
18305
  root.addEventListener("click", (event) => event.stopPropagation());
18021
18306
  return root;
@@ -18025,8 +18310,11 @@ ${block}`;
18025
18310
  instance.root.hidden = false;
18026
18311
  syncTheme(instance);
18027
18312
  setCatalog(instance, catalog || instance.catalog);
18313
+ if (!instance.root.open) instance.root.showModal?.();
18028
18314
  queueMicrotask(() => {
18029
- instance.root.querySelector('[data-provider-row][aria-current="true"]')?.focus?.() || instance.root.querySelector("input, button, select, textarea")?.focus?.();
18315
+ if (!instance.root || instance.root.hidden) return;
18316
+ const target = instance.root.querySelector('[data-provider-row][aria-current="true"]') || instance.root.querySelector("input, button, select, textarea");
18317
+ target?.focus?.();
18030
18318
  });
18031
18319
  }
18032
18320
  function requestClose(instance) {
@@ -18040,6 +18328,7 @@ ${block}`;
18040
18328
  instance.callbacks.onCancelTest?.();
18041
18329
  instance.busy = "";
18042
18330
  }
18331
+ instance.root.close?.();
18043
18332
  instance.root.hidden = true;
18044
18333
  instance.busy = "";
18045
18334
  instance.returnFocus?.focus?.();
@@ -18086,6 +18375,10 @@ ${block}`;
18086
18375
  "Configure experimental third-party integrations used by this project's future Codex runs. Compatibility varies by provider and gateway.",
18087
18376
  "\u914D\u7F6E\u5F53\u524D\u9879\u76EE\u540E\u7EED Codex \u4EFB\u52A1\u4F7F\u7528\u7684\u5B9E\u9A8C\u6027\u7B2C\u4E09\u65B9\u96C6\u6210\uFF1B\u517C\u5BB9\u6027\u53D6\u51B3\u4E8E\u5177\u4F53\u6A21\u578B\u670D\u52A1\u4E0E\u7F51\u5173\u3002"
18088
18377
  );
18378
+ if (instance.callbacks.hasCurrentProject?.() === false) instance.root.querySelector("[data-provider-dialog-subtitle]").textContent = tx(
18379
+ "Manage shared model API profiles. Open a project to choose which provider its future turns use.",
18380
+ "\u7BA1\u7406\u5171\u4EAB\u6A21\u578B API \u914D\u7F6E\u3002\u8FDB\u5165\u9879\u76EE\u540E\uFF0C\u518D\u9009\u62E9\u8BE5\u9879\u76EE\u540E\u7EED\u4EFB\u52A1\u4F7F\u7528\u7684\u670D\u52A1\u3002"
18381
+ );
18089
18382
  renderProviderList(instance);
18090
18383
  renderDetail(instance);
18091
18384
  renderFooter(instance);
@@ -18318,8 +18611,8 @@ ${block}`;
18318
18611
  <label class="codex-provider-disclosure">
18319
18612
  <input type="checkbox" data-provider-disclosure ${disclosureSatisfied ? "checked" : ""}>
18320
18613
  <span data-provider-disclosure-text>${escapeHtml(tx(
18321
- `Future Codex runs in every Overleaf project tab may send selected project content to ${draft.baseUrl || "this endpoint"}.`,
18322
- `\u6240\u6709 Overleaf \u9879\u76EE\u6807\u7B7E\u9875\u7684\u540E\u7EED Codex \u4EFB\u52A1\u90FD\u53EF\u80FD\u628A\u6240\u9009\u9879\u76EE\u5185\u5BB9\u53D1\u9001\u5230 ${draft.baseUrl || "\u6B64\u7AEF\u70B9"}\u3002`
18614
+ `Projects using this shared provider may send task context to ${draft.baseUrl || "this endpoint"}. Each project chooses its own provider.`,
18615
+ `\u4F7F\u7528\u6B64\u5171\u4EAB\u670D\u52A1\u914D\u7F6E\u7684\u9879\u76EE\u53EF\u80FD\u628A\u4EFB\u52A1\u4E0A\u4E0B\u6587\u53D1\u9001\u5230 ${draft.baseUrl || "\u6B64\u7AEF\u70B9"}\u3002\u5404\u9879\u76EE\u72EC\u7ACB\u9009\u62E9\u4F7F\u7528\u7684\u670D\u52A1\u3002`
18323
18616
  ))}</span>
18324
18617
  </label>
18325
18618
  <div class="codex-provider-test-row">
@@ -18365,11 +18658,12 @@ ${block}`;
18365
18658
  "Uses the authentication, model catalog, and provider configuration managed by the local Codex CLI.",
18366
18659
  "\u4F7F\u7528\u672C\u5730 Codex CLI \u7BA1\u7406\u7684\u8EAB\u4EFD\u9A8C\u8BC1\u3001\u6A21\u578B\u76EE\u5F55\u548C\u670D\u52A1\u914D\u7F6E\u3002"
18367
18660
  ))}</p>
18368
- ${active ? `<span class="codex-provider-active-badge">${escapeHtml(tx("Current project", "\u5F53\u524D\u9879\u76EE"))}</span>` : `<button type="button" class="codex-provider-primary-button" data-provider-action="activate-builtin">${escapeHtml(tx("Use for this project", "\u7528\u4E8E\u5F53\u524D\u9879\u76EE"))}</button>`}
18661
+ ${instance.callbacks.hasCurrentProject?.() === false ? "" : active ? `<span class="codex-provider-active-badge">${escapeHtml(tx("Current project", "\u5F53\u524D\u9879\u76EE"))}</span>` : `<button type="button" class="codex-provider-primary-button" data-provider-action="activate-builtin">${escapeHtml(tx("Use for this project", "\u7528\u4E8E\u5F53\u524D\u9879\u76EE"))}</button>`}
18369
18662
  </div>
18370
18663
  `;
18371
18664
  }
18372
18665
  function getCurrentProjectProviderId(instance) {
18666
+ if (instance.callbacks.hasCurrentProject?.() === false) return "";
18373
18667
  const providerId = instance.callbacks.getCurrentProjectProviderId?.();
18374
18668
  return typeof providerId === "string" && providerId.trim() ? providerId.trim() : "builtin";
18375
18669
  }
@@ -18390,6 +18684,7 @@ ${block}`;
18390
18684
  dirty: instance.dirty,
18391
18685
  destinationChanged,
18392
18686
  canSave: canSaveCurrentDraft(instance),
18687
+ hasProject: instance.callbacks.hasCurrentProject?.() !== false,
18393
18688
  canActivate: canActivateCurrentProvider(instance)
18394
18689
  });
18395
18690
  const saveDisabled = actionState.saveEnabled ? "" : ' disabled aria-disabled="true"';
@@ -18410,8 +18705,8 @@ ${block}`;
18410
18705
  const dirty = options2.dirty === true;
18411
18706
  return {
18412
18707
  showSave: isNew || dirty,
18413
- showSaveAndUse: (isNew || dirty) && (!active || options2.destinationChanged === true),
18414
- showUse: !isNew && !active && !dirty,
18708
+ showSaveAndUse: options2.hasProject !== false && (isNew || dirty) && (!active || options2.destinationChanged === true),
18709
+ showUse: options2.hasProject !== false && !isNew && !active && !dirty,
18415
18710
  saveEnabled: options2.canSave === true,
18416
18711
  useEnabled: options2.canActivate === true
18417
18712
  };
@@ -18558,7 +18853,7 @@ ${block}`;
18558
18853
  if (event.key !== "Tab") {
18559
18854
  return;
18560
18855
  }
18561
- const focusable = Array.from(instance.root.querySelectorAll("button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])")).filter((element) => !element.closest("[hidden]"));
18856
+ const focusable = Array.from(instance.root.querySelectorAll("button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])")).filter((element) => !element.closest("[hidden]") && (!element.getClientRects || element.getClientRects().length));
18562
18857
  if (!focusable.length) {
18563
18858
  return;
18564
18859
  }
@@ -18798,8 +19093,8 @@ ${block}`;
18798
19093
  if (!text) return;
18799
19094
  const baseUrl = getCurrentBaseUrl(instance) || instance.tx("this endpoint", "\u6B64\u7AEF\u70B9");
18800
19095
  text.textContent = instance.tx(
18801
- `Future Codex runs in every Overleaf project tab may send selected project content to ${baseUrl}.`,
18802
- `\u6240\u6709 Overleaf \u9879\u76EE\u6807\u7B7E\u9875\u7684\u540E\u7EED Codex \u4EFB\u52A1\u90FD\u53EF\u80FD\u628A\u6240\u9009\u9879\u76EE\u5185\u5BB9\u53D1\u9001\u5230 ${baseUrl}\u3002`
19096
+ `Projects using this shared provider may send task context to ${baseUrl}. Each project chooses its own provider.`,
19097
+ `\u4F7F\u7528\u6B64\u5171\u4EAB\u670D\u52A1\u914D\u7F6E\u7684\u9879\u76EE\u53EF\u80FD\u628A\u4EFB\u52A1\u4E0A\u4E0B\u6587\u53D1\u9001\u5230 ${baseUrl}\u3002\u5404\u9879\u76EE\u72EC\u7ACB\u9009\u62E9\u4F7F\u7528\u7684\u670D\u52A1\u3002`
18803
19098
  );
18804
19099
  }
18805
19100
  function syncTestAction(instance) {
@@ -18835,10 +19130,7 @@ ${block}`;
18835
19130
  if (!panel) {
18836
19131
  return;
18837
19132
  }
18838
- const style = instance.document.defaultView.getComputedStyle(panel);
18839
19133
  instance.root.dataset.theme = panel.dataset.theme === "light" ? "light" : "dark";
18840
- instance.root.style.setProperty("--provider-panel-bg", style.backgroundColor || "#151716");
18841
- instance.root.style.setProperty("--provider-panel-color", style.color || "#eceeea");
18842
19134
  }
18843
19135
  function escapeHtml(value) {
18844
19136
  return String(value ?? "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
@@ -18853,13 +19145,14 @@ ${block}`;
18853
19145
  return escapeHtml(value).replaceAll("`", "&#96;");
18854
19146
  }
18855
19147
  function destroy(instance) {
19148
+ instance.root?.close?.();
18856
19149
  instance.root?.remove?.();
18857
19150
  instance.root = null;
18858
19151
  }
18859
19152
  window.CodexOverleafProviderSettingsDialog = { create, getFooterActionState };
18860
19153
  })();
18861
19154
  }).call(globalThis, void 0, void 0, void 0);
18862
- (function runClassicContentModule56(module, exports, require2) {
19155
+ (function runClassicContentModule58(module, exports, require2) {
18863
19156
  (function initCodexOverleafProjectProviderSelection() {
18864
19157
  "use strict";
18865
19158
  function create(deps = {}) {
@@ -18916,7 +19209,7 @@ ${block}`;
18916
19209
  window.CodexOverleafProjectProviderSelection = { create };
18917
19210
  })();
18918
19211
  }).call(globalThis, void 0, void 0, void 0);
18919
- (function runClassicContentModule57(module, exports, require2) {
19212
+ (function runClassicContentModule59(module, exports, require2) {
18920
19213
  (function initCodexOverleafProviderSettingsCoordinator() {
18921
19214
  "use strict";
18922
19215
  function create(options2 = {}) {
@@ -18932,6 +19225,7 @@ ${block}`;
18932
19225
  getSettingsPanelInstance: options2.getSettingsPanelInstance || (() => null),
18933
19226
  getSelectedModel: options2.getSelectedModel || (() => ""),
18934
19227
  getSelectedProviderId: options2.getSelectedProviderId || (() => "builtin"),
19228
+ hasCurrentProject: options2.hasCurrentProject || (() => true),
18935
19229
  setSelectedProviderId: options2.setSelectedProviderId || (() => {
18936
19230
  }),
18937
19231
  confirmProviderSwitch: options2.confirmProviderSwitch || (() => true),
@@ -18964,6 +19258,7 @@ ${block}`;
18964
19258
  tx: instance.tx,
18965
19259
  ProviderProfiles: Profiles,
18966
19260
  callbacks: {
19261
+ hasCurrentProject: instance.hasCurrentProject,
18967
19262
  getCurrentProjectProviderId: () => instance.getSelectedProviderId() || "builtin",
18968
19263
  onTest: (context) => testProvider(instance, context),
18969
19264
  onCancelTest: () => cancelProviderTest(instance),
@@ -19102,6 +19397,7 @@ ${block}`;
19102
19397
  return { providerId: requestedProviderId, selectedModel: loadResult?.selectedModel || "" };
19103
19398
  }
19104
19399
  async function prepareProviderActivation(instance, providerId) {
19400
+ requireCurrentProject(instance);
19105
19401
  const previousProviderId = instance.getSelectedProviderId() || "builtin";
19106
19402
  const provider = instance.Profiles.getProviderById(instance.catalog, providerId);
19107
19403
  if (providerId !== previousProviderId) {
@@ -19192,6 +19488,7 @@ ${block}`;
19192
19488
  async function saveProvider(instance, context, action = {}) {
19193
19489
  instance.dialog.setBusy("saving", instance.tx("Saving provider\u2026", "\u6B63\u5728\u4FDD\u5B58\u6A21\u578B\u670D\u52A1\u2026"));
19194
19490
  try {
19491
+ if (action.activate === true) requireCurrentProject(instance);
19195
19492
  const result = await request(instance, "codex.providers.upsert", {
19196
19493
  profileId: context.profileId,
19197
19494
  expectedRevision: context.expectedRevision,
@@ -19371,6 +19668,13 @@ ${block}`;
19371
19668
  return { applied: true, change: describeCatalogChange(instance, previousCatalog, nextCatalog) };
19372
19669
  }
19373
19670
  function updateSettingsSummary(instance, override = {}) {
19671
+ if (!instance.hasCurrentProject()) {
19672
+ instance.getSettingsPanelInstance()?.setProviderSummary?.({ summary: instance.tx(
19673
+ "Shared model API profiles \xB7 open a project to select a provider",
19674
+ "\u5171\u4EAB\u6A21\u578B API \u914D\u7F6E \xB7 \u8FDB\u5165\u9879\u76EE\u540E\u9009\u62E9\u4F7F\u7528\u7684\u670D\u52A1"
19675
+ ), tone: "info" });
19676
+ return;
19677
+ }
19374
19678
  const selectedProviderId = instance.getSelectedProviderId() || "builtin";
19375
19679
  const catalogProvider = instance.Profiles.getProviderById(
19376
19680
  instance.catalog,
@@ -19453,6 +19757,12 @@ ${block}`;
19453
19757
  }))
19454
19758
  });
19455
19759
  }
19760
+ function requireCurrentProject(instance) {
19761
+ if (!instance.hasCurrentProject()) throw createClientError(
19762
+ "provider_project_required",
19763
+ instance.tx("Open an Overleaf project before selecting its provider.", "\u8BF7\u5148\u8FDB\u5165 Overleaf \u9879\u76EE\uFF0C\u518D\u9009\u62E9\u8BE5\u9879\u76EE\u4F7F\u7528\u7684\u6A21\u578B\u670D\u52A1\u3002")
19764
+ );
19765
+ }
19456
19766
  function emptyCatalogChange() {
19457
19767
  return { activeProviderChanged: false, activeModelCatalogChanged: false, changedProviderIds: [] };
19458
19768
  }
@@ -19509,7 +19819,7 @@ ${block}`;
19509
19819
  window.CodexOverleafProviderSettingsCoordinator = { create };
19510
19820
  })();
19511
19821
  }).call(globalThis, void 0, void 0, void 0);
19512
- (function runClassicContentModule58(module, exports, require2) {
19822
+ (function runClassicContentModule60(module, exports, require2) {
19513
19823
  (function initCodexOverleafSessionPersistence(root, factory) {
19514
19824
  if (typeof module === "object" && module.exports) {
19515
19825
  module.exports = factory(require2("../shared/storageMigration"));
@@ -19603,7 +19913,7 @@ ${block}`;
19603
19913
  };
19604
19914
  });
19605
19915
  }).call(globalThis, void 0, void 0, void 0);
19606
- (function runClassicContentModule59(module, exports, require2) {
19916
+ (function runClassicContentModule61(module, exports, require2) {
19607
19917
  (function(root, factory) {
19608
19918
  var api = factory();
19609
19919
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19707,7 +20017,7 @@ ${block}`;
19707
20017
  return Object.freeze({ persistPanelState });
19708
20018
  });
19709
20019
  }).call(globalThis, void 0, void 0, void 0);
19710
- (function runClassicContentModule60(module, exports, require2) {
20020
+ (function runClassicContentModule62(module, exports, require2) {
19711
20021
  (function(root, factory) {
19712
20022
  var api = factory();
19713
20023
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19752,7 +20062,7 @@ ${block}`;
19752
20062
  return Object.freeze({ create });
19753
20063
  });
19754
20064
  }).call(globalThis, void 0, void 0, void 0);
19755
- (function runClassicContentModule61(module, exports, require2) {
20065
+ (function runClassicContentModule63(module, exports, require2) {
19756
20066
  (function(root, factory) {
19757
20067
  if (typeof module === "object" && module.exports) {
19758
20068
  module.exports = factory(
@@ -19847,7 +20157,7 @@ ${block}`;
19847
20157
  });
19848
20158
  });
19849
20159
  }).call(globalThis, void 0, void 0, void 0);
19850
- (function runClassicContentModule62(module, exports, require2) {
20160
+ (function runClassicContentModule64(module, exports, require2) {
19851
20161
  (function initCodexOverleafDiagnosticsPanel() {
19852
20162
  "use strict";
19853
20163
  function create(options2 = {}) {
@@ -20275,7 +20585,7 @@ ${block}`;
20275
20585
  };
20276
20586
  })();
20277
20587
  }).call(globalThis, void 0, void 0, void 0);
20278
- (function runClassicContentModule63(module, exports, require2) {
20588
+ (function runClassicContentModule65(module, exports, require2) {
20279
20589
  (function initCodexOverleafRunQueueScheduler(root, factory) {
20280
20590
  if (typeof module === "object" && module.exports) {
20281
20591
  module.exports = factory(require2("../shared/runInputQueue"));
@@ -20603,7 +20913,7 @@ ${block}`;
20603
20913
  return { create, createCoordinator };
20604
20914
  });
20605
20915
  }).call(globalThis, void 0, void 0, void 0);
20606
- (function runClassicContentModule64(module, exports, require2) {
20916
+ (function runClassicContentModule66(module, exports, require2) {
20607
20917
  (function initCodexOverleafActiveTurnControl(root, factory) {
20608
20918
  if (typeof module === "object" && module.exports) {
20609
20919
  module.exports = factory();
@@ -20772,7 +21082,7 @@ ${block}`;
20772
21082
  return { create };
20773
21083
  });
20774
21084
  }).call(globalThis, void 0, void 0, void 0);
20775
- (function runClassicContentModule65(module, exports, require2) {
21085
+ (function runClassicContentModule67(module, exports, require2) {
20776
21086
  (function initCodexOverleafPendingInputView(root, factory) {
20777
21087
  if (typeof module === "object" && module.exports) {
20778
21088
  module.exports = factory();
@@ -20874,7 +21184,7 @@ ${block}`;
20874
21184
  return { create };
20875
21185
  });
20876
21186
  }).call(globalThis, void 0, void 0, void 0);
20877
- (function runClassicContentModule66(module, exports, require2) {
21187
+ (function runClassicContentModule68(module, exports, require2) {
20878
21188
  (function initCodexOverleafComposerPanel() {
20879
21189
  "use strict";
20880
21190
  function create(options2 = {}) {
@@ -20985,7 +21295,7 @@ ${block}`;
20985
21295
  </span>
20986
21296
  </div>
20987
21297
  <div class="codex-context-selection" data-context-selection></div>
20988
- <div class="codex-context-status" data-context-status>Type @ to add context: @file, @compile-log, @current-section.</div>
21298
+ <div class="codex-context-status" data-context-status>Type @ to choose files or add @compile-log. Name the section you want in your request.</div>
20989
21299
  <div class="codex-context-files" data-context-file-list></div>
20990
21300
  </div>
20991
21301
  </form>
@@ -21133,7 +21443,7 @@ ${block}`;
21133
21443
  };
21134
21444
  })();
21135
21445
  }).call(globalThis, void 0, void 0, void 0);
21136
- (function runClassicContentModule67(module, exports, require2) {
21446
+ (function runClassicContentModule69(module, exports, require2) {
21137
21447
  (function initCodexOverleafTheme(root, factory) {
21138
21448
  if (typeof module === "object" && module.exports) {
21139
21449
  module.exports = factory();
@@ -21167,6 +21477,9 @@ ${block}`;
21167
21477
  const resolved = resolveTheme(preference, mediaQueryList);
21168
21478
  if (panelRoot && typeof panelRoot.setAttribute === "function") {
21169
21479
  panelRoot.setAttribute("data-theme", resolved);
21480
+ for (const target of panelRoot.ownerDocument?.querySelectorAll?.(".codex-provider-dialog-root, #codex-overleaf-launcher") || []) {
21481
+ target.setAttribute("data-theme", resolved);
21482
+ }
21170
21483
  }
21171
21484
  return resolved;
21172
21485
  }
@@ -21201,7 +21514,7 @@ ${block}`;
21201
21514
  };
21202
21515
  });
21203
21516
  }).call(globalThis, void 0, void 0, void 0);
21204
- (function runClassicContentModule68(module, exports, require2) {
21517
+ (function runClassicContentModule70(module, exports, require2) {
21205
21518
  !(function(e, t) {
21206
21519
  "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.katex = t() : e.katex = t();
21207
21520
  })("undefined" != typeof self ? self : this, function() {
@@ -24621,7 +24934,7 @@ ${block}`;
24621
24934
  })();
24622
24935
  });
24623
24936
  }).call(globalThis, void 0, void 0, void 0);
24624
- (function runClassicContentModule69(module, exports, require2) {
24937
+ (function runClassicContentModule71(module, exports, require2) {
24625
24938
  !(function(t, e) {
24626
24939
  "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).markdownit = e();
24627
24940
  })(this, function() {
@@ -26693,7 +27006,7 @@ ${block}`;
26693
27006
  }, Ke;
26694
27007
  });
26695
27008
  }).call(globalThis, void 0, void 0, void 0);
26696
- (function runClassicContentModule70(module, exports, require2) {
27009
+ (function runClassicContentModule72(module, exports, require2) {
26697
27010
  (function initCodexOverleafMathText(root) {
26698
27011
  "use strict";
26699
27012
  const DELIMITERS = Object.freeze([
@@ -27078,7 +27391,7 @@ ${block}`;
27078
27391
  }
27079
27392
  })(typeof window !== "undefined" ? window : globalThis);
27080
27393
  }).call(globalThis, void 0, void 0, void 0);
27081
- (function runClassicContentModule71(module, exports, require2) {
27394
+ (function runClassicContentModule73(module, exports, require2) {
27082
27395
  (function initCodexOverleafMarkdownDomRenderer(root, factory) {
27083
27396
  const api = factory();
27084
27397
  if (typeof module === "object" && module.exports) {
@@ -27566,7 +27879,7 @@ ${block}`;
27566
27879
  };
27567
27880
  });
27568
27881
  }).call(globalThis, void 0, void 0, void 0);
27569
- (function runClassicContentModule72(module, exports, require2) {
27882
+ (function runClassicContentModule74(module, exports, require2) {
27570
27883
  (function initCodexOverleafMarkdownText() {
27571
27884
  "use strict";
27572
27885
  function create(deps = {}) {
@@ -28193,7 +28506,7 @@ ${block}`;
28193
28506
  window.CodexOverleafMarkdownText = { create };
28194
28507
  })();
28195
28508
  }).call(globalThis, void 0, void 0, void 0);
28196
- (function runClassicContentModule73(module, exports, require2) {
28509
+ (function runClassicContentModule75(module, exports, require2) {
28197
28510
  (function initCodexOverleafDiagnosticsController() {
28198
28511
  "use strict";
28199
28512
  function create(deps = {}) {
@@ -28762,7 +29075,7 @@ ${block}`;
28762
29075
  window.CodexOverleafDiagnosticsController = { create };
28763
29076
  })();
28764
29077
  }).call(globalThis, void 0, void 0, void 0);
28765
- (function runClassicContentModule74(module, exports, require2) {
29078
+ (function runClassicContentModule76(module, exports, require2) {
28766
29079
  (function initCodexOverleafRunGuidanceView() {
28767
29080
  "use strict";
28768
29081
  const LEGACY_GUIDANCE_TITLES = /* @__PURE__ */ new Set([
@@ -28802,7 +29115,7 @@ ${block}`;
28802
29115
  };
28803
29116
  })();
28804
29117
  }).call(globalThis, void 0, void 0, void 0);
28805
- (function runClassicContentModule75(module, exports, require2) {
29118
+ (function runClassicContentModule77(module, exports, require2) {
28806
29119
  (function initCodexOverleafRunGuidanceController() {
28807
29120
  "use strict";
28808
29121
  function create(deps = {}) {
@@ -28865,7 +29178,7 @@ ${block}`;
28865
29178
  window.CodexOverleafRunGuidanceController = { create };
28866
29179
  })();
28867
29180
  }).call(globalThis, void 0, void 0, void 0);
28868
- (function runClassicContentModule76(module, exports, require2) {
29181
+ (function runClassicContentModule78(module, exports, require2) {
28869
29182
  (function initCodexOverleafRunResultActions(root, factory) {
28870
29183
  const api = factory();
28871
29184
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -28970,7 +29283,7 @@ ${block}`;
28970
29283
  return Object.freeze({ create });
28971
29284
  });
28972
29285
  }).call(globalThis, void 0, void 0, void 0);
28973
- (function runClassicContentModule77(module, exports, require2) {
29286
+ (function runClassicContentModule79(module, exports, require2) {
28974
29287
  (function initCodexOverleafRunTimelineView() {
28975
29288
  "use strict";
28976
29289
  function create(deps = {}) {
@@ -29942,7 +30255,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29942
30255
  window.CodexOverleafRunTimelineView = { create };
29943
30256
  })();
29944
30257
  }).call(globalThis, void 0, void 0, void 0);
29945
- (function runClassicContentModule78(module, exports, require2) {
30258
+ (function runClassicContentModule80(module, exports, require2) {
29946
30259
  (function initCodexOverleafProjectSettingsCoordinator() {
29947
30260
  "use strict";
29948
30261
  function create(deps = {}) {
@@ -30205,6 +30518,8 @@ ${conclusion}` : `${label} ${conclusion}`;
30205
30518
  });
30206
30519
  saveStateSoon();
30207
30520
  renderLocalSkillList();
30521
+ deps.updateGlobalPreferences?.({ codexOverleafSkillEnabled: { [skillId]: Boolean(enabled) } })?.catch(() => {
30522
+ });
30208
30523
  }
30209
30524
  function readSkillLoadingSettingsFromSettings() {
30210
30525
  return SettingsPanel.readState(getSettingsPanelInstance()).skillToggles;
@@ -30269,7 +30584,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30269
30584
  window.CodexOverleafProjectSettingsCoordinator = { create };
30270
30585
  })();
30271
30586
  }).call(globalThis, void 0, void 0, void 0);
30272
- (function runClassicContentModule79(module, exports, require2) {
30587
+ (function runClassicContentModule81(module, exports, require2) {
30273
30588
  (function initCodexOverleafSessionMenuView() {
30274
30589
  "use strict";
30275
30590
  function create(deps = {}) {
@@ -30474,7 +30789,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30474
30789
  window.CodexOverleafSessionMenuView = { create };
30475
30790
  })();
30476
30791
  }).call(globalThis, void 0, void 0, void 0);
30477
- (function runClassicContentModule80(module, exports, require2) {
30792
+ (function runClassicContentModule82(module, exports, require2) {
30478
30793
  (function initCodexOverleafSessionManager() {
30479
30794
  "use strict";
30480
30795
  function create(deps = {}) {
@@ -30733,7 +31048,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30733
31048
  window.CodexOverleafSessionManager = { create };
30734
31049
  })();
30735
31050
  }).call(globalThis, void 0, void 0, void 0);
30736
- (function runClassicContentModule81(module, exports, require2) {
31051
+ (function runClassicContentModule83(module, exports, require2) {
30737
31052
  (function initCodexOverleafSessionForkController(root, factory) {
30738
31053
  const api = factory();
30739
31054
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -30862,7 +31177,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30862
31177
  return { copyRunSnapshot, create };
30863
31178
  });
30864
31179
  }).call(globalThis, void 0, void 0, void 0);
30865
- (function runClassicContentModule82(module, exports, require2) {
31180
+ (function runClassicContentModule84(module, exports, require2) {
30866
31181
  (function initCodexOverleafApplyResultFormatters() {
30867
31182
  "use strict";
30868
31183
  function create(deps = {}) {
@@ -31182,7 +31497,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31182
31497
  window.CodexOverleafApplyResultFormatters = { create };
31183
31498
  })();
31184
31499
  }).call(globalThis, void 0, void 0, void 0);
31185
- (function runClassicContentModule83(module, exports, require2) {
31500
+ (function runClassicContentModule85(module, exports, require2) {
31186
31501
  (function initCodexOverleafModelPickerSupport(root, factory) {
31187
31502
  if (typeof module === "object" && module.exports) {
31188
31503
  module.exports = factory(require2("../shared/models"));
@@ -31283,7 +31598,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31283
31598
  return api;
31284
31599
  });
31285
31600
  }).call(globalThis, void 0, void 0, void 0);
31286
- (function runClassicContentModule84(module, exports, require2) {
31601
+ (function runClassicContentModule86(module, exports, require2) {
31287
31602
  (function initCodexOverleafModelPicker() {
31288
31603
  "use strict";
31289
31604
  function create(deps = {}) {
@@ -31761,7 +32076,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31761
32076
  window.CodexOverleafModelPicker = { create };
31762
32077
  })();
31763
32078
  }).call(globalThis, void 0, void 0, void 0);
31764
- (function runClassicContentModule85(module, exports, require2) {
32079
+ (function runClassicContentModule87(module, exports, require2) {
31765
32080
  (function initCodexOverleafProjectSessionCleanup() {
31766
32081
  "use strict";
31767
32082
  const FRESH_RUNNING_WINDOW_MS = 30 * 60 * 1e3;
@@ -31861,7 +32176,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31861
32176
  window.CodexOverleafProjectSessionCleanup = { create };
31862
32177
  })();
31863
32178
  }).call(globalThis, void 0, void 0, void 0);
31864
- (function runClassicContentModule86(module, exports, require2) {
32179
+ (function runClassicContentModule88(module, exports, require2) {
31865
32180
  (function initCodexOverleafRecentProjects() {
31866
32181
  "use strict";
31867
32182
  function create(deps = {}) {
@@ -32787,7 +33102,7 @@ ${conclusion}` : `${label} ${conclusion}`;
32787
33102
  window.CodexOverleafRecentProjects = { create };
32788
33103
  })();
32789
33104
  }).call(globalThis, void 0, void 0, void 0);
32790
- (function runClassicContentModule87(module, exports, require2) {
33105
+ (function runClassicContentModule89(module, exports, require2) {
32791
33106
  (function initCodexOverleafOtWarmMirror() {
32792
33107
  "use strict";
32793
33108
  function create(deps = {}) {
@@ -33642,7 +33957,7 @@ ${conclusion}` : `${label} ${conclusion}`;
33642
33957
  window.CodexOverleafOtWarmMirror = { create };
33643
33958
  })();
33644
33959
  }).call(globalThis, void 0, void 0, void 0);
33645
- (function runClassicContentModule88(module, exports, require2) {
33960
+ (function runClassicContentModule90(module, exports, require2) {
33646
33961
  (function initCodexOverleafWritebackOrchestrator() {
33647
33962
  "use strict";
33648
33963
  let tr;
@@ -34398,7 +34713,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34398
34713
  window.CodexOverleafWritebackOrchestrator = { create };
34399
34714
  })();
34400
34715
  }).call(globalThis, void 0, void 0, void 0);
34401
- (function runClassicContentModule89(module, exports, require2) {
34716
+ (function runClassicContentModule91(module, exports, require2) {
34402
34717
  (function initCodexOverleafRunSettlementPersistence(root, factory) {
34403
34718
  const api = factory();
34404
34719
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -34441,7 +34756,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34441
34756
  return Object.freeze({ create });
34442
34757
  });
34443
34758
  }).call(globalThis, void 0, void 0, void 0);
34444
- (function runClassicContentModule90(module, exports, require2) {
34759
+ (function runClassicContentModule92(module, exports, require2) {
34445
34760
  (function initPostNavigationSettlementPersistence(root, factory) {
34446
34761
  const api = factory();
34447
34762
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -34533,7 +34848,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34533
34848
  return Object.freeze({ persist, persistRequired });
34534
34849
  });
34535
34850
  }).call(globalThis, void 0, void 0, void 0);
34536
- (function runClassicContentModule91(module, exports, require2) {
34851
+ (function runClassicContentModule93(module, exports, require2) {
34537
34852
  (function initCodexOverleafPanelMaintenance() {
34538
34853
  "use strict";
34539
34854
  function create(deps = {}) {
@@ -34851,7 +35166,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34851
35166
  window.CodexOverleafPanelMaintenance = { create };
34852
35167
  })();
34853
35168
  }).call(globalThis, void 0, void 0, void 0);
34854
- (function runClassicContentModule92(module, exports, require2) {
35169
+ (function runClassicContentModule94(module, exports, require2) {
34855
35170
  (function initCodexOverleafUpdateIdle(root) {
34856
35171
  "use strict";
34857
35172
  function create(options2 = {}) {
@@ -34919,7 +35234,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34919
35234
  root.CodexOverleafUpdateIdle = Object.freeze({ create });
34920
35235
  })(typeof window !== "undefined" ? window : globalThis);
34921
35236
  }).call(globalThis, void 0, void 0, void 0);
34922
- (function runClassicContentModule93(module, exports, require2) {
35237
+ (function runClassicContentModule95(module, exports, require2) {
34923
35238
  (function initCodexOverleafUpdateNotice(root, factory) {
34924
35239
  if (typeof module === "object" && module.exports) {
34925
35240
  module.exports = factory(require2("../shared/managedUpdateProjection"));
@@ -35363,7 +35678,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35363
35678
  return Object.freeze({ mount });
35364
35679
  });
35365
35680
  }).call(globalThis, void 0, void 0, void 0);
35366
- (function runClassicContentModule94(module, exports, require2) {
35681
+ (function runClassicContentModule96(module, exports, require2) {
35367
35682
  (function initCodexOverleafContentRuntime(root) {
35368
35683
  "use strict";
35369
35684
  function init(dependencies2) {
@@ -35556,6 +35871,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35556
35871
  renderAuditHistoryPanel: () => renderAuditHistoryPanel(),
35557
35872
  renderRecentProjectsVariant: (...args) => renderRecentProjectsVariant(...args),
35558
35873
  saveStateSoon: () => saveStateSoon(),
35874
+ updateGlobalPreferences: (patch) => getGlobalPreferences().update(patch),
35559
35875
  setState: (next) => {
35560
35876
  state = next;
35561
35877
  },
@@ -35997,6 +36313,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35997
36313
  const providerSettingsCoordinator = Modules.ProviderSettingsCoordinator.create({
35998
36314
  ProviderProfiles: Modules.ProviderProfiles,
35999
36315
  ProviderSettingsDialog: Modules.ProviderSettingsDialog,
36316
+ hasCurrentProject: () => Boolean(getCurrentProjectId()),
36000
36317
  tx,
36001
36318
  sendBackgroundNative,
36002
36319
  document,
@@ -36163,6 +36480,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36163
36480
  let composerPanelInstance = null;
36164
36481
  let state = null;
36165
36482
  let storageKey = LEGACY_STORAGE_KEY;
36483
+ let globalPreferencesController = null;
36166
36484
  let currentRunView = null;
36167
36485
  let pendingRetryReplacement = null;
36168
36486
  let runQueueScheduler = null;
@@ -36290,9 +36608,10 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36290
36608
  throw error;
36291
36609
  });
36292
36610
  async function init2() {
36611
+ await getGlobalPreferences().initialize();
36293
36612
  await refreshAccountScopeId();
36294
36613
  storageKey = getProjectStorageKey(LEGACY_STORAGE_KEY, window.location.href);
36295
- state = normalizePanelState(await loadStoredState(), { restoreRunningRuns: true });
36614
+ state = normalizePanelState(getGlobalPreferences().overlay(await loadStoredState()), { restoreRunningRuns: true });
36296
36615
  initializeRunQueueScheduler();
36297
36616
  recoverInterruptedRunJournals().then(() => applyStateToPanel()).catch(() => {
36298
36617
  });
@@ -36308,6 +36627,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36308
36627
  recentProjects.mountDashboardShell();
36309
36628
  }
36310
36629
  applyStateToPanel();
36630
+ getGlobalPreferences().refreshView();
36311
36631
  if (isProjectEditorRoute(window.location)) {
36312
36632
  activeProjectId = window.location.pathname.match(/^\/project\/([^/?#]+)/)[1];
36313
36633
  }
@@ -36543,7 +36863,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36543
36863
  button: panel.querySelector("[data-custom-instructions-settings]"),
36544
36864
  callbacks: {
36545
36865
  onBack: () => closeCustomInstructionsSettings(),
36546
- onInputChange: () => persistPanelInputs(),
36866
+ onInputChange: (event) => persistPanelInputs(event),
36547
36867
  onSkillsOpen: () => openSkillsView(),
36548
36868
  onSkillsBack: () => closeSkillsView(),
36549
36869
  onProvidersOpen: () => providerSettingsCoordinator.open(),
@@ -39128,11 +39448,36 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39128
39448
  });
39129
39449
  return scopedPersistenceCoordinator;
39130
39450
  }
39451
+ function getGlobalPreferences() {
39452
+ if (!globalPreferencesController) globalPreferencesController = Modules.GlobalPreferencesController.create({
39453
+ chromeApi: chrome,
39454
+ getState: () => state,
39455
+ setState: (next) => {
39456
+ state = next;
39457
+ },
39458
+ getPanel: () => panel,
39459
+ applyTheme: applyPanelTheme,
39460
+ applyLocale: () => {
39461
+ applyLocaleToPanel();
39462
+ refreshDashboardSoon();
39463
+ },
39464
+ onPreloadChange: (enabled) => contextTrayController.scheduleContextPrefetch({ enabled }),
39465
+ onSkillsChange: () => {
39466
+ renderLocalSkillList();
39467
+ updateSkillsEntrySummary();
39468
+ },
39469
+ onError: (error) => showPluginToast(tx(
39470
+ `Global settings could not be saved or loaded: ${error.message}. Please retry.`,
39471
+ `\u5168\u5C40\u8BBE\u7F6E\u672A\u80FD\u4FDD\u5B58\u6216\u8BFB\u53D6\uFF1A${error.message}\u3002\u8BF7\u91CD\u8BD5\u3002`
39472
+ ), { status: "failed", sticky: true })
39473
+ });
39474
+ return globalPreferencesController;
39475
+ }
39131
39476
  async function reloadProjectRunHistory(newProjectId) {
39132
39477
  try {
39133
39478
  storageKey = getProjectStorageKey(LEGACY_STORAGE_KEY, window.location.href);
39134
39479
  const reloaded = await loadStoredState();
39135
- state = normalizePanelState(reloaded, { restoreRunningRuns: true });
39480
+ state = normalizePanelState(getGlobalPreferences().overlay(reloaded), { restoreRunningRuns: true });
39136
39481
  applyStateToPanel();
39137
39482
  } catch (_error) {
39138
39483
  }
@@ -39732,8 +40077,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39732
40077
  function formatContextItems(focusFiles = []) {
39733
40078
  const fileItems = (focusFiles || []).map((path) => `@file:${path}`);
39734
40079
  return fileItems.length ? fileItems.join(", ") : tx(
39735
- "@whole-project (default); add @file, @compile-log, or @current-section",
39736
- "@whole-project\uFF08\u9ED8\u8BA4\uFF09\uFF1B\u53EF\u6DFB\u52A0 @file\u3001@compile-log\u3001@current-section"
40080
+ "@whole-project (default); choose files or add @compile-log",
40081
+ "@whole-project\uFF08\u9ED8\u8BA4\uFF09\uFF1B\u53EF\u9009\u62E9\u6587\u4EF6\u6216\u6DFB\u52A0 @compile-log"
39737
40082
  );
39738
40083
  }
39739
40084
  function appendProbeUserStatus(probe) {
@@ -40404,6 +40749,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40404
40749
  return error?.message || String(error);
40405
40750
  }
40406
40751
  async function persistPanelInputs(event) {
40752
+ const globalWrite = getGlobalPreferences().handleInput(event);
40753
+ if (globalWrite) return globalWrite;
40407
40754
  if (event?.type === "input" && event?.target?.matches?.("[data-task]")) {
40408
40755
  readPanelInputs();
40409
40756
  saveStateSoon();
@@ -40486,23 +40833,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40486
40833
  setCustomInstructionsForProject(projectId, customInstructionsInput.value);
40487
40834
  }
40488
40835
  setGovernanceRulesForCurrentProject(readGovernanceRulesFromSettings());
40489
- const newSettings = readSkillLoadingSettingsFromSettings();
40490
- const prevOverleafSkills = getSkillLoadingSettings().loadCodexOverleafSkills;
40491
- setSkillLoadingSettings(newSettings);
40492
- const themePref = panel?.querySelector("[data-theme-select]")?.value || "dark";
40493
- if (state) {
40494
- state.theme = themePref;
40495
- }
40496
- applyPanelTheme(themePref);
40497
- const languagePref = panel?.querySelector("[data-language-select]")?.value;
40498
- if (languagePref && state && languagePref !== getLocale()) {
40499
- state.locale = i18n?.normalizeLocale?.(languagePref) || languagePref;
40500
- applyLocaleToPanel();
40501
- }
40502
- if (prevOverleafSkills !== getSkillLoadingSettings().loadCodexOverleafSkills) {
40503
- renderLocalSkillList();
40504
- }
40505
- updateSkillsEntrySummary();
40506
40836
  }
40507
40837
  }
40508
40838
  function readSelectedModelInput() {
@@ -42172,7 +42502,7 @@ Reason: ${item.reason || "No reason provided"}`),
42172
42502
  root.CodexOverleafContentRuntime = { init };
42173
42503
  })(typeof window !== "undefined" ? window : globalThis);
42174
42504
  }).call(globalThis, void 0, void 0, void 0);
42175
- (function runClassicContentModule95(module, exports, require2) {
42505
+ (function runClassicContentModule97(module, exports, require2) {
42176
42506
  (function initCodexOverleafLegacyGlobalRegistry(root, factory) {
42177
42507
  "use strict";
42178
42508
  const api = factory();
@@ -42200,6 +42530,8 @@ Reason: ${item.reason || "No reason provided"}`),
42200
42530
  "DiffReviewPanel",
42201
42531
  "FailureReasons",
42202
42532
  "GovernanceRules",
42533
+ "GlobalPreferences",
42534
+ "GlobalPreferencesController",
42203
42535
  "I18n",
42204
42536
  "LineReferences",
42205
42537
  "LocalSkillsPanel",