agent-things 0.0.0-stage → 1.2.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.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +5 -0
  3. package/README.md +221 -2
  4. package/README.zh-CN.md +222 -0
  5. package/bin/agent-things.cjs +8 -0
  6. package/bin/antigravity-session-status.cjs +96 -0
  7. package/bin/claude-session-status.cjs +55 -0
  8. package/bin/codex-session-status.cjs +287 -0
  9. package/mods/agent-things-ui/.claude-plugin/plugin.json +12 -0
  10. package/mods/agent-things-ui/SKILL.md +10 -0
  11. package/mods/agent-things-ui/hooks/controls.js +112 -0
  12. package/mods/agent-things-ui/hooks/foundation.js +431 -0
  13. package/mods/agent-things-ui/hooks/hooks.json +1 -0
  14. package/mods/agent-things-ui/hooks/presentation.js +223 -0
  15. package/mods/agent-things-ui/hooks/progress.js +1 -0
  16. package/mods/agent-things-ui/hooks/register.js +382 -0
  17. package/native/bin/bridge +0 -0
  18. package/native/bin/bridge.json +20 -0
  19. package/native/session-status-bridge.swift +280 -0
  20. package/outputs/antigravity-session-status.js +2476 -0
  21. package/outputs/codex-session-status.js +1761 -0
  22. package/package.json +75 -4
  23. package/scripts/build-antigravity-bundle.cjs +35 -0
  24. package/scripts/build-codex-bundle.cjs +31 -0
  25. package/scripts/build-native-bridge.cjs +55 -0
  26. package/scripts/build-shared-ui.cjs +16 -0
  27. package/scripts/setup-antigravity-service.cjs +71 -0
  28. package/scripts/setup-claude-service.cjs +21 -0
  29. package/skills/agent-things/SKILL.en.md +95 -0
  30. package/skills/agent-things/SKILL.md +99 -0
  31. package/skills/codex/things/SKILL.en.md +10 -0
  32. package/skills/codex/things/SKILL.md +10 -0
  33. package/skills/things/SKILL.en.md +10 -0
  34. package/skills/things/SKILL.md +10 -0
  35. package/skills/things/checklist.en.md +91 -0
  36. package/skills/things/checklist.md +95 -0
  37. package/src/analysis-app-server.cjs +74 -0
  38. package/src/analysis-assets/output.en.schema.json +93 -0
  39. package/src/analysis-assets/output.schema.json +93 -0
  40. package/src/analysis-assets/prompt.en.txt +17 -0
  41. package/src/analysis-assets/prompt.zh-CN.txt +18 -0
  42. package/src/analysis-budget.cjs +105 -0
  43. package/src/analysis-git.cjs +38 -0
  44. package/src/analysis-history.cjs +150 -0
  45. package/src/analysis-ledger.cjs +82 -0
  46. package/src/analysis-log.cjs +62 -0
  47. package/src/analysis-runner.cjs +203 -0
  48. package/src/analysis-service.cjs +197 -0
  49. package/src/analysis-source.cjs +72 -0
  50. package/src/antigravity-card.cjs +2063 -0
  51. package/src/antigravity-hook.cjs +138 -0
  52. package/src/antigravity-mcp-config.cjs +36 -0
  53. package/src/app-server.cjs +96 -0
  54. package/src/cdp.cjs +115 -0
  55. package/src/claude-inline-install.cjs +38 -0
  56. package/src/claude-mcp-config.cjs +29 -0
  57. package/src/cli/arguments.cjs +30 -0
  58. package/src/cli/environment-probe.cjs +130 -0
  59. package/src/cli/integration-state.cjs +15 -0
  60. package/src/cli/interactive-cli.cjs +236 -0
  61. package/src/cli/prompt-tui.cjs +420 -0
  62. package/src/cli/setup-orchestrator.cjs +449 -0
  63. package/src/codex-mcp-config.cjs +67 -0
  64. package/src/harnesses/antigravity/analysis-profile.cjs +41 -0
  65. package/src/harnesses/antigravity/antigravity-git.cjs +89 -0
  66. package/src/harnesses/antigravity/antigravity-harness.js +1477 -0
  67. package/src/harnesses/antigravity/antigravity-injector.cjs +104 -0
  68. package/src/harnesses/antigravity/antigravity-migration.cjs +235 -0
  69. package/src/harnesses/antigravity/antigravity-service.cjs +357 -0
  70. package/src/harnesses/antigravity/antigravity-title.cjs +155 -0
  71. package/src/harnesses/antigravity/gemini-runner.cjs +304 -0
  72. package/src/harnesses/antigravity/transcript-cleaner.cjs +129 -0
  73. package/src/harnesses/antigravity/transcript-source.cjs +100 -0
  74. package/src/harnesses/claude/claude-harness.js +93 -0
  75. package/src/harnesses/claude/claude-host-helper.cjs +176 -0
  76. package/src/harnesses/claude/claude-injector.cjs +95 -0
  77. package/src/harnesses/claude/claude-local-source.cjs +106 -0
  78. package/src/harnesses/claude/claude-navigation.cjs +99 -0
  79. package/src/harnesses/claude/claude-runner.cjs +74 -0
  80. package/src/harnesses/claude/claude-service.cjs +313 -0
  81. package/src/harnesses/claude/claude-source.cjs +70 -0
  82. package/src/harnesses/codex/codex-analysis.cjs +10 -0
  83. package/src/harnesses/codex/codex-card-bridge.js +123 -0
  84. package/src/harnesses/codex/codex-card-events.cjs +76 -0
  85. package/src/harnesses/codex/codex-card.cjs +169 -0
  86. package/src/harnesses/codex/codex-git.cjs +24 -0
  87. package/src/harnesses/codex/codex-harness.js +229 -0
  88. package/src/harnesses/codex/codex-local-card.js +97 -0
  89. package/src/harnesses/codex/codex-progress-context.cjs +84 -0
  90. package/src/harnesses/codex/codex-service.cjs +502 -0
  91. package/src/i18n.cjs +174 -0
  92. package/src/launchd.cjs +105 -0
  93. package/src/lifecycle-lock.cjs +13 -0
  94. package/src/local-progress-http.cjs +267 -0
  95. package/src/manual-status-agent.cjs +12 -0
  96. package/src/manual-status-startup.cjs +66 -0
  97. package/src/manual-status-store.cjs +466 -0
  98. package/src/mcp-stdio.cjs +67 -0
  99. package/src/model-router.cjs +63 -0
  100. package/src/native-bridge.cjs +17 -0
  101. package/src/npm-updates.cjs +228 -0
  102. package/src/plugins/things/assets/logo.svg +13 -0
  103. package/src/plugins/things/plugin.json +6 -0
  104. package/src/plugins/things/sidecars/things_board/app.js +447 -0
  105. package/src/plugins/things/sidecars/things_board/index.html +2141 -0
  106. package/src/plugins/things/sidecars/things_board/main.mjs +652 -0
  107. package/src/plugins/things/sidecars/things_board/package.json +6 -0
  108. package/src/plugins/things/sidecars/things_board/sidecar.json +21 -0
  109. package/src/plugins/things/sidecars/things_board/styles.css +560 -0
  110. package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +434 -0
  111. package/src/progress-error.cjs +54 -0
  112. package/src/progress-tools.cjs +145 -0
  113. package/src/project-path.cjs +15 -0
  114. package/src/renderer-resource.cjs +17 -0
  115. package/src/request-budget.cjs +24 -0
  116. package/src/resolve.cjs +51 -0
  117. package/src/runtime-install.cjs +635 -0
  118. package/src/session-status-filter.cjs +136 -0
  119. package/src/session-status.js +992 -0
  120. package/src/session-view.cjs +34 -0
  121. package/src/startup/controller.cjs +354 -0
  122. package/src/startup/watch.cjs +126 -0
  123. package/src/state-file-lock.cjs +31 -0
  124. package/src/task-provenance.cjs +42 -0
  125. package/src/ui-foundation.cjs +435 -0
@@ -0,0 +1,2141 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Agent Things 会话任务进度 · 任务进展</title>
7
+ <style>
8
+ :root {
9
+ --accent: #0169cc;
10
+ --accent-hover: #005bb3;
11
+ --at-ink: #e6edf3;
12
+ --at-secondary: #a0a6ad;
13
+ --at-muted: #828c96;
14
+ --at-note: #bbc3ca;
15
+ --at-track: #ffffff12;
16
+ --at-line: #ffffff14;
17
+ --at-input-border: #ffffff18;
18
+ --at-input-bg: #ffffff03;
19
+ --at-hover: #ffffff09;
20
+ --at-selected: #ffffff10;
21
+ --at-source-bg: #ffffff0a;
22
+ --at-number-line: #ffffff25;
23
+ --at-thumb: #e6edf3;
24
+ --at-thumb-edge: #ffffff30;
25
+ --danger: #ef7777;
26
+ --error: #f7ad86;
27
+ --at-panel-bg: #0e1318;
28
+ font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
29
+ color: var(--at-ink);
30
+ color-scheme: dark;
31
+ }
32
+ * {
33
+ box-sizing: border-box;
34
+ scrollbar-width: none;
35
+ -ms-overflow-style: none;
36
+ }
37
+ *::-webkit-scrollbar {
38
+ display: none;
39
+ width: 0;
40
+ height: 0;
41
+ }
42
+ button, input, textarea {
43
+ font: inherit;
44
+ color: inherit;
45
+ }
46
+ button {
47
+ cursor: pointer;
48
+ }
49
+ [hidden] {
50
+ display: none !important;
51
+ }
52
+
53
+ html, body {
54
+ margin: 0;
55
+ padding: 0;
56
+ width: 100%;
57
+ height: 100%;
58
+ min-height: 100vh;
59
+ background: var(--at-panel-bg, #0e1318);
60
+ color: var(--at-ink);
61
+ font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
62
+ box-sizing: border-box;
63
+ overflow-x: hidden;
64
+ -webkit-font-smoothing: antialiased;
65
+ }
66
+
67
+ .shell {
68
+ position: relative;
69
+ width: 100%;
70
+ max-width: 100%;
71
+ min-height: 100vh;
72
+ height: 100%;
73
+ display: flex;
74
+ flex-direction: column;
75
+ background: var(--at-panel-bg, #0e1318);
76
+ border: none;
77
+ border-radius: 0;
78
+ box-shadow: none;
79
+ padding: 18px 20px 24px;
80
+ box-sizing: border-box;
81
+ }
82
+
83
+ .title-heading {
84
+ display: flex;
85
+ flex: none;
86
+ align-items: flex-start;
87
+ gap: 10px;
88
+ border-radius: 5px;
89
+ outline-offset: 4px;
90
+ cursor: default;
91
+ transition: max-height 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s ease, transform 0.22s ease, margin 0.22s ease;
92
+ max-height: 60px;
93
+ opacity: 1;
94
+ transform: translateY(0);
95
+ overflow: visible;
96
+ }
97
+ .shell.is-scrolled .title-heading {
98
+ height: 0;
99
+ min-height: 0;
100
+ max-height: 0;
101
+ opacity: 0;
102
+ visibility: hidden;
103
+ margin: 0;
104
+ padding: 0;
105
+ transform: translateY(-20px);
106
+ overflow: hidden;
107
+ pointer-events: none;
108
+ }
109
+ h2.title {
110
+ font-size: 24px;
111
+ font-weight: 650;
112
+ line-height: 1.3;
113
+ letter-spacing: -0.5px;
114
+ margin: 0;
115
+ min-width: 0;
116
+ overflow-wrap: anywhere;
117
+ display: -webkit-box;
118
+ -webkit-box-orient: vertical;
119
+ -webkit-line-clamp: 2;
120
+ overflow: hidden;
121
+ color: var(--at-ink);
122
+ }
123
+
124
+ .title-progress {
125
+ display: flex;
126
+ flex: none;
127
+ width: 32px;
128
+ height: 32px;
129
+ margin-top: 1px;
130
+ }
131
+ .title-progress svg {
132
+ width: 32px;
133
+ height: 32px;
134
+ display: block;
135
+ }
136
+ .title-progress text {
137
+ opacity: 0;
138
+ transition: opacity 0.15s ease;
139
+ pointer-events: none;
140
+ }
141
+ .title-progress text.progress-unknown {
142
+ opacity: 1;
143
+ }
144
+ .title-heading:hover .progress-pie,
145
+ .title-heading:focus-visible .progress-pie {
146
+ opacity: 0;
147
+ }
148
+ .title-heading:hover text,
149
+ .title-heading:focus-visible text {
150
+ opacity: 1;
151
+ }
152
+
153
+ .panel-body {
154
+ flex: 1;
155
+ overflow-y: auto;
156
+ overflow-x: hidden;
157
+ min-height: 0;
158
+ margin-top: 14px;
159
+ scrollbar-width: none;
160
+ -ms-overflow-style: none;
161
+ transition: margin-top 0.22s ease;
162
+ }
163
+ .shell.is-scrolled .panel-body {
164
+ margin-top: 0;
165
+ }
166
+ .panel-body {
167
+ scrollbar-width: thin;
168
+ scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
169
+ padding-right: 2px;
170
+ }
171
+ .panel-body::-webkit-scrollbar {
172
+ width: 6px;
173
+ height: 6px;
174
+ }
175
+ .panel-body::-webkit-scrollbar-track {
176
+ background: transparent;
177
+ }
178
+ .panel-body::-webkit-scrollbar-thumb {
179
+ background: rgba(255, 255, 255, 0.18);
180
+ border-radius: 4px;
181
+ }
182
+
183
+ .view {
184
+ padding-bottom: 4px;
185
+ }
186
+
187
+ .status-line {
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: space-between;
191
+ gap: 16px;
192
+ }
193
+ .status-block {
194
+ transform: translateY(2px);
195
+ min-width: 0;
196
+ flex: 1;
197
+ }
198
+ .status-name {
199
+ display: flex;
200
+ align-items: center;
201
+ gap: 7px;
202
+ line-height: 18px;
203
+ font-size: 13px;
204
+ min-width: 0;
205
+ }
206
+ .status-name > span:last-child {
207
+ min-width: 0;
208
+ overflow: hidden;
209
+ text-overflow: ellipsis;
210
+ white-space: nowrap;
211
+ }
212
+ .state-dot {
213
+ width: 10px;
214
+ height: 10px;
215
+ border: 1.5px solid;
216
+ border-radius: 50%;
217
+ flex: none;
218
+ background: transparent !important;
219
+ }
220
+ .timestamp {
221
+ font-size: 11px;
222
+ line-height: 16px;
223
+ color: var(--at-secondary);
224
+ margin-top: 2px;
225
+ margin-left: 17px;
226
+ overflow: hidden;
227
+ text-overflow: ellipsis;
228
+ white-space: nowrap;
229
+ }
230
+ .score {
231
+ display: flex;
232
+ align-items: baseline;
233
+ line-height: 1;
234
+ font-variant-numeric: tabular-nums;
235
+ flex: none;
236
+ }
237
+ .score-number {
238
+ font-size: 39px;
239
+ font-weight: 550;
240
+ letter-spacing: -1px;
241
+ color: var(--at-ink);
242
+ }
243
+ .score-unit {
244
+ font-size: 15px;
245
+ color: var(--at-secondary);
246
+ margin-left: 3px;
247
+ }
248
+
249
+ .meter {
250
+ height: 4px;
251
+ background: var(--at-track);
252
+ border-radius: 3px;
253
+ margin: 10px 0 8px;
254
+ overflow: hidden;
255
+ }
256
+ .meter::after {
257
+ content: "";
258
+ display: block;
259
+ height: 100%;
260
+ width: var(--fill, 0%);
261
+ background: var(--mark, #b4b7be);
262
+ border-radius: inherit;
263
+ }
264
+
265
+ .totals-row {
266
+ display: flex;
267
+ justify-content: space-between;
268
+ align-items: center;
269
+ gap: 8px;
270
+ color: var(--at-secondary);
271
+ }
272
+ .totals, .source-label {
273
+ font-size: 11px;
274
+ font-weight: 400;
275
+ line-height: 16px;
276
+ }
277
+ .source-label {
278
+ margin-left: auto;
279
+ text-align: right;
280
+ white-space: nowrap;
281
+ }
282
+
283
+ .summary-block {
284
+ position: relative;
285
+ margin: 10px 0;
286
+ outline: none;
287
+ }
288
+ .overview-summary {
289
+ font-size: 13px;
290
+ line-height: 1.65;
291
+ color: var(--at-note);
292
+ display: -webkit-box;
293
+ -webkit-line-clamp: 3;
294
+ -webkit-box-orient: vertical;
295
+ overflow: hidden;
296
+ white-space: pre-wrap;
297
+ overflow-wrap: anywhere;
298
+ }
299
+ .summary-expand {
300
+ position: absolute;
301
+ right: 0;
302
+ bottom: 0;
303
+ border: 0;
304
+ background: linear-gradient(to right, transparent, var(--at-panel-bg) 18px);
305
+ padding: 0 0 0 22px;
306
+ color: var(--at-secondary);
307
+ font-size: 12px;
308
+ line-height: 21.45px;
309
+ white-space: nowrap;
310
+ cursor: pointer;
311
+ }
312
+ .summary-expand:hover {
313
+ color: inherit;
314
+ }
315
+ .summary-block.expanded .overview-summary {
316
+ display: block;
317
+ -webkit-line-clamp: unset;
318
+ }
319
+ .summary-block.expanded .summary-expand {
320
+ position: static;
321
+ display: block;
322
+ margin-left: auto;
323
+ padding-left: 0;
324
+ background: none;
325
+ }
326
+
327
+ .actions {
328
+ display: flex;
329
+ align-items: center;
330
+ gap: 14px;
331
+ margin: 12px 0 14px;
332
+ }
333
+ .primary {
334
+ border: 0;
335
+ background: var(--accent);
336
+ color: #fff;
337
+ border-radius: 9px;
338
+ padding: 9px 14px;
339
+ font-weight: 550;
340
+ min-height: 36px;
341
+ font-size: 13px;
342
+ white-space: nowrap;
343
+ flex-shrink: 0;
344
+ transition: background 0.15s ease;
345
+ }
346
+ .primary:hover {
347
+ background: var(--accent-hover);
348
+ color: #fff;
349
+ }
350
+ .text-button, .clear, .back {
351
+ border: 0;
352
+ background: none;
353
+ padding: 0;
354
+ color: var(--at-secondary);
355
+ font-size: 12px;
356
+ white-space: nowrap;
357
+ cursor: pointer;
358
+ transition: color 0.12s ease;
359
+ }
360
+ .text-button:hover, .back:hover {
361
+ color: inherit;
362
+ }
363
+ .actions .clear {
364
+ margin-left: auto;
365
+ font-size: 11px;
366
+ color: var(--at-muted);
367
+ white-space: nowrap;
368
+ position: relative;
369
+ }
370
+ .actions .clear:hover {
371
+ color: var(--danger);
372
+ }
373
+ .clear-tooltip {
374
+ position: absolute;
375
+ right: 0;
376
+ bottom: calc(100% + 8px);
377
+ padding: 6px 9px;
378
+ border-radius: 6px;
379
+ background: var(--at-panel-bg);
380
+ color: var(--at-secondary);
381
+ border: 1px solid var(--at-line);
382
+ font-size: 11px;
383
+ pointer-events: none;
384
+ opacity: 0;
385
+ visibility: hidden;
386
+ transition: opacity 0.08s, visibility 0s;
387
+ white-space: nowrap;
388
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
389
+ z-index: 10;
390
+ }
391
+ .clear:is(:hover, :focus-visible) .clear-tooltip {
392
+ opacity: 1;
393
+ visibility: visible;
394
+ transition-delay: 0.1s;
395
+ }
396
+
397
+ .section-head {
398
+ border-top: 1px solid var(--at-line);
399
+ padding-top: 10px;
400
+ display: flex;
401
+ align-items: center;
402
+ justify-content: space-between;
403
+ margin-bottom: 4px;
404
+ }
405
+ .section-head h3 {
406
+ font-size: 12px;
407
+ font-weight: 550;
408
+ margin: 0;
409
+ color: var(--at-ink);
410
+ }
411
+ .remaining-toggle {
412
+ border: 0;
413
+ background: none;
414
+ padding: 0;
415
+ }
416
+ .row-detail {
417
+ font-size: 12px;
418
+ font-weight: 400;
419
+ line-height: 18px;
420
+ color: var(--at-secondary);
421
+ white-space: nowrap;
422
+ }
423
+
424
+ .task-row {
425
+ position: relative;
426
+ display: flex;
427
+ gap: 9px;
428
+ align-items: flex-start;
429
+ padding: 9px 0;
430
+ overflow: hidden;
431
+ isolation: isolate;
432
+ }
433
+ .task-dot {
434
+ width: 12px;
435
+ height: 12px;
436
+ border: 1.3px solid #c89b38;
437
+ border-radius: 50%;
438
+ margin-top: 4px;
439
+ flex: none;
440
+ }
441
+ .task-row[data-status="done"] .task-dot {
442
+ border-color: #548eea;
443
+ background: rgba(84, 142, 234, 0.22);
444
+ }
445
+ .task-content {
446
+ min-width: 0;
447
+ flex: 1;
448
+ }
449
+ .task-title {
450
+ font-size: 13px;
451
+ line-height: 1.4;
452
+ color: var(--at-ink);
453
+ word-break: break-word;
454
+ }
455
+ .task-meta {
456
+ font-size: 10px;
457
+ color: var(--at-secondary);
458
+ margin-top: 2px;
459
+ line-height: 1.4;
460
+ }
461
+ .task-source {
462
+ position: absolute;
463
+ top: 0;
464
+ right: 0;
465
+ bottom: 0;
466
+ z-index: 1;
467
+ display: flex;
468
+ align-items: center;
469
+ padding-left: 25px;
470
+ background: linear-gradient(to right, transparent, var(--at-panel-bg, #0e1318) 25px);
471
+ opacity: 0;
472
+ pointer-events: none;
473
+ transform: translateX(6px);
474
+ transition: opacity 0.16s ease, transform 0.16s ease;
475
+ }
476
+ .task-row:hover .task-source,
477
+ .task-row:focus-within .task-source {
478
+ opacity: 1;
479
+ pointer-events: auto;
480
+ transform: translateX(0);
481
+ }
482
+ .task-source > button {
483
+ border: 0;
484
+ border-radius: 6px;
485
+ background: var(--at-source-bg, #ffffff0a);
486
+ color: var(--at-ink);
487
+ padding: 4px 10px;
488
+ font-size: 11px;
489
+ white-space: nowrap;
490
+ cursor: pointer;
491
+ }
492
+ .task-source > button:disabled {
493
+ opacity: 0.65;
494
+ cursor: wait;
495
+ }
496
+
497
+ .empty {
498
+ font-size: 12px;
499
+ color: var(--at-secondary);
500
+ padding: 8px 0;
501
+ text-align: left;
502
+ }
503
+
504
+ .quiet-row {
505
+ border: 0;
506
+ border-top: 1px solid var(--at-line);
507
+ display: flex;
508
+ justify-content: space-between;
509
+ align-items: center;
510
+ width: 100%;
511
+ background: none;
512
+ color: inherit;
513
+ padding: 10px 0;
514
+ text-align: left;
515
+ font-size: 12px;
516
+ cursor: pointer;
517
+ transition: color 0.15s ease;
518
+ }
519
+ .quiet-row span:last-child {
520
+ color: var(--at-secondary);
521
+ }
522
+ .quiet-row:hover {
523
+ color: var(--at-ink);
524
+ }
525
+
526
+ .overview-bottom {
527
+ margin-top: 8px;
528
+ }
529
+
530
+ /* Views */
531
+ .view-heading {
532
+ position: sticky;
533
+ top: 0;
534
+ z-index: 10;
535
+ background: var(--at-panel-bg);
536
+ display: flex;
537
+ justify-content: space-between;
538
+ align-items: center;
539
+ padding: 4px 0 10px;
540
+ margin-bottom: 6px;
541
+ }
542
+ .view-heading h3 {
543
+ font-size: 14px;
544
+ font-weight: 600;
545
+ margin: 0;
546
+ color: var(--at-ink);
547
+ }
548
+ .view-heading .back {
549
+ font-size: 13px;
550
+ font-weight: 500;
551
+ color: var(--at-secondary);
552
+ padding: 4px 8px;
553
+ margin-right: -6px;
554
+ border-radius: 6px;
555
+ cursor: pointer;
556
+ transition: color 0.12s, background 0.12s;
557
+ }
558
+ .view-heading .back:hover {
559
+ color: var(--at-ink);
560
+ background: var(--at-hover);
561
+ }
562
+ .view-heading::after {
563
+ content: "";
564
+ position: absolute;
565
+ left: -20px;
566
+ right: -20px;
567
+ top: 100%;
568
+ height: 20px;
569
+ background: linear-gradient(to bottom, var(--at-panel-bg), transparent);
570
+ pointer-events: none;
571
+ opacity: 0;
572
+ transition: opacity 0.2s ease-out, background 0.15s ease-out;
573
+ }
574
+ .shell.is-scrolled .view-heading::after {
575
+ opacity: 1;
576
+ }
577
+
578
+ /* Edit View */
579
+ .choices-list {
580
+ display: flex;
581
+ flex-direction: column;
582
+ gap: 4px;
583
+ margin-bottom: 12px;
584
+ }
585
+ .choice {
586
+ display: flex;
587
+ align-items: center;
588
+ gap: 10px;
589
+ width: 100%;
590
+ padding: 8px 9px;
591
+ border: 0;
592
+ border-radius: 7px;
593
+ background: none;
594
+ color: inherit;
595
+ text-align: left;
596
+ font-size: 13px;
597
+ cursor: pointer;
598
+ transition: background 0.12s ease;
599
+ }
600
+ .choice:hover {
601
+ background: var(--at-hover);
602
+ }
603
+ .choice[aria-pressed="true"] {
604
+ background: var(--at-selected);
605
+ }
606
+ .dot {
607
+ width: 12px;
608
+ height: 12px;
609
+ border: 1.6px solid var(--mark);
610
+ border-radius: 50%;
611
+ flex: none;
612
+ }
613
+ .choice[aria-pressed="true"] .dot {
614
+ background: var(--mark);
615
+ box-shadow: inset 0 0 0 2px var(--at-panel-bg);
616
+ }
617
+
618
+ .progress-section {
619
+ margin-top: 20px;
620
+ }
621
+ .progress-head {
622
+ display: flex;
623
+ justify-content: space-between;
624
+ align-items: center;
625
+ margin-bottom: 12px;
626
+ }
627
+ .label {
628
+ font-size: 11px;
629
+ color: var(--at-secondary);
630
+ }
631
+ .number-wrap {
632
+ display: flex;
633
+ align-items: center;
634
+ gap: 5px;
635
+ color: var(--at-secondary);
636
+ }
637
+ .progress-number {
638
+ appearance: textfield;
639
+ color: var(--at-ink);
640
+ width: 65px;
641
+ padding: 2px 3px 4px;
642
+ background: none;
643
+ border: 0;
644
+ border-bottom: 1px solid var(--at-number-line);
645
+ font-size: 27px;
646
+ font-weight: 550;
647
+ text-align: right;
648
+ font-variant-numeric: tabular-nums;
649
+ }
650
+ .progress-number::-webkit-inner-spin-button {
651
+ appearance: none;
652
+ }
653
+ .range {
654
+ position: relative;
655
+ height: 51px;
656
+ margin-top: 2px;
657
+ --mark: #c89b38;
658
+ }
659
+ .range-track {
660
+ position: absolute;
661
+ left: 7px;
662
+ right: 7px;
663
+ top: 10px;
664
+ height: 4px;
665
+ border-radius: 3px;
666
+ background: linear-gradient(to right, var(--mark) var(--fill), var(--at-track) var(--fill));
667
+ pointer-events: none;
668
+ }
669
+ .range-input {
670
+ position: relative;
671
+ appearance: none;
672
+ width: 100%;
673
+ height: 24px;
674
+ background: transparent;
675
+ margin: 0;
676
+ display: block;
677
+ padding: 0;
678
+ cursor: pointer;
679
+ }
680
+ .range-input::-webkit-slider-runnable-track {
681
+ height: 4px;
682
+ background: transparent;
683
+ }
684
+ .range-input::-webkit-slider-thumb {
685
+ appearance: none;
686
+ width: 14px;
687
+ height: 14px;
688
+ margin-top: -5px;
689
+ background: var(--at-thumb);
690
+ border: 2px solid var(--at-panel-bg);
691
+ border-radius: 50%;
692
+ box-shadow: 0 0 0 1px var(--at-thumb-edge);
693
+ }
694
+ .range-nodes {
695
+ position: absolute;
696
+ left: 7px;
697
+ right: 7px;
698
+ top: 0;
699
+ pointer-events: none;
700
+ }
701
+ .range-node {
702
+ position: absolute;
703
+ left: var(--at);
704
+ top: 8px;
705
+ width: 0;
706
+ font-size: 10px;
707
+ color: var(--at-secondary);
708
+ font-variant-numeric: tabular-nums;
709
+ }
710
+ .range-node::before {
711
+ content: "";
712
+ display: block;
713
+ width: 7px;
714
+ height: 7px;
715
+ transform: translateX(-50%);
716
+ border-radius: 50%;
717
+ background: var(--at-panel-bg);
718
+ border: 1px solid var(--at-secondary);
719
+ box-shadow: 0 0 0 1px var(--at-panel-bg);
720
+ }
721
+ .range-node-label {
722
+ position: absolute;
723
+ top: 19px;
724
+ left: 0;
725
+ transform: translateX(-50%);
726
+ }
727
+ .range-node:first-child .range-node-label {
728
+ transform: none;
729
+ }
730
+ .range-node:last-child .range-node-label {
731
+ transform: translateX(-100%);
732
+ }
733
+ .unknown-row {
734
+ display: flex;
735
+ justify-content: flex-end;
736
+ margin: 2px 0 18px;
737
+ }
738
+ .unknown {
739
+ font-size: 11px;
740
+ color: var(--at-secondary);
741
+ border: 0;
742
+ background: none;
743
+ padding: 0;
744
+ cursor: pointer;
745
+ }
746
+ .unknown:hover {
747
+ color: var(--at-ink);
748
+ }
749
+
750
+ .note-label {
751
+ display: block;
752
+ font-size: 11px;
753
+ color: var(--at-secondary);
754
+ margin-bottom: 8px;
755
+ }
756
+ textarea.note-input {
757
+ display: block;
758
+ width: 100%;
759
+ resize: vertical;
760
+ min-height: 66px;
761
+ max-height: 140px;
762
+ background: var(--at-input-bg);
763
+ color: inherit;
764
+ border: 1px solid var(--at-input-border);
765
+ border-radius: 8px;
766
+ padding: 9px;
767
+ line-height: 1.6;
768
+ font-size: 12px;
769
+ }
770
+ textarea.note-input:focus-visible {
771
+ outline: none;
772
+ }
773
+
774
+ .edit-actions {
775
+ display: flex;
776
+ justify-content: flex-end;
777
+ gap: 18px;
778
+ align-items: center;
779
+ padding: 21px 0 16px;
780
+ }
781
+
782
+ .feedback-msg {
783
+ font-size: 11px;
784
+ color: var(--at-secondary);
785
+ margin-top: 10px;
786
+ text-align: right;
787
+ }
788
+ .feedback-msg.error {
789
+ color: var(--error);
790
+ }
791
+ .feedback-msg.success {
792
+ color: #548eea;
793
+ }
794
+
795
+ @media (prefers-color-scheme: light) {
796
+ :root {
797
+ --at-ink: #22272e;
798
+ --at-secondary: #576374;
799
+ --at-muted: #667383;
800
+ --at-note: #46515f;
801
+ --at-track: #c3ccd6;
802
+ --at-line: #dfe4ea;
803
+ --at-input-border: #c7d0da;
804
+ --input-bg: #f7f9fb;
805
+ --hover: #f0f3f6;
806
+ --selected: #e9edf2;
807
+ --source-bg: #e9eef4;
808
+ --number-line: #b6c1ce;
809
+ --thumb: var(--accent);
810
+ --thumb-edge: var(--accent);
811
+ --danger: #bf2f3a;
812
+ --error: #b13a2d;
813
+ --panel-bg: #fff;
814
+ color: var(--at-ink);
815
+ color-scheme: light;
816
+ }
817
+ .shell {
818
+ --panel-bg: #fff;
819
+ border-color: #dfe4ea;
820
+ box-shadow: none;
821
+ }
822
+ }
823
+ </style>
824
+ <script src="/preload.js"></script>
825
+ </head>
826
+ <body>
827
+ <div class="shell" id="agentThingsCard">
828
+ <div class="title-heading" tabindex="0">
829
+ <span class="title-progress" id="titleProgress">
830
+ <svg viewBox="0 0 24 24" width="32" height="32" aria-hidden="true" style="overflow:visible">
831
+ <circle cx="12" cy="12" r="10" fill="none" stroke="#b4b7be" stroke-width="1.6" opacity="0.85"/>
832
+ <text x="12" y="12.4" text-anchor="middle" dominant-baseline="middle" fill="#b4b7be" class="progress-unknown" style="font:600 6.4px -apple-system,BlinkMacSystemFont,sans-serif;letter-spacing:-0.2px;font-variant-numeric:tabular-nums">—</text>
833
+ </svg>
834
+ </span>
835
+ <h2 class="title" id="cardTitle" title="当前会话">当前会话</h2>
836
+ </div>
837
+
838
+ <div class="panel-body" id="panelBody">
839
+ <!-- Overview View -->
840
+ <div id="overviewView" class="view overview">
841
+ <div class="status-line">
842
+ <div class="status-block">
843
+ <div class="status-name">
844
+ <span class="state-dot" id="overviewDot" style="border-color:#b4b7be; background:transparent;"></span>
845
+ <span id="overviewStatusLabel">尚未开始</span>
846
+ </div>
847
+ <div class="timestamp" id="overviewTimestamp">--/-- --:--</div>
848
+ </div>
849
+ <div class="score">
850
+ <span class="score-number" id="overviewScoreNumber">—</span>
851
+ <span class="score-unit" hidden>%</span>
852
+ </div>
853
+ </div>
854
+
855
+ <div class="meter" id="overviewMeter" style="--fill:0%; --mark:#b4b7be;"></div>
856
+
857
+ <div class="totals-row">
858
+ <span class="totals" id="overviewTotals">暂无任务统计</span>
859
+ <span class="source-label" id="overviewSourceLabel">自动分析</span>
860
+ </div>
861
+
862
+ <div class="summary-block" id="summaryBlock" tabindex="0">
863
+ <div class="overview-summary" id="overviewSummary">尚未记录进展</div>
864
+ <button class="summary-expand" id="summaryExpand" onclick="toggleSummaryExpand()" hidden>查看全部</button>
865
+ </div>
866
+
867
+ <div class="actions">
868
+ <button class="primary" id="btnAnalyze" onclick="onAnalyzeClick()">更新进度</button>
869
+ <button class="text-button" id="btnAdjust" onclick="switchToEdit()">手动调整</button>
870
+ <button class="clear" id="btnClear" aria-label="清除进度" onclick="onClearClick()">
871
+ <span class="clear-tooltip" id="clearTooltip" role="tooltip">立即清除进度与任务记录</span>
872
+ <span id="clearBtnLabel">清除进度</span>
873
+ </button>
874
+ </div>
875
+
876
+ <!-- Section Head -->
877
+ <div class="section-head">
878
+ <h3 id="remainingTasksHeading">剩余任务 0</h3>
879
+ </div>
880
+
881
+ <!-- Tasks list -->
882
+ <div class="tasks-list" id="uncompletedTasksList">
883
+ <div class="empty">点击更新进度,整理这次会话的任务</div>
884
+ </div>
885
+
886
+ <!-- Bottom Rows (1:1 identical to sidebar) -->
887
+ <div class="overview-bottom">
888
+ <button class="quiet-row history-open" onclick="switchToHistory()">
889
+ <span id="completedRowLabel">已完成任务</span>
890
+ <span class="row-detail" id="historyCount">0 条 ›</span>
891
+ </button>
892
+ <button class="quiet-row note-open" onclick="switchToEditNote()">
893
+ <span id="notesRowLabel">备注</span>
894
+ <span class="row-detail" id="noteOpenLabel">添加</span>
895
+ </button>
896
+ </div>
897
+ </div>
898
+
899
+ <!-- History View -->
900
+ <div id="historyView" class="view history-view" hidden>
901
+ <div class="view-heading">
902
+ <h3 id="historyHeading">已完成任务</h3>
903
+ <button class="back" id="historyBackBtn" onclick="switchToOverview()">‹ 返回</button>
904
+ </div>
905
+ <div class="history-list" id="historyList">
906
+ <div class="empty">暂无已完成任务</div>
907
+ </div>
908
+ </div>
909
+
910
+ <!-- Edit View -->
911
+ <div id="editView" class="view edit-view" hidden>
912
+ <div class="view-heading">
913
+ <h3 id="editHeading">手动记录会话状态</h3>
914
+ <button class="back" id="editBackBtn" onclick="switchToOverview()">‹ 返回</button>
915
+ </div>
916
+ <div class="choices-list">
917
+
918
+ <button class="choice" id="choice-unstarted" aria-pressed="false" style="--mark:#9098a2" onclick="selectState('unstarted')">
919
+ <span class="dot"></span>
920
+ <span class="choice-label">尚未开始</span>
921
+ </button>
922
+
923
+ <button class="choice" id="choice-unfinished" aria-pressed="true" style="--mark:#c89b38" onclick="selectState('unfinished')">
924
+ <span class="dot"></span>
925
+ <span class="choice-label">有遗留事项</span>
926
+ </button>
927
+
928
+ <button class="choice" id="choice-completed" aria-pressed="false" style="--mark:#548eea" onclick="selectState('completed')">
929
+ <span class="dot"></span>
930
+ <span class="choice-label">全部完成</span>
931
+ </button>
932
+
933
+ <button class="choice" id="choice-pushed" hidden aria-pressed="false" style="--mark:#a17be3" onclick="selectState('pushed')">
934
+ <span class="dot"></span>
935
+ <span class="choice-label">全部完成并已推送</span>
936
+ </button>
937
+
938
+ </div>
939
+
940
+ <div class="progress-section">
941
+ <div class="progress-head">
942
+ <label class="label" id="progressFieldLabel" for="inputProgressNumber">进度</label>
943
+ <div class="number-wrap">
944
+ <input type="number" id="inputProgressNumber" class="progress-number" min="0" max="100" step="1" value="" placeholder="—" aria-label="进度" oninput="onNumberInput(this.value)" onkeydown="onProgressKeyDown(event)">
945
+ <span>%</span>
946
+ </div>
947
+ </div>
948
+
949
+ <div class="range" id="rangeBox" style="--mark:#b4b7be; --fill:0%;">
950
+ <div class="range-track"></div>
951
+ <div class="range-nodes" aria-hidden="true">
952
+
953
+ <span class="range-node" style="--at:0%;">
954
+ <span class="range-node-label">0</span>
955
+ </span>
956
+
957
+ <span class="range-node" style="--at:25%;">
958
+ <span class="range-node-label">25</span>
959
+ </span>
960
+
961
+ <span class="range-node" style="--at:50%;">
962
+ <span class="range-node-label">50</span>
963
+ </span>
964
+
965
+ <span class="range-node" style="--at:75%;">
966
+ <span class="range-node-label">75</span>
967
+ </span>
968
+
969
+ <span class="range-node" style="--at:100%;">
970
+ <span class="range-node-label">100</span>
971
+ </span>
972
+
973
+ </div>
974
+ <input type="range" id="inputSlider" class="range-input" min="0" max="100" step="1" value="0" aria-label="拖动调整进度" onpointerdown="onSliderPointerDown()" onpointerup="onSliderPointerUp()" onpointercancel="onSliderPointerUp()" oninput="onSliderInput(this.value)">
975
+ </div>
976
+
977
+ <div class="unknown-row">
978
+ <button type="button" class="unknown" id="btnClearProgress" onclick="onClearProgressClick()">清空进度</button>
979
+ </div>
980
+ </div>
981
+
982
+ <label class="note-label" id="txtNoteLabel" for="txtNote">备注</label>
983
+ <textarea id="txtNote" class="note-input" maxlength="4000" placeholder="记下下一步要做的事…" aria-label="事项备注" oninput="markFormDirty()"></textarea>
984
+
985
+ <div id="conflictBox" class="conflict-box" style="display:none; margin: 10px 0; padding: 8px 12px; background: rgba(230, 80, 80, 0.12); border: 1px solid rgba(230, 80, 80, 0.35); border-radius: 6px; font-size: 12px; line-height: 1.5; color: var(--at-ink);">
986
+ <div id="conflictMsg">保存冲突:内容已被其他入口修改。当前草稿已保留。</div>
987
+ <div style="margin-top: 6px;">
988
+ <button type="button" class="text-button" id="btnResolveConflict" style="color: var(--mark); text-decoration: underline; padding: 0;" onclick="resolveConflictKeepDraft()">读取最新版本并保留草稿</button>
989
+ </div>
990
+ </div>
991
+
992
+ <div class="edit-actions">
993
+ <button class="text-button" id="btnCancelEdit" onclick="switchToOverview()">取消</button>
994
+ <button class="primary" id="btnSaveRecord" onclick="onSaveRecord()">保存记录</button>
995
+ </div>
996
+ </div>
997
+ </div>
998
+
999
+ <div class="feedback-msg" id="feedbackMsg" role="status"></div>
1000
+ </div>
1001
+
1002
+ <script>
1003
+ const injectedI18n = window.__agentThingsI18n || {};
1004
+ function normalizeLang(val) {
1005
+ return val === 'en' ? 'en' : 'zh';
1006
+ }
1007
+ let activeLang = normalizeLang(window.__agentThingsLang || injectedI18n.lang || (navigator.language && navigator.language.toLowerCase().startsWith('en') ? 'en' : 'zh'));
1008
+ const fallbackLocales = {
1009
+ zh: {
1010
+ docTitleSuffix: '任务进展',
1011
+ defaultDocTitle: 'Agent Things 会话任务进度',
1012
+ defaultSessionTitle: '当前会话',
1013
+ labels: {"unstarted":"尚未开始","unfinished":"有遗留事项","completed":"全部完成","pushed":"全部完成并已推送"},
1014
+ taskLabels: {"todo":"待开始","in_progress":"进行中","blocked":"受阻","needs_verification":"待验收","done":"已完成"},
1015
+ unrecordedSummary: '尚未记录进展',
1016
+ noTasksYet: '暂无任务统计',
1017
+ totalsPattern: '已完成 {done} / {total} 项任务',
1018
+ sourceAuto: '自动分析',
1019
+ btnUpdate: '更新进度',
1020
+ btnUpdating: '正在分析…',
1021
+ btnAdjust: '手动调整',
1022
+ btnClear: '清除进度',
1023
+ clearTooltip: '立即清除进度与任务记录',
1024
+ clearConfirm: '确定要清除本会话的任务进度和记录吗?',
1025
+ clearingFeedback: '正在清除…',
1026
+ clearedFeedback: '✓ 已清空进度',
1027
+ clearFailedPrefix: '清除失败: ',
1028
+ expandAll: '查看全部',
1029
+ collapse: '收起',
1030
+ remainingHeadingPattern: '剩余任务 {count}',
1031
+ showAllCountPattern: '查看全部 {count} 条 ›',
1032
+ collapseArrow: '收起 ›',
1033
+ emptyNoTasks: '点击更新进度,整理这次会话的任务',
1034
+ emptyNoRemaining: '暂无未完成任务',
1035
+ completedHeading: '已完成任务',
1036
+ countArrowPattern: '{count} 条 ›',
1037
+ notesLabel: '备注',
1038
+ addLabel: '添加',
1039
+ editLabel: '编辑',
1040
+ untitledTask: '未命名事项',
1041
+ completedTaskFallback: '已完成事项',
1042
+ viewSource: '查看来源',
1043
+ backLabel: '‹ 返回',
1044
+ emptyCompleted: '暂无已完成任务',
1045
+ editHeading: '手动记录会话状态',
1046
+ progressLabel: '进度',
1047
+ clearValueBtn: '清空进度',
1048
+ notePlaceholder: '记下下一步要做的事…',
1049
+ noteAriaLabel: '事项备注',
1050
+ sliderAriaLabel: '拖动调整进度',
1051
+ cancelBtn: '取消',
1052
+ saveBtn: '保存记录',
1053
+ savingFeedback: '正在保存…',
1054
+ savedFeedback: '✓ 保存成功',
1055
+ saveFailedPrefix: '保存失败: ',
1056
+ conflictBanner: '保存冲突:内容已被其他入口修改。当前草稿已保留。',
1057
+ conflictDetectedFeedback: '保存失败:检测到版本冲突',
1058
+ resolveConflictBtn: '读取最新版本并保留草稿',
1059
+ conflictRebasedFeedback: '基准版本已对齐最新状态,再次点击保存即可提交当前草稿。',
1060
+ startingAnalysisFeedback: '正在开始分析…',
1061
+ analysisNotDonePrefix: '分析未完成: ',
1062
+ analysisAbnormal: '执行异常',
1063
+ updateFailedPrefix: '更新失败: ',
1064
+ locatingShort: '定位中...',
1065
+ locatedJumpMessage: '已跳转并定位到会话来源',
1066
+ locateNotFound: '未找到对应会话消息',
1067
+ locateSent: '已发送定位请求',
1068
+ locateHostUnavailable: '未能连接宿主定位接口',
1069
+ locateFailedPrefix: '定位失败:',
1070
+ unknownActionError: '未知错误',
1071
+ cardOpFailed: '操作失败',
1072
+ cardAuthUnavailable: '获取连接凭据失败',
1073
+ },
1074
+ en: {
1075
+ docTitleSuffix: 'Progress',
1076
+ defaultDocTitle: 'Agent Things Progress',
1077
+ defaultSessionTitle: 'Current session',
1078
+ labels: {"unstarted":"Not started","unfinished":"Remaining items","completed":"Completed","pushed":"Completed & pushed"},
1079
+ taskLabels: {"todo":"To do","in_progress":"In progress","blocked":"Blocked","needs_verification":"Needs verification","done":"Done"},
1080
+ unrecordedSummary: 'No progress recorded',
1081
+ noTasksYet: 'No task stats yet',
1082
+ totalsPattern: '{done} of {total} tasks done',
1083
+ sourceAuto: 'Auto-analyzed',
1084
+ btnUpdate: 'Update progress',
1085
+ btnUpdating: 'Analyzing...',
1086
+ btnAdjust: 'Adjust',
1087
+ btnClear: 'Clear',
1088
+ clearTooltip: 'Clear progress and task records now',
1089
+ clearConfirm: 'Clear progress and task records for this session?',
1090
+ clearingFeedback: 'Clearing...',
1091
+ clearedFeedback: '✓ Cleared',
1092
+ clearFailedPrefix: 'Clear failed: ',
1093
+ expandAll: 'Show all',
1094
+ collapse: 'Collapse',
1095
+ remainingHeadingPattern: 'Remaining tasks ({count})',
1096
+ showAllCountPattern: 'Show all {count} ›',
1097
+ collapseArrow: 'Collapse ›',
1098
+ emptyNoTasks: 'Click Update progress to organize tasks for this session',
1099
+ emptyNoRemaining: 'No remaining tasks',
1100
+ completedHeading: 'Completed tasks',
1101
+ countArrowPattern: '{count} ›',
1102
+ notesLabel: 'Notes',
1103
+ addLabel: 'Add',
1104
+ editLabel: 'Edit',
1105
+ untitledTask: 'Untitled task',
1106
+ completedTaskFallback: 'Completed task',
1107
+ viewSource: 'View source',
1108
+ backLabel: '‹ Back',
1109
+ emptyCompleted: 'No completed tasks',
1110
+ editHeading: 'Set session status',
1111
+ progressLabel: 'Progress',
1112
+ clearValueBtn: 'Clear value',
1113
+ notePlaceholder: 'Add next steps or notes...',
1114
+ noteAriaLabel: 'Session notes',
1115
+ sliderAriaLabel: 'Drag to adjust progress',
1116
+ cancelBtn: 'Cancel',
1117
+ saveBtn: 'Save',
1118
+ savingFeedback: 'Saving...',
1119
+ savedFeedback: '✓ Saved',
1120
+ saveFailedPrefix: 'Save failed: ',
1121
+ conflictBanner: 'Save conflict: updated elsewhere. Your draft has been kept.',
1122
+ conflictDetectedFeedback: 'Save failed: revision conflict detected',
1123
+ resolveConflictBtn: 'Load latest & keep draft',
1124
+ conflictRebasedFeedback: 'Synced to latest version. Click Save again to submit your draft.',
1125
+ startingAnalysisFeedback: 'Starting analysis...',
1126
+ analysisNotDonePrefix: 'Analysis incomplete: ',
1127
+ analysisAbnormal: 'execution error',
1128
+ updateFailedPrefix: 'Update failed: ',
1129
+ locatingShort: 'Locating...',
1130
+ locatedJumpMessage: 'Jumped to source message',
1131
+ locateNotFound: 'Source message not found',
1132
+ locateSent: 'Locate request sent',
1133
+ locateHostUnavailable: 'Unable to reach host locate API',
1134
+ locateFailedPrefix: 'Locate failed: ',
1135
+ unknownActionError: 'Unknown error',
1136
+ cardOpFailed: 'Card action failed',
1137
+ cardAuthUnavailable: 'Card authorization unavailable',
1138
+ }
1139
+ };
1140
+ const colors = injectedI18n.colors || {"unstarted":"#9098a2","unfinished":"#c89b38","completed":"#548eea","pushed":"#a17be3"};
1141
+ function getLocale(targetLang) {
1142
+ const code = normalizeLang(targetLang || activeLang);
1143
+ const fromInjected = injectedI18n.locales && injectedI18n.locales[code];
1144
+ if (fromInjected) return fromInjected;
1145
+ if (code === normalizeLang(injectedI18n.lang) && injectedI18n.strings) return injectedI18n.strings;
1146
+ return fallbackLocales[code];
1147
+ }
1148
+ let locale = getLocale(activeLang);
1149
+ let labels = locale.labels || fallbackLocales[activeLang].labels;
1150
+ let taskLabels = locale.taskLabels || fallbackLocales[activeLang].taskLabels;
1151
+ function str(key, vars) {
1152
+ const tmpl = locale[key] !== undefined ? locale[key] : (fallbackLocales[activeLang][key] !== undefined ? fallbackLocales[activeLang][key] : key);
1153
+ if (!vars) return tmpl;
1154
+ return String(tmpl).replace(/\{(\w+)\}/g, function(_, k) { return vars[k] !== undefined ? String(vars[k]) : ''; });
1155
+ }
1156
+ let lastRenderedData = null;
1157
+
1158
+ function applyStaticLanguage() {
1159
+ document.documentElement.lang = activeLang === 'en' ? 'en' : 'zh-CN';
1160
+ const srcEl = document.getElementById('overviewSourceLabel');
1161
+ if (srcEl) srcEl.textContent = str('sourceAuto');
1162
+ const adjustBtn = document.getElementById('btnAdjust');
1163
+ if (adjustBtn) adjustBtn.textContent = str('btnAdjust');
1164
+ const clearBtn = document.getElementById('btnClear');
1165
+ if (clearBtn) clearBtn.setAttribute('aria-label', str('btnClear'));
1166
+ const clearTip = document.getElementById('clearTooltip');
1167
+ if (clearTip) clearTip.textContent = str('clearTooltip');
1168
+ const clearLbl = document.getElementById('clearBtnLabel');
1169
+ if (clearLbl) clearLbl.textContent = str('btnClear');
1170
+ const completedRowLbl = document.getElementById('completedRowLabel');
1171
+ if (completedRowLbl) completedRowLbl.textContent = str('completedHeading');
1172
+ const notesRowLbl = document.getElementById('notesRowLabel');
1173
+ if (notesRowLbl) notesRowLbl.textContent = str('notesLabel');
1174
+ const histHeading = document.getElementById('historyHeading');
1175
+ if (histHeading) histHeading.textContent = str('completedHeading');
1176
+ const histBack = document.getElementById('historyBackBtn');
1177
+ if (histBack) histBack.textContent = str('backLabel');
1178
+ const editHead = document.getElementById('editHeading');
1179
+ if (editHead) editHead.textContent = str('editHeading');
1180
+ const editBack = document.getElementById('editBackBtn');
1181
+ if (editBack) editBack.textContent = str('backLabel');
1182
+ for (const stateKey of ['unstarted', 'unfinished', 'completed', 'pushed']) {
1183
+ const lbl = document.querySelector('#choice-' + stateKey + ' .choice-label');
1184
+ if (lbl && labels[stateKey]) lbl.textContent = labels[stateKey];
1185
+ }
1186
+ const progLbl = document.getElementById('progressFieldLabel');
1187
+ if (progLbl) progLbl.textContent = str('progressLabel');
1188
+ const numIn = document.getElementById('inputProgressNumber');
1189
+ if (numIn) numIn.setAttribute('aria-label', str('progressLabel'));
1190
+ const sliderIn = document.getElementById('inputSlider');
1191
+ if (sliderIn) sliderIn.setAttribute('aria-label', str('sliderAriaLabel'));
1192
+ const clrProgBtn = document.getElementById('btnClearProgress');
1193
+ if (clrProgBtn) clrProgBtn.textContent = str('clearValueBtn');
1194
+ const txtNoteLbl = document.getElementById('txtNoteLabel');
1195
+ if (txtNoteLbl) txtNoteLbl.textContent = str('notesLabel');
1196
+ const txtNoteEl = document.getElementById('txtNote');
1197
+ if (txtNoteEl) {
1198
+ txtNoteEl.placeholder = str('notePlaceholder');
1199
+ txtNoteEl.setAttribute('aria-label', str('noteAriaLabel'));
1200
+ }
1201
+ const conflictEl = document.getElementById('conflictMsg');
1202
+ if (conflictEl) conflictEl.textContent = str('conflictBanner');
1203
+ const resolveBtn = document.getElementById('btnResolveConflict');
1204
+ if (resolveBtn) resolveBtn.textContent = str('resolveConflictBtn');
1205
+ const cancelBtn = document.getElementById('btnCancelEdit');
1206
+ if (cancelBtn) cancelBtn.textContent = str('cancelBtn');
1207
+ const saveBtn = document.getElementById('btnSaveRecord');
1208
+ if (saveBtn) saveBtn.textContent = str('saveBtn');
1209
+ const btnAnalyzeEl = document.getElementById('btnAnalyze');
1210
+ if (btnAnalyzeEl) btnAnalyzeEl.textContent = btnAnalyzeEl.disabled ? str('btnUpdating') : str('btnUpdate');
1211
+ const summaryBlock = document.getElementById('summaryBlock');
1212
+ const summaryExpandBtn = document.getElementById('summaryExpand');
1213
+ if (summaryBlock && summaryExpandBtn) {
1214
+ summaryExpandBtn.textContent = summaryBlock.classList.contains('expanded') ? str('collapse') : str('expandAll');
1215
+ }
1216
+ if (!lastRenderedData) {
1217
+ applyCardTitle(currentSessionTitle || str('defaultSessionTitle'), false);
1218
+ const statusLbl = document.getElementById('overviewStatusLabel');
1219
+ if (statusLbl) statusLbl.textContent = labels.unstarted;
1220
+ const totalsEl = document.getElementById('overviewTotals');
1221
+ if (totalsEl) totalsEl.textContent = str('noTasksYet');
1222
+ const sumEl = document.getElementById('overviewSummary');
1223
+ if (sumEl) sumEl.textContent = str('unrecordedSummary');
1224
+ const remHead = document.getElementById('remainingTasksHeading');
1225
+ if (remHead) remHead.textContent = str('remainingHeadingPattern', { count: 0 });
1226
+ const uncompEl = document.getElementById('uncompletedTasksList');
1227
+ if (uncompEl && uncompEl.querySelector('.empty')) {
1228
+ uncompEl.innerHTML = '<div class="empty">' + escapeHtml(str('emptyNoTasks')) + '</div>';
1229
+ }
1230
+ const histCount = document.getElementById('historyCount');
1231
+ if (histCount) histCount.textContent = str('countArrowPattern', { count: 0 });
1232
+ const noteLbl = document.getElementById('noteOpenLabel');
1233
+ if (noteLbl) noteLbl.textContent = str('addLabel');
1234
+ const histList = document.getElementById('historyList');
1235
+ if (histList && histList.querySelector('.empty')) {
1236
+ histList.innerHTML = '<div class="empty">' + escapeHtml(str('emptyCompleted')) + '</div>';
1237
+ }
1238
+ }
1239
+ }
1240
+
1241
+ function setActiveLang(nextLang) {
1242
+ if (nextLang !== 'en' && nextLang !== 'zh') return;
1243
+ const changed = nextLang !== activeLang;
1244
+ activeLang = nextLang;
1245
+ locale = getLocale(activeLang);
1246
+ labels = locale.labels || fallbackLocales[activeLang].labels;
1247
+ taskLabels = locale.taskLabels || fallbackLocales[activeLang].taskLabels;
1248
+ applyStaticLanguage();
1249
+ if (changed && lastRenderedData) {
1250
+ applyFullProgressToUI(lastRenderedData);
1251
+ }
1252
+ }
1253
+
1254
+ function escapeHtml(strVal) {
1255
+ if (strVal === null || strVal === undefined) return '';
1256
+ return String(strVal)
1257
+ .replace(/&/g, '&amp;')
1258
+ .replace(/</g, '&lt;')
1259
+ .replace(/>/g, '&gt;')
1260
+ .replace(/"/g, '&quot;')
1261
+ .replace(/'/g, '&#39;');
1262
+ }
1263
+ let conversationId = (window.sidecar?.conversationId || new URLSearchParams(window.location.search).get("conversationId") || "").trim();
1264
+ window.conversationId = conversationId;
1265
+ const connection = {"origin":"http://127.0.0.1:29888","conversationId":conversationId,"title":str('defaultSessionTitle'),"loadToken":null};
1266
+ let currentSessionTitle = '';
1267
+
1268
+ function isGenericTitle(val) {
1269
+ const text = String(val || '').trim();
1270
+ return !text ||
1271
+ text === '当前会话' ||
1272
+ text === 'Agent Things 会话任务进度' ||
1273
+ text === 'Current session' ||
1274
+ text === 'Agent Things Progress' ||
1275
+ text === str('defaultSessionTitle') ||
1276
+ text === str('defaultDocTitle');
1277
+ }
1278
+
1279
+ function applyCardTitle(nextTitle, remember = true) {
1280
+ const clean = String(nextTitle || '').trim();
1281
+ if (remember && !isGenericTitle(clean)) {
1282
+ currentSessionTitle = clean;
1283
+ }
1284
+ const display = !isGenericTitle(clean)
1285
+ ? clean
1286
+ : (!isGenericTitle(currentSessionTitle) ? currentSessionTitle : str('defaultSessionTitle'));
1287
+ const titleEl = document.getElementById('cardTitle');
1288
+ if (titleEl) {
1289
+ titleEl.textContent = display;
1290
+ titleEl.title = display;
1291
+ }
1292
+ document.title = display + ' · ' + str('docTitleSuffix');
1293
+ }
1294
+ let currentRevision = 0;
1295
+ let savedRevision = 0;
1296
+ let draftBaseRevision = savedRevision;
1297
+ let isFormDirty = false;
1298
+ let currentState = "unstarted";
1299
+ let currentProgress = null;
1300
+ let isDraggingSlider = false;
1301
+ let hostChannelPort = null;
1302
+
1303
+ function resetScroll() {
1304
+ const panel = document.getElementById('panelBody');
1305
+ const shell = document.getElementById('agentThingsCard');
1306
+ if (panel) panel.scrollTop = 0;
1307
+ if (shell) shell.classList.remove('is-scrolled');
1308
+ }
1309
+
1310
+ function showConflictNotice(msg) {
1311
+ const box = document.getElementById('conflictBox');
1312
+ const text = document.getElementById('conflictMsg');
1313
+ if (box && text) {
1314
+ text.textContent = msg || str('conflictBanner');
1315
+ box.style.display = 'block';
1316
+ }
1317
+ showFeedback(str('conflictDetectedFeedback'), true);
1318
+ }
1319
+
1320
+ function hideConflictNotice() {
1321
+ const box = document.getElementById('conflictBox');
1322
+ if (box) box.style.display = 'none';
1323
+ }
1324
+
1325
+ function resolveConflictKeepDraft() {
1326
+ draftBaseRevision = savedRevision;
1327
+ hideConflictNotice();
1328
+ showFeedback(str('conflictRebasedFeedback'));
1329
+ }
1330
+
1331
+ function switchToEdit() {
1332
+ resetScroll();
1333
+ draftBaseRevision = savedRevision;
1334
+ isFormDirty = false;
1335
+ hideConflictNotice();
1336
+ document.getElementById('overviewView').hidden = true;
1337
+ document.getElementById('historyView').hidden = true;
1338
+ document.getElementById('editView').hidden = false;
1339
+ clearFeedback();
1340
+ }
1341
+
1342
+ function switchToEditNote() {
1343
+ switchToEdit();
1344
+ setTimeout(function() {
1345
+ const txt = document.getElementById('txtNote');
1346
+ if (txt) txt.focus();
1347
+ }, 50);
1348
+ }
1349
+
1350
+ function switchToHistory() {
1351
+ resetScroll();
1352
+ document.getElementById('overviewView').hidden = true;
1353
+ document.getElementById('editView').hidden = true;
1354
+ document.getElementById('historyView').hidden = false;
1355
+ clearFeedback();
1356
+ }
1357
+
1358
+ function switchToOverview() {
1359
+ resetScroll();
1360
+ document.getElementById('editView').hidden = true;
1361
+ document.getElementById('historyView').hidden = true;
1362
+ document.getElementById('overviewView').hidden = false;
1363
+ isFormDirty = false;
1364
+ hideConflictNotice();
1365
+ clearFeedback();
1366
+ checkSummaryOverflow();
1367
+ }
1368
+
1369
+ function markFormDirty() {
1370
+ isFormDirty = true;
1371
+ }
1372
+
1373
+ function selectState(stateKey, isRemoteSync = false) {
1374
+ if (!isRemoteSync) markFormDirty();
1375
+ currentState = stateKey;
1376
+ for (const key of Object.keys(labels)) {
1377
+ const btn = document.getElementById('choice-' + key);
1378
+ if (btn) btn.setAttribute('aria-pressed', String(key === stateKey));
1379
+ }
1380
+ if (!isRemoteSync) {
1381
+ if (stateKey === 'unstarted') {
1382
+ updateProgressVal(0);
1383
+ } else if (stateKey === 'completed' || stateKey === 'pushed') {
1384
+ updateProgressVal(100);
1385
+ }
1386
+ }
1387
+ updateRangeMark(colors[stateKey] || colors.unfinished);
1388
+ }
1389
+
1390
+ function onNumberInput(val) {
1391
+ markFormDirty();
1392
+ const num = val === '' ? null : Number(val);
1393
+ if (num !== null && !isNaN(num)) {
1394
+ const clamped = Math.max(0, Math.min(100, Math.round(num)));
1395
+ updateProgressVal(clamped);
1396
+ const nextState = clamped === 100 ? (currentState === 'pushed' ? 'pushed' : 'completed')
1397
+ : (clamped === 0 && currentState === 'unstarted' ? 'unstarted' : 'unfinished');
1398
+ selectState(nextState);
1399
+ } else {
1400
+ updateProgressVal(null);
1401
+ }
1402
+ }
1403
+
1404
+ function onProgressKeyDown(event) {
1405
+ if (event.key === 'Enter') {
1406
+ event.preventDefault();
1407
+ onSaveRecord();
1408
+ }
1409
+ }
1410
+
1411
+ function onSliderPointerDown() {
1412
+ isDraggingSlider = true;
1413
+ }
1414
+
1415
+ function onSliderPointerUp() {
1416
+ isDraggingSlider = false;
1417
+ }
1418
+
1419
+ function onSliderInput(val) {
1420
+ markFormDirty();
1421
+ const value = Number(val);
1422
+ const nearest = Math.round(value / 25) * 25;
1423
+ const snapped = (isDraggingSlider && Math.abs(value - nearest) <= 2) ? nearest : value;
1424
+ updateProgressVal(snapped);
1425
+ const nextState = snapped === 100 ? (currentState === 'pushed' ? 'pushed' : 'completed')
1426
+ : (snapped === 0 && currentState === 'unstarted' ? 'unstarted' : 'unfinished');
1427
+ selectState(nextState);
1428
+ }
1429
+
1430
+ function onClearProgressClick() {
1431
+ updateProgressVal(null);
1432
+ }
1433
+
1434
+ function updateProgressVal(val) {
1435
+ currentProgress = val;
1436
+ const slider = document.getElementById('inputSlider');
1437
+ const numberInput = document.getElementById('inputProgressNumber');
1438
+ const rangeBox = document.getElementById('rangeBox');
1439
+ if (slider) slider.value = val !== null ? val : 0;
1440
+ if (numberInput) numberInput.value = val !== null ? val : '';
1441
+ if (rangeBox) rangeBox.style.setProperty('--fill', (val !== null ? val : 0) + '%');
1442
+ }
1443
+
1444
+ function updateRangeMark(markColor) {
1445
+ const rangeBox = document.getElementById('rangeBox');
1446
+ if (rangeBox) rangeBox.style.setProperty('--mark', markColor);
1447
+ }
1448
+
1449
+ function toggleAllRemaining() {
1450
+ const hiddenRows = document.querySelectorAll('.remaining-hidden');
1451
+ const btn = document.getElementById('btnToggleAllRemaining');
1452
+ const isExpanded = btn?.getAttribute('data-expanded') === 'true';
1453
+ hiddenRows.forEach(function(row) { row.hidden = isExpanded; });
1454
+ if (btn) {
1455
+ btn.setAttribute('data-expanded', String(!isExpanded));
1456
+ const total = hiddenRows.length + 3;
1457
+ btn.textContent = isExpanded ? str('showAllCountPattern', { count: total }) : str('collapseArrow');
1458
+ }
1459
+ }
1460
+
1461
+ function toggleSummaryExpand() {
1462
+ const block = document.getElementById('summaryBlock');
1463
+ const btn = document.getElementById('summaryExpand');
1464
+ if (!block || !btn) return;
1465
+ const isExpanded = block.classList.toggle('expanded');
1466
+ btn.textContent = isExpanded ? str('collapse') : str('expandAll');
1467
+ }
1468
+
1469
+ function checkSummaryOverflow() {
1470
+ const summaryEl = document.getElementById('overviewSummary');
1471
+ const btn = document.getElementById('summaryExpand');
1472
+ if (summaryEl && btn) {
1473
+ btn.hidden = summaryEl.scrollHeight <= summaryEl.clientHeight + 2;
1474
+ }
1475
+ }
1476
+
1477
+ async function onSourceClick(button) {
1478
+ if (!button || button.disabled) return;
1479
+ const originalLabel = button.textContent || str('viewSource');
1480
+ try {
1481
+ const sourceJson = button.getAttribute('data-source');
1482
+ if (!sourceJson) return;
1483
+ const source = JSON.parse(sourceJson);
1484
+ button.disabled = true;
1485
+ button.textContent = str('locatingShort');
1486
+
1487
+ // 1. 优先通过 Sidecar 后台 /api/locate 直达宿主 CDP,等待真实跳转与定位结果
1488
+ let locateHandled = false;
1489
+ try {
1490
+ const resp = await fetch('/api/locate', {
1491
+ method: 'POST',
1492
+ headers: { 'Content-Type': 'application/json' },
1493
+ body: JSON.stringify({ conversationId, source }),
1494
+ });
1495
+ const data = await resp.json().catch(() => null);
1496
+ if (resp.ok && data) {
1497
+ locateHandled = true;
1498
+ if (data.located) {
1499
+ showFeedback(data.message || str('locatedJumpMessage'));
1500
+ return;
1501
+ }
1502
+ showFeedback(data.message || str('locateNotFound'), true);
1503
+ return;
1504
+ }
1505
+ } catch (_) {}
1506
+
1507
+ // 2. Sidecar HTTP 不可用时降级到 Port / Parent 消息通道
1508
+ if (!locateHandled) {
1509
+ let posted = false;
1510
+ if (hostChannelPort) {
1511
+ try {
1512
+ hostChannelPort.postMessage({
1513
+ type: 'AGENT_THINGS_LOCATE',
1514
+ conversationId,
1515
+ source,
1516
+ });
1517
+ posted = true;
1518
+ } catch (_) {}
1519
+ }
1520
+ if (window.parent && window.parent !== window) {
1521
+ try {
1522
+ window.parent.postMessage({
1523
+ type: 'AGENT_THINGS_LOCATE',
1524
+ conversationId,
1525
+ source,
1526
+ }, '*');
1527
+ posted = true;
1528
+ } catch (_) {}
1529
+ }
1530
+ if (posted) {
1531
+ showFeedback(str('locateSent'));
1532
+ return;
1533
+ }
1534
+ }
1535
+
1536
+ showFeedback(str('locateHostUnavailable'), true);
1537
+ } catch (err) {
1538
+ showFeedback(str('locateFailedPrefix') + (err.message || str('unknownActionError')), true);
1539
+ } finally {
1540
+ button.disabled = false;
1541
+ button.textContent = str('viewSource') || originalLabel;
1542
+ }
1543
+ }
1544
+
1545
+ function showFeedback(msg, isError = false) {
1546
+ const el = document.getElementById('feedbackMsg');
1547
+ if (!el) return;
1548
+ el.textContent = msg;
1549
+ el.className = 'feedback-msg ' + (isError ? 'error' : 'success');
1550
+ setTimeout(function() { if (el.textContent === msg) el.textContent = ''; }, 4000);
1551
+ }
1552
+
1553
+ function clearFeedback() {
1554
+ const el = document.getElementById('feedbackMsg');
1555
+ if (el) el.textContent = '';
1556
+ }
1557
+
1558
+ let sseSource = null;
1559
+ let sseReconnectTimer = null;
1560
+ let authTicket = null;
1561
+ let serviceOrigin = connection?.origin || null;
1562
+ const pendingActions = new Map();
1563
+
1564
+ async function sendProxyAction(action, payload = {}) {
1565
+ const res = await fetch('/api/action', {
1566
+ method: 'POST',
1567
+ headers: { 'Content-Type': 'application/json' },
1568
+ body: JSON.stringify({
1569
+ conversationId: conversationId,
1570
+ action: action,
1571
+ payload: payload,
1572
+ })
1573
+ });
1574
+ const data = await res.json();
1575
+ if (!res.ok || data.error) throw new Error(data.error || str('cardOpFailed'));
1576
+ return data;
1577
+ }
1578
+
1579
+ function onIncomingHostMessage(data) {
1580
+ if (!data || typeof data !== 'object') return;
1581
+
1582
+ if (data.type === 'AGENT_THINGS_AUTH_RESPONSE' && data.nonce) {
1583
+ const req = pendingActions.get(data.nonce);
1584
+ if (req) {
1585
+ clearTimeout(req.timer);
1586
+ pendingActions.delete(data.nonce);
1587
+ if (data.origin) serviceOrigin = data.origin;
1588
+ req.resolve(data);
1589
+ }
1590
+ return;
1591
+ }
1592
+
1593
+ if (data.type === 'AGENT_THINGS_ACTION_RESULT' && data.nonce) {
1594
+ const req = pendingActions.get(data.nonce);
1595
+ if (req) {
1596
+ clearTimeout(req.timer);
1597
+ pendingActions.delete(data.nonce);
1598
+ if (data.success) {
1599
+ req.resolve(data.data || {});
1600
+ } else {
1601
+ req.reject(new Error(data.error || str('cardOpFailed')));
1602
+ }
1603
+ }
1604
+ return;
1605
+ }
1606
+ }
1607
+
1608
+ async function requestHostAuth() {
1609
+ try {
1610
+ const res = await fetch('/api/ticket?conversationId=' + encodeURIComponent(conversationId));
1611
+ if (!res.ok) throw new Error(str('cardAuthUnavailable'));
1612
+ return await res.json();
1613
+ } catch (err) {
1614
+ const prefix = activeLang === 'en' ? 'Failed to request event ticket: ' : '申请订阅票据失败: ';
1615
+ throw new Error(prefix + err.message);
1616
+ }
1617
+ }
1618
+
1619
+ window.addEventListener('message', (event) => {
1620
+ try {
1621
+ onIncomingHostMessage(event.data);
1622
+ } catch (_) {}
1623
+ });
1624
+
1625
+ async function onSaveRecord() {
1626
+ const btn = document.getElementById('btnSaveRecord');
1627
+ const noteVal = document.getElementById('txtNote')?.value ?? '';
1628
+ try {
1629
+ if (btn) btn.disabled = true;
1630
+ showFeedback(str('savingFeedback'));
1631
+ const reply = await sendProxyAction('update', {
1632
+ expectedRevision: draftBaseRevision,
1633
+ record: {
1634
+ state: currentState,
1635
+ progress: currentProgress,
1636
+ note: noteVal
1637
+ }
1638
+ });
1639
+ // 修复:sendProxyAction 已解包 data,调用方应读 reply.session.recordRevision
1640
+ const newRev = reply?.session?.recordRevision;
1641
+ if (typeof newRev === 'number') {
1642
+ savedRevision = newRev;
1643
+ draftBaseRevision = newRev;
1644
+ currentRevision = newRev;
1645
+ }
1646
+ isFormDirty = false;
1647
+ hideConflictNotice();
1648
+ showFeedback(str('savedFeedback'));
1649
+ setTimeout(switchToOverview, 600);
1650
+ } catch (err) {
1651
+ const isConflict = err.message && (err.message.includes('其他窗口更新') || err.message.includes('版本已被') || err.message.includes('updated by another') || err.message.includes('409') || err.message.includes('conflict') || err.message.includes('revision mismatch'));
1652
+ if (isConflict) {
1653
+ showConflictNotice(str('conflictBanner'));
1654
+ } else {
1655
+ showFeedback(str('saveFailedPrefix') + err.message, true);
1656
+ }
1657
+ } finally {
1658
+ if (btn) btn.disabled = false;
1659
+ }
1660
+ }
1661
+
1662
+ async function onClearClick() {
1663
+ if (!confirm(str('clearConfirm'))) return;
1664
+ try {
1665
+ showFeedback(str('clearingFeedback'));
1666
+ const reply = await sendProxyAction('clear', {
1667
+ expectedRevision: draftBaseRevision,
1668
+ });
1669
+ const newRev = reply?.session?.recordRevision;
1670
+ if (typeof newRev === 'number') {
1671
+ savedRevision = newRev;
1672
+ draftBaseRevision = newRev;
1673
+ currentRevision = newRev;
1674
+ }
1675
+ isFormDirty = false;
1676
+ hideConflictNotice();
1677
+ showFeedback(str('clearedFeedback'));
1678
+ } catch (err) {
1679
+ showFeedback(str('clearFailedPrefix') + err.message, true);
1680
+ }
1681
+ }
1682
+
1683
+ function handleRemoteSessionUpdate(payload) {
1684
+ if (!payload) return;
1685
+ if (payload.lang) setActiveLang(payload.lang);
1686
+ const s = payload.session || payload;
1687
+ if (s && s.lang) setActiveLang(s.lang);
1688
+ const effectiveProgress = typeof s.progress === 'number' ? s.progress : typeof s.progress?.progress === 'number' ? s.progress.progress : (typeof s === 'number' ? s : null);
1689
+ const effectiveState = s.state || s.progress?.state || (effectiveProgress === 100 ? 'completed' : (effectiveProgress > 0 ? 'unfinished' : 'unstarted'));
1690
+ const effectiveTasks = Array.isArray(s.tasks) ? s.tasks : (Array.isArray(s.progress?.tasks) ? s.progress.tasks : (s.analysis?.ledger?.tasks || []));
1691
+ const effectiveNote = s.note || s.progress?.note || '';
1692
+ const effectiveSummary = s.summary || s.progress?.summary || s.analysis?.ledger?.summary || '';
1693
+ const effectiveTitle = !isGenericTitle(s.title)
1694
+ ? String(s.title).trim()
1695
+ : (!isGenericTitle(s.progress?.title) ? String(s.progress.title).trim() : currentSessionTitle);
1696
+
1697
+ if (typeof s.recordRevision === 'number') savedRevision = Math.max(savedRevision, s.recordRevision);
1698
+ else if (typeof s.progress?.revision === 'number') savedRevision = Math.max(savedRevision, s.progress.revision);
1699
+ else if (typeof s.revision === 'number') savedRevision = Math.max(savedRevision, s.revision);
1700
+
1701
+ // 若未处于草稿编辑中,基准版本与当前展示版本同步更新
1702
+ if (!isFormDirty) {
1703
+ currentRevision = savedRevision;
1704
+ draftBaseRevision = savedRevision;
1705
+ }
1706
+
1707
+ const analyzing = Boolean(s.analyzing || s.analysisStatus?.status === 'pending');
1708
+ const analysisStatus = s.analysisStatus;
1709
+ const btnAnalyze = document.getElementById('btnAnalyze');
1710
+ if (btnAnalyze) {
1711
+ if (analyzing) {
1712
+ btnAnalyze.disabled = true;
1713
+ btnAnalyze.textContent = str('btnUpdating');
1714
+ } else {
1715
+ btnAnalyze.disabled = false;
1716
+ btnAnalyze.textContent = str('btnUpdate');
1717
+ if (analysisStatus?.status === 'failed') {
1718
+ showFeedback(str('analysisNotDonePrefix') + (analysisStatus.error || str('analysisAbnormal')), true);
1719
+ }
1720
+ }
1721
+ }
1722
+
1723
+ // 仅在非 dirty 编辑态下将远端状态刷入表单与展示
1724
+ if (!isFormDirty) {
1725
+ applyFullProgressToUI({
1726
+ state: effectiveState,
1727
+ progress: effectiveProgress,
1728
+ tasks: effectiveTasks,
1729
+ note: effectiveNote,
1730
+ summary: effectiveSummary,
1731
+ title: effectiveTitle,
1732
+ revision: currentRevision,
1733
+ updatedAt: s.updatedAt || s.progress?.updatedAt,
1734
+ });
1735
+ }
1736
+ }
1737
+
1738
+ function applyFullProgressToUI(data) {
1739
+ if (!data) return;
1740
+ lastRenderedData = data;
1741
+ currentRevision = data.revision ?? currentRevision;
1742
+ const nextState = data.state || (data.progress === 100 ? 'completed' : data.progress > 0 ? 'unfinished' : 'unstarted');
1743
+ const nextProgress = data.progress ?? null;
1744
+
1745
+ if (!isFormDirty) {
1746
+ currentState = nextState;
1747
+ currentProgress = nextProgress;
1748
+ updateProgressVal(currentProgress);
1749
+ selectState(currentState, true);
1750
+ const noteInput = document.getElementById('txtNote');
1751
+ if (noteInput) noteInput.value = data.note || '';
1752
+ const noteOpenLabel = document.getElementById('noteOpenLabel');
1753
+ if (noteOpenLabel) noteOpenLabel.textContent = data.note ? str('editLabel') : str('addLabel');
1754
+ }
1755
+
1756
+ applyCardTitle(data.title);
1757
+
1758
+ const scoreEl = document.getElementById('overviewScoreNumber');
1759
+ if (scoreEl) scoreEl.textContent = currentProgress !== null ? currentProgress : '—';
1760
+ const scoreUnit = document.querySelector('.score-unit');
1761
+ if (scoreUnit) scoreUnit.hidden = currentProgress === null;
1762
+
1763
+ const labelEl = document.getElementById('overviewStatusLabel');
1764
+ if (labelEl) labelEl.textContent = labels[currentState] || currentState;
1765
+ const dotEl = document.getElementById('overviewDot');
1766
+ if (dotEl) {
1767
+ dotEl.style.borderColor = colors[currentState] || colors.unstarted;
1768
+ dotEl.style.background = 'transparent';
1769
+ }
1770
+
1771
+ const timeEl = document.getElementById('overviewTimestamp');
1772
+ if (timeEl) {
1773
+ const rawTime = data.updatedAt || data.progress?.updatedAt;
1774
+ if (rawTime) {
1775
+ const d = new Date(rawTime);
1776
+ if (!isNaN(d.getTime())) {
1777
+ const m = d.getMonth() + 1;
1778
+ const day = d.getDate();
1779
+ const h = String(d.getHours()).padStart(2, '0');
1780
+ const min = String(d.getMinutes()).padStart(2, '0');
1781
+ timeEl.textContent = `${m}/${day} ${h}:${min}`;
1782
+ } else {
1783
+ timeEl.textContent = '--/-- --:--';
1784
+ }
1785
+ } else {
1786
+ timeEl.textContent = '--/-- --:--';
1787
+ }
1788
+ }
1789
+
1790
+ const meterEl = document.getElementById('overviewMeter');
1791
+ if (meterEl) {
1792
+ const prog = currentProgress != null ? Math.max(0, Math.min(100, currentProgress)) : 0;
1793
+ meterEl.style.setProperty('--fill', prog + '%');
1794
+ meterEl.style.setProperty('--mark', colors[currentState] || colors.unstarted);
1795
+ }
1796
+
1797
+ const totalCount = data.totalTasks ?? data.tasks?.length ?? 0;
1798
+ const doneCount = data.completedTasks ?? data.tasks?.filter(function(t) { return t.status === 'done'; }).length ?? 0;
1799
+ const totalsEl = document.getElementById('overviewTotals');
1800
+ if (totalsEl) {
1801
+ totalsEl.textContent = totalCount > 0 ? str('totalsPattern', { done: doneCount, total: totalCount }) : str('noTasksYet');
1802
+ }
1803
+
1804
+ const summaryText = data.summary || data.note || '';
1805
+ const summaryEl = document.getElementById('overviewSummary');
1806
+ if (summaryEl) {
1807
+ summaryEl.textContent = summaryText || str('unrecordedSummary');
1808
+ }
1809
+ checkSummaryOverflow();
1810
+
1811
+ const titleProgress = document.getElementById('titleProgress');
1812
+ if (titleProgress) {
1813
+ const color = colors[currentState] || colors.unstarted;
1814
+ const hasProgress = currentProgress !== null && currentProgress !== undefined && Number.isFinite(currentProgress);
1815
+ const progVal = hasProgress ? Math.max(0, Math.min(100, currentProgress)) : 0;
1816
+
1817
+ let piePath = '';
1818
+ if (hasProgress && progVal > 0) {
1819
+ const angle = (progVal / 100) * Math.PI * 2;
1820
+ const x = (12 + 7.4 * Math.sin(angle)).toFixed(2);
1821
+ const y = (12 - 7.4 * Math.cos(angle)).toFixed(2);
1822
+ piePath = progVal === 100
1823
+ ? '<path d="M12 4.6a7.4 7.4 0 1 1 0 14.8a7.4 7.4 0 1 1 0-14.8" fill="' + color + '" class="progress-pie"/>'
1824
+ : '<path d="M12 12L12 4.6A7.4 7.4 0 ' + (progVal > 50 ? 1 : 0) + ' 1 ' + x + ' ' + y + 'Z" fill="' + color + '" class="progress-pie"/>';
1825
+ }
1826
+
1827
+ const isHundred = progVal === 100;
1828
+ const fontSize = isHundred ? '5.8px' : '6.4px';
1829
+ const letterSpacing = isHundred ? '-0.3px' : '-0.2px';
1830
+
1831
+ titleProgress.innerHTML = '<svg viewBox="0 0 24 24" width="32" height="32" aria-hidden="true" style="overflow:visible">' +
1832
+ '<circle cx="12" cy="12" r="10" fill="none" stroke="' + color + '" stroke-width="1.6" opacity="' + (hasProgress ? '1' : '0.85') + '"/>' +
1833
+ piePath +
1834
+ '<text x="12" y="12.4" text-anchor="middle" dominant-baseline="middle" fill="' + color + '" class="' + (hasProgress ? '' : 'progress-unknown') + '" style="font:600 ' + fontSize + ' -apple-system,BlinkMacSystemFont,sans-serif;letter-spacing:' + letterSpacing + ';font-variant-numeric:tabular-nums">' + (hasProgress ? (progVal + '%') : '—') + '</text>' +
1835
+ '</svg>';
1836
+ }
1837
+
1838
+ if (Array.isArray(data.tasks)) {
1839
+ const remaining = data.tasks.filter(function(t) { return t.status !== 'done'; });
1840
+ const completed = data.tasks.filter(function(t) { return t.status === 'done'; });
1841
+
1842
+ const remainingHeading = document.getElementById('remainingTasksHeading');
1843
+ if (remainingHeading) remainingHeading.textContent = str('remainingHeadingPattern', { count: remaining.length });
1844
+
1845
+ const toggleBtn = document.getElementById('btnToggleAllRemaining');
1846
+ if (toggleBtn) {
1847
+ toggleBtn.hidden = remaining.length <= 3;
1848
+ toggleBtn.textContent = str('showAllCountPattern', { count: remaining.length });
1849
+ toggleBtn.setAttribute('data-expanded', 'false');
1850
+ }
1851
+
1852
+ const historyCount = document.getElementById('historyCount');
1853
+ if (historyCount) historyCount.textContent = str('countArrowPattern', { count: completed.length });
1854
+
1855
+ const uncompletedList = document.getElementById('uncompletedTasksList');
1856
+ if (uncompletedList) {
1857
+ let html = '';
1858
+ if (data.tasks.length === 0) {
1859
+ html = '<div class="empty">' + escapeHtml(str('emptyNoTasks')) + '</div>';
1860
+ } else if (remaining.length === 0) {
1861
+ html = '<div class="empty">' + escapeHtml(str('emptyNoRemaining')) + '</div>';
1862
+ }
1863
+ html += remaining.map(function(task, idx) {
1864
+ const hasSource = task.source && task.source.locator;
1865
+ const badge = taskLabels[task.status] || task.status;
1866
+ return '<div class="task-row ' + (idx >= 3 ? 'remaining-hidden' : '') + '" data-status="' + escapeHtml(task.status) + '" ' + (hasSource ? 'tabindex="0" ' : '') + (idx >= 3 ? 'hidden' : '') + '>' +
1867
+ '<span class="task-dot"></span>' +
1868
+ '<div class="task-content">' +
1869
+ '<div class="task-title">' + escapeHtml(task.title || task.summary || str('untitledTask')) + '</div>' +
1870
+ '<div class="task-meta">' + escapeHtml(badge) + '</div>' +
1871
+ '</div>' +
1872
+ (hasSource ? '<div class="task-source"><button type="button" data-source="' + escapeHtml(JSON.stringify(task.source)) + '" onclick="onSourceClick(this)">' + escapeHtml(str('viewSource')) + '</button></div>' : '') +
1873
+ '</div>';
1874
+ }).join('');
1875
+ uncompletedList.innerHTML = html;
1876
+ }
1877
+
1878
+ const historyList = document.getElementById('historyList');
1879
+ if (historyList) {
1880
+ let html = '';
1881
+ if (completed.length === 0) {
1882
+ html = '<div class="empty">' + escapeHtml(str('emptyCompleted')) + '</div>';
1883
+ }
1884
+ html += completed.map(function(task, idx) {
1885
+ const hasSource = task.source && task.source.locator;
1886
+ return '<div class="task-row" data-status="done"' + (hasSource ? ' tabindex="0"' : '') + '>' +
1887
+ '<span class="task-dot"></span>' +
1888
+ '<div class="task-content">' +
1889
+ '<div class="task-title">' + escapeHtml(task.title || task.summary || str('completedTaskFallback')) + '</div>' +
1890
+ '<div class="task-meta">' + escapeHtml(taskLabels.done || str('completedShort')) + '</div>' +
1891
+ '</div>' +
1892
+ (hasSource ? '<div class="task-source"><button type="button" data-source="' + escapeHtml(JSON.stringify(task.source)) + '" onclick="onSourceClick(this)">' + escapeHtml(str('viewSource')) + '</button></div>' : '') +
1893
+ '</div>';
1894
+ }).join('');
1895
+ historyList.innerHTML = html;
1896
+ }
1897
+ }
1898
+
1899
+ if (hostChannelPort) {
1900
+ try {
1901
+ hostChannelPort.postMessage({
1902
+ type: 'AGENT_THINGS_CARD_UPDATED',
1903
+ conversationId: conversationId,
1904
+ progress: currentProgress,
1905
+ revision: currentRevision,
1906
+ state: currentState,
1907
+ });
1908
+ } catch (_) {}
1909
+ }
1910
+ }
1911
+
1912
+ async function onAnalyzeClick() {
1913
+ const btn = document.getElementById('btnAnalyze');
1914
+ try {
1915
+ if (btn) {
1916
+ btn.disabled = true;
1917
+ btn.textContent = str('btnUpdating');
1918
+ }
1919
+ showFeedback(str('startingAnalysisFeedback'));
1920
+ await sendProxyAction('analyze', {});
1921
+ } catch (err) {
1922
+ showFeedback(str('updateFailedPrefix') + err.message, true);
1923
+ if (btn) {
1924
+ btn.disabled = false;
1925
+ btn.textContent = str('btnUpdate');
1926
+ }
1927
+ }
1928
+ }
1929
+
1930
+ async function initEventStream() {
1931
+ if (sseReconnectTimer) {
1932
+ clearTimeout(sseReconnectTimer);
1933
+ sseReconnectTimer = null;
1934
+ }
1935
+ if (sseSource) {
1936
+ try { sseSource.close(); } catch (_) {}
1937
+ sseSource = null;
1938
+ }
1939
+
1940
+ try {
1941
+ const auth = await requestHostAuth();
1942
+ if (!auth?.ticket || !auth?.origin) {
1943
+ scheduleReconnect();
1944
+ return;
1945
+ }
1946
+ authTicket = auth.ticket;
1947
+ serviceOrigin = auth.origin;
1948
+
1949
+ const sseUrl = auth.origin + '/session/events?id=' + encodeURIComponent(conversationId) + '&ticket=' + encodeURIComponent(auth.ticket);
1950
+ const es = new EventSource(sseUrl);
1951
+ sseSource = es;
1952
+
1953
+ es.addEventListener('snapshot', function(ev) {
1954
+ try {
1955
+ const data = JSON.parse(ev.data);
1956
+ handleRemoteSessionUpdate(data);
1957
+ } catch (_) {}
1958
+ });
1959
+
1960
+ es.addEventListener('change', function(ev) {
1961
+ try {
1962
+ const data = JSON.parse(ev.data);
1963
+ handleRemoteSessionUpdate(data);
1964
+ } catch (_) {}
1965
+ });
1966
+
1967
+ es.onerror = function() {
1968
+ try { es.close(); } catch (_) {}
1969
+ sseSource = null;
1970
+ scheduleReconnect();
1971
+ };
1972
+ } catch (_) {
1973
+ scheduleReconnect();
1974
+ }
1975
+ }
1976
+
1977
+ function scheduleReconnect() {
1978
+ if (sseReconnectTimer) return;
1979
+ sseReconnectTimer = setTimeout(function() {
1980
+ sseReconnectTimer = null;
1981
+ initEventStream();
1982
+ }, 2000);
1983
+ }
1984
+
1985
+ function setupScrollListener() {
1986
+ const panel = document.getElementById('panelBody');
1987
+ const shell = document.getElementById('agentThingsCard');
1988
+ if (!panel || !shell) return;
1989
+ panel.addEventListener('scroll', function() {
1990
+ const isScrolled = panel.scrollTop > 8;
1991
+ shell.classList.toggle('is-scrolled', isScrolled);
1992
+ }, { passive: true });
1993
+ }
1994
+
1995
+
1996
+ function syncThemeWithHost() {
1997
+ try {
1998
+ const bg = getComputedStyle(document.documentElement).getPropertyValue('--background').trim();
1999
+ const fg = getComputedStyle(document.documentElement).getPropertyValue('--foreground').trim();
2000
+ const mutedFg = getComputedStyle(document.documentElement).getPropertyValue('--muted-foreground').trim();
2001
+
2002
+ let isLight = false;
2003
+ if (bg) {
2004
+ if (bg.startsWith('#') && bg.length >= 7) {
2005
+ const r = parseInt(bg.slice(1, 3), 16), g = parseInt(bg.slice(3, 5), 16), b = parseInt(bg.slice(5, 7), 16);
2006
+ if ((0.299 * r + 0.587 * g + 0.114 * b) > 130) isLight = true;
2007
+ } else if (bg.startsWith('rgb')) {
2008
+ const m = bg.match(/\d+/g);
2009
+ if (m && m.length >= 3 && (0.299 * m[0] + 0.587 * m[1] + 0.114 * m[2]) > 130) isLight = true;
2010
+ }
2011
+ }
2012
+
2013
+ const root = document.documentElement;
2014
+ if (isLight) {
2015
+ root.style.setProperty('--at-ink', fg || '#22272e');
2016
+ root.style.setProperty('--at-secondary', mutedFg || '#576374');
2017
+ root.style.setProperty('--at-muted', '#667383');
2018
+ root.style.setProperty('--at-note', '#46515f');
2019
+ root.style.setProperty('--at-panel-bg', '#ffffff');
2020
+ root.style.setProperty('--at-line', '#dfe4ea');
2021
+ root.style.setProperty('--at-track', '#c3ccd6');
2022
+ root.style.setProperty('--at-input-border', '#c7d0da');
2023
+ root.style.setProperty('--at-input-bg', '#f6f8fa');
2024
+ root.style.setProperty('--at-hover', '#f3f4f6');
2025
+ root.style.setProperty('--at-source-bg', '#f6f8fa');
2026
+ root.style.setProperty('color-scheme', 'light');
2027
+ } else {
2028
+ root.style.setProperty('--at-ink', fg || '#e6edf3');
2029
+ root.style.setProperty('--at-secondary', '#a0a6ad');
2030
+ root.style.setProperty('--at-muted', '#828c96');
2031
+ root.style.setProperty('--at-note', '#bbc3ca');
2032
+ root.style.setProperty('--at-panel-bg', '#0e1318');
2033
+ root.style.setProperty('--at-line', '#ffffff14');
2034
+ root.style.setProperty('--at-track', '#ffffff12');
2035
+ root.style.setProperty('--at-input-border', '#ffffff18');
2036
+ root.style.setProperty('--at-input-bg', '#ffffff03');
2037
+ root.style.setProperty('--at-hover', '#ffffff09');
2038
+ root.style.setProperty('--at-source-bg', '#ffffff0a');
2039
+ root.style.setProperty('color-scheme', 'dark');
2040
+ }
2041
+ } catch (_) {}
2042
+ }
2043
+
2044
+ function resetToEmptySession(nextTitle) {
2045
+ isFormDirty = false;
2046
+ hideConflictNotice();
2047
+ if (nextTitle !== undefined && !isGenericTitle(nextTitle)) {
2048
+ currentSessionTitle = String(nextTitle).trim();
2049
+ }
2050
+ applyFullProgressToUI({
2051
+ state: 'unstarted',
2052
+ progress: null,
2053
+ tasks: [],
2054
+ note: '',
2055
+ summary: str('unrecordedSummary'),
2056
+ title: currentSessionTitle || str('defaultSessionTitle'),
2057
+ revision: 0,
2058
+ updatedAt: null,
2059
+ });
2060
+ const noteInput = document.getElementById('txtNote');
2061
+ if (noteInput) noteInput.value = '';
2062
+ }
2063
+
2064
+ function switchConversation(newId, incomingTitle) {
2065
+ const cleanId = (newId || '').trim();
2066
+ if (!cleanId) return;
2067
+ if (cleanId === conversationId) {
2068
+ if (!isGenericTitle(incomingTitle)) applyCardTitle(incomingTitle);
2069
+ return;
2070
+ }
2071
+ conversationId = cleanId;
2072
+ currentSessionTitle = !isGenericTitle(incomingTitle) ? String(incomingTitle).trim() : '';
2073
+ resetToEmptySession(currentSessionTitle);
2074
+ if (sseSource) {
2075
+ try { sseSource.close(); } catch (_) {}
2076
+ sseSource = null;
2077
+ }
2078
+ fetchSessionSnapshot(conversationId);
2079
+ initEventStream();
2080
+ }
2081
+
2082
+ window.addEventListener('message', (ev) => {
2083
+ if (ev.data?.type === 'theme-change') {
2084
+ setTimeout(syncThemeWithHost, 50);
2085
+ }
2086
+ if (ev.data?.type === 'ANTIGRAVITY_CONVERSATION_CHANGED' || ev.data?.type === 'conversation-change') {
2087
+ const newId = (ev.data?.conversationId || ev.data?.id || '').trim();
2088
+ const incomingTitle = typeof ev.data?.title === 'string' ? ev.data.title.trim() : '';
2089
+ if (newId) {
2090
+ switchConversation(newId, incomingTitle);
2091
+ }
2092
+ }
2093
+ });
2094
+
2095
+ async function fetchSessionSnapshot(convId) {
2096
+ const targetId = convId || conversationId;
2097
+ if (!targetId) return;
2098
+ try {
2099
+ const res = await fetch('/api/session?conversationId=' + encodeURIComponent(targetId));
2100
+ if (res.ok) {
2101
+ const data = await res.json();
2102
+ if (data?.lang) setActiveLang(data.lang);
2103
+ if (data && data.session) {
2104
+ const mergedTitle = !isGenericTitle(data.session.title) ? data.session.title : data.title;
2105
+ handleRemoteSessionUpdate({ ...data.session, title: mergedTitle, lang: data.lang || data.session.lang });
2106
+ } else {
2107
+ resetToEmptySession(data?.title);
2108
+ }
2109
+ } else {
2110
+ resetToEmptySession();
2111
+ }
2112
+ } catch (_) {
2113
+ resetToEmptySession();
2114
+ }
2115
+ }
2116
+
2117
+ function initCard() {
2118
+ applyStaticLanguage();
2119
+ syncThemeWithHost();
2120
+ checkSummaryOverflow();
2121
+ setupScrollListener();
2122
+ fetchSessionSnapshot(conversationId);
2123
+ initEventStream();
2124
+
2125
+ // 当在 Antigravity 切换对话时自动刷新对应会话状态
2126
+ setInterval(() => {
2127
+ const currentActive = (window.sidecar?.conversationId || new URLSearchParams(window.location.search).get("conversationId") || "").trim();
2128
+ if (currentActive && currentActive !== conversationId) {
2129
+ switchConversation(currentActive);
2130
+ }
2131
+ }, 1000);
2132
+ }
2133
+
2134
+ if (document.readyState === 'loading') {
2135
+ document.addEventListener('DOMContentLoaded', initCard);
2136
+ } else {
2137
+ initCard();
2138
+ }
2139
+ </script>
2140
+ </body>
2141
+ </html>