Fix builder plan message display and error handling

- Strip double stars (**) and double hashtags (##) from plan message displayContent in both client and server
- Fix server restart error replacing plan message by skipping error state for plan messages
- Fix rate limiting regex pattern to use proper global flag
This commit is contained in:
Developer
2026-02-16 08:40:58 +00:00
parent 816e72fb03
commit 14f59c2f56
2 changed files with 40 additions and 4 deletions

View File

@@ -1896,6 +1896,17 @@ function hideLoadingIndicator() {
window.hideLoadingIndicator = hideLoadingIndicator;
function renderMessages(session) {
// Helper function to strip markdown formatting from user input
function stripMarkdownFormatting(text) {
if (!text || typeof text !== 'string') return text;
let cleaned = text;
cleaned = cleaned.replace(/\*\*([^*]+)\*\*/g, '$1');
cleaned = cleaned.replace(/\*\*/g, '');
cleaned = cleaned.replace(/^##\s+/gm, '');
cleaned = cleaned.replace(/##/g, '');
return cleaned;
}
// Don't clear the loading indicator if it exists
const loadingIndicator = document.getElementById('loading-indicator');
// Store reference before clearing, and remove animation class to prevent bounce on re-render
@@ -1960,7 +1971,8 @@ function renderMessages(session) {
`;
const userBody = document.createElement('div');
userBody.className = 'body';
userBody.appendChild(renderContentWithTodos(msg.displayContent || msg.content || ''));
const contentToRender = isPlanMessage ? stripMarkdownFormatting(msg.displayContent || msg.content || '') : (msg.displayContent || msg.content || '');
userBody.appendChild(renderContentWithTodos(contentToRender));
userCard.appendChild(userMeta);
userCard.appendChild(userBody);
// Attachments
@@ -3190,7 +3202,18 @@ function streamMessage(sessionId, messageId) {
const message = session?.messages.find(m => m.id === messageId);
if (message && message.status === 'queued') {
// Server restart was signaled, poll for reconnection
// Check if this is a plan message (don't set error for plan messages, just log)
const isPlanMessage = message.phase === 'plan' || message.cli !== 'opencode';
if (isPlanMessage) {
// For plan messages, just log and don't modify the message
console.log('[SSE] Plan message encountered server restart, preserving original content', { messageId, sessionId });
hideLoadingIndicator();
setStatus('Service temporarily unavailable. Please try again in a moment.');
return;
}
// For OpenCode messages, poll for reconnection
console.log('Server restart detected, attempting reconnection...', { messageId, sessionId });
let reconnectAttempts = 0;
const maxReconnectAttempts = 30; // 30 seconds max