Skip to content

fix(dashboard): drop the stale expert welcome while the next one loads - #1848

Open
JasonBuildAI wants to merge 1 commit into
TencentCloud:developfrom
JasonBuildAI:fix/dashboard-stale-expert-welcome
Open

JasonBuildAI wants to merge 1 commit into
TencentCloud:developfrom
JasonBuildAI:fix/dashboard-stale-expert-welcome

Conversation

@JasonBuildAI

Copy link
Copy Markdown

Summary

Switching experts in Chat left the previous expert's welcome message and quick-prompt cards on screen — still clickable — until the new expert's /api/agents/{agent_id}/chat/welcome response arrived. Switching the UI language had the same effect.

useExpertChatWelcome() cancelled late responses, but it never cleared the state it had already loaded when a new request started, so Chat/index.tsx kept passing the stale values into WelcomeScreen for the newly selected expert.

The fix clears fetchedCards / welcomeSuffix immediately before starting the request, so the pending state is empty instead of the previous expert's content. The existing cancellation guard is unchanged: a late response from the expert that was switched away from is still ignored.

Fixes #1480

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (release/* or hotfix/* only)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

Added dashboard/src/pages/Chat/hooks/useExpertQuickCards.test.ts — 4 cases: expert switch, language switch, late response ignored, no expert selected.

Before the fix — 2 failed, 2 passed:

$ cd dashboard && npx vitest run src/pages/Chat/hooks/useExpertQuickCards.test.ts
 FAIL  src/pages/Chat/hooks/useExpertQuickCards.test.ts > useExpertChatWelcome > drops the previous expert's welcome while the next request is pending
AssertionError: expected [ { title: 'Alpha任务', …(5) } ] to deeply equal []
 FAIL  src/pages/Chat/hooks/useExpertQuickCards.test.ts > useExpertChatWelcome > drops the previous welcome while the request for a new language is pending
AssertionError: expected [ { title: 'Alpha任务', …(5) } ] to deeply equal []
 Test Files  1 failed (1)
      Tests  2 failed | 2 passed (4)

After the fix — 4 passed:

$ cd dashboard && npx vitest run src/pages/Chat/hooks/useExpertQuickCards.test.ts
 ✓ src/pages/Chat/hooks/useExpertQuickCards.test.ts (4 tests) 109ms
 Test Files  1 passed (1)
      Tests  4 passed (4)

Other checks (Windows 11, Python 3.12, Node 22):

$ uv run ruff check src tests           -> All checks passed!
$ uv run ruff format --check src tests  -> 1168 files already formatted
$ uv run mypy src/octop                 -> Success: no issues found in 565 source files
$ cd dashboard && npx tsc -b            -> exit 0
$ cd dashboard && npm run build         -> ✓ built in 2m 43s
  • make is not installed in this shell, so the four gate commands were run individually instead of make all.

  • Full dashboard suite (npx vitest run): 10 failed | 1206 passed. All timeouts in unrelated files. Re-running those test files on a pristine develop checkout gives the identical 7 files / 4 tests failing (and the remaining 4 passing), so this change adds no new failures.

  • Backend suite (uv run pytest -n auto -m "not live"): 53 failed | 4322 passed | 158 skipped. The same 53 fail on a pristine develop checkout (verified with a serial --lf re-run on both trees), so they are pre-existing on this Windows machine.

  • npm run format:check flags 1105 files on this checkout because core.autocrlf=true checks everything out as CRLF; Prettier passes on the two files touched here.

  • npm run lint reports 3 pre-existing errors in other files; none of them in the files touched here.

  • make all passes locally (individual ruff / mypy / pytest commands; see above)

  • Added/updated tests

Checklist

  • Updated CHANGELOG.md (if user-facing)
  • README / docs updated (if needed)

AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.

Switching experts left the previous expert's welcome message and
quick-prompt cards on screen — still clickable — until the new
/chat/welcome response arrived; switching the UI language did the same.
useExpertChatWelcome cancelled late responses but never cleared the
state it had already loaded, so Chat/index.tsx kept handing the stale
values to WelcomeScreen. Clear fetchedCards and welcomeSuffix before the
request starts.

Refs TencentCloud#1480
@JasonBuildAI
JasonBuildAI force-pushed the fix/dashboard-stale-expert-welcome branch from 6f08615 to ee31acb Compare October 15, 2026 17:40

This branch has not been deployed

No deployments
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