Skip to content

FIX GUI conversation switching during in-flight requests and sort ordering#1517

Merged
adrian-gavrila merged 1 commit intomicrosoft:mainfrom
adrian-gavrila:fix/conversation-switching-inflight
Mar 18, 2026
Merged

FIX GUI conversation switching during in-flight requests and sort ordering#1517
adrian-gavrila merged 1 commit intomicrosoft:mainfrom
adrian-gavrila:fix/conversation-switching-inflight

Conversation

@adrian-gavrila
Copy link
Copy Markdown
Contributor

Description

Fixes two bugs in the frontend conversation panel:

  1. Conversation switching blocked during in-flight requests — A sendingConvIdsRef guard in ChatWindow.tsx's useEffect
    prevented loading messages for any conversation with an active send. This was redundant since loadConversation() already handles in-flight conversations by appending in-flight user messages and a loading spinner. Removed the 3-line guard.

  2. In-flight conversations jump position after first responseattack_service.py sorts conversations by created_at, but
    in-flight conversations have created_at=None (no stored messages yet), causing them to sort unpredictably. Additionally, SQLite raw queries return timezone-naive datetimes while the rest of the codebase uses UTC-aware datetimes, causing TypeError on comparison.
    Fixed by normalizing naive timestamps to UTC in the sort loop and using datetime.now(timezone.utc) as a fallback for None, so in-flight conversations consistently sort to the end.

Tests and Documentation

  • All existing unit tests pass
  • Pre-commit hooks pass
  • Manually tested both fixes live:
    • Verified switching between conversations while a request is in-flight works correctly
    • Verified in-flight conversations stay at the bottom of the list consistently after the first response arrives
  • No new tests added — these are behavioral fixes to existing logic with no new API surface

@adrian-gavrila adrian-gavrila changed the title FIX conversation switching during in-flight requests and sort ordering FIX GUI conversation switching during in-flight requests and sort ordering Mar 18, 2026
- Replace broad sendingConvIdsRef guard in ChatWindow useEffect with a
  forceLoadRef mechanism. User-initiated panel clicks set forceLoadRef
  to bypass the guard, allowing switches to sending conversations.
  Internal activeConversationId changes from handleSend (e.g., after
  attack creation) leave forceLoadRef unset so the guard protects
  optimistic messages from being overwritten by loadConversation.

- Normalize naive timestamps from SQLite to UTC before sorting conversations.
  Raw SQL queries return timezone-naive datetimes while the rest of the
  codebase uses UTC-aware datetimes, causing TypeError on comparison.

- In-flight conversations (no stored messages, created_at=None) now sort
  to the end using datetime.now(timezone.utc) as fallback, keeping them
  at the bottom of the list consistently.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adrian-gavrila adrian-gavrila force-pushed the fix/conversation-switching-inflight branch from 211ebb2 to f1b6fdf Compare March 18, 2026 15:47
Copy link
Copy Markdown
Contributor

@romanlutz romanlutz left a comment

Choose a reason for hiding this comment

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

Nice!

@adrian-gavrila adrian-gavrila merged commit bdda601 into microsoft:main Mar 18, 2026
41 checks passed
riyosha pushed a commit to riyosha/PyRIT that referenced this pull request Mar 24, 2026
…ering (microsoft#1517)

Co-authored-by: Adrian Gavrila <agavrila@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jbolor21 pushed a commit to jbolor21/jbolor-PyRIT that referenced this pull request Mar 25, 2026
…ering (microsoft#1517)

Co-authored-by: Adrian Gavrila <agavrila@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants