codex-overleaf-link 2.5.1 → 2.6.0
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 +149 -398
- package/README.zh-CN.md +153 -404
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/src/background.js +78 -3
- package/extension/src/backgroundSharedSessions.js +55 -2
- package/extension/src/backgroundUpdateCoordinator.js +128 -12
- package/extension/src/content/activeTurnControl.js +164 -7
- package/extension/src/content/composerAttachments.js +11 -2
- package/extension/src/content/composerPanel.js +92 -12
- package/extension/src/content/contentRuntime.js +920 -276
- package/extension/src/content/contextTray.js +8 -2
- package/extension/src/content/contextUsageView.js +267 -0
- package/extension/src/content/diagnosticsPanel.js +18 -0
- package/extension/src/content/generated/content.bundle.js +4496 -924
- package/extension/src/content/generated/content.bundle.meta.json +6 -3
- package/extension/src/content/legacyGlobalRegistry.js +4 -0
- package/extension/src/content/localSkillsPanel.js +2 -2
- package/extension/src/content/markdownDomRenderer.js +5 -3
- package/extension/src/content/markdownText.js +42 -5
- package/extension/src/content/modelPicker.js +1 -0
- package/extension/src/content/nativeCompatibilityController.js +29 -10
- package/extension/src/content/otWarmMirror.js +1 -1
- package/extension/src/content/pageBridgeClient.js +2 -2
- package/extension/src/content/panelMaintenance.js +6 -2
- package/extension/src/content/panelRenderer.js +51 -27
- package/extension/src/content/pendingInputView.js +1 -1
- package/extension/src/content/projectSettingsCoordinator.js +30 -6
- package/extension/src/content/providerSettingsDialog.js +2 -1
- package/extension/src/content/recentProjects.js +4 -3
- package/extension/src/content/runActivitySummary.js +122 -14
- package/extension/src/content/runCompletionMeta.js +194 -6
- package/extension/src/content/runController.js +2 -1
- package/extension/src/content/runFailureNotice.js +8 -1
- package/extension/src/content/runPresence.js +18 -8
- package/extension/src/content/runQueueScheduler.js +9 -5
- package/extension/src/content/runRecoveryActions.js +2 -1
- package/extension/src/content/runResultActions.js +22 -20
- package/extension/src/content/runReviewController.js +94 -35
- package/extension/src/content/runTimelineView.js +224 -25
- package/extension/src/content/scopedPersistencePanelState.js +92 -23
- package/extension/src/content/sensitivePreflight.js +14 -1
- package/extension/src/content/sessionManager.js +49 -3
- package/extension/src/content/sessionMenuView.js +54 -18
- package/extension/src/content/sessionPersistence.js +25 -5
- package/extension/src/content/settingsPanel.js +15 -2
- package/extension/src/content/settingsWorkbench.js +127 -89
- package/extension/src/content/sharedSessionViewSync.js +4 -3
- package/extension/src/content/subagentActivityView.js +23 -7
- package/extension/src/content/updateNotice.js +60 -6
- package/extension/src/content/writebackOrchestrator.js +35 -22
- package/extension/src/page/compileBridge.js +193 -180
- package/extension/src/page/overleafCapabilities.js +4 -1
- package/extension/src/page/textCoordinates.js +17 -1
- package/extension/src/page/textFileCreator.js +9 -1
- package/extension/src/page/writebackRouter.js +24 -77
- package/extension/src/pageBridge.js +107 -66
- package/extension/src/popup.js +1 -1
- package/extension/src/shared/agentTranscript.js +350 -17
- package/extension/src/shared/auditRecords.js +2 -0
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/compileAdapter.js +58 -17
- package/extension/src/shared/composerAttachmentDraft.js +6 -1
- package/extension/src/shared/contextUsage.js +125 -0
- package/extension/src/shared/failureReasons.js +42 -3
- package/extension/src/shared/i18n.js +299 -29
- package/extension/src/shared/lineReferences.js +38 -31
- package/extension/src/shared/pageRpcContract.js +1 -1
- package/extension/src/shared/panelIcons.js +39 -0
- package/extension/src/shared/reviewing.js +130 -1
- package/extension/src/shared/runActivityModel.js +70 -4
- package/extension/src/shared/runExecutionSnapshot.js +13 -0
- package/extension/src/shared/sessionState.js +63 -4
- package/extension/src/shared/sessionTitle.js +14 -1
- package/extension/src/shared/sharedSessionBridge.js +81 -13
- package/extension/src/shared/staleGuard.js +72 -63
- package/extension/src/shared/storageDb.js +35 -3
- package/extension/src/shared/storageMigration.js +7 -1
- package/extension/src/shared/storageRunActions.js +62 -8
- package/extension/src/shared/undoOperations.js +126 -28
- package/extension/src/shared/updateRuntimeIdentity.js +16 -2
- package/extension/src/shared/writebackSettlement.js +21 -3
- package/extension/styles/panel.css +1106 -490
- package/native-host/src/bootstrapUpdate.js +52 -16
- package/native-host/src/chatBridgeRequest.js +60 -6
- package/native-host/src/chatBridgeResponse.js +10 -1
- package/native-host/src/chatCompletionsBridge.js +29 -2
- package/native-host/src/codexPromptAssembly.js +86 -118
- package/native-host/src/codexSessionRunner.js +126 -17
- package/native-host/src/providerContextError.js +20 -0
- package/native-host/src/taskRunnerRuntime.js +18 -6
- package/native-host/src/textPatch.js +473 -377
- package/native-host/src/updateManager.js +120 -15
- package/package.json +5 -8
|
@@ -4,21 +4,32 @@
|
|
|
4
4
|
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
['
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
// The sidebar is split by scope; a page's section decides whether its groups
|
|
8
|
+
// need an open project. Pages: [id, label key, icon].
|
|
9
|
+
const SECTIONS = [
|
|
10
|
+
['project', 'settingsScopeProjectTitle', [
|
|
11
|
+
['writing', 'settingsWorkbenchWriting', 'pen'],
|
|
12
|
+
['protection', 'settingsWorkbenchProtection', 'shield'],
|
|
13
|
+
['cache', 'otSettingsTitle', 'flask'],
|
|
14
|
+
['history', 'settingsWorkbenchChanges', 'history']
|
|
15
|
+
]],
|
|
16
|
+
['global', 'settingsScopeGlobalTitle', [
|
|
17
|
+
['appearance', 'appearanceTitle', 'appearance'],
|
|
18
|
+
['providers', 'settingsWorkbenchModels', 'bolt'],
|
|
19
|
+
['context', 'settingsWorkbenchContextSkills', 'database'],
|
|
20
|
+
['storage', 'storageTitle', 'archive'],
|
|
21
|
+
['updates', 'softwareUpdatesTitle', 'software']
|
|
22
|
+
]]
|
|
15
23
|
];
|
|
16
24
|
const GROUP_PAGES = {
|
|
17
|
-
|
|
18
|
-
experimental: '
|
|
19
|
-
|
|
25
|
+
'writing-style': 'writing', personalization: 'writing', protection: 'protection', privacy: 'protection',
|
|
26
|
+
experimental: 'cache', history: 'history', appearance: 'appearance', providers: 'providers',
|
|
27
|
+
'context-loading': 'context', skills: 'context', storage: 'storage', updates: 'updates'
|
|
20
28
|
};
|
|
21
|
-
|
|
29
|
+
// Groups without a mapping keep their original scope.
|
|
30
|
+
const FALLBACK_PAGES = { project: 'writing', global: 'context' };
|
|
31
|
+
// The skills list opens in place of the page that holds the Skills group.
|
|
32
|
+
const SKILLS_PAGE = 'context';
|
|
22
33
|
|
|
23
34
|
function mount(instance, options = {}) {
|
|
24
35
|
const container = instance.container, doc = container.ownerDocument;
|
|
@@ -50,93 +61,94 @@
|
|
|
50
61
|
const status = settings.querySelector('[data-project-settings-status]');
|
|
51
62
|
const dialog = make('dialog', 'codex-settings-workbench');
|
|
52
63
|
dialog.setAttribute('aria-labelledby', 'codex-settings-workbench-title');
|
|
53
|
-
const
|
|
54
|
-
const heading = make('div', 'codex-wb-heading');
|
|
55
|
-
const title = make('h2', '', 'settingsWorkbenchTitle');
|
|
64
|
+
const title = make('h2', 'codex-wb-title', 'settingsWorkbenchTitle');
|
|
56
65
|
title.id = 'codex-settings-workbench-title';
|
|
57
|
-
heading.append(title, make('p', '', 'settingsWorkbenchSubtitle'));
|
|
58
66
|
closeButton.classList.add('codex-wb-close');
|
|
59
|
-
closeButton.
|
|
60
|
-
|
|
67
|
+
if (options.icon) closeButton.innerHTML = options.icon('close'); // Static, repository-owned icon path.
|
|
68
|
+
else closeButton.textContent = '\u00d7';
|
|
61
69
|
originalHead?.remove();
|
|
62
70
|
|
|
63
71
|
const layout = make('div', 'codex-wb-layout');
|
|
64
72
|
const sidebar = make('aside', 'codex-wb-sidebar');
|
|
65
|
-
const filters = make('div', 'codex-wb-filters');
|
|
66
|
-
filters.setAttribute('role', 'group');
|
|
67
|
-
const allFilter = button('', 'settingsWorkbenchAll');
|
|
68
|
-
const projectFilter = button('', 'settingsScopeProjectTitle');
|
|
69
|
-
filters.append(allFilter, projectFilter);
|
|
70
73
|
const nav = make('nav', 'codex-wb-nav');
|
|
71
74
|
nav.setAttribute('role', 'tablist');
|
|
72
75
|
nav.setAttribute('aria-orientation', 'vertical');
|
|
73
|
-
|
|
74
|
-
brand.textContent = 'Codex Overleaf Link';
|
|
75
|
-
sidebar.append(filters, nav, brand);
|
|
76
|
+
sidebar.append(title, nav);
|
|
76
77
|
const main = make('div', 'codex-wb-main');
|
|
77
78
|
const body = make('div', 'codex-wb-body');
|
|
78
79
|
const footer = make('footer', 'codex-wb-footer');
|
|
79
80
|
if (status) { status.setAttribute('aria-live', 'polite'); footer.append(status); }
|
|
80
81
|
main.append(body, footer);
|
|
81
82
|
layout.append(sidebar, main);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// The close button floats over the content's top-right corner.
|
|
84
|
+
dialog.append(layout, closeButton);
|
|
85
|
+
const pages = new Map(), navButtons = new Map(), pageScopes = new Map(), sectionLabels = new Map(), groups = [];
|
|
86
|
+
let active = 'writing', returnFocus = null, destroyed = false;
|
|
85
87
|
let providerRequested = false, providerCloseGuard = null, closing = null;
|
|
86
88
|
|
|
87
|
-
for (const [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
for (const [scope, sectionKey, items] of SECTIONS) {
|
|
90
|
+
// Visual section heading; each tab references it as its description.
|
|
91
|
+
const label = make('div', 'codex-wb-nav-section', sectionKey);
|
|
92
|
+
label.id = 'codex-settings-nav-section-' + scope;
|
|
93
|
+
label.setAttribute('aria-hidden', 'true');
|
|
94
|
+
nav.append(label);
|
|
95
|
+
sectionLabels.set(scope, label);
|
|
96
|
+
for (const [id, key, icon] of items) {
|
|
97
|
+
const page = make('section', 'codex-wb-page');
|
|
98
|
+
page.id = 'codex-settings-page-' + id;
|
|
99
|
+
page.dataset.workbenchPage = id;
|
|
100
|
+
page.setAttribute('role', 'tabpanel');
|
|
101
|
+
page.setAttribute('aria-labelledby', 'codex-settings-nav-' + id);
|
|
102
|
+
page.hidden = true;
|
|
103
|
+
page.append(make('h3', 'codex-wb-page-title', key), make('p', 'codex-wb-page-scope'));
|
|
104
|
+
pages.set(id, page);
|
|
105
|
+
pageScopes.set(id, scope);
|
|
106
|
+
const tab = button('codex-wb-nav-button');
|
|
107
|
+
tab.id = 'codex-settings-nav-' + id;
|
|
108
|
+
tab.setAttribute('role', 'tab');
|
|
109
|
+
tab.setAttribute('aria-controls', page.id);
|
|
110
|
+
tab.setAttribute('aria-describedby', label.id);
|
|
111
|
+
if (options.icon) {
|
|
112
|
+
const glyph = make('span', 'codex-wb-nav-icon');
|
|
113
|
+
glyph.innerHTML = options.icon(icon); // Static, repository-owned icon paths only.
|
|
114
|
+
tab.append(glyph);
|
|
115
|
+
}
|
|
116
|
+
tab.append(make('span', '', key));
|
|
117
|
+
listen(tab, 'click', () => select(id));
|
|
118
|
+
nav.append(tab);
|
|
119
|
+
navButtons.set(id, tab);
|
|
104
120
|
}
|
|
105
|
-
tab.append(make('span', '', key));
|
|
106
|
-
listen(tab, 'click', () => select(id));
|
|
107
|
-
nav.append(tab);
|
|
108
|
-
navButtons.set(id, tab);
|
|
109
121
|
}
|
|
110
|
-
function addGroup(node, category
|
|
122
|
+
function addGroup(node, category) {
|
|
123
|
+
const projectOnly = pageScopes.get(category) === 'project';
|
|
111
124
|
node.hidden = true;
|
|
112
125
|
node.dataset.workbenchScope = projectOnly ? 'project' : 'global';
|
|
113
126
|
const summary = node.querySelector('summary');
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
if (summary) {
|
|
128
|
+
// Groups are plain sections: always open while their page is shown.
|
|
129
|
+
summary.tabIndex = -1;
|
|
130
|
+
listen(summary, 'click', event => event.preventDefault());
|
|
131
|
+
}
|
|
117
132
|
pages.get(category).append(node);
|
|
118
|
-
groups.push({ node, category, projectOnly
|
|
133
|
+
groups.push({ node, category, projectOnly });
|
|
119
134
|
}
|
|
135
|
+
const fallbackPage = scope => FALLBACK_PAGES[
|
|
136
|
+
scope && !scope.classList.contains('codex-project-settings-scope--global') ? 'project' : 'global'];
|
|
120
137
|
// Move existing controls rather than copying them. Their listeners, unsaved
|
|
121
138
|
// values, identity, validation and persistence callbacks remain attached.
|
|
122
139
|
for (const group of Array.from(settings.querySelectorAll('[data-set-group]'))) {
|
|
123
140
|
const key = group.dataset.setGroup;
|
|
124
|
-
|
|
125
|
-
const projectOnly = PROJECT_GROUPS.has(key)
|
|
126
|
-
|| (!GROUP_PAGES[key] && originalScope && !originalScope.classList.contains('codex-project-settings-scope--global'));
|
|
127
|
-
addGroup(group, GROUP_PAGES[key] || 'instructions', Boolean(projectOnly));
|
|
141
|
+
addGroup(group, GROUP_PAGES[key] || fallbackPage(group.closest('.codex-project-settings-scope')));
|
|
128
142
|
}
|
|
129
|
-
// Preserve non-card controls
|
|
130
|
-
// Scope headings are replaced by labels on the actual groups.
|
|
143
|
+
// Preserve non-card controls. The sidebar sections replace the scope headings.
|
|
131
144
|
for (const scope of Array.from(settings.querySelectorAll('.codex-project-settings-scope'))) {
|
|
132
145
|
scope.querySelectorAll('.codex-project-settings-scope-title').forEach(node => node.remove());
|
|
133
|
-
if (scope.children.length)
|
|
134
|
-
|
|
135
|
-
} else scope.remove();
|
|
146
|
+
if (scope.children.length) addGroup(scope, fallbackPage(scope));
|
|
147
|
+
else scope.remove();
|
|
136
148
|
}
|
|
137
149
|
for (const node of Array.from(settings.children)) {
|
|
138
150
|
if (node === status) continue;
|
|
139
|
-
addGroup(node,
|
|
151
|
+
addGroup(node, FALLBACK_PAGES.global);
|
|
140
152
|
}
|
|
141
153
|
const providerHost = make('div', 'codex-wb-provider-host');
|
|
142
154
|
providerHost.dataset.providerSettingsHost = '';
|
|
@@ -218,29 +230,54 @@
|
|
|
218
230
|
&& /^\/project\/[^/]+/.test(win?.location?.pathname || '');
|
|
219
231
|
}
|
|
220
232
|
function available(item) {
|
|
221
|
-
return
|
|
233
|
+
return !item.projectOnly || hasProject();
|
|
234
|
+
}
|
|
235
|
+
// A page whose only visible group repeats the page title hides that group's
|
|
236
|
+
// title; the group header keeps only its Saved mark.
|
|
237
|
+
function refreshSoleSections() {
|
|
238
|
+
for (const page of pages.values()) {
|
|
239
|
+
const pageGroups = Array.from(page.querySelectorAll('.codex-set-group'));
|
|
240
|
+
const visibleGroups = pageGroups.filter(node => !node.hidden);
|
|
241
|
+
const pageTitle = page.querySelector('.codex-wb-page-title')?.textContent.trim();
|
|
242
|
+
for (const node of pageGroups) {
|
|
243
|
+
const groupTitle = node.querySelector('.codex-set-group-head .codex-set-group-title');
|
|
244
|
+
const sole = visibleGroups.length === 1 && visibleGroups[0] === node
|
|
245
|
+
&& groupTitle && groupTitle.textContent.trim() === pageTitle;
|
|
246
|
+
if (sole) node.dataset.soleSection = 'true';
|
|
247
|
+
else delete node.dataset.soleSection;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Each page states its scope once, under its title.
|
|
252
|
+
function renderPageScope(page, scope, projectName) {
|
|
253
|
+
const line = page.querySelector('.codex-wb-page-scope');
|
|
254
|
+
if (!line) return;
|
|
255
|
+
const text = t(scope === 'project' ? 'settingsPageScopeProject' : 'settingsPageScopeGlobal');
|
|
256
|
+
if (scope !== 'project' || !projectName) { line.textContent = text; return; }
|
|
257
|
+
const name = doc.createElement('b');
|
|
258
|
+
name.textContent = projectName;
|
|
259
|
+
line.replaceChildren(text + ' \u00b7 ', name);
|
|
222
260
|
}
|
|
223
261
|
function refresh() {
|
|
224
262
|
if (destroyed) return;
|
|
225
|
-
if (
|
|
226
|
-
if (panel.dataset.view === 'skills') { active = 'instructions'; filter = 'all'; }
|
|
263
|
+
if (panel.dataset.view === 'skills') active = SKILLS_PAGE;
|
|
227
264
|
const availablePages = new Set(groups.filter(available).map(item => item.category));
|
|
228
|
-
if (!availablePages.has(active)) active =
|
|
265
|
+
if (!availablePages.has(active)) active = Array.from(navButtons.keys()).find(id => availablePages.has(id)) || 'appearance';
|
|
229
266
|
for (const node of dialog.querySelectorAll('[data-i18n]')) {
|
|
230
267
|
// Existing controls use their established translation pass; update the
|
|
231
268
|
// newly owned chrome only, without replacing controls or skill rows.
|
|
232
|
-
if (node.closest('.codex-wb-
|
|
269
|
+
if (node.closest('.codex-wb-nav, .codex-wb-footer')
|
|
270
|
+
|| node.classList.contains('codex-wb-title')
|
|
233
271
|
|| node.classList.contains('codex-wb-page-title')
|
|
234
|
-
|| node.classList.contains('codex-wb-scope-label')
|
|
235
272
|
|| node.classList.contains('codex-wb-theme-caption')
|
|
236
273
|
|| node.classList.contains('codex-wb-skills-caption')) node.textContent = t(node.dataset.i18n);
|
|
237
274
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
275
|
+
const projectName = hasProject() ? String(instance.getProjectName?.() || '').trim() : '';
|
|
276
|
+
for (const [id, page] of pages) renderPageScope(page, pageScopes.get(id), projectName);
|
|
277
|
+
for (const [scope, label] of sectionLabels) {
|
|
278
|
+
label.hidden = !Array.from(pageScopes).some(([id, pageScope]) => pageScope === scope && availablePages.has(id));
|
|
279
|
+
}
|
|
241
280
|
nav.setAttribute('aria-label', t('settingsWorkbenchCategories'));
|
|
242
|
-
allFilter.setAttribute('aria-pressed', String(filter === 'all'));
|
|
243
|
-
projectFilter.setAttribute('aria-pressed', String(filter === 'project'));
|
|
244
281
|
closeButton.title = t('settingsWorkbenchClose');
|
|
245
282
|
closeButton.setAttribute('aria-label', t('settingsWorkbenchClose'));
|
|
246
283
|
const skillsBack = skills?.querySelector('[data-skills-back]');
|
|
@@ -248,6 +285,7 @@
|
|
|
248
285
|
skillsBack.title = t('settingsBack');
|
|
249
286
|
skillsBack.setAttribute('aria-label', t('settingsBack'));
|
|
250
287
|
}
|
|
288
|
+
if (status) status.hidden = Boolean(status.dataset.statusPage) && status.dataset.statusPage !== active;
|
|
251
289
|
for (const [id, tab] of navButtons) {
|
|
252
290
|
tab.hidden = !availablePages.has(id);
|
|
253
291
|
tab.setAttribute('aria-selected', String(id === active));
|
|
@@ -256,12 +294,11 @@
|
|
|
256
294
|
}
|
|
257
295
|
for (const item of groups) {
|
|
258
296
|
const visible = available(item) && item.category === active && panel.dataset.view !== 'skills';
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
item.node.open = visible && item.expanded;
|
|
262
|
-
}
|
|
297
|
+
// Opening a group when its page is shown keeps the lazy toggle loaders (history, storage).
|
|
298
|
+
if (item.node.tagName === 'DETAILS' && item.node.open !== visible) item.node.open = visible;
|
|
263
299
|
item.node.hidden = !visible;
|
|
264
300
|
}
|
|
301
|
+
refreshSoleSections();
|
|
265
302
|
updateThemes();
|
|
266
303
|
}
|
|
267
304
|
function requestProviders() {
|
|
@@ -277,9 +314,17 @@
|
|
|
277
314
|
try { Promise.resolve(instance.callbacks.onProvidersOpen()).catch(failed); }
|
|
278
315
|
catch (error) { failed(error); }
|
|
279
316
|
}
|
|
317
|
+
// Shows the page that holds a group and returns the group, or null when the
|
|
318
|
+
// group is unavailable (for example a project group outside a project).
|
|
319
|
+
function revealGroup(key) {
|
|
320
|
+
const item = groups.find(entry => entry.node.dataset?.setGroup === key);
|
|
321
|
+
if (!item || !available(item)) return null;
|
|
322
|
+
active = item.category;
|
|
323
|
+
refresh();
|
|
324
|
+
return item.node;
|
|
325
|
+
}
|
|
280
326
|
function revealProviders() {
|
|
281
327
|
active = 'providers';
|
|
282
|
-
filter = 'all';
|
|
283
328
|
providerRequested = true;
|
|
284
329
|
pages.get('providers').dataset.providerEmbedded = 'true';
|
|
285
330
|
panel.dataset.view = 'settings';
|
|
@@ -330,13 +375,6 @@
|
|
|
330
375
|
if (['settings', 'skills'].includes(panel.dataset.view)) show();
|
|
331
376
|
else hide();
|
|
332
377
|
};
|
|
333
|
-
listen(allFilter, 'click', () => { filter = 'all'; refresh(); });
|
|
334
|
-
listen(projectFilter, 'click', () => {
|
|
335
|
-
filter = 'project';
|
|
336
|
-
if (panel.dataset.view === 'skills') instance.callbacks.onSkillsBack?.();
|
|
337
|
-
refresh();
|
|
338
|
-
body.scrollTop = 0;
|
|
339
|
-
});
|
|
340
378
|
listen(nav, 'keydown', event => {
|
|
341
379
|
if (!['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) return;
|
|
342
380
|
const tabs = Array.from(navButtons.values()).filter(tab => !tab.hidden);
|
|
@@ -363,7 +401,7 @@
|
|
|
363
401
|
observer.observe(panel, { attributes: true, attributeFilter: ['data-view', 'data-settings-scope', 'data-theme'] });
|
|
364
402
|
refresh();
|
|
365
403
|
return {
|
|
366
|
-
show, hide, refresh, revealProviders,
|
|
404
|
+
show, hide, refresh, revealGroup, revealProviders,
|
|
367
405
|
setProviderCloseGuard(guard) { providerCloseGuard = guard; },
|
|
368
406
|
destroy() {
|
|
369
407
|
destroyed = true;
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
if (!scope.projectId || !scope.accountScopeId) { pending = false; return; }
|
|
50
50
|
if (saving || isBusy()) { schedule(1000); return; }
|
|
51
51
|
const local = getState();
|
|
52
|
-
// A draft or a not-yet-persisted edit
|
|
53
|
-
// history refresh.
|
|
54
|
-
if (
|
|
52
|
+
// A locally edited draft or a not-yet-persisted edit takes priority over
|
|
53
|
+
// passive history refresh. Callers may distinguish imported shared drafts.
|
|
54
|
+
if ((options.hasLocalDraft ? options.hasLocalDraft(local) : Boolean(local.task))
|
|
55
|
+
|| (local.sessions || []).some(session => StorageDb.hasUnpersistedSharedSession(session))) {
|
|
55
56
|
schedule(1500); return;
|
|
56
57
|
}
|
|
57
58
|
const capturedVersion = version, capturedSignature = signature(local);
|
|
@@ -3,18 +3,31 @@
|
|
|
3
3
|
})(typeof globalThis !== 'undefined' ? globalThis : window, function subagentActivityViewFactory(Agents, Activity) {
|
|
4
4
|
'use strict';
|
|
5
5
|
function create(deps) {
|
|
6
|
-
const { tx, getPanel, plain, make, icon, formatElapsed, renderBlocks } = deps;
|
|
6
|
+
const { tx, getPanel, plain, plainThought, make, icon, formatElapsed, renderBlocks, glyph = () => '' } = deps;
|
|
7
|
+
const withGlyph = (node, name, label) => {
|
|
8
|
+
node.insertAdjacentHTML('beforeend', glyph(name));
|
|
9
|
+
const text = make('span', ''); text.textContent = label; node.append(text);
|
|
10
|
+
return node;
|
|
11
|
+
};
|
|
7
12
|
let viewer = null;
|
|
8
13
|
function statusLabel(status) {
|
|
9
14
|
return ({ pending: tx('Starting', '启动中'), running: tx('Running', '运行中'),
|
|
10
15
|
completed: tx('Completed', '已完成'), failed: tx('Failed', '失败'),
|
|
11
16
|
cancelled: tx('Stopped', '已停止'), unknown: tx('Status unconfirmed', '状态未确认') })[status] || '';
|
|
12
17
|
}
|
|
18
|
+
// A row preview is one plain line: a final message keeps its words, not its
|
|
19
|
+
// Markdown ("- `main.tex` is …" reads "main.tex is …").
|
|
20
|
+
function plainMessage(value) {
|
|
21
|
+
return value.replace(/^\s*(?:#{1,6}\s+|>\s?|[-*+]\s+|\d+[.)]\s+)/gm, '')
|
|
22
|
+
.replace(/!?\[([^\]]*)\]\([^)\s]*\)/g, '$1').replace(/`([^`\n]+)`/g, '$1')
|
|
23
|
+
.replace(/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g, '$2').replace(/\s+/g, ' ').trim();
|
|
24
|
+
}
|
|
13
25
|
function latest(agent) {
|
|
14
26
|
const blocks = Activity.project({ status: agent.status, events: agent.events || [] }).blocks;
|
|
15
27
|
const last = blocks.at(-1);
|
|
16
28
|
const item = last?.kind === 'exploreGroup' ? last.items.at(-1) : last;
|
|
17
|
-
|
|
29
|
+
const text = plain(item?.meta?.target || item?.meta?.command || item?.event?.title || agent.task);
|
|
30
|
+
return (item?.kind === 'message' ? plainMessage(text) : text).slice(0, 180);
|
|
18
31
|
}
|
|
19
32
|
function elapsed(agent, run) {
|
|
20
33
|
const duration = Agents.elapsedMs(agent, run, Date.now());
|
|
@@ -42,9 +55,9 @@
|
|
|
42
55
|
shell.setAttribute('aria-label', tx('Subagent conversation', '子代理对话'));
|
|
43
56
|
const header = make('header', 'codex-subagent-view-head');
|
|
44
57
|
const back = make('button', 'codex-subagent-back');
|
|
45
|
-
back.type = 'button'; back
|
|
58
|
+
back.type = 'button'; withGlyph(back, 'chevronLeft', tx('Back to main task', '返回主任务'));
|
|
46
59
|
back.addEventListener('click', close);
|
|
47
|
-
const readonly = make('span', 'codex-subagent-readonly')
|
|
60
|
+
const readonly = withGlyph(make('span', 'codex-subagent-readonly'), 'lock', tx('Read only', '只读'));
|
|
48
61
|
header.append(back, readonly);
|
|
49
62
|
const parent = make('div', 'codex-subagent-parent');
|
|
50
63
|
const parentLabel = make('span', 'codex-subagent-parent-label');
|
|
@@ -112,7 +125,7 @@
|
|
|
112
125
|
const mark = icon('agent'), copy = make('span', 'run-subagent-copy');
|
|
113
126
|
const name = make('span', 'run-subagent-name'), activity = make('span', 'run-subagent-activity');
|
|
114
127
|
copy.append(name, activity);
|
|
115
|
-
const tail = make('span', 'run-subagent-tail'), status = make('span', ''), time = make('span', 'run-subagent-time');
|
|
128
|
+
const tail = make('span', 'run-subagent-tail'), status = make('span', 'run-subagent-status'), time = make('span', 'run-subagent-time');
|
|
116
129
|
tail.append(status, time);
|
|
117
130
|
el.append(mark, copy, tail);
|
|
118
131
|
el.addEventListener('click', () => open(card, agent.key, el));
|
|
@@ -154,15 +167,17 @@
|
|
|
154
167
|
const childStatus = Agents.effectiveStatus(agent, card.run);
|
|
155
168
|
viewer.title.textContent = plain(agent.title || agent.jobId || agent.threadId);
|
|
156
169
|
viewer.meta.textContent = [statusLabel(childStatus), elapsed(agent, card.run), agent.model, agent.reasoningEffort].filter(Boolean).join(' · ');
|
|
170
|
+
viewer.meta.dataset.state = childStatus;
|
|
157
171
|
viewer.prompt.textContent = plain(agent.task);
|
|
158
172
|
viewer.assignment.hidden = !viewer.prompt.textContent;
|
|
159
173
|
const parent = Activity.project(card.run), last = parent.blocks.at(-1);
|
|
160
174
|
const lastItem = last?.kind === 'exploreGroup' ? last.items.at(-1) : last;
|
|
161
|
-
const parentWork = plain(lastItem?.meta?.target || lastItem?.meta?.command || lastItem?.event?.title).slice(0, 150);
|
|
175
|
+
const parentWork = plainThought(plain(lastItem?.meta?.target || lastItem?.meta?.command || lastItem?.event?.title)).slice(0, 150);
|
|
162
176
|
viewer.parentLabel.textContent = tx('Main agent · ', '主 agent · ') + (card.run.status === 'running'
|
|
163
177
|
? parentWork || tx('Working', '处理中') : tx('Run ended', '本轮已结束'));
|
|
164
178
|
const running = (card.run.subagents || []).filter(item => ['pending', 'running'].includes(Agents.effectiveStatus(item, card.run))).length;
|
|
165
179
|
viewer.parentCount.textContent = tx(running + ' subagents active', running + ' 个子任务进行中');
|
|
180
|
+
viewer.parentCount.hidden = running === 0;
|
|
166
181
|
for (const sibling of card.run.subagents || []) {
|
|
167
182
|
let button = viewer.siblingRows.get(sibling.key);
|
|
168
183
|
if (!button) {
|
|
@@ -172,7 +187,8 @@
|
|
|
172
187
|
}
|
|
173
188
|
button.textContent = plain(sibling.title || sibling.jobId || sibling.threadId);
|
|
174
189
|
button.setAttribute('aria-pressed', String(sibling.key === agent.key));
|
|
175
|
-
button.
|
|
190
|
+
button.dataset.state = Agents.effectiveStatus(sibling, card.run);
|
|
191
|
+
button.title = statusLabel(button.dataset.state);
|
|
176
192
|
}
|
|
177
193
|
const childRun = { id: card.id + ':' + agent.key, status: ['pending', 'running'].includes(childStatus) ? 'running' : childStatus,
|
|
178
194
|
events: agent.events || [], mode: 'ask' };
|
|
@@ -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 === '
|
|
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
|
-
|
|
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:
|
|
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.
|
|
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;
|