agent-things 1.3.2 → 1.3.3
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/mods/agent-things-ui/.claude-plugin/plugin.json +1 -1
- package/mods/agent-things-ui/hooks/foundation.js +78 -1
- package/mods/agent-things-ui/hooks/register.js +77 -12
- package/outputs/antigravity-session-status.js +120 -19
- package/outputs/codex-session-status.js +174 -18
- package/package.json +1 -1
- package/scripts/build-shared-ui.cjs +1 -1
- package/src/antigravity-card.cjs +237 -2
- package/src/harnesses/antigravity/antigravity-harness.js +23 -1
- package/src/harnesses/claude/claude-harness.js +77 -0
- package/src/harnesses/claude/claude-service.cjs +5 -1
- package/src/harnesses/codex/codex-card-bridge.js +3 -2
- package/src/harnesses/codex/codex-card.cjs +2 -1
- package/src/npm-updates.cjs +3 -2
- package/src/plugins/things/sidecars/things_board/index.html +289 -2
- package/src/plugins/things/sidecars/things_board/main.mjs +13 -5
- package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +77 -0
- package/src/session-status.js +97 -18
- package/src/ui-foundation.cjs +77 -0
|
@@ -244,6 +244,11 @@ const presentation = (function createPresentation(lang) {
|
|
|
244
244
|
updateFailedLabel: '升级失败',
|
|
245
245
|
upgradeBtn: '立即升级',
|
|
246
246
|
upgradingShort: '正在升级…',
|
|
247
|
+
checkUpdateBtn: '检查更新',
|
|
248
|
+
checkingUpdateShort: '正在检查…',
|
|
249
|
+
alreadyLatestPattern: '当前已是最新版 v{version}',
|
|
250
|
+
versionTagPattern: 'v{version}',
|
|
251
|
+
checkUpdateFailedLabel: '检查更新失败',
|
|
247
252
|
pleaseWait: '请稍候',
|
|
248
253
|
completedShort: '已完成',
|
|
249
254
|
retryBtn: '重试',
|
|
@@ -433,6 +438,11 @@ const presentation = (function createPresentation(lang) {
|
|
|
433
438
|
updateFailedLabel: 'Upgrade failed',
|
|
434
439
|
upgradeBtn: 'Upgrade',
|
|
435
440
|
upgradingShort: 'Upgrading...',
|
|
441
|
+
checkUpdateBtn: 'Check updates',
|
|
442
|
+
checkingUpdateShort: 'Checking...',
|
|
443
|
+
alreadyLatestPattern: 'Up to date (v{version})',
|
|
444
|
+
versionTagPattern: 'v{version}',
|
|
445
|
+
checkUpdateFailedLabel: 'Update check failed',
|
|
436
446
|
pleaseWait: 'Please wait',
|
|
437
447
|
completedShort: 'Done',
|
|
438
448
|
retryBtn: 'Retry',
|
|
@@ -522,6 +532,72 @@ const presentation = (function createPresentation(lang) {
|
|
|
522
532
|
function analysisDisabled(busy, analyzing, upgradeStage) {
|
|
523
533
|
return Boolean(busy || analyzing || ['waiting', 'installing'].includes(upgradeStage));
|
|
524
534
|
}
|
|
535
|
+
function updateBannerState(info, dict, options = {}) {
|
|
536
|
+
const textDict = dict || {};
|
|
537
|
+
const fmtText = (template, vars = {}) => String(template || '').replace(/\{(\w+)\}/g, (_, k) => (vars[k] !== undefined ? String(vars[k]) : ''));
|
|
538
|
+
const update = info?.update;
|
|
539
|
+
const stage = update?.stage;
|
|
540
|
+
const stages = textDict.updateStages || {
|
|
541
|
+
queued: 'Preparing upgrade',
|
|
542
|
+
checking: 'Checking version',
|
|
543
|
+
downloading: 'Downloading update',
|
|
544
|
+
waiting: 'Waiting for analysis to finish',
|
|
545
|
+
installing: 'Upgrading',
|
|
546
|
+
};
|
|
547
|
+
const activeStage = Boolean(stages[stage]) || Boolean(options.starting);
|
|
548
|
+
const updatedAtMs = update?.updatedAt ? Date.parse(update.updatedAt) : NaN;
|
|
549
|
+
const now = options.now ?? Date.now();
|
|
550
|
+
const completed = stage === 'completed' && Number.isFinite(updatedAtMs) && now - updatedAtMs < 60000;
|
|
551
|
+
const failed = stage === 'failed';
|
|
552
|
+
const visible = Boolean(info?.available || activeStage || failed || completed);
|
|
553
|
+
const command = info?.command || 'npx agent-things@latest';
|
|
554
|
+
const label = activeStage
|
|
555
|
+
? (stages[stage] || stages.queued)
|
|
556
|
+
: failed
|
|
557
|
+
? fmtText(textDict.updateFailedLabel || 'Upgrade failed')
|
|
558
|
+
: completed
|
|
559
|
+
? fmtText(textDict.upgradedToPattern || 'Upgraded to v{version}', { version: update?.currentVersion || '' })
|
|
560
|
+
: fmtText(textDict.updateAvailablePattern || 'Update available v{version}', { version: info?.latestVersion || '' });
|
|
561
|
+
const buttonText = activeStage
|
|
562
|
+
? (textDict.pleaseWait || 'Please wait')
|
|
563
|
+
: completed
|
|
564
|
+
? (textDict.completedShort || 'Done')
|
|
565
|
+
: failed
|
|
566
|
+
? (textDict.retryBtn || 'Retry')
|
|
567
|
+
: (textDict.upgradeBtn || 'Upgrade');
|
|
568
|
+
const detail = options.connectionError
|
|
569
|
+
? `${textDict.reconnectHint || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
|
|
570
|
+
: failed
|
|
571
|
+
? `${update?.error || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
|
|
572
|
+
: (completed && update?.reconnectMcp ? (textDict.reconnectMcpHint || '') : '');
|
|
573
|
+
const currentVersion = info?.currentVersion || '';
|
|
574
|
+
const checkFailed = !visible && options.manualCheckStatus === 'failed';
|
|
575
|
+
let versionText = currentVersion ? fmtText(textDict.versionTagPattern || 'v{version}', { version: currentVersion }) : '';
|
|
576
|
+
if (checkFailed) {
|
|
577
|
+
const errText = options.checkError || info?.checkError || '';
|
|
578
|
+
versionText = errText ? `${textDict.checkUpdateFailedLabel || 'Update check failed'}: ${errText}` : (textDict.checkUpdateFailedLabel || 'Update check failed');
|
|
579
|
+
} else if (!visible && options.manualCheckStatus === 'latest' && currentVersion) {
|
|
580
|
+
versionText = fmtText(textDict.alreadyLatestPattern || 'Up to date (v{version})', { version: currentVersion });
|
|
581
|
+
}
|
|
582
|
+
const checking = Boolean(options.checking);
|
|
583
|
+
return {
|
|
584
|
+
visible,
|
|
585
|
+
active: activeStage,
|
|
586
|
+
completed,
|
|
587
|
+
failed,
|
|
588
|
+
buttonDisabled: activeStage || completed,
|
|
589
|
+
label,
|
|
590
|
+
buttonText,
|
|
591
|
+
detail,
|
|
592
|
+
currentVersion,
|
|
593
|
+
versionText,
|
|
594
|
+
showVersionBar: !visible,
|
|
595
|
+
checking,
|
|
596
|
+
checkDisabled: checking,
|
|
597
|
+
checkFailed,
|
|
598
|
+
checkButtonText: checking ? (textDict.checkingUpdateShort || 'Checking...') : (textDict.checkUpdateBtn || 'Check updates'),
|
|
599
|
+
};
|
|
600
|
+
}
|
|
525
601
|
|
|
526
602
|
const active = forLang(currentLang);
|
|
527
603
|
return {
|
|
@@ -544,6 +620,7 @@ const presentation = (function createPresentation(lang) {
|
|
|
544
620
|
progressState,
|
|
545
621
|
draftTransition,
|
|
546
622
|
analysisDisabled,
|
|
623
|
+
updateBannerState,
|
|
547
624
|
};
|
|
548
625
|
})();
|
|
549
|
-
export const { lang, labels, colors, taskLabels, strings, locales, layout, accent, claudeCodeThemes, normalizeHexColor, resolveAccentPalette, t, format, forLang, formatDate, progressValue, progressState, draftTransition, analysisDisabled } = presentation;
|
|
626
|
+
export const { lang, labels, colors, taskLabels, strings, locales, layout, accent, claudeCodeThemes, normalizeHexColor, resolveAccentPalette, t, format, forLang, formatDate, progressValue, progressState, draftTransition, analysisDisabled, updateBannerState } = presentation;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { progressState } from './progress.js';
|
|
2
|
-
import { draftTransition, forLang } from './foundation.js';
|
|
2
|
+
import { draftTransition, forLang, updateBannerState } from './foundation.js';
|
|
3
3
|
import { CONTENT_WIDTH, NOTE_LINE_WIDTH, colors, date, svg, headerRing, headerTitleSpec, statusBadgeSvg, timeTextSvg, scoreSvg, bar, preview, wrapText, measureButtonWidth, measureClearWidth, paneIconWidth } from './presentation.js';
|
|
4
4
|
|
|
5
5
|
let sessionId, cwd, home, data = null, projectGit = null, updateInfo = null, activeLang = 'zh', configLangLoaded = false;
|
|
6
6
|
let mode = 'overview', draft = null, baseRevision = 0, busy = false, error = '', source = null, sourceMode = 'overview';
|
|
7
7
|
let conflict = false, loading = false, refreshPromise = null;
|
|
8
|
+
let checkingUpdate = false, upgrading = false, manualCheckStatus = '', manualCheckError = '', lastUpdateCheckedAt = 0;
|
|
8
9
|
let expanded = false, noteOpen = false, seen = false, sequence = 0, paneRequested = false, waitLoop = 0;
|
|
9
10
|
const PANE = 'agent-things', PANE_TITLE = 'Agent Things', PINNED = 'pane:pinned';
|
|
10
11
|
const SIDEBAR_HINT_DISMISSED = 'sidebar-hint:dismissed';
|
|
@@ -27,7 +28,11 @@ async function request($, action, fields = {}) {
|
|
|
27
28
|
}
|
|
28
29
|
function receive(value) {
|
|
29
30
|
if (value?.lang === 'en' || value?.lang === 'zh') activeLang = value.lang;
|
|
30
|
-
if ('updateInfo' in value) {
|
|
31
|
+
if ('updateInfo' in value) {
|
|
32
|
+
updateInfo = value.updateInfo;
|
|
33
|
+
if (updateInfo?.available) { manualCheckStatus = ''; manualCheckError = ''; }
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
31
36
|
if ((!data && 'revision' in value) || (data && value.revision >= data.revision)) data = value;
|
|
32
37
|
if (value.paneRequested) paneRequested = true;
|
|
33
38
|
if (value.projectGit) projectGit = value.projectGit;
|
|
@@ -167,12 +172,54 @@ function startRefresh($, includeGit = false) {
|
|
|
167
172
|
async function raceWithin($, promise, timeoutMs) {
|
|
168
173
|
await Promise.race([promise, $.clock.sleep(timeoutMs)]);
|
|
169
174
|
}
|
|
175
|
+
async function runUpdateCheck($, force = false) {
|
|
176
|
+
if (checkingUpdate) return;
|
|
177
|
+
if (force) {
|
|
178
|
+
checkingUpdate = true;
|
|
179
|
+
manualCheckStatus = '';
|
|
180
|
+
manualCheckError = '';
|
|
181
|
+
$.ui.invalidate('ui.render');
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const reply = await request($, 'update-info', force ? { force: true } : {});
|
|
185
|
+
lastUpdateCheckedAt = Date.now();
|
|
186
|
+
receive(reply);
|
|
187
|
+
if (force) {
|
|
188
|
+
if (reply?.updateInfo?.checkError && !reply?.updateInfo?.available) {
|
|
189
|
+
manualCheckStatus = 'failed';
|
|
190
|
+
manualCheckError = reply.updateInfo.checkError;
|
|
191
|
+
} else if (!reply?.updateInfo?.available) {
|
|
192
|
+
manualCheckStatus = 'latest';
|
|
193
|
+
$.clock.after(5000, () => {
|
|
194
|
+
if (manualCheckStatus === 'latest' && !checkingUpdate) {
|
|
195
|
+
manualCheckStatus = '';
|
|
196
|
+
$.ui.invalidate('ui.render');
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} catch (failure) {
|
|
202
|
+
if (force) {
|
|
203
|
+
manualCheckStatus = 'failed';
|
|
204
|
+
manualCheckError = failure.message;
|
|
205
|
+
}
|
|
206
|
+
} finally {
|
|
207
|
+
if (force) checkingUpdate = false;
|
|
208
|
+
$.ui.invalidate('ui.render');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function startUpgrade($) {
|
|
212
|
+
if (upgrading) return;
|
|
213
|
+
upgrading = true; manualCheckStatus = ''; manualCheckError = ''; error = ''; $.ui.invalidate('ui.render');
|
|
214
|
+
try { receive(await request($, 'upgrade')); }
|
|
215
|
+
catch (failure) { error = failure.message; }
|
|
216
|
+
finally { upgrading = false; $.ui.invalidate('ui.render'); }
|
|
217
|
+
}
|
|
170
218
|
async function initialize($) {
|
|
171
219
|
await ensureContext($);
|
|
172
220
|
void startRefresh($);
|
|
173
221
|
$.clock.after(0, async () => {
|
|
174
|
-
|
|
175
|
-
$.ui.invalidate('ui.render');
|
|
222
|
+
await runUpdateCheck($, false);
|
|
176
223
|
});
|
|
177
224
|
}
|
|
178
225
|
|
|
@@ -182,12 +229,12 @@ export function register(on) {
|
|
|
182
229
|
await $.command.register({ name: 'things', description: t('cardCommandDescription'), immediate: true });
|
|
183
230
|
if (paneRequested || await $.store.get(PINNED)) { seen = true; paneRequested = false; void $.ui.open({ id: PANE, title: PANE_TITLE }); }
|
|
184
231
|
void watchChanges($);
|
|
185
|
-
// 账本同步由 watchChanges
|
|
232
|
+
// 账本同步由 watchChanges 负责;这里跟进升级进度与长会话周期重查。
|
|
186
233
|
$.clock.every(2000, async () => {
|
|
187
234
|
const updating = ['queued', 'checking', 'downloading', 'waiting', 'installing'].includes(updateInfo?.update?.stage);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
const refreshDue = seen && !checkingUpdate && lastUpdateCheckedAt > 0 && Date.now() - lastUpdateCheckedAt >= 3600000;
|
|
236
|
+
if (!seen || (!updating && !refreshDue) || (updating && busy)) return;
|
|
237
|
+
await runUpdateCheck($, false);
|
|
191
238
|
});
|
|
192
239
|
return next(e);
|
|
193
240
|
});
|
|
@@ -352,10 +399,28 @@ async function draw($, e, inPane) {
|
|
|
352
399
|
content.push(row([button('completed-label', t('completedHeading'), () => view($, 'completed'), { plain: true }), trailing(button('completed', t('countArrowPattern', { count: completed.length }), () => view($, 'completed'), { plain: true, dimColor: true }))]));
|
|
353
400
|
content.push(rule());
|
|
354
401
|
content.push(row([button('note-label', t('notesLabel'), () => edit($), { plain: true }), trailing(button('edit-note', record?.note ? t('editLabel') : t('addLabel'), () => edit($), { plain: true, dimColor: true }))]));
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
402
|
+
const banner = updateBannerState(updateInfo, strings, {
|
|
403
|
+
starting: upgrading,
|
|
404
|
+
checking: checkingUpdate,
|
|
405
|
+
manualCheckStatus,
|
|
406
|
+
checkError: manualCheckError,
|
|
407
|
+
});
|
|
408
|
+
if (banner.visible) {
|
|
409
|
+
if (banner.active) {
|
|
410
|
+
content.push(text(banner.label, { dimColor: true }));
|
|
411
|
+
} else if (banner.completed) {
|
|
412
|
+
content.push(text(banner.label, { dimColor: true }));
|
|
413
|
+
if (banner.detail) content.push(text(banner.detail, { size: 'footnote', dimColor: true }));
|
|
414
|
+
} else {
|
|
415
|
+
content.push(row([text(banner.label), trailing(button('upgrade', banner.buttonText, () => startUpgrade($)))]));
|
|
416
|
+
if (banner.detail) content.push(text(banner.detail, { color: banner.failed ? '#D43F3F' : undefined, size: 'footnote', dimColor: !banner.failed }));
|
|
417
|
+
}
|
|
418
|
+
} else if (updateInfo || checkingUpdate || manualCheckStatus) {
|
|
419
|
+
content.push(row([
|
|
420
|
+
...(banner.versionText ? [text(banner.versionText, banner.checkFailed ? { size: 'footnote', color: '#D43F3F' } : { size: 'footnote', dimColor: true })] : []),
|
|
421
|
+
trailing(button('check-update', banner.checkButtonText, () => runUpdateCheck($, true), { plain: true, dimColor: true })),
|
|
422
|
+
]));
|
|
423
|
+
}
|
|
359
424
|
}
|
|
360
425
|
if (error) content.push(Box({ width: '100%', flexDirection: 'column', children: [text(wrapText(error, inPane ? Math.max(100, viewWidth - 16) : NOTE_LINE_WIDTH), { color: '#D43F3F' })] }));
|
|
361
426
|
if (mode === 'edit' && (conflict || error.includes('其他窗口') || error.includes('another window'))) content.push(button('reload-version', t('resolveConflictBtn'), async () => {
|
|
@@ -1042,12 +1042,13 @@
|
|
|
1042
1042
|
return;
|
|
1043
1043
|
}
|
|
1044
1044
|
|
|
1045
|
-
//
|
|
1045
|
+
// 宿主桥代发写操作(保存、清除、分析、版本更新)
|
|
1046
1046
|
if (data.type === 'AGENT_THINGS_ACTION_PROXY') {
|
|
1047
1047
|
const { nonce, action, payload } = data;
|
|
1048
1048
|
if (!nonce) return;
|
|
1049
1049
|
try {
|
|
1050
1050
|
const key = JSON.stringify(['local', boundConvId]);
|
|
1051
|
+
const isUpdateAction = action === 'app-update-info' || action === 'app-update-start';
|
|
1051
1052
|
let rpcMsg = null;
|
|
1052
1053
|
if (action === 'update') {
|
|
1053
1054
|
rpcMsg = { type: 'update', key, record: payload.record, expectedRevision: payload.expectedRevision, requestId: 'proxy-update-' + Date.now() };
|
|
@@ -1055,6 +1056,15 @@
|
|
|
1055
1056
|
rpcMsg = { type: 'clear', key, expectedRevision: payload.expectedRevision, requestId: 'proxy-clear-' + Date.now() };
|
|
1056
1057
|
} else if (action === 'analyze') {
|
|
1057
1058
|
rpcMsg = { type: 'analyze', key, requestId: 'proxy-analyze-' + Date.now() };
|
|
1059
|
+
} else if (action === 'app-update-info') {
|
|
1060
|
+
rpcMsg = {
|
|
1061
|
+
type: 'app-update-info',
|
|
1062
|
+
key,
|
|
1063
|
+
...(typeof payload?.force === 'boolean' ? { force: payload.force } : {}),
|
|
1064
|
+
requestId: 'proxy-update-info-' + Date.now(),
|
|
1065
|
+
};
|
|
1066
|
+
} else if (action === 'app-update-start') {
|
|
1067
|
+
rpcMsg = { type: 'app-update-start', key, requestId: 'proxy-update-start-' + Date.now() };
|
|
1058
1068
|
}
|
|
1059
1069
|
if (rpcMsg) {
|
|
1060
1070
|
const res = await fetch(`${getServiceOrigin()}/rpc`, {
|
|
@@ -1063,6 +1073,18 @@
|
|
|
1063
1073
|
body: JSON.stringify(rpcMsg),
|
|
1064
1074
|
});
|
|
1065
1075
|
const reply = await res.json();
|
|
1076
|
+
if (isUpdateAction) {
|
|
1077
|
+
sendReplyToCard(binding, targetPort, {
|
|
1078
|
+
type: 'AGENT_THINGS_ACTION_RESULT',
|
|
1079
|
+
nonce,
|
|
1080
|
+
action,
|
|
1081
|
+
success: !reply.error,
|
|
1082
|
+
error: reply.error || null,
|
|
1083
|
+
updateInfo: reply.updateInfo || null,
|
|
1084
|
+
data: { updateInfo: reply.updateInfo || null, lang: reply.lang },
|
|
1085
|
+
});
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1066
1088
|
if (reply.snapshot) {
|
|
1067
1089
|
window.__codexSessionStatus?.receive?.(reply.snapshot);
|
|
1068
1090
|
}
|
|
@@ -2055,7 +2077,7 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2055
2077
|
panelEvent('close', panel.entry);
|
|
2056
2078
|
const target = panel; panel = null;
|
|
2057
2079
|
clearTimeout(target.pollTimer); cancelAnimationFrame(target.marqueeFrame);
|
|
2058
|
-
clearTimeout(target.updateTimer);
|
|
2080
|
+
clearTimeout(target.updateTimer); clearTimeout(target.manualCheckTimer);
|
|
2059
2081
|
target.resizeObserver?.disconnect();
|
|
2060
2082
|
target.root.remove(); target.entry.button.setAttribute('aria-expanded', 'false');
|
|
2061
2083
|
if (restoreFocus && target.entry.host.isConnected) target.entry.button.focus();
|
|
@@ -2090,6 +2112,7 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2090
2112
|
.note-label{display:block;font-size:11px;color:var(--secondary);margin-bottom:8px}textarea{display:block;width:100%;resize:vertical;min-height:66px;max-height:140px;background:var(--input-bg);color:inherit;border:1px solid var(--input-border);border-radius:8px;padding:9px;line-height:1.6;font-size:12px;scrollbar-width:none;-ms-overflow-style:none}textarea::-webkit-scrollbar{display:none;width:0;height:0}textarea::placeholder{color:var(--muted)}.edit-actions{display:flex;justify-content:flex-end;gap:18px;align-items:center;padding:21px 0 16px}.git{font-size:11px;color:var(--secondary)}.analysis-message{font-size:11px;color:var(--secondary);margin:0 0 13px}.analysis-message:empty,.error:empty,.git:empty{display:none}.error{flex:none;font-size:12px;color:var(--error);padding-top:10px;white-space:pre-wrap}button:disabled,input:disabled,textarea:disabled{opacity:.55;cursor:wait}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
2091
2113
|
.shell textarea:focus-visible{outline:none}
|
|
2092
2114
|
.app-update{margin-top:3px;padding:10px 11px;background:var(--hover);border:1px solid var(--line);border-radius:10px}.app-update-row{display:flex;align-items:center;justify-content:space-between;gap:10px}.app-update-label{font-size:12px;line-height:18px;color:var(--ink);min-width:0;overflow-wrap:anywhere}.app-update-button{flex:none;padding:5px 10px;min-height:28px;border-radius:7px;font-size:11px}.app-update-detail{margin-top:7px;font-size:11px;line-height:1.6;color:var(--secondary);white-space:pre-wrap;overflow-wrap:anywhere;user-select:text}.app-update[data-failed=true] .app-update-detail{color:var(--error)}
|
|
2115
|
+
.version-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 0 2px;font-size:11px;line-height:16px;color:var(--muted)}.version-bar-text{min-width:0;overflow-wrap:anywhere}.version-bar[data-failed=true] .version-bar-text{color:var(--error)}.version-check-button{flex:none;font-size:11px;color:var(--muted)}.version-check-button:hover:not(:disabled){color:inherit}
|
|
2093
2116
|
:host([data-color-mode=light]){--ink:#22272e;--secondary:#576374;--muted:#667383;--note:#46515f;--track:#dfe4ea;--line:#dfe4ea;--input-border:#c7d0da;--input-bg:#f7f9fb;--hover:#f0f3f6;--selected:#e9edf2;--source-bg:#e9eef4;--number-line:#b6c1ce;--thumb:#ffffff;--danger:#bf2f3a;--error:#b13a2d;color:var(--ink);color-scheme:light}
|
|
2094
2117
|
:host([data-color-mode=light]) .shell{--panel-bg:#fff;border-color:#dfe4ea;box-shadow:0 14px 45px #26344520}
|
|
2095
2118
|
:host([data-color-mode=light]) .shell:hover{--panel-bg:#f5f6f7}
|
|
@@ -2160,6 +2183,9 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2160
2183
|
const appUpdateLabel = element('span', null, appUpdateRow, 'app-update-label'); appUpdateLabel.setAttribute('role', 'status');
|
|
2161
2184
|
const appUpdateButton = element('button', S('upgradeBtn'), appUpdateRow, 'primary app-update-button');
|
|
2162
2185
|
const appUpdateDetail = element('div', null, appUpdate, 'app-update-detail'); appUpdateDetail.hidden = true;
|
|
2186
|
+
const versionBar = element('div', null, overview, 'version-bar'); versionBar.hidden = true;
|
|
2187
|
+
const versionBarText = element('span', null, versionBar, 'version-bar-text'); versionBarText.setAttribute('role', 'status');
|
|
2188
|
+
const checkUpdateButton = element('button', S('checkUpdateBtn'), versionBar, 'text-button version-check-button');
|
|
2163
2189
|
const edit = element('div', null, body, 'view edit-view'); edit.hidden = true;
|
|
2164
2190
|
const editHeading = element('div', null, edit, 'view-heading'); const editHeadingTitle = element('h3', S('editHeading'), editHeading);
|
|
2165
2191
|
const choices = new Map(), choiceLabels = new Map(), controls = [];
|
|
@@ -2245,6 +2271,8 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2245
2271
|
if (timelineBackBtn) timelineBackBtn.textContent = S('backLabel');
|
|
2246
2272
|
resolveConflict.textContent = S('resolveConflictBtn');
|
|
2247
2273
|
target.tasksKey = null; target.completedKey = null; target.timelineRevision = null;
|
|
2274
|
+
if (target.updateInfo || target.updateChecking || target.manualCheckStatus) showAppUpdate(target.updateInfo);
|
|
2275
|
+
else checkUpdateButton.textContent = S('checkUpdateBtn');
|
|
2248
2276
|
};
|
|
2249
2277
|
target.capabilities = embedded?.session?.capabilities || null;
|
|
2250
2278
|
panelEvent('open', entry);
|
|
@@ -2258,24 +2286,58 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2258
2286
|
resolveConflict.onclick = () => rebaseDraft(target);
|
|
2259
2287
|
const showAppUpdate = info => {
|
|
2260
2288
|
target.updateInfo = info;
|
|
2261
|
-
const
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2289
|
+
const options = {
|
|
2290
|
+
starting: target.upgradeStarting,
|
|
2291
|
+
checking: target.updateChecking,
|
|
2292
|
+
connectionError: target.updateConnectionError,
|
|
2293
|
+
manualCheckStatus: target.manualCheckStatus,
|
|
2294
|
+
checkError: target.manualCheckError,
|
|
2295
|
+
};
|
|
2296
|
+
const banner = presentation?.updateBannerState
|
|
2297
|
+
? presentation.updateBannerState(info, strings, options)
|
|
2298
|
+
: (() => {
|
|
2299
|
+
const update = info?.update;
|
|
2300
|
+
const stage = update?.stage;
|
|
2301
|
+
const stages = strings.updateStages || { queued: '正在准备升级', checking: '正在检查版本', downloading: '正在下载新版本', waiting: '等待当前分析结束', installing: '正在升级' };
|
|
2302
|
+
const active = Boolean(stages[stage]) || Boolean(options.starting);
|
|
2303
|
+
const completed = stage === 'completed' && Date.now() - Date.parse(update.updatedAt) < 60000;
|
|
2304
|
+
const failed = stage === 'failed';
|
|
2305
|
+
const visible = Boolean(info?.available || active || failed || completed);
|
|
2306
|
+
const command = info?.command || 'npx agent-things@latest';
|
|
2307
|
+
return {
|
|
2308
|
+
visible,
|
|
2309
|
+
active,
|
|
2310
|
+
completed,
|
|
2311
|
+
failed,
|
|
2312
|
+
buttonDisabled: active || completed,
|
|
2313
|
+
label: active ? stages[stage] || stages.queued : failed ? S('updateFailedLabel') : completed
|
|
2314
|
+
? S('upgradedToPattern', { version: update?.currentVersion }) : S('updateAvailablePattern', { version: info?.latestVersion }),
|
|
2315
|
+
buttonText: active ? S('pleaseWait') : completed ? S('completedShort') : failed ? S('retryBtn') : S('upgradeBtn'),
|
|
2316
|
+
detail: options.connectionError ? `${S('reconnectHint')}\n${S('terminalUpgradePrefix')}${command}`
|
|
2317
|
+
: failed ? `${update?.error || ''}\n${S('terminalUpgradePrefix')}${command}` : completed && update?.reconnectMcp ? S('reconnectMcpHint') : '',
|
|
2318
|
+
versionText: options.manualCheckStatus === 'failed'
|
|
2319
|
+
? `${S('checkUpdateFailedLabel')}${options.checkError ? `: ${options.checkError}` : ''}`
|
|
2320
|
+
: (options.manualCheckStatus === 'latest' && info?.currentVersion ? S('alreadyLatestPattern', { version: info.currentVersion }) : (info?.currentVersion ? `v${info.currentVersion}` : '')),
|
|
2321
|
+
showVersionBar: !visible,
|
|
2322
|
+
checkDisabled: Boolean(options.checking),
|
|
2323
|
+
checkFailed: !visible && options.manualCheckStatus === 'failed',
|
|
2324
|
+
checkButtonText: options.checking ? S('checkingUpdateShort') : S('checkUpdateBtn'),
|
|
2325
|
+
};
|
|
2326
|
+
})();
|
|
2327
|
+
appUpdate.hidden = !banner.visible;
|
|
2328
|
+
appUpdate.setAttribute('data-failed', String(banner.failed));
|
|
2329
|
+
appUpdateLabel.textContent = banner.label;
|
|
2330
|
+
appUpdateButton.textContent = banner.buttonText;
|
|
2331
|
+
appUpdateButton.disabled = banner.buttonDisabled;
|
|
2332
|
+
appUpdateDetail.textContent = banner.detail;
|
|
2276
2333
|
appUpdateDetail.hidden = !appUpdateDetail.textContent;
|
|
2334
|
+
versionBar.hidden = !(banner.showVersionBar && (info || banner.checking || banner.checkFailed));
|
|
2335
|
+
versionBar.setAttribute('data-failed', String(banner.checkFailed));
|
|
2336
|
+
versionBarText.textContent = banner.versionText;
|
|
2337
|
+
checkUpdateButton.textContent = banner.checkButtonText;
|
|
2338
|
+
checkUpdateButton.disabled = banner.checkDisabled;
|
|
2277
2339
|
refreshPanel();
|
|
2278
|
-
return active;
|
|
2340
|
+
return banner.active;
|
|
2279
2341
|
};
|
|
2280
2342
|
const pollAppUpdate = async () => {
|
|
2281
2343
|
clearTimeout(target.updateTimer);
|
|
@@ -2283,6 +2345,10 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2283
2345
|
const info = await target.request('app-update-info', 12000);
|
|
2284
2346
|
if (panel !== target) return;
|
|
2285
2347
|
target.updateConnectionError = null;
|
|
2348
|
+
if (info?.available) {
|
|
2349
|
+
target.manualCheckStatus = '';
|
|
2350
|
+
target.manualCheckError = '';
|
|
2351
|
+
}
|
|
2286
2352
|
const active = showAppUpdate(info);
|
|
2287
2353
|
target.updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
|
|
2288
2354
|
} catch (error) {
|
|
@@ -2292,6 +2358,41 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2292
2358
|
target.updateTimer = setTimeout(pollAppUpdate, 2000);
|
|
2293
2359
|
}
|
|
2294
2360
|
};
|
|
2361
|
+
checkUpdateButton.onclick = async () => {
|
|
2362
|
+
if (target.updateChecking || checkUpdateButton.disabled) return;
|
|
2363
|
+
clearTimeout(target.updateTimer);
|
|
2364
|
+
clearTimeout(target.manualCheckTimer);
|
|
2365
|
+
target.updateChecking = true;
|
|
2366
|
+
target.manualCheckStatus = '';
|
|
2367
|
+
target.manualCheckError = '';
|
|
2368
|
+
showAppUpdate(target.updateInfo);
|
|
2369
|
+
try {
|
|
2370
|
+
const info = await target.request('app-update-info', 12000, { force: true });
|
|
2371
|
+
if (panel !== target) return;
|
|
2372
|
+
target.updateChecking = false;
|
|
2373
|
+
target.updateConnectionError = null;
|
|
2374
|
+
if (info?.checkError && !info?.available) {
|
|
2375
|
+
target.manualCheckStatus = 'failed';
|
|
2376
|
+
target.manualCheckError = info.checkError;
|
|
2377
|
+
} else if (!info?.available) {
|
|
2378
|
+
target.manualCheckStatus = 'latest';
|
|
2379
|
+
target.manualCheckTimer = setTimeout(() => {
|
|
2380
|
+
if (panel !== target || target.manualCheckStatus !== 'latest') return;
|
|
2381
|
+
target.manualCheckStatus = '';
|
|
2382
|
+
showAppUpdate(target.updateInfo);
|
|
2383
|
+
}, 5000);
|
|
2384
|
+
}
|
|
2385
|
+
const active = showAppUpdate(info);
|
|
2386
|
+
target.updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
|
|
2387
|
+
} catch (error) {
|
|
2388
|
+
if (panel !== target) return;
|
|
2389
|
+
target.updateChecking = false;
|
|
2390
|
+
target.manualCheckStatus = 'failed';
|
|
2391
|
+
target.manualCheckError = error.message;
|
|
2392
|
+
showAppUpdate(target.updateInfo);
|
|
2393
|
+
target.updateTimer = setTimeout(pollAppUpdate, 60000);
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2295
2396
|
appUpdateButton.onclick = async () => {
|
|
2296
2397
|
if (appUpdateButton.disabled) return;
|
|
2297
2398
|
clearTimeout(target.updateTimer);
|
|
@@ -2617,7 +2718,7 @@ function installCodexSessionStatus(version, restored, embedded) {
|
|
|
2617
2718
|
},
|
|
2618
2719
|
destroy() {
|
|
2619
2720
|
destroyed = true; localCards?.destroy(); harness?.dispose?.(); observer.disconnect(); rootObserver?.disconnect(); headObserver?.disconnect(); cancelAnimationFrame(frame);
|
|
2620
|
-
if (panel) { rememberPanel(panel); panelEvent('dispose', panel.entry); clearTimeout(panel.pollTimer); clearTimeout(panel.updateTimer); cancelAnimationFrame(panel.marqueeFrame); panel.resizeObserver?.disconnect(); panel.root.remove(); panel.entry.button?.setAttribute('aria-expanded', 'false'); panel = null; }
|
|
2721
|
+
if (panel) { rememberPanel(panel); panelEvent('dispose', panel.entry); clearTimeout(panel.pollTimer); clearTimeout(panel.updateTimer); clearTimeout(panel.manualCheckTimer); cancelAnimationFrame(panel.marqueeFrame); panel.resizeObserver?.disconnect(); panel.root.remove(); panel.entry.button?.setAttribute('aria-expanded', 'false'); panel = null; }
|
|
2621
2722
|
for (const entry of [...mounted.values()]) unmount(entry);
|
|
2622
2723
|
document.removeEventListener('pointerdown', onOutside, true); document.removeEventListener('keydown', onKey, true);
|
|
2623
2724
|
document.removeEventListener('scroll', onScroll, true); window.removeEventListener('resize', positionPanel);
|