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.
@@ -347,6 +347,11 @@ function createPresentation(lang) {
347
347
  updateFailedLabel: '升级失败',
348
348
  upgradeBtn: '立即升级',
349
349
  upgradingShort: '正在升级…',
350
+ checkUpdateBtn: '检查更新',
351
+ checkingUpdateShort: '正在检查…',
352
+ alreadyLatestPattern: '当前已是最新版 v{version}',
353
+ versionTagPattern: 'v{version}',
354
+ checkUpdateFailedLabel: '检查更新失败',
350
355
  pleaseWait: '请稍候',
351
356
  completedShort: '已完成',
352
357
  retryBtn: '重试',
@@ -536,6 +541,11 @@ function createPresentation(lang) {
536
541
  updateFailedLabel: 'Upgrade failed',
537
542
  upgradeBtn: 'Upgrade',
538
543
  upgradingShort: 'Upgrading...',
544
+ checkUpdateBtn: 'Check updates',
545
+ checkingUpdateShort: 'Checking...',
546
+ alreadyLatestPattern: 'Up to date (v{version})',
547
+ versionTagPattern: 'v{version}',
548
+ checkUpdateFailedLabel: 'Update check failed',
539
549
  pleaseWait: 'Please wait',
540
550
  completedShort: 'Done',
541
551
  retryBtn: 'Retry',
@@ -625,6 +635,72 @@ function createPresentation(lang) {
625
635
  function analysisDisabled(busy, analyzing, upgradeStage) {
626
636
  return Boolean(busy || analyzing || ['waiting', 'installing'].includes(upgradeStage));
627
637
  }
638
+ function updateBannerState(info, dict, options = {}) {
639
+ const textDict = dict || {};
640
+ const fmtText = (template, vars = {}) => String(template || '').replace(/\{(\w+)\}/g, (_, k) => (vars[k] !== undefined ? String(vars[k]) : ''));
641
+ const update = info?.update;
642
+ const stage = update?.stage;
643
+ const stages = textDict.updateStages || {
644
+ queued: 'Preparing upgrade',
645
+ checking: 'Checking version',
646
+ downloading: 'Downloading update',
647
+ waiting: 'Waiting for analysis to finish',
648
+ installing: 'Upgrading',
649
+ };
650
+ const activeStage = Boolean(stages[stage]) || Boolean(options.starting);
651
+ const updatedAtMs = update?.updatedAt ? Date.parse(update.updatedAt) : NaN;
652
+ const now = options.now ?? Date.now();
653
+ const completed = stage === 'completed' && Number.isFinite(updatedAtMs) && now - updatedAtMs < 60000;
654
+ const failed = stage === 'failed';
655
+ const visible = Boolean(info?.available || activeStage || failed || completed);
656
+ const command = info?.command || 'npx agent-things@latest';
657
+ const label = activeStage
658
+ ? (stages[stage] || stages.queued)
659
+ : failed
660
+ ? fmtText(textDict.updateFailedLabel || 'Upgrade failed')
661
+ : completed
662
+ ? fmtText(textDict.upgradedToPattern || 'Upgraded to v{version}', { version: update?.currentVersion || '' })
663
+ : fmtText(textDict.updateAvailablePattern || 'Update available v{version}', { version: info?.latestVersion || '' });
664
+ const buttonText = activeStage
665
+ ? (textDict.pleaseWait || 'Please wait')
666
+ : completed
667
+ ? (textDict.completedShort || 'Done')
668
+ : failed
669
+ ? (textDict.retryBtn || 'Retry')
670
+ : (textDict.upgradeBtn || 'Upgrade');
671
+ const detail = options.connectionError
672
+ ? `${textDict.reconnectHint || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
673
+ : failed
674
+ ? `${update?.error || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
675
+ : (completed && update?.reconnectMcp ? (textDict.reconnectMcpHint || '') : '');
676
+ const currentVersion = info?.currentVersion || '';
677
+ const checkFailed = !visible && options.manualCheckStatus === 'failed';
678
+ let versionText = currentVersion ? fmtText(textDict.versionTagPattern || 'v{version}', { version: currentVersion }) : '';
679
+ if (checkFailed) {
680
+ const errText = options.checkError || info?.checkError || '';
681
+ versionText = errText ? `${textDict.checkUpdateFailedLabel || 'Update check failed'}: ${errText}` : (textDict.checkUpdateFailedLabel || 'Update check failed');
682
+ } else if (!visible && options.manualCheckStatus === 'latest' && currentVersion) {
683
+ versionText = fmtText(textDict.alreadyLatestPattern || 'Up to date (v{version})', { version: currentVersion });
684
+ }
685
+ const checking = Boolean(options.checking);
686
+ return {
687
+ visible,
688
+ active: activeStage,
689
+ completed,
690
+ failed,
691
+ buttonDisabled: activeStage || completed,
692
+ label,
693
+ buttonText,
694
+ detail,
695
+ currentVersion,
696
+ versionText,
697
+ showVersionBar: !visible,
698
+ checking,
699
+ checkDisabled: checking,
700
+ checkFailed,
701
+ checkButtonText: checking ? (textDict.checkingUpdateShort || 'Checking...') : (textDict.checkUpdateBtn || 'Check updates'),
702
+ };
703
+ }
628
704
 
629
705
  const active = forLang(currentLang);
630
706
  return {
@@ -647,6 +723,7 @@ function createPresentation(lang) {
647
723
  progressState,
648
724
  draftTransition,
649
725
  analysisDisabled,
726
+ updateBannerState,
650
727
  };
651
728
  }
652
729
 
@@ -1373,7 +1450,7 @@ function installCodexSessionStatus(version, restored, embedded) {
1373
1450
  panelEvent('close', panel.entry);
1374
1451
  const target = panel; panel = null;
1375
1452
  clearTimeout(target.pollTimer); cancelAnimationFrame(target.marqueeFrame);
1376
- clearTimeout(target.updateTimer);
1453
+ clearTimeout(target.updateTimer); clearTimeout(target.manualCheckTimer);
1377
1454
  target.resizeObserver?.disconnect();
1378
1455
  target.root.remove(); target.entry.button.setAttribute('aria-expanded', 'false');
1379
1456
  if (restoreFocus && target.entry.host.isConnected) target.entry.button.focus();
@@ -1408,6 +1485,7 @@ function installCodexSessionStatus(version, restored, embedded) {
1408
1485
  .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}
1409
1486
  .shell textarea:focus-visible{outline:none}
1410
1487
  .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)}
1488
+ .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}
1411
1489
  :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}
1412
1490
  :host([data-color-mode=light]) .shell{--panel-bg:#fff;border-color:#dfe4ea;box-shadow:0 14px 45px #26344520}
1413
1491
  :host([data-color-mode=light]) .shell:hover{--panel-bg:#f5f6f7}
@@ -1478,6 +1556,9 @@ function installCodexSessionStatus(version, restored, embedded) {
1478
1556
  const appUpdateLabel = element('span', null, appUpdateRow, 'app-update-label'); appUpdateLabel.setAttribute('role', 'status');
1479
1557
  const appUpdateButton = element('button', S('upgradeBtn'), appUpdateRow, 'primary app-update-button');
1480
1558
  const appUpdateDetail = element('div', null, appUpdate, 'app-update-detail'); appUpdateDetail.hidden = true;
1559
+ const versionBar = element('div', null, overview, 'version-bar'); versionBar.hidden = true;
1560
+ const versionBarText = element('span', null, versionBar, 'version-bar-text'); versionBarText.setAttribute('role', 'status');
1561
+ const checkUpdateButton = element('button', S('checkUpdateBtn'), versionBar, 'text-button version-check-button');
1481
1562
  const edit = element('div', null, body, 'view edit-view'); edit.hidden = true;
1482
1563
  const editHeading = element('div', null, edit, 'view-heading'); const editHeadingTitle = element('h3', S('editHeading'), editHeading);
1483
1564
  const choices = new Map(), choiceLabels = new Map(), controls = [];
@@ -1563,6 +1644,8 @@ function installCodexSessionStatus(version, restored, embedded) {
1563
1644
  if (timelineBackBtn) timelineBackBtn.textContent = S('backLabel');
1564
1645
  resolveConflict.textContent = S('resolveConflictBtn');
1565
1646
  target.tasksKey = null; target.completedKey = null; target.timelineRevision = null;
1647
+ if (target.updateInfo || target.updateChecking || target.manualCheckStatus) showAppUpdate(target.updateInfo);
1648
+ else checkUpdateButton.textContent = S('checkUpdateBtn');
1566
1649
  };
1567
1650
  target.capabilities = embedded?.session?.capabilities || null;
1568
1651
  panelEvent('open', entry);
@@ -1576,24 +1659,58 @@ function installCodexSessionStatus(version, restored, embedded) {
1576
1659
  resolveConflict.onclick = () => rebaseDraft(target);
1577
1660
  const showAppUpdate = info => {
1578
1661
  target.updateInfo = info;
1579
- const update = info?.update;
1580
- const stage = update?.stage;
1581
- const stages = strings.updateStages || { queued: '正在准备升级', checking: '正在检查版本', downloading: '正在下载新版本', waiting: '等待当前分析结束', installing: '正在升级' };
1582
- const active = Boolean(stages[stage]) || target.upgradeStarting;
1583
- const completed = stage === 'completed' && Date.now() - Date.parse(update.updatedAt) < 60000;
1584
- const failed = stage === 'failed';
1585
- appUpdate.hidden = !info?.available && !active && !failed && !completed;
1586
- appUpdate.setAttribute('data-failed', String(failed));
1587
- appUpdateLabel.textContent = active ? stages[stage] || stages.queued : failed ? S('updateFailedLabel') : completed
1588
- ? S('upgradedToPattern', { version: update.currentVersion }) : S('updateAvailablePattern', { version: info?.latestVersion });
1589
- appUpdateButton.textContent = active ? S('pleaseWait') : completed ? S('completedShort') : failed ? S('retryBtn') : S('upgradeBtn');
1590
- appUpdateButton.disabled = active || completed;
1591
- const command = info?.command || 'npx agent-things@latest';
1592
- appUpdateDetail.textContent = target.updateConnectionError ? `${S('reconnectHint')}\n${S('terminalUpgradePrefix')}${command}`
1593
- : failed ? `${update.error}\n${S('terminalUpgradePrefix')}${command}` : completed && update.reconnectMcp ? S('reconnectMcpHint') : '';
1662
+ const options = {
1663
+ starting: target.upgradeStarting,
1664
+ checking: target.updateChecking,
1665
+ connectionError: target.updateConnectionError,
1666
+ manualCheckStatus: target.manualCheckStatus,
1667
+ checkError: target.manualCheckError,
1668
+ };
1669
+ const banner = presentation?.updateBannerState
1670
+ ? presentation.updateBannerState(info, strings, options)
1671
+ : (() => {
1672
+ const update = info?.update;
1673
+ const stage = update?.stage;
1674
+ const stages = strings.updateStages || { queued: '正在准备升级', checking: '正在检查版本', downloading: '正在下载新版本', waiting: '等待当前分析结束', installing: '正在升级' };
1675
+ const active = Boolean(stages[stage]) || Boolean(options.starting);
1676
+ const completed = stage === 'completed' && Date.now() - Date.parse(update.updatedAt) < 60000;
1677
+ const failed = stage === 'failed';
1678
+ const visible = Boolean(info?.available || active || failed || completed);
1679
+ const command = info?.command || 'npx agent-things@latest';
1680
+ return {
1681
+ visible,
1682
+ active,
1683
+ completed,
1684
+ failed,
1685
+ buttonDisabled: active || completed,
1686
+ label: active ? stages[stage] || stages.queued : failed ? S('updateFailedLabel') : completed
1687
+ ? S('upgradedToPattern', { version: update?.currentVersion }) : S('updateAvailablePattern', { version: info?.latestVersion }),
1688
+ buttonText: active ? S('pleaseWait') : completed ? S('completedShort') : failed ? S('retryBtn') : S('upgradeBtn'),
1689
+ detail: options.connectionError ? `${S('reconnectHint')}\n${S('terminalUpgradePrefix')}${command}`
1690
+ : failed ? `${update?.error || ''}\n${S('terminalUpgradePrefix')}${command}` : completed && update?.reconnectMcp ? S('reconnectMcpHint') : '',
1691
+ versionText: options.manualCheckStatus === 'failed'
1692
+ ? `${S('checkUpdateFailedLabel')}${options.checkError ? `: ${options.checkError}` : ''}`
1693
+ : (options.manualCheckStatus === 'latest' && info?.currentVersion ? S('alreadyLatestPattern', { version: info.currentVersion }) : (info?.currentVersion ? `v${info.currentVersion}` : '')),
1694
+ showVersionBar: !visible,
1695
+ checkDisabled: Boolean(options.checking),
1696
+ checkFailed: !visible && options.manualCheckStatus === 'failed',
1697
+ checkButtonText: options.checking ? S('checkingUpdateShort') : S('checkUpdateBtn'),
1698
+ };
1699
+ })();
1700
+ appUpdate.hidden = !banner.visible;
1701
+ appUpdate.setAttribute('data-failed', String(banner.failed));
1702
+ appUpdateLabel.textContent = banner.label;
1703
+ appUpdateButton.textContent = banner.buttonText;
1704
+ appUpdateButton.disabled = banner.buttonDisabled;
1705
+ appUpdateDetail.textContent = banner.detail;
1594
1706
  appUpdateDetail.hidden = !appUpdateDetail.textContent;
1707
+ versionBar.hidden = !(banner.showVersionBar && (info || banner.checking || banner.checkFailed));
1708
+ versionBar.setAttribute('data-failed', String(banner.checkFailed));
1709
+ versionBarText.textContent = banner.versionText;
1710
+ checkUpdateButton.textContent = banner.checkButtonText;
1711
+ checkUpdateButton.disabled = banner.checkDisabled;
1595
1712
  refreshPanel();
1596
- return active;
1713
+ return banner.active;
1597
1714
  };
1598
1715
  const pollAppUpdate = async () => {
1599
1716
  clearTimeout(target.updateTimer);
@@ -1601,6 +1718,10 @@ function installCodexSessionStatus(version, restored, embedded) {
1601
1718
  const info = await target.request('app-update-info', 12000);
1602
1719
  if (panel !== target) return;
1603
1720
  target.updateConnectionError = null;
1721
+ if (info?.available) {
1722
+ target.manualCheckStatus = '';
1723
+ target.manualCheckError = '';
1724
+ }
1604
1725
  const active = showAppUpdate(info);
1605
1726
  target.updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
1606
1727
  } catch (error) {
@@ -1610,6 +1731,41 @@ function installCodexSessionStatus(version, restored, embedded) {
1610
1731
  target.updateTimer = setTimeout(pollAppUpdate, 2000);
1611
1732
  }
1612
1733
  };
1734
+ checkUpdateButton.onclick = async () => {
1735
+ if (target.updateChecking || checkUpdateButton.disabled) return;
1736
+ clearTimeout(target.updateTimer);
1737
+ clearTimeout(target.manualCheckTimer);
1738
+ target.updateChecking = true;
1739
+ target.manualCheckStatus = '';
1740
+ target.manualCheckError = '';
1741
+ showAppUpdate(target.updateInfo);
1742
+ try {
1743
+ const info = await target.request('app-update-info', 12000, { force: true });
1744
+ if (panel !== target) return;
1745
+ target.updateChecking = false;
1746
+ target.updateConnectionError = null;
1747
+ if (info?.checkError && !info?.available) {
1748
+ target.manualCheckStatus = 'failed';
1749
+ target.manualCheckError = info.checkError;
1750
+ } else if (!info?.available) {
1751
+ target.manualCheckStatus = 'latest';
1752
+ target.manualCheckTimer = setTimeout(() => {
1753
+ if (panel !== target || target.manualCheckStatus !== 'latest') return;
1754
+ target.manualCheckStatus = '';
1755
+ showAppUpdate(target.updateInfo);
1756
+ }, 5000);
1757
+ }
1758
+ const active = showAppUpdate(info);
1759
+ target.updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
1760
+ } catch (error) {
1761
+ if (panel !== target) return;
1762
+ target.updateChecking = false;
1763
+ target.manualCheckStatus = 'failed';
1764
+ target.manualCheckError = error.message;
1765
+ showAppUpdate(target.updateInfo);
1766
+ target.updateTimer = setTimeout(pollAppUpdate, 60000);
1767
+ }
1768
+ };
1613
1769
  appUpdateButton.onclick = async () => {
1614
1770
  if (appUpdateButton.disabled) return;
1615
1771
  clearTimeout(target.updateTimer);
@@ -1935,7 +2091,7 @@ function installCodexSessionStatus(version, restored, embedded) {
1935
2091
  },
1936
2092
  destroy() {
1937
2093
  destroyed = true; localCards?.destroy(); harness?.dispose?.(); observer.disconnect(); rootObserver?.disconnect(); headObserver?.disconnect(); cancelAnimationFrame(frame);
1938
- 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; }
2094
+ 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; }
1939
2095
  for (const entry of [...mounted.values()]) unmount(entry);
1940
2096
  document.removeEventListener('pointerdown', onOutside, true); document.removeEventListener('keydown', onKey, true);
1941
2097
  document.removeEventListener('scroll', onScroll, true); window.removeEventListener('resize', positionPanel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-things",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Session task progress and checklists for ChatGPT, Antigravity and Claude Desktop on macOS.",
5
5
  "license": "MIT",
6
6
  "author": "snuffpic",
@@ -5,7 +5,7 @@ const { createPresentation } = require('../src/ui-foundation.cjs');
5
5
 
6
6
  function buildSharedUi() {
7
7
  const target = path.join(__dirname, '../mods/agent-things-ui/hooks/foundation.js');
8
- const source = `// Generated from src/ui-foundation.cjs. Edit the shared source.\nconst presentation = (${createPresentation.toString()})();\nexport const { lang, labels, colors, taskLabels, strings, locales, layout, accent, claudeCodeThemes, normalizeHexColor, resolveAccentPalette, t, format, forLang, formatDate, progressValue, progressState, draftTransition, analysisDisabled } = presentation;\n`;
8
+ const source = `// Generated from src/ui-foundation.cjs. Edit the shared source.\nconst presentation = (${createPresentation.toString()})();\nexport const { lang, labels, colors, taskLabels, strings, locales, layout, accent, claudeCodeThemes, normalizeHexColor, resolveAccentPalette, t, format, forLang, formatDate, progressValue, progressState, draftTransition, analysisDisabled, updateBannerState } = presentation;\n`;
9
9
  fs.writeFileSync(target, source);
10
10
 
11
11
  const sidecarI18nTarget = path.join(__dirname, '../src/plugins/things/sidecars/things_board/ui-i18n.mjs');
@@ -6,6 +6,7 @@ const os = require('node:os');
6
6
  const crypto = require('node:crypto');
7
7
  const { readConfiguredLang, getUi } = require('./i18n.cjs');
8
8
  const { createPresentation } = require('./ui-foundation.cjs');
9
+ const PACKAGE_VERSION = require('../package.json').version;
9
10
 
10
11
  const presentationHelper = createPresentation('zh');
11
12
 
@@ -87,7 +88,7 @@ function renderAntigravityCardHtml({
87
88
  lang = readConfiguredLang(),
88
89
  } = {}) {
89
90
  const ui = getUi(lang);
90
- const { t, labels: uiLabels, taskLabels: uiTaskLabels, strings: uiStrings } = ui;
91
+ const { t, labels: uiLabels, taskLabels: uiTaskLabels, strings: uiStrings, updateBannerState } = ui;
91
92
  const clientI18n = { ...uiStrings };
92
93
  delete clientI18n.defaultDocTitle;
93
94
  const resolvedTitle = title || t('defaultSessionTitle');
@@ -115,6 +116,7 @@ function renderAntigravityCardHtml({
115
116
  title: resolvedTitle,
116
117
  lang: ui.lang,
117
118
  loadToken: connection?.loadToken || null,
119
+ packageVersion: PACKAGE_VERSION,
118
120
  });
119
121
 
120
122
  const lightAccentPalette = presentationHelper.resolveAccentPalette(readAntigravityConfiguredAccent({ isDark: false }), { isDark: false, fallback: '#2F75C3' });
@@ -744,6 +746,72 @@ function renderAntigravityCardHtml({
744
746
  margin-top: 8px;
745
747
  }
746
748
 
749
+ .app-update {
750
+ margin-top: 3px;
751
+ padding: 10px 11px;
752
+ background: var(--hover);
753
+ border: 1px solid var(--line);
754
+ border-radius: 10px;
755
+ }
756
+ .app-update-row {
757
+ display: flex;
758
+ align-items: center;
759
+ justify-content: space-between;
760
+ gap: 10px;
761
+ }
762
+ .app-update-label {
763
+ font-size: 12px;
764
+ line-height: 18px;
765
+ color: var(--ink);
766
+ min-width: 0;
767
+ overflow-wrap: anywhere;
768
+ }
769
+ .app-update-button {
770
+ flex: none;
771
+ padding: 5px 10px;
772
+ min-height: 28px;
773
+ border-radius: 7px;
774
+ font-size: 11px;
775
+ }
776
+ .app-update-detail {
777
+ margin-top: 7px;
778
+ font-size: 11px;
779
+ line-height: 1.6;
780
+ color: var(--secondary);
781
+ white-space: pre-wrap;
782
+ overflow-wrap: anywhere;
783
+ user-select: text;
784
+ }
785
+ .app-update[data-failed=true] .app-update-detail {
786
+ color: var(--error);
787
+ }
788
+
789
+ .version-bar {
790
+ display: flex;
791
+ align-items: center;
792
+ justify-content: space-between;
793
+ gap: 10px;
794
+ padding: 10px 0 2px;
795
+ font-size: 11px;
796
+ line-height: 16px;
797
+ color: var(--muted);
798
+ }
799
+ .version-bar-text {
800
+ min-width: 0;
801
+ overflow-wrap: anywhere;
802
+ }
803
+ .version-bar[data-failed=true] .version-bar-text {
804
+ color: var(--error);
805
+ }
806
+ .version-check-button {
807
+ flex: none;
808
+ font-size: 11px;
809
+ color: var(--muted);
810
+ }
811
+ .version-check-button:hover:not(:disabled) {
812
+ color: inherit;
813
+ }
814
+
747
815
  /* Views */
748
816
  .view-heading {
749
817
  position: sticky;
@@ -1207,6 +1275,17 @@ function renderAntigravityCardHtml({
1207
1275
  <span>${escapeHtml(t('notesLabel'))}</span>
1208
1276
  <span class="row-detail" id="noteOpenLabel">${escapeHtml(note ? t('editLabel') : t('addLabel'))}</span>
1209
1277
  </button>
1278
+ <div class="app-update" id="appUpdateBox" hidden>
1279
+ <div class="app-update-row">
1280
+ <span class="app-update-label" id="appUpdateLabel" role="status"></span>
1281
+ <button type="button" class="primary app-update-button" id="btnAppUpdate" onclick="onUpgradeClick()">${escapeHtml(t('upgradeBtn'))}</button>
1282
+ </div>
1283
+ <div class="app-update-detail" id="appUpdateDetail" hidden></div>
1284
+ </div>
1285
+ </div>
1286
+ <div class="version-bar" id="versionBar">
1287
+ <span class="version-bar-text" id="versionBarText" role="status">${escapeHtml(t('versionTagPattern', { version: PACKAGE_VERSION }))}</span>
1288
+ <button type="button" class="text-button version-check-button" id="btnCheckUpdate" onclick="onCheckUpdateClick()">${escapeHtml(t('checkUpdateBtn'))}</button>
1210
1289
  </div>
1211
1290
  </div>
1212
1291
 
@@ -1317,12 +1396,23 @@ function renderAntigravityCardHtml({
1317
1396
  }
1318
1397
  const conversationId = ${JSON.stringify(conversationId)};
1319
1398
  const connection = ${configJson};
1399
+ const computeUpdateBannerState = ${updateBannerState.toString()};
1320
1400
  let currentRevision = ${Number(revision) || 0};
1321
1401
  let savedRevision = ${Number(revision) || 0};
1322
1402
  let draftBaseRevision = savedRevision;
1323
1403
  let isFormDirty = false;
1324
1404
  let pendingRemoteSnapshot = null;
1325
1405
  let saveSwitchTimer = null;
1406
+ let currentUpdateInfo = null;
1407
+ let updateTimer = null;
1408
+ let manualCheckTimer = null;
1409
+ let updateChecking = false;
1410
+ let upgradeStarting = false;
1411
+ let updateConnectionError = '';
1412
+ let manualCheckStatus = '';
1413
+ let manualCheckError = '';
1414
+ let updatePollingStarted = false;
1415
+ let isSessionAnalyzing = false;
1326
1416
  let currentState = ${JSON.stringify(state)};
1327
1417
  let currentProgress = ${progress != null ? Number(progress) : 'null'};
1328
1418
  let isDraggingSlider = false;
@@ -1959,6 +2049,7 @@ function renderAntigravityCardHtml({
1959
2049
  }
1960
2050
 
1961
2051
  const analyzing = Boolean(s.analyzing || s.analysisStatus?.status === 'pending');
2052
+ isSessionAnalyzing = analyzing;
1962
2053
  const analysisStatus = s.analysisStatus;
1963
2054
  const btnAnalyze = document.getElementById('btnAnalyze');
1964
2055
  if (btnAnalyze) {
@@ -1966,7 +2057,7 @@ function renderAntigravityCardHtml({
1966
2057
  btnAnalyze.disabled = true;
1967
2058
  btnAnalyze.textContent = i18n.btnUpdating;
1968
2059
  } else {
1969
- btnAnalyze.disabled = false;
2060
+ btnAnalyze.disabled = ['waiting', 'installing'].includes(currentUpdateInfo?.update?.stage);
1970
2061
  btnAnalyze.textContent = i18n.btnUpdate;
1971
2062
  if (analysisStatus?.status === 'failed') {
1972
2063
  showFeedback(i18n.analysisNotDonePrefix + (analysisStatus.error || i18n.analysisAbnormal), true);
@@ -2180,6 +2271,146 @@ function renderAntigravityCardHtml({
2180
2271
  }
2181
2272
  }
2182
2273
 
2274
+ function renderUpdateUi(info) {
2275
+ if (info !== undefined) currentUpdateInfo = info;
2276
+ const effectiveInfo = currentUpdateInfo || {
2277
+ currentVersion: connection?.packageVersion || '',
2278
+ available: false,
2279
+ command: 'npx agent-things@latest',
2280
+ update: null,
2281
+ };
2282
+ const banner = computeUpdateBannerState(effectiveInfo, i18n, {
2283
+ starting: upgradeStarting,
2284
+ checking: updateChecking,
2285
+ connectionError: updateConnectionError,
2286
+ manualCheckStatus: manualCheckStatus,
2287
+ checkError: manualCheckError,
2288
+ });
2289
+ const box = document.getElementById('appUpdateBox');
2290
+ const labelEl = document.getElementById('appUpdateLabel');
2291
+ const upgradeEl = document.getElementById('btnAppUpdate');
2292
+ const detailEl = document.getElementById('appUpdateDetail');
2293
+ const versionBarEl = document.getElementById('versionBar');
2294
+ const versionTextEl = document.getElementById('versionBarText');
2295
+ const checkBtnEl = document.getElementById('btnCheckUpdate');
2296
+ if (box) {
2297
+ box.hidden = !banner.visible;
2298
+ box.setAttribute('data-failed', String(banner.failed));
2299
+ }
2300
+ if (labelEl) labelEl.textContent = banner.label;
2301
+ if (upgradeEl) {
2302
+ upgradeEl.textContent = banner.buttonText;
2303
+ upgradeEl.disabled = banner.buttonDisabled;
2304
+ }
2305
+ if (detailEl) {
2306
+ detailEl.textContent = banner.detail;
2307
+ detailEl.hidden = !banner.detail;
2308
+ }
2309
+ if (versionBarEl) {
2310
+ versionBarEl.hidden = !(banner.showVersionBar && (effectiveInfo.currentVersion || banner.checking || banner.checkFailed));
2311
+ versionBarEl.setAttribute('data-failed', String(banner.checkFailed));
2312
+ }
2313
+ if (versionTextEl) versionTextEl.textContent = banner.versionText;
2314
+ if (checkBtnEl) {
2315
+ checkBtnEl.textContent = banner.checkButtonText;
2316
+ checkBtnEl.disabled = banner.checkDisabled;
2317
+ }
2318
+ const btnAnalyze = document.getElementById('btnAnalyze');
2319
+ if (btnAnalyze) {
2320
+ btnAnalyze.disabled = isSessionAnalyzing || ['waiting', 'installing'].includes(currentUpdateInfo?.update?.stage);
2321
+ }
2322
+ return banner.active;
2323
+ }
2324
+
2325
+ async function pollAppUpdate() {
2326
+ if (updateTimer) {
2327
+ clearTimeout(updateTimer);
2328
+ updateTimer = null;
2329
+ }
2330
+ try {
2331
+ const reply = await sendProxyAction('app-update-info', {});
2332
+ const info = reply?.updateInfo ?? null;
2333
+ updateConnectionError = '';
2334
+ if (info?.available) {
2335
+ manualCheckStatus = '';
2336
+ manualCheckError = '';
2337
+ }
2338
+ const active = renderUpdateUi(info);
2339
+ updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
2340
+ } catch (err) {
2341
+ updateConnectionError = err?.message || i18n.cardOpFailed;
2342
+ if (currentUpdateInfo) renderUpdateUi(currentUpdateInfo);
2343
+ updateTimer = setTimeout(pollAppUpdate, 5000);
2344
+ }
2345
+ }
2346
+
2347
+ async function onCheckUpdateClick() {
2348
+ if (updateChecking) return;
2349
+ if (updateTimer) {
2350
+ clearTimeout(updateTimer);
2351
+ updateTimer = null;
2352
+ }
2353
+ if (manualCheckTimer) {
2354
+ clearTimeout(manualCheckTimer);
2355
+ manualCheckTimer = null;
2356
+ }
2357
+ updateChecking = true;
2358
+ manualCheckStatus = '';
2359
+ manualCheckError = '';
2360
+ renderUpdateUi();
2361
+ try {
2362
+ const reply = await sendProxyAction('app-update-info', { force: true });
2363
+ const info = reply?.updateInfo ?? null;
2364
+ updateChecking = false;
2365
+ updateConnectionError = '';
2366
+ if (info?.checkError && !info?.available) {
2367
+ manualCheckStatus = 'failed';
2368
+ manualCheckError = info.checkError;
2369
+ } else if (!info?.available) {
2370
+ manualCheckStatus = 'latest';
2371
+ manualCheckTimer = setTimeout(function() {
2372
+ manualCheckTimer = null;
2373
+ if (manualCheckStatus === 'latest') {
2374
+ manualCheckStatus = '';
2375
+ renderUpdateUi();
2376
+ }
2377
+ }, 5000);
2378
+ }
2379
+ const active = renderUpdateUi(info);
2380
+ updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
2381
+ } catch (err) {
2382
+ updateChecking = false;
2383
+ manualCheckStatus = 'failed';
2384
+ manualCheckError = err?.message || i18n.cardOpFailed;
2385
+ renderUpdateUi();
2386
+ updateTimer = setTimeout(pollAppUpdate, 60000);
2387
+ }
2388
+ }
2389
+
2390
+ async function onUpgradeClick() {
2391
+ const upgradeEl = document.getElementById('btnAppUpdate');
2392
+ if (upgradeEl?.disabled || upgradeStarting) return;
2393
+ if (updateTimer) {
2394
+ clearTimeout(updateTimer);
2395
+ updateTimer = null;
2396
+ }
2397
+ upgradeStarting = true;
2398
+ manualCheckStatus = '';
2399
+ manualCheckError = '';
2400
+ renderUpdateUi();
2401
+ try {
2402
+ const reply = await sendProxyAction('app-update-start', {});
2403
+ upgradeStarting = false;
2404
+ updateConnectionError = '';
2405
+ renderUpdateUi(reply?.updateInfo ?? null);
2406
+ } catch (err) {
2407
+ upgradeStarting = false;
2408
+ updateConnectionError = err?.message || i18n.cardOpFailed;
2409
+ renderUpdateUi();
2410
+ }
2411
+ updateTimer = setTimeout(pollAppUpdate, 1000);
2412
+ }
2413
+
2183
2414
  async function initEventStream() {
2184
2415
  if (sseReconnectTimer) {
2185
2416
  clearTimeout(sseReconnectTimer);
@@ -2198,6 +2429,10 @@ function renderAntigravityCardHtml({
2198
2429
  }
2199
2430
  authTicket = auth.ticket;
2200
2431
  serviceOrigin = auth.origin;
2432
+ if (!updatePollingStarted && hostChannelPort) {
2433
+ updatePollingStarted = true;
2434
+ void pollAppUpdate();
2435
+ }
2201
2436
 
2202
2437
  const sseUrl = auth.origin + '/session/events?id=' + encodeURIComponent(conversationId) + '&ticket=' + encodeURIComponent(auth.ticket);
2203
2438
  const es = new EventSource(sseUrl);
@@ -1039,12 +1039,13 @@
1039
1039
  return;
1040
1040
  }
1041
1041
 
1042
- // 宿主桥代发写操作(保存、清除、分析)
1042
+ // 宿主桥代发写操作(保存、清除、分析、版本更新)
1043
1043
  if (data.type === 'AGENT_THINGS_ACTION_PROXY') {
1044
1044
  const { nonce, action, payload } = data;
1045
1045
  if (!nonce) return;
1046
1046
  try {
1047
1047
  const key = JSON.stringify(['local', boundConvId]);
1048
+ const isUpdateAction = action === 'app-update-info' || action === 'app-update-start';
1048
1049
  let rpcMsg = null;
1049
1050
  if (action === 'update') {
1050
1051
  rpcMsg = { type: 'update', key, record: payload.record, expectedRevision: payload.expectedRevision, requestId: 'proxy-update-' + Date.now() };
@@ -1052,6 +1053,15 @@
1052
1053
  rpcMsg = { type: 'clear', key, expectedRevision: payload.expectedRevision, requestId: 'proxy-clear-' + Date.now() };
1053
1054
  } else if (action === 'analyze') {
1054
1055
  rpcMsg = { type: 'analyze', key, requestId: 'proxy-analyze-' + Date.now() };
1056
+ } else if (action === 'app-update-info') {
1057
+ rpcMsg = {
1058
+ type: 'app-update-info',
1059
+ key,
1060
+ ...(typeof payload?.force === 'boolean' ? { force: payload.force } : {}),
1061
+ requestId: 'proxy-update-info-' + Date.now(),
1062
+ };
1063
+ } else if (action === 'app-update-start') {
1064
+ rpcMsg = { type: 'app-update-start', key, requestId: 'proxy-update-start-' + Date.now() };
1055
1065
  }
1056
1066
  if (rpcMsg) {
1057
1067
  const res = await fetch(`${getServiceOrigin()}/rpc`, {
@@ -1060,6 +1070,18 @@
1060
1070
  body: JSON.stringify(rpcMsg),
1061
1071
  });
1062
1072
  const reply = await res.json();
1073
+ if (isUpdateAction) {
1074
+ sendReplyToCard(binding, targetPort, {
1075
+ type: 'AGENT_THINGS_ACTION_RESULT',
1076
+ nonce,
1077
+ action,
1078
+ success: !reply.error,
1079
+ error: reply.error || null,
1080
+ updateInfo: reply.updateInfo || null,
1081
+ data: { updateInfo: reply.updateInfo || null, lang: reply.lang },
1082
+ });
1083
+ return;
1084
+ }
1063
1085
  if (reply.snapshot) {
1064
1086
  window.__codexSessionStatus?.receive?.(reply.snapshot);
1065
1087
  }