codex-overleaf-link 2.3.3 → 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.3";
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();
@@ -16058,18 +16327,46 @@ ${block}`;
16058
16327
  function defaultIsUsableProjectFileContent(content) {
16059
16328
  return String(content || "").trim().length > 0;
16060
16329
  }
16330
+ function isRetryReplacementEligible(run = {}, projection = {}) {
16331
+ if (!run.id || !["failed", "interrupted"].includes(run.status)) return false;
16332
+ if (run.trackedChangeStatus || run.undoStatus) return false;
16333
+ if (["undoOperations", "undoTrackedChanges", "undoExpectedFiles", "undoBaseFiles", "appliedOperations"].some((field) => Array.isArray(run[field]) && run[field].length)) return false;
16334
+ if (projection.canAccept || projection.canUndo || projection.changedDocument === true) return false;
16335
+ if (projection.failureTerminalState === "needs_review" || projection.terminalState === "needs_review") return false;
16336
+ return projection.changedDocument === false || run.mode === "ask" || hasZeroWriteReport(run.events);
16337
+ }
16338
+ function hasZeroWriteReport(events = []) {
16339
+ return (Array.isArray(events) ? events : []).some((event) => {
16340
+ const rows = Array.isArray(event?.detailStructured?.meta) ? event.detailStructured.meta : [];
16341
+ return rows.some((row) => row?.key === "writeResult" && /(?:wrote|写入)\s*0\b[\s\S]*(?:skipped|跳过)\s*0\b/i.test(String(row.value || "")));
16342
+ });
16343
+ }
16344
+ function resolveRetryReplacement({ candidate, activeSessionId, runs, projectRunSettlement } = {}) {
16345
+ if (!candidate?.runId || candidate.sessionId !== activeSessionId) return "";
16346
+ const source = (Array.isArray(runs) ? runs : []).find((run) => run?.id === candidate.runId);
16347
+ if (!source) return "";
16348
+ const projection = typeof projectRunSettlement === "function" ? projectRunSettlement(source) : {};
16349
+ return isRetryReplacementEligible(source, projection) ? source.id : "";
16350
+ }
16351
+ function replaceRunForRetry(runs, sourceRunId, nextRun, maxRuns = 20) {
16352
+ const retained = (Array.isArray(runs) ? runs : []).filter((run) => !sourceRunId || run?.id !== sourceRunId);
16353
+ return [...retained, nextRun].slice(-Math.max(1, maxRuns));
16354
+ }
16061
16355
  return {
16062
16356
  buildCodexRunParams,
16063
16357
  canUseFocusedPartialSnapshot,
16064
16358
  shouldRestrictWritebackToFocus,
16065
16359
  buildSessionHistoryResult,
16360
+ isRetryReplacementEligible,
16361
+ replaceRunForRetry,
16362
+ resolveRetryReplacement,
16066
16363
  truncateSessionHistoryText,
16067
16364
  normalizeComposerAttachments,
16068
16365
  normalizeSkillInvocation
16069
16366
  };
16070
16367
  });
16071
16368
  }).call(globalThis, void 0, void 0, void 0);
16072
- (function runClassicContentModule49(module, exports, require2) {
16369
+ (function runClassicContentModule51(module, exports, require2) {
16073
16370
  (function initCodexOverleafMirrorHealth(root, factory) {
16074
16371
  if (typeof module === "object" && module.exports) {
16075
16372
  module.exports = factory();
@@ -16153,7 +16450,7 @@ ${block}`;
16153
16450
  };
16154
16451
  });
16155
16452
  }).call(globalThis, void 0, void 0, void 0);
16156
- (function runClassicContentModule50(module, exports, require2) {
16453
+ (function runClassicContentModule52(module, exports, require2) {
16157
16454
  (function initCodexOverleafOtWarmMirrorController(root, factory) {
16158
16455
  if (typeof module === "object" && module.exports) {
16159
16456
  module.exports = factory();
@@ -16306,7 +16603,7 @@ ${block}`;
16306
16603
  };
16307
16604
  });
16308
16605
  }).call(globalThis, void 0, void 0, void 0);
16309
- (function runClassicContentModule51(module, exports, require2) {
16606
+ (function runClassicContentModule53(module, exports, require2) {
16310
16607
  (function initComposerAttachments(global) {
16311
16608
  "use strict";
16312
16609
  function createComposerAttachmentController(options2 = {}) {
@@ -16766,16 +17063,19 @@ ${block}`;
16766
17063
  };
16767
17064
  })(window);
16768
17065
  }).call(globalThis, void 0, void 0, void 0);
16769
- (function runClassicContentModule52(module, exports, require2) {
17066
+ (function runClassicContentModule54(module, exports, require2) {
16770
17067
  (function initCodexOverleafPanelRenderer() {
16771
17068
  "use strict";
16772
17069
  const ROOT_CLASS = "codex-overleaf-panel-mounted";
16773
17070
  const RESIZE_CLASS = "codex-overleaf-panel-resizing";
16774
17071
  const COMPACT_CLASS = "codex-overleaf-panel-compact";
17072
+ const LAUNCHER_VISIBILITY_STORAGE_KEY = "codex-overleaf:launcher-visible";
16775
17073
  function codexIcon(name) {
16776
17074
  const icons = {
16777
17075
  refresh: '<path d="M4.2 5.3A5 5 0 1 1 3.6 10"/><path d="M4.2 2.2v3.1H1.1"/>',
16778
17076
  plus: '<path d="M8 3.2v9.6"/><path d="M3.2 8h9.6"/>',
17077
+ panel: '<rect x="2.3" y="2.3" width="11.4" height="11.4" rx="2"/><path d="M9.2 2.5v11"/><path d="M5.1 6.1h1.5M5.1 8h1.5M5.1 9.9h1.5"/>',
17078
+ collapse: '<path d="m6.1 3.3 4.7 4.7-4.7 4.7"/>',
16779
17079
  settings: '<path d="M3.4 5.2h5.9"/><path d="M11.7 5.2h.9"/><path d="M10.1 3.6v3.2"/><path d="M3.4 10.8h1"/><path d="M6.8 10.8h5.8"/><path d="M5.9 9.2v3.2"/>'
16780
17080
  };
16781
17081
  const safeName = Object.prototype.hasOwnProperty.call(icons, name) ? name : "settings";
@@ -16785,9 +17085,11 @@ ${block}`;
16785
17085
  const doc = options2.document || document;
16786
17086
  const container = options2.container || doc.documentElement;
16787
17087
  const panelEl = doc.createElement("aside");
17088
+ const launcherEl = doc.createElement("button");
16788
17089
  const callbacks = options2.callbacks || {};
16789
17090
  const instance = {
16790
17091
  panelEl,
17092
+ launcherEl,
16791
17093
  callbacks,
16792
17094
  defaultWidth: options2.defaultWidth || 380,
16793
17095
  minWidth: options2.minWidth || 340,
@@ -16796,8 +17098,16 @@ ${block}`;
16796
17098
  lastDesktopWidth: options2.initialWidth || options2.defaultWidth || 380,
16797
17099
  listeners: [],
16798
17100
  document: doc,
16799
- window: options2.window || window
17101
+ window: options2.window || window,
17102
+ chromeApi: options2.chromeApi || (typeof chrome !== "undefined" ? chrome : null),
17103
+ storageChangeListener: null
16800
17104
  };
17105
+ launcherEl.id = "codex-overleaf-launcher";
17106
+ launcherEl.type = "button";
17107
+ launcherEl.title = options2.launcherLabel || "Show or hide Codex panel";
17108
+ launcherEl.setAttribute("aria-label", launcherEl.title);
17109
+ launcherEl.setAttribute("aria-expanded", "false");
17110
+ launcherEl.innerHTML = codexIcon("panel");
16801
17111
  panelEl.id = options2.panelId || "codex-overleaf-panel";
16802
17112
  panelEl.dataset.view = "session";
16803
17113
  panelEl.innerHTML = `
@@ -16809,6 +17119,7 @@ ${block}`;
16809
17119
  <div data-diagnostics-slot></div>
16810
17120
  <button type="button" data-new-session title="New Session" aria-label="New Session">${codexIcon("plus")}</button>
16811
17121
  <button type="button" data-custom-instructions-settings title="Project Settings" aria-label="Project Settings" aria-expanded="false">${codexIcon("settings")}</button>
17122
+ <button type="button" data-close-panel title="Close Codex panel" aria-label="Close Codex panel">${codexIcon("collapse")}</button>
16812
17123
  </div>
16813
17124
  </div>
16814
17125
  <div data-settings-slot></div>
@@ -16823,6 +17134,7 @@ ${block}`;
16823
17134
  <div data-composer-slot></div>
16824
17135
  `;
16825
17136
  container.append(panelEl);
17137
+ container.append(launcherEl);
16826
17138
  doc.documentElement.classList.add(ROOT_CLASS);
16827
17139
  instance.headerEl = panelEl.querySelector("[data-panel-header]");
16828
17140
  instance.bodyEl = panelEl.querySelector("[data-main]");
@@ -16835,6 +17147,8 @@ ${block}`;
16835
17147
  bind(instance, panelEl.querySelector("[data-refresh]"), "click", () => callbacks.onRefresh?.());
16836
17148
  bind(instance, panelEl.querySelector("[data-new-session]"), "click", () => callbacks.onNewSession?.());
16837
17149
  bind(instance, panelEl.querySelector("[data-custom-instructions-settings]"), "click", () => callbacks.onSettingsClick?.());
17150
+ bind(instance, panelEl.querySelector("[data-close-panel]"), "click", () => callbacks.onClosePanel?.());
17151
+ bind(instance, launcherEl, "click", () => callbacks.onLauncherToggle?.());
16838
17152
  bind(instance, panelEl.querySelector("[data-panel-resize-handle]"), "pointerdown", (event) => startResize(instance, event));
16839
17153
  bind(instance, panelEl.querySelector("[data-panel-resize-handle]"), "dblclick", (event) => {
16840
17154
  event?.preventDefault?.();
@@ -16848,8 +17162,10 @@ ${block}`;
16848
17162
  setWidth(instance, instance.lastDesktopWidth || instance.defaultWidth, { notify: true, persist: false });
16849
17163
  });
16850
17164
  setWidth(instance, options2.initialWidth || instance.defaultWidth, { notify: false });
17165
+ initializeLauncherVisibility(instance);
16851
17166
  return {
16852
17167
  panelEl,
17168
+ launcherEl,
16853
17169
  headerEl: instance.headerEl,
16854
17170
  bodyEl: instance.bodyEl,
16855
17171
  diagnosticsSlot: instance.diagnosticsSlot,
@@ -16944,10 +17260,58 @@ ${block}`;
16944
17260
  function setVisible(panelEl, visible) {
16945
17261
  panelEl?.classList?.toggle("is-open", Boolean(visible));
16946
17262
  document.documentElement.classList.toggle(ROOT_CLASS, Boolean(visible));
17263
+ const launcherEl = panelEl?.ownerDocument?.getElementById?.("codex-overleaf-launcher");
17264
+ launcherEl?.classList?.toggle("is-panel-open", Boolean(visible));
17265
+ launcherEl?.setAttribute?.("aria-expanded", visible ? "true" : "false");
17266
+ if (launcherEl) {
17267
+ launcherEl.hidden = Boolean(visible) || launcherEl.dataset.enabled === "false";
17268
+ launcherEl.setAttribute("aria-hidden", launcherEl.hidden ? "true" : "false");
17269
+ }
16947
17270
  if (!visible) {
16948
17271
  document.documentElement.classList.remove(RESIZE_CLASS, COMPACT_CLASS);
16949
17272
  }
16950
17273
  }
17274
+ function initializeLauncherVisibility(instance) {
17275
+ const storage = instance.chromeApi?.storage;
17276
+ if (!storage?.local?.get) {
17277
+ setLauncherVisible(instance, true, { persist: false });
17278
+ return;
17279
+ }
17280
+ Promise.resolve(storage.local.get({ [LAUNCHER_VISIBILITY_STORAGE_KEY]: true })).then((values) => applyLauncherVisibility(instance, values?.[LAUNCHER_VISIBILITY_STORAGE_KEY])).catch(() => applyLauncherVisibility(instance, true));
17281
+ if (storage.onChanged?.addListener) {
17282
+ instance.storageChangeListener = (changes, areaName) => {
17283
+ if (areaName === "local" && changes?.[LAUNCHER_VISIBILITY_STORAGE_KEY]) {
17284
+ applyLauncherVisibility(instance, changes[LAUNCHER_VISIBILITY_STORAGE_KEY].newValue);
17285
+ }
17286
+ };
17287
+ storage.onChanged.addListener(instance.storageChangeListener);
17288
+ }
17289
+ }
17290
+ function applyLauncherVisibility(instance, value) {
17291
+ const visible = value !== false;
17292
+ setLauncherVisible(instance, visible, { persist: false });
17293
+ instance.callbacks.onLauncherVisibilityChange?.(visible);
17294
+ }
17295
+ function setLauncherVisible(target, visible, options2 = {}) {
17296
+ const instance = target?._instance || target;
17297
+ const launcherEl = instance?.launcherEl;
17298
+ if (!launcherEl) return false;
17299
+ const nextVisible = Boolean(visible);
17300
+ launcherEl.dataset.enabled = nextVisible ? "true" : "false";
17301
+ launcherEl.hidden = !nextVisible || instance.panelEl?.classList?.contains("is-open") === true;
17302
+ launcherEl.setAttribute("aria-hidden", launcherEl.hidden ? "true" : "false");
17303
+ if (options2.persist === true) {
17304
+ Promise.resolve(instance.chromeApi?.storage?.local?.set?.({
17305
+ [LAUNCHER_VISIBILITY_STORAGE_KEY]: nextVisible
17306
+ })).catch(() => {
17307
+ });
17308
+ }
17309
+ return nextVisible;
17310
+ }
17311
+ function isLauncherVisible(target) {
17312
+ const instance = target?._instance || target;
17313
+ return Boolean(instance?.launcherEl && instance.launcherEl.dataset.enabled !== "false");
17314
+ }
16951
17315
  function setBadge(headerEl, badge = {}) {
16952
17316
  const actions = headerEl?.querySelector?.(".codex-vscode-head-actions");
16953
17317
  if (!actions) {
@@ -16994,7 +17358,8 @@ ${block}`;
16994
17358
  const doc = panel.ownerDocument || document;
16995
17359
  return new Promise((resolve) => {
16996
17360
  let settled = false;
16997
- const overlay = doc.createElement("div");
17361
+ const returnFocus = doc.activeElement;
17362
+ const overlay = doc.createElement("dialog");
16998
17363
  overlay.className = "codex-plugin-confirm";
16999
17364
  overlay.setAttribute("data-plugin-confirm", "true");
17000
17365
  overlay.setAttribute("role", "dialog");
@@ -17036,12 +17401,15 @@ ${block}`;
17036
17401
  card.append(head, body, actions);
17037
17402
  overlay.append(card);
17038
17403
  panel.append(overlay);
17404
+ overlay.showModal?.();
17039
17405
  const cleanup = (value) => {
17040
17406
  if (settled) return;
17041
17407
  settled = true;
17042
17408
  activeResolve = null;
17043
17409
  doc.removeEventListener("keydown", onKeydown, true);
17410
+ overlay.close?.();
17044
17411
  overlay.remove();
17412
+ returnFocus?.focus?.();
17045
17413
  resolve(value);
17046
17414
  };
17047
17415
  activeResolve = cleanup;
@@ -17062,6 +17430,10 @@ ${block}`;
17062
17430
  overlay.addEventListener("click", (event) => {
17063
17431
  if (event.target === overlay) cleanup(false);
17064
17432
  });
17433
+ overlay.addEventListener("cancel", (event) => {
17434
+ event.preventDefault();
17435
+ cleanup(false);
17436
+ });
17065
17437
  cancel.addEventListener("click", () => cleanup(false));
17066
17438
  confirm.addEventListener("click", () => cleanup(true));
17067
17439
  doc.addEventListener("keydown", onKeydown, true);
@@ -17075,18 +17447,24 @@ ${block}`;
17075
17447
  target.removeEventListener?.(type, listener, options2);
17076
17448
  }
17077
17449
  instance.panelEl?.remove?.();
17450
+ instance.launcherEl?.remove?.();
17451
+ if (instance.storageChangeListener) {
17452
+ instance.chromeApi?.storage?.onChanged?.removeListener?.(instance.storageChangeListener);
17453
+ }
17078
17454
  instance.document.documentElement.classList.remove(ROOT_CLASS, RESIZE_CLASS, COMPACT_CLASS);
17079
17455
  }
17080
17456
  window.CodexOverleafPanelRenderer = {
17081
17457
  create,
17082
17458
  createConfirmController,
17083
17459
  setVisible,
17460
+ setLauncherVisible,
17461
+ isLauncherVisible,
17084
17462
  setBadge,
17085
17463
  setWidth
17086
17464
  };
17087
17465
  })();
17088
17466
  }).call(globalThis, void 0, void 0, void 0);
17089
- (function runClassicContentModule53(module, exports, require2) {
17467
+ (function runClassicContentModule55(module, exports, require2) {
17090
17468
  (function initCodexOverleafSessionPanel() {
17091
17469
  "use strict";
17092
17470
  function create(options2 = {}) {
@@ -17322,7 +17700,7 @@ ${block}`;
17322
17700
  };
17323
17701
  })();
17324
17702
  }).call(globalThis, void 0, void 0, void 0);
17325
- (function runClassicContentModule54(module, exports, require2) {
17703
+ (function runClassicContentModule56(module, exports, require2) {
17326
17704
  (function initCodexOverleafSettingsPanel() {
17327
17705
  "use strict";
17328
17706
  function codexIcon(name) {
@@ -17565,10 +17943,13 @@ ${block}`;
17565
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]"]) {
17566
17944
  const element = container.querySelector(selector);
17567
17945
  element?.addEventListener?.("change", (event) => {
17568
- instance.callbacks.onInputChange?.(event);
17569
- 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
+ });
17570
17952
  });
17571
- element?.addEventListener?.("input", (event) => instance.callbacks.onInputChange?.(event));
17572
17953
  }
17573
17954
  for (const selector of ["[data-governance-readonly-patterns]", "[data-governance-writable-patterns]"]) {
17574
17955
  const element = container.querySelector(selector);
@@ -17837,7 +18218,7 @@ ${block}`;
17837
18218
  };
17838
18219
  })();
17839
18220
  }).call(globalThis, void 0, void 0, void 0);
17840
- (function runClassicContentModule55(module, exports, require2) {
18221
+ (function runClassicContentModule57(module, exports, require2) {
17841
18222
  (function initCodexOverleafProviderSettingsDialog() {
17842
18223
  "use strict";
17843
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";
@@ -17883,12 +18264,13 @@ ${block}`;
17883
18264
  if (instance.root) {
17884
18265
  return instance.root;
17885
18266
  }
17886
- const root = instance.document.createElement("div");
18267
+ const root = instance.document.createElement("dialog");
17887
18268
  root.className = "codex-provider-dialog-root";
18269
+ root.setAttribute("aria-labelledby", "codex-provider-dialog-title");
17888
18270
  root.hidden = true;
17889
18271
  root.innerHTML = `
17890
18272
  <div class="codex-provider-dialog-backdrop" data-provider-backdrop></div>
17891
- <section class="codex-provider-dialog" role="dialog" aria-modal="true" aria-labelledby="codex-provider-dialog-title">
18273
+ <section class="codex-provider-dialog">
17892
18274
  <header class="codex-provider-dialog-head">
17893
18275
  <div class="codex-provider-dialog-heading">
17894
18276
  <div class="codex-provider-dialog-titleline">
@@ -17915,6 +18297,10 @@ ${block}`;
17915
18297
  root.addEventListener("input", (event) => handleInput(instance, event));
17916
18298
  root.addEventListener("change", (event) => handleInput(instance, event));
17917
18299
  root.addEventListener("keydown", (event) => handleKeydown(instance, event));
18300
+ root.addEventListener("cancel", (event) => {
18301
+ event.preventDefault();
18302
+ requestClose(instance);
18303
+ });
17918
18304
  root.addEventListener("mousedown", (event) => event.stopPropagation());
17919
18305
  root.addEventListener("click", (event) => event.stopPropagation());
17920
18306
  return root;
@@ -17924,8 +18310,11 @@ ${block}`;
17924
18310
  instance.root.hidden = false;
17925
18311
  syncTheme(instance);
17926
18312
  setCatalog(instance, catalog || instance.catalog);
18313
+ if (!instance.root.open) instance.root.showModal?.();
17927
18314
  queueMicrotask(() => {
17928
- 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?.();
17929
18318
  });
17930
18319
  }
17931
18320
  function requestClose(instance) {
@@ -17939,6 +18328,7 @@ ${block}`;
17939
18328
  instance.callbacks.onCancelTest?.();
17940
18329
  instance.busy = "";
17941
18330
  }
18331
+ instance.root.close?.();
17942
18332
  instance.root.hidden = true;
17943
18333
  instance.busy = "";
17944
18334
  instance.returnFocus?.focus?.();
@@ -17985,6 +18375,10 @@ ${block}`;
17985
18375
  "Configure experimental third-party integrations used by this project's future Codex runs. Compatibility varies by provider and gateway.",
17986
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"
17987
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
+ );
17988
18382
  renderProviderList(instance);
17989
18383
  renderDetail(instance);
17990
18384
  renderFooter(instance);
@@ -18217,8 +18611,8 @@ ${block}`;
18217
18611
  <label class="codex-provider-disclosure">
18218
18612
  <input type="checkbox" data-provider-disclosure ${disclosureSatisfied ? "checked" : ""}>
18219
18613
  <span data-provider-disclosure-text>${escapeHtml(tx(
18220
- `Future Codex runs in every Overleaf project tab may send selected project content to ${draft.baseUrl || "this endpoint"}.`,
18221
- `\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`
18222
18616
  ))}</span>
18223
18617
  </label>
18224
18618
  <div class="codex-provider-test-row">
@@ -18264,11 +18658,12 @@ ${block}`;
18264
18658
  "Uses the authentication, model catalog, and provider configuration managed by the local Codex CLI.",
18265
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"
18266
18660
  ))}</p>
18267
- ${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>`}
18268
18662
  </div>
18269
18663
  `;
18270
18664
  }
18271
18665
  function getCurrentProjectProviderId(instance) {
18666
+ if (instance.callbacks.hasCurrentProject?.() === false) return "";
18272
18667
  const providerId = instance.callbacks.getCurrentProjectProviderId?.();
18273
18668
  return typeof providerId === "string" && providerId.trim() ? providerId.trim() : "builtin";
18274
18669
  }
@@ -18289,6 +18684,7 @@ ${block}`;
18289
18684
  dirty: instance.dirty,
18290
18685
  destinationChanged,
18291
18686
  canSave: canSaveCurrentDraft(instance),
18687
+ hasProject: instance.callbacks.hasCurrentProject?.() !== false,
18292
18688
  canActivate: canActivateCurrentProvider(instance)
18293
18689
  });
18294
18690
  const saveDisabled = actionState.saveEnabled ? "" : ' disabled aria-disabled="true"';
@@ -18309,8 +18705,8 @@ ${block}`;
18309
18705
  const dirty = options2.dirty === true;
18310
18706
  return {
18311
18707
  showSave: isNew || dirty,
18312
- showSaveAndUse: (isNew || dirty) && (!active || options2.destinationChanged === true),
18313
- showUse: !isNew && !active && !dirty,
18708
+ showSaveAndUse: options2.hasProject !== false && (isNew || dirty) && (!active || options2.destinationChanged === true),
18709
+ showUse: options2.hasProject !== false && !isNew && !active && !dirty,
18314
18710
  saveEnabled: options2.canSave === true,
18315
18711
  useEnabled: options2.canActivate === true
18316
18712
  };
@@ -18457,7 +18853,7 @@ ${block}`;
18457
18853
  if (event.key !== "Tab") {
18458
18854
  return;
18459
18855
  }
18460
- 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));
18461
18857
  if (!focusable.length) {
18462
18858
  return;
18463
18859
  }
@@ -18697,8 +19093,8 @@ ${block}`;
18697
19093
  if (!text) return;
18698
19094
  const baseUrl = getCurrentBaseUrl(instance) || instance.tx("this endpoint", "\u6B64\u7AEF\u70B9");
18699
19095
  text.textContent = instance.tx(
18700
- `Future Codex runs in every Overleaf project tab may send selected project content to ${baseUrl}.`,
18701
- `\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`
18702
19098
  );
18703
19099
  }
18704
19100
  function syncTestAction(instance) {
@@ -18734,10 +19130,7 @@ ${block}`;
18734
19130
  if (!panel) {
18735
19131
  return;
18736
19132
  }
18737
- const style = instance.document.defaultView.getComputedStyle(panel);
18738
19133
  instance.root.dataset.theme = panel.dataset.theme === "light" ? "light" : "dark";
18739
- instance.root.style.setProperty("--provider-panel-bg", style.backgroundColor || "#151716");
18740
- instance.root.style.setProperty("--provider-panel-color", style.color || "#eceeea");
18741
19134
  }
18742
19135
  function escapeHtml(value) {
18743
19136
  return String(value ?? "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
@@ -18752,13 +19145,14 @@ ${block}`;
18752
19145
  return escapeHtml(value).replaceAll("`", "&#96;");
18753
19146
  }
18754
19147
  function destroy(instance) {
19148
+ instance.root?.close?.();
18755
19149
  instance.root?.remove?.();
18756
19150
  instance.root = null;
18757
19151
  }
18758
19152
  window.CodexOverleafProviderSettingsDialog = { create, getFooterActionState };
18759
19153
  })();
18760
19154
  }).call(globalThis, void 0, void 0, void 0);
18761
- (function runClassicContentModule56(module, exports, require2) {
19155
+ (function runClassicContentModule58(module, exports, require2) {
18762
19156
  (function initCodexOverleafProjectProviderSelection() {
18763
19157
  "use strict";
18764
19158
  function create(deps = {}) {
@@ -18815,7 +19209,7 @@ ${block}`;
18815
19209
  window.CodexOverleafProjectProviderSelection = { create };
18816
19210
  })();
18817
19211
  }).call(globalThis, void 0, void 0, void 0);
18818
- (function runClassicContentModule57(module, exports, require2) {
19212
+ (function runClassicContentModule59(module, exports, require2) {
18819
19213
  (function initCodexOverleafProviderSettingsCoordinator() {
18820
19214
  "use strict";
18821
19215
  function create(options2 = {}) {
@@ -18831,6 +19225,7 @@ ${block}`;
18831
19225
  getSettingsPanelInstance: options2.getSettingsPanelInstance || (() => null),
18832
19226
  getSelectedModel: options2.getSelectedModel || (() => ""),
18833
19227
  getSelectedProviderId: options2.getSelectedProviderId || (() => "builtin"),
19228
+ hasCurrentProject: options2.hasCurrentProject || (() => true),
18834
19229
  setSelectedProviderId: options2.setSelectedProviderId || (() => {
18835
19230
  }),
18836
19231
  confirmProviderSwitch: options2.confirmProviderSwitch || (() => true),
@@ -18863,6 +19258,7 @@ ${block}`;
18863
19258
  tx: instance.tx,
18864
19259
  ProviderProfiles: Profiles,
18865
19260
  callbacks: {
19261
+ hasCurrentProject: instance.hasCurrentProject,
18866
19262
  getCurrentProjectProviderId: () => instance.getSelectedProviderId() || "builtin",
18867
19263
  onTest: (context) => testProvider(instance, context),
18868
19264
  onCancelTest: () => cancelProviderTest(instance),
@@ -19001,6 +19397,7 @@ ${block}`;
19001
19397
  return { providerId: requestedProviderId, selectedModel: loadResult?.selectedModel || "" };
19002
19398
  }
19003
19399
  async function prepareProviderActivation(instance, providerId) {
19400
+ requireCurrentProject(instance);
19004
19401
  const previousProviderId = instance.getSelectedProviderId() || "builtin";
19005
19402
  const provider = instance.Profiles.getProviderById(instance.catalog, providerId);
19006
19403
  if (providerId !== previousProviderId) {
@@ -19091,6 +19488,7 @@ ${block}`;
19091
19488
  async function saveProvider(instance, context, action = {}) {
19092
19489
  instance.dialog.setBusy("saving", instance.tx("Saving provider\u2026", "\u6B63\u5728\u4FDD\u5B58\u6A21\u578B\u670D\u52A1\u2026"));
19093
19490
  try {
19491
+ if (action.activate === true) requireCurrentProject(instance);
19094
19492
  const result = await request(instance, "codex.providers.upsert", {
19095
19493
  profileId: context.profileId,
19096
19494
  expectedRevision: context.expectedRevision,
@@ -19270,6 +19668,13 @@ ${block}`;
19270
19668
  return { applied: true, change: describeCatalogChange(instance, previousCatalog, nextCatalog) };
19271
19669
  }
19272
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
+ }
19273
19678
  const selectedProviderId = instance.getSelectedProviderId() || "builtin";
19274
19679
  const catalogProvider = instance.Profiles.getProviderById(
19275
19680
  instance.catalog,
@@ -19352,6 +19757,12 @@ ${block}`;
19352
19757
  }))
19353
19758
  });
19354
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
+ }
19355
19766
  function emptyCatalogChange() {
19356
19767
  return { activeProviderChanged: false, activeModelCatalogChanged: false, changedProviderIds: [] };
19357
19768
  }
@@ -19408,7 +19819,7 @@ ${block}`;
19408
19819
  window.CodexOverleafProviderSettingsCoordinator = { create };
19409
19820
  })();
19410
19821
  }).call(globalThis, void 0, void 0, void 0);
19411
- (function runClassicContentModule58(module, exports, require2) {
19822
+ (function runClassicContentModule60(module, exports, require2) {
19412
19823
  (function initCodexOverleafSessionPersistence(root, factory) {
19413
19824
  if (typeof module === "object" && module.exports) {
19414
19825
  module.exports = factory(require2("../shared/storageMigration"));
@@ -19502,7 +19913,7 @@ ${block}`;
19502
19913
  };
19503
19914
  });
19504
19915
  }).call(globalThis, void 0, void 0, void 0);
19505
- (function runClassicContentModule59(module, exports, require2) {
19916
+ (function runClassicContentModule61(module, exports, require2) {
19506
19917
  (function(root, factory) {
19507
19918
  var api = factory();
19508
19919
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19606,7 +20017,7 @@ ${block}`;
19606
20017
  return Object.freeze({ persistPanelState });
19607
20018
  });
19608
20019
  }).call(globalThis, void 0, void 0, void 0);
19609
- (function runClassicContentModule60(module, exports, require2) {
20020
+ (function runClassicContentModule62(module, exports, require2) {
19610
20021
  (function(root, factory) {
19611
20022
  var api = factory();
19612
20023
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19651,7 +20062,7 @@ ${block}`;
19651
20062
  return Object.freeze({ create });
19652
20063
  });
19653
20064
  }).call(globalThis, void 0, void 0, void 0);
19654
- (function runClassicContentModule61(module, exports, require2) {
20065
+ (function runClassicContentModule63(module, exports, require2) {
19655
20066
  (function(root, factory) {
19656
20067
  if (typeof module === "object" && module.exports) {
19657
20068
  module.exports = factory(
@@ -19746,7 +20157,7 @@ ${block}`;
19746
20157
  });
19747
20158
  });
19748
20159
  }).call(globalThis, void 0, void 0, void 0);
19749
- (function runClassicContentModule62(module, exports, require2) {
20160
+ (function runClassicContentModule64(module, exports, require2) {
19750
20161
  (function initCodexOverleafDiagnosticsPanel() {
19751
20162
  "use strict";
19752
20163
  function create(options2 = {}) {
@@ -20174,7 +20585,7 @@ ${block}`;
20174
20585
  };
20175
20586
  })();
20176
20587
  }).call(globalThis, void 0, void 0, void 0);
20177
- (function runClassicContentModule63(module, exports, require2) {
20588
+ (function runClassicContentModule65(module, exports, require2) {
20178
20589
  (function initCodexOverleafRunQueueScheduler(root, factory) {
20179
20590
  if (typeof module === "object" && module.exports) {
20180
20591
  module.exports = factory(require2("../shared/runInputQueue"));
@@ -20502,7 +20913,7 @@ ${block}`;
20502
20913
  return { create, createCoordinator };
20503
20914
  });
20504
20915
  }).call(globalThis, void 0, void 0, void 0);
20505
- (function runClassicContentModule64(module, exports, require2) {
20916
+ (function runClassicContentModule66(module, exports, require2) {
20506
20917
  (function initCodexOverleafActiveTurnControl(root, factory) {
20507
20918
  if (typeof module === "object" && module.exports) {
20508
20919
  module.exports = factory();
@@ -20671,7 +21082,7 @@ ${block}`;
20671
21082
  return { create };
20672
21083
  });
20673
21084
  }).call(globalThis, void 0, void 0, void 0);
20674
- (function runClassicContentModule65(module, exports, require2) {
21085
+ (function runClassicContentModule67(module, exports, require2) {
20675
21086
  (function initCodexOverleafPendingInputView(root, factory) {
20676
21087
  if (typeof module === "object" && module.exports) {
20677
21088
  module.exports = factory();
@@ -20773,7 +21184,7 @@ ${block}`;
20773
21184
  return { create };
20774
21185
  });
20775
21186
  }).call(globalThis, void 0, void 0, void 0);
20776
- (function runClassicContentModule66(module, exports, require2) {
21187
+ (function runClassicContentModule68(module, exports, require2) {
20777
21188
  (function initCodexOverleafComposerPanel() {
20778
21189
  "use strict";
20779
21190
  function create(options2 = {}) {
@@ -20884,7 +21295,7 @@ ${block}`;
20884
21295
  </span>
20885
21296
  </div>
20886
21297
  <div class="codex-context-selection" data-context-selection></div>
20887
- <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>
20888
21299
  <div class="codex-context-files" data-context-file-list></div>
20889
21300
  </div>
20890
21301
  </form>
@@ -21032,7 +21443,7 @@ ${block}`;
21032
21443
  };
21033
21444
  })();
21034
21445
  }).call(globalThis, void 0, void 0, void 0);
21035
- (function runClassicContentModule67(module, exports, require2) {
21446
+ (function runClassicContentModule69(module, exports, require2) {
21036
21447
  (function initCodexOverleafTheme(root, factory) {
21037
21448
  if (typeof module === "object" && module.exports) {
21038
21449
  module.exports = factory();
@@ -21066,6 +21477,9 @@ ${block}`;
21066
21477
  const resolved = resolveTheme(preference, mediaQueryList);
21067
21478
  if (panelRoot && typeof panelRoot.setAttribute === "function") {
21068
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
+ }
21069
21483
  }
21070
21484
  return resolved;
21071
21485
  }
@@ -21100,7 +21514,7 @@ ${block}`;
21100
21514
  };
21101
21515
  });
21102
21516
  }).call(globalThis, void 0, void 0, void 0);
21103
- (function runClassicContentModule68(module, exports, require2) {
21517
+ (function runClassicContentModule70(module, exports, require2) {
21104
21518
  !(function(e, t) {
21105
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();
21106
21520
  })("undefined" != typeof self ? self : this, function() {
@@ -24520,7 +24934,7 @@ ${block}`;
24520
24934
  })();
24521
24935
  });
24522
24936
  }).call(globalThis, void 0, void 0, void 0);
24523
- (function runClassicContentModule69(module, exports, require2) {
24937
+ (function runClassicContentModule71(module, exports, require2) {
24524
24938
  !(function(t, e) {
24525
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();
24526
24940
  })(this, function() {
@@ -26592,7 +27006,7 @@ ${block}`;
26592
27006
  }, Ke;
26593
27007
  });
26594
27008
  }).call(globalThis, void 0, void 0, void 0);
26595
- (function runClassicContentModule70(module, exports, require2) {
27009
+ (function runClassicContentModule72(module, exports, require2) {
26596
27010
  (function initCodexOverleafMathText(root) {
26597
27011
  "use strict";
26598
27012
  const DELIMITERS = Object.freeze([
@@ -26977,7 +27391,7 @@ ${block}`;
26977
27391
  }
26978
27392
  })(typeof window !== "undefined" ? window : globalThis);
26979
27393
  }).call(globalThis, void 0, void 0, void 0);
26980
- (function runClassicContentModule71(module, exports, require2) {
27394
+ (function runClassicContentModule73(module, exports, require2) {
26981
27395
  (function initCodexOverleafMarkdownDomRenderer(root, factory) {
26982
27396
  const api = factory();
26983
27397
  if (typeof module === "object" && module.exports) {
@@ -27465,7 +27879,7 @@ ${block}`;
27465
27879
  };
27466
27880
  });
27467
27881
  }).call(globalThis, void 0, void 0, void 0);
27468
- (function runClassicContentModule72(module, exports, require2) {
27882
+ (function runClassicContentModule74(module, exports, require2) {
27469
27883
  (function initCodexOverleafMarkdownText() {
27470
27884
  "use strict";
27471
27885
  function create(deps = {}) {
@@ -28092,7 +28506,7 @@ ${block}`;
28092
28506
  window.CodexOverleafMarkdownText = { create };
28093
28507
  })();
28094
28508
  }).call(globalThis, void 0, void 0, void 0);
28095
- (function runClassicContentModule73(module, exports, require2) {
28509
+ (function runClassicContentModule75(module, exports, require2) {
28096
28510
  (function initCodexOverleafDiagnosticsController() {
28097
28511
  "use strict";
28098
28512
  function create(deps = {}) {
@@ -28661,7 +29075,7 @@ ${block}`;
28661
29075
  window.CodexOverleafDiagnosticsController = { create };
28662
29076
  })();
28663
29077
  }).call(globalThis, void 0, void 0, void 0);
28664
- (function runClassicContentModule74(module, exports, require2) {
29078
+ (function runClassicContentModule76(module, exports, require2) {
28665
29079
  (function initCodexOverleafRunGuidanceView() {
28666
29080
  "use strict";
28667
29081
  const LEGACY_GUIDANCE_TITLES = /* @__PURE__ */ new Set([
@@ -28701,7 +29115,7 @@ ${block}`;
28701
29115
  };
28702
29116
  })();
28703
29117
  }).call(globalThis, void 0, void 0, void 0);
28704
- (function runClassicContentModule75(module, exports, require2) {
29118
+ (function runClassicContentModule77(module, exports, require2) {
28705
29119
  (function initCodexOverleafRunGuidanceController() {
28706
29120
  "use strict";
28707
29121
  function create(deps = {}) {
@@ -28764,7 +29178,7 @@ ${block}`;
28764
29178
  window.CodexOverleafRunGuidanceController = { create };
28765
29179
  })();
28766
29180
  }).call(globalThis, void 0, void 0, void 0);
28767
- (function runClassicContentModule76(module, exports, require2) {
29181
+ (function runClassicContentModule78(module, exports, require2) {
28768
29182
  (function initCodexOverleafRunResultActions(root, factory) {
28769
29183
  const api = factory();
28770
29184
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -28869,7 +29283,7 @@ ${block}`;
28869
29283
  return Object.freeze({ create });
28870
29284
  });
28871
29285
  }).call(globalThis, void 0, void 0, void 0);
28872
- (function runClassicContentModule77(module, exports, require2) {
29286
+ (function runClassicContentModule79(module, exports, require2) {
28873
29287
  (function initCodexOverleafRunTimelineView() {
28874
29288
  "use strict";
28875
29289
  function create(deps = {}) {
@@ -29841,7 +30255,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29841
30255
  window.CodexOverleafRunTimelineView = { create };
29842
30256
  })();
29843
30257
  }).call(globalThis, void 0, void 0, void 0);
29844
- (function runClassicContentModule78(module, exports, require2) {
30258
+ (function runClassicContentModule80(module, exports, require2) {
29845
30259
  (function initCodexOverleafProjectSettingsCoordinator() {
29846
30260
  "use strict";
29847
30261
  function create(deps = {}) {
@@ -30104,6 +30518,8 @@ ${conclusion}` : `${label} ${conclusion}`;
30104
30518
  });
30105
30519
  saveStateSoon();
30106
30520
  renderLocalSkillList();
30521
+ deps.updateGlobalPreferences?.({ codexOverleafSkillEnabled: { [skillId]: Boolean(enabled) } })?.catch(() => {
30522
+ });
30107
30523
  }
30108
30524
  function readSkillLoadingSettingsFromSettings() {
30109
30525
  return SettingsPanel.readState(getSettingsPanelInstance()).skillToggles;
@@ -30168,7 +30584,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30168
30584
  window.CodexOverleafProjectSettingsCoordinator = { create };
30169
30585
  })();
30170
30586
  }).call(globalThis, void 0, void 0, void 0);
30171
- (function runClassicContentModule79(module, exports, require2) {
30587
+ (function runClassicContentModule81(module, exports, require2) {
30172
30588
  (function initCodexOverleafSessionMenuView() {
30173
30589
  "use strict";
30174
30590
  function create(deps = {}) {
@@ -30373,7 +30789,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30373
30789
  window.CodexOverleafSessionMenuView = { create };
30374
30790
  })();
30375
30791
  }).call(globalThis, void 0, void 0, void 0);
30376
- (function runClassicContentModule80(module, exports, require2) {
30792
+ (function runClassicContentModule82(module, exports, require2) {
30377
30793
  (function initCodexOverleafSessionManager() {
30378
30794
  "use strict";
30379
30795
  function create(deps = {}) {
@@ -30632,7 +31048,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30632
31048
  window.CodexOverleafSessionManager = { create };
30633
31049
  })();
30634
31050
  }).call(globalThis, void 0, void 0, void 0);
30635
- (function runClassicContentModule81(module, exports, require2) {
31051
+ (function runClassicContentModule83(module, exports, require2) {
30636
31052
  (function initCodexOverleafSessionForkController(root, factory) {
30637
31053
  const api = factory();
30638
31054
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -30761,7 +31177,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30761
31177
  return { copyRunSnapshot, create };
30762
31178
  });
30763
31179
  }).call(globalThis, void 0, void 0, void 0);
30764
- (function runClassicContentModule82(module, exports, require2) {
31180
+ (function runClassicContentModule84(module, exports, require2) {
30765
31181
  (function initCodexOverleafApplyResultFormatters() {
30766
31182
  "use strict";
30767
31183
  function create(deps = {}) {
@@ -31081,7 +31497,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31081
31497
  window.CodexOverleafApplyResultFormatters = { create };
31082
31498
  })();
31083
31499
  }).call(globalThis, void 0, void 0, void 0);
31084
- (function runClassicContentModule83(module, exports, require2) {
31500
+ (function runClassicContentModule85(module, exports, require2) {
31085
31501
  (function initCodexOverleafModelPickerSupport(root, factory) {
31086
31502
  if (typeof module === "object" && module.exports) {
31087
31503
  module.exports = factory(require2("../shared/models"));
@@ -31182,7 +31598,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31182
31598
  return api;
31183
31599
  });
31184
31600
  }).call(globalThis, void 0, void 0, void 0);
31185
- (function runClassicContentModule84(module, exports, require2) {
31601
+ (function runClassicContentModule86(module, exports, require2) {
31186
31602
  (function initCodexOverleafModelPicker() {
31187
31603
  "use strict";
31188
31604
  function create(deps = {}) {
@@ -31470,7 +31886,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31470
31886
  if (!efforts.length) {
31471
31887
  efforts = presentation === "none" ? ["none"] : ["low", "medium", "high", "xhigh"];
31472
31888
  }
31473
- const current = reasoningSelect.value || getState()?.reasoningEffort || "";
31889
+ const current = getState()?.reasoningEffort || reasoningSelect.value || "";
31474
31890
  const fallback = efforts.includes(model?.defaultReasoningEffort) ? model.defaultReasoningEffort : efforts.includes("high") ? "high" : efforts[0];
31475
31891
  reasoningSelect.textContent = "";
31476
31892
  for (const effort of efforts) {
@@ -31660,7 +32076,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31660
32076
  window.CodexOverleafModelPicker = { create };
31661
32077
  })();
31662
32078
  }).call(globalThis, void 0, void 0, void 0);
31663
- (function runClassicContentModule85(module, exports, require2) {
32079
+ (function runClassicContentModule87(module, exports, require2) {
31664
32080
  (function initCodexOverleafProjectSessionCleanup() {
31665
32081
  "use strict";
31666
32082
  const FRESH_RUNNING_WINDOW_MS = 30 * 60 * 1e3;
@@ -31760,7 +32176,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31760
32176
  window.CodexOverleafProjectSessionCleanup = { create };
31761
32177
  })();
31762
32178
  }).call(globalThis, void 0, void 0, void 0);
31763
- (function runClassicContentModule86(module, exports, require2) {
32179
+ (function runClassicContentModule88(module, exports, require2) {
31764
32180
  (function initCodexOverleafRecentProjects() {
31765
32181
  "use strict";
31766
32182
  function create(deps = {}) {
@@ -32686,7 +33102,7 @@ ${conclusion}` : `${label} ${conclusion}`;
32686
33102
  window.CodexOverleafRecentProjects = { create };
32687
33103
  })();
32688
33104
  }).call(globalThis, void 0, void 0, void 0);
32689
- (function runClassicContentModule87(module, exports, require2) {
33105
+ (function runClassicContentModule89(module, exports, require2) {
32690
33106
  (function initCodexOverleafOtWarmMirror() {
32691
33107
  "use strict";
32692
33108
  function create(deps = {}) {
@@ -33541,7 +33957,7 @@ ${conclusion}` : `${label} ${conclusion}`;
33541
33957
  window.CodexOverleafOtWarmMirror = { create };
33542
33958
  })();
33543
33959
  }).call(globalThis, void 0, void 0, void 0);
33544
- (function runClassicContentModule88(module, exports, require2) {
33960
+ (function runClassicContentModule90(module, exports, require2) {
33545
33961
  (function initCodexOverleafWritebackOrchestrator() {
33546
33962
  "use strict";
33547
33963
  let tr;
@@ -34297,7 +34713,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34297
34713
  window.CodexOverleafWritebackOrchestrator = { create };
34298
34714
  })();
34299
34715
  }).call(globalThis, void 0, void 0, void 0);
34300
- (function runClassicContentModule89(module, exports, require2) {
34716
+ (function runClassicContentModule91(module, exports, require2) {
34301
34717
  (function initCodexOverleafRunSettlementPersistence(root, factory) {
34302
34718
  const api = factory();
34303
34719
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -34340,7 +34756,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34340
34756
  return Object.freeze({ create });
34341
34757
  });
34342
34758
  }).call(globalThis, void 0, void 0, void 0);
34343
- (function runClassicContentModule90(module, exports, require2) {
34759
+ (function runClassicContentModule92(module, exports, require2) {
34344
34760
  (function initPostNavigationSettlementPersistence(root, factory) {
34345
34761
  const api = factory();
34346
34762
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -34432,7 +34848,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34432
34848
  return Object.freeze({ persist, persistRequired });
34433
34849
  });
34434
34850
  }).call(globalThis, void 0, void 0, void 0);
34435
- (function runClassicContentModule91(module, exports, require2) {
34851
+ (function runClassicContentModule93(module, exports, require2) {
34436
34852
  (function initCodexOverleafPanelMaintenance() {
34437
34853
  "use strict";
34438
34854
  function create(deps = {}) {
@@ -34456,6 +34872,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34456
34872
  setState,
34457
34873
  getCurrentRunView,
34458
34874
  getSettingsPanelInstance,
34875
+ prepareRetryReplacement,
34459
34876
  StorageDb
34460
34877
  } = deps;
34461
34878
  let auditHistoryRecords = [];
@@ -34608,6 +35025,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34608
35025
  showPluginToast(tx("Nothing to refill: the original task text is unavailable.", "\u65E0\u6CD5\u56DE\u586B\uFF1A\u539F\u4EFB\u52A1\u6587\u672C\u4E0D\u53EF\u7528\u3002"));
34609
35026
  return;
34610
35027
  }
35028
+ prepareRetryReplacement?.(run || null);
34611
35029
  input.value = task;
34612
35030
  getState().task = task;
34613
35031
  autosizeTaskTextarea();
@@ -34748,7 +35166,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34748
35166
  window.CodexOverleafPanelMaintenance = { create };
34749
35167
  })();
34750
35168
  }).call(globalThis, void 0, void 0, void 0);
34751
- (function runClassicContentModule92(module, exports, require2) {
35169
+ (function runClassicContentModule94(module, exports, require2) {
34752
35170
  (function initCodexOverleafUpdateIdle(root) {
34753
35171
  "use strict";
34754
35172
  function create(options2 = {}) {
@@ -34816,7 +35234,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34816
35234
  root.CodexOverleafUpdateIdle = Object.freeze({ create });
34817
35235
  })(typeof window !== "undefined" ? window : globalThis);
34818
35236
  }).call(globalThis, void 0, void 0, void 0);
34819
- (function runClassicContentModule93(module, exports, require2) {
35237
+ (function runClassicContentModule95(module, exports, require2) {
34820
35238
  (function initCodexOverleafUpdateNotice(root, factory) {
34821
35239
  if (typeof module === "object" && module.exports) {
34822
35240
  module.exports = factory(require2("../shared/managedUpdateProjection"));
@@ -35260,7 +35678,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35260
35678
  return Object.freeze({ mount });
35261
35679
  });
35262
35680
  }).call(globalThis, void 0, void 0, void 0);
35263
- (function runClassicContentModule94(module, exports, require2) {
35681
+ (function runClassicContentModule96(module, exports, require2) {
35264
35682
  (function initCodexOverleafContentRuntime(root) {
35265
35683
  "use strict";
35266
35684
  function init(dependencies2) {
@@ -35453,6 +35871,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35453
35871
  renderAuditHistoryPanel: () => renderAuditHistoryPanel(),
35454
35872
  renderRecentProjectsVariant: (...args) => renderRecentProjectsVariant(...args),
35455
35873
  saveStateSoon: () => saveStateSoon(),
35874
+ updateGlobalPreferences: (patch) => getGlobalPreferences().update(patch),
35456
35875
  setState: (next) => {
35457
35876
  state = next;
35458
35877
  },
@@ -35618,7 +36037,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35618
36037
  state = next;
35619
36038
  },
35620
36039
  getCurrentRunView: () => currentRunView,
35621
- getSettingsPanelInstance: () => settingsPanelInstance
36040
+ getSettingsPanelInstance: () => settingsPanelInstance,
36041
+ prepareRetryReplacement: (run) => prepareRetryReplacement(run)
35622
36042
  });
35623
36043
  const {
35624
36044
  showUndoFileSelection,
@@ -35893,6 +36313,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35893
36313
  const providerSettingsCoordinator = Modules.ProviderSettingsCoordinator.create({
35894
36314
  ProviderProfiles: Modules.ProviderProfiles,
35895
36315
  ProviderSettingsDialog: Modules.ProviderSettingsDialog,
36316
+ hasCurrentProject: () => Boolean(getCurrentProjectId()),
35896
36317
  tx,
35897
36318
  sendBackgroundNative,
35898
36319
  document,
@@ -36059,7 +36480,9 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36059
36480
  let composerPanelInstance = null;
36060
36481
  let state = null;
36061
36482
  let storageKey = LEGACY_STORAGE_KEY;
36483
+ let globalPreferencesController = null;
36062
36484
  let currentRunView = null;
36485
+ let pendingRetryReplacement = null;
36063
36486
  let runQueueScheduler = null;
36064
36487
  let runInputCoordinator = null;
36065
36488
  const activeTurnControl = ActiveTurnControl.create({ chrome });
@@ -36150,6 +36573,13 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36150
36573
  sendResponse?.(getPanelStateResponse());
36151
36574
  return;
36152
36575
  }
36576
+ if (message?.type === "codex-overleaf/toggle-launcher") {
36577
+ const visible = !PanelRenderer.isLauncherVisible(panelRendererInstance);
36578
+ PanelRenderer.setLauncherVisible(panelRendererInstance, visible, { persist: true });
36579
+ if (!visible) closePanel();
36580
+ sendResponse?.(getPanelStateResponse());
36581
+ return;
36582
+ }
36153
36583
  if (message?.type === "codex-overleaf/toggle-panel") {
36154
36584
  if (isPanelOpen()) {
36155
36585
  closePanel();
@@ -36178,9 +36608,10 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36178
36608
  throw error;
36179
36609
  });
36180
36610
  async function init2() {
36611
+ await getGlobalPreferences().initialize();
36181
36612
  await refreshAccountScopeId();
36182
36613
  storageKey = getProjectStorageKey(LEGACY_STORAGE_KEY, window.location.href);
36183
- state = normalizePanelState(await loadStoredState(), { restoreRunningRuns: true });
36614
+ state = normalizePanelState(getGlobalPreferences().overlay(await loadStoredState()), { restoreRunningRuns: true });
36184
36615
  initializeRunQueueScheduler();
36185
36616
  recoverInterruptedRunJournals().then(() => applyStateToPanel()).catch(() => {
36186
36617
  });
@@ -36196,6 +36627,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36196
36627
  recentProjects.mountDashboardShell();
36197
36628
  }
36198
36629
  applyStateToPanel();
36630
+ getGlobalPreferences().refreshView();
36199
36631
  if (isProjectEditorRoute(window.location)) {
36200
36632
  activeProjectId = window.location.pathname.match(/^\/project\/([^/?#]+)/)[1];
36201
36633
  }
@@ -36363,7 +36795,14 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36363
36795
  maxWidth: PANEL_MAX_WIDTH,
36364
36796
  pageMinWidth: PAGE_MIN_WIDTH,
36365
36797
  initialWidth: state?.panelWidth || PANEL_DEFAULT_WIDTH,
36798
+ chromeApi: chrome,
36799
+ launcherLabel: tx("Show or hide Codex panel", "\u663E\u793A\u6216\u9690\u85CF Codex \u8FB9\u680F"),
36366
36800
  callbacks: {
36801
+ onLauncherToggle: () => ensurePanelOpen(),
36802
+ onClosePanel: () => closePanel(),
36803
+ onLauncherVisibilityChange: (visible) => {
36804
+ if (!visible) closePanel();
36805
+ },
36367
36806
  onRefresh: () => refreshProbe({ userInitiated: true }),
36368
36807
  onNewSession: () => startNewSession(),
36369
36808
  onChangeHistory: () => openChangeHistory(),
@@ -36424,7 +36863,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36424
36863
  button: panel.querySelector("[data-custom-instructions-settings]"),
36425
36864
  callbacks: {
36426
36865
  onBack: () => closeCustomInstructionsSettings(),
36427
- onInputChange: () => persistPanelInputs(),
36866
+ onInputChange: (event) => persistPanelInputs(event),
36428
36867
  onSkillsOpen: () => openSkillsView(),
36429
36868
  onSkillsBack: () => closeSkillsView(),
36430
36869
  onProvidersOpen: () => providerSettingsCoordinator.open(),
@@ -36527,7 +36966,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36527
36966
  function getPanelStateResponse() {
36528
36967
  return {
36529
36968
  ok: true,
36530
- open: isPanelOpen()
36969
+ open: isPanelOpen(),
36970
+ launcherVisible: PanelRenderer.isLauncherVisible(panelRendererInstance)
36531
36971
  };
36532
36972
  }
36533
36973
  function toggleDiagnosticsMenu() {
@@ -36887,6 +37327,12 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36887
37327
  ) : captureCurrentExecutionSnapshot(submittedPanelState);
36888
37328
  const submittedMode = executionSnapshot.mode;
36889
37329
  const submittedRequireReviewing = executionSnapshot.requireReviewing === true;
37330
+ const replaceRunId = queuedInput ? "" : runController.resolveRetryReplacement({
37331
+ candidate: pendingRetryReplacement,
37332
+ activeSessionId: state.activeSessionId,
37333
+ runs: state.runs,
37334
+ projectRunSettlement: (run) => WritebackSettlement.projectRunSettlement(run)
37335
+ });
36890
37336
  runCancellationRequested = false;
36891
37337
  runCancellationController = new AbortController();
36892
37338
  setRunning(true);
@@ -36899,8 +37345,10 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36899
37345
  executionSnapshot,
36900
37346
  attachments: submittedAttachments,
36901
37347
  skillInvocation: submittedSkillInvocation,
36902
- queueItemId: queuedInput?.id || ""
37348
+ queueItemId: queuedInput?.id || "",
37349
+ replaceRunId
36903
37350
  });
37351
+ if (!queuedInput) pendingRetryReplacement = null;
36904
37352
  const runSessionId = currentRunView.sessionId;
36905
37353
  let runAuditDraft = null;
36906
37354
  try {
@@ -39000,11 +39448,36 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39000
39448
  });
39001
39449
  return scopedPersistenceCoordinator;
39002
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
+ }
39003
39476
  async function reloadProjectRunHistory(newProjectId) {
39004
39477
  try {
39005
39478
  storageKey = getProjectStorageKey(LEGACY_STORAGE_KEY, window.location.href);
39006
39479
  const reloaded = await loadStoredState();
39007
- state = normalizePanelState(reloaded, { restoreRunningRuns: true });
39480
+ state = normalizePanelState(getGlobalPreferences().overlay(reloaded), { restoreRunningRuns: true });
39008
39481
  applyStateToPanel();
39009
39482
  } catch (_error) {
39010
39483
  }
@@ -39604,8 +40077,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39604
40077
  function formatContextItems(focusFiles = []) {
39605
40078
  const fileItems = (focusFiles || []).map((path) => `@file:${path}`);
39606
40079
  return fileItems.length ? fileItems.join(", ") : tx(
39607
- "@whole-project (default); add @file, @compile-log, or @current-section",
39608
- "@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"
39609
40082
  );
39610
40083
  }
39611
40084
  function appendProbeUserStatus(probe) {
@@ -40276,6 +40749,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40276
40749
  return error?.message || String(error);
40277
40750
  }
40278
40751
  async function persistPanelInputs(event) {
40752
+ const globalWrite = getGlobalPreferences().handleInput(event);
40753
+ if (globalWrite) return globalWrite;
40279
40754
  if (event?.type === "input" && event?.target?.matches?.("[data-task]")) {
40280
40755
  readPanelInputs();
40281
40756
  saveStateSoon();
@@ -40358,23 +40833,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40358
40833
  setCustomInstructionsForProject(projectId, customInstructionsInput.value);
40359
40834
  }
40360
40835
  setGovernanceRulesForCurrentProject(readGovernanceRulesFromSettings());
40361
- const newSettings = readSkillLoadingSettingsFromSettings();
40362
- const prevOverleafSkills = getSkillLoadingSettings().loadCodexOverleafSkills;
40363
- setSkillLoadingSettings(newSettings);
40364
- const themePref = panel?.querySelector("[data-theme-select]")?.value || "dark";
40365
- if (state) {
40366
- state.theme = themePref;
40367
- }
40368
- applyPanelTheme(themePref);
40369
- const languagePref = panel?.querySelector("[data-language-select]")?.value;
40370
- if (languagePref && state && languagePref !== getLocale()) {
40371
- state.locale = i18n?.normalizeLocale?.(languagePref) || languagePref;
40372
- applyLocaleToPanel();
40373
- }
40374
- if (prevOverleafSkills !== getSkillLoadingSettings().loadCodexOverleafSkills) {
40375
- renderLocalSkillList();
40376
- }
40377
- updateSkillsEntrySummary();
40378
40836
  }
40379
40837
  }
40380
40838
  function readSelectedModelInput() {
@@ -40473,6 +40931,16 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40473
40931
  panel.dataset.cancelling = running && runCancellationRequested ? "true" : "false";
40474
40932
  renderPendingInputs();
40475
40933
  }
40934
+ function prepareRetryReplacement(run) {
40935
+ const sessionId = state?.activeSessionId || "";
40936
+ const source = findRunRecord(run?.id, sessionId);
40937
+ const eligible = source && runController.isRetryReplacementEligible(
40938
+ source,
40939
+ WritebackSettlement.projectRunSettlement(source)
40940
+ );
40941
+ pendingRetryReplacement = eligible ? { sessionId, runId: source.id } : null;
40942
+ return Boolean(eligible);
40943
+ }
40476
40944
  function startRunView({
40477
40945
  task,
40478
40946
  mode,
@@ -40480,6 +40948,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40480
40948
  reasoningEffort,
40481
40949
  speedTier,
40482
40950
  queueItemId = "",
40951
+ replaceRunId = "",
40483
40952
  executionSnapshot = null
40484
40953
  }) {
40485
40954
  let attachments = [];
@@ -40527,12 +40996,13 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40527
40996
  titleSource: "auto"
40528
40997
  } : {};
40529
40998
  state = updateActiveSession(state, {
40530
- runs: [...state.runs || [], record].slice(-20),
40999
+ runs: runController.replaceRunForRetry(state.runs, replaceRunId, record),
40531
41000
  ...titlePatch
40532
41001
  });
40533
- saveStateSoon();
41002
+ saveStateSoon(replaceRunId ? 0 : 120);
40534
41003
  const log = panel.querySelector("[data-log]");
40535
41004
  removeEmptyRunsMessage(log);
41005
+ if (replaceRunId) log.querySelector(`[data-run-id="${cssEscape(replaceRunId)}"]`)?.remove();
40536
41006
  const root2 = renderRunCard(record);
40537
41007
  log.append(root2);
40538
41008
  scrollLogToBottom({ force: true });
@@ -42032,7 +42502,7 @@ Reason: ${item.reason || "No reason provided"}`),
42032
42502
  root.CodexOverleafContentRuntime = { init };
42033
42503
  })(typeof window !== "undefined" ? window : globalThis);
42034
42504
  }).call(globalThis, void 0, void 0, void 0);
42035
- (function runClassicContentModule95(module, exports, require2) {
42505
+ (function runClassicContentModule97(module, exports, require2) {
42036
42506
  (function initCodexOverleafLegacyGlobalRegistry(root, factory) {
42037
42507
  "use strict";
42038
42508
  const api = factory();
@@ -42060,6 +42530,8 @@ Reason: ${item.reason || "No reason provided"}`),
42060
42530
  "DiffReviewPanel",
42061
42531
  "FailureReasons",
42062
42532
  "GovernanceRules",
42533
+ "GlobalPreferences",
42534
+ "GlobalPreferencesController",
42063
42535
  "I18n",
42064
42536
  "LineReferences",
42065
42537
  "LocalSkillsPanel",