Skip to content

fix(ui): new chat targets focused instance, fix conversation creation flicker#216

Merged
karthikmudunuri merged 6 commits intomainfrom
fix/ui-new-conversation-target-and-flicker
Apr 8, 2026
Merged

fix(ui): new chat targets focused instance, fix conversation creation flicker#216
karthikmudunuri merged 6 commits intomainfrom
fix/ui-new-conversation-target-and-flicker

Conversation

@karthikmudunuri
Copy link
Copy Markdown
Member

Three bugs in sidebar conversation creation:

  1. "New chat" button always created conversations for the alphabetically first instance instead of the one the user is currently viewing. Fixed by using focusedSpritzName when available, falling back to firstAgentName.

  2. Creating a new conversation caused visible flickering because navigate() was called after setSelectedConversation(), causing the URL sync effect to fire a competing navigation. Fixed by navigating first, then updating state. Also switched the creatingConversationFor guard to a ref to prevent stale closure issues on rapid clicks.

  3. New conversations appeared at the bottom of the conversation list because the server may not return lastActivityAt immediately. Fixed by prepending new conversations to the list instead of appending and re-sorting.

WebSocket connections are not affected — fetchAgents deps, applyConversationUpdate guard, and useChatConnection invocation are all unchanged.

Files changed:

  • ui/src/components/acp/sidebar.tsx
  • ui/src/pages/chat.tsx

… flicker

The "New chat" button always created conversations for the alphabetically
first instance instead of the currently focused one. Conversation creation
also caused flickering due to competing navigations and new conversations
appeared at the bottom of the list.

- Use focusedSpritzName for "New chat" button, fall back to first agent
- Navigate before setting state in handleNewConversation to prevent URL
  sync effect from firing a competing navigation
- Use ref-based guard for creatingConversationFor to avoid stale closures
- Prepend new conversations instead of append+sort so they appear at top
- Sidebar: "New chat" calls onNewConversation with focused instance name
- Sidebar: falls back to first agent when no instance is focused
- ChatPage: new conversation creation navigates to the correct instance
- ChatPage: new conversations are prepended at top of conversation list
The new conversation tests triggered the full useChatConnection lifecycle
after navigating to the new conversation. In CI, the ACP client start()
would hang waiting for WebSocket resolution. Fixed by setting
setACPStartPending(true) before clicking the new conversation button,
which makes start() hang in a controlled way without blocking the test.
Also removed unnecessary bootstrap mocks since they are no longer needed.
…in CI

Keep only the two sidebar.test.tsx tests for new-chat targeting which are
pure component tests with no WebSocket/ACP lifecycle involvement.
@karthikmudunuri karthikmudunuri merged commit 4bcb029 into main Apr 8, 2026
1 check passed
@karthikmudunuri karthikmudunuri deleted the fix/ui-new-conversation-target-and-flicker branch April 8, 2026 19:27
@gitrank-connector
Copy link
Copy Markdown

👍 GitRank PR Analysis

Score: 20 points

Metric Value
Component Other (1× multiplier)
Severity P2 - Medium (20 base pts)
Final Score 20 × 1 = 20

Eligibility Checks

Check Status
Issue/Bug Fix
Fix Implementation
PR Documented
Tests
Lines Within Limit

Impact Summary

This PR fixes three related bugs in the sidebar conversation creation flow: (1) 'New chat' button now targets the focused instance instead of the alphabetically first one, (2) eliminates conversation creation flickering by reordering navigation and state updates, and (3) ensures new conversations appear at the top of the list immediately. These fixes improve the user experience and make the UI behavior more intuitive and responsive.

Analysis Details

Component Classification: This PR affects UI components (sidebar and chat page) but doesn't fit neatly into a specific category beyond general UI fixes. The OTHER component is appropriate as a catch-all for UI bug fixes.

Severity Justification: This is a P2 (Medium) severity fix addressing three functional bugs with workarounds. The issues impact user experience (wrong instance selection, visual flickering, conversation ordering) but don't cause data loss or service outages. Users can work around these issues by manually selecting conversations or waiting for the UI to settle.

Eligibility Notes: Issue: True - PR clearly describes three bugs being fixed. Fix Implementation: True - code changes directly address each described issue with appropriate logic changes. PR Linked: True - comprehensive description with technical details and explanation of fixes. Tests: True - 68 lines of new test coverage added for the focused instance behavior. Tests Required: True - this involves business logic changes in conversation creation and UI state management, which require test coverage to prevent regressions.


Analyzed by GitRank 🤖

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.

1 participant