Word chat request refusals from their stable error code by Maya-Kid · Pull Request #931 · deeplethe/utopia · GitHub
Skip to content

Word chat request refusals from their stable error code - #931

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:fix/chat-refusal-wording
Sep 26, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:fix/chat-refusal-wording

Conversation

@Maya-Kid

Copy link
Copy Markdown
Contributor

Problem

When a chat request is refused, for example because no chat model is configured, the chat view shows the server's English sentence even in the Chinese interface. S.err has a translation for that code (no_chat_model), but it is never used here.

Cause

Every other request goes through request(). It looks the refusal's code up in S.err and falls back to the server's sentence (ADR 0004: the server always speaks English, and the wording belongs to the client). The chat stream reads its refusals in consumeChatStream, which only took error.

Change

The code lookup moves out of request() into refusalMessage, and consumeChatStream uses it too, for both streamChat and reattachChat. request() behaves as before.

Verification

Run in containers on a Linux host (Node 20).

Three new cases in src/chatStream.test.ts:

  • A refusal with code: "no_chat_model" is worded from S.err.
  • Without a code, or with a code that is not in the table, the server's sentence is kept.
  • A detail is kept beside the wording.

On dev (b3919ca) with only the new cases added, the first and third fail and the second passes, as it should.

With this change, pnpm test (138 passed) and pnpm build pass.

Limits

An error that arrives after the stream has started (an error frame) is still a plain English sentence without a code. Wording those needs a code on the frame, and that is left for a separate change.

Signed-off-by: dada-yan <BinjunYann@gmail.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One wording function shared by request() and the stream, so a refusal with a code reads the same everywhere and the server keeps speaking English (0004). The three cases pin the code, the fallback and the detail. Merging.

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.

2 participants