codex-overleaf-link 2.5.1 → 2.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +149 -398
  2. package/README.zh-CN.md +153 -404
  3. package/extension/bootstrap/manifest.template.json +1 -1
  4. package/extension/src/background.js +148 -3
  5. package/extension/src/backgroundSharedSessions.js +55 -2
  6. package/extension/src/backgroundUpdateCoordinator.js +128 -12
  7. package/extension/src/content/activeTurnControl.js +164 -7
  8. package/extension/src/content/composerAttachments.js +46 -10
  9. package/extension/src/content/composerPanel.js +92 -12
  10. package/extension/src/content/contentRuntime.js +1114 -321
  11. package/extension/src/content/contextTray.js +8 -2
  12. package/extension/src/content/contextUsageView.js +267 -0
  13. package/extension/src/content/diagnosticsController.js +77 -34
  14. package/extension/src/content/diagnosticsExport.js +1 -1
  15. package/extension/src/content/diagnosticsPanel.js +147 -42
  16. package/extension/src/content/generated/content.bundle.js +5761 -1237
  17. package/extension/src/content/generated/content.bundle.meta.json +6 -3
  18. package/extension/src/content/legacyGlobalRegistry.js +4 -0
  19. package/extension/src/content/localSkillsPanel.js +6 -4
  20. package/extension/src/content/markdownDomRenderer.js +5 -3
  21. package/extension/src/content/markdownText.js +53 -14
  22. package/extension/src/content/modelPicker.js +29 -19
  23. package/extension/src/content/nativeCompatibilityController.js +52 -19
  24. package/extension/src/content/otWarmMirror.js +1 -1
  25. package/extension/src/content/pageBridgeClient.js +7 -7
  26. package/extension/src/content/panelMaintenance.js +10 -2
  27. package/extension/src/content/panelRenderer.js +55 -28
  28. package/extension/src/content/pendingInputView.js +1 -1
  29. package/extension/src/content/projectSettingsCoordinator.js +30 -6
  30. package/extension/src/content/providerSettingsDialog.js +28 -19
  31. package/extension/src/content/recentProjects.js +30 -19
  32. package/extension/src/content/runActivitySummary.js +122 -14
  33. package/extension/src/content/runCompletionMeta.js +194 -6
  34. package/extension/src/content/runController.js +2 -1
  35. package/extension/src/content/runFailureNotice.js +8 -1
  36. package/extension/src/content/runPresence.js +18 -8
  37. package/extension/src/content/runQueueScheduler.js +27 -13
  38. package/extension/src/content/runRecoveryActions.js +2 -1
  39. package/extension/src/content/runResultActions.js +73 -24
  40. package/extension/src/content/runReviewController.js +102 -37
  41. package/extension/src/content/runTimelineView.js +224 -25
  42. package/extension/src/content/scopedPersistencePanelState.js +124 -46
  43. package/extension/src/content/selectionContextView.js +30 -3
  44. package/extension/src/content/sensitivePreflight.js +14 -1
  45. package/extension/src/content/sessionManager.js +49 -3
  46. package/extension/src/content/sessionMenuView.js +54 -18
  47. package/extension/src/content/sessionPersistence.js +25 -5
  48. package/extension/src/content/settingsPanel.js +15 -2
  49. package/extension/src/content/settingsWorkbench.js +127 -89
  50. package/extension/src/content/sharedSessionViewSync.js +13 -4
  51. package/extension/src/content/subagentActivityView.js +23 -7
  52. package/extension/src/content/updateNotice.js +60 -6
  53. package/extension/src/content/writebackOrchestrator.js +301 -72
  54. package/extension/src/content/writingStyleSettings.js +70 -17
  55. package/extension/src/page/compileBridge.js +193 -180
  56. package/extension/src/page/overleafCapabilities.js +4 -1
  57. package/extension/src/page/overleafEditor.js +12 -3
  58. package/extension/src/page/overleafProjectSnapshot.js +56 -3
  59. package/extension/src/page/snapshotRouter.js +75 -66
  60. package/extension/src/page/textCoordinates.js +17 -1
  61. package/extension/src/page/textFileCreator.js +9 -1
  62. package/extension/src/page/treeOperations.js +200 -19
  63. package/extension/src/page/writebackRouter.js +172 -113
  64. package/extension/src/pageBridge.js +124 -73
  65. package/extension/src/popup.js +1 -1
  66. package/extension/src/shared/agentTranscript.js +372 -18
  67. package/extension/src/shared/auditRecords.js +3 -0
  68. package/extension/src/shared/compatibility.js +1 -1
  69. package/extension/src/shared/compileAdapter.js +58 -17
  70. package/extension/src/shared/composerAttachmentDraft.js +27 -7
  71. package/extension/src/shared/contextUsage.js +125 -0
  72. package/extension/src/shared/failureReasons.js +57 -3
  73. package/extension/src/shared/i18n.js +315 -29
  74. package/extension/src/shared/lineReferences.js +38 -31
  75. package/extension/src/shared/pageRpcContract.js +1 -1
  76. package/extension/src/shared/panelIcons.js +39 -0
  77. package/extension/src/shared/projectFiles.js +2 -1
  78. package/extension/src/shared/reviewing.js +130 -1
  79. package/extension/src/shared/runActivityModel.js +70 -4
  80. package/extension/src/shared/runExecutionSnapshot.js +13 -0
  81. package/extension/src/shared/scopedPersistenceBrowserAdapter.js +34 -0
  82. package/extension/src/shared/sessionState.js +63 -4
  83. package/extension/src/shared/sessionTitle.js +14 -1
  84. package/extension/src/shared/sharedSessionBridge.js +81 -13
  85. package/extension/src/shared/staleGuard.js +130 -63
  86. package/extension/src/shared/storageDb.js +35 -3
  87. package/extension/src/shared/storageMigration.js +111 -2
  88. package/extension/src/shared/storageRunActions.js +62 -8
  89. package/extension/src/shared/undoOperations.js +126 -28
  90. package/extension/src/shared/updateRuntimeIdentity.js +16 -2
  91. package/extension/src/shared/writebackSettlement.js +21 -3
  92. package/extension/styles/panel.css +1293 -549
  93. package/native-host/src/bootstrapUpdate.js +52 -16
  94. package/native-host/src/chatBridgeRequest.js +60 -6
  95. package/native-host/src/chatBridgeResponse.js +10 -1
  96. package/native-host/src/chatCompletionsBridge.js +29 -2
  97. package/native-host/src/codexPromptAssembly.js +86 -118
  98. package/native-host/src/codexSessionRunner.js +127 -17
  99. package/native-host/src/debugLog.js +27 -3
  100. package/native-host/src/index.js +42 -11
  101. package/native-host/src/localSkills.js +1 -1
  102. package/native-host/src/mirrorWorkspace.js +47 -3
  103. package/native-host/src/nativeEnvironment.js +27 -5
  104. package/native-host/src/providerContextError.js +20 -0
  105. package/native-host/src/providerRuntime.js +1 -0
  106. package/native-host/src/skills/reviewer-response/SKILL.md +65 -0
  107. package/native-host/src/taskRunnerRuntime.js +28 -8
  108. package/native-host/src/textPatch.js +473 -377
  109. package/native-host/src/updateManager.js +144 -21
  110. package/native-host/src/writingStyleRuntime.js +1 -1
  111. package/package.json +5 -8
@@ -85,9 +85,20 @@
85
85
  } catch (_) { manualCommandCopied = false; }
86
86
  return;
87
87
  }
88
+ if (action === 'restore-previous' && !window.confirm(restorePreviousConfirmText())) return;
88
89
  return runUpdateAction(action);
89
90
  }
90
91
 
92
+ function restorePreviousLabel() {
93
+ const version = currentView?.restorePrevious?.version || '';
94
+ return version ? tx(`Restore v${version}`, `恢复到 v${version}`) : tx('Restore previous version', '恢复到上一版本');
95
+ }
96
+
97
+ function restorePreviousConfirmText() {
98
+ return tx('Restore the previous version? The extension reloads, and saved, idle Overleaf tabs are refreshed. Sessions, settings and provider keys are kept.',
99
+ '恢复到上一版本?扩展会重新加载,已保存且空闲的 Overleaf 标签页会被刷新。会话、设置和模型服务的密钥都会保留。');
100
+ }
101
+
91
102
  async function runUpdateAction(action) {
92
103
  const cancelling = action === 'cancel' || action === 'later';
93
104
  if (cancellationInFlight || ((actionInFlight || settingsActionInFlight) && !cancelling)) return;
@@ -105,7 +116,8 @@
105
116
  cancel: 'codex-overleaf/consent-update-cancel',
106
117
  recover: 'codex-overleaf/consent-update-recover',
107
118
  dismiss: 'codex-overleaf/consent-update-dismiss',
108
- reload: 'codex-overleaf/consent-update-reload'
119
+ reload: 'codex-overleaf/consent-update-reload',
120
+ 'restore-previous': 'codex-overleaf/consent-update-rollback'
109
121
  }[action]);
110
122
  if (sequence === actionSequence) currentView = view;
111
123
  } catch (error) {
@@ -226,6 +238,13 @@
226
238
  button.dataset.updateSettingsBound = 'true';
227
239
  button.addEventListener('click', handleSettingsAction);
228
240
  }
241
+ const restore = panel.querySelector?.('[data-restore-previous-version]');
242
+ if (restore && restore.dataset.updateSettingsBound !== 'true') {
243
+ restore.dataset.updateSettingsBound = 'true';
244
+ restore.addEventListener('click', () => {
245
+ if (window.confirm(restorePreviousConfirmText())) void runUpdateAction('restore-previous');
246
+ });
247
+ }
229
248
  renderSettings();
230
249
  }
231
250
 
@@ -356,13 +375,23 @@
356
375
  let statusText = '';
357
376
  let buttonText = tx('Check for updates', '检查更新');
358
377
 
359
- if (stateName === 'idle' && state.code === 'update_cooldown') {
378
+ if (stateName === 'idle' && state.code === 'update_skipped_after_rollback') {
379
+ statusText = tx(
380
+ `v${latestVersion} is skipped because you restored the previous version. Check for updates to install it again.`,
381
+ `你已恢复到上一版本,自动更新会跳过 v${latestVersion}。点“检查更新”可以重新安装。`
382
+ );
383
+ } else if (stateName === 'idle' && state.code === 'update_cooldown') {
360
384
  const until = Number(state.cooldownUntil || 0);
361
385
  const time = until > 0 && Number.isFinite(until) ? new Date(until).toLocaleString(getLocale() || undefined) : '';
362
386
  statusText = tx(
363
387
  `Update v${latestVersion} is paused after a failed installation. ${time ? `Check again after ${time}.` : 'Check again after its cooldown ends.'}`,
364
388
  `v${latestVersion} 安装失败后已暂停更新。${time ? `请在 ${time} 后再次检查。` : '请在冷却期结束后再次检查。'}`
365
389
  );
390
+ } else if (stateName === 'idle' && !state.code && state.lastCheckedAt > 0
391
+ && (!latestVersion || !isNewerStableVersion(latestVersion, currentVersion))) {
392
+ // A finished check with nothing newer still answers the user's question.
393
+ const time = new Date(state.lastCheckedAt).toLocaleTimeString(getLocale() || undefined, { hour: 'numeric', minute: '2-digit' });
394
+ statusText = tx(`You have the latest stable version. Checked at ${time}.`, `已是最新稳定版本。检查时间 ${time}。`);
366
395
  } else if (['reload_required', 'reload_tabs_required'].includes(stateName)) {
367
396
  summaryText = tx(`Installed v${latestVersion}; running extension v${currentVersion}.`, `已安装 v${latestVersion};扩展当前运行 v${currentVersion}。`);
368
397
  statusText = getCopy(state).detail;
@@ -404,11 +433,19 @@
404
433
  } else {
405
434
  button.disabled = actionInFlight || settingsActionInFlight || ACTIVE_UPDATE_STATES.has(stateName);
406
435
  }
436
+ const restore = settingsRoot.querySelector?.('[data-restore-previous-version]');
437
+ if (restore) {
438
+ restore.hidden = !currentView?.actions?.restorePrevious;
439
+ restore.textContent = restorePreviousLabel();
440
+ restore.disabled = actionInFlight || settingsActionInFlight;
441
+ }
407
442
  }
408
443
 
409
444
  function visibleActions(state) {
410
445
  const value = currentView?.state || {};
411
- if (value.recoveryPending) return [{ id: 'recover', label: tx('Check recovery', '检查恢复状态'), primary: true }];
446
+ const restore = currentView?.actions?.restorePrevious
447
+ ? [{ id: 'restore-previous', label: restorePreviousLabel(), primary: false }] : [];
448
+ if (value.recoveryPending) return [...restore, { id: 'recover', label: tx('Check recovery', '检查恢复状态'), primary: true }];
412
449
  if (value.cancelRequested || ['checking', 'downloading'].includes(state)) {
413
450
  return [{ id: 'cancel', label: value.cancelRequested
414
451
  ? value.code ? tx('Retry cancellation', '重试取消') : tx('Cancelling…', '正在取消…')
@@ -442,7 +479,7 @@
442
479
  ];
443
480
  }
444
481
  if (state === 'committed') {
445
- return [{ id: 'dismiss', label: tx('Done', '完成'), primary: true }];
482
+ return [...restore, { id: 'dismiss', label: tx('Done', '完成'), primary: true }];
446
483
  }
447
484
  return [];
448
485
  }
@@ -512,7 +549,9 @@
512
549
  rolled_back: {
513
550
  eyebrow: tx('Previous version restored', '已恢复上一版本'),
514
551
  title: state.currentVersion ? 'v' + state.currentVersion : '',
515
- detail: tx('The replacement failed its health check.', '替换版本未通过健康检查。')
552
+ detail: state.code === 'update_user_rollback'
553
+ ? tx('You restored the previous version. Automatic reminders for this version are paused for 24 hours. Check for updates to install it again.', '已恢复到上一版本,刚才退出的版本将暂停自动提醒 24 小时。点“检查更新”可以重新安装。')
554
+ : tx('The replacement failed its health check.', '替换版本未通过健康检查。')
516
555
  },
517
556
  failed: {
518
557
  eyebrow: tx('Update could not continue', '更新无法继续'),
@@ -536,6 +575,7 @@
536
575
  update_not_applied: ['The update was stopped before installation. Retry when ready.', '更新已在安装前停止,可准备就绪后重试。'],
537
576
  update_recovery_pending: ['The update result is being checked. Recovery has not been confirmed.', '正在确认更新结果,恢复状态尚未确认。'],
538
577
  update_rolled_back: ['The previous version has been restored.', '已恢复上一版本。'],
578
+ update_user_rollback: ['You restored the previous version.', '你已恢复到上一版本。'],
539
579
  update_not_managed: ['Run install-managed once to enable coordinated automatic updates.', '请先运行一次 install-managed,以启用扩展与本机服务的协调更新。'],
540
580
  update_native_busy: ['Native Host is still processing a Codex task.', 'Native Host 仍在处理 Codex 任务。'],
541
581
  update_revoke_too_late: ['The update is already being installed. Wait for its result.', '更新已进入安装,请等待结果。'],
@@ -549,7 +589,7 @@
549
589
  if (messages[code]) return tx(...messages[code]);
550
590
  if (['update_health_failed', 'update_request_failed', 'update_failed'].includes(code)) return tx('The updated components could not be confirmed. Check recovery before retrying.', '尚未确认更新后的组件正常,请先检查恢复状态。');
551
591
  if (['update_bootstrap_health_timeout', 'update_bootstrap_reload_failed'].includes(code)) return tx('The updated startup components did not finish restarting and confirming. Check recovery before retrying.', '更新后的启动组件未能完成重启和确认,请先检查恢复状态。');
552
- if (['update_bootstrap_source_mismatch', 'update_bootstrap_source_version_mismatch'].includes(code)) return tx('The installed startup files do not match a supported update source. Check recovery before retrying.', '已安装的启动文件与支持的升级来源不一致,请先检查恢复状态。');
592
+ if (['update_bootstrap_source_mismatch', 'update_bootstrap_source_version_mismatch'].includes(code)) return tx('The installed startup files do not match a supported update source. Restore the previous version in Settings, or reinstall once.', '已安装的启动文件与支持的升级来源不一致。请在设置中恢复到上一版本,或重新安装一次。');
553
593
  if (['update_bootstrap_record_missing', 'update_bootstrap_record_invalid', 'update_bootstrap_backup_mismatch', 'update_bootstrap_already_restoring'].includes(code)) return tx('The startup recovery material could not be confirmed. The update result remains unconfirmed.', '尚未确认启动组件的恢复材料有效,更新结果仍待确认。');
554
594
  if (['update_bootstrap_confirmation_pending', 'update_bootstrap_native_restart_required'].includes(code)) return tx('Waiting for the updated startup components and Native Host to finish restarting and confirming.', '正在等待更新后的启动组件和本机服务完成重启及确认。');
555
595
  if (code === 'update_bootstrap_monitor_unavailable') return tx('The update recovery monitor could not start. Check recovery before retrying.', '更新恢复监护程序未能启动,请先检查恢复状态。');
@@ -607,10 +647,24 @@
607
647
  return tx('The installed release candidate has the same version number as the stable release. Reinstall to use the stable release.',
608
648
  '已安装的候选版与稳定版使用相同版本号。请重新安装以使用稳定版。');
609
649
  }
650
+ if (state.code === 'update_bootstrap_source_mismatch') {
651
+ return tx('The installed startup files differ from the published release this update starts from, for example after a release candidate or local build. Reinstall once to continue.',
652
+ '已安装的启动文件与这次更新所基于的正式版不一致(例如装过候选版或本地构建)。重新安装一次即可继续。');
653
+ }
610
654
  const reason = state.manualReason || {};
611
655
  return tx(reason.en || reason.zh || '', reason.zh || reason.en || '');
612
656
  }
613
657
 
658
+ // Compares the numeric x.y.z core only; a local build ahead of the release is not behind.
659
+ function isNewerStableVersion(candidate, current) {
660
+ const parts = value => String(value || '').replace(/^v/i, '').split('-')[0].split('.').map(part => Number(part) || 0);
661
+ const [left, right] = [parts(candidate), parts(current)];
662
+ for (let index = 0; index < 3; index++) {
663
+ if ((left[index] || 0) !== (right[index] || 0)) return (left[index] || 0) > (right[index] || 0);
664
+ }
665
+ return false;
666
+ }
667
+
614
668
  function tx(english, chinese) {
615
669
  const locale = String(getLocale() || document.documentElement?.lang || 'en');
616
670
  return /^zh\b/i.test(locale) ? chinese : english;