DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(model-config): 模型开关改为两个带 label 的官方 Switch
hairyf364462b3006b
diff --git a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.cssr.ts b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.cssr.tsindex bed345fc..f7519dfc 100644--- a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.cssr.ts+++ b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.cssr.ts@@ -7,25 +7,29 @@ const { secondary, tertiary, borderL3, brand, focusRing } = sharedStylesexport default c([c('.dshp-model-compat', {order: '1',+ display: 'flex',+ gap: '16px',minWidth: '0',margin: '0',padding: '0',border: 'none',}),+ c('.dshp-model-compat__field', {+ display: 'flex',+ flexDirection: 'column',+ gap: '4px',+ minWidth: '0',+ }),c('.dshp-model-compat__label', {- display: 'block',- marginBottom: '4px',padding: '0',color: tertiary,fontSize: '12px',lineHeight: '18px',}),- c('.dshp-model-compat__choices', {+ c('.dshp-model-compat__switch', {display: 'flex',- flexWrap: 'wrap',- gap: '16px',- minHeight: '32px',alignItems: 'center',+ height: '32px',}),c('.dshp-model-compat__levels', {order: '3',diff --git a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.test.tsx b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.test.tsxindex a82b4881..15f68c10 100644--- a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.test.tsx+++ b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.test.tsx@@ -15,9 +15,17 @@ vi.mock('dsh-tauri/client', () => ({}),}))+vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({+ Switch: ({ checked, disabled, label, title }: {+ checked: boolean+ disabled?: boolean+ label: string+ title?: string+ }) => <button type="button" role="switch" aria-checked={checked} aria-label={label} title={title} disabled={disabled} />,+}))+const t: Translate = (key, params) => {const dict: Record<string, string> = {- modelConfig: 'Model config',thinkingMode: 'Thinking mode',thinkingLevels: 'Thinking levels',thinkingModeHint: 'Declare whether this model thinks',@@ -43,28 +51,29 @@ function markup(model: Record<string, unknown>, templateCompat: boolean, disable)}-interface Choice {+interface SwitchState {checked: booleandisabled: booleanlabel: string- ariaLabel: stringtitle: string}-function choices(html: string): Choice[] {- const pattern = /<label class="dshp-checkbox"([^>]*)><input class="dshp-checkbox__input" type="checkbox"([^>]*)><span class="dshp-checkbox__label">([^<]*)<\/span><\/label>/g- return [...html.matchAll(pattern)].map((match) => {- const input = match[2] ?? ''+function switches(html: string): SwitchState[] {+ return [...html.matchAll(/<button type="button" role="switch"([^>]*)>/g)].map((match) => {+ const attrs = match[1] ?? ''return {- title: /title="([^"]*)"/.exec(match[1] ?? '')?.[1] ?? '',- checked: input.includes('checked=""'),- disabled: input.includes('disabled=""'),- ariaLabel: /aria-label="([^"]*)"/.exec(input)?.[1] ?? '',- label: match[3] ?? '',+ checked: attrs.includes('aria-checked="true"'),+ disabled: attrs.includes('disabled=""'),+ label: /aria-label="([^"]*)"/.exec(attrs)?.[1] ?? '',+ title: /title="([^"]*)"/.exec(attrs)?.[1] ?? '',}})}+function fieldLabels(html: string): string[] {+ return [...html.matchAll(/<span class="dshp-model-compat__label"([^>]*)>([^<]*)<\/span>/g)].map(match => match[2] ?? '')+}+function chips(html: string): { checked: boolean, disabled: boolean, level: string }[] {return [...html.matchAll(/<label class="dshp-model-compat__chip"><input type="checkbox"([^>]*)>([a-z]+)<\/label>/g)].map(match => ({@@ -75,15 +84,12 @@ function chips(html: string): { checked: boolean, disabled: boolean, level: stri}describe('modelCompatFields', () => {- it('labels the row and offers an ungraded thinking choice while thinking stays off', () => {+ it('labels the thinking switch while thinking stays off', () => {const html = markup({}, false)- expect(html).toContain('<fieldset class="dshp-model-compat" aria-label="Model config 1">')- expect(html).toContain('<legend class="dshp-model-compat__label">Model config</legend>')- expect(html).toContain('<div class="dshp-model-compat__choices">')- expect(choices(html)).toHaveLength(1)- expect(choices(html)[0]).toMatchObject({- label: 'Thinking mode',- ariaLabel: 'Thinking mode 1',+ expect(fieldLabels(html)).toEqual(['Thinking mode'])+ expect(switches(html)).toHaveLength(1)+ expect(switches(html)[0]).toMatchObject({+ label: 'Thinking mode 1',title: 'Declare whether this model thinks',checked: false,})@@ -92,17 +98,17 @@ describe('modelCompatFields', () => {it('renders the seven level chips once a graded level is declared', () => {const html = markup({ reasoningEfforts: { off: null, low: 'low' } }, false)- expect(choices(html)[0]?.checked).toBe(true)+ expect(switches(html)[0]?.checked).toBe(true)+ expect(fieldLabels(html)).toEqual(['Thinking mode', 'Thinking levels'])expect(chips(html).map(chip => chip.level)).toEqual(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'])expect(chips(html).filter(chip => chip.checked).map(chip => chip.level)).toEqual(['off', 'low'])expect(html).toContain('aria-label="Thinking levels 1"')})- it('gates the developer-role choice on the caller protocol decision', () => {+ it('gates the developer-role switch on the caller protocol decision', () => {const model = { compat: { thinkingFormat: 'chat-template', supportsDeveloperRole: false } }- expect(choices(markup(model, true)).map(choice => choice.label)).toEqual(['Thinking mode', 'Disable developer role'])- expect(choices(markup(model, true))[1]).toMatchObject({- ariaLabel: 'Disable developer role 1',+ expect(switches(markup(model, true)).map(item => item.label)).toEqual(['Thinking mode 1', 'Disable developer role 1'])+ expect(switches(markup(model, true))[1]).toMatchObject({title: 'Turn this on for an endpoint that rejects the developer role',checked: true,})@@ -111,7 +117,7 @@ describe('modelCompatFields', () => {it('disables every control while the editor is read-only', () => {const html = markup({ reasoningEfforts: { low: 'low' } }, true, true)- expect(choices(html).every(choice => choice.disabled)).toBe(true)+ expect(switches(html).every(item => item.disabled)).toBe(true)expect(chips(html).every(chip => chip.disabled)).toBe(true)})})diff --git a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.tsx b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.tsxindex ffc0db19..7e7319c7 100644--- a/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.tsx+++ b/packages/dsh-tauri-ui/src/client/components/model-extras/model-compat-fields.tsx@@ -1,5 +1,6 @@import type { ReactElement } from 'react'import type { ModelCompatFieldsProps } from './model-compat-fields.types'+import { Switch } from '@deepseek-ai/dsh-client-ui-primitives'import { MODEL_COMPAT_FIELDS_STYLE_ID } from '../../constants'import { useMountStyle } from '../../hooks/use-mount-style'import {@@ -12,7 +13,6 @@ import {thinkingEffortsOf,toggleThinkingLevel,} from '../../service/model-compat'-import { Checkbox } from '../checkbox'import modelCompatFieldsStyle from './model-compat-fields.cssr'export function ModelCompatFields({@@ -27,33 +27,36 @@ export function ModelCompatFields({const position = index + 1return (<>- <fieldset className="dshp-model-compat" aria-label={`${t('modelConfig')} ${String(position)}`}>- <legend className="dshp-model-compat__label">{t('modelConfig')}</legend>- <div className="dshp-model-compat__choices">- <Checkbox- checked={supportsThinking(model)}- disabled={disabled}- aria-label={`${t('thinkingMode')} ${String(position)}`}- title={t('thinkingModeHint')}- onChange={(next) => { onPatch({ reasoningEfforts: next ? enableThinking(model) : false }) }}- >- {t('thinkingMode')}- </Checkbox>- {templateCompat- ? (- <Checkbox- checked={supportsTemplateThinking(model)}- disabled={disabled}- aria-label={`${t('developerRole')} ${String(position)}`}- title={t('developerRoleHint')}- onChange={(next) => { onPatch({ compat: templateThinkingCompat(model, next) }) }}- >- {t('developerRole')}- </Checkbox>- )- : null}+ <div className="dshp-model-compat">+ <div className="dshp-model-compat__field">+ <span className="dshp-model-compat__label" title={t('thinkingModeHint')}>{t('thinkingMode')}</span>+ <div className="dshp-model-compat__switch">+ <Switch+ checked={supportsThinking(model)}+ disabled={disabled}+ label={`${t('thinkingMode')} ${String(position)}`}+ title={t('thinkingModeHint')}+ onChange={(next) => { onPatch({ reasoningEfforts: next ? enableThinking(model) : false }) }}+ />+ </div></div>- </fieldset>+ {templateCompat+ ? (+ <div className="dshp-model-compat__field">+ <span className="dshp-model-compat__label" title={t('developerRoleHint')}>{t('developerRole')}</span>+ <div className="dshp-model-compat__switch">+ <Switch+ checked={supportsTemplateThinking(model)}+ disabled={disabled}+ label={`${t('developerRole')} ${String(position)}`}+ title={t('developerRoleHint')}+ onChange={(next) => { onPatch({ compat: templateThinkingCompat(model, next) }) }}+ />+ </div>+ </div>+ )+ : null}+ </div>{supportsThinking(model)? (<div className="dshp-model-compat__levels" role="group" aria-label={`${t('thinkingLevels')} ${String(position)}`}>diff --git a/packages/dsh-tauri-ui/src/client/components/official.tsx b/packages/dsh-tauri-ui/src/client/components/official.tsxnew file mode 100644index 00000000..4dcc2941--- /dev/null+++ b/packages/dsh-tauri-ui/src/client/components/official.tsx@@ -0,0 +1,33 @@+export {+ BrandWordmark,+ Button,+ ConnectionIndicator,+ DisclosureRow,+ FISH_LOGO_PATH,+ FISH_LOGO_VIEWBOX,+ FishLogo,+ HoverCard,+ Input,+ Menu,+ Modal,+ Pill,+ StateDot,+ Switch,+ Tag,+ Toast,+ Tooltip,+} from '@deepseek-ai/dsh-client-ui-primitives'++export type {+ BrandWordmarkProps,+ ButtonVariant,+ ConnectionIndicatorState,+ DisclosureRowProps,+ MenuEntry,+ MenuItem,+ MenuLabel,+ MenuSeparator,+ StateDotState,+ TagTone,+ TooltipSide,+} from '@deepseek-ai/dsh-client-ui-primitives'diff --git a/packages/dsh-tauri-ui/src/client/components/registry.ts b/packages/dsh-tauri-ui/src/client/components/registry.tsnew file mode 100644index 00000000..0ea89360--- /dev/null+++ b/packages/dsh-tauri-ui/src/client/components/registry.ts@@ -0,0 +1,162 @@+export interface UiComponentSource {+ kind: 'reexport' | 'refork'+ component: string+ package: string+ version: string+ availableAt: readonly string[]+ upstreamPath: string+ mappedClass?: string+}++export interface UiComponentEntry {+ id: string+ title: string+ source: UiComponentSource+}++const PRIMITIVES = '@deepseek-ai/dsh-client-ui-primitives'+const VERSION = '0.1.7-alpha.1'+const AVAILABLE_BOTH = ['0.1.5-rc.1', '0.1.7-alpha.1']+const AVAILABLE_LATEST = ['0.1.7-alpha.1']++function slug(name: string): string {+ return name.replaceAll('_', '-').replaceAll(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()+}++function primitives(component: string, file: string): UiComponentEntry {+ return {+ id: slug(component),+ title: component,+ source: {+ kind: 'reexport',+ component,+ package: PRIMITIVES,+ version: VERSION,+ availableAt: AVAILABLE_BOTH,+ upstreamPath: `packages/client/ui-primitives/src/${file}.tsx`,+ },+ }+}++function refork(component: string, source: Omit<UiComponentSource, 'kind' | 'component' | 'version'>): UiComponentEntry {+ return {+ id: slug(component),+ title: component,+ source: {+ kind: 'refork',+ component,+ version: VERSION,+ ...source,+ },+ }+}++export const UI_COMPONENT_REGISTRY: readonly UiComponentEntry[] = [+ primitives('Button', 'Button'),+ primitives('ButtonVariant', 'Button'),+ primitives('Switch', 'Switch'),+ primitives('Tag', 'Tag'),+ primitives('TagTone', 'Tag'),+ primitives('Pill', 'Pill'),+ primitives('Menu', 'Menu'),+ primitives('MenuEntry', 'Menu'),+ primitives('MenuItem', 'Menu'),+ primitives('MenuLabel', 'Menu'),+ primitives('MenuSeparator', 'Menu'),+ primitives('Input', 'Input'),+ primitives('Tooltip', 'Tooltip'),+ primitives('TooltipSide', 'Tooltip'),+ primitives('Toast', 'Toast'),+ primitives('Modal', 'Modal'),+ primitives('HoverCard', 'HoverCard'),+ primitives('DisclosureRow', 'DisclosureRow'),+ primitives('DisclosureRowProps', 'DisclosureRow'),+ primitives('StateDot', 'StateDot'),+ primitives('StateDotState', 'StateDot'),+ primitives('ConnectionIndicator', 'ConnectionIndicator'),+ primitives('ConnectionIndicatorState', 'ConnectionIndicator'),+ primitives('BrandWordmark', 'BrandWordmark'),+ primitives('BrandWordmarkProps', 'BrandWordmark'),+ primitives('FishLogo', 'FishLogo'),+ primitives('FISH_LOGO_PATH', 'FishLogo'),+ primitives('FISH_LOGO_VIEWBOX', 'FishLogo'),++ refork('NewSessionButton', {+ package: '@deepseek-ai/dsh-client-ui-sidebar',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-sidebar/src/client/SidebarRoot.module.css',+ mappedClass: 'newSession',+ }),+ refork('SearchIconButton', {+ package: '@deepseek-ai/dsh-client-ui-workspace',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.module.css',+ mappedClass: 'searchButton',+ }),+ refork('ToolbarIconButton', {+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',+ mappedClass: 'iconButton',+ }),+ refork('AddButton', {+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',+ mappedClass: 'addButton',+ }),+ refork('DangerOutlineButton', {+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',+ mappedClass: 'danger',+ }),+ refork('RowIconButton', {+ package: '@deepseek-ai/dsh-client-ui-workspace',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-workspace/src/client/rows/Rows.module.css',+ mappedClass: 'iconButton',+ }),+ refork('HelpIconButton', {+ package: PRIMITIVES,+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-primitives/src/settings-form/fields.module.css',+ mappedClass: 'helpButton',+ }),+ refork('SeatChip', {+ package: '@deepseek-ai/dsh-client-ui-agent-preset',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-agent-preset/src/client/AgentPresetSeat.module.css',+ mappedClass: 'seat',+ }),+ refork('ComposerTriggerChip', {+ package: '@deepseek-ai/dsh-client-ui-permission-presets',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-permission-presets/src/client/PermissionSelect.module.css',+ mappedClass: 'trigger',+ }),+ refork('MessageIconAction', {+ package: '@deepseek-ai/dsh-client-ui-chat',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-chat/src/client/chat/MessageIconActions.module.css',+ mappedClass: 'action',+ }),+ refork('SettingsSelector', {+ package: '@deepseek-ai/dsh-client-ui-permission-presets',+ availableAt: AVAILABLE_BOTH,+ upstreamPath: 'packages/client/ui-permission-presets/src/client/PermissionRow.module.css',+ mappedClass: 'selector',+ }),+ refork('VersionTag', {+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',+ mappedClass: 'versionTag',+ }),+ refork('StatusTag', {+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',+ availableAt: AVAILABLE_LATEST,+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',+ mappedClass: 'statusTag',+ }),+]diff --git a/packages/dsh-tauri-ui/src/client/constants/index.ts b/packages/dsh-tauri-ui/src/client/constants/index.tsindex b7f975ee..a707d4fa 100644--- a/packages/dsh-tauri-ui/src/client/constants/index.ts+++ b/packages/dsh-tauri-ui/src/client/constants/index.ts@@ -25,6 +25,19 @@ export const CHECKBOX_STYLE_ID = 'dsh-tauri-ui-checkbox-styles'export const MODEL_EXTRAS_STYLE_ID = 'dsh-tauri-ui-model-extras-styles'export const MODEL_CONFIG_TOOLBAR_STYLE_ID = 'dsh-tauri-ui-model-config-toolbar-styles'export const MODEL_COMPAT_FIELDS_STYLE_ID = 'dsh-tauri-ui-model-compat-fields-styles'+export const NEW_SESSION_BUTTON_STYLE_ID = 'dsh-tauri-ui-new-session-button-styles'+export const SEARCH_ICON_BUTTON_STYLE_ID = 'dsh-tauri-ui-search-icon-button-styles'+export const TOOLBAR_ICON_BUTTON_STYLE_ID = 'dsh-tauri-ui-toolbar-icon-button-styles'+export const ADD_BUTTON_STYLE_ID = 'dsh-tauri-ui-add-button-styles'+export const DANGER_OUTLINE_BUTTON_STYLE_ID = 'dsh-tauri-ui-danger-outline-button-styles'+export const ROW_ICON_BUTTON_STYLE_ID = 'dsh-tauri-ui-row-icon-button-styles'+export const HELP_ICON_BUTTON_STYLE_ID = 'dsh-tauri-ui-help-icon-button-styles'+export const SEAT_CHIP_STYLE_ID = 'dsh-tauri-ui-seat-chip-styles'+export const COMPOSER_TRIGGER_CHIP_STYLE_ID = 'dsh-tauri-ui-composer-trigger-chip-styles'+export const MESSAGE_ICON_ACTION_STYLE_ID = 'dsh-tauri-ui-message-icon-action-styles'+export const SETTINGS_SELECTOR_STYLE_ID = 'dsh-tauri-ui-settings-selector-styles'+export const VERSION_TAG_STYLE_ID = 'dsh-tauri-ui-version-tag-styles'+export const STATUS_TAG_STYLE_ID = 'dsh-tauri-ui-status-tag-styles'/** 接管后的英雄区工作区选择控件(官方 chip 由样式隐藏,见 `components/hero-workspace.cssr.ts`)。 */export const HERO_WORKSPACE_CHIP_CLASS = 'dshp-hero-workspace'diff --git a/src-tauri/src/bridge/config.rs b/src-tauri/src/bridge/config.rsindex fc795bda..a4b40af3 100644--- a/src-tauri/src/bridge/config.rs+++ b/src-tauri/src/bridge/config.rs@@ -13,6 +13,17 @@ pub async fn get_app_config(app_handle: AppHandle) -> Result<config::Setting, StOk(config::get_store_dat_setting(&app_handle))}+/// 当前桌面端是否为 dev 构建(`tauri dev` / `pnpm dev:desktop`)。+///+/// 插件用它决定是否挂载只面向开发的调试入口(例如 dsh-tauri-ui 的「UI 组件」页);+/// release 必须返回 `false`,否则调试入口会随正式包发布。插件侧没有可用的构建期+/// 开关:`dsh-tauri-tsdown` 无条件把 `process.env.NODE_ENV` 定成 `'production'`,+/// 也不替换 `import.meta.env`,因此只能由宿主在运行时告知。+#[tauri::command]+pub fn is_dev_build() -> bool {+ cfg!(debug_assertions)+}+/// 更新桌面端配置////// `close_action` 对应前端的 camelCase `closeAction`,命中关闭按钮时的行为diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex 593b237d..1e05d9aa 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -906,6 +906,7 @@ pub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {crate::bridge::quarantine_broken_patch_layers,crate::bridge::strip_unresolved_patch_entries,crate::bridge::get_dsh_status,+ crate::bridge::is_dev_build,crate::bridge::get_preinstall_plugins,crate::bridge::get_preinstall_pending,crate::bridge::install_preinstall_plugins,