Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/presenter/agentPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ export class AgentPresenter implements IAgentPresenter {
}

await this.messageManager.editMessage(messageId, JSON.stringify(content))
if (message.status === 'pending') {
await this.messageManager.updateMessageStatus(messageId, 'sent')
}
presenter.sessionManager.clearPendingQuestion(message.conversationId)
presenter.sessionManager.setStatus(message.conversationId, 'idle')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ export class LLMEventHandler {
{},
state.message.content
)
if (hasPendingQuestions) {
// Question tool ends the assistant message even when waiting for user input.
await this.messageManager.updateMessageStatus(eventId, 'sent')
}
this.searchingMessages.delete(eventId)
presenter.sessionManager.setStatus(state.conversationId, 'waiting_permission')
if (!hasPendingPermissions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ export class MessageManager implements IMessageManager {

// 处理每个未完成的消息
for (const message of pendingMessages) {
const blocks = Array.isArray(message.content) ? message.content : []
const hasQuestionRequest = blocks.some(
(block) => block.type === 'action' && block.action_type === 'question_request'
)
if (hasQuestionRequest) {
await this.updateMessageStatus(message.id, 'sent')
continue
}
Comment on lines +387 to +394
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Finalize non-action loading blocks when restoring question messages.

Marking the message as sent without normalizing loading blocks can leave spinners stuck after a restart. Consider finalizing non-action loading blocks before persisting status.

💡 Suggested fix
           if (hasQuestionRequest) {
+            let didNormalize = false
+            const normalizedBlocks = blocks.map((block) => {
+              if (block.type !== 'action' && block.status === 'loading') {
+                didNormalize = true
+                return { ...block, status: 'success' }
+              }
+              return block
+            })
+            if (didNormalize) {
+              await this.editMessage(message.id, JSON.stringify(normalizedBlocks))
+            }
             await this.updateMessageStatus(message.id, 'sent')
             continue
           }
🤖 Prompt for AI Agents
In `@src/main/presenter/sessionPresenter/managers/messageManager.ts` around lines
387 - 394, When restoring messages that contain a question_request action in
MessageManager (messageManager.ts), finalize any non-action "loading" blocks in
message.content before calling updateMessageStatus(message.id, 'sent') so
spinners don't remain stuck; specifically, iterate the blocks array (the same
one used for the hasQuestionRequest check), convert any loading-type blocks that
are not action blocks into their final form (e.g., replace or mutate their
type/content to a completed/text block or set a completed flag), persist those
changes to the message object, then call this.updateMessageStatus(message.id,
'sent') and continue. Ensure you touch the same message.content structure and
keep the existing hasQuestionRequest logic.

await this.handleMessageError(message.id, 'common.error.sessionInterrupted')
}
}
Expand Down