Skip to content

fix(ui): avoid false stale chat send guard#2034

Open
erauner12 wants to merge 9 commits into
kagent-dev:mainfrom
erauner12:fix/ui-send-guard-streaming-messages
Open

fix(ui): avoid false stale chat send guard#2034
erauner12 wants to merge 9 commits into
kagent-dev:mainfrom
erauner12:fix/ui-send-guard-streaming-messages

Conversation

@erauner12

@erauner12 erauner12 commented Jun 17, 2026

Copy link
Copy Markdown

Fixes a false-positive chat send guard that can show New messages loaded — please review before sending during normal same-tab usage after an agent response has already completed and is visible.

The send guard now compares backend-derived messages against all locally visible comparable messages instead of only persisted/stored messages. This preserves the intended cross-tab stale-message warning while allowing the next same-tab send to proceed.

Fixes #2033.

Changes

  • Count all locally visible comparable chat messages when deciding whether the backend has unseen messages.
  • Apply the same comparable-message filtering to backend-derived messages before comparing counts.
  • Add mounted regression tests covering:
    • same-tab completed stream does not block the next send
    • true cross-tab/unseen messages still block
    • cross-tab/unseen messages still block after a same-tab stream

Validation

Automated:

cd ui
npm test -- --runTestsByPath src/components/chat/__tests__/ChatInterface.sendGuard.test.tsx --runInBand

Result:

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total

Previously also run successfully during branch validation:

src/lib/__tests__/messageHandlers.test.ts: 27 passed
Full UI Jest suite: 268 passed

Manual:

  • Deployed/tested locally against kind-kagent.
  • Verified the next same-tab message sends without the false New messages loaded toast after a completed agent response.

Signed-off-by: Evan Rauner <raunerevan@gmail.com>
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 17, 2026
@erauner12 erauner12 marked this pull request as ready for review June 17, 2026 01:17
@erauner12 erauner12 requested a review from peterj as a code owner June 17, 2026 01:17
Copilot AI review requested due to automatic review settings June 17, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the cross-tab “send guard” logic in ChatInterface to avoid falsely blocking sends when same-tab streaming messages are already visible, and adds Jest coverage for the updated behavior.

Changes:

  • Count comparable messages using both stored + streaming messages (and exclude specific ADK originalTypes) to prevent false “stale messages” blocks.
  • Reuse the same comparable-message counting logic for both local and DB message comparisons.
  • Add a dedicated test suite validating send-guard behavior across same-tab streaming and cross-tab updates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ui/src/components/chat/ChatInterface.tsx Refines send-guard message counting and centralizes exclusion logic to reduce false blocks.
ui/src/components/chat/tests/ChatInterface.sendGuard.test.tsx Adds regression tests covering same-tab streaming vs cross-tab message scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/src/components/chat/ChatInterface.tsx Outdated
Comment thread ui/src/components/chat/ChatInterface.tsx Outdated
Comment thread ui/src/components/chat/__tests__/ChatInterface.sendGuard.test.tsx Outdated
@mesutoezdil

mesutoezdil commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

1 small thing worth adding: a 1-line comment on why ToolCallSummaryMessage is in the excluded set. It is the only newly added type and not obvious from the name alone whether it can indicate real unseen context.

erauner12 and others added 8 commits June 17, 2026 05:46
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Signed-off-by: Evan Rauner <raunerevan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI chat: "New messages loaded" notification can incorrectly block sending the next message

3 participants