+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -202,9 +215,12 @@
btn.disabled = true;
btn.textContent = '生成中...';
+ btn.classList.add('opacity-70', 'cursor-not-allowed');
output.classList.remove('hidden');
outputContent.classList.add('hidden');
streaming.classList.remove('hidden');
+ document.getElementById('streaming-text').textContent = '';
+ document.getElementById('streaming-status').textContent = '';
// Clear previous results
document.getElementById('pr-title').textContent = '';
@@ -213,54 +229,64 @@
document.getElementById('pr-details').innerHTML = '';
document.getElementById('pr-impact').textContent = '';
document.getElementById('pr-markdown').textContent = '';
- document.getElementById('markdown-preview').classList.add('hidden');
markdownContent = '';
// Accumulate streaming content
const fields = { title: '', type: '', summary: '', details: '', impact: '' };
+ let rawStreamText = '';
SSE.post(`/api/repos/${repoId}/generate`, {
base: baseRef,
head: headRef,
}, {
+ // Raw streaming content from LLM — show in real-time
+ content(data) {
+ const chunk = data.content || '';
+ rawStreamText += chunk;
+ document.getElementById('streaming-text').textContent = rawStreamText;
+ // Auto-scroll to bottom
+ const container = document.getElementById('streaming-content');
+ container.scrollTop = container.scrollHeight;
+ },
title(data) {
fields.title += data.content || '';
document.getElementById('pr-title').textContent = fields.title;
- document.getElementById('streaming-status').textContent = '生成标题...';
+ document.getElementById('streaming-status').textContent = '解析标题...';
},
type(data) {
fields.type += data.content || '';
document.getElementById('pr-type').textContent = fields.type;
- document.getElementById('streaming-status').textContent = '生成类型...';
+ document.getElementById('streaming-status').textContent = '解析类型...';
},
summary(data) {
fields.summary += data.content || '';
document.getElementById('pr-summary').textContent = fields.summary;
- document.getElementById('streaming-status').textContent = '生成摘要...';
+ document.getElementById('streaming-status').textContent = '解析摘要...';
},
detail(data) {
fields.details += data.content || '';
document.getElementById('pr-details').innerHTML = renderMarkdown(fields.details);
- document.getElementById('streaming-status').textContent = '生成详细说明...';
+ document.getElementById('streaming-status').textContent = '解析详细说明...';
},
impact(data) {
fields.impact += data.content || '';
document.getElementById('pr-impact').textContent = fields.impact;
- document.getElementById('streaming-status').textContent = '生成影响范围...';
+ document.getElementById('streaming-status').textContent = '解析影响范围...';
},
markdown(data) {
markdownContent += data.content || '';
document.getElementById('pr-markdown').textContent = markdownContent;
},
done() {
- // Assemble full markdown from structured fields for copy
+ // Assemble full markdown from structured fields
markdownContent = buildMarkdown(fields);
document.getElementById('pr-markdown').textContent = markdownContent;
- document.getElementById('markdown-preview').classList.remove('hidden');
+ // Switch from streaming to structured display
streaming.classList.add('hidden');
outputContent.classList.remove('hidden');
btn.disabled = false;
btn.textContent = '生成 PR 描述';
+ btn.classList.remove('opacity-70', 'cursor-not-allowed');
},
error(data) {
showToast('生成失败: ' + (data.message || '未知错误'), 'error');
@@ -268,6 +294,7 @@
output.classList.add('hidden');
btn.disabled = false;
btn.textContent = '生成 PR 描述';
+ btn.classList.remove('opacity-70', 'cursor-not-allowed');
},
});
}