# AI Routing Admin Runtime Fix Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Make the AI configuration center match the existing admin theme, use Chinese copy everywhere, show existing provider/workflow bindings from the database, and expose a single user-facing streaming runtime entry point driven by scene code plus JSON inputs.

**Architecture:** Keep the existing provider/endpoint/scene/log model. The admin page uses the current Element Plus dark glass theme and existing list-page conventions. Runtime calls accept `sceneCode` and `inputs` JSON, enrich inputs with the logged-in user context on the backend, resolve the scene binding from the database, then stream provider output back to the user.

**Tech Stack:** Spring Boot, MyBatis-Plus, FastJSON, Vue 3, Element Plus, uni-app chunked streaming.

---

### Task 1: Admin Page Theme And Chinese Copy

**Files:**
- Modify: `web-admin/src/views/aiconfig/AiRoutingList.vue`

- [x] Replace English page title, tabs, table columns, dialogs, buttons, alerts, empty states, and confirm text with Chinese.
- [x] Replace the standalone white panel styles with the project page-header, glass card, table card, and dark Element Plus table styles.
- [x] Add summary cards for providers, endpoints, scenes, and logs so the page matches existing management pages.

### Task 2: User Runtime Request Shape

**Files:**
- Modify: `server/src/main/java/com/emotion/dto/request/ai/AiRuntimeRequest.java`
- Modify: `server/src/main/java/com/emotion/controller/AiRoutingController.java`
- Modify: `server/src/main/java/com/emotion/service/impl/AiRuntimeServiceImpl.java`

- [x] Accept user calls as `sceneCode` plus `inputs` JSON.
- [x] Keep user identity server-side by reading `UserContextHolder`.
- [x] Enrich runtime inputs with safe user context keys before provider invocation.
- [x] Keep SSE stream events as the only formal output path for user-facing AI calls.

### Task 3: Seed Existing Configurations Into Routing Tables

**Files:**
- Modify: `sql/2026-05-22-ai-scene-routing.sql`

- [x] Insert a Coze provider from existing `t_ai_config` rows when missing.
- [x] Insert endpoint rows from current enabled Coze workflow configurations.
- [x] Bind existing scenes to known workflow configs where a safe mapping exists.
- [x] Keep unknown scenes visible but disabled until explicitly bound in the admin page.

### Task 4: Verify End To End

**Commands:**
- `mvn test`
- `mvn -DskipTests clean package`
- `npm run build`
- `npm run build:mp-weixin`
- Remote SQL migration execution.
- Remote health checks for backend and ASR.

- [x] Backend tests pass.
- [x] Backend package succeeds.
- [x] Admin build succeeds.
- [x] Mini program build succeeds.
- [x] Remote routing tables contain provider, endpoints, and scene bindings.
