codex-overleaf-link 2.1.3 → 2.1.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.
- package/README.md +23 -23
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/runtime-manifest.json +1 -0
- package/extension/src/content/composerPanel.js +5 -1
- package/extension/src/content/contentRuntime.js +7 -10
- package/extension/src/content/modelPicker.js +5 -1
- package/extension/src/content/otWarmMirror.js +1 -1
- package/extension/src/content/projectSessionCleanup.js +100 -0
- package/extension/src/content/providerSettingsCoordinator.js +5 -1
- package/extension/src/content/recentProjects.js +17 -11
- package/extension/src/content/runController.js +4 -3
- package/extension/src/content/writebackController.js +3 -3
- package/extension/src/shared/agentTranscript.js +23 -23
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/i18n.js +16 -0
- package/extension/src/shared/sessionState.js +3 -0
- package/extension/styles/panel.css +51 -3
- package/native-host/src/codexSessionRunner.js +1 -1
- package/native-host/src/diffEngine.js +10 -5
- package/native-host/src/taskRunnerRuntime.js +24 -17
- package/package.json +1 -1
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-2.1.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-2.1.5-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=v2.1.
|
|
41
|
+
CODEX_OVERLEAF_REF=v2.1.5 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.5/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/v2.1.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v2.1.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.5/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v2.1.5'
|
|
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@2.1.
|
|
59
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- 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@2.1.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@2.1.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@2.1.
|
|
89
|
+
| Install / update | `npm exec --yes codex-overleaf-link@2.1.5 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@2.1.5 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@2.1.5 -- 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 v2.1.
|
|
101
|
+
The v2.1.5 GitHub Release contains:
|
|
102
102
|
|
|
103
|
-
- `codex-overleaf-link-extension-v2.1.
|
|
104
|
-
- `codex-overleaf-native-host-v2.1.
|
|
105
|
-
- `codex-overleaf-link-2.1.
|
|
106
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.1.
|
|
107
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.
|
|
103
|
+
- `codex-overleaf-link-extension-v2.1.5.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v2.1.5.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-2.1.5.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
|
|
106
|
+
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.1.5` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.5` 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 v2.1.3 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@2.1.
|
|
118
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- 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=v2.1.
|
|
153
|
+
CODEX_OVERLEAF_REF=v2.1.5 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.5/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@2.1.
|
|
159
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-managed --browser chromium
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Features
|
|
@@ -292,7 +292,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
|
|
|
292
292
|
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.
|
|
293
293
|
|
|
294
294
|
```bash
|
|
295
|
-
npm exec --yes codex-overleaf-link@2.1.
|
|
295
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- install-managed
|
|
296
296
|
```
|
|
297
297
|
|
|
298
298
|
**The Windows popup or panel shows a Bash recovery command**
|
|
@@ -341,8 +341,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
|
|
|
341
341
|
| Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
|
|
342
342
|
| 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`. |
|
|
343
343
|
| 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`. |
|
|
344
|
-
| Installer/update command | `npm exec --yes codex-overleaf-link@2.1.
|
|
345
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@2.1.
|
|
344
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@2.1.5 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- install-managed --browser chromium` |
|
|
345
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-managed --browser chromium` |
|
|
346
346
|
| 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` |
|
|
347
347
|
| 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`. |
|
|
348
348
|
| 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. |
|
|
@@ -378,7 +378,7 @@ Contributions are welcome. Please open an issue before submitting large changes
|
|
|
378
378
|
The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
|
|
379
379
|
|
|
380
380
|
```bash
|
|
381
|
-
npm exec --yes codex-overleaf-link@2.1.
|
|
381
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- install-managed
|
|
382
382
|
```
|
|
383
383
|
|
|
384
384
|
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.
|
|
@@ -388,11 +388,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
|
|
|
388
388
|
The legacy native-only installer remains available for source or unmanaged extension directories:
|
|
389
389
|
|
|
390
390
|
```bash
|
|
391
|
-
npm exec --yes codex-overleaf-link@2.1.
|
|
391
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- install-native
|
|
392
392
|
```
|
|
393
393
|
|
|
394
394
|
Legacy native-only installations can be removed with:
|
|
395
395
|
|
|
396
396
|
```bash
|
|
397
|
-
npm exec --yes codex-overleaf-link@2.1.
|
|
397
|
+
npm exec --yes codex-overleaf-link@2.1.5 -- uninstall-native
|
|
398
398
|
```
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"src/content/applyResultFormatters.js",
|
|
59
59
|
"src/content/modelPickerSupport.js",
|
|
60
60
|
"src/content/modelPicker.js",
|
|
61
|
+
"src/content/projectSessionCleanup.js",
|
|
61
62
|
"src/content/recentProjects.js",
|
|
62
63
|
"src/content/otWarmMirror.js",
|
|
63
64
|
"src/content/writebackOrchestrator.js",
|
|
@@ -49,7 +49,11 @@
|
|
|
49
49
|
</label>
|
|
50
50
|
<div class="codex-model-config" data-model-config>
|
|
51
51
|
<button type="button" class="codex-model-config-button" data-model-config-toggle aria-haspopup="menu" aria-expanded="false">
|
|
52
|
-
<span class="codex-model-speed-indicator" data-speed-indicator hidden
|
|
52
|
+
<span class="codex-model-speed-indicator" data-speed-indicator hidden aria-hidden="true">
|
|
53
|
+
<svg viewBox="0 0 16 16" focusable="false">
|
|
54
|
+
<path d="M8.9 1.8 3.8 8.8h3.3l-.5 5.4 5.5-7.5H8.8z"></path>
|
|
55
|
+
</svg>
|
|
56
|
+
</span>
|
|
53
57
|
<span data-model-display>5.4</span>
|
|
54
58
|
<span data-reasoning-display>Medium</span>
|
|
55
59
|
</button>
|
|
@@ -604,7 +604,7 @@
|
|
|
604
604
|
window,
|
|
605
605
|
getSettingsPanelInstance: () => settingsPanelInstance,
|
|
606
606
|
getSelectedModel: () => state?.model || '', getSelectedProviderId: () => state?.providerId || 'builtin',
|
|
607
|
-
setSelectedProviderId: providerId => { state = updateActiveSession(state, { providerId: providerId || 'builtin' }); },
|
|
607
|
+
setSelectedProviderId: (providerId, model) => { state = updateActiveSession(state, { providerId: providerId || 'builtin', ...(model !== undefined ? { model } : {}) }); const modelSelect = panel?.querySelector('[data-model]'); if (model !== undefined && modelSelect) modelSelect.value = ''; },
|
|
608
608
|
refreshModelOptions: loadModelOptions, persistInputs: persistPanelInputs
|
|
609
609
|
});
|
|
610
610
|
// v1.8.1 D3: the dashboard was a one-shot render — another tab finishing a
|
|
@@ -1727,13 +1727,10 @@
|
|
|
1727
1727
|
return;
|
|
1728
1728
|
}
|
|
1729
1729
|
appendRunEvent({
|
|
1730
|
-
//
|
|
1731
|
-
// reads and writes to these files (shouldRestrictWritebackToFocus),
|
|
1732
|
-
// it does not merely "prioritize" them. The selection persists across
|
|
1733
|
-
// turns until cleared via the + tray.
|
|
1730
|
+
// @context prioritizes these files; complete project runs may still update related files.
|
|
1734
1731
|
title: tx(
|
|
1735
|
-
`This run
|
|
1736
|
-
|
|
1732
|
+
`This run will prioritize: ${formatContextItems(getActiveFocusFiles())} (persists across turns; clear via +)`,
|
|
1733
|
+
`本轮将优先处理:${formatContextItems(getActiveFocusFiles())}(跨轮保留,可在 + 中清除)`
|
|
1737
1734
|
),
|
|
1738
1735
|
status: 'completed'
|
|
1739
1736
|
});
|
|
@@ -1785,7 +1782,7 @@
|
|
|
1785
1782
|
focusFiles,
|
|
1786
1783
|
isUsableProjectFileContent: window.CodexOverleafProjectFiles.isUsableProjectFileContent
|
|
1787
1784
|
});
|
|
1788
|
-
let restrictToFocusFiles = runController.shouldRestrictWritebackToFocus({ focusFiles });
|
|
1785
|
+
let restrictToFocusFiles = runController.shouldRestrictWritebackToFocus({ focusFiles, focusedPartialSnapshot });
|
|
1789
1786
|
if (snapshotWarnings.blocking.length && !warmMirrorReuse.useExistingMirror && !focusedPartialSnapshot) {
|
|
1790
1787
|
for (const warning of snapshotWarnings.blocking) {
|
|
1791
1788
|
appendLog(tx(`Cannot continue: ${formatProjectSnapshotWarning(warning)}`, `无法继续:${formatProjectSnapshotWarning(warning)}`));
|
|
@@ -1827,8 +1824,8 @@
|
|
|
1827
1824
|
if (Array.isArray(warmMirrorReuse.focusFiles) && warmMirrorReuse.focusFiles.length) {
|
|
1828
1825
|
focusFiles = warmMirrorReuse.focusFiles;
|
|
1829
1826
|
}
|
|
1830
|
-
restrictToFocusFiles = true;
|
|
1831
1827
|
}
|
|
1828
|
+
restrictToFocusFiles = runController.shouldRestrictWritebackToFocus({ focusFiles, focusedPartialSnapshot: warmMirrorReuse.partialSnapshot, otWarmStart });
|
|
1832
1829
|
appendRunEvent({
|
|
1833
1830
|
title: warmMirrorReuse.warmStart
|
|
1834
1831
|
? tr('warmMirrorReuseTitle')
|
|
@@ -6313,7 +6310,7 @@
|
|
|
6313
6310
|
saveStateSoon();
|
|
6314
6311
|
return;
|
|
6315
6312
|
}
|
|
6316
|
-
renderReasoningOptions(getRenderedModelEntries());
|
|
6313
|
+
if (event?.target?.matches?.('[data-speed]')) state = updateActiveSession(state, { speedTier: readSelectedSpeedInput() }); renderReasoningOptions(getRenderedModelEntries());
|
|
6317
6314
|
renderSpeedOptions(getRenderedModelEntries());
|
|
6318
6315
|
readPanelInputs();
|
|
6319
6316
|
renderModelConfigChoices();
|
|
@@ -83,20 +83,24 @@
|
|
|
83
83
|
const modelSelect = getPanel()?.querySelector('[data-model]');
|
|
84
84
|
const reasoningSelect = getPanel()?.querySelector('[data-reasoning]');
|
|
85
85
|
const speedSelect = getPanel()?.querySelector('[data-speed]');
|
|
86
|
+
let changedInput = null;
|
|
86
87
|
|
|
87
88
|
if (choice.dataset.reasoningChoice && reasoningSelect) {
|
|
88
89
|
reasoningSelect.value = choice.dataset.reasoningChoice;
|
|
90
|
+
changedInput = reasoningSelect;
|
|
89
91
|
} else if (choice.dataset.modelChoice && modelSelect) {
|
|
90
92
|
modelSelect.value = choice.dataset.modelChoice;
|
|
93
|
+
changedInput = modelSelect;
|
|
91
94
|
renderReasoningOptions(getRenderedModelEntries());
|
|
92
95
|
renderSpeedOptions(getRenderedModelEntries());
|
|
93
96
|
} else if (choice.dataset.speedChoice && speedSelect) {
|
|
94
97
|
speedSelect.value = choice.dataset.speedChoice;
|
|
98
|
+
changedInput = speedSelect;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
renderModelConfigChoices();
|
|
98
102
|
updateModelDisplay();
|
|
99
|
-
await persistPanelInputs();
|
|
103
|
+
await persistPanelInputs(changedInput ? { type: 'change', target: changedInput } : undefined);
|
|
100
104
|
}
|
|
101
105
|
async function loadModelOptions(providerSelection) {
|
|
102
106
|
const generation = ++modelLoadGeneration;
|
|
@@ -881,7 +881,7 @@
|
|
|
881
881
|
return {
|
|
882
882
|
ok: true,
|
|
883
883
|
project,
|
|
884
|
-
restrictToFocusFiles: runController.shouldRestrictWritebackToFocus({ focusFiles })
|
|
884
|
+
restrictToFocusFiles: runController.shouldRestrictWritebackToFocus({ focusFiles, focusedPartialSnapshot })
|
|
885
885
|
};
|
|
886
886
|
}
|
|
887
887
|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
(function initCodexOverleafProjectSessionCleanup() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const FRESH_RUNNING_WINDOW_MS = 30 * 60 * 1000;
|
|
5
|
+
|
|
6
|
+
function create(deps = {}) {
|
|
7
|
+
const {
|
|
8
|
+
tr,
|
|
9
|
+
getAccountScopeId,
|
|
10
|
+
showPluginConfirm,
|
|
11
|
+
showPluginToast,
|
|
12
|
+
sendBackgroundNative,
|
|
13
|
+
mutateProjectPanelState,
|
|
14
|
+
renderRecentProjectsVariant
|
|
15
|
+
} = deps;
|
|
16
|
+
|
|
17
|
+
function isFreshRunningRecord(StorageDb, record) {
|
|
18
|
+
if (StorageDb.derivePrimaryStatusBadge(record) !== 'running') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const touched = Date.parse(record.updatedAt || record.lastActivityAt || record.createdAt || '');
|
|
22
|
+
return !Number.isFinite(touched) || (Date.now() - touched) <= FRESH_RUNNING_WINDOW_MS;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function clearProjectSessions(projectId, projectName) {
|
|
26
|
+
const StorageDb = window.CodexOverleafStorageDb;
|
|
27
|
+
const SessionState = window.CodexOverleafSessionState;
|
|
28
|
+
if (!StorageDb || !SessionState) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const scope = getAccountScopeId();
|
|
32
|
+
const records = (await StorageDb.getAllByIndex('sessions', 'projectId', projectId))
|
|
33
|
+
.filter(record => record && (!scope || record.accountScopeId === scope));
|
|
34
|
+
if (!records.length) {
|
|
35
|
+
await renderRecentProjectsVariant();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (records.some(record => isFreshRunningRecord(StorageDb, record))) {
|
|
39
|
+
showPluginToast(tr('recentProjects_clearProject_running'), { status: 'warning', sticky: true });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const approved = await showPluginConfirm({
|
|
43
|
+
title: tr('recentProjects_clearProject_title', { project: projectName }),
|
|
44
|
+
message: tr('recentProjects_clearProject_message', { count: String(records.length), project: projectName }),
|
|
45
|
+
confirmLabel: tr('recentProjects_clearProject_confirm'),
|
|
46
|
+
cancelLabel: tr('confirmDefaultCancel'),
|
|
47
|
+
destructive: true
|
|
48
|
+
});
|
|
49
|
+
if (!approved) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
await mutateProjectPanelState(projectId, state => records.reduce(
|
|
54
|
+
(nextState, record) => SessionState.deleteSession(nextState, record.id),
|
|
55
|
+
state
|
|
56
|
+
));
|
|
57
|
+
} catch (_error) { /* IndexedDB deletion remains authoritative for the dashboard. */ }
|
|
58
|
+
|
|
59
|
+
let removed = 0;
|
|
60
|
+
let historyFailures = 0;
|
|
61
|
+
for (const record of records) {
|
|
62
|
+
try {
|
|
63
|
+
await StorageDb.deleteRecord('sessions', record.id);
|
|
64
|
+
removed++;
|
|
65
|
+
} catch (_error) { /* The remaining record stays visible and can be retried. */ }
|
|
66
|
+
try {
|
|
67
|
+
const response = await sendBackgroundNative({
|
|
68
|
+
method: 'codex.history.clearPlugin',
|
|
69
|
+
params: { sessionId: record.id, threadId: record.codexThreadId || '' }
|
|
70
|
+
});
|
|
71
|
+
if (!response || !response.ok) {
|
|
72
|
+
historyFailures++;
|
|
73
|
+
}
|
|
74
|
+
} catch (_error) {
|
|
75
|
+
historyFailures++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (removed < records.length) {
|
|
79
|
+
showPluginToast(tr('recentProjects_clearProject_partial', {
|
|
80
|
+
removed: String(removed),
|
|
81
|
+
count: String(records.length)
|
|
82
|
+
}), { status: 'warning', sticky: true });
|
|
83
|
+
} else if (historyFailures) {
|
|
84
|
+
showPluginToast(tr('recentProjects_clearProject_historyPartial', {
|
|
85
|
+
count: String(historyFailures)
|
|
86
|
+
}), { status: 'warning', sticky: true });
|
|
87
|
+
} else {
|
|
88
|
+
showPluginToast(tr('recentProjects_clearProject_done', {
|
|
89
|
+
count: String(removed),
|
|
90
|
+
project: projectName
|
|
91
|
+
}), { status: 'completed' });
|
|
92
|
+
}
|
|
93
|
+
await renderRecentProjectsVariant();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { clearProjectSessions };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
window.CodexOverleafProjectSessionCleanup = { create };
|
|
100
|
+
})();
|
|
@@ -111,7 +111,11 @@
|
|
|
111
111
|
: previousProviderId;
|
|
112
112
|
const sessionProviderChanged = requestedProviderId !== previousProviderId;
|
|
113
113
|
if (sessionProviderChanged) {
|
|
114
|
-
|
|
114
|
+
const requestedProvider = window.CodexOverleafProviderProfiles.getProviderById(catalog, requestedProviderId);
|
|
115
|
+
const preferredModelId = requestedProvider?.kind === 'custom'
|
|
116
|
+
? requestedProvider.defaultModelId || requestedProvider.models?.[0]?.id || ''
|
|
117
|
+
: '';
|
|
118
|
+
instance.setSelectedProviderId(requestedProviderId, preferredModelId);
|
|
115
119
|
}
|
|
116
120
|
const changedProviderIds = Array.isArray(change.changedProviderIds) ? change.changedProviderIds : [];
|
|
117
121
|
if (!change.forceSessionRefresh && !sessionProviderChanged && !changedProviderIds.includes(requestedProviderId)) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
(function initCodexOverleafRecentProjects() {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
// of contentRuntime.js (v1.4.8 structural-debt phase 4): the account-scoped
|
|
6
|
-
// project-name cache + DOM enrichment, the welcome/empty/degraded states,
|
|
7
|
-
// row rendering, and the per-project/variant switchers. Code moved verbatim;
|
|
8
|
-
// runtime collaborators are factory-injected (the account scope id stays in
|
|
9
|
-
// the runtime and is read through a getter).
|
|
4
|
+
// Cross-project dashboard: account-scoped names, project rows and sessions.
|
|
10
5
|
function create(deps = {}) {
|
|
11
6
|
const {
|
|
12
7
|
tr,
|
|
@@ -24,6 +19,10 @@
|
|
|
24
19
|
PROJECT_EDITOR_RESERVED_IDS,
|
|
25
20
|
STATUS_BADGE_CLASS
|
|
26
21
|
} = deps;
|
|
22
|
+
const projectSessionCleanup = window.CodexOverleafProjectSessionCleanup.create({
|
|
23
|
+
tr, getAccountScopeId: getCachedAccountScopeId, showPluginConfirm, showPluginToast,
|
|
24
|
+
sendBackgroundNative, mutateProjectPanelState, renderRecentProjectsVariant
|
|
25
|
+
});
|
|
27
26
|
|
|
28
27
|
// chrome.storage.local cache key (spec §5.6.3). The cache is keyed by
|
|
29
28
|
// accountScopeId so a second account on the same Chrome profile cannot
|
|
@@ -416,9 +415,6 @@
|
|
|
416
415
|
el.appendChild(textNode(tr('recentProjects_row_projectLinkUnavailable'), 'recent-projects-row-warning'));
|
|
417
416
|
}
|
|
418
417
|
if (!valid) {
|
|
419
|
-
// Dead entry: the session records behind it carry an empty/garbage
|
|
420
|
-
// projectId, so it can never be opened or expanded. Offer a cleanup
|
|
421
|
-
// action that removes those records (and with them, this row).
|
|
422
418
|
var deadWrap = document.createElement('div');
|
|
423
419
|
deadWrap.className = 'recent-projects-row-wrap';
|
|
424
420
|
var deadHead = document.createElement('div');
|
|
@@ -438,8 +434,6 @@
|
|
|
438
434
|
deadWrap.appendChild(deadHead);
|
|
439
435
|
return deadWrap;
|
|
440
436
|
}
|
|
441
|
-
// Wrap the row with an expand toggle + a lazily-populated session list so
|
|
442
|
-
// sessions can be managed (delete/rename) without entering the project.
|
|
443
437
|
var wrap = document.createElement('div');
|
|
444
438
|
wrap.className = 'recent-projects-row-wrap';
|
|
445
439
|
wrap.setAttribute('data-project-row-wrap', projectId);
|
|
@@ -456,8 +450,20 @@
|
|
|
456
450
|
expand.textContent = tr('recentProjects_sessions_action');
|
|
457
451
|
var head = document.createElement('div');
|
|
458
452
|
head.className = 'recent-projects-row-head';
|
|
453
|
+
var clear = document.createElement('button');
|
|
454
|
+
clear.type = 'button';
|
|
455
|
+
clear.className = 'recent-projects-row-clear';
|
|
456
|
+
clear.setAttribute('data-project-clear', '');
|
|
457
|
+
clear.title = tr('recentProjects_clearProject');
|
|
458
|
+
clear.setAttribute('aria-label', tr('recentProjects_clearProject'));
|
|
459
|
+
clear.textContent = '×';
|
|
460
|
+
clear.addEventListener('click', function (event) {
|
|
461
|
+
event.stopPropagation();
|
|
462
|
+
projectSessionCleanup.clearProjectSessions(projectId, name).catch(function () { /* surfaced by the action */ });
|
|
463
|
+
});
|
|
459
464
|
head.appendChild(el);
|
|
460
465
|
head.appendChild(expand);
|
|
466
|
+
head.appendChild(clear);
|
|
461
467
|
var sessionsEl = document.createElement('div');
|
|
462
468
|
sessionsEl.className = 'recent-projects-sessions';
|
|
463
469
|
sessionsEl.setAttribute('data-project-sessions', '');
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
model: state.model,
|
|
50
50
|
reasoningEffort: state.reasoningEffort,
|
|
51
51
|
speedTier: state.speedTier,
|
|
52
|
+
locale: state.locale === 'zh' ? 'zh' : 'en',
|
|
52
53
|
session: state.session,
|
|
53
54
|
threadId: codexThreadId || undefined,
|
|
54
55
|
customInstructions: normalizedCustomInstructions || undefined,
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
return params;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
function buildSessionHistoryResult({ assistantMessage = '', syncOutcome = {}, syncChanges = [], locale = '
|
|
74
|
+
function buildSessionHistoryResult({ assistantMessage = '', syncOutcome = {}, syncChanges = [], locale = 'en' } = {}) {
|
|
74
75
|
const parts = [];
|
|
75
76
|
const finalAnswer = truncateSessionHistoryText(assistantMessage, 1600);
|
|
76
77
|
if (finalAnswer) {
|
|
@@ -129,8 +130,8 @@
|
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
function shouldRestrictWritebackToFocus({ focusFiles = [] } = {}) {
|
|
133
|
-
return normalizeFocusFiles(focusFiles).length > 0;
|
|
133
|
+
function shouldRestrictWritebackToFocus({ focusFiles = [], focusedPartialSnapshot = false, otWarmStart = false } = {}) {
|
|
134
|
+
return normalizeFocusFiles(focusFiles).length > 0 && (focusedPartialSnapshot === true || otWarmStart === true);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
function isFullSnapshotWarning(warning) {
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
function formatUnsupportedLocalChangeSummary(changes = [], locale = '
|
|
196
|
+
function formatUnsupportedLocalChangeSummary(changes = [], locale = 'en') {
|
|
197
197
|
if (!changes.length) {
|
|
198
198
|
return '';
|
|
199
199
|
}
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
return lines.join('\n');
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function formatUnsupportedLocalChangeReason(changeOrReason, locale = '
|
|
221
|
+
function formatUnsupportedLocalChangeReason(changeOrReason, locale = 'en') {
|
|
222
222
|
const isEnglish = locale === 'en';
|
|
223
223
|
const change = typeof changeOrReason === 'object' && changeOrReason
|
|
224
224
|
? changeOrReason
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
: '当前类型暂不支持自动写回。';
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
function formatBinaryPayloadLimitReason(change = {}, locale = '
|
|
250
|
+
function formatBinaryPayloadLimitReason(change = {}, locale = 'en') {
|
|
251
251
|
const isEnglish = locale === 'en';
|
|
252
252
|
const size = formatBytes(change.size);
|
|
253
253
|
const limit = formatBytes(change.limit || change.aggregateLimit || change.nativeOutputLimit);
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
function normalizeLocale(options = {}) {
|
|
52
|
-
return options?.locale === '
|
|
52
|
+
return options?.locale === 'zh' ? 'zh' : 'en';
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function textFor(locale, zh, en) {
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
&& /(context|thread|turn|conversation|codex)/i.test(label);
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
function formatContextCompactionCheckpoint(event = {}, locale = '
|
|
433
|
+
function formatContextCompactionCheckpoint(event = {}, locale = 'en') {
|
|
434
434
|
const method = String(event.detail?.method || event.title || '');
|
|
435
435
|
const running = event.status === 'running' || /(started|starting|begin|prepar)/i.test(method);
|
|
436
436
|
return {
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
return `${prefix}:${itemId || 'current'}`;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
function formatPlanUpdateTitle(params = {}, locale = '
|
|
562
|
+
function formatPlanUpdateTitle(params = {}, locale = 'en') {
|
|
563
563
|
const steps = Array.isArray(params.plan) ? params.plan : [];
|
|
564
564
|
const active = steps.find(step => step.status === 'in_progress') || steps.find(step => step.status === 'pending');
|
|
565
565
|
const text = cleanVisibleText(active?.step || params.explanation || '');
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
: textFor(locale, 'Codex 更新了执行计划。', 'Codex updated its plan.');
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
function formatPlanUpdateDetail(params = {}, locale = '
|
|
571
|
+
function formatPlanUpdateDetail(params = {}, locale = 'en') {
|
|
572
572
|
const steps = Array.isArray(params.plan) ? params.plan : [];
|
|
573
573
|
if (!steps.length) {
|
|
574
574
|
return undefined;
|
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
* part of Codex's answer. `formatHumanReport` retains the legacy flat-text
|
|
893
893
|
* shape for transcripts, storage fallback, and existing assertions.
|
|
894
894
|
*/
|
|
895
|
-
function buildStructuredHumanReport(report = {}, locale = '
|
|
895
|
+
function buildStructuredHumanReport(report = {}, locale = 'en') {
|
|
896
896
|
const conclusion = cleanVisibleMarkdownText(report.conclusion || '');
|
|
897
897
|
|
|
898
898
|
const bodySections = [];
|
|
@@ -939,7 +939,7 @@
|
|
|
939
939
|
return { conclusion, body: bodySections.join('\n\n'), meta };
|
|
940
940
|
}
|
|
941
941
|
|
|
942
|
-
function formatHumanReport(report = {}, locale = '
|
|
942
|
+
function formatHumanReport(report = {}, locale = 'en') {
|
|
943
943
|
const sections = [];
|
|
944
944
|
const conclusion = cleanVisibleMarkdownText(report.conclusion || '');
|
|
945
945
|
if (conclusion) {
|
|
@@ -969,7 +969,7 @@
|
|
|
969
969
|
return sections.join('\n\n');
|
|
970
970
|
}
|
|
971
971
|
|
|
972
|
-
function buildFallbackReport(input, counts, locale = '
|
|
972
|
+
function buildFallbackReport(input, counts, locale = 'en') {
|
|
973
973
|
const operations = Array.isArray(input.operations) ? input.operations : [];
|
|
974
974
|
const appliedOperations = collectAppliedOperations(input.applyResults);
|
|
975
975
|
const affectedFiles = collectAffectedFiles(operations, input.summary, input.applyResults);
|
|
@@ -1023,7 +1023,7 @@
|
|
|
1023
1023
|
return localized.nextAction || primary.nextAction || '';
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
-
function formatWriteResult(appliedCount, skippedCount, locale = '
|
|
1026
|
+
function formatWriteResult(appliedCount, skippedCount, locale = 'en') {
|
|
1027
1027
|
return textFor(
|
|
1028
1028
|
locale,
|
|
1029
1029
|
`已写入 ${appliedCount} 项,跳过 ${skippedCount} 项`,
|
|
@@ -1031,7 +1031,7 @@
|
|
|
1031
1031
|
);
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
|
-
function inferUnchangedReason(input, locale = '
|
|
1034
|
+
function inferUnchangedReason(input, locale = 'en') {
|
|
1035
1035
|
if (input.mode === 'ask' || input.status === '只问不改') {
|
|
1036
1036
|
return textFor(locale, '这轮是只问不改。', 'This run was Ask mode.');
|
|
1037
1037
|
}
|
|
@@ -1041,7 +1041,7 @@
|
|
|
1041
1041
|
return '';
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
|
-
function formatFallbackNextStep(input, skippedCount, affectedFiles, locale = '
|
|
1044
|
+
function formatFallbackNextStep(input, skippedCount, affectedFiles, locale = 'en') {
|
|
1045
1045
|
if (skippedCount) {
|
|
1046
1046
|
return textFor(locale, '请查看本轮报告中的跳过项,处理后可以重试。', 'Review the skipped items in this report, then retry after resolving them.');
|
|
1047
1047
|
}
|
|
@@ -1070,7 +1070,7 @@
|
|
|
1070
1070
|
};
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
-
function technicalOnly(event, locale = '
|
|
1073
|
+
function technicalOnly(event, locale = 'en') {
|
|
1074
1074
|
return {
|
|
1075
1075
|
kind: 'technical',
|
|
1076
1076
|
visible: false,
|
|
@@ -1094,7 +1094,7 @@
|
|
|
1094
1094
|
return TECHNICAL_EVENT_PATTERNS.some(pattern => pattern.test(type));
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
-
function summarizeCommandActivity(event, locale = '
|
|
1097
|
+
function summarizeCommandActivity(event, locale = 'en') {
|
|
1098
1098
|
const type = String(event.type || '');
|
|
1099
1099
|
const command = String(event.detail?.command || '');
|
|
1100
1100
|
const output = String(event.detail?.output || '');
|
|
@@ -1140,7 +1140,7 @@
|
|
|
1140
1140
|
return 'check';
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
1143
|
-
function formatCommandStartedTitle(kind, command, locale = '
|
|
1143
|
+
function formatCommandStartedTitle(kind, command, locale = 'en') {
|
|
1144
1144
|
if (kind === 'search') {
|
|
1145
1145
|
const query = extractSearchQuery(command);
|
|
1146
1146
|
return query ? textFor(locale, `正在搜索项目内容:${query}`, `Searching project content: ${query}`) : textFor(locale, '正在搜索项目内容。', 'Searching project content.');
|
|
@@ -1157,7 +1157,7 @@
|
|
|
1157
1157
|
return textFor(locale, '正在执行一次本地检查。', 'Running a local check.');
|
|
1158
1158
|
}
|
|
1159
1159
|
|
|
1160
|
-
function formatCommandCompletedTitle(kind, output, failed, locale = '
|
|
1160
|
+
function formatCommandCompletedTitle(kind, output, failed, locale = 'en') {
|
|
1161
1161
|
if (failed) {
|
|
1162
1162
|
if (kind === 'search') {
|
|
1163
1163
|
return textFor(locale, '搜索没有正常完成。', 'Search did not finish normally.');
|
|
@@ -1184,7 +1184,7 @@
|
|
|
1184
1184
|
return textFor(locale, '本地检查已完成。', 'Local check completed.');
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
-
function formatCommandPublicDetail(kind, command, locale = '
|
|
1187
|
+
function formatCommandPublicDetail(kind, command, locale = 'en') {
|
|
1188
1188
|
if (kind !== 'search') {
|
|
1189
1189
|
return undefined;
|
|
1190
1190
|
}
|
|
@@ -1235,7 +1235,7 @@
|
|
|
1235
1235
|
return files;
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
-
function formatFilesInline(files = [], locale = '
|
|
1238
|
+
function formatFilesInline(files = [], locale = 'en') {
|
|
1239
1239
|
const values = normalizeStringList(files);
|
|
1240
1240
|
if (!values.length) {
|
|
1241
1241
|
return textFor(locale, '没有文件', 'no files');
|
|
@@ -1300,7 +1300,7 @@
|
|
|
1300
1300
|
.trim();
|
|
1301
1301
|
}
|
|
1302
1302
|
|
|
1303
|
-
function addListSection(sections, label, values, locale = '
|
|
1303
|
+
function addListSection(sections, label, values, locale = 'en') {
|
|
1304
1304
|
const items = normalizeStringList(values);
|
|
1305
1305
|
if (!items.length) {
|
|
1306
1306
|
return;
|
|
@@ -1314,7 +1314,7 @@
|
|
|
1314
1314
|
* rendered report. Per-item first line gets the `- ` bullet; subsequent
|
|
1315
1315
|
* lines pass through verbatim (the formatter already indents them).
|
|
1316
1316
|
*/
|
|
1317
|
-
function addStructuredListSection(sections, label, values, locale = '
|
|
1317
|
+
function addStructuredListSection(sections, label, values, locale = 'en') {
|
|
1318
1318
|
const items = normalizeMultilineStringList(values);
|
|
1319
1319
|
if (!items.length) {
|
|
1320
1320
|
return;
|
|
@@ -1408,7 +1408,7 @@
|
|
|
1408
1408
|
return files;
|
|
1409
1409
|
}
|
|
1410
1410
|
|
|
1411
|
-
function formatOperationLine(operation, locale = '
|
|
1411
|
+
function formatOperationLine(operation, locale = 'en') {
|
|
1412
1412
|
const labels = OPERATION_LABELS[locale] || OPERATION_LABELS.zh;
|
|
1413
1413
|
const label = labels[operation?.type] || operation?.type || textFor(locale, '处理', 'process');
|
|
1414
1414
|
const filePath = operation?.path || operation?.from || operation?.to || textFor(locale, '未知文件', 'unknown file');
|
|
@@ -1418,7 +1418,7 @@
|
|
|
1418
1418
|
: (reason ? `${filePath}:${label}(${reason})` : `${filePath}:${label}`);
|
|
1419
1419
|
}
|
|
1420
1420
|
|
|
1421
|
-
function formatOperationReason(operation, locale = '
|
|
1421
|
+
function formatOperationReason(operation, locale = 'en') {
|
|
1422
1422
|
const key = operation?.reasonKey || '';
|
|
1423
1423
|
const count = Number(operation?.reasonParams?.count || 0);
|
|
1424
1424
|
if (key === 'localWorkspaceDelete') {
|
|
@@ -1440,7 +1440,7 @@
|
|
|
1440
1440
|
return localizeVisibleReason(operation?.reason || '', locale);
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
|
-
function formatSkippedOperationLine(item, locale = '
|
|
1443
|
+
function formatSkippedOperationLine(item, locale = 'en') {
|
|
1444
1444
|
const operation = item?.operation || {};
|
|
1445
1445
|
const labels = OPERATION_LABELS[locale] || OPERATION_LABELS.zh;
|
|
1446
1446
|
const label = labels[operation.type] || operation.type || textFor(locale, '处理', 'process');
|
|
@@ -1547,7 +1547,7 @@
|
|
|
1547
1547
|
};
|
|
1548
1548
|
}
|
|
1549
1549
|
|
|
1550
|
-
function formatSkippedReason(result = {}, operation = {}, locale = '
|
|
1550
|
+
function formatSkippedReason(result = {}, operation = {}, locale = 'en') {
|
|
1551
1551
|
const key = result.reasonKey || '';
|
|
1552
1552
|
const code = result.code || '';
|
|
1553
1553
|
const filePath = result.reasonParams?.filePath || operation?.path || operation?.from || operation?.to || '';
|
|
@@ -1664,7 +1664,7 @@
|
|
|
1664
1664
|
return parts.join(', ');
|
|
1665
1665
|
}
|
|
1666
1666
|
|
|
1667
|
-
function localizeVisibleReason(reason, locale = '
|
|
1667
|
+
function localizeVisibleReason(reason, locale = 'en') {
|
|
1668
1668
|
const text = cleanVisibleText(reason || '');
|
|
1669
1669
|
if (!text || locale !== 'en') {
|
|
1670
1670
|
return text;
|
|
@@ -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 = '2.1.
|
|
15
|
+
const BUILD_TARGET_VERSION = '2.1.5';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -469,6 +469,14 @@
|
|
|
469
469
|
recentProjects_sessions_toggle: "Show / manage this project's sessions",
|
|
470
470
|
recentProjects_sessions_action: 'View runs',
|
|
471
471
|
recentProjects_sessions_action_open: 'Hide runs',
|
|
472
|
+
recentProjects_clearProject: 'Delete all sessions for this project',
|
|
473
|
+
recentProjects_clearProject_title: 'Delete all Codex sessions for {project}?',
|
|
474
|
+
recentProjects_clearProject_message: 'This permanently deletes all {count} plugin sessions, run history, and matching plugin-local Codex thread history for {project}. It will not modify Overleaf files or global Codex history.',
|
|
475
|
+
recentProjects_clearProject_confirm: 'Delete all',
|
|
476
|
+
recentProjects_clearProject_running: 'This project may still have a running Codex task. Cancel it before deleting all sessions.',
|
|
477
|
+
recentProjects_clearProject_done: 'Deleted {count} session(s) from {project}.',
|
|
478
|
+
recentProjects_clearProject_partial: 'Deleted {removed} of {count} sessions. The remaining records are still visible; retry to remove them.',
|
|
479
|
+
recentProjects_clearProject_historyPartial: 'Sessions were deleted, but {count} plugin-local Codex thread history item(s) could not be cleared.',
|
|
472
480
|
recentProjects_cleanup: 'Remove this dead entry',
|
|
473
481
|
recentProjects_cleanup_title: 'Remove dead project entry?',
|
|
474
482
|
recentProjects_cleanup_message: 'This entry has no usable project link, so it cannot be opened or expanded. Removing it deletes all of its session records. This cannot be undone.',
|
|
@@ -954,6 +962,14 @@
|
|
|
954
962
|
recentProjects_sessions_toggle: '查看/管理该项目的会话',
|
|
955
963
|
recentProjects_sessions_action: '查看会话',
|
|
956
964
|
recentProjects_sessions_action_open: '收起会话',
|
|
965
|
+
recentProjects_clearProject: '删除该项目的全部会话',
|
|
966
|
+
recentProjects_clearProject_title: '删除 {project} 的全部 Codex 会话?',
|
|
967
|
+
recentProjects_clearProject_message: '这会永久删除 {project} 的全部 {count} 个插件会话、运行历史及对应的插件本地 Codex 线程历史。不会修改 Overleaf 文件或全局 Codex 历史。',
|
|
968
|
+
recentProjects_clearProject_confirm: '全部删除',
|
|
969
|
+
recentProjects_clearProject_running: '该项目可能仍有 Codex 任务在运行。请先取消任务,再删除全部会话。',
|
|
970
|
+
recentProjects_clearProject_done: '已删除 {project} 的 {count} 个会话。',
|
|
971
|
+
recentProjects_clearProject_partial: '已删除 {count} 个会话中的 {removed} 个。剩余记录仍会显示,可重试删除。',
|
|
972
|
+
recentProjects_clearProject_historyPartial: '会话已删除,但有 {count} 条插件本地 Codex 线程历史未能清除。',
|
|
957
973
|
recentProjects_cleanup: '清除这条失效记录',
|
|
958
974
|
recentProjects_cleanup_title: '清除失效的项目记录?',
|
|
959
975
|
recentProjects_cleanup_message: '这条记录的项目链接已失效,无法打开或展开。清除后,它名下的全部会话记录将被删除,且无法恢复。',
|
|
@@ -1051,6 +1051,9 @@
|
|
|
1051
1051
|
runs,
|
|
1052
1052
|
task: summarizeTextForStorage(session.task, 'task'),
|
|
1053
1053
|
mode: normalizeMode(session.mode || fallbackState.mode),
|
|
1054
|
+
providerId: typeof session.providerId === 'string' && session.providerId
|
|
1055
|
+
? session.providerId
|
|
1056
|
+
: 'builtin',
|
|
1054
1057
|
model: normalizeTextField(session.model || fallbackState.model || DEFAULT_PANEL_STATE.model, 80),
|
|
1055
1058
|
reasoningEffort: normalizeReasoning(session.reasoningEffort || fallbackState.reasoningEffort),
|
|
1056
1059
|
speedTier: normalizeSpeedTier(session.speedTier || fallbackState.speedTier),
|
|
@@ -3390,9 +3390,30 @@
|
|
|
3390
3390
|
|
|
3391
3391
|
#codex-overleaf-panel .codex-model-speed-indicator {
|
|
3392
3392
|
flex: 0 0 auto;
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3393
|
+
display: inline-flex;
|
|
3394
|
+
align-items: center;
|
|
3395
|
+
justify-content: center;
|
|
3396
|
+
width: 14px;
|
|
3397
|
+
height: 14px;
|
|
3398
|
+
color: var(--tl-fg-1);
|
|
3399
|
+
line-height: 0;
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
#codex-overleaf-panel .codex-model-speed-indicator[hidden] {
|
|
3403
|
+
display: none;
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
#codex-overleaf-panel .codex-model-speed-indicator svg {
|
|
3407
|
+
width: 100%;
|
|
3408
|
+
height: 100%;
|
|
3409
|
+
overflow: visible;
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
#codex-overleaf-panel .codex-model-speed-indicator path {
|
|
3413
|
+
fill: currentColor;
|
|
3414
|
+
stroke: currentColor;
|
|
3415
|
+
stroke-width: 0.55;
|
|
3416
|
+
stroke-linejoin: round;
|
|
3396
3417
|
}
|
|
3397
3418
|
|
|
3398
3419
|
#codex-overleaf-panel .codex-model-config-popover {
|
|
@@ -4192,6 +4213,33 @@
|
|
|
4192
4213
|
color: var(--tl-fail);
|
|
4193
4214
|
}
|
|
4194
4215
|
|
|
4216
|
+
#codex-overleaf-panel .recent-projects-row-clear {
|
|
4217
|
+
position: absolute;
|
|
4218
|
+
top: 8px;
|
|
4219
|
+
right: 8px;
|
|
4220
|
+
z-index: 2;
|
|
4221
|
+
width: 24px;
|
|
4222
|
+
height: 24px;
|
|
4223
|
+
border-radius: var(--tl-r-sm);
|
|
4224
|
+
color: var(--tl-fg-4);
|
|
4225
|
+
font-size: 16px;
|
|
4226
|
+
line-height: 1;
|
|
4227
|
+
opacity: 0;
|
|
4228
|
+
transform: translateX(4px);
|
|
4229
|
+
transition: color 120ms ease, background 120ms ease, opacity 120ms ease, transform 120ms ease;
|
|
4230
|
+
}
|
|
4231
|
+
|
|
4232
|
+
#codex-overleaf-panel .recent-projects-row-wrap:hover .recent-projects-row-clear,
|
|
4233
|
+
#codex-overleaf-panel .recent-projects-row-clear:focus-visible {
|
|
4234
|
+
opacity: 1;
|
|
4235
|
+
transform: translateX(0);
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4238
|
+
#codex-overleaf-panel .recent-projects-row-clear:hover {
|
|
4239
|
+
background: var(--tl-hover);
|
|
4240
|
+
color: var(--tl-fail);
|
|
4241
|
+
}
|
|
4242
|
+
|
|
4195
4243
|
#codex-overleaf-panel .recent-projects-loading {
|
|
4196
4244
|
padding: 10px 12px;
|
|
4197
4245
|
color: var(--tl-fg-3);
|
|
@@ -252,7 +252,7 @@ async function runCodexSession({ params = {}, env = process.env, emit = () => {}
|
|
|
252
252
|
if (change.type === 'write' && typeof change.previousContent === 'string') {
|
|
253
253
|
return {
|
|
254
254
|
...change,
|
|
255
|
-
diff: computeLineDiff(change.previousContent, change.content),
|
|
255
|
+
diff: computeLineDiff(change.previousContent, change.content, 3, params.locale === 'zh' ? 'zh' : 'en'),
|
|
256
256
|
patches: computeTextPatches(change.previousContent, change.content)
|
|
257
257
|
};
|
|
258
258
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function computeLineDiff(oldText, newText, contextLines = 3) {
|
|
3
|
+
function computeLineDiff(oldText, newText, contextLines = 3, locale = 'en') {
|
|
4
4
|
const oldLines = splitLines(oldText);
|
|
5
5
|
const newLines = splitLines(newText);
|
|
6
6
|
|
|
@@ -12,23 +12,28 @@ function computeLineDiff(oldText, newText, contextLines = 3) {
|
|
|
12
12
|
const MAX_DIFF_PRODUCT = 4000000;
|
|
13
13
|
|
|
14
14
|
if (oldLines.length > MAX_LINES || newLines.length > MAX_LINES || oldLines.length * newLines.length > MAX_DIFF_PRODUCT) {
|
|
15
|
-
return buildTruncatedResult(oldLines.length, newLines.length);
|
|
15
|
+
return buildTruncatedResult(oldLines.length, newLines.length, locale);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const edits = myersDiff(oldLines, newLines);
|
|
19
19
|
if (edits === null) {
|
|
20
|
-
return buildTruncatedResult(oldLines.length, newLines.length);
|
|
20
|
+
return buildTruncatedResult(oldLines.length, newLines.length, locale);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return buildHunks(oldLines, newLines, edits, contextLines);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function buildTruncatedResult(oldCount, newCount) {
|
|
26
|
+
function buildTruncatedResult(oldCount, newCount, locale = 'en') {
|
|
27
27
|
return [{
|
|
28
28
|
startA: 1,
|
|
29
29
|
startB: 1,
|
|
30
30
|
truncated: true,
|
|
31
|
-
lines: [{
|
|
31
|
+
lines: [{
|
|
32
|
+
type: 'context',
|
|
33
|
+
text: locale === 'zh'
|
|
34
|
+
? `文件改动较大(${oldCount} → ${newCount} 行),请在 Overleaf 中查看完整差异。`
|
|
35
|
+
: `Large file change (${oldCount} → ${newCount} lines). Review the full diff in Overleaf.`
|
|
36
|
+
}]
|
|
32
37
|
}];
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -889,6 +889,7 @@ function validateTaskResultOperationQuotas(result = {}) {
|
|
|
889
889
|
}
|
|
890
890
|
|
|
891
891
|
function buildDefaultUserReport(mode, operations = [], params = {}) {
|
|
892
|
+
const locale = normalizeReportLocale(params.locale);
|
|
892
893
|
const checked = (params.project?.files || [])
|
|
893
894
|
.map(file => file?.path)
|
|
894
895
|
.filter(path => typeof path === 'string' && path.length > 0)
|
|
@@ -897,19 +898,29 @@ function buildDefaultUserReport(mode, operations = [], params = {}) {
|
|
|
897
898
|
|
|
898
899
|
return {
|
|
899
900
|
conclusion: hasOperations
|
|
900
|
-
? 'Codex 已准备好建议修改,等待确认或写入。'
|
|
901
|
-
: '这轮任务已完成,没有写入 Overleaf 文件。',
|
|
901
|
+
? reportText(locale, 'Codex prepared proposed changes and is waiting for confirmation or writeback.', 'Codex 已准备好建议修改,等待确认或写入。')
|
|
902
|
+
: reportText(locale, 'This task completed without writing Overleaf files.', '这轮任务已完成,没有写入 Overleaf 文件。'),
|
|
902
903
|
checked,
|
|
903
904
|
findings: [],
|
|
904
|
-
plannedChanges: hasOperations ? operations.map(formatOperationForUserReport) : [],
|
|
905
|
+
plannedChanges: hasOperations ? operations.map(operation => formatOperationForUserReport(operation, locale)) : [],
|
|
905
906
|
appliedChanges: [],
|
|
906
|
-
unchangedReason: hasOperations
|
|
907
|
+
unchangedReason: hasOperations
|
|
908
|
+
? ''
|
|
909
|
+
: (mode === 'ask' ? reportText(locale, 'This run was Ask mode.', '这轮是只问不改。') : ''),
|
|
907
910
|
nextStep: hasOperations
|
|
908
|
-
? '请确认修改方案后写入 Overleaf。'
|
|
909
|
-
: '可以继续追问,或加入更多 @context 后再检查。'
|
|
911
|
+
? reportText(locale, 'Review and confirm the proposed changes before writing them to Overleaf.', '请确认修改方案后写入 Overleaf。')
|
|
912
|
+
: reportText(locale, 'Continue the conversation, or add more @context and run another check.', '可以继续追问,或加入更多 @context 后再检查。')
|
|
910
913
|
};
|
|
911
914
|
}
|
|
912
915
|
|
|
916
|
+
function normalizeReportLocale(locale) {
|
|
917
|
+
return locale === 'zh' ? 'zh' : 'en';
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function reportText(locale, english, chinese) {
|
|
921
|
+
return locale === 'zh' ? chinese : english;
|
|
922
|
+
}
|
|
923
|
+
|
|
913
924
|
function normalizeUserReport(value, fallback) {
|
|
914
925
|
if (!value || typeof value !== 'object') {
|
|
915
926
|
return fallback;
|
|
@@ -932,17 +943,13 @@ function normalizeStringArray(value, fallback = []) {
|
|
|
932
943
|
return value.filter(item => typeof item === 'string');
|
|
933
944
|
}
|
|
934
945
|
|
|
935
|
-
function formatOperationForUserReport(operation) {
|
|
936
|
-
const labels =
|
|
937
|
-
edit: '编辑',
|
|
938
|
-
create: '
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
};
|
|
943
|
-
const label = labels[operation?.type] || operation?.type || '处理';
|
|
944
|
-
const filePath = operation?.path || operation?.to || '未知文件';
|
|
945
|
-
return `${filePath}:${label}`;
|
|
946
|
+
function formatOperationForUserReport(operation, locale = 'en') {
|
|
947
|
+
const labels = locale === 'zh'
|
|
948
|
+
? { edit: '编辑', create: '新建', rename: '重命名', move: '移动', delete: '删除' }
|
|
949
|
+
: { edit: 'edit', create: 'create', rename: 'rename', move: 'move', delete: 'delete' };
|
|
950
|
+
const label = labels[operation?.type] || operation?.type || reportText(locale, 'change', '处理');
|
|
951
|
+
const filePath = operation?.path || operation?.to || reportText(locale, 'unknown file', '未知文件');
|
|
952
|
+
return locale === 'zh' ? `${filePath}:${label}` : `${filePath}: ${label}`;
|
|
946
953
|
}
|
|
947
954
|
|
|
948
955
|
function collectResultOperations(result) {
|