Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(config): 服务内存上限输入框内补上 MB 单位 (#937)

iuuuuuuuu408f029adbb7
diff --git a/src/ui/config/debug.tsx b/src/ui/config/debug.tsx
index f8fdda18..f6189c87 100644
--- a/src/ui/config/debug.tsx
+++ b/src/ui/config/debug.tsx
@@ -1,6 +1,6 @@
import type { RuntimeInfo } from '@/types'
import { ArrowRotateRight, ArrowUpRightFromSquare, ChevronRight, CircleInfo, Copy, Power } from '@gravity-ui/icons'
-import { Button, Chip, Description, Input, Link, ListBox, Select, Spinner, Switch, Tooltip } from '@heroui/react'
+import { Button, Chip, Description, Input, InputGroup, Link, ListBox, Select, Spinner, Switch, Tooltip } from '@heroui/react'
import { useMutation, useQuery } from '@tanstack/react-query'
import { invoke } from '@tauri-apps/api/core'
import { useState } from 'react'
@@ -461,15 +461,18 @@ export function ConfigDebug() {
<div className="flex items-center justify-between gap-2">
<span className="text-xs font-medium text-ink">{t('ui.heap_limit')}</span>
<div className="flex items-center gap-1.5">
- <Input
- type="number"
- variant="secondary"
- value={heapValue}
- placeholder={t('ui.heap_limit_auto')}
- onChange={e => setHeapInput(e.target.value)}
- className="w-24 h-8 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
- aria-label={t('ui.heap_limit')}
- />
+ <InputGroup variant="secondary" className="w-24 h-8 min-h-8!">
+ <InputGroup.Input
+ type="number"
+ value={heapValue}
+ placeholder={t('ui.heap_limit_auto')}
+ onChange={e => setHeapInput(e.target.value)}
+ className="min-w-0 py-0 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
+ aria-label={t('ui.heap_limit')}
+ data-testid="dsh-config-heap-input"
+ />
+ <InputGroup.Suffix className="px-1.5" data-testid="dsh-config-heap-unit">MB</InputGroup.Suffix>
+ </InputGroup>
<Button
size="sm"
variant="primary"
diff --git a/test/harness-heap.test.ts b/test/harness-heap.test.ts
index 99f04c36..afa326a2 100644
--- a/test/harness-heap.test.ts
+++ b/test/harness-heap.test.ts
@@ -3,6 +3,7 @@ import i18next from 'i18next'
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
import { resources } from '../src/i18n/index.resource'
import { attachStartupDiagnostics } from '../src/store/modules/harness/utils'
+import { readSource } from './setup/read-source'
const invokeMock = vi.hoisted(() => vi.fn())
@@ -91,3 +92,41 @@ describe('harness heap i18n contract', () => {
}
})
})
+
+describe('服务内存上限的单位', () => {
+ /** 堆上限所在的那一行(到下一个分隔块为止),单位必须落在输入框自身而不是别处 */
+ function heapRow(): string {
+ const source = readSource('src/ui/config/debug.tsx')
+ const start = source.indexOf('ui.heap_limit')
+ expect(start).toBeGreaterThan(-1)
+ const end = source.indexOf('<div className="border-t', start)
+ expect(end).toBeGreaterThan(start)
+ return source.slice(start, end)
+ }
+
+ it('输入框内以 InputGroup 后缀给出 MB 单位', () => {
+ const row = heapRow()
+
+ expect(row).toMatch(/<InputGroup[\s>]/)
+ expect(row).toMatch(/<InputGroup\.Input/)
+ expect(row).toMatch(/<InputGroup\.Suffix[^>]*data-testid="dsh-config-heap-unit"[^>]*>\s*MB\s*</)
+ expect(row).not.toMatch(/<Input[\s>]/)
+ })
+
+ it('保留原有的数字输入语义与无障碍标签', () => {
+ const row = heapRow()
+
+ expect(row).toMatch(/data-testid="dsh-config-heap-input"/)
+ expect(row).toMatch(/type="number"/)
+ expect(row).toMatch(/value=\{heapValue\}/)
+ expect(row).toMatch(/placeholder=\{t\('ui\.heap_limit_auto'\)\}/)
+ expect(row).toMatch(/aria-label=\{t\('ui\.heap_limit'\)\}/)
+ expect(row).toMatch(/onChange=\{e => setHeapInput\(e\.target\.value\)\}/)
+ })
+
+ it('从 heroui 具名导入 InputGroup', () => {
+ const source = readSource('src/ui/config/debug.tsx')
+
+ expect(source).toMatch(/import \{[^}]+InputGroup[^}]*\} from '@heroui\/react'/)
+ })
+})