agent-things 1.2.2 → 1.3.1

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.
@@ -5,6 +5,24 @@ const path = require('node:path');
5
5
  const os = require('node:os');
6
6
  const crypto = require('node:crypto');
7
7
  const { readConfiguredLang, getUi } = require('./i18n.cjs');
8
+ const { createPresentation } = require('./ui-foundation.cjs');
9
+
10
+ const presentationHelper = createPresentation('zh');
11
+
12
+ function readAntigravityConfiguredAccent({ isDark = false } = {}) {
13
+ const defaultPrimary = isDark ? '#2F71E3' : '#2F75C3';
14
+ try {
15
+ const configPath = path.join(os.homedir(), '.gemini', 'config', 'config.json');
16
+ if (fs.existsSync(configPath)) {
17
+ const cfg = JSON.parse(fs.readFileSync(configPath, 'utf8'));
18
+ const settings = cfg?.userSettings || {};
19
+ const seeds = isDark ? settings.customThemeSeedsDark : settings.customThemeSeedsLight;
20
+ const customPrimary = seeds?.primary;
21
+ if (customPrimary) return customPrimary;
22
+ }
23
+ } catch (_) {}
24
+ return defaultPrimary;
25
+ }
8
26
 
9
27
  const colors = {
10
28
  unstarted: '#9098a2',
@@ -99,6 +117,9 @@ function renderAntigravityCardHtml({
99
117
  loadToken: connection?.loadToken || null,
100
118
  });
101
119
 
120
+ const lightAccentPalette = presentationHelper.resolveAccentPalette(readAntigravityConfiguredAccent({ isDark: false }), { isDark: false, fallback: '#2F75C3' });
121
+ const darkAccentPalette = presentationHelper.resolveAccentPalette(readAntigravityConfiguredAccent({ isDark: true }), { isDark: true, fallback: '#2F71E3' });
122
+
102
123
  return `<!DOCTYPE html>
103
124
  <html lang="${htmlLang}">
104
125
  <head>
@@ -107,8 +128,12 @@ function renderAntigravityCardHtml({
107
128
  <title>${escapeHtml(resolvedTitle)} · ${escapeHtml(t('docTitleSuffix'))}</title>
108
129
  <style>
109
130
  :root {
110
- --accent: #0169cc;
111
- --accent-hover: #005bb3;
131
+ --accent: ${darkAccentPalette.normal};
132
+ --accent-hover: ${darkAccentPalette.hover};
133
+ --accent-pressed: ${darkAccentPalette.pressed};
134
+ --on-accent: ${darkAccentPalette.onAccent};
135
+ --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
136
+ --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
112
137
  --ink: #e6edf3;
113
138
  --secondary: #a0a6ad;
114
139
  --muted: #828c96;
@@ -121,8 +146,7 @@ function renderAntigravityCardHtml({
121
146
  --selected: #ffffff10;
122
147
  --source-bg: #ffffff0a;
123
148
  --number-line: #ffffff25;
124
- --thumb: #e6edf3;
125
- --thumb-edge: #ffffff30;
149
+ --thumb: #ffffff;
126
150
  --danger: #ef7777;
127
151
  --error: #f7ad86;
128
152
  --panel-bg: #0e1318;
@@ -220,7 +244,7 @@ function renderAntigravityCardHtml({
220
244
  border-radius: 6px;
221
245
  background: none;
222
246
  color: var(--secondary);
223
- transition: color 0.12s, background 0.12s, opacity 0.18s ease, transform 0.22s ease;
247
+ transition: color 150ms var(--ease-out), background-color 150ms var(--ease-out), opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
224
248
  z-index: 5;
225
249
  }
226
250
  .open-pane:hover,
@@ -228,6 +252,9 @@ function renderAntigravityCardHtml({
228
252
  color: var(--ink);
229
253
  background: var(--hover);
230
254
  }
255
+ .open-pane:active:not(:disabled) {
256
+ transform: scale(0.94);
257
+ }
231
258
  .open-pane:focus-visible {
232
259
  outline: 2px solid var(--accent);
233
260
  outline-offset: 1px;
@@ -240,7 +267,8 @@ function renderAntigravityCardHtml({
240
267
  position: absolute;
241
268
  right: calc(100% + 6px);
242
269
  top: 50%;
243
- transform: translateY(-50%);
270
+ transform-origin: center right;
271
+ transform: translateY(-50%) scale(0.96);
244
272
  padding: 4px 8px;
245
273
  border-radius: 6px;
246
274
  background: var(--panel-bg);
@@ -253,13 +281,14 @@ function renderAntigravityCardHtml({
253
281
  pointer-events: none;
254
282
  opacity: 0;
255
283
  visibility: hidden;
256
- transition: opacity 0.08s, visibility 0s;
284
+ transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), visibility 0s linear 150ms;
257
285
  z-index: 20;
258
286
  }
259
287
  .open-pane:is(:hover, :focus-visible) .open-pane-tip {
260
288
  opacity: 1;
289
+ transform: translateY(-50%) scale(1);
261
290
  visibility: visible;
262
- transition-delay: 0.15s;
291
+ transition: opacity 150ms var(--ease-out) 160ms, transform 150ms var(--ease-out) 160ms, visibility 0s linear 160ms;
263
292
  }
264
293
  .shell.is-scrolled .open-pane {
265
294
  opacity: 0;
@@ -294,21 +323,29 @@ function renderAntigravityCardHtml({
294
323
  height: 32px;
295
324
  display: block;
296
325
  }
326
+ .title-progress .progress-pie,
297
327
  .title-progress text {
298
- opacity: 0;
299
- transition: opacity 0.15s ease;
328
+ transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
329
+ transform-origin: 12px 12px;
300
330
  pointer-events: none;
301
331
  }
332
+ .title-progress text {
333
+ opacity: 0;
334
+ transform: scale(0.94);
335
+ }
302
336
  .title-progress text.progress-unknown {
303
337
  opacity: 1;
338
+ transform: none;
304
339
  }
305
340
  .title-heading:hover .progress-pie,
306
341
  .title-heading:focus-visible .progress-pie {
307
342
  opacity: 0;
343
+ transform: scale(0.94);
308
344
  }
309
345
  .title-heading:hover text,
310
346
  .title-heading:focus-visible text {
311
347
  opacity: 1;
348
+ transform: scale(1);
312
349
  }
313
350
 
314
351
  .panel-body {
@@ -399,7 +436,7 @@ function renderAntigravityCardHtml({
399
436
  .meter {
400
437
  height: 4px;
401
438
  background: var(--track);
402
- border-radius: 3px;
439
+ border-radius: 999px;
403
440
  margin: 10px 0 8px;
404
441
  overflow: hidden;
405
442
  }
@@ -410,6 +447,7 @@ function renderAntigravityCardHtml({
410
447
  width: ${progress != null ? Math.max(0, Math.min(100, progress)) : 0}%;
411
448
  background: ${stateColor};
412
449
  border-radius: inherit;
450
+ transition: width 220ms var(--ease-out), background-color 180ms var(--ease-out);
413
451
  }
414
452
 
415
453
  .totals-row {
@@ -483,7 +521,7 @@ function renderAntigravityCardHtml({
483
521
  .primary {
484
522
  border: 0;
485
523
  background: var(--accent);
486
- color: #fff;
524
+ color: var(--on-accent, #fff);
487
525
  border-radius: 9px;
488
526
  padding: 9px 14px;
489
527
  font-weight: 550;
@@ -491,11 +529,16 @@ function renderAntigravityCardHtml({
491
529
  font-size: 13px;
492
530
  white-space: nowrap;
493
531
  flex-shrink: 0;
494
- transition: background 0.15s ease;
532
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.14);
533
+ transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms var(--ease-out);
495
534
  }
496
- .primary:hover {
535
+ .primary:hover:not(:disabled) {
497
536
  background: var(--accent-hover);
498
- color: #fff;
537
+ color: var(--on-accent, #fff);
538
+ }
539
+ .primary:active:not(:disabled) {
540
+ background: var(--accent-pressed, var(--accent-hover));
541
+ transform: scale(0.97);
499
542
  }
500
543
  .text-button, .clear, .back {
501
544
  border: 0;
@@ -505,11 +548,14 @@ function renderAntigravityCardHtml({
505
548
  font-size: 12px;
506
549
  white-space: nowrap;
507
550
  cursor: pointer;
508
- transition: color 0.12s ease;
551
+ transition: transform 160ms var(--ease-out), color 150ms var(--ease-out);
509
552
  }
510
553
  .text-button:hover, .back:hover {
511
554
  color: inherit;
512
555
  }
556
+ .text-button:active:not(:disabled), .clear:active:not(:disabled), .back:active:not(:disabled) {
557
+ transform: scale(0.97);
558
+ }
513
559
  .actions .clear {
514
560
  margin-left: auto;
515
561
  font-size: 11px;
@@ -531,17 +577,20 @@ function renderAntigravityCardHtml({
531
577
  border: 1px solid var(--line);
532
578
  font-size: 11px;
533
579
  pointer-events: none;
580
+ transform-origin: bottom right;
534
581
  opacity: 0;
582
+ transform: scale(0.96) translateY(3px);
535
583
  visibility: hidden;
536
- transition: opacity 0.08s, visibility 0s;
584
+ transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), visibility 0s linear 150ms;
537
585
  white-space: nowrap;
538
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
586
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
539
587
  z-index: 10;
540
588
  }
541
589
  .clear:is(:hover, :focus-visible) .clear-tooltip {
542
590
  opacity: 1;
591
+ transform: scale(1) translateY(0);
543
592
  visibility: visible;
544
- transition-delay: 0.1s;
593
+ transition: opacity 150ms var(--ease-out) 160ms, transform 150ms var(--ease-out) 160ms, visibility 0s linear 160ms;
545
594
  }
546
595
 
547
596
  .section-head {
@@ -675,10 +724,17 @@ function renderAntigravityCardHtml({
675
724
  text-align: left;
676
725
  font-size: 12px;
677
726
  cursor: pointer;
678
- transition: color 0.15s ease;
727
+ transition: transform 160ms var(--ease-out), color 150ms var(--ease-out);
728
+ }
729
+ .quiet-row:active:not(:disabled) {
730
+ transform: scale(0.988);
679
731
  }
680
732
  .quiet-row span:last-child {
681
733
  color: var(--secondary);
734
+ transition: transform 160ms var(--ease-out), color 150ms var(--ease-out);
735
+ }
736
+ .quiet-row:hover span:last-child {
737
+ transform: translateX(2px);
682
738
  }
683
739
  .quiet-row:hover {
684
740
  color: var(--ink);
@@ -756,11 +812,14 @@ function renderAntigravityCardHtml({
756
812
  text-align: left;
757
813
  font-size: 13px;
758
814
  cursor: pointer;
759
- transition: background 0.12s ease;
815
+ transition: transform 160ms var(--ease-out), background-color 150ms var(--ease-out);
760
816
  }
761
817
  .choice:hover {
762
818
  background: var(--hover);
763
819
  }
820
+ .choice:active:not(:disabled) {
821
+ transform: scale(0.988);
822
+ }
764
823
  .choice[aria-pressed="true"] {
765
824
  background: var(--selected);
766
825
  }
@@ -770,6 +829,7 @@ function renderAntigravityCardHtml({
770
829
  border: 1.6px solid var(--mark);
771
830
  border-radius: 50%;
772
831
  flex: none;
832
+ transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
773
833
  }
774
834
  .choice[aria-pressed="true"] .dot {
775
835
  background: var(--mark);
@@ -813,7 +873,7 @@ function renderAntigravityCardHtml({
813
873
  }
814
874
  .range {
815
875
  position: relative;
816
- height: 51px;
876
+ height: 48px;
817
877
  margin-top: 2px;
818
878
  --mark: ${stateColor};
819
879
  }
@@ -821,11 +881,15 @@ function renderAntigravityCardHtml({
821
881
  position: absolute;
822
882
  left: 7px;
823
883
  right: 7px;
824
- top: 10px;
825
- height: 4px;
826
- border-radius: 3px;
827
- background: linear-gradient(to right, var(--mark) var(--fill), var(--track) var(--fill));
884
+ top: 9px;
885
+ height: 6px;
886
+ border-radius: 999px;
887
+ background: linear-gradient(to right, var(--range-fill, var(--mark)) var(--fill), var(--track) var(--fill));
828
888
  pointer-events: none;
889
+ transition: background-color 160ms var(--ease-out);
890
+ }
891
+ .range.is-dragging .range-track {
892
+ transition: none;
829
893
  }
830
894
  .range-input {
831
895
  position: relative;
@@ -839,18 +903,26 @@ function renderAntigravityCardHtml({
839
903
  cursor: pointer;
840
904
  }
841
905
  .range-input::-webkit-slider-runnable-track {
842
- height: 4px;
906
+ height: 6px;
843
907
  background: transparent;
844
908
  }
845
909
  .range-input::-webkit-slider-thumb {
846
910
  appearance: none;
847
- width: 14px;
848
- height: 14px;
911
+ width: 16px;
912
+ height: 16px;
849
913
  margin-top: -5px;
850
914
  background: var(--thumb);
851
- border: 2px solid var(--panel-bg);
915
+ border: 0.5px solid rgba(0, 0, 0, 0.14);
852
916
  border-radius: 50%;
853
- box-shadow: 0 0 0 1px var(--thumb-edge);
917
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
918
+ transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
919
+ }
920
+ .range-input:hover::-webkit-slider-thumb {
921
+ transform: scale(1.06);
922
+ }
923
+ .range-input:active::-webkit-slider-thumb {
924
+ transform: scale(1.1);
925
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(0, 0, 0, 0.12);
854
926
  }
855
927
  .range-nodes {
856
928
  position: absolute;
@@ -865,23 +937,17 @@ function renderAntigravityCardHtml({
865
937
  top: 8px;
866
938
  width: 0;
867
939
  font-size: 10px;
940
+ font-weight: 500;
941
+ opacity: 0.78;
868
942
  color: var(--secondary);
869
943
  font-variant-numeric: tabular-nums;
870
944
  }
871
945
  .range-node::before {
872
- content: "";
873
- display: block;
874
- width: 7px;
875
- height: 7px;
876
- transform: translateX(-50%);
877
- border-radius: 50%;
878
- background: var(--panel-bg);
879
- border: 1px solid var(--secondary);
880
- box-shadow: 0 0 0 1px var(--panel-bg);
946
+ display: none;
881
947
  }
882
948
  .range-node-label {
883
949
  position: absolute;
884
- top: 19px;
950
+ top: 20px;
885
951
  left: 0;
886
952
  transform: translateX(-50%);
887
953
  }
@@ -953,13 +1019,57 @@ function renderAntigravityCardHtml({
953
1019
  color: #548eea;
954
1020
  }
955
1021
 
1022
+ :root[data-color-mode="light"],
1023
+ :root.light {
1024
+ --accent: ${lightAccentPalette.normal};
1025
+ --accent-hover: ${lightAccentPalette.hover};
1026
+ --accent-pressed: ${lightAccentPalette.pressed};
1027
+ --on-accent: ${lightAccentPalette.onAccent};
1028
+ --ink: #22272e;
1029
+ --secondary: #576374;
1030
+ --muted: #667383;
1031
+ --note: #46515f;
1032
+ --track: #dfe4ea;
1033
+ --line: #dfe4ea;
1034
+ --input-border: #c7d0da;
1035
+ --input-bg: #f7f9fb;
1036
+ --hover: #f0f3f6;
1037
+ --selected: #e9edf2;
1038
+ --source-bg: #e9eef4;
1039
+ --number-line: #b6c1ce;
1040
+ --thumb: #ffffff;
1041
+ --danger: #bf2f3a;
1042
+ --error: #b13a2d;
1043
+ --panel-bg: #fff;
1044
+ color: var(--ink);
1045
+ color-scheme: light;
1046
+ }
1047
+ html[data-color-mode="light"] .shell,
1048
+ html.light .shell {
1049
+ --panel-bg: #fff;
1050
+ border-color: #dfe4ea;
1051
+ box-shadow: none;
1052
+ }
1053
+ html[data-color-mode="light"] .shell:hover,
1054
+ html.light .shell:hover {
1055
+ --panel-bg: #f5f6f7;
1056
+ }
1057
+ html[data-color-mode="light"] .range,
1058
+ html.light .range {
1059
+ --range-fill: color-mix(in srgb, var(--mark) 85%, #000);
1060
+ }
1061
+
956
1062
  @media (prefers-color-scheme: light) {
957
- :root {
1063
+ :root:not([data-color-mode="dark"]):not(.dark) {
1064
+ --accent: ${lightAccentPalette.normal};
1065
+ --accent-hover: ${lightAccentPalette.hover};
1066
+ --accent-pressed: ${lightAccentPalette.pressed};
1067
+ --on-accent: ${lightAccentPalette.onAccent};
958
1068
  --ink: #22272e;
959
1069
  --secondary: #576374;
960
1070
  --muted: #667383;
961
1071
  --note: #46515f;
962
- --track: #c3ccd6;
1072
+ --track: #dfe4ea;
963
1073
  --line: #dfe4ea;
964
1074
  --input-border: #c7d0da;
965
1075
  --input-bg: #f7f9fb;
@@ -967,22 +1077,37 @@ function renderAntigravityCardHtml({
967
1077
  --selected: #e9edf2;
968
1078
  --source-bg: #e9eef4;
969
1079
  --number-line: #b6c1ce;
970
- --thumb: var(--accent);
971
- --thumb-edge: var(--accent);
1080
+ --thumb: #ffffff;
972
1081
  --danger: #bf2f3a;
973
1082
  --error: #b13a2d;
974
1083
  --panel-bg: #fff;
975
1084
  color: var(--ink);
976
1085
  color-scheme: light;
977
1086
  }
978
- .shell {
1087
+ html:not([data-color-mode="dark"]):not(.dark) .shell {
979
1088
  --panel-bg: #fff;
980
1089
  border-color: #dfe4ea;
981
1090
  box-shadow: none;
982
1091
  }
983
- .shell:hover {
1092
+ html:not([data-color-mode="dark"]):not(.dark) .shell:hover {
984
1093
  --panel-bg: #f5f6f7;
985
1094
  }
1095
+ html:not([data-color-mode="dark"]):not(.dark) .range {
1096
+ --range-fill: color-mix(in srgb, var(--mark) 85%, #000);
1097
+ }
1098
+ }
1099
+ @media (prefers-reduced-motion: reduce) {
1100
+ .primary:active:not(:disabled),
1101
+ .text-button:active:not(:disabled),
1102
+ .clear:active:not(:disabled),
1103
+ .back:active:not(:disabled),
1104
+ .choice:active:not(:disabled),
1105
+ .quiet-row:active:not(:disabled),
1106
+ .open-pane:active:not(:disabled),
1107
+ .range-input:hover::-webkit-slider-thumb,
1108
+ .range-input:active::-webkit-slider-thumb {
1109
+ transform: none;
1110
+ }
986
1111
  }
987
1112
  </style>
988
1113
  </head>
@@ -1023,15 +1148,13 @@ function renderAntigravityCardHtml({
1023
1148
 
1024
1149
  <div class="totals-row">
1025
1150
  <span class="totals" id="overviewTotals">${escapeHtml(totalsText)}</span>
1026
- <span class="source-label">${escapeHtml(sourceLabel)}</span>
1151
+ <span class="source-label" id="overviewSourceLabel">${escapeHtml(sourceLabel)}</span>
1027
1152
  </div>
1028
1153
 
1029
- ${summaryText ? `
1030
- <div class="summary-block" id="summaryBlock" tabindex="0">
1154
+ <div class="summary-block" id="summaryBlock" tabindex="0"${summaryText ? '' : ' hidden'}>
1031
1155
  <div class="overview-summary" id="overviewSummary">${escapeHtml(summaryText)}</div>
1032
1156
  <button class="summary-expand" id="summaryExpand" onclick="toggleSummaryExpand()" hidden>${escapeHtml(t('expandAll'))}</button>
1033
1157
  </div>
1034
- ` : ''}
1035
1158
 
1036
1159
  <div class="actions">
1037
1160
  <button class="primary" id="btnAnalyze" onclick="onAnalyzeClick()">${escapeHtml(t('btnUpdate'))}</button>
@@ -1198,10 +1321,14 @@ function renderAntigravityCardHtml({
1198
1321
  let savedRevision = ${Number(revision) || 0};
1199
1322
  let draftBaseRevision = savedRevision;
1200
1323
  let isFormDirty = false;
1324
+ let pendingRemoteSnapshot = null;
1325
+ let saveSwitchTimer = null;
1201
1326
  let currentState = ${JSON.stringify(state)};
1202
1327
  let currentProgress = ${progress != null ? Number(progress) : 'null'};
1203
1328
  let isDraggingSlider = false;
1204
1329
  let hostChannelPort = null;
1330
+ let hostHandshakePending = false;
1331
+ let hostHandshakePromise = null;
1205
1332
 
1206
1333
  function resetScroll() {
1207
1334
  const panel = document.getElementById('panelBody');
@@ -1232,6 +1359,10 @@ function renderAntigravityCardHtml({
1232
1359
  }
1233
1360
 
1234
1361
  function switchToEdit() {
1362
+ if (saveSwitchTimer) {
1363
+ clearTimeout(saveSwitchTimer);
1364
+ saveSwitchTimer = null;
1365
+ }
1235
1366
  resetScroll();
1236
1367
  draftBaseRevision = savedRevision;
1237
1368
  isFormDirty = false;
@@ -1259,6 +1390,10 @@ function renderAntigravityCardHtml({
1259
1390
  }
1260
1391
 
1261
1392
  function switchToOverview() {
1393
+ if (saveSwitchTimer) {
1394
+ clearTimeout(saveSwitchTimer);
1395
+ saveSwitchTimer = null;
1396
+ }
1262
1397
  resetScroll();
1263
1398
  document.getElementById('editView').hidden = true;
1264
1399
  document.getElementById('historyView').hidden = true;
@@ -1266,7 +1401,13 @@ function renderAntigravityCardHtml({
1266
1401
  isFormDirty = false;
1267
1402
  hideConflictNotice();
1268
1403
  clearFeedback();
1269
- checkSummaryOverflow();
1404
+ if (pendingRemoteSnapshot) {
1405
+ const pending = pendingRemoteSnapshot;
1406
+ pendingRemoteSnapshot = null;
1407
+ applyFullProgressToUI(pending);
1408
+ } else {
1409
+ checkSummaryOverflow();
1410
+ }
1270
1411
  }
1271
1412
 
1272
1413
  function markFormDirty() {
@@ -1313,10 +1454,14 @@ function renderAntigravityCardHtml({
1313
1454
 
1314
1455
  function onSliderPointerDown() {
1315
1456
  isDraggingSlider = true;
1457
+ const rangeBox = document.getElementById('rangeBox');
1458
+ if (rangeBox) rangeBox.classList.add('is-dragging');
1316
1459
  }
1317
1460
 
1318
1461
  function onSliderPointerUp() {
1319
1462
  isDraggingSlider = false;
1463
+ const rangeBox = document.getElementById('rangeBox');
1464
+ if (rangeBox) rangeBox.classList.remove('is-dragging');
1320
1465
  }
1321
1466
 
1322
1467
  function onSliderInput(val) {
@@ -1412,7 +1557,7 @@ function renderAntigravityCardHtml({
1412
1557
  const source = JSON.parse(sourceJson);
1413
1558
  showFeedback(i18n.locatingSourceMessage);
1414
1559
 
1415
- const result = hostChannelPort
1560
+ const result = (hostChannelPort && !hostHandshakePending)
1416
1561
  ? await postHostChannelRequest({
1417
1562
  type: 'AGENT_THINGS_LOCATE',
1418
1563
  source,
@@ -1474,7 +1619,9 @@ function renderAntigravityCardHtml({
1474
1619
  }
1475
1620
 
1476
1621
  async function sendProxyAction(action, payload = {}) {
1477
- if (!hostChannelPort) {
1622
+ if (hostHandshakePromise) {
1623
+ try { await hostHandshakePromise; } catch (_) {}
1624
+ } else if (!hostChannelPort) {
1478
1625
  try { await requestHostAuth(); } catch (_) {}
1479
1626
  }
1480
1627
  return postHostChannelRequest({
@@ -1503,7 +1650,13 @@ function renderAntigravityCardHtml({
1503
1650
  try {
1504
1651
  if (btn) btn.disabled = true;
1505
1652
  clearFeedback();
1506
- if (hostChannelPort) {
1653
+ if (hostHandshakePending && hostHandshakePromise) {
1654
+ await Promise.race([
1655
+ hostHandshakePromise.catch(() => null),
1656
+ new Promise((resolve) => setTimeout(resolve, 250)),
1657
+ ]);
1658
+ }
1659
+ if (hostChannelPort && !hostHandshakePending) {
1507
1660
  try {
1508
1661
  await postHostChannelRequest({
1509
1662
  type: 'AGENT_THINGS_OPEN_PANE',
@@ -1523,7 +1676,7 @@ function renderAntigravityCardHtml({
1523
1676
  return;
1524
1677
  }
1525
1678
  try { await requestHostAuth(); } catch (_) {}
1526
- if (hostChannelPort) {
1679
+ if (hostChannelPort && !hostHandshakePending) {
1527
1680
  await postHostChannelRequest({
1528
1681
  type: 'AGENT_THINGS_OPEN_PANE',
1529
1682
  }, { timeoutMs: 4500, errorLabel: i18n.cardRequestTimeout });
@@ -1541,6 +1694,8 @@ function renderAntigravityCardHtml({
1541
1694
  if (!data || typeof data !== 'object') return;
1542
1695
 
1543
1696
  if (data.type === 'AGENT_THINGS_AUTH_RESPONSE' && data.nonce) {
1697
+ hostHandshakePending = false;
1698
+ hostHandshakePromise = null;
1544
1699
  const req = pendingActions.get(data.nonce);
1545
1700
  if (req) {
1546
1701
  clearTimeout(req.timer);
@@ -1571,14 +1726,21 @@ function renderAntigravityCardHtml({
1571
1726
  }
1572
1727
 
1573
1728
  function requestHostAuth() {
1574
- return new Promise((resolve, reject) => {
1729
+ if (hostHandshakePromise) return hostHandshakePromise;
1730
+ const isInitialHandshake = !hostChannelPort;
1731
+ if (isInitialHandshake) {
1732
+ hostHandshakePending = true;
1733
+ }
1734
+ const promise = new Promise((resolve, reject) => {
1575
1735
  const nonce = 'auth-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 7);
1576
1736
  const timer = setTimeout(() => {
1577
1737
  pendingActions.delete(nonce);
1578
- if (hostChannelPort && !authTicket) {
1579
- try { hostChannelPort.close(); } catch (_) {}
1738
+ if (isInitialHandshake || (hostChannelPort && !authTicket)) {
1739
+ hostHandshakePending = false;
1740
+ try { hostChannelPort?.close?.(); } catch (_) {}
1580
1741
  hostChannelPort = null;
1581
1742
  }
1743
+ if (hostHandshakePromise === promise) hostHandshakePromise = null;
1582
1744
  reject(new Error(i18n.cardTimeout));
1583
1745
  }, 8000);
1584
1746
 
@@ -1597,6 +1759,7 @@ function renderAntigravityCardHtml({
1597
1759
  } catch (_) {
1598
1760
  try { hostChannelPort.close(); } catch (_) {}
1599
1761
  hostChannelPort = null;
1762
+ hostHandshakePending = true;
1600
1763
  }
1601
1764
  }
1602
1765
 
@@ -1614,15 +1777,25 @@ function renderAntigravityCardHtml({
1614
1777
  } else {
1615
1778
  clearTimeout(timer);
1616
1779
  pendingActions.delete(nonce);
1780
+ hostHandshakePending = false;
1781
+ if (hostHandshakePromise === promise) hostHandshakePromise = null;
1617
1782
  reject(new Error(i18n.cardAuthUnavailable));
1618
1783
  return;
1619
1784
  }
1620
1785
  } catch (err) {
1621
1786
  clearTimeout(timer);
1622
1787
  pendingActions.delete(nonce);
1788
+ if (isInitialHandshake) {
1789
+ hostHandshakePending = false;
1790
+ try { hostChannelPort?.close?.(); } catch (_) {}
1791
+ hostChannelPort = null;
1792
+ }
1793
+ if (hostHandshakePromise === promise) hostHandshakePromise = null;
1623
1794
  reject(err);
1624
1795
  }
1625
1796
  });
1797
+ hostHandshakePromise = promise;
1798
+ return promise;
1626
1799
  }
1627
1800
 
1628
1801
  window.addEventListener('message', (event) => {
@@ -1631,22 +1804,48 @@ function renderAntigravityCardHtml({
1631
1804
  } catch (_) {}
1632
1805
  });
1633
1806
 
1807
+ function buildAppliedSessionSnapshot(replySession, fallback) {
1808
+ const pending = pendingRemoteSnapshot;
1809
+ const pendingRev = typeof pending?.revision === 'number' ? pending.revision : -1;
1810
+ const replyRev = typeof replySession?.recordRevision === 'number' ? replySession.recordRevision : -1;
1811
+ const hasNewerPending = Boolean(pending && (replyRev < 0 || pendingRev >= replyRev));
1812
+ return {
1813
+ state: hasNewerPending ? pending.state : (replySession?.state || fallback.state),
1814
+ progress: hasNewerPending ? pending.progress : (replySession && 'progress' in replySession ? replySession.progress : fallback.progress),
1815
+ note: hasNewerPending ? pending.note : (replySession && 'note' in replySession ? replySession.note : fallback.note),
1816
+ summary: hasNewerPending
1817
+ ? pending.summary
1818
+ : ((replySession && 'summary' in replySession ? replySession.summary : fallback.summary) || ''),
1819
+ source: hasNewerPending ? pending.source : (replySession?.source || fallback.source || 'manual'),
1820
+ updatedAt: hasNewerPending ? pending.updatedAt : (replySession?.updatedAt || fallback.updatedAt || new Date().toISOString()),
1821
+ tasks: (hasNewerPending ? pending.tasks : null) || replySession?.tasks || pending?.tasks,
1822
+ title: (hasNewerPending ? pending.title : null) || replySession?.title || pending?.title,
1823
+ revision: hasNewerPending ? pending.revision : (replyRev >= 0 ? replyRev : fallback.revision),
1824
+ };
1825
+ }
1826
+
1634
1827
  async function onSaveRecord() {
1635
1828
  const btn = document.getElementById('btnSaveRecord');
1636
1829
  const noteVal = document.getElementById('txtNote')?.value ?? '';
1830
+ if (saveSwitchTimer) {
1831
+ clearTimeout(saveSwitchTimer);
1832
+ saveSwitchTimer = null;
1833
+ }
1637
1834
  try {
1638
1835
  if (btn) btn.disabled = true;
1639
1836
  showFeedback(i18n.savingFeedback);
1837
+ const submittedState = currentState;
1838
+ const submittedProgress = currentProgress;
1640
1839
  const reply = await sendProxyAction('update', {
1641
1840
  expectedRevision: draftBaseRevision,
1642
1841
  record: {
1643
- state: currentState,
1644
- progress: currentProgress,
1842
+ state: submittedState,
1843
+ progress: submittedProgress,
1645
1844
  note: noteVal
1646
1845
  }
1647
1846
  });
1648
- // 修复:sendProxyAction 已解包 data,调用方应读 reply.session.recordRevision
1649
- const newRev = reply?.session?.recordRevision;
1847
+ const replySession = reply?.session || null;
1848
+ const newRev = replySession?.recordRevision;
1650
1849
  if (typeof newRev === 'number') {
1651
1850
  savedRevision = newRev;
1652
1851
  draftBaseRevision = newRev;
@@ -1654,8 +1853,21 @@ function renderAntigravityCardHtml({
1654
1853
  }
1655
1854
  isFormDirty = false;
1656
1855
  hideConflictNotice();
1856
+ const applied = buildAppliedSessionSnapshot(replySession, {
1857
+ state: submittedState,
1858
+ progress: submittedProgress,
1859
+ note: noteVal,
1860
+ summary: noteVal,
1861
+ source: 'manual',
1862
+ revision: currentRevision,
1863
+ });
1864
+ pendingRemoteSnapshot = null;
1865
+ applyFullProgressToUI(applied);
1657
1866
  showFeedback(i18n.savedFeedback);
1658
- setTimeout(switchToOverview, 600);
1867
+ saveSwitchTimer = setTimeout(function() {
1868
+ saveSwitchTimer = null;
1869
+ switchToOverview();
1870
+ }, 600);
1659
1871
  } catch (err) {
1660
1872
  const isConflict = err.message && (err.message.includes('其他窗口更新') || err.message.includes('another window') || err.message.includes('版本已被') || err.message.includes('409') || err.message.includes('conflict') || err.message.includes('revision mismatch'));
1661
1873
  if (isConflict) {
@@ -1670,19 +1882,32 @@ function renderAntigravityCardHtml({
1670
1882
 
1671
1883
  async function onClearClick() {
1672
1884
  if (!confirm(i18n.clearConfirm)) return;
1885
+ if (saveSwitchTimer) {
1886
+ clearTimeout(saveSwitchTimer);
1887
+ saveSwitchTimer = null;
1888
+ }
1673
1889
  try {
1674
1890
  showFeedback(i18n.clearingFeedback);
1675
1891
  const reply = await sendProxyAction('clear', {
1676
1892
  expectedRevision: draftBaseRevision,
1677
1893
  });
1678
- const newRev = reply?.session?.recordRevision;
1679
- if (typeof newRev === 'number') {
1680
- savedRevision = newRev;
1681
- draftBaseRevision = newRev;
1682
- currentRevision = newRev;
1683
- }
1894
+ const replySession = reply?.session || null;
1895
+ const newRev = typeof replySession?.recordRevision === 'number' ? replySession.recordRevision : 0;
1896
+ savedRevision = newRev;
1897
+ draftBaseRevision = newRev;
1898
+ currentRevision = newRev;
1684
1899
  isFormDirty = false;
1685
1900
  hideConflictNotice();
1901
+ const applied = buildAppliedSessionSnapshot(replySession, {
1902
+ state: 'unstarted',
1903
+ progress: null,
1904
+ note: '',
1905
+ summary: '',
1906
+ source: 'manual',
1907
+ revision: newRev,
1908
+ });
1909
+ pendingRemoteSnapshot = null;
1910
+ applyFullProgressToUI(applied);
1686
1911
  showFeedback(i18n.clearedFeedback);
1687
1912
  } catch (err) {
1688
1913
  showFeedback(i18n.clearFailedPrefix + err.message, true);
@@ -1698,15 +1923,39 @@ function renderAntigravityCardHtml({
1698
1923
  const effectiveNote = s.note || s.progress?.note || '';
1699
1924
  const effectiveSummary = s.summary || s.progress?.summary || s.analysis?.ledger?.summary || '';
1700
1925
  const effectiveTitle = s.title || s.progress?.title || '';
1926
+ const effectiveSource = s.source || s.progress?.source || (s.analysis || s.savedAnalysis ? 'analysis' : 'manual');
1927
+ const effectiveUpdatedAt = s.updatedAt || s.progress?.updatedAt || s.analysisStatus?.finishedAt || '';
1928
+
1929
+ const isRemoteClear = s.recordRevision === 0 && effectiveProgress === null && !effectiveNote;
1930
+ if (isRemoteClear) {
1931
+ savedRevision = 0;
1932
+ } else if (typeof s.recordRevision === 'number') {
1933
+ savedRevision = Math.max(savedRevision, s.recordRevision);
1934
+ } else if (typeof s.progress?.revision === 'number') {
1935
+ savedRevision = Math.max(savedRevision, s.progress.revision);
1936
+ } else if (typeof s.revision === 'number') {
1937
+ savedRevision = Math.max(savedRevision, s.revision);
1938
+ }
1701
1939
 
1702
- if (typeof s.recordRevision === 'number') savedRevision = Math.max(savedRevision, s.recordRevision);
1703
- else if (typeof s.progress?.revision === 'number') savedRevision = Math.max(savedRevision, s.progress.revision);
1704
- else if (typeof s.revision === 'number') savedRevision = Math.max(savedRevision, s.revision);
1705
-
1706
- // 若未处于草稿编辑中,基准版本与当前展示版本同步更新
1707
- if (!isFormDirty) {
1940
+ const nextSnapshot = {
1941
+ state: effectiveState,
1942
+ progress: effectiveProgress,
1943
+ tasks: effectiveTasks,
1944
+ note: effectiveNote,
1945
+ summary: effectiveSummary,
1946
+ title: effectiveTitle,
1947
+ source: effectiveSource,
1948
+ updatedAt: effectiveUpdatedAt,
1949
+ revision: savedRevision,
1950
+ };
1951
+
1952
+ // Cache latest remote snapshot even during dirty form edits so it renders on exit/save/clear
1953
+ if (isFormDirty) {
1954
+ pendingRemoteSnapshot = nextSnapshot;
1955
+ } else {
1708
1956
  currentRevision = savedRevision;
1709
1957
  draftBaseRevision = savedRevision;
1958
+ pendingRemoteSnapshot = null;
1710
1959
  }
1711
1960
 
1712
1961
  const analyzing = Boolean(s.analyzing || s.analysisStatus?.status === 'pending');
@@ -1725,17 +1974,9 @@ function renderAntigravityCardHtml({
1725
1974
  }
1726
1975
  }
1727
1976
 
1728
- // 仅在非 dirty 编辑态下将远端状态刷入表单与展示
1977
+ // Apply to DOM immediately when not in dirty edit mode
1729
1978
  if (!isFormDirty) {
1730
- applyFullProgressToUI({
1731
- state: effectiveState,
1732
- progress: effectiveProgress,
1733
- tasks: effectiveTasks,
1734
- note: effectiveNote,
1735
- summary: effectiveSummary,
1736
- title: effectiveTitle,
1737
- revision: currentRevision,
1738
- });
1979
+ applyFullProgressToUI(nextSnapshot);
1739
1980
  }
1740
1981
  }
1741
1982
 
@@ -1791,10 +2032,30 @@ function renderAntigravityCardHtml({
1791
2032
  totalsEl.textContent = totalCount > 0 ? fmt('totalsPattern', { done: doneCount, total: totalCount }) : i18n.noTasksYet;
1792
2033
  }
1793
2034
 
2035
+ const tsEl = document.getElementById('overviewTimestamp');
2036
+ if (tsEl && data.updatedAt) {
2037
+ const dt = new Date(data.updatedAt);
2038
+ if (!isNaN(dt.getTime())) {
2039
+ tsEl.textContent = (dt.getMonth() + 1) + '/' + dt.getDate() + ' ' + String(dt.getHours()).padStart(2, '0') + ':' + String(dt.getMinutes()).padStart(2, '0');
2040
+ }
2041
+ }
2042
+
2043
+ const sourceEl = document.getElementById('overviewSourceLabel');
2044
+ if (sourceEl && data.source) {
2045
+ sourceEl.textContent = data.source === 'analysis' ? i18n.sourceAuto : i18n.sourceManual;
2046
+ }
2047
+
1794
2048
  const summaryText = data.summary || data.note || '';
2049
+ const summaryBlock = document.getElementById('summaryBlock');
1795
2050
  const summaryEl = document.getElementById('overviewSummary');
1796
- if (summaryEl && summaryText) {
1797
- summaryEl.textContent = summaryText;
2051
+ if (summaryEl) {
2052
+ if (summaryText) {
2053
+ summaryEl.textContent = summaryText;
2054
+ if (summaryBlock) summaryBlock.hidden = false;
2055
+ } else if ('summary' in data || 'note' in data) {
2056
+ summaryEl.textContent = '';
2057
+ if (summaryBlock) summaryBlock.hidden = true;
2058
+ }
1798
2059
  }
1799
2060
  checkSummaryOverflow();
1800
2061
 
@@ -1984,9 +2245,176 @@ function renderAntigravityCardHtml({
1984
2245
  }, { passive: true });
1985
2246
  }
1986
2247
 
2248
+ function setupHostAutoResize() {
2249
+ // Built-in host resize reporting so inline embeds expand beyond the 200px default after srcdoc verification strips host wrappers.
2250
+ if (!window.parent || window.parent === window) return function() {};
2251
+ const MIN_HEIGHT = 24;
2252
+ const MAX_HEIGHT = 20000;
2253
+ const SLACK = 4;
2254
+ const WINDOW_MS = 2000;
2255
+ const MAX_UPDATES_PER_WINDOW = 40;
2256
+ const MAX_DISTINCT_HEIGHTS = 8;
2257
+ const COOLDOWN_MS = 2000;
2258
+ let lastHeight = -1;
2259
+ let updates = [];
2260
+ let frozen = false;
2261
+ let rafId = null;
2262
+
2263
+ function sendHeight(rawHeight) {
2264
+ if (frozen) return;
2265
+ let height = Math.ceil(rawHeight);
2266
+ if (!(height > 0)) height = 0;
2267
+ if (height > MAX_HEIGHT) height = MAX_HEIGHT;
2268
+ if (height < MIN_HEIGHT) height = MIN_HEIGHT;
2269
+ if (lastHeight >= 0 && Math.abs(height - lastHeight) <= SLACK) return;
2270
+
2271
+ const now = Date.now();
2272
+ updates.push({ t: now, h: height });
2273
+ while (updates.length && now - updates[0].t > WINDOW_MS) {
2274
+ updates.shift();
2275
+ }
2276
+ if (updates.length > MAX_UPDATES_PER_WINDOW) {
2277
+ const seen = {};
2278
+ let distinct = 0;
2279
+ for (let i = 0; i < updates.length; i++) {
2280
+ if (!seen[updates[i].h]) {
2281
+ seen[updates[i].h] = true;
2282
+ distinct++;
2283
+ }
2284
+ }
2285
+ if (distinct <= MAX_DISTINCT_HEIGHTS) {
2286
+ frozen = true;
2287
+ updates = [];
2288
+ setTimeout(function() {
2289
+ frozen = false;
2290
+ measure();
2291
+ }, COOLDOWN_MS);
2292
+ return;
2293
+ }
2294
+ }
2295
+
2296
+ lastHeight = height;
2297
+ try {
2298
+ window.parent.postMessage({ type: 'RESIZE', height: height }, '*');
2299
+ } catch (_) {}
2300
+ }
2301
+
2302
+ function measure() {
2303
+ const body = document.body;
2304
+ const shell = document.getElementById('agentThingsCard');
2305
+ let margins = 0;
2306
+ if (body && typeof getComputedStyle === 'function') {
2307
+ try {
2308
+ const style = getComputedStyle(body);
2309
+ margins = (parseFloat(style.marginTop) || 0) + (parseFloat(style.marginBottom) || 0);
2310
+ } catch (_) {}
2311
+ }
2312
+ const bodyHeight = body ? Math.max(body.scrollHeight || 0, body.offsetHeight || 0) : 0;
2313
+ const shellRect = shell && typeof shell.getBoundingClientRect === 'function' ? shell.getBoundingClientRect() : null;
2314
+ const shellHeight = shell
2315
+ ? Math.max(shell.scrollHeight || 0, shell.offsetHeight || 0, shellRect ? (shellRect.height || 0) : 0)
2316
+ : 0;
2317
+ const content = Math.max(bodyHeight, shellHeight) + margins;
2318
+ if (content > 0) sendHeight(content + SLACK);
2319
+ }
2320
+
2321
+ function scheduleMeasure() {
2322
+ if (typeof requestAnimationFrame === 'function') {
2323
+ if (rafId && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(rafId);
2324
+ rafId = requestAnimationFrame(function() {
2325
+ rafId = null;
2326
+ measure();
2327
+ });
2328
+ } else {
2329
+ measure();
2330
+ }
2331
+ }
2332
+
2333
+ if (typeof ResizeObserver === 'function') {
2334
+ try {
2335
+ const observer = new ResizeObserver(scheduleMeasure);
2336
+ const shell = document.getElementById('agentThingsCard');
2337
+ if (document.body) observer.observe(document.body);
2338
+ if (shell && shell !== document.body) observer.observe(shell);
2339
+ } catch (_) {}
2340
+ }
2341
+
2342
+ if (typeof window.addEventListener === 'function') {
2343
+ window.addEventListener('load', measure);
2344
+ }
2345
+ if (document.fonts && document.fonts.ready && typeof document.fonts.ready.then === 'function') {
2346
+ document.fonts.ready.then(measure);
2347
+ }
2348
+
2349
+ measure();
2350
+ return measure;
2351
+ }
2352
+
2353
+ function normalizeCardHex(raw) {
2354
+ if (typeof raw !== 'string') return '';
2355
+ const s = raw.trim();
2356
+ if (/^#[0-9a-fA-F]{6}$/.test(s)) return s.toUpperCase();
2357
+ if (/^#[0-9a-fA-F]{3}$/.test(s)) return ('#' + s[1] + s[1] + s[2] + s[2] + s[3] + s[3]).toUpperCase();
2358
+ const m = s.match(/^rgba?\\(\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})/i);
2359
+ if (!m) return '';
2360
+ return '#' + [m[1], m[2], m[3]].map(n => Math.max(0, Math.min(255, Number(n))).toString(16).padStart(2, '0')).join('').toUpperCase();
2361
+ }
2362
+
2363
+ function applyHostThemeMode(rawMode, rawBg) {
2364
+ let mode = rawMode === 'light' || rawMode === 'dark' ? rawMode : '';
2365
+ if (!mode && typeof rawBg === 'string' && rawBg.trim()) {
2366
+ const bgHex = normalizeCardHex(rawBg);
2367
+ if (bgHex) {
2368
+ const r = parseInt(bgHex.slice(1, 3), 16), g = parseInt(bgHex.slice(3, 5), 16), b = parseInt(bgHex.slice(5, 7), 16);
2369
+ mode = (0.299 * r + 0.587 * g + 0.114 * b) > 130 ? 'light' : 'dark';
2370
+ }
2371
+ }
2372
+ if (mode) {
2373
+ document.documentElement.setAttribute('data-color-mode', mode);
2374
+ document.documentElement.style.colorScheme = mode;
2375
+ }
2376
+ return mode;
2377
+ }
2378
+
2379
+ function applyHostAccent(rawPrimary, rawFg) {
2380
+ const hex = normalizeCardHex(rawPrimary);
2381
+ if (!hex) return;
2382
+ const rootStyle = document.documentElement.style;
2383
+ rootStyle.setProperty('--accent', hex);
2384
+ const rgb = [parseInt(hex.slice(1, 3), 16), parseInt(hex.slice(3, 5), 16), parseInt(hex.slice(5, 7), 16)];
2385
+ const lum = rgb.reduce((acc, c, i) => {
2386
+ const srgb = c / 255;
2387
+ const lin = srgb <= 0.03928 ? srgb / 12.92 : Math.pow((srgb + 0.055) / 1.055, 2.4);
2388
+ return acc + lin * (i === 0 ? 0.2126 : i === 1 ? 0.7152 : 0.0722);
2389
+ }, 0);
2390
+ const isLightInk = lum > 0.45;
2391
+ const mixHex = (tRgb, weight) => '#' + rgb.map((c, i) => Math.max(0, Math.min(255, Math.round(c * weight + tRgb[i] * (1 - weight)))).toString(16).padStart(2, '0')).join('').toUpperCase();
2392
+ const docMode = document.documentElement.getAttribute('data-color-mode');
2393
+ const hostIsLight = docMode ? docMode === 'light' : !window.matchMedia?.('(prefers-color-scheme: dark)').matches;
2394
+ const darkTarget = isLightInk || hostIsLight ? [0, 0, 0] : [255, 255, 255];
2395
+ rootStyle.setProperty('--accent-hover', mixHex(darkTarget, 0.88));
2396
+ rootStyle.setProperty('--accent-pressed', mixHex(darkTarget, 0.78));
2397
+ const fgHex = normalizeCardHex(rawFg);
2398
+ rootStyle.setProperty('--on-accent', fgHex || (isLightInk ? '#0D0D0D' : '#FFFFFF'));
2399
+ }
2400
+
1987
2401
  function initCard() {
2402
+ if (window.__agentThingsHostTheme) {
2403
+ applyHostThemeMode(window.__agentThingsHostTheme);
2404
+ }
2405
+ if (window.__agentThingsHostAccent) {
2406
+ applyHostAccent(window.__agentThingsHostAccent, window.__agentThingsHostAccentFg);
2407
+ }
2408
+ window.addEventListener('message', function(ev) {
2409
+ if (ev?.data?.type === 'THEME_SYNC' && ev.data.cssVariables) {
2410
+ const vars = ev.data.cssVariables;
2411
+ applyHostThemeMode(vars['--theme-type'], vars['--background']);
2412
+ applyHostAccent(vars['--primary'] || vars['--accent'], vars['--primary-foreground']);
2413
+ }
2414
+ });
1988
2415
  checkSummaryOverflow();
1989
2416
  setupScrollListener();
2417
+ setupHostAutoResize();
1990
2418
  initEventStream();
1991
2419
  }
1992
2420