Merge remote-tracking branch 'origin/master' into worktree/code-diff-card
This commit is contained in:
commit
3c632ebf66
318 files changed
+9061
-3253
No files matched your search
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/modules/README.md
|
||||
README.md: 83ba5357cf84a12105518ed057fd120584b636cb
|
||||
README.zh.md: 9e5c75838e52fda7d74b074b9c1a9dacef7932a8
|
||||
README.md: 4c9dc4a3a13cb6f24e03c927d0277e137ab97b9f
|
||||
README.zh.md: bc5b78d258270962661ab27ca7eb1a58cc61f01c
|
||||
@@ -71,6 +71,8 @@ The Node half snapshots each client bundle and available source map before publi
|
||||
|
||||
### Boot manifest injection
|
||||
|
||||
The bundle route follows the injected `webServer` lifetime: it registers when the service is ready and is removed and re-registered when that service is replaced. Module composition and `fetchBundle()` remain available without a Web server.
|
||||
|
||||
The host contributes structured index rows that inject, into `<head>`: the `window.__ModuleLoader__` queue facade, advisory preloads for every application combo, the parser-blocking bootstrap combo scripts, then the boot graph before the shell reads it. A Web carrier renders those rows into its index response; a shell-owned carrier can render the same rows without a Web server. The facade's `create()` materializes the modules bundle, delegates construction to its `createClientModuleSystem` export, and leaves the same facade in live-registration mode.
|
||||
|
||||
### Source map
|
||||
|
||||
@@ -71,6 +71,8 @@ Node 半侧会在发布前快照每个客户端 bundle 及其现有 source map
|
||||
|
||||
### 启动 manifest 注入
|
||||
|
||||
bundle 路由随注入的 `webServer` 生命周期注册:服务就绪时注册,服务被替换时移除并重新注册。模块组合与 `fetchBundle()` 在没有 Web server 时仍可用。
|
||||
|
||||
宿主贡献结构化 index 行,并向 `<head>` 注入:`window.__ModuleLoader__` queue facade、每个 application combo 的提示性 preload、阻塞 parser 的 bootstrap combo 脚本,然后才是外壳读取前的启动图。Web 载体把这些行渲染进 index 响应;由 shell 持有的载体则可以在没有 Web server 时渲染同一批行。facade 的 `create()` 物化 modules bundle、把构造委托给其 `createClientModuleSystem` 导出,并让同一 facade 进入 live registration 模式。
|
||||
|
||||
### 源码索引
|
||||
|
||||
@@ -504,6 +504,7 @@ export class ClientModuleRegistry extends Service {
|
||||
|
||||
/**
|
||||
* Build the service: subscribe, seed, and run the activation flush.
|
||||
* Bundle routes follow the optional Web carrier's injected lifecycle.
|
||||
* @param ctx - plugin context carrying Loader and an optional Web carrier.
|
||||
*/
|
||||
constructor(ctx: Context) {
|
||||
@@ -540,8 +541,7 @@ export class ClientModuleRegistry extends Service {
|
||||
'client-modules: bundle route',
|
||||
)
|
||||
}
|
||||
if (ctx.get('webServer') === undefined) ctx.inject(['webServer'], registerWebCarrier)
|
||||
else registerWebCarrier(ctx)
|
||||
ctx.inject(['webServer'], registerWebCarrier)
|
||||
ctx.on('webserver/index-inject', (table) => {
|
||||
table.push(...bootInjections(this.composed))
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import { tmpdir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { runInNewContext } from 'node:vm'
|
||||
import { Context, type Fiber } from '@deepseek-ai/cordis'
|
||||
import { Context, FiberState, type Fiber } from '@deepseek-ai/cordis'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { renderIndexInjections, type WebServer, type WebRoute } from '@deepseek-ai/dsh-host-webserver'
|
||||
import * as modulesClient from '../src/client/index.ts'
|
||||
@@ -24,12 +24,50 @@ const BOOTSTRAP_URL = comboUrl([MODULES_ID], 'boot')
|
||||
const APPLICATION_URL = comboUrl([UI_RENDERER_ID], 'app')
|
||||
|
||||
let root: string | undefined
|
||||
const contexts: { ctx: Context; ready?: Promise<WebRoute> }[] = []
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
await Promise.all(contexts.splice(0).map(async ({ ctx, ready }) => {
|
||||
await ready
|
||||
await ctx.fiber.dispose()
|
||||
}))
|
||||
if (root !== undefined) rmSync(root, { recursive: true, force: true })
|
||||
root = undefined
|
||||
})
|
||||
|
||||
it.each([false, true])('tracks the Web carrier lifetime when server-first is %s', async (serverFirst) => {
|
||||
const ctx = new Context()
|
||||
contexts.push({ ctx })
|
||||
ctx.provide('loader', { entries: () => [] })
|
||||
const routes = new Set<WebRoute>()
|
||||
const mountServer = () => ctx.plugin((serverCtx) => {
|
||||
serverCtx.provide('webServer', {
|
||||
register: (route: WebRoute) => {
|
||||
routes.add(route)
|
||||
return () => { routes.delete(route) }
|
||||
},
|
||||
} as WebServer)
|
||||
})
|
||||
let server = serverFirst ? await mountServer() : undefined
|
||||
const modules = await ctx.plugin(ClientModuleRegistry)
|
||||
const service = ctx.get('clientModules')!
|
||||
expect(service.graph().entries).toEqual([])
|
||||
expect(service.fetchBundle(new Request('http://localhost/plugins/missing')).status).toBe(404)
|
||||
if (!serverFirst) {
|
||||
expect(routes.size).toBe(0)
|
||||
server = await mountServer()
|
||||
}
|
||||
await expect.poll(() => routes.size).toBe(1)
|
||||
await server!.dispose()
|
||||
await expect.poll(() => routes.size).toBe(0)
|
||||
expect(modules.state).toBe(FiberState.ACTIVE)
|
||||
expect(service.fetchBundle(new Request('http://localhost/plugins/missing')).status).toBe(404)
|
||||
await mountServer()
|
||||
await expect.poll(() => routes.size).toBe(1)
|
||||
await modules.dispose()
|
||||
expect(routes.size).toBe(0)
|
||||
})
|
||||
|
||||
/** Create a resolvable package whose client export points at the returned path. */
|
||||
function writePackage(
|
||||
packageName: string,
|
||||
@@ -65,8 +103,10 @@ function constructWithRoute(
|
||||
entryBaseUrl?: string
|
||||
internal?: NonNullable<Context['loader']['internal']>
|
||||
} = {},
|
||||
): { context: Context; service: ClientModuleRegistry; route: WebRoute } {
|
||||
): { context: Context; service: ClientModuleRegistry; route: Promise<WebRoute> } {
|
||||
const ctx = new Context()
|
||||
const owned: typeof contexts[number] = { ctx }
|
||||
contexts.push(owned)
|
||||
ctx.baseUrl = options.contextBaseUrl ?? pathToFileURL(root!).href + '/'
|
||||
ctx.provide('loader', {
|
||||
internal: options.internal,
|
||||
@@ -81,19 +121,19 @@ function constructWithRoute(
|
||||
}
|
||||
},
|
||||
})
|
||||
let route: WebRoute | undefined
|
||||
const route = Promise.withResolvers<WebRoute>()
|
||||
const webServer: Pick<WebServer, 'port' | 'register' | 'tapIndex'> = {
|
||||
port: 0,
|
||||
register: (candidate) => {
|
||||
if (candidate.path === '/plugins') route = candidate
|
||||
if (candidate.path === '/plugins') route.resolve(candidate)
|
||||
return () => {}
|
||||
},
|
||||
tapIndex: () => () => {},
|
||||
}
|
||||
ctx.provide('webServer', webServer as WebServer)
|
||||
const service = new ClientModuleRegistry(ctx)
|
||||
if (route === undefined) throw new Error('client bundle route was not registered')
|
||||
return { context: ctx, service, route }
|
||||
owned.ready = route.promise
|
||||
return { context: ctx, service, route: route.promise }
|
||||
}
|
||||
|
||||
/** Construct the node-half service over the enabled fixture entries. */
|
||||
@@ -102,7 +142,7 @@ function construct(packageNames: string[]): ClientModuleRegistry {
|
||||
}
|
||||
|
||||
/** Invoke the registered plugin route and capture status, headers, and bytes. */
|
||||
async function routeRequest(route: WebRoute, url: string, method = 'GET'): Promise<{
|
||||
async function routeRequest(route: Promise<WebRoute>, url: string, method = 'GET'): Promise<{
|
||||
status: number
|
||||
headers: Record<string, string> | undefined
|
||||
body: Buffer
|
||||
@@ -121,7 +161,7 @@ async function routeRequest(route: WebRoute, url: string, method = 'GET'): Promi
|
||||
return response
|
||||
},
|
||||
} as unknown as ServerResponse
|
||||
await route.handler({ method, url } as IncomingMessage, response)
|
||||
await (await route).handler({ method, url } as IncomingMessage, response)
|
||||
return { status, headers, body }
|
||||
}
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md
|
||||
README.md: 1d3e6c6d0774ed78bb0a1952ba57e5f607f24b47
|
||||
README.zh.md: e7f0419939076b1276586cfba28129b7df1ba355
|
||||
README.md: d22fa2eed35457c0599fd41473102b1aebe4bd2e
|
||||
README.zh.md: b53cf76dc8b8a253da83d1e94b6f9f1b5abf19cc
|
||||
@@ -67,7 +67,7 @@ Writing your own component in your own package is fine when the need is genuinel
|
||||
|
||||
### Controls and icons
|
||||
|
||||
The catalog above lists what each export is for; this section covers the behavior that props alone do not show. The `ic_ds_*` icon set and `FishLogo`/`BrandWordmark` marks fill brand and inline-icon slots. `FileTypeIcon` renders the traditional 28px Excel, folder, HTML, image, Markdown, generic, PDF, PPT, video, and Word glyphs, and uses the imported square technology artwork for the established 48 code and configuration categories. The import replaces artwork only: archive-only categories do not extend `CodeFileType`. `classifyFileType` applies exact filename, prefix, suffix, optional project-context, and extension rules in that order; React names win over TypeScript/JavaScript, Angular suffixes win over their base extension, and a Dart file becomes Flutter only when the supplied project files contain a `pubspec.yaml` with `flutter:`. Markdown and SVG remain traditional Markdown and image files. Office mappings include XLSM/Numbers as Excel, KEY as slides, and RTF/ODT/Pages as documents. `fileExtension` exposes the same basename and final-dot parsing for adjacent metadata labels. Traditional glyphs use a solid category-colored sheet with a white mark and translucent white corner; the generic file uses a grey sheet and darker grey corner. Callers may override the sheet color through `--dsh-file-type-icon-color`. The full-color technology artwork is the deliberate exception and retains its embedded palette. All glyphs are decorative and carry no label. `LinkIcon` remains the smaller leading glyph for clickable artifact links — globe, folder, code, image, document, or plain paper — while `classifyLinkPath` folds the shared file types into that existing six-category vocabulary. `ConnectionIndicator` renders a warning-colored disconnected action, a connecting label whose one-to-three dots advance every 500ms independently of retry timing, or a success-colored recovered status. Hover or keyboard focus shows only the reconnect action label, including while the connecting dots animate. Every state reserves the widest supplied label and uses fixed icon and text columns, so copy changes do not move or resize the control. Its owner supplies visibility, the recovery hold, localized labels, and the immediate-reconnect callback; the primitive uses no native title tooltip. `useAnchoredPosition` and `useAnchoredMaxHeight` keep floating panels and bottom-anchored overlays clamped to the viewport and following their anchor. `HoverCard` keeps its portaled preview reachable across the anchor gap and can expose a copy button through the `copyText` prop. `Toast` holds for the window its owner names through `holdMs`, because how long a banner has to stay depends on how much there is to read; the same value drives its unmount timer and the stylesheet's fade delay, so the two cannot disagree. `rankByName` is the `/` menu's shared candidate ranker for the command and skill sources: the query must be a case-insensitive ordered subsequence of the name; prefix hits rank first, then alignment score, then source order. `Menu.autoFocus` focuses its first enabled item, supports Arrow Up/Down and Home/End navigation, and focuses the first button in the anchor on Escape; it is opt-in for action menus.
|
||||
The catalog above lists what each export is for; this section covers the behavior that props alone do not show. The `ic_ds_*` icon set and `FishLogo`/`BrandWordmark` marks fill brand and inline-icon slots. `FileTypeIcon` renders the traditional 28px Excel, folder, HTML, image, Markdown, generic, PDF, PPT, video, and Word glyphs, and uses the imported square technology artwork for the established 48 code and configuration categories. The import replaces artwork only: archive-only categories do not extend `CodeFileType`. `classifyFileType` applies exact filename, prefix, suffix, optional project-context, and extension rules in that order; React names win over TypeScript/JavaScript, Angular suffixes win over their base extension, and a Dart file becomes Flutter only when the supplied project files contain a `pubspec.yaml` with `flutter:`. Markdown and SVG remain traditional Markdown and image files. Office mappings include XLSM/Numbers as Excel, KEY as slides, and RTF/ODT/Pages as documents. `fileExtension` exposes the same basename and final-dot parsing for adjacent metadata labels. Traditional glyphs use a solid category-colored sheet with a white mark and translucent white corner; the generic file uses a grey sheet and darker grey corner. Callers may override the sheet color through `--dsh-file-type-icon-color`. The full-color technology artwork is the deliberate exception and retains its embedded palette. All glyphs are decorative and carry no label. `LinkIcon` remains the smaller leading glyph for clickable artifact links — globe, folder, code, image, document, or plain paper — while `classifyLinkPath` folds the shared file types into that existing six-category vocabulary. `ConnectionIndicator` renders a warning-colored disconnected action whose permanent retry glyph marks the retry action beside the owner-supplied outage label, a connecting spinner beside a label whose one-to-three dots advance every 500ms independently of retry timing, or a success-colored recovered status. Clicking either warning state requests an immediate reconnect; no hover interaction changes the copy. The pill fades in on appearance, fades out for 150ms before unmounting, and sizes to its current label. Its owner supplies visibility, the recovery hold, localized labels, and the immediate-reconnect callback; the primitive uses no native title tooltip. `useAnchoredPosition` and `useAnchoredMaxHeight` keep floating panels and bottom-anchored overlays clamped to the viewport and following their anchor. `HoverCard` keeps its portaled preview reachable across the anchor gap and can expose a copy button through the `copyText` prop. `Toast` holds for the window its owner names through `holdMs`, because how long a banner has to stay depends on how much there is to read; the same value drives its unmount timer and the stylesheet's fade delay, so the two cannot disagree. `rankByName` is the `/` menu's shared candidate ranker for the command and skill sources: the query must be a case-insensitive ordered subsequence of the name; prefix hits rank first, then alignment score, then source order. `Menu.autoFocus` focuses its first enabled item, supports Arrow Up/Down and Home/End navigation, and focuses the first button in the anchor on Escape; it is opt-in for action menus.
|
||||
|
||||
### Rendering agent output
|
||||
|
||||
@@ -98,8 +98,6 @@ The package enforces one separation: presentational React atoms with zero Cordis
|
||||
| [`src/ReadBlock.tsx`](src/ReadBlock.tsx) / [`src/DiffBlock.tsx`](src/DiffBlock.tsx) | Read and diff cards |
|
||||
| [`src/SearchBlock.tsx`](src/SearchBlock.tsx) / [`src/WebBlock.tsx`](src/WebBlock.tsx) | Search and web-retrieval cards |
|
||||
| [`src/icons/`](src/icons/) | `ic_ds_*` glyph components and brand marks |
|
||||
| [`src/code-file-icon-artwork.ts`](src/code-file-icon-artwork.ts) | Embedded inner SVG markup for the 48 detailed code-file categories |
|
||||
| [`src/code-file-icon-artwork.manifest.json`](src/code-file-icon-artwork.manifest.json) | Design-export digests, included categories, and intentionally excluded artwork |
|
||||
| [`src/useAnchoredPosition.ts`](src/useAnchoredPosition.ts) / [`src/useAnchoredMaxHeight.ts`](src/useAnchoredMaxHeight.ts) | Floating-panel and overlay geometry hooks |
|
||||
|
||||
### Streaming markdown
|
||||
|
||||
@@ -67,7 +67,7 @@ kind: "package-library"
|
||||
|
||||
### 控件与图标
|
||||
|
||||
上面的目录说明每个导出的用途;本节讲 props 本身看不出来的行为。`ic_ds_*` 图标集与 `FishLogo`/`BrandWordmark` 标记填充品牌与行内图标 slot。`FileTypeIcon` 渲染传统的 28px Excel、folder、HTML、image、Markdown、generic、PDF、PPT、video 与 Word 图形,并为现有 48 个代码和配置类别使用导入的方形技术图形。该导入只替换图形:资源包中额外的类别不会扩展 `CodeFileType`。`classifyFileType` 按完整文件名、前缀、后缀、可选项目上下文、扩展名的顺序匹配;React 文件名优先于 TypeScript/JavaScript,Angular 后缀优先于基础扩展名,只有传入的项目文件包含带 `flutter:` 的 `pubspec.yaml` 时 Dart 文件才使用 Flutter。Markdown 与 SVG 仍分别使用传统 Markdown 与图片图形。办公文件映射包含 XLSM/Numbers 的表格图标、KEY 的幻灯片图标,以及 RTF/ODT/Pages 的文档图标。`fileExtension` 为相邻元数据 label 暴露同一套 basename 与最终点号解析。传统图形使用实色分类底板、白色标记和半透明白色折角;通用文件使用灰色底板与较深灰色折角。调用方可通过 `--dsh-file-type-icon-color` 覆盖底板颜色。全彩技术图形是明确例外,会保留其内嵌调色板。所有图形都是装饰性的,不自带 label。`LinkIcon` 仍是可点击产物链接较小的前置分类图形——地球、文件夹、代码、图片、文档或纸张——`classifyLinkPath` 把共享文件类型折叠进原有六类词汇。`ConnectionIndicator` 可渲染警告色的断联操作、以独立于 retry 时序的 500ms 节奏推进一至三个点的连接中状态,或成功色的恢复状态。悬停或键盘聚焦时只显示重连操作文案,连接中的圆点动画也保持隐藏。所有状态都为最长的输入 label 预留空间,并使用固定的图标列和文字列,因此文案变化不会移动控件或改变其宽度。它的持有方提供可见性、恢复驻留时间、本地化 label 与立即重连回调;该原语不使用原生 title tooltip。`useAnchoredPosition` 与 `useAnchoredMaxHeight` 让浮动面板与底部锚定浮层始终钳制在视口内并跟随锚点。`HoverCard` 通过指针离开宽限期让采用 portal 的预览在跨过锚点间隙时仍可触及,并可通过 `copyText` prop 提供复制按钮。`Toast` 的停留时长由使用方通过 `holdMs` 指定,因为横幅该留多久取决于有多少内容要读;同一个值同时驱动它的卸载定时器与样式表的淡出延迟,两者不可能再错位。`rankByName` 是 `/` 菜单命令源与 skill(技能)源共享的候选排序器:查询必须是名字的不区分大小写的有序子序列;前缀命中排最前,其次按对齐分数,再按来源顺序。 `Menu.autoFocus` 聚焦首个启用项,支持上下方向键与 Home/End 导航,并在 Escape 时聚焦 anchor 内的第一个按钮;操作菜单可显式启用。
|
||||
上面的目录说明每个导出的用途;本节讲 props 本身看不出来的行为。`ic_ds_*` 图标集与 `FishLogo`/`BrandWordmark` 标记填充品牌与行内图标 slot。`FileTypeIcon` 渲染传统的 28px Excel、folder、HTML、image、Markdown、generic、PDF、PPT、video 与 Word 图形,并为现有 48 个代码和配置类别使用导入的方形技术图形。该导入只替换图形:资源包中额外的类别不会扩展 `CodeFileType`。`classifyFileType` 按完整文件名、前缀、后缀、可选项目上下文、扩展名的顺序匹配;React 文件名优先于 TypeScript/JavaScript,Angular 后缀优先于基础扩展名,只有传入的项目文件包含带 `flutter:` 的 `pubspec.yaml` 时 Dart 文件才使用 Flutter。Markdown 与 SVG 仍分别使用传统 Markdown 与图片图形。办公文件映射包含 XLSM/Numbers 的表格图标、KEY 的幻灯片图标,以及 RTF/ODT/Pages 的文档图标。`fileExtension` 为相邻元数据 label 暴露同一套 basename 与最终点号解析。传统图形使用实色分类底板、白色标记和半透明白色折角;通用文件使用灰色底板与较深灰色折角。调用方可通过 `--dsh-file-type-icon-color` 覆盖底板颜色。全彩技术图形是明确例外,会保留其内嵌调色板。所有图形都是装饰性的,不自带 label。`LinkIcon` 仍是可点击产物链接较小的前置分类图形——地球、文件夹、代码、图片、文档或纸张——`classifyLinkPath` 把共享文件类型折叠进原有六类词汇。`ConnectionIndicator` 可渲染警告色的断联操作(常驻重试图形指明重试动作,断联文案由持有方提供)、spinner 加一至三个点以独立于 retry 时序的 500ms 节奏推进的连接中状态,或成功色的恢复状态。点击任一警告状态都会请求立即重连;没有任何悬停交互会改变文案。药丸出现时淡入、卸载前淡出 150ms,宽度随当前 label 自适应。它的持有方提供可见性、恢复驻留时间、本地化 label 与立即重连回调;该原语不使用原生 title tooltip。`useAnchoredPosition` 与 `useAnchoredMaxHeight` 让浮动面板与底部锚定浮层始终钳制在视口内并跟随锚点。`HoverCard` 通过指针离开宽限期让采用 portal 的预览在跨过锚点间隙时仍可触及,并可通过 `copyText` prop 提供复制按钮。`Toast` 的停留时长由使用方通过 `holdMs` 指定,因为横幅该留多久取决于有多少内容要读;同一个值同时驱动它的卸载定时器与样式表的淡出延迟,两者不可能再错位。`rankByName` 是 `/` 菜单命令源与 skill(技能)源共享的候选排序器:查询必须是名字的不区分大小写的有序子序列;前缀命中排最前,其次按对齐分数,再按来源顺序。 `Menu.autoFocus` 聚焦首个启用项,支持上下方向键与 Home/End 导航,并在 Escape 时聚焦 anchor 内的第一个按钮;操作菜单可显式启用。
|
||||
|
||||
### 渲染 agent 输出
|
||||
|
||||
@@ -98,8 +98,6 @@ kind: "package-library"
|
||||
| [`src/ReadBlock.tsx`](src/ReadBlock.tsx) / [`src/DiffBlock.tsx`](src/DiffBlock.tsx) | 读取与差异卡片 |
|
||||
| [`src/SearchBlock.tsx`](src/SearchBlock.tsx) / [`src/WebBlock.tsx`](src/WebBlock.tsx) | 搜索与网页检索卡片 |
|
||||
| [`src/icons/`](src/icons/) | `ic_ds_*` 字形组件与品牌标记 |
|
||||
| [`src/code-file-icon-artwork.ts`](src/code-file-icon-artwork.ts) | 48 个细分代码文件类别的内嵌内层 SVG markup |
|
||||
| [`src/code-file-icon-artwork.manifest.json`](src/code-file-icon-artwork.manifest.json) | 设计导出摘要、已纳入类别与有意排除的图稿 |
|
||||
| [`src/useAnchoredPosition.ts`](src/useAnchoredPosition.ts) / [`src/useAnchoredMaxHeight.ts`](src/useAnchoredMaxHeight.ts) | 浮动面板与浮层几何钩子 |
|
||||
|
||||
### 流式 Markdown
|
||||
|
||||
@@ -4,25 +4,49 @@
|
||||
grid-template-columns: 14px max-content;
|
||||
align-items: center;
|
||||
column-gap: 4px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 13px;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 18px;
|
||||
white-space: nowrap;
|
||||
transition: background-color 160ms ease-out, color 160ms ease-out;
|
||||
transition:
|
||||
background-color 160ms ease-out,
|
||||
color 160ms ease-out,
|
||||
border-color 160ms ease-out,
|
||||
opacity 150ms ease-out;
|
||||
animation: indicator-enter 150ms ease-out;
|
||||
}
|
||||
|
||||
.leaving {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@keyframes indicator-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.warning {
|
||||
background: var(--dsw-alias-state-warn-tertiary);
|
||||
color: var(--dsw-alias-state-warn-label);
|
||||
border-color: color-mix(in srgb, var(--dsw-alias-state-warn-label) 20%, transparent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.warning:hover {
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--dsw-alias-state-warn-tertiary),
|
||||
var(--dsw-alias-state-warn-primary) 6%
|
||||
);
|
||||
}
|
||||
|
||||
.warning:active {
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
@@ -39,6 +63,7 @@
|
||||
.success {
|
||||
background: var(--dsw-alias-state-success-tertiary);
|
||||
color: var(--dsw-alias-state-success-primary);
|
||||
border-color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.icon {
|
||||
@@ -49,35 +74,20 @@
|
||||
}
|
||||
|
||||
.label {
|
||||
display: grid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.stateLabel,
|
||||
.hoverLabel,
|
||||
.sizeLabel {
|
||||
grid-area: 1 / 1;
|
||||
.spinner {
|
||||
animation: spinner-rotate 0.9s linear infinite;
|
||||
}
|
||||
|
||||
.sizeLabel {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.warning:is(:hover, :focus-visible) .stateLabel {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.hoverLabel {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.warning:is(:hover, :focus-visible) .hoverLabel {
|
||||
visibility: visible;
|
||||
@keyframes spinner-rotate {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.dots {
|
||||
display: inline-block;
|
||||
width: 1.5em;
|
||||
width: 1em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@@ -100,8 +110,14 @@
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.indicator,
|
||||
.secondDot,
|
||||
.thirdDot {
|
||||
.thirdDot,
|
||||
.spinner {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.indicator {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IconCheckOutline16, IconWarningOutline16 } from './icons/index.tsx'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { IconCheckOutline16, IconLoadingOutline16, IconRefreshOutline14 } from './icons/index.tsx'
|
||||
import css from './ConnectionIndicator.module.css'
|
||||
|
||||
/** Visual state rendered by {@link ConnectionIndicator}. */
|
||||
@@ -7,11 +8,16 @@ export type ConnectionIndicatorState =
|
||||
| 'connecting'
|
||||
| 'recovered'
|
||||
|
||||
/** Exit-transition length; keep equal to the `.leaving` transition duration in the stylesheet. */
|
||||
const EXIT_MS = 150
|
||||
|
||||
/**
|
||||
* Render an inline connection-recovery control.
|
||||
* Render an inline connection-recovery control. The outage and retry-attempt
|
||||
* states are one button whose static label already names the retry action;
|
||||
* clicking it requests an immediate reconnect. The indicator animates in on
|
||||
* appearance and fades out for {@link EXIT_MS} before unmounting.
|
||||
* @param props.state - visible outage, retry-attempt, or recovered state.
|
||||
* @param props.disconnectedLabel - localized outage text.
|
||||
* @param props.reconnectLabel - localized action text shown on hover or focus.
|
||||
* @param props.disconnectedLabel - localized outage text naming the retry action.
|
||||
* @param props.connectingLabel - localized retry text followed by the attempt dots.
|
||||
* @param props.recoveredLabel - localized recovery confirmation.
|
||||
* @param props.reconnectActionLabel - accessible label for the outage action.
|
||||
@@ -22,7 +28,6 @@ export type ConnectionIndicatorState =
|
||||
export function ConnectionIndicator({
|
||||
state,
|
||||
disconnectedLabel,
|
||||
reconnectLabel,
|
||||
connectingLabel,
|
||||
recoveredLabel,
|
||||
reconnectActionLabel,
|
||||
@@ -31,63 +36,66 @@ export function ConnectionIndicator({
|
||||
}: {
|
||||
state: ConnectionIndicatorState | undefined
|
||||
disconnectedLabel: string
|
||||
reconnectLabel: string
|
||||
connectingLabel: string
|
||||
recoveredLabel: string
|
||||
reconnectActionLabel: string
|
||||
restartActionLabel: string
|
||||
onReconnect: () => void
|
||||
}) {
|
||||
if (state === undefined) return null
|
||||
const sizeLabels = (
|
||||
<>
|
||||
<span className={css.sizeLabel} aria-hidden="true">{disconnectedLabel}</span>
|
||||
<span className={css.sizeLabel} aria-hidden="true">{reconnectLabel}</span>
|
||||
<span className={css.sizeLabel} aria-hidden="true">
|
||||
{connectingLabel}<span className={css.dots}>...</span>
|
||||
</span>
|
||||
<span className={css.sizeLabel} aria-hidden="true">{recoveredLabel}</span>
|
||||
</>
|
||||
)
|
||||
if (state === 'recovered') {
|
||||
const [rendered, setRendered] = useState(state)
|
||||
const leaving = state === undefined && rendered !== undefined
|
||||
useEffect(() => {
|
||||
if (state !== undefined) {
|
||||
setRendered(state)
|
||||
return
|
||||
}
|
||||
if (rendered === undefined) return
|
||||
const timeout = window.setTimeout(() => { setRendered(undefined) }, EXIT_MS)
|
||||
return () => { window.clearTimeout(timeout) }
|
||||
}, [state, rendered])
|
||||
|
||||
if (rendered === undefined) return null
|
||||
const leavingClass = leaving ? ` ${css.leaving}` : ''
|
||||
if (rendered === 'recovered') {
|
||||
return (
|
||||
<div className={`${css.indicator} ${css.success}`} role="status" aria-label={recoveredLabel}>
|
||||
<div
|
||||
className={`${css.indicator} ${css.success}${leavingClass}`}
|
||||
role="status"
|
||||
aria-label={recoveredLabel}
|
||||
>
|
||||
<span className={css.icon} aria-hidden="true"><IconCheckOutline16 size={14} /></span>
|
||||
<span className={css.label}>
|
||||
{sizeLabels}
|
||||
<span className={css.stateLabel}>{recoveredLabel}</span>
|
||||
</span>
|
||||
<span className={css.label}>{recoveredLabel}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const connecting = state === 'connecting'
|
||||
const connecting = rendered === 'connecting'
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`${css.indicator} ${css.warning}`}
|
||||
data-phase={state}
|
||||
className={`${css.indicator} ${css.warning}${leavingClass}`}
|
||||
data-phase={rendered}
|
||||
aria-label={connecting ? restartActionLabel : reconnectActionLabel}
|
||||
onClick={onReconnect}
|
||||
>
|
||||
<span className={css.icon} aria-hidden="true"><IconWarningOutline16 size={14} /></span>
|
||||
<span className={css.icon} aria-hidden="true">
|
||||
{connecting
|
||||
? <IconLoadingOutline16 size={14} className={css.spinner} />
|
||||
: <IconRefreshOutline14 size={14} />}
|
||||
</span>
|
||||
<span className={css.label}>
|
||||
{sizeLabels}
|
||||
<span className={css.stateLabel}>
|
||||
{connecting
|
||||
? (
|
||||
<>
|
||||
{connectingLabel}
|
||||
<span className={css.dots} aria-hidden="true">
|
||||
<span>.</span>
|
||||
<span className={css.secondDot}>.</span>
|
||||
<span className={css.thirdDot}>.</span>
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
: disconnectedLabel}
|
||||
</span>
|
||||
<span className={css.hoverLabel}>{reconnectLabel}</span>
|
||||
{connecting
|
||||
? (
|
||||
<>
|
||||
{connectingLabel}
|
||||
<span className={css.dots} aria-hidden="true">
|
||||
<span>.</span>
|
||||
<span className={css.secondDot}>.</span>
|
||||
<span className={css.thirdDot}>.</span>
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
: disconnectedLabel}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -462,8 +462,7 @@ describe('ConnectionIndicator', () => {
|
||||
it('renders outage, attempt progress, and recovered states without a native tooltip', () => {
|
||||
const reconnect = vi.fn()
|
||||
const labels = {
|
||||
disconnectedLabel: 'Disconnected',
|
||||
reconnectLabel: 'Reconnect',
|
||||
disconnectedLabel: 'Disconnected, retry',
|
||||
connectingLabel: 'Connecting',
|
||||
recoveredLabel: 'Connected',
|
||||
reconnectActionLabel: 'Disconnected, reconnect now',
|
||||
@@ -476,8 +475,7 @@ describe('ConnectionIndicator', () => {
|
||||
expect(container.firstChild).toBeNull()
|
||||
rerender(<ConnectionIndicator state="disconnected" {...labels} />)
|
||||
const indicator = screen.getByRole('button', { name: 'Disconnected, reconnect now' })
|
||||
expect(indicator.textContent).toContain('Disconnected')
|
||||
expect(indicator.textContent).toContain('Reconnect')
|
||||
expect(indicator.textContent).toContain('Disconnected, retry')
|
||||
expect(indicator.hasAttribute('title')).toBe(false)
|
||||
expect(indicator.querySelector('svg')).toBeTruthy()
|
||||
fireEvent.click(indicator)
|
||||
@@ -491,4 +489,27 @@ describe('ConnectionIndicator', () => {
|
||||
expect(screen.queryByRole('button')).toBeNull()
|
||||
expect(screen.getByRole('status', { name: 'Connected' })).toBeTruthy()
|
||||
})
|
||||
|
||||
it('fades out for the exit duration before unmounting', () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const labels = {
|
||||
disconnectedLabel: 'Disconnected, retry',
|
||||
connectingLabel: 'Connecting',
|
||||
recoveredLabel: 'Connected',
|
||||
reconnectActionLabel: 'Disconnected, reconnect now',
|
||||
restartActionLabel: 'Connecting, restart now',
|
||||
onReconnect: vi.fn(),
|
||||
}
|
||||
const { container, rerender } = render(
|
||||
<ConnectionIndicator state="disconnected" {...labels} />,
|
||||
)
|
||||
rerender(<ConnectionIndicator state={undefined} {...labels} />)
|
||||
expect(screen.getByRole('button', { name: 'Disconnected, reconnect now' })).toBeTruthy()
|
||||
act(() => { vi.advanceTimersByTime(150) })
|
||||
expect(container.firstChild).toBeNull()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/ui-settings-general/README.md
|
||||
README.md: 845d9c48dce2264d478f0ac854ef85a480828a14
|
||||
README.zh.md: 814082f94156e44b45e015e67acb7a281ba2e7e9
|
||||
README.md: af68c42ad111f74e68037436e18a5be57195a64b
|
||||
README.zh.md: f929df66a13cde7beb63721922f2a3f4aa90ba43
|
||||
@@ -25,7 +25,7 @@ Use this package to give the dsh web client a Settings panel, connection-recover
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
Users reach the shell through the sidebar's bottom Settings control; feature plugins contribute their pages and onboarding steps through the slot ledgers this shell projects. In both the expanded sidebar and collapsed rail, the control exposes the localized Settings label as its accessible name. A pale-yellow **Disconnected** action beside Settings indicates browser offline suspension. Automatic recovery shows **Reconnecting** with one to three dots advancing every 500ms. Hover or keyboard focus changes either yellow label to **Reconnect now** without changing its background; press feedback stays within the warning palette, and selecting it starts retry 1 immediately. Recovery changes the region to pale-green **Connected** for two seconds before it disappears. The icon, left-aligned text origin, height, and width remain fixed across every visible state. Initial startup and uninterrupted healthy operation remain silent. The shell renders the modal panel, the navigation built from `settings.section` entries, and exactly one mounted onboarding step at a time.
|
||||
Users reach the shell through the sidebar's bottom Settings control; feature plugins contribute their pages and onboarding steps through the slot ledgers this shell projects. In both the expanded sidebar and collapsed rail, the control exposes the localized Settings label as its accessible name. A pale-yellow **Disconnected** action beside Settings indicates browser offline suspension; its permanent retry glyph marks the retry action, which the Chinese outage copy also names (连接异常,刷新重试). Every recovery attempt shows a spinner beside **Reconnecting** with one to three dots advancing every 500ms, and an attempt stays visible for at least 800ms so brief retries do not flicker. Selecting either yellow state starts an immediate retry; press feedback stays within the warning palette. Recovery changes the region to pale-green **Connected** for two seconds from the moment the green pill becomes visible. The pill fades in on appearance, fades out over 150ms on removal, and sizes to its current label. Initial startup and uninterrupted healthy operation remain silent. The shell renders the modal panel, the navigation built from `settings.section` entries, and exactly one mounted onboarding step at a time.
|
||||
|
||||
### The General section
|
||||
|
||||
@@ -55,7 +55,7 @@ The navigation is a projection of the `settings.section` ledger; nav labels may
|
||||
|
||||
### Connection recovery
|
||||
|
||||
The shell is an explicit recovery consumer, so it injects Connection directly rather than adding lifecycle controls to `ctx.remote`. Its private hooks compartment binds `ctx.connection.state`, while the component receives only the selected state and an injected callback for `ctx.connection.reconnect()`. `ConnectionIndicator` owns the inline presentation and receives all visible and accessible copy from the `settings` locale namespace; the shell owns the two-second recovered-state timer.
|
||||
The shell is an explicit recovery consumer, so it injects Connection directly rather than adding lifecycle controls to `ctx.remote`. Its private hooks compartment binds `ctx.connection.state`, while the component receives only the selected state and an injected callback for `ctx.connection.reconnect()`. `ConnectionIndicator` owns the inline presentation and receives all visible and accessible copy from the `settings` locale namespace; the shell owns the 800ms minimum-visible hold for the connecting state and the two-second recovered-state timer, which starts when the recovered pill becomes visible after the hold.
|
||||
|
||||
### Document availability
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ kind: "package-reference"
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
用户通过侧边栏底部的 Settings 控件进入外壳;功能插件通过本外壳所投影的 slot 账本贡献自己的页面与引导步骤。在展开侧边栏和收起轨道中,该控件都会把本地化的 Settings 文案作为其可访问名称。Settings 右侧浅黄色的**连接异常**操作表示浏览器离线暂停;自动恢复期间显示**自动重连中**,其后一至三个点每 500ms 前进一次。鼠标悬浮或键盘聚焦任一黄色状态时,只有文案变为**立即重连**,背景保持不变;按压反馈留在黄色色阶内,选中后立即从 retry 1 开始。恢复后该区域变为浅绿色的**连接成功**,驻留 2 秒再消失。所有可见状态的文字都左对齐,且图标、文字起点、高度和宽度保持固定。首次启动与未曾中断的健康连接保持静默。外壳渲染模态面板、由 `settings.section` 条目构建的导航,以及每次只挂载一个的引导步骤。
|
||||
用户通过侧边栏底部的 Settings 控件进入外壳;功能插件通过本外壳所投影的 slot 账本贡献自己的页面与引导步骤。在展开侧边栏和收起轨道中,该控件都会把本地化的 Settings 文案作为其可访问名称。Settings 右侧浅黄色的**连接异常**操作表示浏览器离线暂停;其常驻重试图形与中文文案「连接异常,刷新重试」都指明重试动作。每次恢复尝试都显示 spinner 加**重新连接中**,其后一至三个点每 500ms 前进一次,且每次尝试至少可见 800ms,短暂重试不会闪动。选中任一黄色状态都会立即发起重试;按压反馈留在黄色色阶内。恢复后该区域变为浅绿色的**连接成功**,从绿色药丸可见起驻留 2 秒再消失。药丸出现时淡入、移除时以 150ms 淡出,宽度随当前文案自适应。首次启动与未曾中断的健康连接保持静默。外壳渲染模态面板、由 `settings.section` 条目构建的导航,以及每次只挂载一个的引导步骤。
|
||||
|
||||
### 「通用」分区
|
||||
|
||||
@@ -55,7 +55,7 @@ kind: "package-reference"
|
||||
|
||||
### 连接恢复
|
||||
|
||||
外壳是明确的恢复功能消费方,因此直接注入 Connection,而不把生命周期控制放进 `ctx.remote`。它的私有 hooks compartment 绑定 `ctx.connection.state`,组件只接收选出的状态与调用 `ctx.connection.reconnect()` 的注入回调。`ConnectionIndicator` 拥有内联展示并从 `settings` locale namespace 接收全部可见与无障碍文案;2 秒恢复状态计时器归外壳所有。
|
||||
外壳是明确的恢复功能消费方,因此直接注入 Connection,而不把生命周期控制放进 `ctx.remote`。它的私有 hooks compartment 绑定 `ctx.connection.state`,组件只接收选出的状态与调用 `ctx.connection.reconnect()` 的注入回调。`ConnectionIndicator` 拥有内联展示并从 `settings` locale namespace 接收全部可见与无障碍文案;连接中状态的 800ms 最短可见驻留与 2 秒恢复确认计时器归外壳所有;恢复计时从驻留结束、恢复药丸实际可见时开始。
|
||||
|
||||
### 文档可用性
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ import css from './SettingsRoot.module.css'
|
||||
|
||||
const RECOVERY_CONFIRMATION_MS = 2_000
|
||||
|
||||
/** Minimum visible time for the connecting pill; shorter attempts read as flicker. */
|
||||
const CONNECTING_MIN_VISIBLE_MS = 800
|
||||
|
||||
/** Nav glyph by section id; unknown ids fall back to the settings gear. */
|
||||
function navIcon(id: string) {
|
||||
if (id === 'models') return <IconDataOutline16 className={css.navIcon} size={16} />
|
||||
@@ -113,6 +116,8 @@ export function SettingsRoot(props: SettingsRootComponentProps) {
|
||||
const [activeId, setActiveId] = useState<string | undefined>(undefined)
|
||||
const [completedOnboarding, setCompletedOnboarding] = useState<ReadonlySet<string>>(() => new Set())
|
||||
const [showRecovery, setShowRecovery] = useState(false)
|
||||
const [holdConnecting, setHoldConnecting] = useState(false)
|
||||
const connectingShownAt = useRef<number | undefined>(undefined)
|
||||
const triggerButton = useRef<HTMLButtonElement | null>(null)
|
||||
const wasOpen = useRef(open)
|
||||
const close = useCallback(() => {
|
||||
@@ -157,8 +162,32 @@ export function SettingsRoot(props: SettingsRootComponentProps) {
|
||||
}
|
||||
if (previous !== 'disconnected' && previous !== 'connecting') return
|
||||
setShowRecovery(true)
|
||||
}, [connectionState])
|
||||
|
||||
// The confirmation window starts when the recovered pill becomes visible,
|
||||
// which the connecting minimum-visible hold can delay past the transition.
|
||||
useLayoutEffect(() => {
|
||||
if (!showRecovery || holdConnecting) return
|
||||
const timeout = window.setTimeout(() => { setShowRecovery(false) }, RECOVERY_CONFIRMATION_MS)
|
||||
return () => { window.clearTimeout(timeout) }
|
||||
}, [showRecovery, holdConnecting])
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (connectionState === 'connecting') {
|
||||
connectingShownAt.current = Date.now()
|
||||
return
|
||||
}
|
||||
const shownAt = connectingShownAt.current
|
||||
if (shownAt === undefined) return
|
||||
connectingShownAt.current = undefined
|
||||
const remaining = CONNECTING_MIN_VISIBLE_MS - (Date.now() - shownAt)
|
||||
if (remaining <= 0) return
|
||||
setHoldConnecting(true)
|
||||
const timeout = window.setTimeout(() => { setHoldConnecting(false) }, remaining)
|
||||
return () => {
|
||||
window.clearTimeout(timeout)
|
||||
setHoldConnecting(false)
|
||||
}
|
||||
}, [connectionState])
|
||||
|
||||
const completeOnboardingStep = useCallback((id: string) => {
|
||||
@@ -169,10 +198,10 @@ export function SettingsRoot(props: SettingsRootComponentProps) {
|
||||
}, [])
|
||||
|
||||
let connectionIndicator: ConnectionIndicatorState | undefined
|
||||
if (connectionState === 'disconnected') {
|
||||
connectionIndicator = 'disconnected'
|
||||
} else if (connectionState === 'connecting') {
|
||||
if (connectionState === 'connecting' || holdConnecting) {
|
||||
connectionIndicator = 'connecting'
|
||||
} else if (connectionState === 'disconnected') {
|
||||
connectionIndicator = 'disconnected'
|
||||
} else if (showRecovery) {
|
||||
connectionIndicator = 'recovered'
|
||||
}
|
||||
@@ -194,7 +223,6 @@ export function SettingsRoot(props: SettingsRootComponentProps) {
|
||||
<ConnectionIndicator
|
||||
state={wide ? connectionIndicator : undefined}
|
||||
disconnectedLabel={t('connection.error')}
|
||||
reconnectLabel={t('connection.retry')}
|
||||
connectingLabel={t('connection.connecting')}
|
||||
recoveredLabel={t('connection.connected')}
|
||||
reconnectActionLabel={t('connection.reconnect')}
|
||||
|
||||
@@ -8,12 +8,11 @@ export const zh = {
|
||||
'openDocument': '打开配置文件',
|
||||
'openDocument.error': '无法打开配置文件',
|
||||
'general.nav': '通用设置',
|
||||
'connection.error': '连接异常',
|
||||
'connection.retry': '立即重连',
|
||||
'connection.connecting': '自动重连中',
|
||||
'connection.error': '连接异常,刷新重试',
|
||||
'connection.connecting': '重新连接中',
|
||||
'connection.connected': '连接成功',
|
||||
'connection.reconnect': '连接异常,点击立即重连',
|
||||
'connection.restart': '连接中断,正在自动重试,点击立即重连',
|
||||
'connection.restart': '连接中断,正在重试,点击立即重连',
|
||||
} satisfies Record<string, string>
|
||||
|
||||
/** The settings namespace key union. */
|
||||
@@ -28,9 +27,8 @@ export const en = {
|
||||
'openDocument.error': 'Could not open configuration file',
|
||||
'general.nav': 'General',
|
||||
'connection.error': 'Disconnected',
|
||||
'connection.retry': 'Reconnect now',
|
||||
'connection.connecting': 'Reconnecting',
|
||||
'connection.connected': 'Connected',
|
||||
'connection.reconnect': 'Disconnected, reconnect now',
|
||||
'connection.restart': 'Reconnecting automatically, reconnect now',
|
||||
'connection.restart': 'Reconnecting, reconnect now',
|
||||
} satisfies Record<SettingsKey, string>
|
||||
@@ -118,8 +118,8 @@ describe('ui-settings-general apply', () => {
|
||||
settings.mutate.mockResolvedValueOnce(ok(english))
|
||||
const t = c.ctx.locale.bind(NS)
|
||||
expect(t('title')).toBe('设置')
|
||||
expect(t('connection.error')).toBe('连接异常')
|
||||
expect(t('connection.connecting')).toBe('自动重连中')
|
||||
expect(t('connection.error')).toBe('连接异常,刷新重试')
|
||||
expect(t('connection.connecting')).toBe('重新连接中')
|
||||
expect(t('connection.connected')).toBe('连接成功')
|
||||
c.ctx.locale.setLocale('en')
|
||||
expect(t('close')).toBe('Close')
|
||||
|
||||
@@ -162,14 +162,57 @@ describe('SettingsRoot trigger', () => {
|
||||
expect(mounted.reconnect).toHaveBeenCalledOnce()
|
||||
|
||||
mounted.setConnectionState('connecting')
|
||||
expect(screen.getByRole('button', { name: 'Reconnecting automatically, reconnect now' }).textContent)
|
||||
expect(screen.getByRole('button', { name: 'Reconnecting, reconnect now' }).textContent)
|
||||
.toContain('Reconnecting...')
|
||||
|
||||
// An attempt that resolves instantly still shows the connecting pill for
|
||||
// its 800ms minimum before the confirmation replaces it.
|
||||
mounted.setConnectionState('connected')
|
||||
expect(screen.queryByRole('status')).toBeNull()
|
||||
act(() => { vi.advanceTimersByTime(800) })
|
||||
expect(screen.getByRole('status', { name: 'Connected' })).toBeTruthy()
|
||||
// The confirmation window is measured from visibility, not the transition.
|
||||
act(() => { vi.advanceTimersByTime(1_999) })
|
||||
expect(screen.getByRole('status', { name: 'Connected' })).toBeTruthy()
|
||||
// The confirmation window closes at 2s, then the pill fades for 150ms.
|
||||
act(() => { vi.advanceTimersByTime(1) })
|
||||
act(() => { vi.advanceTimersByTime(150) })
|
||||
expect(screen.queryByRole('status')).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps the attempt label steady through the hold and confirms for the full window', () => {
|
||||
vi.useFakeTimers()
|
||||
const mounted = mount({ dictionary: zh })
|
||||
mounted.setConnectionState('connecting')
|
||||
const attempt = screen.getByRole('button', { name: '连接中断,正在重试,点击立即重连' })
|
||||
expect(attempt.textContent).toContain('重新连接中')
|
||||
fireEvent.click(attempt)
|
||||
expect(mounted.reconnect).toHaveBeenCalledOnce()
|
||||
expect(attempt.textContent).toContain('重新连接中')
|
||||
// An attempt that resolves mid-hold keeps its label until the hold ends.
|
||||
act(() => { vi.advanceTimersByTime(100) })
|
||||
mounted.setConnectionState('connected')
|
||||
expect(screen.getByRole('button', { name: '连接中断,正在重试,点击立即重连' }).textContent)
|
||||
.toContain('重新连接中')
|
||||
act(() => { vi.advanceTimersByTime(700) })
|
||||
expect(screen.getByRole('status', { name: '连接成功' })).toBeTruthy()
|
||||
// The full two-second confirmation follows the delayed appearance.
|
||||
act(() => { vi.advanceTimersByTime(1_999) })
|
||||
expect(screen.getByRole('status', { name: '连接成功' })).toBeTruthy()
|
||||
act(() => { vi.advanceTimersByTime(1) })
|
||||
act(() => { vi.advanceTimersByTime(150) })
|
||||
expect(screen.queryByRole('status')).toBeNull()
|
||||
})
|
||||
|
||||
it('skips the hold when the attempt already stayed visible long enough', () => {
|
||||
vi.useFakeTimers()
|
||||
const mounted = mount()
|
||||
mounted.setConnectionState('connecting')
|
||||
act(() => { vi.advanceTimersByTime(800) })
|
||||
mounted.setConnectionState('connected')
|
||||
expect(screen.getByRole('status', { name: 'Connected' })).toBeTruthy()
|
||||
act(() => { vi.advanceTimersByTime(2_000) })
|
||||
act(() => { vi.advanceTimersByTime(150) })
|
||||
expect(screen.queryByRole('status')).toBeNull()
|
||||
})
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/ui-settings-models/README.md
|
||||
README.md: 283761d17f857c9142a59ee3b333081df84ecd9c
|
||||
README.zh.md: 61029555adfc3ee14ccb5b083322d7ae5dbedfee
|
||||
README.md: f1314b1db9ee231b2f67777491ac57aefc5ea85a
|
||||
README.zh.md: 17861766c52333e90947a6c643c7df8cab4992b4
|
||||
@@ -37,6 +37,8 @@ The primary field on an editor card is a single **API key** input — the page n
|
||||
|
||||
The collapsed 自定义设置 fold carries the curated extras: `baseURL` for both families (the deepseek placeholder shows the public endpoint), each adapter's model catalog, and the **display name** and **API protocol** of a pi-ai route the adapter does not ship. Profile `headers` remain deployment configuration in `settings.yaml` or Cordis config and have no Models-page editor. The Provider ID stays fixed: it is the settings key, the name every other namespace and every logged session references, and the stem of a credential reference the page cannot read back to move. Reasoning effort is deliberately not among the editable fields: it is a per-model capability, so a provider-scoped control could only be set to a value some models reject. Each DeepSeek row edits `id`, optional display `name`, and optional `contextWindow`/`maxTokens`; existing fields outside that curated set survive edits.
|
||||
|
||||
The DeepSeek card edits the shared `llm-deepseek` endpoint, credentials, and model catalog without a protocol selector. When Cordis YAML selects Messages, the public endpoint placeholder is `https://api.deepseek.com/anthropic`. Saving the card preserves protocol configuration.
|
||||
|
||||
### Adding and deleting providers
|
||||
|
||||
The add flow is a card carrying the dormant-directory provider select — a bare-mounted `llm-pi-ai` offers its whole installed catalog before any route exists. **Add a custom provider** declares a route pi-ai does not ship; the create card asks for a unique **Provider ID**, an endpoint, a protocol, and at least one uniquely-identified model, because nothing can default those. The endpoint must be a parseable HTTP or HTTPS URL; localhost, IPv4 and IPv6 literals, and custom ports remain valid. A syntax error blocks both discovery and creation at the field, while a request failure remains a separate provider error. **Fetch available models** asks the `llm/discoverModels` Remote about the endpoint the form shows, so adding a provider is one pass instead of save-then-return; the reply opens a searchable picker rather than being written, and nothing is written until **Add selected**. Each selected candidate copies its id, display name, context window, and output-token cap into the editable row when disclosed, while an existing row retains its user-tuned values. Search matches model ids and optional display names without clearing hidden selections. **Select all** adds the visible results, while **Deselect all** clears the entire selection so hidden results cannot be adopted accidentally. A row is deletable only when the user layer alone carries it (removal restores the composition base), and its confirmation dialog names the provider.
|
||||
@@ -69,7 +71,7 @@ Each settings write carries the card's current `revision`, so a concurrent write
|
||||
|
||||
### Onboarding coordinator
|
||||
|
||||
The notice step owns its exact copy in `src/client/locales.ts` and its acknowledgement version in `src/onboarding-copy.ts`; on loopback it compares and writes `ui-onboarding.welcomeNoticeVersion` through the existing settings API, and only an explicit Continue records the current version. A non-loopback browser cannot use that Host-only namespace, so acknowledgement is process-local and the notice returns after reload. The DeepSeek step renders the existing `ProviderEditor` in credential-only mode inside the shared onboarding modal; `credentials.set` stays the only secret write, and no provider settings are changed.
|
||||
The notice step owns its exact copy in `src/client/locales.ts` and its acknowledgement version in `src/onboarding-copy.ts`; on loopback it compares and writes `ui-onboarding.welcomeNoticeVersion` through the existing settings API, and only an explicit Continue records the current version. A non-loopback browser cannot use that Host-only namespace, so acknowledgement is process-local and the notice returns after reload. The DeepSeek step targets `deepseek-official` in `llm-deepseek` and renders the existing `ProviderEditor` in credential-only mode inside the shared onboarding modal; `credentials.set` stays the only secret write, and no provider settings are changed.
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ kind: "package-reference"
|
||||
|
||||
收起的「自定义设置」折叠区承载精选的额外字段:两个家族都有 `baseURL`(deepseek 的占位符显示公共端点)、各适配器自己的模型目录,以及适配器未提供的 pi-ai 路由的**显示名称**与 **API 协议**。Profile `headers` 仍是 `settings.yaml` 或 Cordis 配置中的部署配置,Models 页面不提供编辑器。Provider ID 保持固定:它是 settings 的键、其他每个 namespace 与每一条已记录会话引用的名字,也是页面读不回、因而搬不走的凭据引用词干。推理等级刻意不在可编辑字段之列:它是按模型的能力,提供方级的控件只可能被设成某些模型会拒绝的值。每个 DeepSeek 行编辑 `id`、可选显示 `name` 与可选 `contextWindow`/`maxTokens`;该精选集之外的现有字段在编辑后仍会保留。
|
||||
|
||||
`llm-deepseek` 的 DeepSeek 卡片编辑共用的端点、凭据和模型目录,不提供协议选择器。Cordis YAML 选择 Messages 时,官方端点占位符为 `https://api.deepseek.com/anthropic`;保存卡片不会改写协议配置。
|
||||
|
||||
### 新增与删除提供方
|
||||
|
||||
「新增」流程是一张承载休眠目录提供方选择框的卡片——裸挂载的 `llm-pi-ai` 在任何路由存在之前就能提供其完整的已安装 catalog。**添加自定义提供方**声明一条 pi-ai 不提供的路由;创建卡片会索要唯一的 **Provider ID**、端点、协议与至少一个可唯一识别的模型,因为没有东西能为它们兜底。端点必须是可解析的 HTTP 或 HTTPS URL;localhost、IPv4 与 IPv6 字面地址以及自定义端口仍然有效。语法错误会在字段处阻止询问与创建,请求失败则继续作为独立的提供方错误显示。**获取可用模型**通过 `llm/discoverModels` Remote 查询表单显示的端点,因此新增提供方一次即可完成,而非先保存再返回;回复打开的是可搜索选择器而非直接写入,只有点击**添加所选**才会写入。每个选中候选会在提供方公布相应信息时,把 id、显示名、上下文窗口与最大输出 token 数复制进可编辑行;已经存在的行保留用户调整过的值。搜索会匹配模型 id 与可选显示名称,且不会清除隐藏项的勾选状态。**全选**会加入可见结果,而**取消全选**会清空全部勾选,以免意外采用隐藏结果。只有用户层单独携带某行时,该行才可删除(删除会恢复组合基线),其确认对话框会指名该提供方。
|
||||
@@ -69,7 +71,7 @@ kind: "package-reference"
|
||||
|
||||
### 引导协调器
|
||||
|
||||
声明步骤在 `src/client/locales.ts` 中持有精确文案,并在 `src/onboarding-copy.ts` 中持有确认版本;回环时它通过既有 settings API 比较并写入 `ui-onboarding.welcomeNoticeVersion`,且只有显式点击「继续」才会记录当前版本。非回环浏览器无法使用这个仅限宿主的 namespace,因此确认只保留在进程内,刷新后声明会再次出现。DeepSeek 步骤在共享引导模态框内以仅凭据模式渲染既有 `ProviderEditor`;`credentials.set` 仍是唯一的机密写入,且不改变任何提供方设置。
|
||||
声明步骤在 `src/client/locales.ts` 中持有精确文案,并在 `src/onboarding-copy.ts` 中持有确认版本;回环时它通过既有 settings API 比较并写入 `ui-onboarding.welcomeNoticeVersion`,且只有显式点击「继续」才会记录当前版本。非回环浏览器无法使用这个仅限宿主的 namespace,因此确认只保留在进程内,刷新后声明会再次出现。DeepSeek 步骤面向 `llm-deepseek` 中的 `deepseek-official`,在共享引导模态框内以仅凭据模式渲染既有 `ProviderEditor`;`credentials.set` 仍是唯一的机密写入,且不改变任何提供方设置。
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ import styles from './ModelsSection.module.css'
|
||||
/** Per-adapter-family curated field sets (unknown namespaces get the hint alone). */
|
||||
type EditorLayout = 'deepseek' | 'pi-ai' | 'unknown'
|
||||
|
||||
/** The public DeepSeek endpoint shown as the deepseek base-URL placeholder. */
|
||||
const DEEPSEEK_PUBLIC_BASE_URL = 'https://api.deepseek.com'
|
||||
|
||||
|
||||
/** Props of {@link ProviderEditor}. */
|
||||
export interface ProviderEditorProps {
|
||||
@@ -414,14 +413,16 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
|
||||
type="text"
|
||||
value={stringAt(draft, 'baseURL') ?? ''}
|
||||
placeholder={family === 'deepseek'
|
||||
? DEEPSEEK_PUBLIC_BASE_URL
|
||||
? t(stringAt(fallback, 'protocol') === 'messages' ? 'deepSeekMessagesBaseUrl' : 'deepSeekChatBaseUrl')
|
||||
: stringAt(fallback, 'baseURL') ?? t('baseUrlDefault')}
|
||||
aria-describedby={family === 'deepseek' ? `${props.provider}-endpoint-hint` : undefined}
|
||||
aria-label={t('baseUrl')}
|
||||
disabled={disabled}
|
||||
onChange={(event) => {
|
||||
setField('baseURL', event.target.value === '' ? undefined : event.target.value)
|
||||
}}
|
||||
/>
|
||||
{family === 'deepseek' ? <span id={`${props.provider}-endpoint-hint`} className={styles['advancedHint']}>{t('deepSeekEndpointHint')}</span> : null}
|
||||
</div>
|
||||
{/* The protocol sits beside the endpoint it describes, as it does
|
||||
on the create card. */}
|
||||
|
||||
@@ -35,6 +35,9 @@ export const en = {
|
||||
customized: 'Customized settings',
|
||||
baseUrl: 'Base URL',
|
||||
baseUrlDefault: 'Provider default',
|
||||
deepSeekChatBaseUrl: 'https://api.deepseek.com',
|
||||
deepSeekMessagesBaseUrl: 'https://api.deepseek.com/anthropic',
|
||||
deepSeekEndpointHint: 'Use an endpoint compatible with the configured connection.',
|
||||
models: 'Models',
|
||||
modelsInherited: 'Using the adapter defaults',
|
||||
modelsCustomized: 'Customized model catalog',
|
||||
@@ -142,6 +145,9 @@ export const zh: { [Key in keyof typeof en]: string } = {
|
||||
customized: '自定义设置',
|
||||
baseUrl: 'API 地址',
|
||||
baseUrlDefault: '提供方默认',
|
||||
deepSeekChatBaseUrl: 'https://api.deepseek.com',
|
||||
deepSeekMessagesBaseUrl: 'https://api.deepseek.com/anthropic',
|
||||
deepSeekEndpointHint: '请填写与当前连接配置兼容的 API 地址。',
|
||||
models: '模型目录',
|
||||
modelsInherited: '正在使用适配器默认模型',
|
||||
modelsCustomized: '已自定义模型目录',
|
||||
|
||||
@@ -665,6 +665,51 @@ describe('ModelsSection', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('edits the shared DeepSeek card while preserving the YAML protocol selection', async () => {
|
||||
const namespace: SettingsNamespaceView = {
|
||||
...wireNamespaces()[0]!,
|
||||
ns: 'llm-deepseek',
|
||||
value: { protocol: 'messages', apiKeyEnv: 'DEEPSEEK_API_KEY', models: DEFAULT_DEEPSEEK_MODELS },
|
||||
user: {},
|
||||
}
|
||||
const { face, mutate, set } = scriptedFace({
|
||||
mutate: vi.fn(() => Promise.resolve(remoteOk(namespace))),
|
||||
})
|
||||
const { ProviderEditor } = await import('../src/client/ProviderEditor.tsx')
|
||||
render(<ProviderEditor
|
||||
provider="deepseek-official"
|
||||
displayName="DeepSeek"
|
||||
namespace={namespace}
|
||||
schema={settingsSchema}
|
||||
settingsPath={[]}
|
||||
operations={operationsWith(face)}
|
||||
t={t}
|
||||
readOnly={false}
|
||||
onClose={vi.fn()}
|
||||
/>)
|
||||
fireEvent.click(screen.getByText(en.customized))
|
||||
expect(screen.getByLabelText<HTMLInputElement>(en.baseUrl).placeholder)
|
||||
.toBe('https://api.deepseek.com/anthropic')
|
||||
expect(screen.queryByLabelText(en.customApi)).toBeNull()
|
||||
expect(screen.getByText(en.deepSeekEndpointHint)).toBeTruthy()
|
||||
fireEvent.change(screen.getByLabelText(en.keyInput), { target: { value: 'sk-messages-test' } })
|
||||
fireEvent.change(screen.getByLabelText(en.baseUrl), { target: { value: 'https://messages.example/anthropic' } })
|
||||
fireEvent.change(screen.getByLabelText(`${en.modelName} 1`), { target: { value: 'Messages Flash' } })
|
||||
fireEvent.click(screen.getByText(en.apply))
|
||||
await waitFor(() => { expect(set).toHaveBeenCalledWith('DEEPSEEK_API_KEY', 'sk-messages-test') })
|
||||
expect(mutate.mock.calls).toEqual([[
|
||||
'llm-deepseek',
|
||||
[
|
||||
{ op: 'set', path: ['baseURL'], value: 'https://messages.example/anthropic' },
|
||||
{ op: 'set', path: ['models'], value: [
|
||||
{ ...DEFAULT_DEEPSEEK_MODELS[0], name: 'Messages Flash' },
|
||||
DEFAULT_DEEPSEEK_MODELS[1],
|
||||
] },
|
||||
],
|
||||
0,
|
||||
]])
|
||||
})
|
||||
|
||||
it('rejects duplicate DeepSeek model ids before writing', async () => {
|
||||
const { mutate } = await mountDeepSeekCard()
|
||||
fireEvent.click(screen.getByText(en.customized))
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/ui-user-questions/README.md
|
||||
README.md: 9e5997eb2ebe69b4b2d49b57a61b0bd36ec41053
|
||||
README.zh.md: 44a73607f95e7859b344034b5abaa2c386619083
|
||||
README.md: 5a31c688d7f7ea9a9ad10877628a333d797ac06d
|
||||
README.zh.md: 4db6cfa9fdead65c8e1c567981d0c16d92e9cb1e
|
||||
@@ -29,7 +29,7 @@ When the agent asks a question, the composer becomes the question surface: answe
|
||||
|
||||
### Answering
|
||||
|
||||
A multi-select draft keeps its selected labels while the user opens or edits the custom answer, so its submitted item may carry both `selected` and `custom`; a single-select custom answer remains exclusive. Question detail reuses the assistant-output `MarkdownText` primitive, including its GFM rendering and untrusted-content policy. The capped card keeps its title, navigation, and submission actions fixed while long detail and choices share an internal scroll region. "Skip this question" retains other drafts and emits the existing blank `{ selected: [] }` result for that item, while close rejects the whole wait as `ASK_CANCELLED`.
|
||||
A multi-select draft keeps its selected labels while the user opens or edits the custom answer, so its submitted item may carry both `selected` and `custom`; a single-select custom answer remains exclusive. Question detail reuses the assistant-output `MarkdownText` primitive, including its GFM rendering and untrusted-content policy. The capped card keeps its title, navigation, and submission actions fixed while long detail and choices share an internal scroll region. "Skip" retains other drafts and emits the existing blank `{ selected: [] }` result for that item, while close rejects the whole wait as `ASK_CANCELLED`.
|
||||
|
||||
### The plan-review card
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ kind: "package-reference"
|
||||
|
||||
### 作答
|
||||
|
||||
用户打开或编辑自定义答案时,多选题草稿会保留已选中的标签,因此提交项可以同时携带 `selected` 与 `custom`;单选题的自定义答案仍保持互斥。问题详情复用助手输出的 `MarkdownText` 原语,包括其 GFM 渲染与不受信任内容策略。限高卡片保持标题、导航与提交动作固定,超长的详情与选项共享内部滚动区。「跳过此问题」会保留其他草稿,并为该项发出既有的空 `{ selected: [] }` 结果;关闭则以 `ASK_CANCELLED` 拒绝整个等待。
|
||||
用户打开或编辑自定义答案时,多选题草稿会保留已选中的标签,因此提交项可以同时携带 `selected` 与 `custom`;单选题的自定义答案仍保持互斥。问题详情复用助手输出的 `MarkdownText` 原语,包括其 GFM 渲染与不受信任内容策略。限高卡片保持标题、导航与提交动作固定,超长的详情与选项共享内部滚动区。「跳过」会保留其他草稿,并为该项发出既有的空 `{ selected: [] }` 结果;关闭则以 `ASK_CANCELLED` 拒绝整个等待。
|
||||
|
||||
### plan-review 卡片
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export const zh = {
|
||||
'nav.cancel': '放弃整组问题',
|
||||
'option.recommended': '推荐',
|
||||
'custom.placeholder': '输入你的答案',
|
||||
'action.skip': '跳过本题',
|
||||
'action.skip': '跳过',
|
||||
'action.next': '下一题',
|
||||
'plan.header': '计划待审',
|
||||
'plan.approve': '确认执行',
|
||||
@@ -33,7 +33,7 @@ export const en = {
|
||||
'nav.cancel': 'Dismiss all questions',
|
||||
'option.recommended': 'Recommended',
|
||||
'custom.placeholder': 'Type your answer',
|
||||
'action.skip': 'Skip this question',
|
||||
'action.skip': 'Skip',
|
||||
'action.next': 'Next',
|
||||
'plan.header': 'Plan review',
|
||||
'plan.approve': 'Approve',
|
||||
|
||||
@@ -247,9 +247,9 @@ describe('QuestionComposer', () => {
|
||||
expect((screen.getByText('下一题').closest('button') as HTMLButtonElement).disabled).toBe(true)
|
||||
fireEvent.click(screen.getByRole('radio', { name: '研究潜力型' }))
|
||||
expect(screen.getByText('2 / 3')).toBeTruthy()
|
||||
fireEvent.click(screen.getByRole('button', { name: '跳过本题' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: '跳过' }))
|
||||
expect(screen.getByText('3 / 3')).toBeTruthy()
|
||||
fireEvent.click(screen.getByRole('button', { name: '跳过本题' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: '跳过' }))
|
||||
|
||||
expect(answer).toHaveBeenCalledWith(answerBatch([
|
||||
{ id: 'profile', selected: ['研究潜力型'] },
|
||||
@@ -346,7 +346,7 @@ describe('QuestionComposer', () => {
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '放弃整组问题' }))
|
||||
expect(await screen.findByText('第一次取消失败')).toBeTruthy()
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', { name: '跳过本题' }).disabled).toBe(false)
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', { name: '跳过' }).disabled).toBe(false)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '放弃整组问题' }))
|
||||
expect(await screen.findByText('第二次取消失败')).toBeTruthy()
|
||||
@@ -387,7 +387,7 @@ describe('QuestionComposer', () => {
|
||||
const { carrier } = wait([{ id: 'detail', question: '补充你的要求' }])
|
||||
render(<QuestionComposer matched={carrier} {...kit} t={seatOver(en, commonEn)} />)
|
||||
expect(screen.getByLabelText('Dismiss all questions')).toBeTruthy()
|
||||
expect(screen.getByRole('button', { name: 'Skip this question' })).toBeTruthy()
|
||||
expect(screen.getByRole('button', { name: 'Skip' })).toBeTruthy()
|
||||
expect(screen.getByPlaceholderText('Type your answer')).toBeTruthy()
|
||||
})
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/web/README.md
|
||||
README.md: 6bc0c4f241d1afb28825cadc19f89b7f54d4b637
|
||||
README.zh.md: e2d7ab81e82f1b5b1b93b95e4ed117a80f897a8e
|
||||
README.md: 7bdcec9e2a964b746cbd808497f9222e2b4150fa
|
||||
README.zh.md: a7243e52a7bababebb75a0ee9f4e22a99fa83337
|
||||
@@ -35,7 +35,7 @@ Boot runs in two stages: the module stage adopts the parser-loaded bootstrap bat
|
||||
|
||||
### The boot page
|
||||
|
||||
The boot page uses plain DOM and local CSS, so bundle and plugin-activation failures remain visible: it shows one spinner node whose CSS arc grows as entries activate, and reports per-entry status. The spinner and its animation phase persist until the full UI replaces the boot page. A plugin that fails import or activation is reported by name with the reason (missing service, import error, or state) instead of a blank page.
|
||||
The boot page uses plain DOM and local CSS, so bundle and plugin-activation failures remain visible: it shows one spinner node whose CSS arc grows as entries activate, and reports per-entry status. The spinner and its animation phase persist until the full UI replaces the boot page. A plugin that fails import or activation is reported by name with the reason (missing service, import failure, or state) instead of a blank page. The console contains the original import error.
|
||||
|
||||
### The shared module table
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ kind: "package-library"
|
||||
|
||||
### 启动页
|
||||
|
||||
启动页只使用原生 DOM 与本地 CSS,因此 bundle 与插件激活失败保持可见:它显示一个 spinner 节点,其 CSS 圆弧随 entry 激活而增长,并逐 entry 报告状态。spinner 及其动画相位会一直保留,直到完整 UI 替换启动页。导入或激活失败的插件会按名称报告并给出原因(缺失服务、导入错误或状态),而不是白屏。
|
||||
启动页只使用原生 DOM 与本地 CSS,因此 bundle 与插件激活失败保持可见:它显示一个 spinner 节点,其 CSS 圆弧随 entry 激活而增长,并逐 entry 报告状态。spinner 及其动画相位会一直保留,直到完整 UI 替换启动页。导入或激活失败的插件会按名称报告并给出原因(缺失服务、导入失败或状态),而不是白屏。控制台包含原始导入错误。
|
||||
|
||||
### 共享模块表
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ export interface ClientBootOptions {
|
||||
/**
|
||||
* Compose the client: `ctx.plugin(Loader)`, `loader.internal = modules`, one
|
||||
* `loader.create({ name })` per manifest row, `loader.await()`, then
|
||||
* {@link assertEntriesActive}. A row whose module cannot be imported rejects
|
||||
* `loader.create`, so that import error propagates from here as-is.
|
||||
* {@link assertEntriesActive}. A row whose module cannot be imported is marked
|
||||
* failed; the Loader logs its import error and the audit rejects startup.
|
||||
* @param options - context, module system, manifest, optional progress sink.
|
||||
* @returns resolves after every entry is active; rejects with the audit report otherwise.
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
createClientModuleSystem, parseBootManifest,
|
||||
type ClientBundleRegistration, type ClientModuleLoader, type ClientModuleLoaderTarget, type WebBootEntry, type WebBootGraph,
|
||||
} from '@deepseek-ai/dsh-client-modules/client'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, onTestFinished, vi } from 'vitest'
|
||||
import { assertEntriesActive, bootClient, type EntryStateLabel } from '../src/boot-client.ts'
|
||||
import { FIBER_STATE } from '../src/loader-status.ts'
|
||||
|
||||
@@ -77,17 +77,21 @@ describe('bootClient', () => {
|
||||
await ctx.fiber.dispose()
|
||||
})
|
||||
|
||||
it('surfaces the Loader import error for a row that is neither seeded nor a graph row', async () => {
|
||||
it('reports and logs an import failure for a row that is neither seeded nor a graph row', async () => {
|
||||
const { modules } = modulesOf(graphOf(['seeded']), { seeded: { apply: () => {} } })
|
||||
const manifest = parseBootManifest(graphOf(['ghost']))
|
||||
const ctx = new Context()
|
||||
onTestFinished(() => ctx.fiber.dispose())
|
||||
const error = vi.spyOn(ctx.logger, 'error').mockImplementation(() => {})
|
||||
onTestFinished(() => { error.mockRestore() })
|
||||
const sink = stateSink()
|
||||
|
||||
await expect(bootClient({ ctx, modules, manifest, onEntryState: sink.onEntryState })).rejects.toThrow(
|
||||
/failed to import loader entry \S+ \(ghost\): client-modules: cannot resolve/,
|
||||
'web boot: 1 entry did not activate\nghost: import failed (see console for the import error)',
|
||||
)
|
||||
expect(sink.states.get('ghost')).toEqual(['loading'])
|
||||
await ctx.fiber.dispose()
|
||||
expect(sink.states.get('ghost')).toEqual(['loading', 'failed'])
|
||||
expect(error).toHaveBeenCalledOnce()
|
||||
expect(error.mock.calls[0]?.[0]).toHaveProperty('message', expect.stringContaining('client-modules: cannot resolve'))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user