codex-overleaf-link 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <h1>Codex Overleaf Link</h1>
4
4
  <p><strong>Empower Overleaf with Codex.</strong></p>
5
5
  <p>
6
- <img src="https://img.shields.io/badge/version-1.9.7-blue" alt="version">
6
+ <img src="https://img.shields.io/badge/version-1.9.9-blue" alt="version">
7
7
  <img src="https://img.shields.io/badge/platform-macOS%20%2F%20Windows%20%2F%20Linux-lightgrey" alt="platform">
8
8
  <img src="https://img.shields.io/badge/chrome-MV3-green" alt="chrome manifest v3">
9
9
  <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node version">
@@ -38,14 +38,14 @@ One command installs the managed native host **and** managed extension runtime.
38
38
  macOS / Linux:
39
39
 
40
40
  ```bash
41
- CODEX_OVERLEAF_REF=v1.9.7 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.7/install.sh)"
41
+ CODEX_OVERLEAF_REF=v1.9.9 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.9/install.sh)"
42
42
  ```
43
43
 
44
44
  Windows PowerShell:
45
45
 
46
46
  ```powershell
47
- iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.7/install.ps1 -OutFile install.ps1
48
- $env:CODEX_OVERLEAF_REF='v1.9.7'
47
+ iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.9/install.ps1 -OutFile install.ps1
48
+ $env:CODEX_OVERLEAF_REF='v1.9.9'
49
49
  powershell -ExecutionPolicy Bypass -File install.ps1
50
50
  ```
51
51
 
@@ -56,7 +56,7 @@ Then, in the `chrome://extensions` tab the script opened: enable **Developer mod
56
56
  `npm exec` installs the same managed native host and extension runtime without keeping a source checkout. Use it if you prefer a pinned npm package.
57
57
 
58
58
  ```bash
59
- npm exec --yes codex-overleaf-link@1.9.7 -- install-managed
59
+ npm exec --yes codex-overleaf-link@1.9.9 -- install-managed
60
60
  ```
61
61
 
62
62
  Then, in `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the managed extension path printed by the command. The Release extension zip remains available for explicitly unmanaged/manual installations.
@@ -86,9 +86,9 @@ npm installs, updates, and uninstalls the coordinated managed extension/native p
86
86
 
87
87
  | Action | Command |
88
88
  |--------|---------|
89
- | Install / update | `npm exec --yes codex-overleaf-link@1.9.7 -- install-managed` |
90
- | Diagnose | `npm exec --yes codex-overleaf-link@1.9.7 -- doctor` |
91
- | Uninstall | `npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed` |
89
+ | Install / update | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` |
90
+ | Diagnose | `npm exec --yes codex-overleaf-link@1.9.9 -- doctor` |
91
+ | Uninstall | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` |
92
92
 
93
93
  Use `--extension-id <chrome-extension-id>` only for a custom/dev unpacked extension id that differs from the official bundled id.
94
94
 
@@ -98,13 +98,13 @@ Managed installations discover signed stable updates automatically and apply the
98
98
 
99
99
  ## GitHub Release Artifacts
100
100
 
101
- The v1.9.7 GitHub Release contains:
101
+ The v1.9.9 GitHub Release contains:
102
102
 
103
- - `codex-overleaf-link-extension-v1.9.7.zip`: loadable Chrome extension package for manual unpacked installation.
104
- - `codex-overleaf-native-host-v1.9.7.tar.gz`: native host runtime files used by the installer and release verification.
105
- - `codex-overleaf-link-1.9.7.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
106
- - `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.7` when run directly from the release artifact.
107
- - `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.7` when run directly from the release artifact.
103
+ - `codex-overleaf-link-extension-v1.9.9.zip`: loadable Chrome extension package for manual unpacked installation.
104
+ - `codex-overleaf-native-host-v1.9.9.tar.gz`: native host runtime files used by the installer and release verification.
105
+ - `codex-overleaf-link-1.9.9.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
106
+ - `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.9` when run directly from the release artifact.
107
+ - `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.9` when run directly from the release artifact.
108
108
  - `uninstall-native-host.mjs`: native host uninstaller that removes the Chrome Native Messaging manifest, bridge executable, and runtime copy.
109
109
  - `nativeHostPlatform.js`, `manifest.js`, `runtimeInstaller.js`: helper files required by the loose uninstaller asset.
110
110
  - `SHA256SUMS` and `release-manifest.json`: checksum and artifact metadata for release verification.
@@ -115,7 +115,7 @@ The v1.9.7 GitHub Release contains:
115
115
  Remove the native host (use `--browser chromium` on Linux Chromium):
116
116
 
117
117
  ```bash
118
- npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed
118
+ npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed
119
119
  ```
120
120
 
121
121
  The same command works on Windows PowerShell. If you installed from a manual checkout or source installer, you can also run `npm run uninstall:native` inside the repo, use `node ~/.codex-overleaf/source/scripts/uninstall-native-host.mjs` on macOS / Linux, or use `node $env:LOCALAPPDATA\CodexOverleaf\source\scripts\uninstall-native-host.mjs` on Windows PowerShell.
@@ -150,13 +150,13 @@ Then remove the extension from `chrome://extensions`. To delete local data: on m
150
150
  Linux Chromium install or update:
151
151
 
152
152
  ```bash
153
- CODEX_OVERLEAF_REF=v1.9.7 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.7/install.sh)" -- --browser chromium
153
+ CODEX_OVERLEAF_REF=v1.9.9 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.9/install.sh)" -- --browser chromium
154
154
  ```
155
155
 
156
156
  Linux Chromium uninstall:
157
157
 
158
158
  ```bash
159
- npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed --browser chromium
159
+ npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed --browser chromium
160
160
  ```
161
161
 
162
162
  ## Features
@@ -291,7 +291,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
291
291
  Re-run any [native host installer](#install), reload the extension in `chrome://extensions`, then refresh the Overleaf tab. This also fixes extension/native version mismatch and native protocol mismatch.
292
292
 
293
293
  ```bash
294
- npm exec --yes codex-overleaf-link@1.9.7 -- install-managed
294
+ npm exec --yes codex-overleaf-link@1.9.9 -- install-managed
295
295
  ```
296
296
 
297
297
  **The Windows popup or panel shows a Bash recovery command**
@@ -340,8 +340,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
340
340
  | Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
341
341
  | Install mode | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout; native host installed with `--browser chromium`. |
342
342
  | Extension id | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. |
343
- | Installer/update command | `npm exec --yes codex-overleaf-link@1.9.7 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- install-managed --browser chromium` |
344
- | Uninstall command | `npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-managed --browser chromium` |
343
+ | Installer/update command | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed --browser chromium` |
344
+ | Uninstall command | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed --browser chromium` |
345
345
  | Manifest/registry path | `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.codex.overleaf.json` | `HKCU\Software\Google\Chrome\NativeMessagingHosts\com.codex.overleaf` -> `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime\com.codex.overleaf.json` | `~/.config/google-chrome/NativeMessagingHosts/com.codex.overleaf.json` | `~/.config/chromium/NativeMessagingHosts/com.codex.overleaf.json` |
346
346
  | Bridge/runtime/source path | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `%LOCALAPPDATA%\CodexOverleaf\codex-overleaf-bridge.cmd`; runtime `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime`; source `%LOCALAPPDATA%\CodexOverleaf\source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. |
347
347
  | Node/Git/Codex/TeX | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. |
@@ -377,7 +377,7 @@ Contributions are welcome. Please open an issue before submitting large changes
377
377
  The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
378
378
 
379
379
  ```bash
380
- npm exec --yes codex-overleaf-link@1.9.7 -- install-managed
380
+ npm exec --yes codex-overleaf-link@1.9.9 -- install-managed
381
381
  ```
382
382
 
383
383
  Load the printed extension path once from `chrome://extensions`. Starting with the next signed stable release, Codex Overleaf Link checks GitHub Releases automatically, downloads and verifies the coordinated extension/native-host bundle, waits until every connected Overleaf tab is saved and idle, and then updates both components together. A failed health check restores the previous version automatically.
@@ -387,11 +387,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
387
387
  The legacy native-only installer remains available for source or unmanaged extension directories:
388
388
 
389
389
  ```bash
390
- npm exec --yes codex-overleaf-link@1.9.7 -- install-native
390
+ npm exec --yes codex-overleaf-link@1.9.9 -- install-native
391
391
  ```
392
392
 
393
393
  Legacy native-only installations can be removed with:
394
394
 
395
395
  ```bash
396
- npm exec --yes codex-overleaf-link@1.9.7 -- uninstall-native
396
+ npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-native
397
397
  ```
@@ -6,11 +6,23 @@ const UPDATE_STATE_KEY = 'codex-overleaf-managed-update-state-v1';
6
6
  const UPDATE_RELOAD_TABS_KEY = 'codex-overleaf-managed-update-tabs-v1';
7
7
  const CHECK_ALARM = 'codex-overleaf-stable-update-check';
8
8
  const IDLE_ALARM = 'codex-overleaf-staged-update-idle';
9
- const OVERLEAF_MATCHES = [
9
+ const OVERLEAF_EDITOR_MATCHES = [
10
10
  'https://www.overleaf.com/project/*',
11
11
  'https://overleaf.com/project/*'
12
12
  ];
13
+ const OVERLEAF_MATCHES = [
14
+ 'https://www.overleaf.com/project',
15
+ 'https://overleaf.com/project',
16
+ ...OVERLEAF_EDITOR_MATCHES
17
+ ];
13
18
  const APPLYING_STATES = new Set(['applying', 'awaiting_health', 'rolling_back']);
19
+ const FAST_IDLE_RETRY_BLOCKERS = new Set(['recent_user_activity', 'save_state_not_stable']);
20
+ const FAST_IDLE_RETRY_MS = 4000;
21
+ const SLOW_IDLE_RETRY_MS = 15000;
22
+ const IDLE_RETRY_ALARM_MINUTES = 0.5;
23
+
24
+ let idleRetryTimer = null;
25
+ let idleApplyPromise = null;
14
26
 
15
27
  let runtimeLoadError = null;
16
28
  try {
@@ -80,7 +92,7 @@ async function initializeBootstrap() {
80
92
  chrome.alarms.create(CHECK_ALARM, { delayInMinutes: 0.5, periodInMinutes: 24 * 60 });
81
93
  const state = await getUpdateState();
82
94
  if (state.state === 'staged' || state.state === 'waiting_for_idle') {
83
- chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 0.1 });
95
+ scheduleIdleRetry(state.blockers);
84
96
  }
85
97
  }
86
98
 
@@ -183,19 +195,28 @@ async function checkAndStage(options = {}) {
183
195
  blockers: []
184
196
  });
185
197
  await broadcastUpdateState('staged');
186
- chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 0.1 });
187
198
  return tryApplyStagedUpdate();
188
199
  }
189
200
 
190
- async function tryApplyStagedUpdate() {
201
+ function tryApplyStagedUpdate() {
202
+ if (idleApplyPromise) return idleApplyPromise;
203
+ idleApplyPromise = tryApplyStagedUpdateCore().finally(() => {
204
+ idleApplyPromise = null;
205
+ });
206
+ return idleApplyPromise;
207
+ }
208
+
209
+ async function tryApplyStagedUpdateCore() {
210
+ cancelIdleRetryTimer();
191
211
  const state = await getUpdateState();
192
212
  if (!['staged', 'waiting_for_idle'].includes(state.state)) {
213
+ await clearIdleRetry();
193
214
  return state;
194
215
  }
195
216
  if (Number(state.postponeUntil || 0) > Date.now()) {
196
217
  return state;
197
218
  }
198
- const tabs = await chrome.tabs.query({ url: OVERLEAF_MATCHES });
219
+ const tabs = await chrome.tabs.query({ url: OVERLEAF_EDITOR_MATCHES });
199
220
  const probes = await Promise.all(tabs.map(tab => probeTabIdle(tab)));
200
221
  const nativeGate = await requestInternal({ method: 'update.canApply', params: {} }).catch(error => ({
201
222
  ok: false,
@@ -210,10 +231,12 @@ async function tryApplyStagedUpdate() {
210
231
  blocker: blockers[0],
211
232
  blockers
212
233
  });
213
- chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 1 });
234
+ await broadcastUpdateState('waiting_for_idle');
235
+ scheduleIdleRetry(blockers);
214
236
  return waiting;
215
237
  }
216
238
 
239
+ await clearIdleRetry();
217
240
  await chrome.storage.local.set({ [UPDATE_RELOAD_TABS_KEY]: tabs.map(tab => tab.id).filter(Number.isInteger) });
218
241
  await setUpdateState({ ...state, state: 'applying', blocker: '', blockers: [] });
219
242
  await broadcastUpdateState('applying');
@@ -229,6 +252,30 @@ async function tryApplyStagedUpdate() {
229
252
  return { state: 'awaiting_health' };
230
253
  }
231
254
 
255
+ function scheduleIdleRetry(blockers = []) {
256
+ cancelIdleRetryTimer();
257
+ const values = Array.isArray(blockers) ? blockers.filter(Boolean) : [];
258
+ const onlyFastBlockers = values.length > 0 && values.every(value => FAST_IDLE_RETRY_BLOCKERS.has(value));
259
+ const delayMs = onlyFastBlockers ? FAST_IDLE_RETRY_MS : SLOW_IDLE_RETRY_MS;
260
+ idleRetryTimer = setTimeout(() => {
261
+ idleRetryTimer = null;
262
+ tryApplyStagedUpdate().catch(() => {});
263
+ }, delayMs);
264
+ chrome.alarms.create(IDLE_ALARM, { delayInMinutes: IDLE_RETRY_ALARM_MINUTES });
265
+ }
266
+
267
+ function cancelIdleRetryTimer() {
268
+ if (idleRetryTimer !== null) {
269
+ clearTimeout(idleRetryTimer);
270
+ idleRetryTimer = null;
271
+ }
272
+ }
273
+
274
+ async function clearIdleRetry() {
275
+ cancelIdleRetryTimer();
276
+ await chrome.alarms.clear(IDLE_ALARM).catch(() => {});
277
+ }
278
+
232
279
  async function probeTabIdle(tab) {
233
280
  if (!Number.isInteger(tab?.id)) {
234
281
  return { idle: false, blockers: ['tab_unavailable'] };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Codex Overleaf Link",
4
- "version": "1.9.7",
4
+ "version": "1.9.9",
5
5
  "description": "Connect the active Overleaf project to a local Codex bridge.",
6
6
  "icons": {
7
7
  "16": "assets/icons/icon16.png",
@@ -17,6 +17,8 @@
17
17
  "storage"
18
18
  ],
19
19
  "host_permissions": [
20
+ "https://www.overleaf.com/project",
21
+ "https://overleaf.com/project",
20
22
  "https://www.overleaf.com/project/*",
21
23
  "https://overleaf.com/project/*"
22
24
  ],
@@ -13,18 +13,6 @@
13
13
  </div>
14
14
  <button id="open-panel" data-popup-context>Open panel in Overleaf</button>
15
15
  <p id="status" data-popup-context>Use this on an Overleaf project tab.</p>
16
- <section class="updates" aria-labelledby="updates-title">
17
- <div class="section-head">
18
- <strong id="updates-title">Stable updates</strong>
19
- <span id="update-state" class="update-state">Checking</span>
20
- </div>
21
- <p id="update-versions">Current unknown · Latest unknown</p>
22
- <p id="update-detail" class="muted">Automatic updates apply when Overleaf is saved and idle.</p>
23
- <div class="update-actions">
24
- <button id="check-update" class="secondary" type="button">Check now</button>
25
- <button id="postpone-update" class="quiet" type="button" hidden>Later</button>
26
- </div>
27
- </section>
28
16
  <div id="native-install" class="install" data-popup-context hidden>
29
17
  <strong>Native host attention required</strong>
30
18
  <p>Run this command in Terminal, then reload this extension in Chrome.</p>
@@ -34,6 +22,5 @@
34
22
  <script src="../runtime/src/shared/compatibility.js"></script>
35
23
  <script src="../runtime/src/popup.js"></script>
36
24
  <script src="updateStatus.js"></script>
37
- <script src="popup.js"></script>
38
25
  </body>
39
26
  </html>
@@ -176,10 +176,7 @@
176
176
  if (ACTIVE_PHASES.has(phase)) {
177
177
  return [{ id: 'close', label: 'Close window', kind: 'quiet' }];
178
178
  }
179
- return [
180
- { id: 'close', label: 'Close', kind: 'quiet' },
181
- { id: 'check', label: 'Check latest', kind: 'primary' }
182
- ];
179
+ return [{ id: 'close', label: 'Close', kind: 'quiet' }];
183
180
  }
184
181
 
185
182
  function renderActions(phase) {
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "matches": [
4
+ "https://www.overleaf.com/project",
5
+ "https://overleaf.com/project",
4
6
  "https://www.overleaf.com/project/*",
5
7
  "https://overleaf.com/project/*"
6
8
  ],
@@ -10,6 +10,8 @@
10
10
  const CHECK_REQUEST_TIMEOUT_MS = 15 * 1000;
11
11
  const LEGACY_GUARD = Number.MAX_SAFE_INTEGER;
12
12
  const OVERLEAF_MATCHES = [
13
+ 'https://www.overleaf.com/project',
14
+ 'https://overleaf.com/project',
13
15
  'https://www.overleaf.com/project/*',
14
16
  'https://overleaf.com/project/*'
15
17
  ];
@@ -412,13 +414,16 @@
412
414
  }
413
415
 
414
416
  function isAllowedSender(sender) {
415
- if (sender?.id && sender.id !== chrome.runtime.id) return false;
416
- if (!sender?.tab) return true;
417
+ if (sender?.id !== chrome.runtime.id) return false;
417
418
  try {
418
- const url = new URL(sender.tab.url || '');
419
+ const url = new URL(sender?.url || sender?.tab?.url || '');
420
+ const extensionRoot = new URL(chrome.runtime.getURL(''));
421
+ if (url.origin === extensionRoot.origin) {
422
+ return url.pathname === '/bootstrap/popup.html';
423
+ }
419
424
  return url.protocol === 'https:' &&
420
425
  (url.hostname === 'www.overleaf.com' || url.hostname === 'overleaf.com') &&
421
- url.pathname.startsWith('/project/');
426
+ (url.pathname === '/project' || url.pathname.startsWith('/project/'));
422
427
  } catch (_error) {
423
428
  return false;
424
429
  }
@@ -715,7 +715,7 @@
715
715
  reviewAction: trackedChangeInFlight.size > 0,
716
716
  dialog: Boolean(activePluginConfirmResolve)
717
717
  }),
718
- checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs: 0, pollIntervalMs: 1 }),
718
+ checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs: 1500, pollIntervalMs: 100, requirePositiveSignal: true }),
719
719
  onApplyingChange: applying => { if (panel) panel.dataset.updating = applying ? 'true' : 'false'; },
720
720
  showToast: (...args) => showPluginToast(...args),
721
721
  getStateMessage: state => ({
@@ -146,6 +146,18 @@
146
146
  <p class="codex-set-row-help" data-i18n="languageHelp">Panel display language.</p>
147
147
  </div>
148
148
  </details>
149
+ <details class="codex-set-group" data-set-group="updates" open>
150
+ <summary class="codex-set-group-head">
151
+ <span class="codex-set-group-title">${codexSetIcon('appearance')}<span data-i18n="softwareUpdatesTitle">Software updates</span></span>
152
+ </summary>
153
+ <div class="codex-set-card" data-update-settings>
154
+ <div class="codex-set-row">
155
+ <p class="codex-set-row-help" data-update-settings-summary data-i18n="softwareUpdatesHelp">Automatically checks signed stable releases for the Extension and Native Host.</p>
156
+ <p class="codex-set-note" data-update-settings-state aria-live="polite" hidden></p>
157
+ <button type="button" class="codex-set-btn" data-check-updates data-i18n="checkForUpdates">Check for updates</button>
158
+ </div>
159
+ </div>
160
+ </details>
149
161
  <details class="codex-set-group" data-set-group="storage" data-storage-card>
150
162
  <summary class="codex-set-group-head">
151
163
  <span class="codex-set-group-title">${codexSetIcon('database')}<span data-i18n="storageTitle">History &amp; storage</span></span>
@@ -6,7 +6,11 @@
6
6
  let stableSavedSince = 0;
7
7
  let applying = false;
8
8
  const documentRef = options.document || root.document;
9
- const noteActivity = () => { lastUserActivityAt = Date.now(); stableSavedSince = 0; };
9
+ const noteActivity = event => {
10
+ if (event?.target?.closest?.('#codex-overleaf-panel')) return;
11
+ lastUserActivityAt = Date.now();
12
+ stableSavedSince = 0;
13
+ };
10
14
  for (const eventName of ['input', 'keydown', 'pointerdown']) {
11
15
  documentRef?.addEventListener?.(eventName, noteActivity, true);
12
16
  }
@@ -5,9 +5,10 @@
5
5
  let currentView = null;
6
6
  let mountedPanel = null;
7
7
  let actionInFlight = false;
8
- let completionTimer = null;
9
8
  let listenerInstalled = false;
10
9
  let getLocale = () => '';
10
+ let settingsRoot = null;
11
+ let settingsActionInFlight = false;
11
12
 
12
13
  function mount(panelLike, options = {}) {
13
14
  if (typeof options.getLocale === 'function') {
@@ -16,10 +17,12 @@
16
17
  const panel = panelLike?.panelEl || panelLike;
17
18
  if (!panel) return;
18
19
  if (mountedPanel === panel) {
20
+ bindSettingsControls(panel);
19
21
  render();
20
22
  return;
21
23
  }
22
24
  mountedPanel = panel;
25
+ bindSettingsControls(panel);
23
26
  notice?.remove();
24
27
  notice = document.createElement('section');
25
28
  notice.className = 'codex-update-notice';
@@ -61,8 +64,9 @@
61
64
  try {
62
65
  currentView = await request({
63
66
  install: 'codex-overleaf/consent-update-install',
67
+ retry: 'codex-overleaf/consent-update-check',
64
68
  later: 'codex-overleaf/consent-update-later',
65
- retry: 'codex-overleaf/consent-update-check'
69
+ dismiss: 'codex-overleaf/consent-update-dismiss'
66
70
  }[action]);
67
71
  } catch (error) {
68
72
  currentView = {
@@ -93,9 +97,53 @@
93
97
  return response.result;
94
98
  }
95
99
 
100
+ function bindSettingsControls(panel) {
101
+ settingsRoot = panel;
102
+ const button = panel.querySelector?.('[data-check-updates]');
103
+ if (button && button.dataset.updateSettingsBound !== 'true') {
104
+ button.dataset.updateSettingsBound = 'true';
105
+ button.addEventListener('click', handleSettingsAction);
106
+ }
107
+ renderSettings();
108
+ }
109
+
110
+ async function handleSettingsAction() {
111
+ if (settingsActionInFlight) return;
112
+ settingsActionInFlight = true;
113
+ renderSettings();
114
+ const stateName = currentView?.state?.state || 'idle';
115
+ try {
116
+ if (stateName === 'update_available') {
117
+ currentView = await request('codex-overleaf/consent-update-install');
118
+ } else if (['failed', 'rolled_back'].includes(stateName)) {
119
+ currentView = await request('codex-overleaf/consent-update-check');
120
+ } else if (!['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'].includes(stateName)) {
121
+ currentView = await request('codex-overleaf/consent-update-check');
122
+ } else {
123
+ return;
124
+ }
125
+ } catch (error) {
126
+ currentView = {
127
+ ...(currentView || {}),
128
+ state: {
129
+ ...(currentView?.state || {}),
130
+ state: 'failed',
131
+ code: error?.code || 'update_failed',
132
+ message: error?.message || tx('Update check failed.', '更新检查失败。')
133
+ },
134
+ progress: { value: 0, determinate: true, phase: 'failed' },
135
+ showPanel: true
136
+ };
137
+ } finally {
138
+ settingsActionInFlight = false;
139
+ render();
140
+ }
141
+ }
142
+
96
143
  function render() {
97
- if (!notice || !currentView) return;
98
- clearTimeout(completionTimer);
144
+ if (!currentView) return;
145
+ renderSettings();
146
+ if (!notice) return;
99
147
  if (!currentView.showPanel) {
100
148
  notice.hidden = true;
101
149
  notice.replaceChildren();
@@ -150,11 +198,53 @@
150
198
  if (focusedAction) {
151
199
  notice.querySelector('[data-update-notice-action="' + focusedAction + '"]:not(:disabled)')?.focus();
152
200
  }
153
- if (state.state === 'committed') {
154
- completionTimer = setTimeout(() => {
155
- if (notice?.dataset.state === 'committed') notice.hidden = true;
156
- }, 5000);
201
+ }
202
+
203
+ function renderSettings() {
204
+ if (!settingsRoot) return;
205
+ const summary = settingsRoot.querySelector?.('[data-update-settings-summary]');
206
+ const status = settingsRoot.querySelector?.('[data-update-settings-state]');
207
+ const button = settingsRoot.querySelector?.('[data-check-updates]');
208
+ if (!summary || !status || !button) return;
209
+
210
+ const state = currentView?.state || {};
211
+ const stateName = state.state || 'idle';
212
+ const manifestVersion = typeof chrome.runtime.getManifest === 'function'
213
+ ? chrome.runtime.getManifest().version
214
+ : '';
215
+ const currentVersion = state.currentVersion || manifestVersion || '';
216
+ const latestVersion = state.latestVersion || '';
217
+ const activeStates = ['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'];
218
+ let summaryText = tx(
219
+ `Current v${currentVersion}. Signed stable releases are checked automatically.`,
220
+ `当前版本 v${currentVersion}。系统会自动检查签名稳定版本。`
221
+ );
222
+ let statusText = '';
223
+ let buttonText = tx('Check for updates', '检查更新');
224
+
225
+ if (stateName === 'checking') {
226
+ statusText = tx('Checking the latest stable release…', '正在检查最新稳定版本…');
227
+ buttonText = tx('Checking…', '检查中…');
228
+ } else if (stateName === 'update_available') {
229
+ summaryText = tx(`Stable v${latestVersion} is available.`, `稳定版本 v${latestVersion} 已可用。`);
230
+ statusText = tx('Ready to download and verify.', '已可下载并验证。');
231
+ buttonText = tx('Update now', '立即更新');
232
+ } else if (activeStates.includes(stateName)) {
233
+ statusText = getCopy(state).detail;
234
+ buttonText = tx('Update in progress', '更新进行中');
235
+ } else if (stateName === 'failed' || stateName === 'rolled_back') {
236
+ statusText = state.message || getCopy(state).detail;
237
+ buttonText = tx('Retry', '重试');
238
+ } else if (stateName === 'committed') {
239
+ summaryText = tx(`Current v${currentVersion}. Update completed successfully.`, `当前版本 v${currentVersion}。更新已成功完成。`);
240
+ statusText = tx('Both components passed the health check.', '两个组件均已通过健康检查。');
157
241
  }
242
+
243
+ summary.textContent = summaryText;
244
+ status.textContent = statusText;
245
+ status.hidden = !statusText;
246
+ button.textContent = buttonText;
247
+ button.disabled = settingsActionInFlight || stateName === 'checking' || activeStates.includes(stateName);
158
248
  }
159
249
 
160
250
  function visibleActions(state) {
@@ -171,12 +261,15 @@
171
261
  if (['failed', 'rolled_back'].includes(state)) {
172
262
  return [{ id: 'retry', label: tx('Retry', '重试'), primary: true }];
173
263
  }
264
+ if (state === 'committed') {
265
+ return [{ id: 'dismiss', label: tx('Done', '完成'), primary: true }];
266
+ }
174
267
  return [];
175
268
  }
176
269
 
177
270
  function getCopy(state) {
178
271
  const target = state.latestVersion ? 'v' + state.latestVersion : '';
179
- const blocker = blockerCopy(state.blocker);
272
+ const blocker = blockersCopy(state.blockers?.length ? state.blockers : [state.blocker]);
180
273
  return {
181
274
  update_available: {
182
275
  eyebrow: tx('Update available', '发现新版本'),
@@ -230,15 +323,35 @@
230
323
  return {
231
324
  unsaved: tx('Overleaf has not confirmed that this document is saved.', 'Overleaf 尚未确认当前文档已保存。'),
232
325
  active_run: tx('A Codex task is still running.', 'Codex 任务仍在运行。'),
326
+ run: tx('A Codex task is still running in an Overleaf tab.', '某个 Overleaf 标签页中的 Codex 任务仍在运行。'),
233
327
  cancelling: tx('Cancellation is still settling.', '取消操作仍在收尾。'),
234
328
  storage_write: tx('Extension state is still being saved.', '扩展状态仍在保存。'),
329
+ storage: tx('Extension state is still being saved.', '扩展状态仍在保存。'),
235
330
  review_action: tx('Accept or Undo is still running.', '接受或撤销操作仍在进行。'),
331
+ reviewAction: tx('Accept or Undo is still running.', '接受或撤销操作仍在进行。'),
236
332
  dialog_open: tx('A confirmation dialog is open.', '确认对话框仍处于打开状态。'),
333
+ dialog: tx('A confirmation dialog is open.', '确认对话框仍处于打开状态。'),
334
+ recent_user_activity: tx('Waiting briefly after the latest editor activity.', '正在等待最近一次编辑操作稳定下来。'),
335
+ save_state_not_stable: tx('The saved state is being confirmed.', '正在确认稳定的已保存状态。'),
336
+ save_state_unverified: tx('An Overleaf tab has not verified its saved state yet.', '某个 Overleaf 标签页尚未验证已保存状态。'),
337
+ tab_probe_timeout: tx('An Overleaf tab did not answer the safety check. Reload that tab if this persists.', '某个 Overleaf 标签页未响应安全检查;若持续出现,请刷新该标签页。'),
338
+ tab_probe_unavailable: tx('An Overleaf tab needs to be reloaded before it can join the safety check.', '某个 Overleaf 标签页需要刷新后才能参与安全检查。'),
339
+ tab_unavailable: tx('An Overleaf tab is unavailable for the safety check.', '某个 Overleaf 标签页当前无法完成安全检查。'),
340
+ idle_probe_failed: tx('The Overleaf safety check failed. Reload the affected tab and retry.', 'Overleaf 安全检查失败;请刷新受影响的标签页后重试。'),
237
341
  native_project_locked: tx('Native Host still holds a project lock.', 'Native Host 仍持有项目锁。'),
238
- native_run_active: tx('Native Host is still processing a task.', 'Native Host 仍在处理任务。')
342
+ native_run_active: tx('Native Host is still processing a task.', 'Native Host 仍在处理任务。'),
343
+ busy: tx('A component is still busy.', '某个组件仍处于忙碌状态。')
239
344
  }[value] || tx('Waiting until every Overleaf tab is saved and idle.', '正在等待所有 Overleaf 标签页完成保存并进入空闲状态。');
240
345
  }
241
346
 
347
+ function blockersCopy(values = []) {
348
+ const messages = [...new Set(values.filter(Boolean).map(blockerCopy))];
349
+ return messages.join(' ') || tx(
350
+ 'Waiting until every Overleaf tab is saved and idle.',
351
+ '正在等待所有 Overleaf 标签页完成保存并进入空闲状态。'
352
+ );
353
+ }
354
+
242
355
  function tx(english, chinese) {
243
356
  const locale = String(getLocale() || document.documentElement?.lang || 'en');
244
357
  return /^zh\b/i.test(locale) ? chinese : english;
@@ -248,39 +248,9 @@
248
248
 
249
249
  function scheduleConsentUpdateUi() {
250
250
  const start = () => {
251
- if (typeof document.createElement !== 'function') return;
252
- injectConsentUpdateStyles();
253
- const section = ensureUpdateSection();
254
- let actionInFlight = false;
255
- let currentView = null;
256
-
257
- section.addEventListener('click', async event => {
258
- const action = event.target?.closest?.('[data-update-action]')?.dataset?.updateAction;
259
- if (!action || actionInFlight) return;
260
- actionInFlight = true;
261
- renderUpdateSection(section, currentView, { busyAction: action });
262
- try {
263
- currentView = await sendConsentAction(action);
264
- } catch (error) {
265
- currentView = failedUpdateView(currentView, error);
266
- } finally {
267
- actionInFlight = false;
268
- renderUpdateSection(section, currentView);
269
- }
270
- });
271
-
272
- chrome.runtime.onMessage.addListener(message => {
273
- if (message?.type !== 'codex-overleaf/consent-update-state') return;
274
- currentView = message.view;
275
- if (!actionInFlight) renderUpdateSection(section, currentView);
276
- });
277
-
278
- sendConsentAction('get')
279
- .then(view => {
280
- currentView = view;
281
- renderUpdateSection(section, view);
282
- })
283
- .catch(error => renderUpdateSection(section, failedUpdateView(null, error)));
251
+ if (typeof document.querySelector !== 'function') return;
252
+ document.querySelector('.updates')?.remove();
253
+ document.body?.classList?.remove('consent-update-focus');
284
254
  };
285
255
 
286
256
  if (document.readyState === 'loading') {
@@ -12,7 +12,7 @@
12
12
  const MIN_NATIVE_VERSION = '1.0.0';
13
13
  const MIN_COMPATIBLE_NATIVE_VERSION = '1.0.0';
14
14
  const MIN_COMPATIBLE_EXTENSION_VERSION = '1.0.0';
15
- const BUILD_TARGET_VERSION = '1.9.7';
15
+ const BUILD_TARGET_VERSION = '1.9.9';
16
16
  const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
17
17
  const REQUIRED_CAPABILITIES = Object.freeze([
18
18
  'bridgePing',
@@ -284,6 +284,9 @@
284
284
  eventsTruncatedNote: 'Earlier steps of this run were trimmed.',
285
285
  newSessionTooltip: 'Start a fresh conversation — the current session\u2019s context will not carry over',
286
286
  storageTitle: 'History & storage',
287
+ softwareUpdatesTitle: 'Software updates',
288
+ softwareUpdatesHelp: 'Automatically checks signed stable releases for the Extension and Native Host.',
289
+ checkForUpdates: 'Check for updates',
287
290
  storageUsageLoading: 'Calculating usage\u2026',
288
291
  storageClearAll: 'Clear all history\u2026',
289
292
  storageClearAllHelp: 'Removes every stored session, run and audit record for all projects. Project settings and rules are kept.',
@@ -756,6 +759,9 @@
756
759
  eventsTruncatedNote: '本轮更早的步骤已精简。',
757
760
  newSessionTooltip: '开启全新对话——当前会话的上下文不会带入',
758
761
  storageTitle: '历史与存储',
762
+ softwareUpdatesTitle: '软件更新',
763
+ softwareUpdatesHelp: '自动检查 Extension 与 Native Host 的签名稳定版本。',
764
+ checkForUpdates: '检查更新',
759
765
  storageUsageLoading: '正在计算占用…',
760
766
  storageClearAll: '清空全部历史…',
761
767
  storageClearAllHelp: '删除所有项目已存储的全部会话、运行与审计记录。项目设置与规则会保留。',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-overleaf-link",
3
- "version": "1.9.7",
3
+ "version": "1.9.9",
4
4
  "description": "Cross-platform Chrome bridge that connects Codex to the active Overleaf project.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",