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.
- package/LICENSE +21 -0
- package/NOTICE +5 -0
- package/README.md +221 -2
- package/README.zh-CN.md +222 -0
- package/bin/agent-things.cjs +8 -0
- package/bin/antigravity-session-status.cjs +96 -0
- package/bin/claude-session-status.cjs +55 -0
- package/bin/codex-session-status.cjs +287 -0
- package/mods/agent-things-ui/.claude-plugin/plugin.json +12 -0
- package/mods/agent-things-ui/SKILL.md +10 -0
- package/mods/agent-things-ui/hooks/controls.js +112 -0
- package/mods/agent-things-ui/hooks/foundation.js +431 -0
- package/mods/agent-things-ui/hooks/hooks.json +1 -0
- package/mods/agent-things-ui/hooks/presentation.js +223 -0
- package/mods/agent-things-ui/hooks/progress.js +1 -0
- package/mods/agent-things-ui/hooks/register.js +382 -0
- package/native/bin/bridge +0 -0
- package/native/bin/bridge.json +20 -0
- package/native/session-status-bridge.swift +280 -0
- package/outputs/antigravity-session-status.js +2476 -0
- package/outputs/codex-session-status.js +1761 -0
- package/package.json +75 -4
- package/scripts/build-antigravity-bundle.cjs +35 -0
- package/scripts/build-codex-bundle.cjs +31 -0
- package/scripts/build-native-bridge.cjs +55 -0
- package/scripts/build-shared-ui.cjs +16 -0
- package/scripts/setup-antigravity-service.cjs +71 -0
- package/scripts/setup-claude-service.cjs +21 -0
- package/skills/agent-things/SKILL.en.md +95 -0
- package/skills/agent-things/SKILL.md +99 -0
- package/skills/codex/things/SKILL.en.md +10 -0
- package/skills/codex/things/SKILL.md +10 -0
- package/skills/things/SKILL.en.md +10 -0
- package/skills/things/SKILL.md +10 -0
- package/skills/things/checklist.en.md +91 -0
- package/skills/things/checklist.md +95 -0
- package/src/analysis-app-server.cjs +74 -0
- package/src/analysis-assets/output.en.schema.json +93 -0
- package/src/analysis-assets/output.schema.json +93 -0
- package/src/analysis-assets/prompt.en.txt +17 -0
- package/src/analysis-assets/prompt.zh-CN.txt +18 -0
- package/src/analysis-budget.cjs +105 -0
- package/src/analysis-git.cjs +38 -0
- package/src/analysis-history.cjs +150 -0
- package/src/analysis-ledger.cjs +82 -0
- package/src/analysis-log.cjs +62 -0
- package/src/analysis-runner.cjs +203 -0
- package/src/analysis-service.cjs +197 -0
- package/src/analysis-source.cjs +72 -0
- package/src/antigravity-card.cjs +2063 -0
- package/src/antigravity-hook.cjs +138 -0
- package/src/antigravity-mcp-config.cjs +36 -0
- package/src/app-server.cjs +96 -0
- package/src/cdp.cjs +115 -0
- package/src/claude-inline-install.cjs +38 -0
- package/src/claude-mcp-config.cjs +29 -0
- package/src/cli/arguments.cjs +30 -0
- package/src/cli/environment-probe.cjs +130 -0
- package/src/cli/integration-state.cjs +15 -0
- package/src/cli/interactive-cli.cjs +236 -0
- package/src/cli/prompt-tui.cjs +420 -0
- package/src/cli/setup-orchestrator.cjs +449 -0
- package/src/codex-mcp-config.cjs +67 -0
- package/src/harnesses/antigravity/analysis-profile.cjs +41 -0
- package/src/harnesses/antigravity/antigravity-git.cjs +89 -0
- package/src/harnesses/antigravity/antigravity-harness.js +1477 -0
- package/src/harnesses/antigravity/antigravity-injector.cjs +104 -0
- package/src/harnesses/antigravity/antigravity-migration.cjs +235 -0
- package/src/harnesses/antigravity/antigravity-service.cjs +357 -0
- package/src/harnesses/antigravity/antigravity-title.cjs +155 -0
- package/src/harnesses/antigravity/gemini-runner.cjs +304 -0
- package/src/harnesses/antigravity/transcript-cleaner.cjs +129 -0
- package/src/harnesses/antigravity/transcript-source.cjs +100 -0
- package/src/harnesses/claude/claude-harness.js +93 -0
- package/src/harnesses/claude/claude-host-helper.cjs +176 -0
- package/src/harnesses/claude/claude-injector.cjs +95 -0
- package/src/harnesses/claude/claude-local-source.cjs +106 -0
- package/src/harnesses/claude/claude-navigation.cjs +99 -0
- package/src/harnesses/claude/claude-runner.cjs +74 -0
- package/src/harnesses/claude/claude-service.cjs +313 -0
- package/src/harnesses/claude/claude-source.cjs +70 -0
- package/src/harnesses/codex/codex-analysis.cjs +10 -0
- package/src/harnesses/codex/codex-card-bridge.js +123 -0
- package/src/harnesses/codex/codex-card-events.cjs +76 -0
- package/src/harnesses/codex/codex-card.cjs +169 -0
- package/src/harnesses/codex/codex-git.cjs +24 -0
- package/src/harnesses/codex/codex-harness.js +229 -0
- package/src/harnesses/codex/codex-local-card.js +97 -0
- package/src/harnesses/codex/codex-progress-context.cjs +84 -0
- package/src/harnesses/codex/codex-service.cjs +502 -0
- package/src/i18n.cjs +174 -0
- package/src/launchd.cjs +105 -0
- package/src/lifecycle-lock.cjs +13 -0
- package/src/local-progress-http.cjs +267 -0
- package/src/manual-status-agent.cjs +12 -0
- package/src/manual-status-startup.cjs +66 -0
- package/src/manual-status-store.cjs +466 -0
- package/src/mcp-stdio.cjs +67 -0
- package/src/model-router.cjs +63 -0
- package/src/native-bridge.cjs +17 -0
- package/src/npm-updates.cjs +228 -0
- package/src/plugins/things/assets/logo.svg +13 -0
- package/src/plugins/things/plugin.json +6 -0
- package/src/plugins/things/sidecars/things_board/app.js +447 -0
- package/src/plugins/things/sidecars/things_board/index.html +2141 -0
- package/src/plugins/things/sidecars/things_board/main.mjs +652 -0
- package/src/plugins/things/sidecars/things_board/package.json +6 -0
- package/src/plugins/things/sidecars/things_board/sidecar.json +21 -0
- package/src/plugins/things/sidecars/things_board/styles.css +560 -0
- package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +434 -0
- package/src/progress-error.cjs +54 -0
- package/src/progress-tools.cjs +145 -0
- package/src/project-path.cjs +15 -0
- package/src/renderer-resource.cjs +17 -0
- package/src/request-budget.cjs +24 -0
- package/src/resolve.cjs +51 -0
- package/src/runtime-install.cjs +635 -0
- package/src/session-status-filter.cjs +136 -0
- package/src/session-status.js +992 -0
- package/src/session-view.cjs +34 -0
- package/src/startup/controller.cjs +354 -0
- package/src/startup/watch.cjs +126 -0
- package/src/state-file-lock.cjs +31 -0
- package/src/task-provenance.cjs +42 -0
- package/src/ui-foundation.cjs +435 -0
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
/* Manual session marks. Loaded in a dedicated CDP isolated world. */
|
|
2
|
+
function installCodexSessionStatus(version, restored, embedded) {
|
|
3
|
+
if (window.__codexSessionStatus && !embedded?.independent) return;
|
|
4
|
+
const harness = embedded?.independent ? null : window.__sessionStatusHarness || null;
|
|
5
|
+
let localCards = null;
|
|
6
|
+
const send = payload => {
|
|
7
|
+
if (embedded) embedded.send(payload);
|
|
8
|
+
else if (harness?.send) harness.send(payload);
|
|
9
|
+
else window.__codexSessionStatusSend(payload);
|
|
10
|
+
};
|
|
11
|
+
const presentation = window.__agentThingsPresentation;
|
|
12
|
+
let activeLang = embedded?.lang || embedded?.snapshot?.lang || window.__agentThingsConnection?.lang || window.__agentThingsLang || presentation?.lang || 'zh';
|
|
13
|
+
let ui = presentation?.forLang ? presentation.forLang(activeLang) : null;
|
|
14
|
+
let strings = ui?.strings || presentation?.strings || {};
|
|
15
|
+
let labels = ui?.labels || presentation?.labels || {
|
|
16
|
+
unstarted: '尚未开始', unfinished: '有遗留事项', completed: '全部完成', pushed: '全部完成并已推送',
|
|
17
|
+
};
|
|
18
|
+
let taskLabels = ui?.taskLabels || presentation?.taskLabels || {
|
|
19
|
+
todo: '待开始', in_progress: '进行中', blocked: '受阻', needs_verification: '待验收', done: '已完成',
|
|
20
|
+
};
|
|
21
|
+
const S = (key, vars) => (ui?.t ? ui.t(key, vars) : (strings[key] || key));
|
|
22
|
+
const setLang = nextLang => {
|
|
23
|
+
const resolved = nextLang === 'en' ? 'en' : nextLang === 'zh' ? 'zh' : activeLang;
|
|
24
|
+
if (!presentation?.forLang || (resolved === activeLang && ui)) return false;
|
|
25
|
+
activeLang = resolved;
|
|
26
|
+
ui = presentation.forLang(activeLang);
|
|
27
|
+
strings = ui.strings;
|
|
28
|
+
labels = ui.labels;
|
|
29
|
+
taskLabels = ui.taskLabels;
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
const colors = presentation?.colors || { unstarted: '#9098a2', unfinished: '#c89b38', completed: '#548eea', pushed: '#a17be3' };
|
|
33
|
+
let snapshot = { revision: 0, records: {} };
|
|
34
|
+
const mounted = new Map();
|
|
35
|
+
const pending = new Map();
|
|
36
|
+
const panelStates = new Map(restored?.panelStates || []);
|
|
37
|
+
let panel = null;
|
|
38
|
+
let serial = 0;
|
|
39
|
+
const requestPrefix = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
40
|
+
let frame = 0;
|
|
41
|
+
let destroyed = false;
|
|
42
|
+
const startup = { installedAt: Date.now(), sidebarReadyAt: null, badgesReadyAt: null };
|
|
43
|
+
function measureStartup() {
|
|
44
|
+
if (startup.badgesReadyAt !== null) return;
|
|
45
|
+
const rows = harness?.startupRows ? harness.startupRows().filter(visible)
|
|
46
|
+
: [...document.querySelectorAll('[data-app-action-sidebar-project-list-id] [data-app-action-sidebar-thread-row]')].filter(row => ['local', 'remote'].includes(row.getAttribute('data-app-action-sidebar-thread-kind')) && visible(row));
|
|
47
|
+
if (!rows.length) return;
|
|
48
|
+
startup.sidebarReadyAt ??= Date.now();
|
|
49
|
+
if (rows.every(row => row.querySelector('[data-codex-session-status]'))) startup.badgesReadyAt = Date.now();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function rememberPanel(target) {
|
|
53
|
+
const active = target.root.shadowRoot.activeElement;
|
|
54
|
+
const state = { key: target.entry.key, mode: target.mode, dirty: target.dirty, revision: target.revision,
|
|
55
|
+
note: target.note.value, progress: target.progress.value, draft: { ...target.draft },
|
|
56
|
+
remainingExpanded: target.remainingExpanded, scrollTop: target.body.scrollTop,
|
|
57
|
+
noteScrollTop: target.note.scrollTop, selectionStart: target.note.selectionStart, selectionEnd: target.note.selectionEnd,
|
|
58
|
+
focus: active === target.note ? 'note' : active === target.progress ? 'progress' : null,
|
|
59
|
+
error: target.error.textContent, conflict: target.conflict };
|
|
60
|
+
panelStates.set(target.entry.key, state);
|
|
61
|
+
try { sessionStorage.setItem(`codex-session-status-panel:v1:${target.entry.key}`, JSON.stringify(state)); } catch { /* Keep the in-memory copy when storage is unavailable. */ }
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function rememberedPanel(key) {
|
|
66
|
+
if (panelStates.has(key)) return panelStates.get(key);
|
|
67
|
+
try {
|
|
68
|
+
const state = JSON.parse(sessionStorage.getItem(`codex-session-status-panel:v1:${key}`));
|
|
69
|
+
if (state && ['overview', 'edit', 'history'].includes(state.mode)) { panelStates.set(key, state); return state; }
|
|
70
|
+
} catch { /* Start from the current saved record if a browser cache cannot be read. */ }
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function restorePanel(target, state) {
|
|
75
|
+
target.remainingExpanded = state.remainingExpanded;
|
|
76
|
+
if (state.dirty) {
|
|
77
|
+
target.dirty = true; target.revision = state.revision;
|
|
78
|
+
target.draft = state.draft || { state: recordFor(state.key)?.state || 'unfinished',
|
|
79
|
+
progress: state.progress === '' ? null : Number(state.progress), note: state.note || '' };
|
|
80
|
+
target.note.value = state.note; updateDraft(target, target.draft); target.progress.value = state.progress;
|
|
81
|
+
}
|
|
82
|
+
target.restoreScroll = state.scrollTop || 0;
|
|
83
|
+
target.setView(state.mode || (state.dirty ? 'edit' : 'overview'));
|
|
84
|
+
target.error.textContent = state.error || '';
|
|
85
|
+
target.conflict = Boolean(state.dirty && state.conflict);
|
|
86
|
+
target.resolveConflict.hidden = !target.conflict;
|
|
87
|
+
if (target.mode === 'edit') {
|
|
88
|
+
if (state.focus === 'note') {
|
|
89
|
+
target.note.focus({ preventScroll: true });
|
|
90
|
+
target.note.setSelectionRange(state.selectionStart ?? target.note.value.length, state.selectionEnd ?? target.note.value.length);
|
|
91
|
+
} else if (state.focus === 'progress') target.progress.focus({ preventScroll: true });
|
|
92
|
+
target.note.scrollTop = state.noteScrollTop || 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function panelEvent(action, entry) {
|
|
97
|
+
try { send(JSON.stringify({ type: 'panel-event', action,
|
|
98
|
+
requestId: `${requestPrefix}:${++serial}`, key: entry.key })); } catch { /* Diagnostic only. */ }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function element(tag, text, parent, className) {
|
|
102
|
+
const node = document.createElement(tag);
|
|
103
|
+
if (text != null) node.textContent = text;
|
|
104
|
+
if (className) node.className = className;
|
|
105
|
+
parent?.append(node);
|
|
106
|
+
return node;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function recordFor(key) {
|
|
110
|
+
const record = snapshot.records[key];
|
|
111
|
+
return record?.state ? record : null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function summary(key) {
|
|
115
|
+
const record = recordFor(key);
|
|
116
|
+
if (!record) return S('badgeNotOrganized');
|
|
117
|
+
return `${labels[record.state]}${record.progress === null ? S('badgeProgressUnrecordedSuffix') : ` · ${record.progress}%`}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function makeRing(button, record, pie = false, loading = false) {
|
|
121
|
+
button.replaceChildren();
|
|
122
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
123
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
124
|
+
svg.setAttribute('width', '24'); svg.setAttribute('height', '24');
|
|
125
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
126
|
+
if (loading) {
|
|
127
|
+
svg.setAttribute('class', 'loading');
|
|
128
|
+
const circle = document.createElementNS(svg.namespaceURI, 'circle');
|
|
129
|
+
for (const [name, value] of Object.entries({ cx: 12, cy: 12, r: 10, fill: 'none', stroke: '#0169cc', 'stroke-width': 1.6, 'stroke-dasharray': '42 63', 'stroke-linecap': 'round' })) circle.setAttribute(name, value);
|
|
130
|
+
svg.append(circle); button.append(svg); return;
|
|
131
|
+
}
|
|
132
|
+
const color = record ? colors[record.state] : '#858991';
|
|
133
|
+
for (const progress of pie ? [null] : [null, record?.progress]) {
|
|
134
|
+
if (progress === undefined || progress === null && svg.childElementCount) continue;
|
|
135
|
+
const circle = document.createElementNS(svg.namespaceURI, 'circle');
|
|
136
|
+
for (const [name, value] of Object.entries({ cx: 12, cy: 12, r: 10, fill: 'none', stroke: color, 'stroke-width': 1.6 })) {
|
|
137
|
+
circle.setAttribute(name, value);
|
|
138
|
+
}
|
|
139
|
+
if (progress === null) circle.setAttribute('opacity', pie ? '1' : record?.progress != null ? '.25' : '.85');
|
|
140
|
+
else {
|
|
141
|
+
circle.setAttribute('stroke-dasharray', `${62.832 * progress / 100} 62.832`);
|
|
142
|
+
circle.setAttribute('transform', 'rotate(-90 12 12)');
|
|
143
|
+
circle.setAttribute('stroke-linecap', 'round');
|
|
144
|
+
}
|
|
145
|
+
svg.append(circle);
|
|
146
|
+
}
|
|
147
|
+
if (pie && record?.progress > 0) {
|
|
148
|
+
const sector = document.createElementNS(svg.namespaceURI, 'path');
|
|
149
|
+
const angle = record.progress / 100 * Math.PI * 2;
|
|
150
|
+
const x = 12 + 7.4 * Math.sin(angle);
|
|
151
|
+
const y = 12 - 7.4 * Math.cos(angle);
|
|
152
|
+
sector.setAttribute('d', record.progress === 100
|
|
153
|
+
? 'M12 4.6a7.4 7.4 0 1 1 0 14.8a7.4 7.4 0 1 1 0-14.8'
|
|
154
|
+
: `M12 12L12 4.6A7.4 7.4 0 ${record.progress > 50 ? 1 : 0} 1 ${x} ${y}Z`);
|
|
155
|
+
sector.setAttribute('fill', color); sector.setAttribute('class', 'progress-pie');
|
|
156
|
+
svg.append(sector);
|
|
157
|
+
}
|
|
158
|
+
if (pie || record) {
|
|
159
|
+
const text = document.createElementNS(svg.namespaceURI, 'text');
|
|
160
|
+
text.setAttribute('x', '12'); text.setAttribute('y', '12.4');
|
|
161
|
+
text.setAttribute('text-anchor', 'middle'); text.setAttribute('dominant-baseline', 'middle');
|
|
162
|
+
text.setAttribute('fill', color);
|
|
163
|
+
text.setAttribute('style', `font:600 ${pie ? 6.4 : 8}px -apple-system,BlinkMacSystemFont,sans-serif;font-variant-numeric:tabular-nums`);
|
|
164
|
+
text.textContent = record?.progress == null ? '—' : pie ? `${record.progress}%` : String(record.progress);
|
|
165
|
+
if (record?.progress == null) text.setAttribute('class', 'progress-unknown');
|
|
166
|
+
svg.append(text);
|
|
167
|
+
}
|
|
168
|
+
button.append(svg);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function paintVisibility(entry) {
|
|
172
|
+
const selected = harness?.isRowSelected ? harness.isRowSelected(entry.row) : entry.row.getAttribute('data-app-action-sidebar-thread-selected') === 'true';
|
|
173
|
+
entry.host.toggleAttribute('data-visible', Boolean(recordFor(entry.key) || snapshot.analyzingKeys?.includes(entry.key) || entry.hovered || selected));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function paint(entry) {
|
|
177
|
+
const record = recordFor(entry.key);
|
|
178
|
+
const loading = snapshot.analyzingKeys?.includes(entry.key) || false;
|
|
179
|
+
const ringKey = JSON.stringify([record?.state, record?.progress, loading]);
|
|
180
|
+
if (entry.ringKey !== ringKey) { makeRing(entry.button, record, false, loading); entry.ringKey = ringKey; }
|
|
181
|
+
paintVisibility(entry);
|
|
182
|
+
entry.button.setAttribute('aria-busy', String(loading));
|
|
183
|
+
const description = S('ringAriaPattern', { title: entry.title, summary: loading ? S('ringUpdating') : summary(entry.key) });
|
|
184
|
+
entry.button.setAttribute('aria-label', description);
|
|
185
|
+
entry.button.title = description;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function unmount(entry) {
|
|
189
|
+
harness?.unmount?.(entry);
|
|
190
|
+
entry.row.removeEventListener('pointerenter', entry.onEnter); entry.row.removeEventListener('pointerleave', entry.onLeave);
|
|
191
|
+
entry.host.remove();
|
|
192
|
+
for (const [name, previous] of Object.entries(entry.original)) {
|
|
193
|
+
if (previous.value) entry.slot.style.setProperty(name, previous.value, previous.priority);
|
|
194
|
+
else entry.slot.style.removeProperty(name);
|
|
195
|
+
}
|
|
196
|
+
if (entry.slot.classList.contains('status-slot-injected')) entry.slot.remove();
|
|
197
|
+
mounted.delete(entry.row);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function attachHost(slot, emptyWrapper, placeholder) {
|
|
201
|
+
const original = Object.fromEntries(['width', 'min-width', 'flex-basis'].map(name => [name, {
|
|
202
|
+
value: slot.style.getPropertyValue(name), priority: slot.style.getPropertyPriority(name)
|
|
203
|
+
}]));
|
|
204
|
+
for (const name of Object.keys(original)) slot.style.setProperty(name, '24px');
|
|
205
|
+
const target = emptyWrapper ? placeholder : slot;
|
|
206
|
+
for (const existing of target.querySelectorAll('span[data-codex-session-status]')) {
|
|
207
|
+
existing.remove();
|
|
208
|
+
}
|
|
209
|
+
const host = element('span', null, target);
|
|
210
|
+
host.setAttribute('data-codex-session-status', '');
|
|
211
|
+
host.style.cssText = 'display:flex;width:24px;height:28px;flex:none;align-items:center;justify-content:center';
|
|
212
|
+
const shadow = host.attachShadow({ mode: 'open' });
|
|
213
|
+
element('style', `:host{opacity:0}:host([data-visible]),:host(:focus-within){opacity:1}@keyframes status-spin{to{transform:rotate(360deg)}}svg.loading{animation:status-spin .85s linear infinite;transform-origin:center}button{all:unset;box-sizing:border-box;width:28px;height:28px;display:grid;place-items:center;cursor:pointer;border-radius:7px}button:hover{background:color-mix(in srgb,currentColor 8%,transparent)}button:focus-visible{outline:2px solid #0169cc;outline-offset:1px}svg{display:block;pointer-events:none}`, shadow);
|
|
214
|
+
const button = element('button', null, shadow);
|
|
215
|
+
button.type = 'button'; button.setAttribute('aria-haspopup', 'dialog'); button.setAttribute('aria-expanded', 'false');
|
|
216
|
+
return { host, button, original };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function reconcile() {
|
|
220
|
+
frame = 0;
|
|
221
|
+
if (destroyed) return;
|
|
222
|
+
measureStartup();
|
|
223
|
+
if (harness?.reconcile) {
|
|
224
|
+
harness.reconcile({ mounted, unmount, attachHost, paint, paintVisibility, openPanel, closePanel, isPanelBusy: () => panel?.busy, isPanelEntry: e => panel?.entry === e });
|
|
225
|
+
measureStartup();
|
|
226
|
+
if (panel && (!panel.entry.host.isConnected || !visible(panel.entry.host))) closePanel(false);
|
|
227
|
+
else positionPanel();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
for (const entry of mounted.values()) {
|
|
231
|
+
if (!entry.row.isConnected || !entry.host.isConnected || !entry.row.closest('[data-app-action-sidebar-project-list-id]') ||
|
|
232
|
+
!['local', 'remote'].includes(entry.row.getAttribute('data-app-action-sidebar-thread-kind')) ||
|
|
233
|
+
entry.row.getAttribute('data-app-action-sidebar-thread-id') !== entry.threadId ||
|
|
234
|
+
entry.row.getAttribute('data-app-action-sidebar-thread-host-id') !== entry.rawHost) unmount(entry);
|
|
235
|
+
}
|
|
236
|
+
const rows = document.querySelectorAll('[data-app-action-sidebar-project-list-id] [data-app-action-sidebar-thread-row]');
|
|
237
|
+
for (const row of rows) {
|
|
238
|
+
const kind = row.getAttribute('data-app-action-sidebar-thread-kind');
|
|
239
|
+
if (kind !== 'local' && kind !== 'remote') continue;
|
|
240
|
+
const threadId = row.getAttribute('data-app-action-sidebar-thread-id');
|
|
241
|
+
if (!threadId) continue;
|
|
242
|
+
const titleNode = row.querySelector('[data-thread-title]');
|
|
243
|
+
const title = row.getAttribute('data-app-action-sidebar-thread-title') || titleNode?.textContent || S('sessionFallbackTitle');
|
|
244
|
+
const existing = mounted.get(row);
|
|
245
|
+
if (existing) {
|
|
246
|
+
if (existing.title !== title) { existing.title = title; paint(existing); }
|
|
247
|
+
paintVisibility(existing);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
// Target the existing reserved leading slot; leave occupied native icons intact.
|
|
251
|
+
const trigger = titleNode?.closest('[data-thread-title-trigger]');
|
|
252
|
+
const slot = trigger?.previousElementSibling;
|
|
253
|
+
if (!slot || !slot.classList.contains('w-4')) continue;
|
|
254
|
+
// Native rows keep an empty relative wrapper inside the leading slot.
|
|
255
|
+
const placeholder = slot.firstElementChild;
|
|
256
|
+
const emptyWrapper = slot.childElementCount === 1 && placeholder.tagName === 'DIV' &&
|
|
257
|
+
placeholder.childElementCount === 0 && !placeholder.textContent.trim();
|
|
258
|
+
if (slot.childElementCount !== 0 && !emptyWrapper) continue;
|
|
259
|
+
const rawHost = row.getAttribute('data-app-action-sidebar-thread-host-id');
|
|
260
|
+
const key = JSON.stringify([rawHost || (kind === 'remote' ? 'cloud' : 'local'), threadId]);
|
|
261
|
+
const { host, button, original } = attachHost(slot, emptyWrapper, placeholder);
|
|
262
|
+
const entry = { row, key, threadId, rawHost, title, slot, host, button, original, hovered: row.matches(':hover') };
|
|
263
|
+
entry.onEnter = () => { entry.hovered = true; paintVisibility(entry); };
|
|
264
|
+
entry.onLeave = () => { entry.hovered = false; paintVisibility(entry); };
|
|
265
|
+
row.addEventListener('pointerenter', entry.onEnter); row.addEventListener('pointerleave', entry.onLeave);
|
|
266
|
+
for (const type of ['pointerdown', 'dblclick']) host.addEventListener(type, e => e.stopPropagation());
|
|
267
|
+
button.addEventListener('click', async e => {
|
|
268
|
+
e.preventDefault(); e.stopPropagation();
|
|
269
|
+
if (panel?.busy) return;
|
|
270
|
+
if (panel?.entry === entry) closePanel();
|
|
271
|
+
else { closePanel(); openPanel(entry); }
|
|
272
|
+
});
|
|
273
|
+
mounted.set(row, entry); paint(entry);
|
|
274
|
+
}
|
|
275
|
+
if (panel && (!panel.entry.host.isConnected || !visible(panel.entry.host))) closePanel(false);
|
|
276
|
+
else positionPanel();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function schedule() {
|
|
280
|
+
if (!frame && !destroyed) frame = requestAnimationFrame(reconcile);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function visible(node) {
|
|
284
|
+
const r = node.getBoundingClientRect();
|
|
285
|
+
return r.width > 0 && r.height > 0 && r.bottom > 0 && r.top < innerHeight;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function positionPanel() {
|
|
289
|
+
if (!panel) return;
|
|
290
|
+
if (embedded) {
|
|
291
|
+
panel.root.setAttribute('data-color-mode', embedded.theme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
// Foreground colors change when the host window becomes inactive.
|
|
295
|
+
// Read the painted page background, whose luminance represents its theme.
|
|
296
|
+
let mode = null;
|
|
297
|
+
for (let node = panel.entry.row; node; node = node.parentElement) {
|
|
298
|
+
const rgba = getComputedStyle(node).backgroundColor.match(/[\d.]+/g)?.map(Number);
|
|
299
|
+
if (!rgba || (rgba[3] ?? 1) < .95) continue;
|
|
300
|
+
mode = rgba[0] * .2126 + rgba[1] * .7152 + rgba[2] * .0722 < 150 ? 'dark' : 'light';
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
mode ||= panel.root.getAttribute('data-color-mode') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
304
|
+
if (panel.root.getAttribute('data-color-mode') !== mode) panel.root.setAttribute('data-color-mode', mode);
|
|
305
|
+
const anchor = panel.entry.host.getBoundingClientRect();
|
|
306
|
+
const rect = panel.shell.getBoundingClientRect();
|
|
307
|
+
const left = Math.max(8, Math.min(anchor.right + 10, innerWidth - rect.width - 8));
|
|
308
|
+
const top = Math.max(8, Math.min(anchor.top - 12, innerHeight - rect.height - 8));
|
|
309
|
+
panel.shell.style.left = `${left}px`; panel.shell.style.top = `${top}px`;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function updateDraft(target, patch) {
|
|
313
|
+
target.draft = presentation ? presentation.draftTransition({ draft: target.draft, baseRevision: target.revision }, { type: 'patch', patch }).draft : { ...target.draft, ...patch };
|
|
314
|
+
target.dirty = true;
|
|
315
|
+
const draft = target.draft;
|
|
316
|
+
target.progress.value = draft.progress ?? '';
|
|
317
|
+
target.slider.value = draft.progress ?? 0;
|
|
318
|
+
target.range.style.setProperty('--fill', `${draft.progress ?? 0}%`);
|
|
319
|
+
target.range.style.setProperty('--mark', colors[draft.state] || colors.unfinished);
|
|
320
|
+
for (const [state, button] of target.choices) button.setAttribute('aria-pressed', String(draft.state === state));
|
|
321
|
+
rememberPanel(target);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function refreshPanel() {
|
|
325
|
+
if (!panel) return;
|
|
326
|
+
const target = panel, record = recordFor(target.entry.key);
|
|
327
|
+
target.choices.get('pushed').hidden = target.projectGit?.hasRemote !== true;
|
|
328
|
+
target.git.textContent = target.projectGit?.status === 'unknown' ? S('gitCheckUnavailable') : '';
|
|
329
|
+
if (!target.busy && !target.dirty) {
|
|
330
|
+
target.revision = snapshot.records[target.entry.key]?.revision ?? 0;
|
|
331
|
+
target.draft = presentation ? presentation.draftTransition({}, { type: 'begin', record, revision: target.revision }).draft : { state: record?.state || 'unfinished', progress: record?.progress ?? null, note: record?.note || '' };
|
|
332
|
+
target.note.value = target.draft.note;
|
|
333
|
+
target.progress.value = target.draft.progress ?? '';
|
|
334
|
+
target.slider.value = target.draft.progress ?? 0;
|
|
335
|
+
target.range.style.setProperty('--fill', `${target.draft.progress ?? 0}%`);
|
|
336
|
+
target.range.style.setProperty('--mark', colors[target.draft.state]);
|
|
337
|
+
for (const [state, button] of target.choices) button.setAttribute('aria-pressed', String(target.draft.state === state));
|
|
338
|
+
}
|
|
339
|
+
makeRing(target.titleProgress, record, true);
|
|
340
|
+
target.heading.setAttribute('aria-label', `${target.entry.title}, ${summary(target.entry.key)}`);
|
|
341
|
+
target.statusLabel.textContent = record ? labels[record.state] : S('statusUnrecorded');
|
|
342
|
+
target.statusDot.style.borderColor = record ? colors[record.state] : colors.unstarted;
|
|
343
|
+
target.timestamp.textContent = record ? (ui?.formatDate ? ui.formatDate(record.updatedAt) : new Date(record.updatedAt).toLocaleString(activeLang === 'en' ? 'en-US' : 'zh-CN', { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' })) : '';
|
|
344
|
+
target.scoreNumber.textContent = record?.progress ?? '—';
|
|
345
|
+
target.scoreUnit.hidden = record?.progress == null;
|
|
346
|
+
target.meter.style.setProperty('--fill', `${record?.progress ?? 0}%`);
|
|
347
|
+
target.meter.style.setProperty('--mark', record ? colors[record.state] : colors.unstarted);
|
|
348
|
+
target.sourceLabel.textContent = record ? (record.source === 'analysis' ? S('sourceAuto') : S('sourceManual')) : '';
|
|
349
|
+
const summaryText = record?.note || '';
|
|
350
|
+
if (target.overviewSummary.textContent !== summaryText) {
|
|
351
|
+
target.overviewSummary.textContent = summaryText;
|
|
352
|
+
target.setSummaryExpanded(false);
|
|
353
|
+
}
|
|
354
|
+
target.summaryBlock.hidden = !summaryText;
|
|
355
|
+
target.noteOpen.textContent = record?.note ? S('editLabel') : S('addLabel');
|
|
356
|
+
target.analyze.disabled = presentation ? presentation.analysisDisabled(target.busy || target.capabilities?.analyze === false, target.analyzing, target.updateInfo?.update?.stage) : target.busy || target.analyzing || ['waiting', 'installing'].includes(target.updateInfo?.update?.stage);
|
|
357
|
+
target.renderHistory?.();
|
|
358
|
+
positionPanel();
|
|
359
|
+
target.scheduleMarquees?.();
|
|
360
|
+
if (target.restoreScroll != null && (target.mode === 'edit' || target.analysisState)) {
|
|
361
|
+
target.body.scrollTop = target.restoreScroll; target.restoreScroll = null;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function save(patch = {}, reset = false, target = panel) {
|
|
366
|
+
if (!target || target.busy) return false;
|
|
367
|
+
const raw = target.progress.value.trim();
|
|
368
|
+
const progress = raw === '' ? null : Number(raw);
|
|
369
|
+
if (!reset && progress !== null && (!Number.isInteger(progress) || progress < 0 || progress > 100)) {
|
|
370
|
+
target.error.textContent = S('invalidProgressError'); return false;
|
|
371
|
+
}
|
|
372
|
+
const record = reset ? null : { ...target.draft, progress, note: target.note.value, ...patch };
|
|
373
|
+
target.busy = true; target.error.textContent = '';
|
|
374
|
+
for (const control of target.controls) control.disabled = true;
|
|
375
|
+
try {
|
|
376
|
+
const state = await target.request('update', 7000, { expectedRevision: target.revision, record });
|
|
377
|
+
target.dirty = false;
|
|
378
|
+
target.conflict = false; target.resolveConflict.hidden = true;
|
|
379
|
+
rememberPanel(target);
|
|
380
|
+
// 保存成功即补读一次,并吸收保存期间到达的待刷新,避免 finally 再读一次。
|
|
381
|
+
target.syncVersion = panelVersion(target.entry.key); target.syncPending = false;
|
|
382
|
+
if (embedded && state) target.showHistory(state); else target.pollHistory?.();
|
|
383
|
+
return true;
|
|
384
|
+
} catch (error) {
|
|
385
|
+
target.error.textContent = error.message;
|
|
386
|
+
if ((error.code === 'REVISION_CONFLICT' || (!error.code && (error.message === '此会话已在其他窗口更新,请重新确认' || error.message === S('conflictDetectedFeedback')))) && target.dirty && !reset) {
|
|
387
|
+
target.conflict = true;
|
|
388
|
+
target.resolveConflict.hidden = false;
|
|
389
|
+
rememberPanel(target);
|
|
390
|
+
}
|
|
391
|
+
return false;
|
|
392
|
+
} finally {
|
|
393
|
+
target.busy = false;
|
|
394
|
+
for (const control of target.controls) control.disabled = false;
|
|
395
|
+
if (target.syncPending && panel === target) syncPanel(target);
|
|
396
|
+
if (panel === target) { target.analyze.disabled = target.analyzing; refreshPanel(); }
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function rebaseDraft(target) {
|
|
401
|
+
if (target.busy || !target.conflict) return;
|
|
402
|
+
target.busy = true;
|
|
403
|
+
for (const control of target.controls) control.disabled = true;
|
|
404
|
+
try {
|
|
405
|
+
const state = await target.request('analysis-state', 7000);
|
|
406
|
+
target.revision = snapshot.records[target.entry.key]?.revision ?? 0;
|
|
407
|
+
target.conflict = false; target.resolveConflict.hidden = true;
|
|
408
|
+
target.error.textContent = S('conflictReloadedFeedback');
|
|
409
|
+
target.showHistory?.(state);
|
|
410
|
+
rememberPanel(target);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
target.error.textContent = error.message;
|
|
413
|
+
} finally {
|
|
414
|
+
target.busy = false;
|
|
415
|
+
for (const control of target.controls) control.disabled = false;
|
|
416
|
+
if (panel === target) {
|
|
417
|
+
if (target.syncPending) syncPanel(target);
|
|
418
|
+
refreshPanel();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function cancelRead(requestId, request) {
|
|
424
|
+
if (!['project-git', 'analysis-state', 'app-update-info'].includes(request.type) || !(embedded || harness?.supportsRequestCancellation)) return;
|
|
425
|
+
try { send(JSON.stringify({ type: 'cancel-request', requestId: `${requestPrefix}:${++serial}`, cancelRequestId: requestId })); } catch { /* Local cleanup still runs if the host has disconnected. */ }
|
|
426
|
+
}
|
|
427
|
+
function closePanel(restoreFocus = true) {
|
|
428
|
+
if (!panel || panel.busy) return;
|
|
429
|
+
for (const [id, request] of pending) {
|
|
430
|
+
if (request.key === panel.entry.key && ['project-git', 'analysis-state', 'app-update-info'].includes(request.type) && (embedded || harness?.supportsRequestCancellation)) {
|
|
431
|
+
cancelRead(id, request); clearTimeout(request.timer); pending.delete(id);
|
|
432
|
+
request.reject(Object.assign(new Error(S('cardRequestCancelled')), { code: 'REQUEST_CANCELLED' }));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
rememberPanel(panel);
|
|
436
|
+
panelEvent('close', panel.entry);
|
|
437
|
+
const target = panel; panel = null;
|
|
438
|
+
clearTimeout(target.pollTimer); cancelAnimationFrame(target.marqueeFrame);
|
|
439
|
+
clearTimeout(target.updateTimer);
|
|
440
|
+
target.resizeObserver?.disconnect();
|
|
441
|
+
target.root.remove(); target.entry.button.setAttribute('aria-expanded', 'false');
|
|
442
|
+
if (restoreFocus && target.entry.host.isConnected) target.entry.button.focus();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function openPanel(entry) {
|
|
446
|
+
if (panel) return;
|
|
447
|
+
const root = element('div', null, embedded?.container || document.body);
|
|
448
|
+
root.setAttribute('data-codex-session-status-panel', '');
|
|
449
|
+
if (!embedded) root.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483646';
|
|
450
|
+
const shadow = root.attachShadow({ mode: 'open' });
|
|
451
|
+
element('style', `
|
|
452
|
+
:host{--accent:${presentation?.accent.normal || '#0169cc'};--accent-hover:${presentation?.accent.hover || '#005bb3'};--ink:#e6edf3;--secondary:#a0a6ad;--muted:#828c96;--note:#bbc3ca;--track:#ffffff12;--line:#ffffff14;--input-border:#ffffff18;--input-bg:#ffffff03;--hover:#ffffff09;--selected:#ffffff10;--source-bg:#ffffff0a;--number-line:#ffffff25;--thumb:#e6edf3;--thumb-edge:#ffffff30;--danger:#ef7777;--error:#f7ad86;font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--ink);color-scheme:dark}
|
|
453
|
+
*{box-sizing:border-box;scrollbar-width:none;-ms-overflow-style:none}*::-webkit-scrollbar{display:none;width:0;height:0}button,input,textarea{font:inherit}button{cursor:pointer}button,input,textarea{color:inherit}[hidden]{display:none!important}
|
|
454
|
+
.shell{position:fixed;pointer-events:auto;width:${presentation?.layout.panelWidth || 340}px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);display:flex;flex-direction:column;overflow:hidden;--panel-bg:#0e1318;background:var(--panel-bg);border:1px solid #ffffff1c;border-radius:20px;box-shadow:0 16px 54px #0005;padding:22px 20px 14px}
|
|
455
|
+
.shell:hover{--panel-bg:#1f242a}.title-heading{display:flex;flex:none;align-items:flex-start;gap:10px;margin-right:24px;border-radius:5px;outline-offset:4px}
|
|
456
|
+
h2.title{font-size:24px;font-weight:650;line-height:1.3;letter-spacing:-.5px;margin:0;min-width:0;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
|
|
457
|
+
.title-progress{display:flex;flex:none;width:32px;height:32px;margin-top:1px}.title-progress svg{width:32px;height:32px}.title-progress text{opacity:0}.title-progress text.progress-unknown{opacity:1}.title-heading:hover .progress-pie,.title-heading:focus-visible .progress-pie{opacity:0}.title-heading:hover text,.title-heading:focus-visible text{opacity:1}
|
|
458
|
+
.close{position:absolute;right:12px;top:7px;border:0;background:none;color:var(--secondary);font-size:0;width:28px;height:28px;padding:0}.close::before,.close::after{content:"";position:absolute;left:7px;top:13px;width:14px;height:1px;background:currentColor;transform:rotate(45deg)}.close::after{transform:rotate(-45deg)}
|
|
459
|
+
.open-pane{position:absolute;right:44px;top:7px;border:0;background:none;color:var(--secondary);width:28px;height:28px;padding:0;border-radius:6px}.open-pane:hover{color:var(--ink);background:var(--hover)}.open-pane::before{content:"";position:absolute;left:7px;top:8px;width:14px;height:12px;border:1.3px solid currentColor;border-radius:3px;box-sizing:border-box}.open-pane::after{content:"";position:absolute;left:16px;top:8px;width:1.3px;height:12px;background:currentColor}.shell.has-open-pane .title-heading{margin-right:56px}.open-pane-tip{position:absolute;right:0;top:calc(100% + 6px);padding:5px 8px;border-radius:6px;background:var(--panel-bg);color:var(--ink);border:1px solid var(--line);box-shadow:0 4px 14px #0003;font-size:11px;line-height:1.4;white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;transition:opacity .08s,visibility 0s;z-index:2}.open-pane:is(:hover,:focus-visible) .open-pane-tip{opacity:1;visibility:visible;transition-delay:.15s}
|
|
460
|
+
.panel-body{overflow:auto;min-height:0;margin-top:23px;scrollbar-width:none;-ms-overflow-style:none}.panel-body::-webkit-scrollbar{display:none;width:0;height:0}.view{padding-bottom:4px}.status-line{display:flex;align-items:center;justify-content:space-between;gap:16px}.status-block{transform:translateY(2px);min-width:0;flex:1}.status-name{display:flex;align-items:center;gap:7px;line-height:18px;min-width:0}.status-name>span:last-child,.timestamp{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.state-dot{width:10px;height:10px;border:1.5px solid;border-radius:50%;flex:none}.timestamp{font-size:11px;line-height:16px;color:var(--secondary);margin-top:2px;margin-left:17px}.score{display:flex;align-items:baseline;line-height:1;font-variant-numeric:tabular-nums;flex:none}.score-number{font-size:39px;font-weight:550;letter-spacing:-1px}.score-unit{font-size:15px;color:var(--secondary);margin-left:3px}
|
|
461
|
+
.meter{height:4px;background:var(--track);border-radius:3px;margin:14px 0 10px;overflow:hidden}.meter::after{content:"";display:block;height:100%;width:var(--fill);background:var(--mark);border-radius:inherit}.totals-row{display:flex;justify-content:space-between;align-items:center;gap:8px;color:var(--secondary)}.totals,.source-label{font-size:11px;font-weight:400;line-height:16px}.source-label{margin-left:auto;text-align:right;white-space:nowrap}.summary-block{position:relative;margin:16px 0;outline:none}.overview-summary{font-size:13px;line-height:1.65;color:var(--note);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere}.summary-expand{position:absolute;right:0;bottom:0;border:0;background:linear-gradient(to right,transparent,var(--panel-bg) 18px);padding:0 0 0 22px;color:var(--secondary);font-size:12px;line-height:21.45px;white-space:nowrap}.summary-expand:hover{color:inherit}.summary-block.expanded .overview-summary{display:block;-webkit-line-clamp:unset}.summary-block.expanded .summary-expand{position:static;display:block;margin-left:auto;padding-left:0;background:none}
|
|
462
|
+
.actions{display:flex;align-items:center;gap:14px;margin:18px 0 22px}.primary{border:0;background:var(--accent);color:#fff;border-radius:9px;padding:9px 14px;font-weight:550;min-height:36px;white-space:nowrap}.primary:hover{background:var(--accent-hover);color:#fff}.text-button,.clear,.back{border:0;background:none;padding:0;color:var(--secondary);font-size:12px;white-space:nowrap}.text-button:hover,.back:hover{color:inherit}.actions .clear{margin-left:auto;font-size:11px;color:var(--muted);white-space:nowrap;transition:color .12s}.actions .clear:hover{color:var(--danger)}.actions .clear{position:relative}.clear-tooltip{position:absolute;right:0;bottom:calc(100% + 8px);padding:6px 9px;border-radius:6px;background:var(--panel-bg);color:var(--secondary);border:1px solid var(--line);font-size:11px;white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;transition:opacity .08s,visibility 0s}.clear:is(:hover,:focus-visible) .clear-tooltip{opacity:1;visibility:visible;transition-delay:.1s}.section-head{border-top:1px solid var(--line);padding-top:16px;display:flex;align-items:center;justify-content:space-between;margin-bottom:5px}.section-head h3{font-size:12px;font-weight:550;margin:0}.remaining-toggle{border:0;background:none;padding:0}.row-detail{font-size:12px;font-weight:400;line-height:18px;color:var(--secondary);white-space:nowrap}
|
|
463
|
+
.task-row{position:relative;display:flex;gap:9px;align-items:flex-start;padding:9px 0;overflow:hidden;isolation:isolate}.task-dot{width:12px;height:12px;border:1.3px solid #c89b38;border-radius:50%;margin-top:4px;flex:none}.task-row[data-status=done] .task-dot{border-color:#548eea;background:#548eea22}.task-content{min-width:0;flex:1}.task-title{width:100%;overflow:hidden;mask-image:linear-gradient(to right,#000 calc(100% - 12px),transparent)}.task-track{display:flex;width:max-content;transform:translateX(0);transition:transform .22s ease-out}.task-copy{white-space:nowrap;flex:none}.task-row:is(:hover,:focus-within) .task-title.overflowing .task-track{transform:translateX(calc(-1 * var(--travel)));transition-duration:var(--duration,4s);transition-timing-function:linear;will-change:transform}.task-meta{font-size:10px;color:var(--secondary);margin-top:3px}.task-source{position:absolute;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:flex-end;padding-left:28px;background:linear-gradient(to right,transparent,var(--panel-bg) 25px);opacity:0;pointer-events:none;transform:translateX(4px);transition:opacity .13s,transform .13s}.task-source button{border:0;border-radius:6px;background:var(--source-bg);color:inherit;padding:5px 7px;font-size:11px;white-space:nowrap}.task-row:hover .task-source,.task-row:focus-within .task-source{opacity:1;pointer-events:auto;transform:none}.task-row:focus-visible{outline:1px solid var(--accent);outline-offset:1px}
|
|
464
|
+
@media(prefers-reduced-motion:reduce){.task-row .task-title.overflowing .task-track{transform:none;transition:none}.task-title{overflow:auto}}
|
|
465
|
+
@media(hover:none){.task-source{opacity:1;pointer-events:auto;transform:none}}
|
|
466
|
+
.empty{font-size:12px;color:var(--secondary);padding:13px 0}.quiet-row{border:0;border-top:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;width:100%;background:none;color:inherit;padding:15px 0;text-align:left;font-size:12px}.quiet-row span:last-child{color:var(--secondary)}.overview-bottom{margin-top:13px}.view-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}.view-heading h3{font-size:14px;font-weight:550;margin:0}.choice{display:flex;align-items:center;gap:10px;width:100%;padding:8px 9px;border:0;border-radius:7px;background:none;color:inherit;text-align:left}.choice:hover{background:var(--hover)}.choice[aria-pressed=true]{background:var(--selected)}.dot{width:12px;height:12px;border:1.6px solid var(--mark);border-radius:50%;flex:none}.choice[aria-pressed=true] .dot{background:var(--mark);box-shadow:inset 0 0 0 2px var(--panel-bg)}
|
|
467
|
+
.progress-section{margin-top:20px}.progress-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.label{font-size:11px;color:var(--secondary)}.number-wrap{display:flex;align-items:center;gap:5px;color:var(--secondary)}.progress-number{appearance:textfield;color:var(--ink);width:65px;padding:2px 3px 4px;background:none;border:0;border-bottom:1px solid var(--number-line);font-size:27px;font-weight:550;text-align:right;font-variant-numeric:tabular-nums}.progress-number::-webkit-inner-spin-button{appearance:none}.range{position:relative;height:51px;margin-top:2px;--mark:#c89b38}.range-track{position:absolute;left:7px;right:7px;top:10px;height:4px;border-radius:3px;background:linear-gradient(to right,var(--range-fill,var(--mark)) var(--fill),var(--track) var(--fill));pointer-events:none}.range-input{position:relative;appearance:none;width:100%;height:24px;background:transparent;margin:0;display:block;padding:0;cursor:pointer}.range-input::-webkit-slider-runnable-track{height:4px;background:transparent}.range-input::-webkit-slider-thumb{appearance:none;width:14px;height:14px;margin-top:-5px;background:var(--thumb);border:2px solid var(--panel-bg);border-radius:50%;box-shadow:0 0 0 1px var(--thumb-edge)}.range-nodes{position:absolute;left:7px;right:7px;top:0;pointer-events:none}.range-node{position:absolute;left:var(--at);top:8px;width:0;font-size:10px;color:var(--secondary);font-variant-numeric:tabular-nums}.range-node::before{content:"";display:block;width:7px;height:7px;transform:translateX(-50%);border-radius:50%;background:var(--panel-bg);border:1px solid var(--secondary);box-shadow:0 0 0 1px var(--panel-bg)}.range-node-label{position:absolute;top:19px;left:0;transform:translateX(-50%)}.range-node:first-child .range-node-label{transform:none}.range-node:last-child .range-node-label{transform:translateX(-100%)}.unknown-row{display:flex;justify-content:flex-end;margin:2px 0 18px}.unknown{font-size:11px}
|
|
468
|
+
.note-label{display:block;font-size:11px;color:var(--secondary);margin-bottom:8px}textarea{display:block;width:100%;resize:vertical;min-height:66px;max-height:140px;background:var(--input-bg);color:inherit;border:1px solid var(--input-border);border-radius:8px;padding:9px;line-height:1.6;font-size:12px;scrollbar-width:none;-ms-overflow-style:none}textarea::-webkit-scrollbar{display:none;width:0;height:0}textarea::placeholder{color:var(--muted)}.edit-actions{display:flex;justify-content:flex-end;gap:18px;align-items:center;padding:21px 0 16px}.git{font-size:11px;color:var(--secondary)}.analysis-message{font-size:11px;color:var(--secondary);margin:0 0 13px}.analysis-message:empty,.error:empty,.git:empty{display:none}.error{flex:none;font-size:12px;color:var(--error);padding-top:10px;white-space:pre-wrap}button:disabled,input:disabled,textarea:disabled{opacity:.55;cursor:wait}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
469
|
+
.shell textarea:focus-visible{outline:none}
|
|
470
|
+
.app-update{margin-top:3px;padding:10px 11px;background:var(--hover);border:1px solid var(--line);border-radius:10px}.app-update-row{display:flex;align-items:center;justify-content:space-between;gap:10px}.app-update-label{font-size:12px;line-height:18px;color:var(--ink);min-width:0;overflow-wrap:anywhere}.app-update-button{flex:none;padding:5px 10px;min-height:28px;border-radius:7px;font-size:11px}.app-update-detail{margin-top:7px;font-size:11px;line-height:1.6;color:var(--secondary);white-space:pre-wrap;overflow-wrap:anywhere;user-select:text}.app-update[data-failed=true] .app-update-detail{color:var(--error)}
|
|
471
|
+
:host([data-color-mode=light]){--ink:#22272e;--secondary:#576374;--muted:#667383;--note:#46515f;--track:#c3ccd6;--line:#dfe4ea;--input-border:#c7d0da;--input-bg:#f7f9fb;--hover:#f0f3f6;--selected:#e9edf2;--source-bg:#e9eef4;--number-line:#b6c1ce;--thumb:var(--accent);--thumb-edge:var(--accent);--danger:#bf2f3a;--error:#b13a2d;color:var(--ink);color-scheme:light}
|
|
472
|
+
:host([data-color-mode=light]) .shell{--panel-bg:#fff;border-color:#dfe4ea;box-shadow:0 14px 45px #26344520}
|
|
473
|
+
:host([data-color-mode=light]) .shell:hover{--panel-bg:#f5f6f7}
|
|
474
|
+
:host([data-color-mode=light]) .range{--range-fill:color-mix(in srgb,var(--mark) 85%,#000)}
|
|
475
|
+
:host([data-color-mode=light]) .meter::after{background:color-mix(in srgb,var(--mark) 85%,#000)}
|
|
476
|
+
`, shadow);
|
|
477
|
+
if (embedded) element('style', '.shell{position:relative;max-width:100%;max-height:none}.shell,:host([data-color-mode=light]) .shell{box-shadow:none}.panel-body{overflow:visible}', shadow);
|
|
478
|
+
const shell = element('div', null, shadow, 'shell');
|
|
479
|
+
shell.setAttribute('role', embedded ? 'region' : 'dialog'); shell.setAttribute('aria-label', S('panelAriaPattern', { title: entry.title }));
|
|
480
|
+
const close = embedded ? null : element('button', '×', shell, 'close'); close?.setAttribute('aria-label', S('close'));
|
|
481
|
+
// 宿主支持时,在关闭按钮左侧提供「在侧栏打开」:把卡片交给宿主的常驻侧栏面板。
|
|
482
|
+
const openPane = harness?.openPane ? element('button', null, shell, 'open-pane') : null;
|
|
483
|
+
let openPaneTip = null;
|
|
484
|
+
if (openPane) {
|
|
485
|
+
shell.classList.add('has-open-pane'); openPane.setAttribute('aria-label', S('openInSidebar'));
|
|
486
|
+
openPaneTip = element('span', S('openInSidebar'), openPane, 'open-pane-tip');
|
|
487
|
+
openPaneTip.setAttribute('role', 'tooltip');
|
|
488
|
+
}
|
|
489
|
+
const heading = element('div', null, shell, 'title-heading'); heading.tabIndex = 0;
|
|
490
|
+
const titleProgress = element('span', null, heading, 'title-progress');
|
|
491
|
+
element('h2', entry.title, heading, 'title');
|
|
492
|
+
const body = element('div', null, shell, 'panel-body');
|
|
493
|
+
const overview = element('div', null, body, 'view overview');
|
|
494
|
+
const statusLine = element('div', null, overview, 'status-line');
|
|
495
|
+
const statusBlock = element('div', null, statusLine, 'status-block');
|
|
496
|
+
const statusName = element('div', null, statusBlock, 'status-name');
|
|
497
|
+
const statusDot = element('span', null, statusName, 'state-dot');
|
|
498
|
+
const statusLabel = element('span', null, statusName);
|
|
499
|
+
const timestamp = element('div', null, statusBlock, 'timestamp');
|
|
500
|
+
const score = element('div', null, statusLine, 'score');
|
|
501
|
+
const scoreNumber = element('span', null, score, 'score-number');
|
|
502
|
+
const scoreUnit = element('span', '%', score, 'score-unit');
|
|
503
|
+
const meter = element('div', null, overview, 'meter');
|
|
504
|
+
const totalsRow = element('div', null, overview, 'totals-row');
|
|
505
|
+
const totals = element('span', S('totalsEmpty'), totalsRow, 'totals');
|
|
506
|
+
const sourceLabel = element('span', null, totalsRow, 'source-label');
|
|
507
|
+
const summaryBlock = element('div', null, overview, 'summary-block'); summaryBlock.tabIndex = 0;
|
|
508
|
+
const overviewSummary = element('div', null, summaryBlock, 'overview-summary');
|
|
509
|
+
const summaryExpand = element('button', S('expandAll'), summaryBlock, 'summary-expand');
|
|
510
|
+
summaryExpand.hidden = true; summaryExpand.setAttribute('aria-expanded', 'false');
|
|
511
|
+
const actions = element('div', null, overview, 'actions');
|
|
512
|
+
const analyze = element('button', S('btnUpdate'), actions, 'primary analyze');
|
|
513
|
+
const editOpen = element('button', S('btnAdjust'), actions, 'text-button edit-open');
|
|
514
|
+
const clear = element('button', S('btnClear'), actions, 'clear');
|
|
515
|
+
clear.setAttribute('aria-label', S('btnClear'));
|
|
516
|
+
const clearTip = element('span', S('clearTooltip'), clear, 'clear-tooltip');
|
|
517
|
+
clearTip.setAttribute('role', 'tooltip');
|
|
518
|
+
const sectionHead = element('div', null, overview, 'section-head');
|
|
519
|
+
const tasksHeading = element('h3', S('remainingHeadingPattern', { count: 0 }), sectionHead);
|
|
520
|
+
const remainingToggle = element('button', null, sectionHead, 'remaining-toggle row-detail');
|
|
521
|
+
remainingToggle.hidden = true; remainingToggle.setAttribute('aria-expanded', 'false');
|
|
522
|
+
const currentTasks = element('div', null, overview, 'current-tasks');
|
|
523
|
+
const bottom = element('div', null, overview, 'overview-bottom');
|
|
524
|
+
const historyOpen = element('button', null, bottom, 'quiet-row history-open'); const historyRowTitle = element('span', S('completedHeading'), historyOpen);
|
|
525
|
+
const historyCount = element('span', S('countArrowPattern', { count: 0 }), historyOpen, 'row-detail');
|
|
526
|
+
const noteRow = element('button', null, bottom, 'quiet-row note-open'); const noteRowTitle = element('span', S('notesLabel'), noteRow);
|
|
527
|
+
const noteOpen = element('span', S('addLabel'), noteRow);
|
|
528
|
+
const timelineOpen = embedded ? element('button', S('timelineLink'), bottom, 'quiet-row timeline-open') : null;
|
|
529
|
+
const appUpdate = element('div', null, bottom, 'app-update'); appUpdate.hidden = true;
|
|
530
|
+
const appUpdateRow = element('div', null, appUpdate, 'app-update-row');
|
|
531
|
+
const appUpdateLabel = element('span', null, appUpdateRow, 'app-update-label'); appUpdateLabel.setAttribute('role', 'status');
|
|
532
|
+
const appUpdateButton = element('button', S('upgradeBtn'), appUpdateRow, 'primary app-update-button');
|
|
533
|
+
const appUpdateDetail = element('div', null, appUpdate, 'app-update-detail'); appUpdateDetail.hidden = true;
|
|
534
|
+
const edit = element('div', null, body, 'view edit-view'); edit.hidden = true;
|
|
535
|
+
const editHeading = element('div', null, edit, 'view-heading'); const editHeadingTitle = element('h3', S('editHeading'), editHeading);
|
|
536
|
+
const choices = new Map(), choiceLabels = new Map(), controls = [];
|
|
537
|
+
for (const [state, label] of Object.entries(labels)) {
|
|
538
|
+
const button = element('button', null, edit, 'choice'); button.style.setProperty('--mark', colors[state]);
|
|
539
|
+
element('span', null, button, 'dot'); choiceLabels.set(state, element('span', label, button)); button.setAttribute('aria-pressed', 'false');
|
|
540
|
+
choices.set(state, button); controls.push(button); if (state === 'pushed') button.hidden = true;
|
|
541
|
+
button.onclick = () => updateDraft(target, { state, progress: state === 'unstarted' ? 0 : state === 'unfinished'
|
|
542
|
+
? target.draft.state === 'unfinished' ? target.draft.progress : null : 100 });
|
|
543
|
+
button.onkeydown = event => {
|
|
544
|
+
if (!['ArrowUp', 'ArrowDown'].includes(event.key)) return;
|
|
545
|
+
event.preventDefault(); const buttons = [...choices.values()].filter(item => !item.hidden);
|
|
546
|
+
buttons[(buttons.indexOf(button) + (event.key === 'ArrowDown' ? 1 : buttons.length - 1)) % buttons.length].focus();
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
const progressSection = element('div', null, edit, 'progress-section');
|
|
550
|
+
const progressHead = element('div', null, progressSection, 'progress-head'); const progressHeadLabel = element('label', S('progressLabel'), progressHead, 'label');
|
|
551
|
+
const numberWrap = element('div', null, progressHead, 'number-wrap');
|
|
552
|
+
const progress = element('input', null, numberWrap, 'progress-number'); progress.type = 'number'; progress.min = '0'; progress.max = '100'; progress.step = '1'; progress.placeholder = '—'; progress.setAttribute('aria-label', S('progressLabel')); element('span', '%', numberWrap);
|
|
553
|
+
const range = element('div', null, progressSection, 'range'); element('div', null, range, 'range-track');
|
|
554
|
+
const nodes = element('div', null, range, 'range-nodes'); nodes.setAttribute('aria-hidden', 'true');
|
|
555
|
+
for (const value of [0, 25, 50, 75, 100]) { const node = element('span', null, nodes, 'range-node'); node.style.setProperty('--at', `${value}%`); element('span', String(value), node, 'range-node-label'); }
|
|
556
|
+
const slider = element('input', null, range, 'range-input'); slider.type = 'range'; slider.min = '0'; slider.max = '100'; slider.step = '1'; slider.setAttribute('aria-label', S('sliderAriaLabel'));
|
|
557
|
+
const unknownRow = element('div', null, progressSection, 'unknown-row'); const unknown = element('button', S('clearValueBtn'), unknownRow, 'text-button unknown');
|
|
558
|
+
const noteLabel = element('label', S('notesLabel'), edit, 'note-label');
|
|
559
|
+
const note = element('textarea', null, edit); note.maxLength = 4000; note.placeholder = S('notePlaceholder'); note.setAttribute('aria-label', S('noteAriaLabel'));
|
|
560
|
+
noteLabel.htmlFor = note.id = `session-status-note-${serial}`;
|
|
561
|
+
const git = element('div', null, edit, 'git');
|
|
562
|
+
const editActions = element('div', null, edit, 'edit-actions');
|
|
563
|
+
const cancel = element('button', S('cancelBtn'), editActions, 'text-button cancel');
|
|
564
|
+
const submit = element('button', S('saveBtn'), editActions, 'primary save-record');
|
|
565
|
+
const history = element('div', null, body, 'view history-view'); history.hidden = true;
|
|
566
|
+
const historyHeading = element('div', null, history, 'view-heading'); const historyHeadingTitle = element('h3', S('completedHeading'), historyHeading);
|
|
567
|
+
const back = element('button', S('backLabel'), historyHeading, 'back');
|
|
568
|
+
const historyList = element('div', null, history, 'history-list');
|
|
569
|
+
const timelineView = embedded ? element('div', null, body, 'view history-view') : null;
|
|
570
|
+
let timelineList, timelineHeadingTitle, timelineBackBtn;
|
|
571
|
+
if (timelineView) {
|
|
572
|
+
timelineView.hidden = true;
|
|
573
|
+
const title = element('div', null, timelineView, 'view-heading'); timelineHeadingTitle = element('h3', S('timelineHeading'), title);
|
|
574
|
+
timelineBackBtn = element('button', S('backLabel'), title, 'back');
|
|
575
|
+
timelineBackBtn.onclick = () => target.setView('overview');
|
|
576
|
+
timelineList = element('div', null, timelineView, 'history-list');
|
|
577
|
+
}
|
|
578
|
+
const analysisMessage = element('div', null, body, 'analysis-message'); analysisMessage.setAttribute('role', 'status');
|
|
579
|
+
const error = element('div', null, shell, 'error'); error.setAttribute('role', 'status');
|
|
580
|
+
const resolveConflict = element('button', S('resolveConflictBtn'), shell, 'text-button'); resolveConflict.hidden = true;
|
|
581
|
+
controls.push(note, progress, slider, unknown, cancel, submit, clear, analyze, editOpen, resolveConflict);
|
|
582
|
+
panel = { entry, root, shell, body, heading, titleProgress, choices, note, progress, slider, range, git, error, resolveConflict, controls,
|
|
583
|
+
statusLabel, statusDot, timestamp, scoreNumber, scoreUnit, meter, sourceLabel, overviewSummary, summaryBlock, noteOpen,
|
|
584
|
+
totals, analyze, historyList, dirty: false, busy: false, analyzing: false, revision: 0, mode: 'overview' };
|
|
585
|
+
const target = panel;
|
|
586
|
+
target.applyLocale = () => {
|
|
587
|
+
shell.setAttribute('aria-label', S('panelAriaPattern', { title: entry.title }));
|
|
588
|
+
close?.setAttribute('aria-label', S('close'));
|
|
589
|
+
if (openPane) {
|
|
590
|
+
openPane.setAttribute('aria-label', S('openInSidebar'));
|
|
591
|
+
if (openPaneTip) openPaneTip.textContent = S('openInSidebar');
|
|
592
|
+
}
|
|
593
|
+
summaryExpand.textContent = target.summaryExpanded ? S('collapse') : S('expandAll');
|
|
594
|
+
analyze.textContent = target.analyzing ? S('btnUpdating') : S('btnUpdate');
|
|
595
|
+
editOpen.textContent = S('btnAdjust');
|
|
596
|
+
clear.textContent = S('btnClear');
|
|
597
|
+
clear.setAttribute('aria-label', S('btnClear'));
|
|
598
|
+
clearTip.textContent = S('clearTooltip');
|
|
599
|
+
historyRowTitle.textContent = S('completedHeading');
|
|
600
|
+
noteRowTitle.textContent = S('notesLabel');
|
|
601
|
+
if (timelineOpen) timelineOpen.textContent = S('timelineLink');
|
|
602
|
+
editHeadingTitle.textContent = S('editHeading');
|
|
603
|
+
for (const [state, labelEl] of choiceLabels) labelEl.textContent = labels[state];
|
|
604
|
+
progressHeadLabel.textContent = S('progressLabel');
|
|
605
|
+
progress.setAttribute('aria-label', S('progressLabel'));
|
|
606
|
+
slider.setAttribute('aria-label', S('sliderAriaLabel'));
|
|
607
|
+
unknown.textContent = S('clearValueBtn');
|
|
608
|
+
noteLabel.textContent = S('notesLabel');
|
|
609
|
+
note.placeholder = S('notePlaceholder');
|
|
610
|
+
note.setAttribute('aria-label', S('noteAriaLabel'));
|
|
611
|
+
cancel.textContent = S('cancelBtn');
|
|
612
|
+
submit.textContent = S('saveBtn');
|
|
613
|
+
historyHeadingTitle.textContent = S('completedHeading');
|
|
614
|
+
back.textContent = S('backLabel');
|
|
615
|
+
if (timelineHeadingTitle) timelineHeadingTitle.textContent = S('timelineHeading');
|
|
616
|
+
if (timelineBackBtn) timelineBackBtn.textContent = S('backLabel');
|
|
617
|
+
resolveConflict.textContent = S('resolveConflictBtn');
|
|
618
|
+
target.tasksKey = null; target.completedKey = null; target.timelineRevision = null;
|
|
619
|
+
};
|
|
620
|
+
target.capabilities = embedded?.session?.capabilities || null;
|
|
621
|
+
panelEvent('open', entry);
|
|
622
|
+
target.request = (type, timeout, extra = {}) => new Promise((resolve, reject) => {
|
|
623
|
+
const requestId = `${requestPrefix}:${++serial}`;
|
|
624
|
+
const timer = setTimeout(() => { cancelRead(requestId, { type }); pending.delete(requestId); const error = new Error(S('cardRequestTimeout')); error.code = 'STATUS_REQUEST_TIMEOUT'; reject(error); }, timeout);
|
|
625
|
+
pending.set(requestId, { resolve, reject, timer, type, key: entry.key });
|
|
626
|
+
try { send(JSON.stringify({ type, requestId, key: entry.key, ...extra })); }
|
|
627
|
+
catch { clearTimeout(timer); pending.delete(requestId); const error = new Error(S('cardStatusDisconnected')); error.code = 'STATUS_SEND_FAILED'; reject(error); }
|
|
628
|
+
});
|
|
629
|
+
resolveConflict.onclick = () => rebaseDraft(target);
|
|
630
|
+
const showAppUpdate = info => {
|
|
631
|
+
target.updateInfo = info;
|
|
632
|
+
const update = info?.update;
|
|
633
|
+
const stage = update?.stage;
|
|
634
|
+
const stages = strings.updateStages || { queued: '正在准备升级', checking: '正在检查版本', downloading: '正在下载新版本', waiting: '等待当前分析结束', installing: '正在升级' };
|
|
635
|
+
const active = Boolean(stages[stage]) || target.upgradeStarting;
|
|
636
|
+
const completed = stage === 'completed' && Date.now() - Date.parse(update.updatedAt) < 60000;
|
|
637
|
+
const failed = stage === 'failed';
|
|
638
|
+
appUpdate.hidden = !info?.available && !active && !failed && !completed;
|
|
639
|
+
appUpdate.setAttribute('data-failed', String(failed));
|
|
640
|
+
appUpdateLabel.textContent = active ? stages[stage] || stages.queued : failed ? S('updateFailedLabel') : completed
|
|
641
|
+
? S('upgradedToPattern', { version: update.currentVersion }) : S('updateAvailablePattern', { version: info?.latestVersion });
|
|
642
|
+
appUpdateButton.textContent = active ? S('pleaseWait') : completed ? S('completedShort') : failed ? S('retryBtn') : S('upgradeBtn');
|
|
643
|
+
appUpdateButton.disabled = active || completed;
|
|
644
|
+
const command = info?.command || 'npx agent-things@latest';
|
|
645
|
+
appUpdateDetail.textContent = target.updateConnectionError ? `${S('reconnectHint')}\n${S('terminalUpgradePrefix')}${command}`
|
|
646
|
+
: failed ? `${update.error}\n${S('terminalUpgradePrefix')}${command}` : completed && update.reconnectMcp ? S('reconnectMcpHint') : '';
|
|
647
|
+
appUpdateDetail.hidden = !appUpdateDetail.textContent;
|
|
648
|
+
refreshPanel();
|
|
649
|
+
return active;
|
|
650
|
+
};
|
|
651
|
+
const pollAppUpdate = async () => {
|
|
652
|
+
clearTimeout(target.updateTimer);
|
|
653
|
+
try {
|
|
654
|
+
const info = await target.request('app-update-info', 12000);
|
|
655
|
+
if (panel !== target) return;
|
|
656
|
+
target.updateConnectionError = null;
|
|
657
|
+
const active = showAppUpdate(info);
|
|
658
|
+
target.updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
|
|
659
|
+
} catch (error) {
|
|
660
|
+
if (panel !== target) return;
|
|
661
|
+
target.updateConnectionError = error.message;
|
|
662
|
+
if (target.updateInfo) showAppUpdate(target.updateInfo);
|
|
663
|
+
target.updateTimer = setTimeout(pollAppUpdate, 2000);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
appUpdateButton.onclick = async () => {
|
|
667
|
+
if (appUpdateButton.disabled) return;
|
|
668
|
+
clearTimeout(target.updateTimer);
|
|
669
|
+
target.upgradeStarting = true;
|
|
670
|
+
showAppUpdate(target.updateInfo);
|
|
671
|
+
try {
|
|
672
|
+
const info = await target.request('app-update-start', 12000);
|
|
673
|
+
if (panel !== target) return;
|
|
674
|
+
target.updateConnectionError = null;
|
|
675
|
+
target.upgradeStarting = false;
|
|
676
|
+
showAppUpdate(info);
|
|
677
|
+
} catch (error) {
|
|
678
|
+
if (panel !== target) return;
|
|
679
|
+
target.upgradeStarting = false;
|
|
680
|
+
target.updateConnectionError = error.message;
|
|
681
|
+
showAppUpdate(target.updateInfo);
|
|
682
|
+
}
|
|
683
|
+
if (panel === target) target.updateTimer = setTimeout(pollAppUpdate, 1000);
|
|
684
|
+
};
|
|
685
|
+
target.scheduleMarquees = () => {
|
|
686
|
+
cancelAnimationFrame(target.marqueeFrame);
|
|
687
|
+
target.marqueeFrame = requestAnimationFrame(() => {
|
|
688
|
+
if (panel !== target) return;
|
|
689
|
+
if (target.mode === 'overview' && !target.summaryExpanded) summaryExpand.hidden = overviewSummary.scrollHeight <= overviewSummary.clientHeight + 1;
|
|
690
|
+
for (const title of shadow.querySelectorAll('.task-title')) {
|
|
691
|
+
if (!title.clientWidth) continue;
|
|
692
|
+
const width = title.firstElementChild.firstElementChild.getBoundingClientRect().width;
|
|
693
|
+
const maskWidth = title.closest('.task-row').querySelector('.task-source')?.offsetWidth || 0;
|
|
694
|
+
const distance = Math.max(0, width - title.clientWidth + maskWidth + 8);
|
|
695
|
+
title.classList.toggle('overflowing', distance > 1);
|
|
696
|
+
title.style.setProperty('--travel', `${distance}px`);
|
|
697
|
+
title.style.setProperty('--duration', `${Math.max(1, distance / 26)}s`);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
target.setSummaryExpanded = expanded => {
|
|
702
|
+
target.summaryExpanded = expanded;
|
|
703
|
+
summaryBlock.classList.toggle('expanded', expanded);
|
|
704
|
+
summaryExpand.textContent = expanded ? S('collapse') : S('expandAll');
|
|
705
|
+
summaryExpand.setAttribute('aria-expanded', String(expanded));
|
|
706
|
+
positionPanel(); target.scheduleMarquees();
|
|
707
|
+
};
|
|
708
|
+
summaryExpand.onclick = () => { summaryExpand.focus({ preventScroll: true }); target.setSummaryExpanded(!target.summaryExpanded); };
|
|
709
|
+
summaryBlock.addEventListener('focusout', event => { if (!summaryBlock.contains(event.relatedTarget)) target.setSummaryExpanded(false); });
|
|
710
|
+
target.resizeObserver = new ResizeObserver(target.scheduleMarquees); target.resizeObserver.observe(body);
|
|
711
|
+
target.setView = mode => {
|
|
712
|
+
target.mode = mode; overview.hidden = mode !== 'overview'; edit.hidden = mode !== 'edit'; history.hidden = mode !== 'history';
|
|
713
|
+
if (timelineView) timelineView.hidden = mode !== 'timeline';
|
|
714
|
+
body.scrollTop = 0; target.error.textContent = '';
|
|
715
|
+
if (mode !== 'edit') { target.conflict = false; resolveConflict.hidden = true; }
|
|
716
|
+
refreshPanel();
|
|
717
|
+
rememberPanel(target);
|
|
718
|
+
};
|
|
719
|
+
const cancelEdit = () => { target.dirty = false; target.setView('overview'); editOpen.focus(); };
|
|
720
|
+
target.cancelEdit = cancelEdit;
|
|
721
|
+
editOpen.onclick = () => { target.setView('edit'); (choices.get(target.draft.state) || choices.values().next().value).focus(); };
|
|
722
|
+
noteRow.onclick = () => { target.setView('edit'); note.focus(); };
|
|
723
|
+
historyOpen.onclick = () => target.setView('history'); back.onclick = () => target.setView('overview'); cancel.onclick = cancelEdit;
|
|
724
|
+
if (timelineOpen) timelineOpen.onclick = () => target.setView('timeline');
|
|
725
|
+
remainingToggle.onclick = () => { target.remainingExpanded = !target.remainingExpanded; refreshPanel(); };
|
|
726
|
+
const locate = async source => {
|
|
727
|
+
if (target.capabilities?.locate === false) { analysisMessage.textContent = S('locateHostDisconnected'); return; }
|
|
728
|
+
if (embedded) {
|
|
729
|
+
if (!source?.turnId || !source?.itemId) { analysisMessage.textContent = S('locateNoSource'); return; }
|
|
730
|
+
analysisMessage.textContent = S('locatingMessage');
|
|
731
|
+
try {
|
|
732
|
+
const result = await target.request('locate-source', 14000, { source: { turnId: source.turnId, itemId: source.itemId } });
|
|
733
|
+
analysisMessage.textContent = result?.message || S('locatedMessage');
|
|
734
|
+
} catch (error) { analysisMessage.textContent = error.message; }
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (!source?.turnId || !source?.itemId) { analysisMessage.textContent = S('locateNoSource'); return; }
|
|
738
|
+
const harness = window.__sessionStatusHarness;
|
|
739
|
+
if (harness?.locate) {
|
|
740
|
+
try { await harness.locate({ entry, source, analysisMessage, request: target.request }); }
|
|
741
|
+
catch (error) { analysisMessage.textContent = error.message; }
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const row = entry.row;
|
|
745
|
+
if (row.getAttribute('data-app-action-sidebar-thread-selected') !== 'true') {
|
|
746
|
+
const trigger = row.querySelector('[data-thread-title-trigger]');
|
|
747
|
+
if (!trigger) { analysisMessage.textContent = S('locateOpenFailed'); return; } trigger.click();
|
|
748
|
+
}
|
|
749
|
+
const deadline = Date.now() + 4000;
|
|
750
|
+
while (Date.now() < deadline) {
|
|
751
|
+
if (row.getAttribute('data-app-action-sidebar-thread-selected') === 'true') {
|
|
752
|
+
const message = [...document.querySelectorAll('[data-content-search-unit-key]')].find(node => node.getAttribute('data-content-search-unit-key') === `${source.turnId}:${source.itemId}`);
|
|
753
|
+
if (message) { message.scrollIntoView({ block: 'center', behavior: 'smooth' }); const previous = message.style.outline; message.style.outline = '2px solid #0169cc'; setTimeout(() => { if (message.style.outline === '2px solid rgb(1, 105, 204)') message.style.outline = previous; }, 3000); analysisMessage.textContent = S('locatedMessage'); return; }
|
|
754
|
+
}
|
|
755
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
756
|
+
}
|
|
757
|
+
try { await target.request('locate-source', 30000, { source }); analysisMessage.textContent = S('locatedMessage'); }
|
|
758
|
+
catch (error) { analysisMessage.textContent = error.message; }
|
|
759
|
+
};
|
|
760
|
+
const renderTask = (task, sources, parent) => {
|
|
761
|
+
const row = element('div', null, parent, 'task-row'); row.dataset.status = task.status; row.tabIndex = 0;
|
|
762
|
+
element('span', null, row, 'task-dot'); const content = element('div', null, row, 'task-content');
|
|
763
|
+
const title = element('div', null, content, 'task-title'); title.title = task.title;
|
|
764
|
+
const track = element('div', null, title, 'task-track');
|
|
765
|
+
const text = task.summary || task.title;
|
|
766
|
+
element('span', text, track, 'task-copy');
|
|
767
|
+
element('div', taskLabels[task.status] || S('taskUnknown'), content, 'task-meta');
|
|
768
|
+
const ref = task.evidenceRefs?.find(value => sources?.[value]?.turnId);
|
|
769
|
+
if (ref) { const mask = element('div', null, row, 'task-source'); const link = element('button', S('viewSource'), mask); link.setAttribute('aria-label', `${S('viewSourceAriaPrefix')}${task.title}`); link.onclick = () => locate(sources[ref]); }
|
|
770
|
+
};
|
|
771
|
+
target.renderHistory = () => {
|
|
772
|
+
const state = target.analysisState; if (!state) return;
|
|
773
|
+
if (timelineList && target.timelineRevision !== state.revision) {
|
|
774
|
+
target.timelineRevision = state.revision;
|
|
775
|
+
timelineList.replaceChildren();
|
|
776
|
+
for (const item of [...(state.timeline || [])].reverse()) {
|
|
777
|
+
const date = new Date(item.requestedAt).toLocaleString(activeLang === 'en' ? 'en-US' : 'zh-CN');
|
|
778
|
+
const progress = item.record?.progress ?? item.progress;
|
|
779
|
+
const label = item.source === 'analysis' ? S('timelineAnalysis') : S('timelineManual');
|
|
780
|
+
const value = item.status === 'failed' ? S('analysisFailedWord') : item.status === 'pending' ? S('analyzingWord') : progress == null ? S('unrecordedShort') : `${progress}%`;
|
|
781
|
+
element('div', `${date} · ${label} · ${value}`, timelineList, 'quiet-row');
|
|
782
|
+
}
|
|
783
|
+
if (!timelineList.childElementCount) element('div', S('emptyTimeline'), timelineList, 'empty');
|
|
784
|
+
}
|
|
785
|
+
const ledger = state.analysis?.ledger; const tasks = ledger?.tasks || [];
|
|
786
|
+
const remaining = tasks.filter(task => ['todo', 'in_progress', 'blocked', 'needs_verification'].includes(task.status));
|
|
787
|
+
const completed = tasks.filter(task => task.status === 'done');
|
|
788
|
+
totals.textContent = tasks.length ? S('totalsPattern', { done: completed.length, total: tasks.length }) : S('totalsEmpty');
|
|
789
|
+
tasksHeading.textContent = S('remainingHeadingPattern', { count: remaining.length });
|
|
790
|
+
remainingToggle.hidden = remaining.length <= 3;
|
|
791
|
+
remainingToggle.textContent = target.remainingExpanded ? S('collapseArrow') : S('showAllCountPattern', { count: remaining.length });
|
|
792
|
+
remainingToggle.setAttribute('aria-expanded', String(Boolean(target.remainingExpanded)));
|
|
793
|
+
const tasksKey = JSON.stringify([remaining, state.analysis?.sources, Boolean(target.remainingExpanded), activeLang]);
|
|
794
|
+
if (target.tasksKey !== tasksKey) {
|
|
795
|
+
target.tasksKey = tasksKey; currentTasks.replaceChildren();
|
|
796
|
+
if (!tasks.length) element('div', S('emptyNoTasks'), currentTasks, 'empty');
|
|
797
|
+
else if (!remaining.length) element('div', S('emptyNoRemaining'), currentTasks, 'empty');
|
|
798
|
+
for (const task of target.remainingExpanded ? remaining : remaining.slice(0, 3)) renderTask(task, state.analysis?.sources, currentTasks);
|
|
799
|
+
}
|
|
800
|
+
historyCount.textContent = S('countArrowPattern', { count: completed.length });
|
|
801
|
+
const completedKey = JSON.stringify([completed, state.analysis?.sources, activeLang]);
|
|
802
|
+
if (target.completedKey === completedKey) return;
|
|
803
|
+
target.completedKey = completedKey; historyList.replaceChildren();
|
|
804
|
+
for (const task of completed) renderTask(task, state.analysis?.sources, historyList);
|
|
805
|
+
if (!completed.length) element('div', S('emptyCompleted'), historyList, 'empty');
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
const pollHistory = () => {
|
|
809
|
+
if (panel !== target) return;
|
|
810
|
+
target.request('analysis-state', 7000).then(showHistory).catch(() => {
|
|
811
|
+
if (panel !== target) return;
|
|
812
|
+
analysisMessage.textContent = S('retryingStatus');
|
|
813
|
+
clearTimeout(target.pollTimer); target.pollTimer = setTimeout(pollHistory, 2000);
|
|
814
|
+
});
|
|
815
|
+
};
|
|
816
|
+
target.pollHistory = pollHistory;
|
|
817
|
+
const showHistory = state => {
|
|
818
|
+
if (panel !== target || !state || (target.historyRevision ?? -1) > state.revision) return;
|
|
819
|
+
target.historyRevision = state.revision; target.analysisState = state;
|
|
820
|
+
const active = (state.timeline || []).find(item => item.source === 'analysis' && item.status === 'pending');
|
|
821
|
+
target.analyzing = Boolean(active); analyze.disabled = target.analyzing;
|
|
822
|
+
const stages = strings.analysisStages || { starting: '正在启动分析', reading: '正在读取会话', retrying: '正在重新连接', analyzing: '正在分析任务' };
|
|
823
|
+
target.stageMessage = active ? (stages[active.stage] || stages.analyzing) : '';
|
|
824
|
+
const latest = state.timeline?.at(-1);
|
|
825
|
+
analysisMessage.textContent = target.stageMessage || (latest?.status === 'failed' ? `${S('analysisFailedPrefix')}${latest.error || S('analysisFailedRetry')}` : ''); analyze.textContent = active ? S('btnUpdating') : S('btnUpdate');
|
|
826
|
+
clearTimeout(target.pollTimer); if (active && !embedded?.streamConnected) target.pollTimer = setTimeout(pollHistory, 2000);
|
|
827
|
+
refreshPanel();
|
|
828
|
+
};
|
|
829
|
+
target.showHistory = showHistory;
|
|
830
|
+
analyze.onclick = async () => {
|
|
831
|
+
analyze.disabled = true; analysisMessage.textContent = S('startingAnalysisFeedback');
|
|
832
|
+
try { showHistory(await target.request('analyze', 7000)); }
|
|
833
|
+
catch (error) {
|
|
834
|
+
if (panel !== target) return;
|
|
835
|
+
if (['STATUS_REQUEST_TIMEOUT', 'STATUS_SEND_FAILED'].includes(error.code)) {
|
|
836
|
+
analysisMessage.textContent = S('retryingStatus'); clearTimeout(target.pollTimer); target.pollTimer = setTimeout(pollHistory, 2000);
|
|
837
|
+
} else { analysisMessage.textContent = error.message; analyze.disabled = false; }
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
const setProgress = value => {
|
|
841
|
+
const state = presentation ? presentation.progressState(target.draft.state, value) : value === 100 ? target.draft.state === 'pushed' ? 'pushed' : 'completed'
|
|
842
|
+
: value === 0 && target.draft.state === 'unstarted' ? 'unstarted' : 'unfinished';
|
|
843
|
+
updateDraft(target, { progress: value, state });
|
|
844
|
+
};
|
|
845
|
+
let dragging = false;
|
|
846
|
+
slider.onpointerdown = () => { dragging = true; };
|
|
847
|
+
const endDrag = () => { dragging = false; }; slider.onpointerup = endDrag; slider.onpointercancel = endDrag; slider.onlostpointercapture = endDrag;
|
|
848
|
+
slider.oninput = () => { const value = Number(slider.value), nearest = Math.round(value / 25) * 25; setProgress(presentation ? presentation.progressValue(value, dragging) : dragging && Math.abs(value - nearest) <= 2 ? nearest : value); };
|
|
849
|
+
progress.oninput = () => { const raw = progress.value.trim(); if (!raw) setProgress(null); else if (Number.isInteger(Number(raw)) && Number(raw) >= 0 && Number(raw) <= 100) setProgress(Number(raw)); else target.dirty = true; };
|
|
850
|
+
unknown.onclick = () => setProgress(null);
|
|
851
|
+
note.oninput = () => { target.draft.note = note.value; target.dirty = true; rememberPanel(target); };
|
|
852
|
+
submit.onclick = async () => { if (await save({}, false, target)) target.setView('overview'); };
|
|
853
|
+
progress.onkeydown = event => { if (event.key === 'Enter') submit.click(); };
|
|
854
|
+
clear.onclick = async () => { if (await save({}, true, target)) target.setView('overview'); };
|
|
855
|
+
if (close) close.onclick = () => closePanel();
|
|
856
|
+
if (openPane) openPane.onclick = async () => {
|
|
857
|
+
openPane.disabled = true; analysisMessage.textContent = '';
|
|
858
|
+
try { await harness.openPane({ entry, request: target.request }); if (panel === target) closePanel(); }
|
|
859
|
+
catch (error) { if (panel === target) { openPane.disabled = false; analysisMessage.textContent = error.message; } }
|
|
860
|
+
};
|
|
861
|
+
// 首次历史读取前以当前快照为基线:读取期间到达的新版快照会触发补读。
|
|
862
|
+
target.syncVersion = panelVersion(entry.key);
|
|
863
|
+
if (embedded?.analysisState) showHistory(embedded.analysisState); else pollHistory();
|
|
864
|
+
pollAppUpdate();
|
|
865
|
+
target.request('project-git', 14000).then(info => { if (panel === target) { target.projectGit = info; refreshPanel(); } }).catch(() => {
|
|
866
|
+
if (panel === target) { target.projectGit = { status: 'unknown', hasRemote: false }; refreshPanel(); }
|
|
867
|
+
});
|
|
868
|
+
entry.button?.setAttribute('aria-expanded', 'true'); refreshPanel();
|
|
869
|
+
const remembered = rememberedPanel(entry.key);
|
|
870
|
+
if (remembered) restorePanel(target, remembered); else if (!embedded) editOpen.focus();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function receive(next) {
|
|
874
|
+
if (!next || (next.revision < snapshot.revision && (!next.lang || next.lang === activeLang))) return;
|
|
875
|
+
const langChanged = next.lang ? setLang(next.lang) : false;
|
|
876
|
+
snapshot = next;
|
|
877
|
+
if (langChanged && panel) panel.applyLocale?.();
|
|
878
|
+
for (const entry of mounted.values()) paint(entry);
|
|
879
|
+
refreshPanel();
|
|
880
|
+
// 其他入口改了这个会话(保存、清除、分析、任务来源):按单会话数据版本补读;弹窗忙时记下,空闲后补读一次。乱序回复由 historyRevision 丢弃。
|
|
881
|
+
if (panel?.pollHistory) syncPanel(panel);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function panelVersion(key) {
|
|
885
|
+
if (snapshot.keyVersions) return snapshot.keyVersions[key] ?? snapshot.keyVersionBase ?? 0;
|
|
886
|
+
return JSON.stringify([snapshot.records?.[key] || null, (snapshot.analyzingKeys || []).includes(key)]);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function syncPanel(target) {
|
|
890
|
+
const version = panelVersion(target.entry.key);
|
|
891
|
+
if (target.syncVersion === undefined) { target.syncVersion = version; return; }
|
|
892
|
+
if (target.syncVersion === version && !target.syncPending) return;
|
|
893
|
+
if (target.busy) { target.syncPending = true; return; }
|
|
894
|
+
target.syncVersion = version; target.syncPending = false; target.pollHistory();
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function onOutside(event) {
|
|
898
|
+
if (!panel || event.composedPath().includes(panel.root) || event.composedPath().includes(panel.entry.host)) return;
|
|
899
|
+
if (event.composedPath().some(node => node.hasAttribute?.('data-codex-session-status'))) return;
|
|
900
|
+
closePanel(false);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function onKey(event) {
|
|
904
|
+
if (!panel || event.key !== 'Escape') return;
|
|
905
|
+
event.preventDefault(); event.stopPropagation();
|
|
906
|
+
closePanel();
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function onScroll() {
|
|
910
|
+
if (!panel) return;
|
|
911
|
+
if (!visible(panel.entry.host)) closePanel(false);
|
|
912
|
+
else positionPanel();
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const observer = new MutationObserver(records => {
|
|
916
|
+
if (records.every(r => r.target.closest?.('[data-codex-session-status], [data-codex-session-status-panel]'))) return;
|
|
917
|
+
schedule();
|
|
918
|
+
});
|
|
919
|
+
const filter = harness?.attributeFilter || ['data-app-action-sidebar-thread-selected', 'data-app-action-sidebar-thread-id', 'data-app-action-sidebar-thread-host-id', 'data-app-action-sidebar-thread-title', 'hidden', 'aria-expanded', 'style', 'class', 'data-theme'];
|
|
920
|
+
if (!embedded) {
|
|
921
|
+
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: filter });
|
|
922
|
+
document.addEventListener('pointerdown', onOutside, true);
|
|
923
|
+
document.addEventListener('keydown', onKey, true);
|
|
924
|
+
document.addEventListener('scroll', onScroll, true);
|
|
925
|
+
}
|
|
926
|
+
window.addEventListener('resize', positionPanel);
|
|
927
|
+
const api = {
|
|
928
|
+
receive(next) { receive(next); localCards?.receive(next); },
|
|
929
|
+
receiveCardEvent({ snapshot: next, analysisState, session }) {
|
|
930
|
+
if (!embedded) return;
|
|
931
|
+
embedded.streamConnected = true;
|
|
932
|
+
if (!next || next.revision < snapshot.revision) return;
|
|
933
|
+
if (panel && session?.key === panel.entry.key) panel.capabilities = session.capabilities;
|
|
934
|
+
receive(next);
|
|
935
|
+
panel?.showHistory(analysisState);
|
|
936
|
+
},
|
|
937
|
+
disconnectCardEvents() {
|
|
938
|
+
if (!embedded?.streamConnected) return;
|
|
939
|
+
embedded.streamConnected = false;
|
|
940
|
+
if (panel?.analyzing) panel.pollHistory();
|
|
941
|
+
},
|
|
942
|
+
setTheme(theme) { if (embedded && embedded.theme !== theme && ['light', 'dark'].includes(theme)) { embedded.theme = theme; positionPanel(); } },
|
|
943
|
+
reply(message) {
|
|
944
|
+
localCards?.reply(message);
|
|
945
|
+
const { requestId, error, errorInfo, session, snapshot: next, analysisState, projectGit, updateInfo, navigation, pane } = message;
|
|
946
|
+
if (panel && session?.key === panel.entry.key) panel.capabilities = session.capabilities;
|
|
947
|
+
receive(next);
|
|
948
|
+
const request = pending.get(requestId);
|
|
949
|
+
if (!request) return;
|
|
950
|
+
clearTimeout(request.timer); pending.delete(requestId);
|
|
951
|
+
if (error) request.reject(Object.assign(new Error(error), errorInfo || {})); else request.resolve(navigation || updateInfo || projectGit || analysisState || pane);
|
|
952
|
+
},
|
|
953
|
+
status: () => ({ mounted: mounted.size, panelOpen: Boolean(panel), revision: snapshot.revision, version, startup: { ...startup } }),
|
|
954
|
+
exportForReload({ allowPending = false } = {}) {
|
|
955
|
+
if (!allowPending && (panel?.busy || pending.size)) return { busy: true };
|
|
956
|
+
const active = panel ? rememberPanel(panel) : null;
|
|
957
|
+
return { snapshot, panel: active, panelStates: [...panelStates], localCards: localCards?.exportState() };
|
|
958
|
+
},
|
|
959
|
+
destroy() {
|
|
960
|
+
destroyed = true; localCards?.destroy(); harness?.dispose?.(); observer.disconnect(); cancelAnimationFrame(frame);
|
|
961
|
+
if (panel) { rememberPanel(panel); panelEvent('dispose', panel.entry); clearTimeout(panel.pollTimer); clearTimeout(panel.updateTimer); cancelAnimationFrame(panel.marqueeFrame); panel.resizeObserver?.disconnect(); panel.root.remove(); panel.entry.button?.setAttribute('aria-expanded', 'false'); panel = null; }
|
|
962
|
+
for (const entry of [...mounted.values()]) unmount(entry);
|
|
963
|
+
document.removeEventListener('pointerdown', onOutside, true); document.removeEventListener('keydown', onKey, true);
|
|
964
|
+
document.removeEventListener('scroll', onScroll, true); window.removeEventListener('resize', positionPanel);
|
|
965
|
+
for (const request of pending.values()) { clearTimeout(request.timer); request.reject(new Error(S('cardDaemonDisconnected'))); }
|
|
966
|
+
pending.clear(); if (!embedded?.independent) delete window.__codexSessionStatus;
|
|
967
|
+
if (harness?.globalName && window[harness.globalName]) delete window[harness.globalName];
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
if (!embedded?.independent) window.__codexSessionStatus = api;
|
|
971
|
+
if (harness?.globalName) window[harness.globalName] = api;
|
|
972
|
+
if (embedded) {
|
|
973
|
+
receive(embedded.snapshot);
|
|
974
|
+
openPanel({ key: embedded.key, title: embedded.title });
|
|
975
|
+
if (restored?.panel) restorePanel(panel, restored.panel);
|
|
976
|
+
return api;
|
|
977
|
+
}
|
|
978
|
+
localCards = harness?.createLocalCards?.({
|
|
979
|
+
mount: (options, state) => installCodexSessionStatus(version, state, options),
|
|
980
|
+
send: payload => send(payload), snapshot: () => snapshot, restored: restored?.localCards,
|
|
981
|
+
});
|
|
982
|
+
reconcile();
|
|
983
|
+
if (restored) {
|
|
984
|
+
receive(restored.snapshot);
|
|
985
|
+
const saved = restored.panel;
|
|
986
|
+
const entry = saved && [...mounted.values()].find(item => item.key === saved.key);
|
|
987
|
+
if (entry) {
|
|
988
|
+
panelStates.set(saved.key, saved);
|
|
989
|
+
openPanel(entry);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|