Merge pull request #4716 from deepseek-harness/feat/current-version-display
feat(client): 在通用设置展示当前版本号
This commit is contained in:
commit
2c233c64f0
14 files changed
+81
-15
No files matched your search
@@ -26,3 +26,4 @@
|
||||
- switch "Developer tools"
|
||||
- text: Send behavior while busy What Enter and the Send button do while the agent is running; Cmd/Ctrl+Enter uses the other behavior
|
||||
- button "Queue"
|
||||
- text: "Current version: {{version}}"
|
||||
@@ -26,3 +26,4 @@
|
||||
- switch "Developer tools"
|
||||
- text: Send behavior while busy What Enter and the Send button do while the agent is running; Cmd/Ctrl+Enter uses the other behavior
|
||||
- button "Queue"
|
||||
- text: "Current version: {{version}}"
|
||||
@@ -26,3 +26,4 @@
|
||||
- switch "开发者工具"
|
||||
- text: 繁忙时的发送行为 智能体运行时 Enter 键和发送按钮的行为;Cmd/Ctrl+Enter 使用另一行为
|
||||
- button "排队发送"
|
||||
- text: 当前版本:{{version}}
|
||||
@@ -29,6 +29,8 @@ const PLUGIN_INSTANCES_EXPECTED = join(SNAPSHOT_DIR, 'plugin-instances.expected.
|
||||
const DIALOG_EN_EXPECTED = join(SNAPSHOT_DIR, 'dialog-en.expected.md')
|
||||
const PLUGIN_ROW_SELECTOR = '[data-plugin-scope="preset"] [data-plugin-entry="tool-subagent"]'
|
||||
const MODE = webSnapshotMode()
|
||||
const { version } = JSON.parse(await readFile(new URL('../../../package.json', import.meta.url), 'utf8')) as { version: string }
|
||||
const versionCapture = { replacements: [[version, '{{version}}']] as const }
|
||||
|
||||
describe('web e2e: settings modal and General preferences', () => {
|
||||
let scaffold: WebScaffold
|
||||
@@ -93,8 +95,9 @@ describe('web e2e: settings modal and General preferences', () => {
|
||||
await expect.poll(() => openRequests, { timeout: 5_000 }).toBe(1)
|
||||
await expect.poll(() => openDocument.isEnabled(), { timeout: 5_000 }).toBe(true)
|
||||
await page.unroute('**/api/settings/openSettingsDocument')
|
||||
await dialog.getByText(`当前版本:${version}`, { exact: true }).waitFor()
|
||||
// Golden of the freshly opened dialog (default zh, General active).
|
||||
const snapshot = await captureStableAria(page, '[role="dialog"]', scaffold.workspaceCwd)
|
||||
const snapshot = await captureStableAria(page, '[role="dialog"]', scaffold.workspaceCwd, versionCapture)
|
||||
await compareOrRefreshGolden(DIALOG_EXPECTED, snapshot, MODE)
|
||||
// Section switch: aria-current moves (the Models page itself has its own scenario file).
|
||||
await dialog.getByRole('button', { name: '模型' }).click()
|
||||
@@ -647,6 +650,7 @@ describe('web e2e: settings modal and General preferences', () => {
|
||||
// ...and the attribute follows that switch, in the assembled app.
|
||||
await expect.poll(() => page.evaluate(() => document.documentElement.lang), { timeout: 5_000 }).toBe('en')
|
||||
expect(await enDialog.getByRole('button', { name: 'General' }).getAttribute('aria-current')).toBe('true')
|
||||
await enDialog.getByText(`Current version: ${version}`, { exact: true }).waitFor()
|
||||
await expect.poll(() => enDialog.getByText('Appearance', { exact: true }).count(), { timeout: 5_000 }).toBe(1)
|
||||
expect(await page.evaluate(() => localStorage.getItem('dsh.locale'))).toBeNull()
|
||||
await expect.poll(async () => readFile(join(scaffold.harnessHome, 'settings.yaml'), 'utf8'), { timeout: 5_000 })
|
||||
@@ -756,7 +760,8 @@ describe('web e2e: settings modal and General preferences', () => {
|
||||
// Golden of the English fallback dialog — the visible output this change
|
||||
// produces. The zh golden above covers the detected-locale surface, so
|
||||
// the pair pins both directions of the resolution.
|
||||
const snapshot = await captureStableAria(frPage, '[role="dialog"]', fresh.workspaceCwd)
|
||||
await dialog.getByText(`Current version: ${version}`, { exact: true }).waitFor()
|
||||
const snapshot = await captureStableAria(frPage, '[role="dialog"]', fresh.workspaceCwd, versionCapture)
|
||||
await compareOrRefreshGolden(DIALOG_EN_EXPECTED, snapshot, MODE)
|
||||
expect(frTripwire.pageErrors).toEqual([])
|
||||
expect(frTripwire.warnings).toEqual([])
|
||||
@@ -780,7 +785,7 @@ describe('web e2e: settings modal and General preferences', () => {
|
||||
const dialog = withoutBrowser.getByRole('dialog', { name: 'Settings' })
|
||||
await dialog.getByRole('button', { name: 'Detailed', exact: true }).waitFor()
|
||||
expect(await dialog.getByText('Open chat links in', { exact: true }).count()).toBe(0)
|
||||
const snapshot = await captureStableAria(withoutBrowser, '[role="dialog"]', fresh.workspaceCwd)
|
||||
const snapshot = await captureStableAria(withoutBrowser, '[role="dialog"]', fresh.workspaceCwd, versionCapture)
|
||||
await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'dialog-no-browser.expected.md'), snapshot, MODE)
|
||||
expect(browserConsole.pageErrors).toEqual([])
|
||||
expect(browserConsole.warnings).toEqual([])
|
||||
|
||||
@@ -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: 2337b7db8f5b8d2713d17f83092d948657a5acdb
|
||||
README.zh.md: 2fd25f3d1b44c400b4400397e94d641766d9ae62
|
||||
README.md: e06ecf5f36234f634cbff708f592fbe83c9f175e
|
||||
README.zh.md: 6eb54b49a7a7f1a55a6f9389c57f736533715185
|
||||
@@ -33,9 +33,11 @@ In Desktop, the account-row update control shows availability, progress, verific
|
||||
|
||||
### The General section
|
||||
|
||||
The current release version appears at the bottom of General Settings in Web and Desktop, using the build’s `DSH_CLIENT_VERSION` metadata and the active language. Partial builds without version metadata omit the row.
|
||||
|
||||
The Developer tools switch controls the shared preference described by [ui-settings](../ui-settings/README.md#use-this-package). It is available in both Web and desktop, follows accepted changes immediately, and disables duplicate input while a write settles. A failed write displays localized retry guidance.
|
||||
|
||||
The General section holds the built-in Developer tools row and rows registered into `settings.general.item` by feature packages. Each registrant owns its row copy and behavior. The Appearance row, for example, lives in ui-theme.
|
||||
The General section holds the built-in Developer tools and Current version rows alongside rows registered into `settings.general.item` by feature packages. Each registrant owns its row copy and behavior. The Appearance row, for example, lives in ui-theme.
|
||||
|
||||
### Opening the configuration file
|
||||
|
||||
@@ -53,7 +55,7 @@ The onboarding ledger projects in ascending order and mounts exactly one step at
|
||||
<details>
|
||||
<summary>Implementation internals — click to expand</summary>
|
||||
|
||||
The shell owns the chrome and the projections; it contributes the Developer tools row, while feature registrants own their additional content and copy.
|
||||
The shell owns the chrome and the projections; it contributes the Developer tools and Current version rows, while feature registrants own their additional content and copy.
|
||||
|
||||
### Ledger projections
|
||||
|
||||
@@ -104,7 +106,7 @@ None; this package neither assembles nor sends a provider request.
|
||||
|
||||
These limits define what the shell itself provides versus what features must supply; they are current package constraints.
|
||||
|
||||
- **Additional General rows require their feature plugins** — the shell supplies Developer tools; feature plugins supply the remaining preferences.
|
||||
- **Additional General rows require their feature plugins** — the shell supplies Developer tools and Current version; feature plugins supply the remaining preferences.
|
||||
- **The Windows caption badge keeps a side-opening bubble** — `DesktopUpdateBadge` occupies `sidebar.toggle.badge` in the caption and requests `side="right"`, so the Desktop-owned menu text can cover its bubble while the sidebar is collapsed on Windows; the sidebar toggle and New Session bubbles open below the caption instead (#4688).
|
||||
|
||||
<a id="dev-note"></a>
|
||||
|
||||
@@ -33,9 +33,11 @@ kind: "package-reference"
|
||||
|
||||
### 「通用」分区
|
||||
|
||||
Web 与桌面端的通用设置底部显示当前发布版本,使用构建注入的 `DSH_CLIENT_VERSION` 元数据和当前语言。缺少版本元数据的局部构建不显示该行。
|
||||
|
||||
开发者工具开关控制 [ui-settings](../ui-settings/README.zh.md#use-this-package) 定义的共享偏好。Web 和桌面端均提供此开关,立即跟随已接受的变更,并在写入完成前禁用重复输入。写入失败时显示本地化的重试提示。
|
||||
|
||||
「通用」分区承载内置的开发者工具行和功能包注册进 `settings.general.item` 的行。每个注册方拥有自己的行文案与行为。例如「外观」行位于 ui-theme。
|
||||
「通用」分区承载内置的开发者工具行与当前版本行,以及功能包注册进 `settings.general.item` 的行。每个注册方拥有自己的行文案与行为。例如「外观」行位于 ui-theme。
|
||||
|
||||
### 打开配置文件
|
||||
|
||||
@@ -53,7 +55,7 @@ kind: "package-reference"
|
||||
<details>
|
||||
<summary>实现细节——点击展开</summary>
|
||||
|
||||
外壳拥有界面框架与投影,并提供开发者工具行;功能注册方拥有其余内容与文案。
|
||||
外壳拥有界面框架与投影,并提供开发者工具行与当前版本行;功能注册方拥有其余内容与文案。
|
||||
|
||||
### 账本投影
|
||||
|
||||
@@ -104,7 +106,7 @@ kind: "package-reference"
|
||||
|
||||
这些限制说明外壳自身提供什么、功能包必须提供什么;它们是当前包约束。
|
||||
|
||||
- **额外的通用设置行需要相应功能插件**:外壳提供开发者工具;功能插件提供其他偏好。
|
||||
- **额外的通用设置行需要相应功能插件**:外壳提供开发者工具与当前版本;功能插件提供其他偏好。
|
||||
- **Windows 顶栏徽标的气泡仍向右展开**:`DesktopUpdateBadge` 占用顶栏的 `sidebar.toggle.badge` 且请求 `side="right"`,侧栏收起时其气泡会被 Desktop 菜单文字遮挡;侧栏开关与新建会话的气泡则改在顶栏下方展开(#4688)。
|
||||
|
||||
<a id="dev-note"></a>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
.row {
|
||||
padding: 16px 0;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/** Installed release version in General Settings for Web and Desktop. */
|
||||
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import css from './CurrentVersionRow.module.css'
|
||||
|
||||
/**
|
||||
* Render the version embedded by the client build; partial builds without metadata omit the row.
|
||||
* @param props - runtime share and localized copy.
|
||||
* @returns the current release label, or nothing when build metadata is absent.
|
||||
*/
|
||||
export function CurrentVersionRow({ t }: PropsRuntime<'settings.general.item'> & PropsLocale<'settings'>) {
|
||||
const version = process.env.DSH_CLIENT_VERSION
|
||||
if (version === undefined) return null
|
||||
return <div className={css.row}>{t('general.currentVersion', { version })}</div>
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import type { DesktopUpdateBridge } from './desktop-update-bridge.ts'
|
||||
import { DesktopUpdateSource } from './desktop-update-source.ts'
|
||||
import { CloseLabel, HeaderContent, TriggerContent } from './chrome.tsx'
|
||||
import { GeneralSection } from './GeneralSection.tsx'
|
||||
import { CurrentVersionRow } from './CurrentVersionRow.tsx'
|
||||
import { DeveloperToolsRow, type DeveloperToolsRowInjected } from './DeveloperToolsRow.tsx'
|
||||
import { SettingsDocumentAction } from './SettingsDocumentAction.tsx'
|
||||
import type { SettingsDocumentActionInjected } from './SettingsDocumentAction.tsx'
|
||||
@@ -76,6 +77,10 @@ export function apply(ctx: ClientContext): void {
|
||||
setEnabled: enabled => ctx.settingsScope.developerTools.setEnabled(enabled),
|
||||
}),
|
||||
}, DeveloperToolsRow))
|
||||
// Last row: every feature-registered preference row orders below 100.
|
||||
ctx.slots.inject('settings.general.item', () => ctx.slots.register({
|
||||
name: 'settings.general.item', id: 'current-version', order: 100, locale: NS,
|
||||
}, CurrentVersionRow))
|
||||
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'ui-settings-general: dictionaries')
|
||||
const connection = ctx.get('connection') as ConnectionHandle
|
||||
const carrier = (globalThis as typeof globalThis & { dshDesktop?: { protocolVersion: number; updates?: DesktopUpdateBridge } }).dshDesktop
|
||||
|
||||
@@ -26,6 +26,7 @@ export const zh = {
|
||||
'openDocument': '打开配置文件',
|
||||
'openDocument.error': '无法打开配置文件',
|
||||
'general.nav': '通用设置',
|
||||
'general.currentVersion': '当前版本:{version}',
|
||||
'developerTools.title': '开发者工具',
|
||||
'developerTools.error': '保存失败,请重试',
|
||||
'developerTools.description': '显示用于调试和排查问题的工具与信息',
|
||||
@@ -65,6 +66,7 @@ export const en = {
|
||||
'openDocument': 'Open configuration file',
|
||||
'openDocument.error': 'Could not open configuration file',
|
||||
'general.nav': 'General',
|
||||
'general.currentVersion': 'Current version: {version}',
|
||||
'developerTools.title': 'Developer tools',
|
||||
'developerTools.error': 'Could not save. Please try again.',
|
||||
'developerTools.description': 'Show tools and information for debugging and troubleshooting',
|
||||
|
||||
@@ -102,7 +102,7 @@ describe('ui-settings-general apply', () => {
|
||||
expect(generalLabel(c)).toBe('通用设置')
|
||||
expect(c.ctx.slots.spec('settings.general.item')).toEqual({ kind: 'list', scope: 'root' })
|
||||
// The shared developer-tool control belongs to General; onboarding remains feature-owned.
|
||||
expect(c.ctx.slots.entries('settings.general.item').filter(row => row.locale === NS).map(row => row.options.id)).toEqual(['developer-tools'])
|
||||
expect(c.ctx.slots.entries('settings.general.item').filter(row => row.locale === NS).map(row => row.options.id)).toEqual(['developer-tools', 'current-version'])
|
||||
expect(c.ctx.slots.entries('settings.onboarding').filter(row => row.locale === NS)).toEqual([])
|
||||
const developerRow = c.ctx.slots.entries('settings.general.item').find(row => row.options.id === 'developer-tools')!
|
||||
const developer = (developerRow.inject as unknown as () => DeveloperToolsRowInjected)()
|
||||
@@ -213,7 +213,7 @@ describe('ui-settings-general apply', () => {
|
||||
expect(ownEntries(c, name)[0]).not.toBe(before[index])
|
||||
})
|
||||
expect(c.ctx.slots.spec('settings.general.item')).toEqual({ kind: 'list', scope: 'root' })
|
||||
expect(c.ctx.slots.entries('settings.general.item').filter(row => row.locale === NS).map(row => row.options.id)).toEqual(['developer-tools'])
|
||||
expect(c.ctx.slots.entries('settings.general.item').filter(row => row.locale === NS).map(row => row.options.id)).toEqual(['developer-tools', 'current-version'])
|
||||
// The recovered registrations still ride the locale path.
|
||||
const english = localeView('en', 1)
|
||||
const chinese = localeView('zh', 2)
|
||||
@@ -237,6 +237,7 @@ describe('ui-settings-general apply', () => {
|
||||
await c.unload(SELF)
|
||||
await c.flush()
|
||||
for (const [name] of SEATS) expect(ownEntries(c, name)).toHaveLength(0)
|
||||
expect(c.ctx.slots.entries('settings.general.item').filter(row => row.locale === NS)).toEqual([])
|
||||
expect(c.ctx.slots.spec('settings.general.item')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -22,11 +22,12 @@ function derivedDocumentStore(remote: object) {
|
||||
const ctx = { remote } as never
|
||||
return new SettingsDocumentStore(ctx, new SettingsDescribeMirror(ctx))
|
||||
}
|
||||
import { en } from '../src/client/locales.ts'
|
||||
import { en, zh } from '../src/client/locales.ts'
|
||||
import { CurrentVersionRow } from '../src/client/CurrentVersionRow.tsx'
|
||||
import { DesktopUpdateBadge } from '../src/client/DesktopUpdateIndicator.tsx'
|
||||
import type { DesktopUpdateView } from '../src/client/desktop-update-bridge.ts'
|
||||
|
||||
afterEach(cleanup)
|
||||
afterEach(() => { cleanup(); vi.unstubAllEnvs() })
|
||||
|
||||
// The seat's key domain is settings ∪ common; the stub answers from the
|
||||
// package dictionary and falls back to the key like the real chain.
|
||||
@@ -222,3 +223,26 @@ it('reports a failed developer-tool write and allows retry', async () => {
|
||||
await waitFor(() => { expect(toggle.getAttribute('aria-checked')).toBe('true') })
|
||||
expect(screen.queryByRole('alert')).toBeNull()
|
||||
})
|
||||
|
||||
describe('current version', () => {
|
||||
it.each([
|
||||
['Current version: 1.2.3-rc.4', en],
|
||||
['当前版本:1.2.3-rc.4', zh],
|
||||
])('renders the localized release label %s', (expected, dictionary) => {
|
||||
vi.stubEnv('DSH_CLIENT_VERSION', '1.2.3-rc.4')
|
||||
const translate: TriggerContentProps['t'] = (key, params) => {
|
||||
let text = (dictionary as Record<string, string>)[key] ?? key
|
||||
for (const [name, value] of Object.entries(params ?? {})) text = text.replace(`{${name}}`, String(value))
|
||||
return text
|
||||
}
|
||||
render(<CurrentVersionRow {...kit} t={translate} />)
|
||||
expect(screen.getByText(expected)).toBeTruthy()
|
||||
expect(screen.queryByRole('button')).toBeNull()
|
||||
})
|
||||
|
||||
it('omits the row when a partial build has no version metadata', () => {
|
||||
vi.stubEnv('DSH_CLIENT_VERSION', undefined)
|
||||
const view = render(<CurrentVersionRow {...kit} t={t} />)
|
||||
expect(view.container.textContent).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -1994,6 +1994,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
'client-ui-conversation EnterBehaviorRow id \'composer-enter\'',
|
||||
'client-ui-permission-presets PermissionRow id \'permission\'',
|
||||
'client-ui-settings-general DeveloperToolsRow id \'developer-tools\'',
|
||||
'client-ui-settings-general CurrentVersionRow id \'current-version\'',
|
||||
'client-ui-theme AppearanceRow id \'appearance\'',
|
||||
'client-ui-theme FontSizeRow id \'font-size\'',
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user