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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6549
   
   ### Brief Description
   
   When the AI assistant configuration cannot be loaded, the tab reported it 
only as a toast and then
   rendered the configuration form anyway — every field empty and the API key 
slot prompting for a key,
   i.e. it claimed that nothing is configured 
(`web/src/pages/settings/AiAssistantTab.tsx:159-176`).
   The load endpoints are admin-only on the server 
(`AuthInterceptor.isAdminOnlyGetPath` covers
   `/api/llm/config` and `/api/llm/models`, answering 403 "Admin permission 
required"), so a reader
   opening the tab always lands in that state, and the server's reason was 
discarded in favour of the
   generic `llm.loadFailed`.
   
   A failed load now keeps the reason the request failed with and renders an 
error notice above the
   form with a retry button that re-runs the load and clears the notice once it 
succeeds. The shape
   follows `AlertRuleAssetList`, which already does this for its own list, and 
the home page's assistant
   load failure is handled the same way in #6082.
   
   User-visible change: a configuration the tab could not read is no longer 
presented as an empty one —
   the operator sees why it is missing and can retry. No new copy: the notice 
and the button reuse
   `llm.loadFailed` (only as the fallback text) and `common.retry`.
   
   ### How Did You Test This Change?
   
   ```
   $ cd web && npx eslint src/pages/settings/AiAssistantTab.tsx 
src/pages/settings/__tests__/AiAssistantTab.test.tsx
   # clean
   
   $ cd web && npx prettier --check src/pages/settings/AiAssistantTab.tsx 
src/pages/settings/__tests__/AiAssistantTab.test.tsx
   # clean
   
   $ cd web && npx vitest run 
src/pages/settings/__tests__/AiAssistantTab.test.tsx --maxWorkers=1 
--fileParallelism=false
    ✓ src/pages/settings/__tests__/AiAssistantTab.test.tsx (10 tests) 7.1s
        ✓ reports a failed configuration load with its reason and can retry it
    Test Files  1 passed (1)
         Tests  10 passed (10)
   
   $ cd web && npx tsc -b
   # clean
   ```
   
   The new test fails without the fix (this is the mutation check: the load 
effect, the notice and the
   retry are restored, the test is kept):
   
   ```
   $ cd web && npx vitest run 
src/pages/settings/__tests__/AiAssistantTab.test.tsx --maxWorkers=1 
--fileParallelism=false
    FAIL src/pages/settings/__tests__/AiAssistantTab.test.tsx > AiAssistantTab 
> reports a failed configuration load with its reason and can retry it
   TestingLibraryElementError: Unable to find an element with the text: Admin 
permission required.
    Test Files  1 failed (1)
         Tests  1 failed | 9 passed (10)
   ```
   
   The assertions are the reason the request failed with (the fix surfaces it), 
the retry issuing a
   second load call, and the loaded configuration replacing the notice (`密钥已配置` 
appears, the notice
   disappears); the existing nine cases pin the save, clear-key and 
connection-test paths.
   
   ### 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