Skip to content

fix(ai): report a failed LLM runtime load on the page - #6827

Merged
lizhimins merged 1 commit into
apache:masterfrom
Frun1na:fix/ai-runtime-load-failure
Nov 27, 2026
Merged

lizhimins merged 1 commit into
apache:masterfrom
Frun1na:fix/ai-runtime-load-failure

Conversation

@Frun1na

@Frun1na Frun1na commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

A failed LLM runtime load on /ai was a toast and nothing else: useLlmRuntime reported it through onError (web/src/pages/ai/hooks/useLlmRuntime.ts:123-127) and left config null, while every explanation the composer has — the not-ready banner (Composer.tsx:314), the provider status and its tag (:417, :427) — is behind llmConfig. Sending needs llmReady (Composer.tsx:254), so after the toast faded the page showed a dead send button with no reason and no retry.

The hook now keeps the failure (error: string | null, cleared by a successful load or when the runtime is disabled) and the page renders it above the composer as an error alert carrying the server's message plus a Retry that reloads the runtime — the treatment this page already gives its timeline load failure (index.tsx:189-205), the settings tab since #6550 (AiAssistantTab.tsx:171-172) and the home page in #6082.

User-visible behaviour: an operator whose runtime could not be read is told so on the page and can retry, instead of being left with a disabled composer that cannot be told apart from an unconfigured provider.

How Did You Test This Change?

$ ./wb test
✓   npx eslint src/pages/ai/__tests__/AiPage.test.tsx src/pages/ai/hooks/useLlmRuntime.test.ts src/pages/ai/hooks/useLlmRuntime.ts src/pages/ai/index.tsx
✓   npx prettier --check src/pages/ai/__tests__/AiPage.test.tsx src/pages/ai/hooks/useLlmRuntime.test.ts src/pages/ai/hooks/useLlmRuntime.ts src/pages/ai/index.tsx
✓   npx vitest related --run src/pages/ai/__tests__/AiPage.test.tsx src/pages/ai/hooks/useLlmRuntime.test.ts src/pages/ai/hooks/useLlmRuntime.ts src/pages/ai/index.tsx
✓   npx tsc -b

AiPage.test.tsx gains a case per failure shape (an Error and a {} rejection, the pair the failed-timeline-load case already uses): the page must render the alert, keep the composer disabled, and clear the alert after Retry re-requests the runtime (getLlmConfig twice, getLlmModels once). useLlmRuntime.test.ts pins the hook state itself: error carries the failure message, the toast callback still fires, and a successful reload() clears both the error and llmReady: false.

The new tests fail without the fix:

 FAIL  src/pages/ai/__tests__/AiPage.test.tsx > AiPage > offers recovery for a failed LLM runtime load: Error: runtime unavailable
 FAIL  src/pages/ai/__tests__/AiPage.test.tsx > AiPage > offers recovery for a failed LLM runtime load: {}
TestingLibraryElementError: Unable to find role="alert"

 FAIL  src/pages/ai/hooks/useLlmRuntime.test.ts > useLlmRuntime > surfaces the failed load for the page and clears it on a successful reload
AssertionError: expected undefined to be 'runtime unavailable' // Object.is equality

 Test Files  2 failed | 19 passed (21)
      Tests  3 failed | 267 passed (270)
src/pages/ai/hooks/useLlmRuntime.test.ts(193,27): error TS2339: Property 'error' does not exist on type 'UseLlmRuntimeResult'.
src/pages/ai/hooks/useLlmRuntime.test.ts(203,27): error TS2339: Property 'error' does not exist on type 'UseLlmRuntimeResult'.

That run is the branch with the two product files reverted (git stash push of useLlmRuntime.ts and index.tsx) and the new cases kept: nothing announces the failure, so the page's only alert is missing and the hook exposes no state for it.

Other consumers

  • This page's toast (index.tsx:83) is kept: it announces the failure when it happens, the new banner is what stays on the page. Both carry the page's existing ai.runtimeLoadFailed string, so the two cannot disagree.
  • The settings tab (AiAssistantTab.tsx:171-172, fix(settings): report a failed AI configuration load instead of an empty form #6550) and the home page (fix(home): report a failed assistant config load instead of a dead input #6082) are the other two surfaces of this failure and are already handled there; they use the llm.loadFailed wording instead. Those files are outside this change, and unifying the two strings is a translation-table change, not this fix.
  • useLlmRuntime's other state and behaviour are unchanged: the monotonic request id still drops a superseded response (including a failed one, which is why error is only set for the current request), and reload() is still the same load.
  • No new UI text is introduced: both strings already exist under web/src/i18n/.

Checklist

  • One coherent change; unrelated modifications are not bundled in
  • Commit subject follows Conventional Commits (feat: / fix: / refactor: / chore: / docs: / perf:)
  • 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)

Report a failed LLM runtime load on the AI page instead of a toast only.

useLlmRuntime handed the failure to onError and left config null, so the page kept none of it:
the composer's not-ready banner, its provider status and its send guard all key off llmConfig,
which meant a runtime that could not be read looked exactly like one that was never configured -
a disabled send button with no explanation and no retry. The hook now exposes the failure and
the page renders it above the composer with the retry, the treatment its timeline load failure
already gets (and the settings tab since apache#6550, the home page in apache#6082).
Copilot AI balanced review requested due to automatic review settings October 15, 2026 19:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 7 days. If you would like to continue working on this, please reopen the PR with updated changes.

@github-actions github-actions Bot added the stale label Oct 23, 2026
@github-actions github-actions Bot closed this Oct 23, 2026
@lizhimins lizhimins reopened this Nov 27, 2026
@lizhimins
lizhimins changed the base branch from rocketmq-studio to master November 27, 2026 04:42
@lizhimins
lizhimins merged commit a424278 into apache:master Nov 27, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A failed LLM runtime load leaves the AI page's composer dead with no explanation or retry

3 participants