codex-overleaf-link 2.3.0 → 2.3.1

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.
Files changed (33) hide show
  1. package/README.md +23 -23
  2. package/extension/bootstrap/manifest.template.json +1 -1
  3. package/extension/src/background.js +20 -0
  4. package/extension/src/content/composerPanel.js +0 -2
  5. package/extension/src/content/contentRuntime.js +108 -110
  6. package/extension/src/content/generated/content.bundle.js +566 -331
  7. package/extension/src/content/generated/content.bundle.meta.json +4 -3
  8. package/extension/src/content/markdownText.js +12 -10
  9. package/extension/src/content/mathText.js +155 -9
  10. package/extension/src/content/nativeCompatibilityController.js +2 -2
  11. package/extension/src/content/otWarmMirror.js +1 -1
  12. package/extension/src/content/runTimelineView.js +6 -0
  13. package/extension/src/content/writebackOrchestrator.js +2 -49
  14. package/extension/src/page/trackedChangesLifecycle.js +10 -4
  15. package/extension/src/page/writebackRouter.js +6 -2
  16. package/extension/src/shared/agentTranscript.js +10 -3
  17. package/extension/src/shared/compatibility.js +1 -1
  18. package/extension/src/shared/i18n.js +2 -4
  19. package/extension/src/shared/pageRpcContract.js +2 -2
  20. package/extension/src/shared/runExecutionSnapshot.js +14 -4
  21. package/extension/src/shared/runExecutionSnapshotCodec.js +5 -2
  22. package/extension/src/shared/scopedPersistenceQueuePolicy.js +20 -1
  23. package/extension/src/shared/scopedPersistenceReceipt.js +60 -0
  24. package/extension/src/shared/scopedPersistenceTransaction.js +50 -47
  25. package/extension/src/shared/sessionState.js +46 -11
  26. package/extension/src/shared/storageDb.js +6 -5
  27. package/extension/src/shared/writebackOperationEvidence.js +16 -6
  28. package/extension/src/shared/writebackSettlement.js +28 -6
  29. package/extension/styles/panel.css +18 -8
  30. package/native-host/src/codexPromptAssembly.js +1 -1
  31. package/native-host/src/taskRunnerRuntime.js +11 -81
  32. package/native-host/src/updateManager.js +36 -1
  33. package/package.json +1 -1
@@ -1697,10 +1697,17 @@
1697
1697
  if (providerError) {
1698
1698
  return providerError;
1699
1699
  }
1700
- if (/Mode must be "confirm" or "auto"/i.test(text)) {
1700
+ if (/suggest_mode_removed|Suggest mode has been removed/i.test(text)) {
1701
+ return {
1702
+ conclusion: textFor(locale, "\u5EFA\u8BAE\u4FEE\u6539\u6A21\u5F0F\u5DF2\u7ECF\u79FB\u9664\u3002", "Suggest mode has been removed."),
1703
+ nextStep: textFor(locale, "\u8BF7\u5237\u65B0\u6269\u5C55\uFF0C\u7136\u540E\u9009\u62E9\u201C\u53EA\u95EE\u4E0D\u6539\u201D\u6216\u201C\u81EA\u52A8\u5199\u5165\u201D\u3002", "Reload the extension, then choose Ask or Auto."),
1704
+ failureCode: "suggest_mode_removed"
1705
+ };
1706
+ }
1707
+ if (/Mode must be "(?:confirm|ask)" or "auto"/i.test(text)) {
1701
1708
  return {
1702
1709
  conclusion: textFor(locale, "\u8FD9\u8F6E\u6CA1\u6709\u5199\u5165\uFF1A\u5F53\u524D\u662F\u201C\u53EA\u95EE\u4E0D\u6539\u201D\uFF0C\u4F46\u8FD9\u4E2A\u4EFB\u52A1\u9700\u8981\u5199\u5165\u6743\u9650\u3002", "No files were written: this task needs write access, but the current mode is Ask."),
1703
- nextStep: textFor(locale, "\u8BF7\u5207\u6362\u5230\u201C\u5EFA\u8BAE\u4FEE\u6539\u201D\u6216\u201C\u81EA\u52A8\u5199\u5165\u201D\u540E\u91CD\u65B0\u8FD0\u884C\u3002", "Switch to Suggest or Auto and run the task again."),
1710
+ nextStep: textFor(locale, "\u8BF7\u5207\u6362\u5230\u201C\u81EA\u52A8\u5199\u5165\u201D\u540E\u91CD\u65B0\u8FD0\u884C\u3002", "Switch to Auto and run the task again."),
1704
1711
  failureCode: null
1705
1712
  // no direct catalog match — preflight / governance
1706
1713
  };
@@ -1772,7 +1779,7 @@
1772
1779
  if (/checkpoint/i.test(text)) {
1773
1780
  return {
1774
1781
  conclusion: textFor(locale, "\u8FD9\u8F6E\u6CA1\u6709\u81EA\u52A8\u5199\u5165\uFF1ACodex \u6CA1\u6709\u62FF\u5230\u53EF\u6062\u590D\u7248\u672C\u3002", "This run did not auto-write: Codex did not get a recoverable version."),
1775
- nextStep: textFor(locale, "\u8BF7\u5207\u6362\u5230\u201C\u5EFA\u8BAE\u4FEE\u6539\u201D\uFF0C\u6216\u786E\u8BA4 Overleaf Reviewing \u5DF2\u5F00\u542F\u540E\u518D\u7528\u201C\u81EA\u52A8\u5199\u5165\u201D\u3002", "Switch to Suggest, or confirm Overleaf Reviewing is enabled before using Auto."),
1782
+ nextStep: textFor(locale, "\u8BF7\u786E\u8BA4 Overleaf Reviewing \u5DF2\u5F00\u542F\u540E\u518D\u7528\u201C\u81EA\u52A8\u5199\u5165\u201D\u3002", "Confirm that Overleaf Reviewing is enabled before using Auto."),
1776
1783
  failureCode: null
1777
1784
  // no current catalog code; preflight reviewing issue
1778
1785
  };
@@ -4333,8 +4340,6 @@ ${block}`;
4333
4340
  writeMode: "Write mode",
4334
4341
  modeAsk: "Ask",
4335
4342
  modeAskTitle: "Read and analyze only. Do not write to Overleaf.",
4336
- modeConfirm: "Suggest",
4337
- modeConfirmTitle: "Show a change plan first, then write after approval.",
4338
4343
  modeAuto: "Auto",
4339
4344
  modeAutoTitle: "Write directly after authorization. Deletes still require confirmation.",
4340
4345
  addContext: "Add @ context",
@@ -4470,6 +4475,7 @@ ${block}`;
4470
4475
  refreshProbeDone: "Refreshed: {status}",
4471
4476
  refreshProbeFailed: "Refresh failed. Reload Overleaf and try again.",
4472
4477
  processedFailed: "Failed {elapsed}",
4478
+ processedCancelled: "Cancelled {elapsed}",
4473
4479
  processing: "Running {elapsed}",
4474
4480
  processed: "Done {elapsed}",
4475
4481
  restoredRunStoppedTitle: "Stopped tracking this run after a page refresh",
@@ -4846,8 +4852,6 @@ ${block}`;
4846
4852
  writeMode: "\u5199\u5165\u6A21\u5F0F",
4847
4853
  modeAsk: "\u53EA\u95EE\u4E0D\u6539",
4848
4854
  modeAskTitle: "\u53EA\u8BFB\u53D6\u548C\u5206\u6790\uFF0C\u4E0D\u5199\u5165 Overleaf",
4849
- modeConfirm: "\u5EFA\u8BAE\u4FEE\u6539",
4850
- modeConfirmTitle: "\u5148\u7ED9\u51FA\u4FEE\u6539\u65B9\u6848\uFF0C\u786E\u8BA4\u540E\u5199\u5165",
4851
4855
  modeAuto: "\u81EA\u52A8\u5199\u5165",
4852
4856
  modeAutoTitle: "\u6388\u6743\u540E\u76F4\u63A5\u5199\u5165\uFF0C\u5220\u9664\u4ECD\u9700\u786E\u8BA4",
4853
4857
  addContext: "\u6DFB\u52A0 @ \u4E0A\u4E0B\u6587",
@@ -4983,6 +4987,7 @@ ${block}`;
4983
4987
  refreshProbeDone: "\u5DF2\u91CD\u65B0\u68C0\u6D4B\uFF1A{status}",
4984
4988
  refreshProbeFailed: "\u68C0\u6D4B\u5931\u8D25\uFF1A\u8BF7\u5237\u65B0 Overleaf \u9875\u9762\u540E\u91CD\u8BD5",
4985
4989
  processedFailed: "\u5904\u7406\u5931\u8D25 {elapsed}",
4990
+ processedCancelled: "\u5DF2\u53D6\u6D88 {elapsed}",
4986
4991
  processing: "\u5904\u7406\u4E2D {elapsed}",
4987
4992
  processed: "\u5DF2\u5904\u7406 {elapsed}",
4988
4993
  restoredRunStoppedTitle: "\u9875\u9762\u5237\u65B0\u540E\u5DF2\u505C\u6B62\u8DDF\u8E2A\u8FD9\u8F6E\u4EFB\u52A1",
@@ -5498,7 +5503,7 @@ ${block}`;
5498
5503
  })(typeof window !== "undefined" ? window : globalThis, function runExecutionSnapshotCodecFactory() {
5499
5504
  "use strict";
5500
5505
  const SCHEMA_VERSION = 1;
5501
- const VALID_MODES = /* @__PURE__ */ new Set(["ask", "confirm", "auto"]);
5506
+ const VALID_MODES = /* @__PURE__ */ new Set(["ask", "auto"]);
5502
5507
  const VALID_SOURCES = /* @__PURE__ */ new Set(["submitted", "legacy-captured", "legacy-inferred"]);
5503
5508
  const TUPLE_FIELDS = Object.freeze([
5504
5509
  "mode",
@@ -5515,12 +5520,15 @@ ${block}`;
5515
5520
  function normalizeSnapshot(value = {}, options2 = {}) {
5516
5521
  const input = value && typeof value === "object" ? value : {};
5517
5522
  assertNoSecretFields(input);
5523
+ if (input.mode === "confirm" && options2.migrateLegacyConfirm !== true) {
5524
+ throw snapshotError("suggest_mode_removed", "Suggest mode has been removed. Choose Ask or Auto.");
5525
+ }
5518
5526
  const providerId = normalizeText(input.providerId) || "builtin";
5519
5527
  const revision = normalizeRevisionResult(input.providerRevision);
5520
5528
  if (!revision.ok) throw snapshotError("provider_revision_conflict", revision.error);
5521
5529
  const snapshot = {
5522
5530
  schemaVersion: SCHEMA_VERSION,
5523
- mode: VALID_MODES.has(input.mode) ? input.mode : "ask",
5531
+ mode: input.mode === "auto" ? "auto" : "ask",
5524
5532
  providerId,
5525
5533
  providerRevision: providerId === "builtin" ? "" : revision.value,
5526
5534
  model: normalizeText(input.model).slice(0, 160),
@@ -5671,7 +5679,10 @@ ${block}`;
5671
5679
  const rawPayload = rawQueueItem?.payload && typeof rawQueueItem.payload === "object" ? rawQueueItem.payload : rawQueueItem;
5672
5680
  const persisted = rawQueueItem?.executionSnapshot || rawPayload?.executionSnapshot;
5673
5681
  if (persisted && typeof persisted === "object") {
5674
- return Codec.normalizeSnapshot(persisted, { source: persisted.source || "submitted" });
5682
+ return Codec.normalizeSnapshot(persisted, {
5683
+ source: persisted.source || "submitted",
5684
+ migrateLegacyConfirm: true
5685
+ });
5675
5686
  }
5676
5687
  const raw = rawPayload && typeof rawPayload === "object" ? rawPayload : {};
5677
5688
  const fallback = fallbackInput && typeof fallbackInput === "object" ? fallbackInput : {};
@@ -5690,12 +5701,16 @@ ${block}`;
5690
5701
  inferred = true;
5691
5702
  }
5692
5703
  return Codec.normalizeSnapshot(captured, {
5693
- source: inferred ? "legacy-inferred" : "legacy-captured"
5704
+ source: inferred ? "legacy-inferred" : "legacy-captured",
5705
+ migrateLegacyConfirm: true
5694
5706
  });
5695
5707
  }
5696
5708
  function resolveForExecution(value = {}, options2 = {}) {
5697
5709
  const persisted = value.executionSnapshot || value;
5698
- const snapshot = Codec.normalizeSnapshot(persisted, { source: persisted.source || "submitted" });
5710
+ const snapshot = Codec.normalizeSnapshot(persisted, {
5711
+ source: persisted.source || "submitted",
5712
+ migrateLegacyConfirm: true
5713
+ });
5699
5714
  if (snapshot.providerId === "builtin") return Codec.normalizeSnapshot(snapshot, { source: snapshot.source });
5700
5715
  const catalog = options2.catalog || {};
5701
5716
  const provider = ProviderProfiles?.getProviderById ? ProviderProfiles.getProviderById(catalog, snapshot.providerId) : (catalog.providers || []).find((item) => item?.id === snapshot.providerId);
@@ -5718,7 +5733,10 @@ ${block}`;
5718
5733
  }
5719
5734
  function snapshotOf(value = {}) {
5720
5735
  const persisted = value.executionSnapshot || value;
5721
- return Codec.normalizeSnapshot(persisted, { source: persisted.source || "submitted" });
5736
+ return Codec.normalizeSnapshot(persisted, {
5737
+ source: persisted.source || "submitted",
5738
+ migrateLegacyConfirm: true
5739
+ });
5722
5740
  }
5723
5741
  function cloneSnapshot(value = {}) {
5724
5742
  const snapshot = snapshotOf(value);
@@ -5836,8 +5854,20 @@ ${block}`;
5836
5854
  }).slice(0, max));
5837
5855
  }
5838
5856
  function normalizeMeta(value) {
5857
+ var revision = normalizeRevision(value && value.revision);
5858
+ var hasDurableRevision = Boolean(value && Object.prototype.hasOwnProperty.call(value, "durableRevision"));
5859
+ var durableRevision = hasDurableRevision ? Math.min(normalizeRevision(value.durableRevision), revision) : revision;
5860
+ var pendingValue = value && value.pendingCommit;
5861
+ var pendingRevision = normalizeRevision(pendingValue && pendingValue.revision);
5862
+ var pendingCommit = pendingValue && typeof pendingValue === "object" && pendingRevision > durableRevision && pendingRevision <= revision ? {
5863
+ revision: pendingRevision,
5864
+ writerId: cleanPart(pendingValue.writerId),
5865
+ startedAt: cleanPart(pendingValue.startedAt)
5866
+ } : null;
5839
5867
  return {
5840
- revision: normalizeRevision(value && value.revision),
5868
+ revision,
5869
+ durableRevision,
5870
+ pendingCommit,
5841
5871
  queueRevision: normalizeRevision(value && value.queueRevision),
5842
5872
  writerId: cleanPart(value && value.writerId),
5843
5873
  updatedAt: cleanPart(value && value.updatedAt),
@@ -6046,19 +6076,78 @@ ${block}`;
6046
6076
  });
6047
6077
  }).call(globalThis, void 0, void 0, void 0);
6048
6078
  (function runClassicContentModule18(module, exports, require2) {
6079
+ (function(root, factory) {
6080
+ if (typeof module === "object" && module.exports) {
6081
+ module.exports = factory();
6082
+ } else {
6083
+ root.CodexOverleafModuleRegistry.define("ScopedPersistenceReceipt", [], factory);
6084
+ }
6085
+ })(typeof globalThis !== "undefined" ? globalThis : this, function() {
6086
+ "use strict";
6087
+ function createFenceMeta(meta, currentMeta, writerId) {
6088
+ var startedAt = (/* @__PURE__ */ new Date()).toISOString();
6089
+ var revision = currentMeta.revision + 1;
6090
+ return {
6091
+ ...meta,
6092
+ revision,
6093
+ durableRevision: currentMeta.durableRevision,
6094
+ pendingCommit: { revision, writerId, startedAt },
6095
+ writerId,
6096
+ updatedAt: startedAt
6097
+ };
6098
+ }
6099
+ function createCommittedMeta(fenceMeta) {
6100
+ return {
6101
+ ...fenceMeta,
6102
+ durableRevision: fenceMeta.revision,
6103
+ pendingCommit: null,
6104
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
6105
+ };
6106
+ }
6107
+ function createRecoveredMeta(currentMeta, fenceMeta, writerId) {
6108
+ var revision = fenceMeta.revision + 1;
6109
+ return {
6110
+ ...currentMeta,
6111
+ revision,
6112
+ durableRevision: revision,
6113
+ pendingCommit: null,
6114
+ queueRevision: fenceMeta.queueRevision + 1,
6115
+ writerId,
6116
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
6117
+ };
6118
+ }
6119
+ function decorateReceiptError(error, revision) {
6120
+ if (error && typeof error === "object") {
6121
+ error.code = error.code || "persistence_receipt_write_failed";
6122
+ error.persistenceActionCommitted = true;
6123
+ error.persistenceRevision = revision;
6124
+ }
6125
+ return error;
6126
+ }
6127
+ return Object.freeze({
6128
+ createFenceMeta,
6129
+ createCommittedMeta,
6130
+ createRecoveredMeta,
6131
+ decorateReceiptError
6132
+ });
6133
+ });
6134
+ }).call(globalThis, void 0, void 0, void 0);
6135
+ (function runClassicContentModule19(module, exports, require2) {
6049
6136
  (function(root, factory) {
6050
6137
  if (typeof module === "object" && module.exports) {
6051
6138
  module.exports = factory(
6052
6139
  require2("./scopedPersistenceQueuePolicy"),
6053
- require2("./scopedPersistenceBrowserAdapter")
6140
+ require2("./scopedPersistenceBrowserAdapter"),
6141
+ require2("./scopedPersistenceReceipt")
6054
6142
  );
6055
6143
  } else {
6056
6144
  root.CodexOverleafModuleRegistry.define("ScopedPersistenceTransaction", [
6057
6145
  "ScopedPersistenceQueuePolicy",
6058
- "ScopedPersistenceBrowserAdapter"
6146
+ "ScopedPersistenceBrowserAdapter",
6147
+ "ScopedPersistenceReceipt"
6059
6148
  ], factory);
6060
6149
  }
6061
- })(typeof globalThis !== "undefined" ? globalThis : this, function(QueuePolicy, BrowserAdapter) {
6150
+ })(typeof globalThis !== "undefined" ? globalThis : this, function(QueuePolicy, BrowserAdapter, Receipt) {
6062
6151
  "use strict";
6063
6152
  var applyQueueMutations = QueuePolicy.applyQueueMutations;
6064
6153
  var cleanPart = QueuePolicy.cleanPart;
@@ -6084,9 +6173,9 @@ ${block}`;
6084
6173
  var scope = normalizeScope(inputScope);
6085
6174
  generation += 1;
6086
6175
  var tokenGeneration = generation;
6087
- active = makeToken(scope, tokenGeneration, 0, false, 0);
6176
+ active = tokenFromMeta(scope, tokenGeneration, false, {});
6088
6177
  var meta = await strictRead(adapter, scope);
6089
- var token = makeToken(scope, tokenGeneration, meta.revision, false, meta.queueRevision);
6178
+ var token = tokenFromMeta(scope, tokenGeneration, false, meta);
6090
6179
  if (active && active.generation === tokenGeneration && sameScope(active, token)) active = token;
6091
6180
  return token;
6092
6181
  }
@@ -6100,10 +6189,10 @@ ${block}`;
6100
6189
  });
6101
6190
  }
6102
6191
  if (!detached && active && sameScope(active, scope)) {
6103
- return makeToken(scope, active.generation, active.revision, false, active.queueRevision);
6192
+ return tokenFromMeta(scope, active.generation, false, active);
6104
6193
  }
6105
6194
  var meta = await strictRead(adapter, scope);
6106
- return makeToken(scope, detached ? 0 : generation, meta.revision, detached, meta.queueRevision);
6195
+ return tokenFromMeta(scope, detached ? 0 : generation, detached, meta);
6107
6196
  }
6108
6197
  function isCurrent(token) {
6109
6198
  return Boolean(token && active && token.detached !== true && token.generation === active.generation && sameScope(token, active));
@@ -6130,13 +6219,7 @@ ${block}`;
6130
6219
  var queueMutations = normalizeQueueMutations(commitOptions);
6131
6220
  if (queueMutations.length && currentMeta.queueRevision !== normalizeRevision(token.queueRevision)) {
6132
6221
  if (!token.detached && isCurrent(token)) {
6133
- active = makeToken(
6134
- scope,
6135
- token.generation,
6136
- currentMeta.revision,
6137
- false,
6138
- currentMeta.queueRevision
6139
- );
6222
+ active = tokenFromMeta(scope, token.generation, false, currentMeta);
6140
6223
  }
6141
6224
  return {
6142
6225
  ok: false,
@@ -6148,33 +6231,26 @@ ${block}`;
6148
6231
  }
6149
6232
  var projected = applyQueueMutations(currentMeta, queueMutations, writerId);
6150
6233
  if (!projected.ok) return projected;
6151
- var nextMeta = {
6234
+ var nextMeta = Receipt.createFenceMeta({
6152
6235
  ...projected.meta,
6153
- revision: currentMeta.revision + 1,
6154
- writerId,
6155
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
6156
6236
  sessionTombstones: mergeTombstones(
6157
6237
  projected.meta.sessionTombstones,
6158
6238
  commitOptions && commitOptions.sessionTombstones,
6159
6239
  200
6160
6240
  )
6161
- };
6241
+ }, currentMeta, writerId);
6162
6242
  await adapter.write(scope, nextMeta);
6163
6243
  if (!token.detached && isCurrent(token)) {
6164
- active = makeToken(
6165
- scope,
6166
- token.generation,
6167
- nextMeta.revision,
6168
- false,
6169
- nextMeta.queueRevision
6170
- );
6244
+ active = tokenFromMeta(scope, token.generation, false, nextMeta);
6171
6245
  }
6172
6246
  var value;
6173
6247
  try {
6174
6248
  value = await action({
6175
6249
  scope,
6176
6250
  baseRevision: currentMeta.revision,
6251
+ durableRevision: currentMeta.durableRevision,
6177
6252
  conflict,
6253
+ previousCommitIncomplete: Boolean(currentMeta.pendingCommit),
6178
6254
  writerId,
6179
6255
  currentMeta,
6180
6256
  nextMeta
@@ -6183,23 +6259,11 @@ ${block}`;
6183
6259
  if (queueMutations.some(function(mutation) {
6184
6260
  return ["remove", "release", "restore"].includes(cleanPart(mutation.type));
6185
6261
  })) {
6186
- var recoveredMeta = {
6187
- ...currentMeta,
6188
- revision: nextMeta.revision + 1,
6189
- queueRevision: nextMeta.queueRevision + 1,
6190
- writerId,
6191
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
6192
- };
6262
+ var recoveredMeta = Receipt.createRecoveredMeta(currentMeta, nextMeta, writerId);
6193
6263
  try {
6194
6264
  await adapter.write(scope, recoveredMeta);
6195
6265
  if (!token.detached && isCurrent(token)) {
6196
- active = makeToken(
6197
- scope,
6198
- token.generation,
6199
- recoveredMeta.revision,
6200
- false,
6201
- recoveredMeta.queueRevision
6202
- );
6266
+ active = tokenFromMeta(scope, token.generation, false, recoveredMeta);
6203
6267
  }
6204
6268
  } catch (recoveryError) {
6205
6269
  if (error && typeof error === "object") {
@@ -6209,13 +6273,24 @@ ${block}`;
6209
6273
  }
6210
6274
  throw error;
6211
6275
  }
6276
+ var committedMeta = Receipt.createCommittedMeta(nextMeta);
6277
+ try {
6278
+ await adapter.write(scope, committedMeta);
6279
+ } catch (error) {
6280
+ throw Receipt.decorateReceiptError(error, nextMeta.revision);
6281
+ }
6282
+ if (!token.detached && isCurrent(token)) {
6283
+ active = tokenFromMeta(scope, token.generation, false, committedMeta);
6284
+ }
6212
6285
  return {
6213
6286
  ok: true,
6214
6287
  value,
6215
- revision: nextMeta.revision,
6216
- queueRevision: nextMeta.queueRevision,
6217
- queueClaims: nextMeta.queueClaims,
6288
+ revision: committedMeta.revision,
6289
+ durableRevision: committedMeta.durableRevision,
6290
+ queueRevision: committedMeta.queueRevision,
6291
+ queueClaims: committedMeta.queueClaims,
6218
6292
  rebased: conflict,
6293
+ recoveredIncompleteCommit: Boolean(currentMeta.pendingCommit),
6219
6294
  superseded: !token.detached && !isCurrent(token)
6220
6295
  };
6221
6296
  });
@@ -6225,7 +6300,7 @@ ${block}`;
6225
6300
  captureCommitView,
6226
6301
  commit,
6227
6302
  getActiveView: function() {
6228
- return active ? makeToken(active, active.generation, active.revision, false, active.queueRevision) : null;
6303
+ return active ? tokenFromMeta(active, active.generation, false, active) : null;
6229
6304
  },
6230
6305
  getWriterId: function() {
6231
6306
  return writerId;
@@ -6237,16 +6312,29 @@ ${block}`;
6237
6312
  isCurrent
6238
6313
  });
6239
6314
  }
6240
- function makeToken(scope, tokenGeneration, revision, detached, queueRevision) {
6315
+ function makeToken(scope, tokenGeneration, revision, detached, queueRevision, durableRevision, pendingCommit) {
6241
6316
  return Object.freeze({
6242
6317
  accountScopeId: scope.accountScopeId,
6243
6318
  projectId: scope.projectId,
6244
6319
  generation: normalizeRevision(tokenGeneration),
6245
6320
  revision: normalizeRevision(revision),
6321
+ durableRevision: normalizeRevision(durableRevision),
6322
+ pendingCommit: pendingCommit && typeof pendingCommit === "object" ? Object.freeze({ ...pendingCommit }) : null,
6246
6323
  queueRevision: normalizeRevision(queueRevision),
6247
6324
  detached: detached === true
6248
6325
  });
6249
6326
  }
6327
+ function tokenFromMeta(scope, tokenGeneration, detached, meta) {
6328
+ return makeToken(
6329
+ scope,
6330
+ tokenGeneration,
6331
+ meta.revision,
6332
+ detached,
6333
+ meta.queueRevision,
6334
+ meta.durableRevision,
6335
+ meta.pendingCommit
6336
+ );
6337
+ }
6250
6338
  async function strictRead(adapter, scope) {
6251
6339
  return normalizeMeta(await adapter.read(scope));
6252
6340
  }
@@ -6268,7 +6356,7 @@ ${block}`;
6268
6356
  });
6269
6357
  });
6270
6358
  }).call(globalThis, void 0, void 0, void 0);
6271
- (function runClassicContentModule19(module, exports, require2) {
6359
+ (function runClassicContentModule20(module, exports, require2) {
6272
6360
  (function initCodexOverleafRunInputQueue(root, factory) {
6273
6361
  if (typeof module === "object" && module.exports) {
6274
6362
  module.exports = factory(require2("./runExecutionSnapshot"));
@@ -6538,7 +6626,7 @@ ${block}`;
6538
6626
  };
6539
6627
  });
6540
6628
  }).call(globalThis, void 0, void 0, void 0);
6541
- (function runClassicContentModule20(module, exports, require2) {
6629
+ (function runClassicContentModule21(module, exports, require2) {
6542
6630
  (function initCodexOverleafSettlementFacts(root, factory) {
6543
6631
  if (typeof module === "object" && module.exports) {
6544
6632
  module.exports = factory(require2("./failureReasons"));
@@ -6830,7 +6918,7 @@ ${block}`;
6830
6918
  };
6831
6919
  });
6832
6920
  }).call(globalThis, void 0, void 0, void 0);
6833
- (function runClassicContentModule21(module, exports, require2) {
6921
+ (function runClassicContentModule22(module, exports, require2) {
6834
6922
  (function initCodexOverleafWritebackEvidenceProjection(root, factory) {
6835
6923
  const api = factory();
6836
6924
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -6963,7 +7051,7 @@ ${block}`;
6963
7051
  });
6964
7052
  });
6965
7053
  }).call(globalThis, void 0, void 0, void 0);
6966
- (function runClassicContentModule22(module, exports, require2) {
7054
+ (function runClassicContentModule23(module, exports, require2) {
6967
7055
  (function initCodexOverleafWritebackOperationEvidence(root, factory) {
6968
7056
  if (typeof module === "object" && module.exports) {
6969
7057
  module.exports = factory();
@@ -7068,12 +7156,22 @@ ${block}`;
7068
7156
  };
7069
7157
  }
7070
7158
  function normalizeTrackedChanges(value) {
7071
- return (Array.isArray(value) ? value : []).map((item) => ({
7072
- key: normalizeText(item?.key),
7073
- id: normalizeText(item?.id),
7074
- path: normalizeText(item?.path),
7075
- label: normalizeText(item?.label)
7076
- })).filter((item) => item.key || item.id || item.path);
7159
+ const normalized = [];
7160
+ const seen = /* @__PURE__ */ new Set();
7161
+ for (const item of Array.isArray(value) ? value : []) {
7162
+ const change = {
7163
+ key: normalizeText(item?.key),
7164
+ id: normalizeText(item?.id),
7165
+ path: normalizeText(item?.path),
7166
+ label: normalizeText(item?.label)
7167
+ };
7168
+ if (!change.key && !change.id && !change.path) continue;
7169
+ const identity = `${change.path}\0${change.key || change.id || "path-only"}`;
7170
+ if (seen.has(identity)) continue;
7171
+ seen.add(identity);
7172
+ normalized.push(change);
7173
+ }
7174
+ return normalized;
7077
7175
  }
7078
7176
  function normalizeStringArray(value) {
7079
7177
  return (Array.isArray(value) ? value : []).map(normalizeText).filter(Boolean);
@@ -7092,7 +7190,7 @@ ${block}`;
7092
7190
  };
7093
7191
  });
7094
7192
  }).call(globalThis, void 0, void 0, void 0);
7095
- (function runClassicContentModule23(module, exports, require2) {
7193
+ (function runClassicContentModule24(module, exports, require2) {
7096
7194
  (function initCodexOverleafWritebackSettlement(root, factory) {
7097
7195
  if (typeof module === "object" && module.exports) {
7098
7196
  module.exports = factory(
@@ -7351,7 +7449,8 @@ ${block}`;
7351
7449
  }
7352
7450
  const successful = isSuccessfulTrackedChangeSettlement(input.result);
7353
7451
  const reviewCodes = kind === "accept" ? ACCEPT_NEEDS_REVIEW_CODES : REJECT_NEEDS_REVIEW_CODES;
7354
- const needsReview = !successful && failures.some(
7452
+ const incompleteReject = kind === "reject" && collectRunResultSkipped(input.result).length > 0;
7453
+ const needsReview = incompleteReject || !successful && failures.some(
7355
7454
  (failure) => failure.terminalState === "needs_review" || reviewCodes.has(failure.code)
7356
7455
  );
7357
7456
  const status = needsReview ? "needs_review" : kind === "accept" ? "accepted" : "rejected";
@@ -7610,7 +7709,7 @@ ${block}`;
7610
7709
  if (!operation || typeof operation !== "object") return operation;
7611
7710
  return operation.type === "edit" && typeof result?.verifiedContent === "string" ? { ...operation, verifiedContent: result.verifiedContent } : operation;
7612
7711
  }
7613
- function selectExpectedFilesForTrackedUndo(project, operations = [], trackedChanges = []) {
7712
+ function selectExpectedFilesForTrackedUndo(project, operations = [], trackedChanges = [], previousExpectedFiles = []) {
7614
7713
  const paths = /* @__PURE__ */ new Set();
7615
7714
  for (const change of trackedChanges || []) {
7616
7715
  if (change?.path) paths.add(change.path);
@@ -7619,7 +7718,18 @@ ${block}`;
7619
7718
  if (operation?.path) paths.add(operation.path);
7620
7719
  if (operation?.to) paths.add(operation.to);
7621
7720
  }
7622
- return (project?.files || []).filter((file) => paths.has(file.path) && typeof file.content === "string").map((file) => ({ path: file.path, content: file.content }));
7721
+ const expectedByPath = /* @__PURE__ */ new Map();
7722
+ for (const file of previousExpectedFiles || []) {
7723
+ if (paths.has(file?.path) && typeof file?.content === "string" && !expectedByPath.has(file.path)) {
7724
+ expectedByPath.set(file.path, { path: file.path, content: file.content });
7725
+ }
7726
+ }
7727
+ for (const file of project?.files || []) {
7728
+ if (paths.has(file?.path) && typeof file?.content === "string" && !expectedByPath.has(file.path)) {
7729
+ expectedByPath.set(file.path, { path: file.path, content: file.content });
7730
+ }
7731
+ }
7732
+ return Array.from(expectedByPath.values());
7623
7733
  }
7624
7734
  function acceptDiagnosticStatus(step, info) {
7625
7735
  if (step === "modeBefore" || step === "replayStart") return "info";
@@ -7703,7 +7813,7 @@ ${block}`;
7703
7813
  };
7704
7814
  });
7705
7815
  }).call(globalThis, void 0, void 0, void 0);
7706
- (function runClassicContentModule24(module, exports, require2) {
7816
+ (function runClassicContentModule25(module, exports, require2) {
7707
7817
  (function initSessionState(root, factory) {
7708
7818
  if (typeof module === "object" && module.exports) {
7709
7819
  module.exports = factory(
@@ -7723,7 +7833,7 @@ ${block}`;
7723
7833
  })(typeof globalThis !== "undefined" ? globalThis : window, function sessionStateFactory(i18n, SettlementFacts, RunInputQueue, LineReferences, PathRedaction) {
7724
7834
  "use strict";
7725
7835
  const DEFAULT_PANEL_STATE = {
7726
- mode: "confirm",
7836
+ mode: "ask",
7727
7837
  providerId: "builtin",
7728
7838
  model: "gpt-5.4",
7729
7839
  reasoningEffort: "high",
@@ -7745,7 +7855,7 @@ ${block}`;
7745
7855
  activeSessionId: "",
7746
7856
  customInstructionsByProject: {}
7747
7857
  };
7748
- const VALID_MODES = /* @__PURE__ */ new Set(["ask", "confirm", "auto"]);
7858
+ const VALID_MODES = /* @__PURE__ */ new Set(["ask", "auto"]);
7749
7859
  const VALID_REASONING = /* @__PURE__ */ new Set(["none", "minimal", "low", "medium", "high", "xhigh"]);
7750
7860
  const VALID_SPEED_TIERS = /* @__PURE__ */ new Set(["standard", "fast"]);
7751
7861
  const VALID_LOCALES = /* @__PURE__ */ new Set(["en", "zh"]);
@@ -7814,9 +7924,7 @@ ${block}`;
7814
7924
  ...DEFAULT_PANEL_STATE,
7815
7925
  ...input
7816
7926
  };
7817
- if (!VALID_MODES.has(state.mode)) {
7818
- state.mode = DEFAULT_PANEL_STATE.mode;
7819
- }
7927
+ state.mode = normalizeMode(state.mode);
7820
7928
  if (!VALID_REASONING.has(state.reasoningEffort)) {
7821
7929
  state.reasoningEffort = DEFAULT_PANEL_STATE.reasoningEffort;
7822
7930
  }
@@ -7892,13 +8000,14 @@ ${block}`;
7892
8000
  history,
7893
8001
  runs,
7894
8002
  task: sanitizeAssistantVisibleText(session.task),
7895
- mode: VALID_MODES.has(session.mode) ? session.mode : fallbackState.mode,
8003
+ mode: normalizeMode(session.mode, fallbackState.mode),
7896
8004
  providerId: typeof session.providerId === "string" && session.providerId.trim() ? session.providerId.trim() : fallbackState.providerId || "builtin",
7897
8005
  model: typeof session.model === "string" && session.model ? session.model : fallbackState.model,
7898
8006
  reasoningEffort: VALID_REASONING.has(session.reasoningEffort) ? session.reasoningEffort : fallbackState.reasoningEffort,
7899
8007
  speedTier: VALID_SPEED_TIERS.has(session.speedTier) ? session.speedTier : fallbackState.speedTier,
7900
8008
  requireReviewing: session.requireReviewing !== false,
7901
8009
  focusFiles: normalizeFocusFiles(session.focusFiles),
8010
+ projectReferenceFiles: normalizeProjectReferenceFiles(session.projectReferenceFiles),
7902
8011
  codexThreadId: typeof session.codexThreadId === "string" ? session.codexThreadId : "",
7903
8012
  pendingInputs: normalizePendingInputs(
7904
8013
  session.pendingInputs,
@@ -7968,13 +8077,14 @@ ${block}`;
7968
8077
  id: active.id,
7969
8078
  history: Array.isArray(active.history) ? active.history.slice(-10) : [],
7970
8079
  focusFiles: normalizeFocusFiles(active.focusFiles),
8080
+ projectReferenceFiles: normalizeProjectReferenceFiles(active.projectReferenceFiles),
7971
8081
  codexThreadId: active.codexThreadId || "",
7972
8082
  providerId: state.providerId || "builtin"
7973
8083
  };
7974
8084
  state.runs = Array.isArray(active.runs) ? active.runs : [];
7975
8085
  state.task = typeof active.task === "string" ? active.task : "";
7976
8086
  state.focusFiles = normalizeFocusFiles(active.focusFiles);
7977
- state.mode = VALID_MODES.has(active.mode) ? active.mode : DEFAULT_PANEL_STATE.mode;
8087
+ state.mode = normalizeMode(active.mode);
7978
8088
  state.requireReviewing = active.requireReviewing !== false;
7979
8089
  return state;
7980
8090
  }
@@ -7992,13 +8102,14 @@ ${block}`;
7992
8102
  history: normalizeHistoryEntries(overrides.history),
7993
8103
  runs,
7994
8104
  task: sanitizeAssistantVisibleText(overrides.task),
7995
- mode: VALID_MODES.has(overrides.mode) ? overrides.mode : DEFAULT_PANEL_STATE.mode,
8105
+ mode: normalizeMode(overrides.mode),
7996
8106
  providerId: typeof overrides.providerId === "string" && overrides.providerId.trim() ? overrides.providerId.trim() : "builtin",
7997
8107
  model: typeof overrides.model === "string" && overrides.model ? overrides.model : DEFAULT_PANEL_STATE.model,
7998
8108
  reasoningEffort: VALID_REASONING.has(overrides.reasoningEffort) ? overrides.reasoningEffort : DEFAULT_PANEL_STATE.reasoningEffort,
7999
8109
  speedTier: VALID_SPEED_TIERS.has(overrides.speedTier) ? overrides.speedTier : DEFAULT_PANEL_STATE.speedTier,
8000
8110
  requireReviewing: overrides.requireReviewing !== false,
8001
8111
  focusFiles: normalizeFocusFiles(overrides.focusFiles),
8112
+ projectReferenceFiles: normalizeProjectReferenceFiles(overrides.projectReferenceFiles),
8002
8113
  codexThreadId: typeof overrides.codexThreadId === "string" ? overrides.codexThreadId : "",
8003
8114
  pendingInputs: normalizePendingInputs(overrides.pendingInputs)
8004
8115
  };
@@ -8418,6 +8529,32 @@ ${block}`;
8418
8529
  }
8419
8530
  return files.slice(0, 5);
8420
8531
  }
8532
+ function normalizeProjectReferenceFiles(value) {
8533
+ const seen = /* @__PURE__ */ new Set();
8534
+ const files = [];
8535
+ for (const item of Array.isArray(value) ? value : []) {
8536
+ const rawPath = typeof item === "string" ? item : item?.path;
8537
+ if (typeof rawPath !== "string" || !rawPath.trim() || rawPath.length > 512) {
8538
+ continue;
8539
+ }
8540
+ if (/^(?:[A-Za-z]:|[\\/])/.test(rawPath) || rawPath.includes("\0")) {
8541
+ continue;
8542
+ }
8543
+ const path = rawPath.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\.\//, "").trim();
8544
+ if (!path || path.split("/").some((segment) => !segment || segment === "." || segment === "..") || seen.has(path)) {
8545
+ continue;
8546
+ }
8547
+ seen.add(path);
8548
+ files.push({
8549
+ path,
8550
+ kind: item?.kind === "binary" ? "binary" : "text"
8551
+ });
8552
+ if (files.length >= 5e3) {
8553
+ break;
8554
+ }
8555
+ }
8556
+ return files;
8557
+ }
8421
8558
  function normalizeCustomInstructionsByProject(value) {
8422
8559
  const result = {};
8423
8560
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -8491,7 +8628,7 @@ ${block}`;
8491
8628
  // Skills page was reopened.
8492
8629
  codexOverleafSkills: compactCodexOverleafSkillsForStorage(source.codexOverleafSkills),
8493
8630
  composerAttachments: normalizeComposerAttachmentsForPersistence(source.composerAttachments),
8494
- mode: VALID_MODES.has(active?.mode) ? active.mode : normalizeMode(source.mode),
8631
+ mode: normalizeMode(active?.mode, source.mode),
8495
8632
  providerId: typeof source.providerId === "string" && source.providerId.trim() ? source.providerId.trim() : "builtin",
8496
8633
  model: normalizeTextField(source.model || DEFAULT_PANEL_STATE.model, 80),
8497
8634
  reasoningEffort: VALID_REASONING.has(source.reasoningEffort) ? source.reasoningEffort : normalizeReasoning(source.reasoningEffort),
@@ -8578,6 +8715,7 @@ ${block}`;
8578
8715
  speedTier: normalizeSpeedTier(session.speedTier || fallbackState.speedTier),
8579
8716
  requireReviewing: session.requireReviewing !== false,
8580
8717
  focusFiles: normalizeFocusFiles(session.focusFiles),
8718
+ projectReferenceFiles: normalizeProjectReferenceFiles(session.projectReferenceFiles),
8581
8719
  codexThreadId: typeof session.codexThreadId === "string" ? session.codexThreadId : "",
8582
8720
  pendingInputs: normalizePendingInputs(session.pendingInputs)
8583
8721
  };
@@ -8785,8 +8923,14 @@ ${block}`;
8785
8923
  undoExpectedFiles: []
8786
8924
  };
8787
8925
  }
8788
- function normalizeMode(mode) {
8789
- return VALID_MODES.has(mode) ? mode : DEFAULT_PANEL_STATE.mode;
8926
+ function normalizeMode(mode, fallback = DEFAULT_PANEL_STATE.mode) {
8927
+ if (mode === "confirm") {
8928
+ return "ask";
8929
+ }
8930
+ if (VALID_MODES.has(mode)) {
8931
+ return mode;
8932
+ }
8933
+ return VALID_MODES.has(fallback) ? fallback : DEFAULT_PANEL_STATE.mode;
8790
8934
  }
8791
8935
  function normalizeReasoning(reasoningEffort) {
8792
8936
  return VALID_REASONING.has(reasoningEffort) ? reasoningEffort : DEFAULT_PANEL_STATE.reasoningEffort;
@@ -8980,7 +9124,7 @@ ${block}`;
8980
9124
  };
8981
9125
  });
8982
9126
  }).call(globalThis, void 0, void 0, void 0);
8983
- (function runClassicContentModule25(module, exports, require2) {
9127
+ (function runClassicContentModule26(module, exports, require2) {
8984
9128
  (function initStorageKeys(root, factory) {
8985
9129
  if (typeof module === "object" && module.exports) {
8986
9130
  module.exports = factory();
@@ -9008,7 +9152,7 @@ ${block}`;
9008
9152
  };
9009
9153
  });
9010
9154
  }).call(globalThis, void 0, void 0, void 0);
9011
- (function runClassicContentModule26(module, exports, require2) {
9155
+ (function runClassicContentModule27(module, exports, require2) {
9012
9156
  (function initStaleGuard(root, factory) {
9013
9157
  if (typeof module === "object" && module.exports) {
9014
9158
  module.exports = factory();
@@ -9159,7 +9303,7 @@ ${block}`;
9159
9303
  };
9160
9304
  });
9161
9305
  }).call(globalThis, void 0, void 0, void 0);
9162
- (function runClassicContentModule27(module, exports, require2) {
9306
+ (function runClassicContentModule28(module, exports, require2) {
9163
9307
  (function initStorageRunActions(root, factory) {
9164
9308
  if (typeof module === "object" && module.exports) {
9165
9309
  module.exports = factory();
@@ -9287,7 +9431,7 @@ ${block}`;
9287
9431
  };
9288
9432
  });
9289
9433
  }).call(globalThis, void 0, void 0, void 0);
9290
- (function runClassicContentModule28(module, exports, require2) {
9434
+ (function runClassicContentModule29(module, exports, require2) {
9291
9435
  (function initStorageSessionClaims(root, factory) {
9292
9436
  var api = factory();
9293
9437
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -9353,7 +9497,7 @@ ${block}`;
9353
9497
  return Object.freeze({ createSessionClaimer });
9354
9498
  });
9355
9499
  }).call(globalThis, void 0, void 0, void 0);
9356
- (function runClassicContentModule29(module, exports, require2) {
9500
+ (function runClassicContentModule30(module, exports, require2) {
9357
9501
  (function initStorageDb(root, factory) {
9358
9502
  if (typeof module === "object" && module.exports) {
9359
9503
  module.exports = factory(
@@ -9648,7 +9792,7 @@ ${block}`;
9648
9792
  history: compactHistoryForStorage(input.history),
9649
9793
  runs: compactRunsForStorage(input.runs, options2),
9650
9794
  task: normalizeDisplayTextForStorage(input.task, SESSION_STORAGE_LIMITS.taskChars),
9651
- mode: typeof input.mode === "string" ? input.mode : "",
9795
+ mode: normalizeCurrentMode(input.mode),
9652
9796
  providerId: typeof input.providerId === "string" && input.providerId ? input.providerId : "builtin",
9653
9797
  model: typeof input.model === "string" ? input.model : "",
9654
9798
  reasoningEffort: typeof input.reasoningEffort === "string" ? input.reasoningEffort : "",
@@ -9779,6 +9923,9 @@ ${block}`;
9779
9923
  saveVerification: input.saveVerification && typeof input.saveVerification === "object" ? summarizeVerificationObject(input.saveVerification) : null
9780
9924
  };
9781
9925
  }
9926
+ function normalizeCurrentMode(mode) {
9927
+ return mode === "auto" ? "auto" : "ask";
9928
+ }
9782
9929
  function extractLightweightPrefs(state, projectId) {
9783
9930
  var prefs = {
9784
9931
  storageSchemaVersion: TARGET_SCHEMA_VERSION,
@@ -9786,7 +9933,7 @@ ${block}`;
9786
9933
  model: typeof state.model === "string" ? state.model : "",
9787
9934
  reasoningEffort: typeof state.reasoningEffort === "string" ? state.reasoningEffort : "",
9788
9935
  speedTier: typeof state.speedTier === "string" ? state.speedTier : "",
9789
- mode: typeof state.mode === "string" ? state.mode : "",
9936
+ mode: normalizeCurrentMode(state.mode),
9790
9937
  locale: typeof state.locale === "string" ? state.locale : "",
9791
9938
  requireReviewing: state.requireReviewing !== false,
9792
9939
  autoRecompile: state.autoRecompile !== false,
@@ -10574,7 +10721,7 @@ ${block}`;
10574
10721
  };
10575
10722
  });
10576
10723
  }).call(globalThis, void 0, void 0, void 0);
10577
- (function runClassicContentModule30(module, exports, require2) {
10724
+ (function runClassicContentModule31(module, exports, require2) {
10578
10725
  (function initStorageMigration(root, factory) {
10579
10726
  if (typeof module === "object" && module.exports) {
10580
10727
  module.exports = factory(require2("./storageDb"));
@@ -11029,7 +11176,7 @@ ${block}`;
11029
11176
  };
11030
11177
  });
11031
11178
  }).call(globalThis, void 0, void 0, void 0);
11032
- (function runClassicContentModule31(module, exports, require2) {
11179
+ (function runClassicContentModule32(module, exports, require2) {
11033
11180
  (function initCompileAdapter(root, factory) {
11034
11181
  if (typeof module === "object" && module.exports) {
11035
11182
  module.exports = factory();
@@ -11172,7 +11319,7 @@ ${block}`;
11172
11319
  };
11173
11320
  });
11174
11321
  }).call(globalThis, void 0, void 0, void 0);
11175
- (function runClassicContentModule32(module, exports, require2) {
11322
+ (function runClassicContentModule33(module, exports, require2) {
11176
11323
  (function initCodexOverleafCompatibility(root, factory) {
11177
11324
  if (typeof module === "object" && module.exports) {
11178
11325
  module.exports = factory();
@@ -11186,7 +11333,7 @@ ${block}`;
11186
11333
  const MIN_NATIVE_VERSION = "1.0.0";
11187
11334
  const MIN_COMPATIBLE_NATIVE_VERSION = "1.0.0";
11188
11335
  const MIN_COMPATIBLE_EXTENSION_VERSION = "1.0.0";
11189
- const BUILD_TARGET_VERSION = "2.3.0";
11336
+ const BUILD_TARGET_VERSION = "2.3.1";
11190
11337
  const DEFAULT_CHROME_EXTENSION_ID = "illdpneeeopfffmiepaejglgmhpmdhdc";
11191
11338
  const REQUIRED_CAPABILITIES = Object.freeze([
11192
11339
  "bridgePing",
@@ -11480,14 +11627,14 @@ ${block}`;
11480
11627
  };
11481
11628
  });
11482
11629
  }).call(globalThis, void 0, void 0, void 0);
11483
- (function runClassicContentModule33(module, exports, require2) {
11630
+ (function runClassicContentModule34(module, exports, require2) {
11484
11631
  (function(root, factory) {
11485
11632
  var api = factory();
11486
11633
  if (typeof module === "object" && module.exports) module.exports = api;
11487
11634
  if (root) root.CodexOverleafPageRpcContract = api;
11488
11635
  })(typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : this, function() {
11489
11636
  "use strict";
11490
- var REVISION = "2026-07-26-page-rpc-contract-v13";
11637
+ var REVISION = "2026-07-31-page-rpc-contract-v14";
11491
11638
  var METHODS = freezeCatalog({
11492
11639
  initializeCapability: entry("bridge.initialize", "control", "none", "default", false, "none"),
11493
11640
  probe: entry("bridge.probe", "read", "none", "default", false, "safe"),
@@ -11543,7 +11690,7 @@ ${block}`;
11543
11690
  file_list: 35e3,
11544
11691
  compile: 75e3,
11545
11692
  lifecycle: 12e4,
11546
- writeback: 3e4
11693
+ writeback: 45e3
11547
11694
  };
11548
11695
  var candidate = Number(overrides[timeoutClass]);
11549
11696
  return Number.isFinite(candidate) && candidate > 0 ? candidate : defaults[timeoutClass];
@@ -11607,7 +11754,7 @@ ${block}`;
11607
11754
  });
11608
11755
  });
11609
11756
  }).call(globalThis, void 0, void 0, void 0);
11610
- (function runClassicContentModule34(module, exports, require2) {
11757
+ (function runClassicContentModule35(module, exports, require2) {
11611
11758
  (function initCodexOverleafManagedUpdateProjection(root) {
11612
11759
  "use strict";
11613
11760
  const PHASE_ALIASES = Object.freeze({
@@ -11913,7 +12060,7 @@ ${block}`;
11913
12060
  });
11914
12061
  })(typeof window !== "undefined" ? window : globalThis);
11915
12062
  }).call(globalThis, void 0, void 0, void 0);
11916
- (function runClassicContentModule35(module, exports, require2) {
12063
+ (function runClassicContentModule36(module, exports, require2) {
11917
12064
  (function initGovernanceRules(root, factory) {
11918
12065
  if (typeof module === "object" && module.exports) {
11919
12066
  let projectFiles = null;
@@ -12130,7 +12277,7 @@ ${block}`;
12130
12277
  };
12131
12278
  });
12132
12279
  }).call(globalThis, void 0, void 0, void 0);
12133
- (function runClassicContentModule36(module, exports, require2) {
12280
+ (function runClassicContentModule37(module, exports, require2) {
12134
12281
  (function initSensitiveScan(root, factory) {
12135
12282
  if (typeof module === "object" && module.exports) {
12136
12283
  module.exports = factory();
@@ -12240,7 +12387,7 @@ ${block}`;
12240
12387
  };
12241
12388
  });
12242
12389
  }).call(globalThis, void 0, void 0, void 0);
12243
- (function runClassicContentModule37(module, exports, require2) {
12390
+ (function runClassicContentModule38(module, exports, require2) {
12244
12391
  (function initAuditRecords(root, factory) {
12245
12392
  if (typeof module === "object" && module.exports) {
12246
12393
  module.exports = factory();
@@ -12766,7 +12913,7 @@ ${block}`;
12766
12913
  };
12767
12914
  });
12768
12915
  }).call(globalThis, void 0, void 0, void 0);
12769
- (function runClassicContentModule38(module, exports, require2) {
12916
+ (function runClassicContentModule39(module, exports, require2) {
12770
12917
  (function initCodexOverleafNativeChannel(root, factory) {
12771
12918
  if (typeof module === "object" && module.exports) {
12772
12919
  module.exports = factory();
@@ -12845,7 +12992,7 @@ ${block}`;
12845
12992
  };
12846
12993
  });
12847
12994
  }).call(globalThis, void 0, void 0, void 0);
12848
- (function runClassicContentModule39(module, exports, require2) {
12995
+ (function runClassicContentModule40(module, exports, require2) {
12849
12996
  (function initCodexOverleafPageBridgeClient(root, factory) {
12850
12997
  const api = factory();
12851
12998
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -13047,7 +13194,7 @@ ${block}`;
13047
13194
  });
13048
13195
  });
13049
13196
  }).call(globalThis, void 0, void 0, void 0);
13050
- (function runClassicContentModule40(module, exports, require2) {
13197
+ (function runClassicContentModule41(module, exports, require2) {
13051
13198
  (function initCodexOverleafNativeCompatibilityController(root, factory) {
13052
13199
  const api = factory();
13053
13200
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -13272,8 +13419,8 @@ ${block}`;
13272
13419
  tip.dataset.onboardingTip = "true";
13273
13420
  tip.setAttribute("role", "status");
13274
13421
  tip.textContent = tx(
13275
- "Tip: Start with Ask mode to explore safely. Switch to Suggest to review edits before applying.",
13276
- "\u63D0\u793A\uFF1A\u5148\u7528 Ask \u6A21\u5F0F\u5B89\u5168\u63A2\u7D22\uFF1B\u9700\u8981\u4FEE\u6539\u65F6\u5207\u6362\u5230 Suggest\uFF0C\u5E94\u7528\u524D\u53EF\u5148\u5BA1\u9605\u3002"
13422
+ "Tip: Start with Ask mode to explore safely. Switch to Auto only when you want Codex to edit files.",
13423
+ "\u63D0\u793A\uFF1A\u5148\u7528 Ask \u6A21\u5F0F\u5B89\u5168\u63A2\u7D22\uFF1B\u53EA\u6709\u9700\u8981 Codex \u4FEE\u6539\u6587\u4EF6\u65F6\u624D\u5207\u6362\u5230 Auto\u3002"
13277
13424
  );
13278
13425
  Object.assign(tip.style, {
13279
13426
  position: "absolute",
@@ -13326,7 +13473,7 @@ ${block}`;
13326
13473
  return Object.freeze({ create });
13327
13474
  });
13328
13475
  }).call(globalThis, void 0, void 0, void 0);
13329
- (function runClassicContentModule41(module, exports, require2) {
13476
+ (function runClassicContentModule42(module, exports, require2) {
13330
13477
  (function initCodexOverleafWritebackController(root, factory) {
13331
13478
  if (typeof module === "object" && module.exports) {
13332
13479
  module.exports = factory();
@@ -13588,7 +13735,7 @@ ${block}`;
13588
13735
  };
13589
13736
  });
13590
13737
  }).call(globalThis, void 0, void 0, void 0);
13591
- (function runClassicContentModule42(module, exports, require2) {
13738
+ (function runClassicContentModule43(module, exports, require2) {
13592
13739
  (function initCodexOverleafReviewHunks(root, factory) {
13593
13740
  if (typeof module === "object" && module.exports) {
13594
13741
  module.exports = factory();
@@ -13807,7 +13954,7 @@ ${block}`;
13807
13954
  };
13808
13955
  });
13809
13956
  }).call(globalThis, void 0, void 0, void 0);
13810
- (function runClassicContentModule43(module, exports, require2) {
13957
+ (function runClassicContentModule44(module, exports, require2) {
13811
13958
  (function initCodexOverleafDiffReviewPanel(root, factory) {
13812
13959
  if (typeof module === "object" && module.exports) {
13813
13960
  module.exports = factory(require2("./reviewHunks"));
@@ -14534,7 +14681,7 @@ ${block}`;
14534
14681
  };
14535
14682
  });
14536
14683
  }).call(globalThis, void 0, void 0, void 0);
14537
- (function runClassicContentModule44(module, exports, require2) {
14684
+ (function runClassicContentModule45(module, exports, require2) {
14538
14685
  (function initCodexOverleafContextTray(root, factory) {
14539
14686
  if (typeof module === "object" && module.exports) {
14540
14687
  module.exports = factory(require2("../shared/projectFiles"));
@@ -15282,7 +15429,7 @@ ${block}`;
15282
15429
  };
15283
15430
  });
15284
15431
  }).call(globalThis, void 0, void 0, void 0);
15285
- (function runClassicContentModule45(module, exports, require2) {
15432
+ (function runClassicContentModule46(module, exports, require2) {
15286
15433
  (function initCodexOverleafLocalSkillsPanel(root, factory) {
15287
15434
  if (typeof module === "object" && module.exports) {
15288
15435
  module.exports = factory();
@@ -15513,7 +15660,7 @@ ${block}`;
15513
15660
  };
15514
15661
  });
15515
15662
  }).call(globalThis, void 0, void 0, void 0);
15516
- (function runClassicContentModule46(module, exports, require2) {
15663
+ (function runClassicContentModule47(module, exports, require2) {
15517
15664
  (function initCodexOverleafRunController(root, factory) {
15518
15665
  if (typeof module === "object" && module.exports) {
15519
15666
  module.exports = factory();
@@ -15715,7 +15862,7 @@ ${block}`;
15715
15862
  };
15716
15863
  });
15717
15864
  }).call(globalThis, void 0, void 0, void 0);
15718
- (function runClassicContentModule47(module, exports, require2) {
15865
+ (function runClassicContentModule48(module, exports, require2) {
15719
15866
  (function initCodexOverleafMirrorHealth(root, factory) {
15720
15867
  if (typeof module === "object" && module.exports) {
15721
15868
  module.exports = factory();
@@ -15799,7 +15946,7 @@ ${block}`;
15799
15946
  };
15800
15947
  });
15801
15948
  }).call(globalThis, void 0, void 0, void 0);
15802
- (function runClassicContentModule48(module, exports, require2) {
15949
+ (function runClassicContentModule49(module, exports, require2) {
15803
15950
  (function initCodexOverleafOtWarmMirrorController(root, factory) {
15804
15951
  if (typeof module === "object" && module.exports) {
15805
15952
  module.exports = factory();
@@ -15952,7 +16099,7 @@ ${block}`;
15952
16099
  };
15953
16100
  });
15954
16101
  }).call(globalThis, void 0, void 0, void 0);
15955
- (function runClassicContentModule49(module, exports, require2) {
16102
+ (function runClassicContentModule50(module, exports, require2) {
15956
16103
  (function initComposerAttachments(global) {
15957
16104
  "use strict";
15958
16105
  function createComposerAttachmentController(options2 = {}) {
@@ -16412,7 +16559,7 @@ ${block}`;
16412
16559
  };
16413
16560
  })(window);
16414
16561
  }).call(globalThis, void 0, void 0, void 0);
16415
- (function runClassicContentModule50(module, exports, require2) {
16562
+ (function runClassicContentModule51(module, exports, require2) {
16416
16563
  (function initCodexOverleafPanelRenderer() {
16417
16564
  "use strict";
16418
16565
  const ROOT_CLASS = "codex-overleaf-panel-mounted";
@@ -16732,7 +16879,7 @@ ${block}`;
16732
16879
  };
16733
16880
  })();
16734
16881
  }).call(globalThis, void 0, void 0, void 0);
16735
- (function runClassicContentModule51(module, exports, require2) {
16882
+ (function runClassicContentModule52(module, exports, require2) {
16736
16883
  (function initCodexOverleafSessionPanel() {
16737
16884
  "use strict";
16738
16885
  function create(options2 = {}) {
@@ -16968,7 +17115,7 @@ ${block}`;
16968
17115
  };
16969
17116
  })();
16970
17117
  }).call(globalThis, void 0, void 0, void 0);
16971
- (function runClassicContentModule52(module, exports, require2) {
17118
+ (function runClassicContentModule53(module, exports, require2) {
16972
17119
  (function initCodexOverleafSettingsPanel() {
16973
17120
  "use strict";
16974
17121
  function codexIcon(name) {
@@ -17483,7 +17630,7 @@ ${block}`;
17483
17630
  };
17484
17631
  })();
17485
17632
  }).call(globalThis, void 0, void 0, void 0);
17486
- (function runClassicContentModule53(module, exports, require2) {
17633
+ (function runClassicContentModule54(module, exports, require2) {
17487
17634
  (function initCodexOverleafProviderSettingsDialog() {
17488
17635
  "use strict";
17489
17636
  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";
@@ -18403,7 +18550,7 @@ ${block}`;
18403
18550
  window.CodexOverleafProviderSettingsDialog = { create, getFooterActionState };
18404
18551
  })();
18405
18552
  }).call(globalThis, void 0, void 0, void 0);
18406
- (function runClassicContentModule54(module, exports, require2) {
18553
+ (function runClassicContentModule55(module, exports, require2) {
18407
18554
  (function initCodexOverleafProjectProviderSelection() {
18408
18555
  "use strict";
18409
18556
  function create(deps = {}) {
@@ -18460,7 +18607,7 @@ ${block}`;
18460
18607
  window.CodexOverleafProjectProviderSelection = { create };
18461
18608
  })();
18462
18609
  }).call(globalThis, void 0, void 0, void 0);
18463
- (function runClassicContentModule55(module, exports, require2) {
18610
+ (function runClassicContentModule56(module, exports, require2) {
18464
18611
  (function initCodexOverleafProviderSettingsCoordinator() {
18465
18612
  "use strict";
18466
18613
  function create(options2 = {}) {
@@ -19053,7 +19200,7 @@ ${block}`;
19053
19200
  window.CodexOverleafProviderSettingsCoordinator = { create };
19054
19201
  })();
19055
19202
  }).call(globalThis, void 0, void 0, void 0);
19056
- (function runClassicContentModule56(module, exports, require2) {
19203
+ (function runClassicContentModule57(module, exports, require2) {
19057
19204
  (function initCodexOverleafSessionPersistence(root, factory) {
19058
19205
  if (typeof module === "object" && module.exports) {
19059
19206
  module.exports = factory(require2("../shared/storageMigration"));
@@ -19147,7 +19294,7 @@ ${block}`;
19147
19294
  };
19148
19295
  });
19149
19296
  }).call(globalThis, void 0, void 0, void 0);
19150
- (function runClassicContentModule57(module, exports, require2) {
19297
+ (function runClassicContentModule58(module, exports, require2) {
19151
19298
  (function(root, factory) {
19152
19299
  var api = factory();
19153
19300
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19251,7 +19398,7 @@ ${block}`;
19251
19398
  return Object.freeze({ persistPanelState });
19252
19399
  });
19253
19400
  }).call(globalThis, void 0, void 0, void 0);
19254
- (function runClassicContentModule58(module, exports, require2) {
19401
+ (function runClassicContentModule59(module, exports, require2) {
19255
19402
  (function(root, factory) {
19256
19403
  var api = factory();
19257
19404
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -19296,7 +19443,7 @@ ${block}`;
19296
19443
  return Object.freeze({ create });
19297
19444
  });
19298
19445
  }).call(globalThis, void 0, void 0, void 0);
19299
- (function runClassicContentModule59(module, exports, require2) {
19446
+ (function runClassicContentModule60(module, exports, require2) {
19300
19447
  (function(root, factory) {
19301
19448
  if (typeof module === "object" && module.exports) {
19302
19449
  module.exports = factory(
@@ -19391,7 +19538,7 @@ ${block}`;
19391
19538
  });
19392
19539
  });
19393
19540
  }).call(globalThis, void 0, void 0, void 0);
19394
- (function runClassicContentModule60(module, exports, require2) {
19541
+ (function runClassicContentModule61(module, exports, require2) {
19395
19542
  (function initCodexOverleafDiagnosticsPanel() {
19396
19543
  "use strict";
19397
19544
  function create(options2 = {}) {
@@ -19819,7 +19966,7 @@ ${block}`;
19819
19966
  };
19820
19967
  })();
19821
19968
  }).call(globalThis, void 0, void 0, void 0);
19822
- (function runClassicContentModule61(module, exports, require2) {
19969
+ (function runClassicContentModule62(module, exports, require2) {
19823
19970
  (function initCodexOverleafRunQueueScheduler(root, factory) {
19824
19971
  if (typeof module === "object" && module.exports) {
19825
19972
  module.exports = factory(require2("../shared/runInputQueue"));
@@ -20147,7 +20294,7 @@ ${block}`;
20147
20294
  return { create, createCoordinator };
20148
20295
  });
20149
20296
  }).call(globalThis, void 0, void 0, void 0);
20150
- (function runClassicContentModule62(module, exports, require2) {
20297
+ (function runClassicContentModule63(module, exports, require2) {
20151
20298
  (function initCodexOverleafActiveTurnControl(root, factory) {
20152
20299
  if (typeof module === "object" && module.exports) {
20153
20300
  module.exports = factory();
@@ -20316,7 +20463,7 @@ ${block}`;
20316
20463
  return { create };
20317
20464
  });
20318
20465
  }).call(globalThis, void 0, void 0, void 0);
20319
- (function runClassicContentModule63(module, exports, require2) {
20466
+ (function runClassicContentModule64(module, exports, require2) {
20320
20467
  (function initCodexOverleafPendingInputView(root, factory) {
20321
20468
  if (typeof module === "object" && module.exports) {
20322
20469
  module.exports = factory();
@@ -20407,7 +20554,7 @@ ${block}`;
20407
20554
  return { create };
20408
20555
  });
20409
20556
  }).call(globalThis, void 0, void 0, void 0);
20410
- (function runClassicContentModule64(module, exports, require2) {
20557
+ (function runClassicContentModule65(module, exports, require2) {
20411
20558
  (function initCodexOverleafComposerPanel() {
20412
20559
  "use strict";
20413
20560
  function create(options2 = {}) {
@@ -20437,12 +20584,10 @@ ${block}`;
20437
20584
  <span class="codex-mode-label" data-i18n="mode">Mode</span>
20438
20585
  <div class="codex-mode-switch" role="group" aria-label="Write mode">
20439
20586
  <button type="button" data-mode-choice="ask" aria-pressed="false" title="Read and analyze only. Do not write to Overleaf.">Ask</button>
20440
- <button type="button" data-mode-choice="confirm" aria-pressed="false" title="Show a change plan first, then write after approval.">Suggest</button>
20441
20587
  <button type="button" data-mode-choice="auto" aria-pressed="false" title="Write directly after authorization. Deletes still require confirmation.">Auto</button>
20442
20588
  </div>
20443
20589
  <select data-mode aria-label="Mode" hidden>
20444
20590
  <option value="ask">Ask</option>
20445
- <option value="confirm">Suggest</option>
20446
20591
  <option value="auto">Auto</option>
20447
20592
  </select>
20448
20593
  </div>
@@ -20668,7 +20813,7 @@ ${block}`;
20668
20813
  };
20669
20814
  })();
20670
20815
  }).call(globalThis, void 0, void 0, void 0);
20671
- (function runClassicContentModule65(module, exports, require2) {
20816
+ (function runClassicContentModule66(module, exports, require2) {
20672
20817
  (function initCodexOverleafTheme(root, factory) {
20673
20818
  if (typeof module === "object" && module.exports) {
20674
20819
  module.exports = factory();
@@ -20736,7 +20881,7 @@ ${block}`;
20736
20881
  };
20737
20882
  });
20738
20883
  }).call(globalThis, void 0, void 0, void 0);
20739
- (function runClassicContentModule66(module, exports, require2) {
20884
+ (function runClassicContentModule67(module, exports, require2) {
20740
20885
  !(function(e, t) {
20741
20886
  "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();
20742
20887
  })("undefined" != typeof self ? self : this, function() {
@@ -24156,7 +24301,7 @@ ${block}`;
24156
24301
  })();
24157
24302
  });
24158
24303
  }).call(globalThis, void 0, void 0, void 0);
24159
- (function runClassicContentModule67(module, exports, require2) {
24304
+ (function runClassicContentModule68(module, exports, require2) {
24160
24305
  !(function(t, e) {
24161
24306
  "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();
24162
24307
  })(this, function() {
@@ -26228,7 +26373,7 @@ ${block}`;
26228
26373
  }, Ke;
26229
26374
  });
26230
26375
  }).call(globalThis, void 0, void 0, void 0);
26231
- (function runClassicContentModule68(module, exports, require2) {
26376
+ (function runClassicContentModule69(module, exports, require2) {
26232
26377
  (function initCodexOverleafMathText(root) {
26233
26378
  "use strict";
26234
26379
  const DELIMITERS = Object.freeze([
@@ -26239,6 +26384,19 @@ ${block}`;
26239
26384
  ]);
26240
26385
  const LONG_INLINE_MATH_CHARS = 120;
26241
26386
  const COMPLEX_INLINE_MATH_CHARS = 80;
26387
+ const MAX_PROJECT_MACRO_SOURCES = 12;
26388
+ const MAX_PROJECT_MACRO_SOURCE_CHARS = 256 * 1024;
26389
+ const MAX_PROJECT_MACROS = 64;
26390
+ const MAX_MACRO_EXPANSION_CHARS = 512;
26391
+ const DEFAULT_MATH_MACROS = Object.freeze({
26392
+ "\\E": "\\mathbb{E}",
26393
+ "\\Var": "\\operatorname{Var}",
26394
+ "\\Cov": "\\operatorname{Cov}",
26395
+ "\\R": "\\mathbb{R}",
26396
+ "\\N": "\\mathbb{N}",
26397
+ "\\Z": "\\mathbb{Z}"
26398
+ });
26399
+ const UNSAFE_MACRO_PATTERN = /\\(?:href|url|includegraphics|input|include|write|openout|read|html\w*|class|style|data|def|gdef|edef|xdef|newcommand|renewcommand|providecommand|DeclareMathOperator)\b/i;
26242
26400
  function parseMathSegments(value) {
26243
26401
  const source = String(value || "");
26244
26402
  if (!source) {
@@ -26300,9 +26458,10 @@ ${block}`;
26300
26458
  searchFrom = start + delimiter.open.length;
26301
26459
  continue;
26302
26460
  }
26303
- const value = source.slice(start + delimiter.open.length, closeStart);
26461
+ const rawValue = source.slice(start + delimiter.open.length, closeStart);
26462
+ const value = rawValue.trim();
26304
26463
  const end = closeStart + delimiter.close.length;
26305
- if (!isValidMathValue(value, delimiter) || overlapsCodeRange(start, end, codeRanges)) {
26464
+ if (!isValidMathValue(rawValue, delimiter) || overlapsCodeRange(start, end, codeRanges)) {
26306
26465
  searchFrom = start + delimiter.open.length;
26307
26466
  continue;
26308
26467
  }
@@ -26319,7 +26478,7 @@ ${block}`;
26319
26478
  }
26320
26479
  const previous = source[index - 1] || "";
26321
26480
  const next = source[index + 1] || "";
26322
- return previous !== "$" && next !== "$" && next !== "" && !/\s/.test(next);
26481
+ return previous !== "$" && next !== "$" && next !== "";
26323
26482
  }
26324
26483
  function findClosingDelimiter(source, fromIndex, delimiter, codeRanges) {
26325
26484
  let searchFrom = fromIndex;
@@ -26330,7 +26489,7 @@ ${block}`;
26330
26489
  }
26331
26490
  const previous = source[index - 1] || "";
26332
26491
  const next = source[index + delimiter.close.length] || "";
26333
- const invalidSingleDollar = delimiter.singleDollar && (previous === "$" || next === "$" || /\s/.test(previous));
26492
+ const invalidSingleDollar = delimiter.singleDollar && (previous === "$" || next === "$");
26334
26493
  if (!isEscaped(source, index) && !isInsideRange(index, codeRanges) && !invalidSingleDollar) {
26335
26494
  return index;
26336
26495
  }
@@ -26340,10 +26499,21 @@ ${block}`;
26340
26499
  }
26341
26500
  function isValidMathValue(value, delimiter) {
26342
26501
  const source = String(value || "");
26343
- if (!source.trim()) {
26502
+ const trimmed = source.trim();
26503
+ if (!trimmed) {
26344
26504
  return false;
26345
26505
  }
26346
- return delimiter.display || !/[\r\n]/.test(source);
26506
+ if (!delimiter.display && /[\r\n]/.test(source)) {
26507
+ return false;
26508
+ }
26509
+ if (!delimiter.singleDollar || !/^\s/.test(source) && !/\s$/.test(source)) {
26510
+ return true;
26511
+ }
26512
+ return looksLikeWhitespaceWrappedMath(trimmed);
26513
+ }
26514
+ function looksLikeWhitespaceWrappedMath(value) {
26515
+ const source = String(value || "").trim();
26516
+ return /\\[A-Za-z]+/.test(source) || /[_^=<>+\-*/()[\]{}|]/.test(source) || /^[A-Za-z](?:_[A-Za-z0-9{}]+|\^[A-Za-z0-9{}]+)?$/.test(source);
26347
26517
  }
26348
26518
  function collectInlineCodeRanges(source) {
26349
26519
  const ranges = [];
@@ -26394,7 +26564,8 @@ ${block}`;
26394
26564
  }
26395
26565
  nodes.push(createMathNode(segment, {
26396
26566
  document: documentRef,
26397
- katex: options2.katex || root.katex
26567
+ katex: options2.katex || root.katex,
26568
+ macros: options2.macros || buildMathMacros(options2.projectSources)
26398
26569
  }));
26399
26570
  }
26400
26571
  return nodes;
@@ -26420,6 +26591,7 @@ ${block}`;
26420
26591
  strict: "warn",
26421
26592
  maxExpand: 200,
26422
26593
  maxSize: 20,
26594
+ macros: options2.macros || buildMathMacros(),
26423
26595
  output: "htmlAndMathml"
26424
26596
  });
26425
26597
  node.dataset.mathRendered = "true";
@@ -26427,7 +26599,7 @@ ${block}`;
26427
26599
  } catch (_error) {
26428
26600
  node.classList.add("run-math--fallback");
26429
26601
  node.dataset.mathRendered = "false";
26430
- node.textContent = segment.raw;
26602
+ node.textContent = source;
26431
26603
  return node;
26432
26604
  }
26433
26605
  }
@@ -26444,6 +26616,106 @@ ${block}`;
26444
26616
  }
26445
26617
  return /(?:=|\\(?:le|ge|approx|sim|to|Rightarrow|Longrightarrow)\b|\\begin\{(?:aligned|gathered|split|array)\}|\\\\)/.test(source);
26446
26618
  }
26619
+ function parseStandaloneMath(value) {
26620
+ const source = String(value || "").trim();
26621
+ if (!source) {
26622
+ return null;
26623
+ }
26624
+ const segments = parseMathSegments(source);
26625
+ if (segments.length !== 1 || segments[0].type !== "math" || segments[0].raw !== source) {
26626
+ return null;
26627
+ }
26628
+ return segments[0];
26629
+ }
26630
+ function buildMathMacros(projectSources = []) {
26631
+ const macros = { ...DEFAULT_MATH_MACROS };
26632
+ let remainingChars = MAX_PROJECT_MACRO_SOURCE_CHARS;
26633
+ let projectMacroCount = 0;
26634
+ for (const sourceRecord of Array.isArray(projectSources) ? projectSources.slice(0, MAX_PROJECT_MACRO_SOURCES) : []) {
26635
+ if (projectMacroCount >= MAX_PROJECT_MACROS || remainingChars <= 0) {
26636
+ break;
26637
+ }
26638
+ const path = String(sourceRecord?.path || "");
26639
+ if (!/\.(?:tex|sty|cls|ltx)$/i.test(path)) {
26640
+ continue;
26641
+ }
26642
+ const source = stripLatexComments(
26643
+ String(sourceRecord?.content || "").slice(0, remainingChars)
26644
+ );
26645
+ remainingChars -= source.length;
26646
+ const pattern = /\\(newcommand|renewcommand|providecommand|DeclareMathOperator)(\*)?/g;
26647
+ let match;
26648
+ while ((match = pattern.exec(source)) !== null && projectMacroCount < MAX_PROJECT_MACROS) {
26649
+ let cursor = skipWhitespace(source, pattern.lastIndex);
26650
+ const nameGroup = readBracedGroup(source, cursor);
26651
+ if (!nameGroup) {
26652
+ continue;
26653
+ }
26654
+ const macroName = nameGroup.value.trim();
26655
+ cursor = skipWhitespace(source, nameGroup.end);
26656
+ if (source[cursor] === "[") {
26657
+ continue;
26658
+ }
26659
+ const expansionGroup = readBracedGroup(source, cursor);
26660
+ if (!expansionGroup) {
26661
+ continue;
26662
+ }
26663
+ let expansion = expansionGroup.value.trim();
26664
+ if (match[1] === "DeclareMathOperator") {
26665
+ expansion = `\\operatorname${match[2] ? "*" : ""}{${expansion}}`;
26666
+ }
26667
+ if (!isSafeMacroDefinition(macroName, expansion)) {
26668
+ continue;
26669
+ }
26670
+ macros[macroName] = expansion;
26671
+ projectMacroCount++;
26672
+ pattern.lastIndex = expansionGroup.end;
26673
+ }
26674
+ }
26675
+ return macros;
26676
+ }
26677
+ function readBracedGroup(source, start) {
26678
+ if (source[start] !== "{") {
26679
+ return null;
26680
+ }
26681
+ let depth = 0;
26682
+ for (let index = start; index < source.length; index++) {
26683
+ if (source[index] === "{" && !isEscaped(source, index)) {
26684
+ depth++;
26685
+ } else if (source[index] === "}" && !isEscaped(source, index)) {
26686
+ depth--;
26687
+ if (depth === 0) {
26688
+ return {
26689
+ value: source.slice(start + 1, index),
26690
+ end: index + 1
26691
+ };
26692
+ }
26693
+ }
26694
+ }
26695
+ return null;
26696
+ }
26697
+ function skipWhitespace(source, start) {
26698
+ let index = start;
26699
+ while (index < source.length && /\s/.test(source[index])) {
26700
+ index++;
26701
+ }
26702
+ return index;
26703
+ }
26704
+ function stripLatexComments(source) {
26705
+ return String(source || "").split(/\r?\n/).map((line) => {
26706
+ for (let index = 0; index < line.length; index++) {
26707
+ if (line[index] === "%" && !isEscaped(line, index)) {
26708
+ return line.slice(0, index);
26709
+ }
26710
+ }
26711
+ return line;
26712
+ }).join("\n");
26713
+ }
26714
+ function isSafeMacroDefinition(name, expansion) {
26715
+ const macroName = String(name || "");
26716
+ const body = String(expansion || "");
26717
+ return /^\\[A-Za-z@]+$/.test(macroName) && body.length > 0 && body.length <= MAX_MACRO_EXPANSION_CHARS && !body.includes("#") && !body.includes(macroName) && !UNSAFE_MACRO_PATTERN.test(macroName) && !UNSAFE_MACRO_PATTERN.test(body);
26718
+ }
26447
26719
  function toNodeArray(value) {
26448
26720
  if (Array.isArray(value)) {
26449
26721
  return value;
@@ -26472,11 +26744,13 @@ ${block}`;
26472
26744
  };
26473
26745
  }
26474
26746
  const api = {
26747
+ buildMathMacros,
26475
26748
  buildMathNodes,
26476
26749
  createMathNode,
26477
26750
  matchMathAt,
26478
26751
  normalizeMathForRendering,
26479
- parseMathSegments
26752
+ parseMathSegments,
26753
+ parseStandaloneMath
26480
26754
  };
26481
26755
  root.CodexOverleafMathText = api;
26482
26756
  if (typeof module !== "undefined" && module.exports) {
@@ -26484,7 +26758,7 @@ ${block}`;
26484
26758
  }
26485
26759
  })(typeof window !== "undefined" ? window : globalThis);
26486
26760
  }).call(globalThis, void 0, void 0, void 0);
26487
- (function runClassicContentModule69(module, exports, require2) {
26761
+ (function runClassicContentModule70(module, exports, require2) {
26488
26762
  (function initCodexOverleafMarkdownDomRenderer(root, factory) {
26489
26763
  const api = factory();
26490
26764
  if (typeof module === "object" && module.exports) {
@@ -26912,7 +27186,7 @@ ${block}`;
26912
27186
  };
26913
27187
  });
26914
27188
  }).call(globalThis, void 0, void 0, void 0);
26915
- (function runClassicContentModule70(module, exports, require2) {
27189
+ (function runClassicContentModule71(module, exports, require2) {
26916
27190
  (function initCodexOverleafMarkdownText() {
26917
27191
  "use strict";
26918
27192
  function create(deps = {}) {
@@ -26923,11 +27197,15 @@ ${block}`;
26923
27197
  callPageBridge,
26924
27198
  getCurrentProjectId,
26925
27199
  getCurrentProjectReferenceFiles,
27200
+ getCurrentProjectMathSources,
26926
27201
  showPluginToast
26927
27202
  } = deps;
26928
27203
  function renderMarkdownInlineText(target, value) {
26929
27204
  target.replaceChildren(...buildMarkdownInlineNodes(value));
26930
27205
  }
27206
+ function getMathMacros() {
27207
+ return MathText?.buildMathMacros?.(getCurrentProjectMathSources?.() || []) || {};
27208
+ }
26931
27209
  function sanitizeAssistantVisibleText(value) {
26932
27210
  if (typeof value !== "string" || !value) {
26933
27211
  return "";
@@ -26976,6 +27254,7 @@ ${block}`;
26976
27254
  return mathText.buildMathNodes(source, {
26977
27255
  document,
26978
27256
  katex: window.katex,
27257
+ macros: getMathMacros(),
26979
27258
  renderText: buildMarkdownInlineNodesWithoutMath
26980
27259
  });
26981
27260
  }
@@ -27008,6 +27287,11 @@ ${block}`;
27008
27287
  function buildInlineCodeNodes(value) {
27009
27288
  const source = String(value || "");
27010
27289
  const trimmed = source.trim();
27290
+ const standaloneMath = MathText?.parseStandaloneMath?.(trimmed);
27291
+ if (standaloneMath && MathText?.createMathNode) return [MathText.createMathNode(
27292
+ standaloneMath,
27293
+ { document, katex: window.katex, macros: getMathMacros() }
27294
+ )];
27011
27295
  const refs = trimmed ? parseRuntimeLineReferences(trimmed, "plain-text-token") : [];
27012
27296
  const ref = refs.length === 1 && refs[0]?.rawText === trimmed ? refs[0] : null;
27013
27297
  if (ref && !isRuntimeLocalPathLike(ref.rawPath)) {
@@ -27348,13 +27632,17 @@ ${block}`;
27348
27632
  `[${safeLabel.replace(/]/g, "\\]")}](${target2.replace(/\)/g, "\\)")})`
27349
27633
  );
27350
27634
  },
27351
- renderCodeNodes: (text) => buildMarkdownInlineNodes(`\`${String(text || "").replace(/`/g, "\\`")}\``),
27635
+ renderCodeNodes: (text) => buildInlineCodeNodes(text),
27352
27636
  sanitizeText: sanitizeAssistantVisibleText,
27353
- createMathNode: (segment) => runtimeRoot.CodexOverleafMathText.createMathNode(segment, {
27354
- document,
27355
- katex: runtimeRoot.katex,
27356
- renderText: (text) => buildMarkdownInlineNodes(text)
27357
- }),
27637
+ createMathNode: (segment) => runtimeRoot.CodexOverleafMathText.createMathNode(
27638
+ segment,
27639
+ {
27640
+ document,
27641
+ katex: runtimeRoot.katex,
27642
+ macros: getMathMacros(),
27643
+ renderText: (text) => buildMarkdownInlineNodes(text)
27644
+ }
27645
+ ),
27358
27646
  recordDiagnostic: recordRenderingDiagnostic
27359
27647
  });
27360
27648
  return;
@@ -27525,7 +27813,7 @@ ${block}`;
27525
27813
  window.CodexOverleafMarkdownText = { create };
27526
27814
  })();
27527
27815
  }).call(globalThis, void 0, void 0, void 0);
27528
- (function runClassicContentModule71(module, exports, require2) {
27816
+ (function runClassicContentModule72(module, exports, require2) {
27529
27817
  (function initCodexOverleafDiagnosticsController() {
27530
27818
  "use strict";
27531
27819
  function create(deps = {}) {
@@ -28094,7 +28382,7 @@ ${block}`;
28094
28382
  window.CodexOverleafDiagnosticsController = { create };
28095
28383
  })();
28096
28384
  }).call(globalThis, void 0, void 0, void 0);
28097
- (function runClassicContentModule72(module, exports, require2) {
28385
+ (function runClassicContentModule73(module, exports, require2) {
28098
28386
  (function initCodexOverleafRunGuidanceView() {
28099
28387
  "use strict";
28100
28388
  const LEGACY_GUIDANCE_TITLES = /* @__PURE__ */ new Set([
@@ -28134,7 +28422,7 @@ ${block}`;
28134
28422
  };
28135
28423
  })();
28136
28424
  }).call(globalThis, void 0, void 0, void 0);
28137
- (function runClassicContentModule73(module, exports, require2) {
28425
+ (function runClassicContentModule74(module, exports, require2) {
28138
28426
  (function initCodexOverleafRunGuidanceController() {
28139
28427
  "use strict";
28140
28428
  function create(deps = {}) {
@@ -28197,7 +28485,7 @@ ${block}`;
28197
28485
  window.CodexOverleafRunGuidanceController = { create };
28198
28486
  })();
28199
28487
  }).call(globalThis, void 0, void 0, void 0);
28200
- (function runClassicContentModule74(module, exports, require2) {
28488
+ (function runClassicContentModule75(module, exports, require2) {
28201
28489
  (function initCodexOverleafRunTimelineView() {
28202
28490
  "use strict";
28203
28491
  function create(deps = {}) {
@@ -28413,6 +28701,9 @@ ${block}`;
28413
28701
  if (status === "failed") {
28414
28702
  return tr("processedFailed", { elapsed });
28415
28703
  }
28704
+ if (status === "rejected" || status === "cancelled") {
28705
+ return tr("processedCancelled", { elapsed });
28706
+ }
28416
28707
  if (status === "running") {
28417
28708
  return tr("processing", { elapsed });
28418
28709
  }
@@ -28543,6 +28834,9 @@ ${block}`;
28543
28834
  if (run.startedAt && run.finishedAt) {
28544
28835
  return formatProcessedSummary(run.status || "completed", new Date(run.finishedAt).getTime() - new Date(run.startedAt).getTime());
28545
28836
  }
28837
+ if (run.status === "rejected" || run.status === "cancelled") {
28838
+ return tx("Cancelled", "\u5DF2\u53D6\u6D88");
28839
+ }
28546
28840
  return run.status === "failed" ? tx("Failed", "\u5904\u7406\u5931\u8D25") : tx("Done", "\u5DF2\u5904\u7406");
28547
28841
  }
28548
28842
  function renderRunEvent(event) {
@@ -29145,7 +29439,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29145
29439
  window.CodexOverleafRunTimelineView = { create };
29146
29440
  })();
29147
29441
  }).call(globalThis, void 0, void 0, void 0);
29148
- (function runClassicContentModule75(module, exports, require2) {
29442
+ (function runClassicContentModule76(module, exports, require2) {
29149
29443
  (function initCodexOverleafProjectSettingsCoordinator() {
29150
29444
  "use strict";
29151
29445
  function create(deps = {}) {
@@ -29472,7 +29766,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29472
29766
  window.CodexOverleafProjectSettingsCoordinator = { create };
29473
29767
  })();
29474
29768
  }).call(globalThis, void 0, void 0, void 0);
29475
- (function runClassicContentModule76(module, exports, require2) {
29769
+ (function runClassicContentModule77(module, exports, require2) {
29476
29770
  (function initCodexOverleafSessionMenuView() {
29477
29771
  "use strict";
29478
29772
  function create(deps = {}) {
@@ -29677,7 +29971,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29677
29971
  window.CodexOverleafSessionMenuView = { create };
29678
29972
  })();
29679
29973
  }).call(globalThis, void 0, void 0, void 0);
29680
- (function runClassicContentModule77(module, exports, require2) {
29974
+ (function runClassicContentModule78(module, exports, require2) {
29681
29975
  (function initCodexOverleafSessionManager() {
29682
29976
  "use strict";
29683
29977
  function create(deps = {}) {
@@ -29936,7 +30230,7 @@ ${conclusion}` : `${label} ${conclusion}`;
29936
30230
  window.CodexOverleafSessionManager = { create };
29937
30231
  })();
29938
30232
  }).call(globalThis, void 0, void 0, void 0);
29939
- (function runClassicContentModule78(module, exports, require2) {
30233
+ (function runClassicContentModule79(module, exports, require2) {
29940
30234
  (function initCodexOverleafApplyResultFormatters() {
29941
30235
  "use strict";
29942
30236
  function create(deps = {}) {
@@ -30256,7 +30550,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30256
30550
  window.CodexOverleafApplyResultFormatters = { create };
30257
30551
  })();
30258
30552
  }).call(globalThis, void 0, void 0, void 0);
30259
- (function runClassicContentModule79(module, exports, require2) {
30553
+ (function runClassicContentModule80(module, exports, require2) {
30260
30554
  (function initCodexOverleafModelPickerSupport(root, factory) {
30261
30555
  if (typeof module === "object" && module.exports) {
30262
30556
  module.exports = factory(require2("../shared/models"));
@@ -30357,7 +30651,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30357
30651
  return api;
30358
30652
  });
30359
30653
  }).call(globalThis, void 0, void 0, void 0);
30360
- (function runClassicContentModule80(module, exports, require2) {
30654
+ (function runClassicContentModule81(module, exports, require2) {
30361
30655
  (function initCodexOverleafModelPicker() {
30362
30656
  "use strict";
30363
30657
  function create(deps = {}) {
@@ -30835,7 +31129,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30835
31129
  window.CodexOverleafModelPicker = { create };
30836
31130
  })();
30837
31131
  }).call(globalThis, void 0, void 0, void 0);
30838
- (function runClassicContentModule81(module, exports, require2) {
31132
+ (function runClassicContentModule82(module, exports, require2) {
30839
31133
  (function initCodexOverleafProjectSessionCleanup() {
30840
31134
  "use strict";
30841
31135
  const FRESH_RUNNING_WINDOW_MS = 30 * 60 * 1e3;
@@ -30935,7 +31229,7 @@ ${conclusion}` : `${label} ${conclusion}`;
30935
31229
  window.CodexOverleafProjectSessionCleanup = { create };
30936
31230
  })();
30937
31231
  }).call(globalThis, void 0, void 0, void 0);
30938
- (function runClassicContentModule82(module, exports, require2) {
31232
+ (function runClassicContentModule83(module, exports, require2) {
30939
31233
  (function initCodexOverleafRecentProjects() {
30940
31234
  "use strict";
30941
31235
  function create(deps = {}) {
@@ -31861,7 +32155,7 @@ ${conclusion}` : `${label} ${conclusion}`;
31861
32155
  window.CodexOverleafRecentProjects = { create };
31862
32156
  })();
31863
32157
  }).call(globalThis, void 0, void 0, void 0);
31864
- (function runClassicContentModule83(module, exports, require2) {
32158
+ (function runClassicContentModule84(module, exports, require2) {
31865
32159
  (function initCodexOverleafOtWarmMirror() {
31866
32160
  "use strict";
31867
32161
  function create(deps = {}) {
@@ -32623,7 +32917,7 @@ ${conclusion}` : `${label} ${conclusion}`;
32623
32917
  applyResults: [],
32624
32918
  nextStep: tr("warmMirrorStaleBlockedNextStep")
32625
32919
  });
32626
- finishRunView(tr("warmMirrorStaleBlockedTitle"), "failed");
32920
+ await finishRunView(tr("warmMirrorStaleBlockedTitle"), "failed");
32627
32921
  return { ok: false };
32628
32922
  }
32629
32923
  if (focusedPartialSnapshot) {
@@ -32716,7 +33010,7 @@ ${conclusion}` : `${label} ${conclusion}`;
32716
33010
  window.CodexOverleafOtWarmMirror = { create };
32717
33011
  })();
32718
33012
  }).call(globalThis, void 0, void 0, void 0);
32719
- (function runClassicContentModule84(module, exports, require2) {
33013
+ (function runClassicContentModule85(module, exports, require2) {
32720
33014
  (function initCodexOverleafWritebackOrchestrator() {
32721
33015
  "use strict";
32722
33016
  let tr;
@@ -32729,7 +33023,6 @@ ${conclusion}` : `${label} ${conclusion}`;
32729
33023
  let appendOperationsPreview;
32730
33024
  let appendPartialWritebackWarning;
32731
33025
  let appendApplyResult;
32732
- let renderDiffReview;
32733
33026
  let renderReadOnlyDiffReview;
32734
33027
  let showPluginConfirm;
32735
33028
  let callPageBridge;
@@ -32793,8 +33086,8 @@ ${conclusion}` : `${label} ${conclusion}`;
32793
33086
  applyResults: [],
32794
33087
  mode: runMode,
32795
33088
  nextStep: tx(
32796
- "Switch to Suggest or Auto only when you want Codex to edit files.",
32797
- "\u53EA\u6709\u5E0C\u671B Codex \u4FEE\u6539\u6587\u4EF6\u65F6\uFF0C\u624D\u9700\u8981\u5207\u6362\u5230\u5EFA\u8BAE\u4FEE\u6539\u6216\u81EA\u52A8\u5199\u5165\u3002"
33089
+ "Switch to Auto only when you want Codex to edit files.",
33090
+ "\u53EA\u6709\u5E0C\u671B Codex \u4FEE\u6539\u6587\u4EF6\u65F6\uFF0C\u624D\u9700\u8981\u5207\u6362\u5230\u81EA\u52A8\u5199\u5165\u3002"
32798
33091
  )
32799
33092
  });
32800
33093
  return {
@@ -32873,50 +33166,6 @@ ${conclusion}` : `${label} ${conclusion}`;
32873
33166
  })
32874
33167
  };
32875
33168
  }
32876
- if (runMode === "confirm") {
32877
- appendRunEvent({
32878
- title: tx(
32879
- `Local Codex produced ${operations.length} change(s). Review the diff before applying.`,
32880
- `\u672C\u5730 Codex \u4EA7\u751F\u4E86 ${operations.length} \u9879\u6539\u52A8\uFF0C\u8BF7\u67E5\u770B\u5DEE\u5F02\u540E\u786E\u8BA4\u3002`
32881
- ),
32882
- status: "running"
32883
- });
32884
- const accepted = await renderDiffReview(visibleSyncChanges);
32885
- if (!accepted.length) {
32886
- appendRunEvent({
32887
- title: tx("Sync cancelled: Overleaf was not modified.", "\u5DF2\u53D6\u6D88\u540C\u6B65\uFF1AOverleaf \u6CA1\u6709\u88AB\u4FEE\u6539\u3002"),
32888
- status: "completed"
32889
- });
32890
- appendCompletionReport({
32891
- conclusion: tx("You cancelled syncing. Local Codex changes were not written back to Overleaf.", "\u4F60\u53D6\u6D88\u4E86\u540C\u6B65\uFF0C\u672C\u5730 Codex \u6539\u52A8\u6CA1\u6709\u5199\u56DE Overleaf\u3002"),
32892
- status: "rejected",
32893
- operations: [],
32894
- applyResults: [],
32895
- mode: runMode,
32896
- nextStep: tx("Run the task again, or switch to Auto if you want changes synced directly.", "\u53EF\u4EE5\u91CD\u65B0\u8FD0\u884C\u4EFB\u52A1\uFF0C\u6216\u5207\u6362\u5230\u81EA\u52A8\u5199\u5165\u540E\u518D\u540C\u6B65\u3002")
32897
- });
32898
- return {
32899
- summaryLine: tx("Sync cancelled", "\u5DF2\u53D6\u6D88\u540C\u6B65"),
32900
- hasSkippedOperations: additionalSkippedEntries.length > 0,
32901
- settlement: buildSettlement({
32902
- operations,
32903
- applyResult: { ok: false, applied: [], skipped: additionalSkippedEntries }
32904
- }),
32905
- audit: buildAuditSummaryFromApply({
32906
- operations,
32907
- applyResults: additionalSkippedEntries.length ? [{ ok: false, applied: [], skipped: additionalSkippedEntries }] : [],
32908
- blockedFiles: additionalSkippedEntries.map((item) => summarizeOperationForAudit(item.operation, item.result, "blocked")),
32909
- resultStatus: "rejected"
32910
- })
32911
- };
32912
- }
32913
- operations = buildSyncApplyOperations(accepted, project);
32914
- const acceptedPathSafety = partitionUnsafeProjectPathOperations(operations);
32915
- if (acceptedPathSafety.skipped.length) {
32916
- additionalSkippedEntries.push(...acceptedPathSafety.skipped);
32917
- operations = acceptedPathSafety.safe;
32918
- }
32919
- }
32920
33169
  const deleteOperations = operations.filter((operation) => operation.type === "delete");
32921
33170
  if (deleteOperations.length) {
32922
33171
  const approved = await showPluginConfirm({
@@ -33470,7 +33719,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
33470
33719
  appendOperationsPreview,
33471
33720
  appendPartialWritebackWarning,
33472
33721
  appendApplyResult,
33473
- renderDiffReview,
33474
33722
  renderReadOnlyDiffReview,
33475
33723
  showPluginConfirm,
33476
33724
  callPageBridge,
@@ -33516,7 +33764,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
33516
33764
  window.CodexOverleafWritebackOrchestrator = { create };
33517
33765
  })();
33518
33766
  }).call(globalThis, void 0, void 0, void 0);
33519
- (function runClassicContentModule85(module, exports, require2) {
33767
+ (function runClassicContentModule86(module, exports, require2) {
33520
33768
  (function initCodexOverleafRunSettlementPersistence(root, factory) {
33521
33769
  const api = factory();
33522
33770
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -33559,7 +33807,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
33559
33807
  return Object.freeze({ create });
33560
33808
  });
33561
33809
  }).call(globalThis, void 0, void 0, void 0);
33562
- (function runClassicContentModule86(module, exports, require2) {
33810
+ (function runClassicContentModule87(module, exports, require2) {
33563
33811
  (function initPostNavigationSettlementPersistence(root, factory) {
33564
33812
  const api = factory();
33565
33813
  if (typeof module === "object" && module.exports) module.exports = api;
@@ -33651,7 +33899,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
33651
33899
  return Object.freeze({ persist, persistRequired });
33652
33900
  });
33653
33901
  }).call(globalThis, void 0, void 0, void 0);
33654
- (function runClassicContentModule87(module, exports, require2) {
33902
+ (function runClassicContentModule88(module, exports, require2) {
33655
33903
  (function initCodexOverleafPanelMaintenance() {
33656
33904
  "use strict";
33657
33905
  function create(deps = {}) {
@@ -33967,7 +34215,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
33967
34215
  window.CodexOverleafPanelMaintenance = { create };
33968
34216
  })();
33969
34217
  }).call(globalThis, void 0, void 0, void 0);
33970
- (function runClassicContentModule88(module, exports, require2) {
34218
+ (function runClassicContentModule89(module, exports, require2) {
33971
34219
  (function initCodexOverleafUpdateIdle(root) {
33972
34220
  "use strict";
33973
34221
  function create(options2 = {}) {
@@ -34035,7 +34283,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34035
34283
  root.CodexOverleafUpdateIdle = Object.freeze({ create });
34036
34284
  })(typeof window !== "undefined" ? window : globalThis);
34037
34285
  }).call(globalThis, void 0, void 0, void 0);
34038
- (function runClassicContentModule89(module, exports, require2) {
34286
+ (function runClassicContentModule90(module, exports, require2) {
34039
34287
  (function initCodexOverleafUpdateNotice(root, factory) {
34040
34288
  if (typeof module === "object" && module.exports) {
34041
34289
  module.exports = factory(require2("../shared/managedUpdateProjection"));
@@ -34479,7 +34727,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34479
34727
  return Object.freeze({ mount });
34480
34728
  });
34481
34729
  }).call(globalThis, void 0, void 0, void 0);
34482
- (function runClassicContentModule90(module, exports, require2) {
34730
+ (function runClassicContentModule91(module, exports, require2) {
34483
34731
  (function initCodexOverleafContentRuntime(root) {
34484
34732
  "use strict";
34485
34733
  function init(dependencies2) {
@@ -34529,7 +34777,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34529
34777
  "codex.providers.clear-secret",
34530
34778
  "codex.providers.delete",
34531
34779
  "task.run",
34532
- "task.confirm",
34533
34780
  "mirror.sync",
34534
34781
  "mirror.patchFiles",
34535
34782
  "mirror.confirmWriteback",
@@ -34639,6 +34886,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34639
34886
  callPageBridge,
34640
34887
  getCurrentProjectId,
34641
34888
  getCurrentProjectReferenceFiles,
34889
+ getCurrentProjectMathSources,
34642
34890
  showPluginToast,
34643
34891
  recordRenderingDiagnostic: (detail) => appendTechnicalEvent({ type: "rendering.diagnostic", detail })
34644
34892
  });
@@ -34973,7 +35221,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
34973
35221
  appendOperationsPreview,
34974
35222
  appendPartialWritebackWarning,
34975
35223
  appendApplyResult,
34976
- renderDiffReview,
34977
35224
  renderReadOnlyDiffReview,
34978
35225
  showPluginConfirm,
34979
35226
  callPageBridge,
@@ -35867,9 +36114,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
35867
36114
  if (mode === "ask") {
35868
36115
  return "Ask";
35869
36116
  }
35870
- if (mode === "confirm") {
35871
- return "Confirm";
35872
- }
35873
36117
  if (mode === "auto") {
35874
36118
  return "Auto";
35875
36119
  }
@@ -36184,7 +36428,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36184
36428
  if (!useExistingMirror) {
36185
36429
  appendLog(formatProjectSnapshotUserLog(project));
36186
36430
  }
36187
- currentRunView.projectFiles = captureProjectReferenceFiles(project);
36431
+ persistCurrentProjectReferenceFiles(project);
36188
36432
  const snapshotWarnings = useExistingMirror ? { blocking: [], nonBlocking: [] } : getProjectSnapshotWarnings(project);
36189
36433
  const warmMirrorReuse = useExistingMirror ? warmStart : await awaitRunStep(resolveWarmMirrorReuse(project, {
36190
36434
  snapshotWarnings,
@@ -36222,7 +36466,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36222
36466
  skippedFiles: [],
36223
36467
  blockedFiles: snapshotWarnings.blocking.map((reason) => ({ path: "project", reason }))
36224
36468
  });
36225
- finishRunView(tx("Blocked: full project was not read", "\u5DF2\u963B\u6B62\uFF1A\u6CA1\u6709\u8BFB\u5230\u5B8C\u6574\u9879\u76EE"), "failed");
36469
+ await finishRunView(tx("Blocked: full project was not read", "\u5DF2\u963B\u6B62\uFF1A\u6CA1\u6709\u8BFB\u5230\u5B8C\u6574\u9879\u76EE"), "failed");
36226
36470
  return;
36227
36471
  }
36228
36472
  if (warmMirrorReuse.useExistingMirror) {
@@ -36295,7 +36539,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36295
36539
  reason: finding.detectorId || "sensitive"
36296
36540
  }))
36297
36541
  });
36298
- finishRunView(tx("Blocked: sensitive content review required", "\u5DF2\u963B\u6B62\uFF1A\u9700\u8981\u5904\u7406\u654F\u611F\u5185\u5BB9"), "failed");
36542
+ await finishRunView(tx("Blocked: sensitive content review required", "\u5DF2\u963B\u6B62\uFF1A\u9700\u8981\u5904\u7406\u654F\u611F\u5185\u5BB9"), "failed");
36299
36543
  return;
36300
36544
  }
36301
36545
  if (sensitiveFindings.findings.length) {
@@ -36330,7 +36574,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36330
36574
  return;
36331
36575
  }
36332
36576
  project = staleRetry.project;
36333
- currentRunView.projectFiles = captureProjectReferenceFiles(project);
36577
+ persistCurrentProjectReferenceFiles(project);
36334
36578
  useExistingMirror = false;
36335
36579
  fileOverlays = null;
36336
36580
  otWarmStart = false;
@@ -36384,14 +36628,14 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36384
36628
  } else {
36385
36629
  appendRunEvent({ title: tx("Cancelled: user chose not to create a new thread.", "\u5DF2\u53D6\u6D88\uFF1A\u7528\u6237\u9009\u62E9\u4E0D\u65B0\u5EFA\u7EBF\u7A0B\u3002"), status: "rejected" });
36386
36630
  await finalizeAuditRecord(runAuditDraft, { resultStatus: "rejected" });
36387
- finishRunView(tx("Cancelled", "\u5DF2\u53D6\u6D88"), "rejected");
36631
+ await finishRunView(tx("Cancelled", "\u5DF2\u53D6\u6D88"), "rejected");
36388
36632
  return;
36389
36633
  }
36390
36634
  }
36391
36635
  if (!response.ok) {
36392
36636
  if (runCancellationRequested || isRunCancellationError(response.error)) {
36393
36637
  appendRunCancelledReport();
36394
- finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36638
+ await finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36395
36639
  void finalizeAuditRecord(runAuditDraft, { resultStatus: "cancelled" });
36396
36640
  return;
36397
36641
  }
@@ -36456,7 +36700,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36456
36700
  sensitiveFindings: sensitiveFindings.findings,
36457
36701
  blockedFiles: [{ path: "codex.run", reason: response.error?.code || response.error?.message || "native_error" }]
36458
36702
  });
36459
- finishRunView(response.error?.code === "project_locked" ? tx("Codex task already running", "Codex \u4EFB\u52A1\u6B63\u5728\u8FD0\u884C") : tx("Local Codex error", "\u672C\u5730 Codex \u9519\u8BEF"), "failed");
36703
+ await finishRunView(response.error?.code === "project_locked" ? tx("Codex task already running", "Codex \u4EFB\u52A1\u6B63\u5728\u8FD0\u884C") : tx("Local Codex error", "\u672C\u5730 Codex \u9519\u8BEF"), "failed");
36460
36704
  return;
36461
36705
  }
36462
36706
  throwIfRunCancellationRequested();
@@ -36497,7 +36741,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36497
36741
  sensitiveFindings: sensitiveFindings.findings,
36498
36742
  blockedFiles: [{ path: "codex.run", reason: "codex_no_usable_result" }]
36499
36743
  });
36500
- finishRunView(tx("Local Codex returned nothing usable", "\u672C\u5730 Codex \u6CA1\u6709\u8FD4\u56DE\u53EF\u7528\u7ED3\u679C"), "failed");
36744
+ await finishRunView(tx("Local Codex returned nothing usable", "\u672C\u5730 Codex \u6CA1\u6709\u8FD4\u56DE\u53EF\u7528\u7ED3\u679C"), "failed");
36501
36745
  return;
36502
36746
  }
36503
36747
  const writebackProject = useExistingMirror ? mergeProjectWithSyncChangeBaseFiles(project, syncChanges) : project;
@@ -36517,7 +36761,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36517
36761
  sensitiveFindings: sensitiveFindings.findings,
36518
36762
  resultStatus: syncOutcome.hasSkippedOperations ? "completed_with_skips" : "completed"
36519
36763
  });
36520
- finishRunView(
36764
+ await finishRunView(
36521
36765
  syncOutcome.hasSkippedOperations ? tx("Sync completed with skipped items", "\u540C\u6B65\u5B8C\u6210\u4F46\u6709\u8DF3\u8FC7\u9879") : tx("Sync completed", "\u540C\u6B65\u5B8C\u6210"),
36522
36766
  syncOutcome.hasSkippedOperations ? "failed" : "completed"
36523
36767
  );
@@ -36587,7 +36831,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36587
36831
  } catch (error) {
36588
36832
  if (runCancellationRequested || isRunCancellationError(error)) {
36589
36833
  appendRunCancelledReport();
36590
- finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36834
+ await finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36591
36835
  void finalizeAuditRecord(runAuditDraft, { resultStatus: "cancelled" });
36592
36836
  return;
36593
36837
  }
@@ -36627,7 +36871,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36627
36871
  resultStatus: "failed",
36628
36872
  blockedFiles: [{ path: "task", reason: error.message }]
36629
36873
  });
36630
- finishRunView(tx("Task failed", "\u4EFB\u52A1\u5931\u8D25"), "failed");
36874
+ await finishRunView(tx("Task failed", "\u4EFB\u52A1\u5931\u8D25"), "failed");
36631
36875
  } finally {
36632
36876
  const settledView = currentRunView;
36633
36877
  const settledRecord = settledView ? findRunRecord(settledView.recordId, settledView.sessionId) : null;
@@ -36700,7 +36944,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36700
36944
  if (runCancellationRequested || isRunCancellationError(response.error)) {
36701
36945
  appendRunCancelledReport();
36702
36946
  await finalizeAuditRecord(runAuditDraft, { resultStatus: "cancelled" });
36703
- finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36947
+ await finishRunView(tx("Cancelled", "\u5DF2\u4E2D\u65AD"), "rejected");
36704
36948
  return;
36705
36949
  }
36706
36950
  const translated = translateRawError(response.error.message, { mode: submittedMode, locale: getLocale() });
@@ -36728,7 +36972,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36728
36972
  resultStatus: "failed",
36729
36973
  blockedFiles: [{ path: "skill-installer", reason: response.error?.code || response.error?.message || "native_error" }]
36730
36974
  });
36731
- finishRunView(tx("Skill installer failed", "Skill installer \u5931\u8D25"), "failed");
36975
+ await finishRunView(tx("Skill installer failed", "Skill installer \u5931\u8D25"), "failed");
36732
36976
  return;
36733
36977
  }
36734
36978
  const assistantMessage = response.result?.assistantMessage || getAssistantAnswerForCurrentRun();
@@ -36741,7 +36985,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36741
36985
  mode: submittedMode
36742
36986
  });
36743
36987
  await finalizeAuditRecord(runAuditDraft, { resultStatus: "completed" });
36744
- finishRunView(tx("Skill installer completed", "Skill installer \u5DF2\u5B8C\u6210"), "completed");
36988
+ await finishRunView(tx("Skill installer completed", "Skill installer \u5DF2\u5B8C\u6210"), "completed");
36745
36989
  const runSessionForHistory = findSessionById(runSessionId) || getActiveSession(state);
36746
36990
  const rawAssistantMessage = assistantMessage;
36747
36991
  const rawSyncOutcome = { summaryLine: "skill installer completed" };
@@ -36832,7 +37076,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
36832
37076
  nextStep
36833
37077
  });
36834
37078
  const finishTitle = requireReviewing ? tx("Not started: could not enable Track Changes", "\u672A\u5F00\u59CB\uFF1A\u65E0\u6CD5\u5F00\u542F\u7559\u75D5") : tx("Not started: could not switch to Editing", "\u672A\u5F00\u59CB\uFF1A\u65E0\u6CD5\u5207\u6362\u5230 Editing");
36835
- finishRunView(finishTitle, "failed");
37079
+ await finishRunView(finishTitle, "failed");
36836
37080
  return {
36837
37081
  ok: false,
36838
37082
  reason,
@@ -37874,9 +38118,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
37874
38118
  function createDiffReviewElement(syncChanges, options2 = {}) {
37875
38119
  return diffReviewPanel.createDiffReviewElement(syncChanges, options2);
37876
38120
  }
37877
- function renderDiffReview(syncChanges) {
37878
- return diffReviewPanel.renderDiffReview(syncChanges);
37879
- }
37880
38121
  function renderReadOnlyDiffReview(syncChanges, title = tr("diffWrittenChangesTitle")) {
37881
38122
  return diffReviewPanel.renderReadOnlyDiffReview(syncChanges, title);
37882
38123
  }
@@ -38447,76 +38688,10 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
38447
38688
  mode,
38448
38689
  operations: [],
38449
38690
  applyResults: [],
38450
- nextStep: tx("Continue the conversation, or switch to Suggest/Auto to let Codex edit files.", "\u53EF\u4EE5\u7EE7\u7EED\u8FFD\u95EE\uFF0C\u6216\u5207\u6362\u5230\u5EFA\u8BAE\u4FEE\u6539/\u81EA\u52A8\u5199\u5165\u540E\u8BA9 Codex \u4FEE\u6539\u6587\u4EF6\u3002")
38691
+ nextStep: tx("Continue the conversation, or switch to Auto to let Codex edit files.", "\u53EF\u4EE5\u7EE7\u7EED\u8FFD\u95EE\uFF0C\u6216\u5207\u6362\u5230\u81EA\u52A8\u5199\u5165\u540E\u8BA9 Codex \u4FEE\u6539\u6587\u4EF6\u3002")
38451
38692
  });
38452
38693
  return { status: tr("modeAsk"), summaryLine: summaryLine2 };
38453
38694
  }
38454
- if (result.status === "requires_task_confirmation") {
38455
- appendPlannedChangeSummary(result.summary, tx("Preparing changes", "\u51C6\u5907\u4FEE\u6539"));
38456
- const approved = await showPluginConfirm({
38457
- title: tx("Apply these changes?", "\u5E94\u7528\u8FD9\u4E9B\u4FEE\u6539\uFF1F"),
38458
- message: formatSummary(tx("Change Summary", "\u4FEE\u6539\u6458\u8981"), result.summary),
38459
- confirmLabel: tx("Apply changes", "\u5E94\u7528\u4FEE\u6539"),
38460
- cancelLabel: tr("confirmDefaultCancel")
38461
- });
38462
- if (!approved) {
38463
- appendLog(tx("Cancelled: Codex did not write any files.", "\u5DF2\u53D6\u6D88\uFF1ACodex \u6CA1\u6709\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\u3002"));
38464
- const summaryLine3 = appendChangeSummary({ notes, summary: result.summary, status: "rejected" });
38465
- appendCompletionReport({
38466
- conclusion: tx("You cancelled this change. Codex did not write files.", "\u4F60\u53D6\u6D88\u4E86\u8FD9\u8F6E\u4FEE\u6539\uFF0CCodex \u6CA1\u6709\u5199\u5165\u6587\u4EF6\u3002"),
38467
- status: "rejected",
38468
- notes,
38469
- summary: result.summary,
38470
- userReport: result.userReport,
38471
- mode,
38472
- operations: [],
38473
- applyResults: [],
38474
- nextStep: tx("Adjust the task and run again, or switch to Ask first so Codex can explain the plan.", "\u53EF\u4EE5\u8C03\u6574\u4EFB\u52A1\u63CF\u8FF0\u540E\u91CD\u65B0\u8FD0\u884C\uFF0C\u6216\u5207\u5230\u53EA\u95EE\u4E0D\u6539\u5148\u8BA9 Codex \u89E3\u91CA\u65B9\u6848\u3002")
38475
- });
38476
- return { status: "rejected", summaryLine: summaryLine3 };
38477
- }
38478
- const confirmed = result.planId ? await sendNative({ method: "task.confirm", params: { planId: result.planId } }) : { ok: true, result: { operations: result.operations || [] } };
38479
- if (!confirmed.ok) {
38480
- appendLog(`Confirm failed: ${confirmed.error.message}`);
38481
- const summaryLine3 = appendChangeSummary({ notes, operations: [], status: "confirm failed" });
38482
- appendCompletionReport({
38483
- conclusion: tx("No writable changes were returned after confirmation.", "\u786E\u8BA4\u540E\u6CA1\u6709\u62FF\u5230\u53EF\u5199\u5165\u7684\u4FEE\u6539\u3002"),
38484
- status: "confirm failed",
38485
- notes,
38486
- userReport: result.userReport,
38487
- mode,
38488
- operations: [],
38489
- applyResults: [],
38490
- nextStep: confirmed.error.message
38491
- });
38492
- return { status: "confirm failed", summaryLine: summaryLine3 };
38493
- }
38494
- const operations2 = confirmed.result.operations || [];
38495
- appendOperationsPreview(operations2, tx("Confirmed; preparing to write", "\u7528\u6237\u5DF2\u786E\u8BA4\uFF0C\u51C6\u5907\u5199\u5165"));
38496
- const applied2 = await applyTaskOperations(project, operations2, { allowHighRisk: true });
38497
- appendApplyResult(applied2);
38498
- recordUndoFromApply(project, applied2);
38499
- const summaryLine2 = appendChangeSummary({
38500
- notes,
38501
- operations: operations2,
38502
- applyResults: [applied2],
38503
- status: "confirmed and applied"
38504
- });
38505
- appendCompletionReport({
38506
- conclusion: notes || tx("Changes were written after your confirmation.", "\u5DF2\u6309\u4F60\u7684\u786E\u8BA4\u5199\u5165\u4FEE\u6539\u3002"),
38507
- status: "confirmed and applied",
38508
- notes,
38509
- userReport: result.userReport,
38510
- mode,
38511
- operations: operations2,
38512
- applyResults: [applied2]
38513
- });
38514
- return {
38515
- status: "confirmed and applied",
38516
- summaryLine: summaryLine2,
38517
- hasSkippedOperations: hasSkippedApplyOperations([applied2])
38518
- };
38519
- }
38520
38695
  if (result.status === "delete_plan_required") {
38521
38696
  const operations2 = result.operations || [];
38522
38697
  const applyResults = [];
@@ -38588,7 +38763,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
38588
38763
  }
38589
38764
  const operations = result.operations || [];
38590
38765
  appendOperationsPreview(operations, tx("Preparing to write", "\u51C6\u5907\u5199\u5165"));
38591
- const applied = await applyTaskOperations(project, operations, { allowHighRisk: mode === "confirm" });
38766
+ const applied = await applyTaskOperations(project, operations);
38592
38767
  appendApplyResult(applied);
38593
38768
  recordUndoFromApply(project, applied);
38594
38769
  appendLog(mode === "auto" ? tx("Auto write task completed.", "\u81EA\u52A8\u5199\u5165\u4EFB\u52A1\u5B8C\u6210\u3002") : tx("Task completed.", "\u4EFB\u52A1\u5B8C\u6210\u3002"));
@@ -38856,9 +39031,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
38856
39031
  if (mode === "ask") {
38857
39032
  return tr("modeAsk");
38858
39033
  }
38859
- if (mode === "confirm") {
38860
- return tr("modeConfirm");
38861
- }
38862
39034
  if (mode === "auto") {
38863
39035
  return tr("modeAuto");
38864
39036
  }
@@ -38869,8 +39041,6 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
38869
39041
  const labels = {
38870
39042
  completed: tx("Completed", "\u5DF2\u5B8C\u6210"),
38871
39043
  rejected: tx("Cancelled", "\u5DF2\u53D6\u6D88"),
38872
- "confirm failed": tx("Confirmation failed", "\u786E\u8BA4\u5931\u8D25"),
38873
- "confirmed and applied": tx("Suggested changes applied", "\u5DF2\u5E94\u7528\u5EFA\u8BAE\u4FEE\u6539"),
38874
39044
  "applied with delete plan": tx("Applied with confirmed deletes", "\u5DF2\u5E94\u7528\u5E76\u5220\u9664\u786E\u8BA4\u9879"),
38875
39045
  "applied without deletes": tx("Applied without deletes", "\u5DF2\u5E94\u7528\u975E\u5220\u9664\u4FEE\u6539"),
38876
39046
  "\u53EA\u95EE\u4E0D\u6539": tr("modeAsk")
@@ -39268,7 +39438,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39268
39438
  history: Array.isArray(session.history) ? session.history : [],
39269
39439
  task: typeof session.task === "string" ? session.task : "",
39270
39440
  pendingInputs: Array.isArray(session.pendingInputs) ? session.pendingInputs : [],
39271
- mode: session.mode || prefs.mode || "confirm",
39441
+ mode: session.mode || prefs.mode || "ask",
39272
39442
  providerId: session.providerId || "builtin",
39273
39443
  model: session.model || prefs.model || "gpt-5.4",
39274
39444
  reasoningEffort: session.reasoningEffort || prefs.reasoningEffort || "high",
@@ -39577,7 +39747,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39577
39747
  }));
39578
39748
  }
39579
39749
  async function selectMode(mode) {
39580
- if (!["ask", "confirm", "auto"].includes(mode)) {
39750
+ if (!["ask", "auto"].includes(mode)) {
39581
39751
  return;
39582
39752
  }
39583
39753
  const modeSelect = panel?.querySelector("[data-mode]");
@@ -39824,7 +39994,11 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39824
39994
  events: root2.querySelector("[data-run-events]"),
39825
39995
  report: root2.querySelector("[data-run-report]"),
39826
39996
  status: root2.querySelector("[data-run-status]"),
39827
- projectFiles: captureProjectReferenceFiles(arguments[0]?.project),
39997
+ // A run starts before warm-mirror resolution has produced its lightweight
39998
+ // project snapshot. Seed references from the already-prefetched project
39999
+ // inventory so early stream events and fast Ask responses can still
40000
+ // resolve project-relative locations.
40001
+ projectFiles: getCurrentProjectReferenceFiles(),
39828
40002
  startedAt: Date.now(),
39829
40003
  queueItemId,
39830
40004
  nativeRequestId: "",
@@ -39841,7 +40015,7 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39841
40015
  session.lastActivityAt = updatedAt;
39842
40016
  return updatedAt;
39843
40017
  }
39844
- function finishRunView(text, status) {
40018
+ async function finishRunView(text, status) {
39845
40019
  if (!currentRunView) {
39846
40020
  return;
39847
40021
  }
@@ -39859,7 +40033,8 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
39859
40033
  runGuidanceController.settleView(currentRunView);
39860
40034
  const navigationDivergent = currentRunView.runProjectId && activeProjectId !== currentRunView.runProjectId;
39861
40035
  if (!navigationDivergent) {
39862
- saveStateSoon();
40036
+ await flushQueuedSaveState().catch(() => {
40037
+ });
39863
40038
  }
39864
40039
  renderSessionList();
39865
40040
  }
@@ -40129,6 +40304,37 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40129
40304
  }
40130
40305
  return nextWidth;
40131
40306
  }
40307
+ function getCurrentProjectMathSources() {
40308
+ const sources = [];
40309
+ const seen = /* @__PURE__ */ new Set();
40310
+ let remainingChars = 256 * 1024;
40311
+ const add = (item) => {
40312
+ if (!item || typeof item !== "object" || typeof item.content !== "string") return;
40313
+ const path = normalizeReferencePathForRuntime(item.path || item.filePath || "");
40314
+ if (!path || seen.has(path) || hasUnsafeRuntimePathSegments(path) || !/\.(?:tex|sty|cls|ltx)$/i.test(path) || remainingChars <= 0) return;
40315
+ const content = item.content.slice(0, Math.min(64 * 1024, remainingChars));
40316
+ remainingChars -= content.length;
40317
+ seen.add(path);
40318
+ sources.push({ path, content });
40319
+ };
40320
+ for (const collection of [
40321
+ currentRunView?.projectFiles,
40322
+ currentRunView?.files,
40323
+ currentRunView?.project?.files,
40324
+ currentRunView?.snapshot?.files,
40325
+ currentRunView?.projectSnapshot?.files,
40326
+ currentRunView?.contextFiles,
40327
+ state?.projectFiles,
40328
+ state?.files,
40329
+ state?.project?.files,
40330
+ state?.snapshot?.files,
40331
+ state?.projectSnapshot?.files,
40332
+ state?.contextFiles
40333
+ ]) {
40334
+ if (Array.isArray(collection)) collection.forEach(add);
40335
+ }
40336
+ return sources;
40337
+ }
40132
40338
  function getCurrentProjectReferenceFiles() {
40133
40339
  const files = [];
40134
40340
  const seen = /* @__PURE__ */ new Set();
@@ -40169,7 +40375,10 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40169
40375
  value.forEach((item) => addFile(item, true));
40170
40376
  }
40171
40377
  };
40378
+ const activeSession = typeof getActiveSession === "function" ? getActiveSession(state) : null;
40172
40379
  addFiles(currentRunView?.projectFiles);
40380
+ addFiles(activeSession?.projectReferenceFiles);
40381
+ addFiles(contextTrayController?.getContextProject?.()?.files);
40173
40382
  addFiles(currentRunView?.files);
40174
40383
  addFiles(currentRunView?.project?.files);
40175
40384
  addFiles(currentRunView?.snapshot?.files);
@@ -40183,13 +40392,24 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40183
40392
  addFiles(state?.contextFiles);
40184
40393
  addTextPaths(state?.focusFiles);
40185
40394
  addTextPaths(state?.session?.focusFiles);
40186
- const activeSession = typeof getActiveSession === "function" ? getActiveSession(state) : null;
40187
40395
  addTextPaths(activeSession?.focusFiles);
40188
40396
  for (const session of Array.isArray(state?.sessions) ? state.sessions : []) {
40397
+ addFiles(session?.projectReferenceFiles);
40189
40398
  addTextPaths(session?.focusFiles);
40190
40399
  }
40191
40400
  return files;
40192
40401
  }
40402
+ function persistCurrentProjectReferenceFiles(project) {
40403
+ const projectFiles = captureProjectReferenceFiles(project);
40404
+ if (currentRunView) {
40405
+ currentRunView.projectFiles = projectFiles;
40406
+ }
40407
+ if (getActiveSession(state)) {
40408
+ state = updateActiveSession(state, { projectReferenceFiles: projectFiles });
40409
+ saveStateSoon();
40410
+ }
40411
+ return projectFiles;
40412
+ }
40193
40413
  function captureProjectReferenceFiles(project) {
40194
40414
  const result = [];
40195
40415
  const seen = /* @__PURE__ */ new Set();
@@ -40583,7 +40803,12 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40583
40803
  record.undoOperations = [];
40584
40804
  record.undoBaseFiles = [];
40585
40805
  record.undoTrackedChanges = combinedTrackedChanges;
40586
- record.undoExpectedFiles = selectExpectedFilesForTrackedUndo(project, combinedAppliedOperations, combinedTrackedChanges);
40806
+ record.undoExpectedFiles = selectExpectedFilesForTrackedUndo(
40807
+ project,
40808
+ combinedAppliedOperations,
40809
+ combinedTrackedChanges,
40810
+ record.undoExpectedFiles
40811
+ );
40587
40812
  record.undoStatus = "";
40588
40813
  record.partialWriteback = skippedEntries.length > 0;
40589
40814
  if (combinedTrackedChanges.length) {
@@ -40626,7 +40851,12 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40626
40851
  record.undoOperations = checkpoint.undoOperations;
40627
40852
  record.undoBaseFiles = checkpoint.undoBaseFiles;
40628
40853
  record.undoTrackedChanges = [];
40629
- record.undoExpectedFiles = selectExpectedFilesForTrackedUndo(project, combinedAppliedOperations, []);
40854
+ record.undoExpectedFiles = selectExpectedFilesForTrackedUndo(
40855
+ project,
40856
+ combinedAppliedOperations,
40857
+ [],
40858
+ record.undoExpectedFiles
40859
+ );
40630
40860
  record.undoStatus = "";
40631
40861
  record.partialWriteback = skippedEntries.length > 0;
40632
40862
  refreshRunCardControls(record.id);
@@ -40644,8 +40874,13 @@ ${tx("Writeback note: Codex could not confirm any Overleaf write result entries,
40644
40874
  function normalizeApplyTrackedChanges(changes = []) {
40645
40875
  return WritebackSettlement.normalizeApplyTrackedChanges(changes);
40646
40876
  }
40647
- function selectExpectedFilesForTrackedUndo(project, operations = [], trackedChanges = []) {
40648
- return WritebackSettlement.selectExpectedFilesForTrackedUndo(project, operations, trackedChanges);
40877
+ function selectExpectedFilesForTrackedUndo(project, operations = [], trackedChanges = [], previousExpectedFiles = []) {
40878
+ return WritebackSettlement.selectExpectedFilesForTrackedUndo(
40879
+ project,
40880
+ operations,
40881
+ trackedChanges,
40882
+ previousExpectedFiles
40883
+ );
40649
40884
  }
40650
40885
  function buildTrackedUndoPostFiles(run) {
40651
40886
  const expectedFiles = Array.isArray(run?.undoExpectedFiles) ? run.undoExpectedFiles : [];
@@ -41238,7 +41473,7 @@ Reason: ${item.reason || "No reason provided"}`),
41238
41473
  root.CodexOverleafContentRuntime = { init };
41239
41474
  })(typeof window !== "undefined" ? window : globalThis);
41240
41475
  }).call(globalThis, void 0, void 0, void 0);
41241
- (function runClassicContentModule91(module, exports, require2) {
41476
+ (function runClassicContentModule92(module, exports, require2) {
41242
41477
  (function initCodexOverleafLegacyGlobalRegistry(root, factory) {
41243
41478
  "use strict";
41244
41479
  const api = factory();