Skip to content

fix(plugin-chatbot): a refused AI approve or reject says why, not HTTP 403 - #39063

Open
os-bob wants to merge 2 commits into
mainfrom
claude/project-thread-9ik7zi
Open

os-bob wants to merge 2 commits into
mainfrom
claude/project-thread-9ik7zi

Conversation

@os-bob

@os-bob os-bob commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Requested by bob · project thread

Refs #39049 — the framework-side items listed under "Independent of the choice". The fix itself (option A, ruled on the card) is the cloud gate's and is routed to the cloud seat there; this PR does not close the card.

What changes

  • useHitlInChat: on a non-2xx decision answer, read the error envelope { success: false, error: { code, message, details: { reason } } }. The card now shows the server's error.message (a bare-string error still shows as before) and carries details.reason on the decision's error state. With no usable body, the fallback names the button pressed: a failed reject reads Rejection failed: HTTP <status>, never Approval failed.
  • ToolDecisionState: the error arm gains an optional reason.
  • Chat card (toolDetail) and AI Approvals inbox: reason === 'pending_action_session_required' draws the localized sentence aiApprovals.sessionRequired instead of the server's English text. The reason string lives beside the lapse reason in pendingActionLapse.ts, so both surfaces map it the same way.
  • aiApprovals.sessionRequired added to every locale pack and to AI_APPROVALS_DEFAULT_TRANSLATIONS; zh-Hant regenerated by scripts/gen-zh-hant.mjs.
  • headers option docs of useHitlInChat / usePendingActions: drop Authorization as the example, and say the decision doors admit only the host's signed-in session.

Why

Every in-app AI confirmation in production shows Approval failed: HTTP 403 because the hook ignored the structured error the route sends. Whatever the cloud gate does next, a refusal should say why, in the reader's language, and a failed reject should not call itself an approval.

Verification

  • New ChatbotEnhanced.refusedDecision-39049.test.tsx (4 cases, through the real buttons, rendered in zh): session-required reason → localized sentence, no 403; unknown reason → server message; empty 502 on reject → Rejection failed: HTTP 502; inbox approve refused for want of a session → the same localized sentence.
  • Ablation: the 4 new cases run against the previous ui/packages/plugin-chatbot/src and ui/packages/i18n → 4 failed; with this change → 4 passed.
  • packages/plugin-chatbot/ full suite: 87 files, 842 tests passed. packages/i18n suite plus app-shell defaults-maps-mirror-en-pack: passed (the zh-Hant generator test included).
  • eslint on the touched files: 0 errors.

Clause-②: no
Metadata-protocol: none

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@os-bob os-bob self-assigned this Dec 2, 2026
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor

triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

Progress knock · 2026-12-02T14:06Z

@os-bob 本 PR 自 2026-12-02T06:38Z 起无更新(非 draft、无审阅、无请求审阅人),关联 p1 #39049。请回一句:继续推进(转 ready 流程/请审)、转 draft,还是关闭?下轮巡检仍无答复时,按分诊规则 ⑥ 报维护者。

os-bob commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Reply to the progress knock 7348024557: continue. The maintainer's answer (os-bob, 2026-12-02T14:52Z, on this project's decision card): 「继续推进,请审后合并」.

State on head d4d43b79: CI green (45 passed, 15 skipped), no conflict, not a draft. The diff touches no governed surface (ui/packages/plugin-chatbot, ui/packages/i18n, one changeset). It is waiting on a review record; it lands after that, by the maintainer's merge or enqueue.

This PR covers only the framework-side items of #39049 and does not close it; the gate fix (option A) is routed to the cloud seat on that card.


Generated by Claude Code

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

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants