Skip to content

fix(ui): prevent chat rail flicker when switching conversations - #3218

Open
vedantlavale wants to merge 2 commits into
kagent-dev:mainfrom
vedantlavale:fix/3078-chat-switch-flicker
Open

vedantlavale wants to merge 2 commits into
kagent-dev:mainfrom
vedantlavale:fix/3078-chat-switch-flicker

Conversation

@vedantlavale

@vedantlavale vedantlavale commented Oct 15, 2026 •

Copy link
Copy Markdown

Closes #3078

What changed

When a reader switches conversations, the route contains only the conversation ID while the selected instance is loading. The rail now resolves the Agent from the already-loaded conversation list during that gap, so the Agent identity, sibling filter, Agent Details link, and New chat link remain stable.

The transcript also keeps its loading skeleton visible until the selected conversation record is ready, instead of briefly rendering an empty conversation.

How it was tested

  • NODE_OPTIONS=--localstorage-file=/tmp/kagent-ui-test-storage corepack yarn vitest run src/components/agent/AgentRail.loading.test.tsx — 4 tests passed.
  • corepack yarn typecheck — passed.
  • Targeted ESLint for the changed UI and Playwright files — passed.
  • git diff --check — passed.
  • Manual mock UI verification with ?mock=slow while switching from the seeded ready conversation to its sibling.

Before and after

Captured from the same route and mock scenario. The before capture uses local main; the after capture uses this branch.

Before After
Before: current main chat rail After: fixed chat rail

Risks and follow-ups

This is a UI-only change. It does not change the API, persistence, or conversation lifecycle. The Playwright browser executable was unavailable in the local environment, so the focused browser test remains for CI and manual verification.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 15, 2026
@vedantlavale
vedantlavale force-pushed the fix/3078-chat-switch-flicker branch from ba40386 to abbafa0 Compare October 15, 2026 12:14

@Charlesthebird Charlesthebird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This automated review is a first pass. A manual review will follow once the blockers are addressed.


Nothing blocks merge. The fix is correct, and the before/after recording in the next comment shows the rail and transcript stay stable during a switch.

✅ What I checked
  • ✅ List entry vs. instance.agent: both map through toAgentInstance, and the list reads every page. A conversation missing from the list falls back to the base behaviour.
  • ✅ isLoading={instance.isLoading}: true only on first load for a key. Background re-reads, polling and errors don't flash or stick the skeleton (shouldRetryOnError: false).
  • ✅ ChatTranscript keeps its hooks above the early return, and the composer lives in AgentChatPage, so the skeleton loses no state.
  • ✅ The new unit test fails on base; the new Playwright test fails on base only at its skeleton check (agent-rail.spec.ts#L174).

🤖 written by Claude

Comment thread ui/playwright/tests/chat/agent-rail.spec.ts Outdated
@Charlesthebird

Copy link
Copy Markdown
Collaborator

Before/after of switching to a sibling chat with ?mock=slow. Before, the rail shows the raw ID and every chat, and the transcript shows an empty state. After, the rail keeps the agent and the transcript shows a skeleton.

pr3218-reel.mp4

🤖 written by Claude

@Charlesthebird Charlesthebird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding this! I think removing the test would be fine for this and then I can approve.

Signed-off-by: vedantlavale <vedantlavale@gmail.com>
@vedantlavale
vedantlavale force-pushed the fix/3078-chat-switch-flicker branch from abbafa0 to 95df886 Compare October 16, 2026 02:36
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.

Switching chats flashes the chat id and every agent's chats in the rail

2 participants