Frun1na opened a new pull request, #6082:
URL: https://github.com/apache/rocketmq-dashboard/pull/6082

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6081
   
   ### Brief Description
   
   The home page loaded the assistant configuration with 
`getLlmConfig().catch(() => null)`
   (`web/src/pages/home/index.tsx:118`), so a failed request was stored as 
"there is no configuration" —
   indistinguishable from the state before the response arrives. The shared 
composer explains a missing
   configuration only when it has one: its not-ready banner and status tag are 
both behind `llmConfig && ...`
   (`web/src/pages/ai/components/Composer.tsx:312`, `:425`), while the send 
action requires `llmReady`
   (`index.tsx:100-101`). A failed `GET /api/llm/config` therefore left the 
input box disabled with no reason
   shown, no retry, and nothing to tell it apart from a page that is still 
loading.
   
   The failure is now a state: the load is wrapped in try/catch, the page 
renders `llm.loadFailed` above the
   composer with a retry that re-runs the load, and the recovered configuration 
drives the composer again.
   User-visible change: on the home page a failed assistant-configuration 
request now says so ("加载AI配置失败"
   / "Failed to load AI config") and can be retried; before, the input box was 
silently dead. No new
   user-facing copy was introduced — `llm.loadFailed` and `common.retry` 
already exist with Chinese and
   English entries.
   
   The model fallback is unchanged: when the configuration cannot be read, the 
home model list is still
   offered and the recommended model is still preselected.
   
   ### How Did You Test This Change?
   
   ```
   $ cd web && npx eslint src/pages/home/index.tsx
   # clean
   
   $ cd web && npx prettier --check src/pages/home/index.tsx
   # clean
   
   $ cd web && npx vitest related --run src/pages/home/index.tsx --maxWorkers=1 
--fileParallelism=false
    ✓ src/pages/home/__tests__/HomePage.test.tsx (10 tests) 1384ms
    ✓ src/App.test.tsx (10 tests) 468ms
    Test Files  2 passed (2)
         Tests  20 passed (20)
   
   $ cd web && npx tsc -b
   # clean
   ```
   
   The new test fails without the fix:
   
   ```
   $ cd web && npx vitest related --run 
src/pages/home/__tests__/HomePage.test.tsx \
       --maxWorkers=1 --fileParallelism=false
    FAIL src/pages/home/__tests__/HomePage.test.tsx > HomePage LLM models > 
says the assistant configuration could not be loaded instead of leaving the 
input dead
    TestingLibraryElementError: Unable to find an element with the text: 
加载AI配置失败.
    Test Files  1 failed (1)
         Tests  1 failed | 9 passed (10)
   ```
   
   (That run is `pages/home/index.tsx` reverted and the new test kept, which is 
also the mutation check; the
   case is green again once the fix is restored. The test also pins the 
recovery: after the retry the composer
   reports its provider status and a prompt is handed to the AI page again.)
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / 
`refactor:` / `chore:` / `docs:` / `perf:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [ ] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to