@chatcode/cco-better-sidebar 0.18.0-alpha.4 → 0.18.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +30 -9
  2. package/README_EN.md +30 -9
  3. package/cordis.patch.yml +6 -5
  4. package/lib/client-editor.js +10954 -395
  5. package/lib/client-mermaid.js +10835 -300
  6. package/lib/client-registry.js +4035 -2215
  7. package/lib/client-terminal.js +435 -292
  8. package/lib/client.js +4035 -2215
  9. package/lib/index.js +282 -47
  10. package/lib/types/client/LogoutConfirmDialog.d.ts +5 -0
  11. package/lib/types/client/PluginMarketSettingsSection.d.ts +7 -0
  12. package/lib/types/client/PluginMarketView.d.ts +7 -0
  13. package/lib/types/client/PluginProjectPicker.d.ts +13 -0
  14. package/lib/types/client/api.d.ts +21 -0
  15. package/lib/types/client/builtins/tabs.d.ts +13 -1
  16. package/lib/types/client/icons.d.ts +26 -8
  17. package/lib/types/client/locales-ja.d.ts +25 -0
  18. package/lib/types/client/locales.d.ts +39 -0
  19. package/lib/types/client/plugin-market-catalog.d.ts +25 -0
  20. package/lib/types/client/service.d.ts +1 -1
  21. package/lib/types/client/ui-tweaks/archive.d.ts +9 -28
  22. package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
  23. package/lib/types/client/ui-tweaks/dom-text.d.ts +2 -0
  24. package/lib/types/client/ui-tweaks/index.d.ts +9 -1
  25. package/lib/types/client/ui-tweaks/sidebar-header.d.ts +6 -0
  26. package/lib/types/client/ui-tweaks/typography.d.ts +9 -0
  27. package/lib/types/config.d.ts +4 -3
  28. package/lib/types/context-types.d.ts +12 -14
  29. package/lib/types/login-page-script.d.ts +2 -0
  30. package/lib/types/login-route.d.ts +2 -0
  31. package/lib/types/plugin-market-api.d.ts +5 -0
  32. package/lib/types/plugin-market-shared.d.ts +59 -0
  33. package/lib/types/prefs-shared.d.ts +1 -1
  34. package/lib/types/pty-deps.d.ts +1 -1
  35. package/lib/types/ui-tweaks/config.d.ts +6 -7
  36. package/lib/types/ui-tweaks/index.d.ts +2 -3
  37. package/package.json +2 -2
  38. package/src/client/AccountMenu.tsx +12 -2
  39. package/src/client/BrowserView.tsx +1 -1
  40. package/src/client/DiffTab.tsx +1 -1
  41. package/src/client/EditorHost.tsx +1 -1
  42. package/src/client/FileTree.tsx +10 -5
  43. package/src/client/FreeWindow.tsx +2 -1
  44. package/src/client/GitView.tsx +7 -3
  45. package/src/client/LogoutConfirmDialog.tsx +39 -0
  46. package/src/client/PluginMarketSettingsSection.tsx +55 -0
  47. package/src/client/PluginMarketView.module.css +50 -0
  48. package/src/client/PluginMarketView.tsx +243 -0
  49. package/src/client/PluginProjectPicker.tsx +73 -0
  50. package/src/client/SideCardSection.tsx +2 -23
  51. package/src/client/Sidebar.tsx +2 -2
  52. package/src/client/TabBar.tsx +2 -4
  53. package/src/client/TextEditor.tsx +2 -1
  54. package/src/client/TreePanel.tsx +1 -2
  55. package/src/client/UsageHeatmapSection.tsx +1 -1
  56. package/src/client/api.ts +12 -0
  57. package/src/client/builtins/tabs.tsx +25 -5
  58. package/src/client/builtins/viewers.tsx +2 -1
  59. package/src/client/icons.tsx +57 -4
  60. package/src/client/index.tsx +10 -1
  61. package/src/client/intercept.tsx +1 -1
  62. package/src/client/locales-ja.ts +65 -0
  63. package/src/client/locales.ts +118 -1
  64. package/src/client/md-toc.tsx +1 -1
  65. package/src/client/mermaid.tsx +2 -1
  66. package/src/client/open-with-settings.tsx +1 -1
  67. package/src/client/plugin-market-catalog.ts +90 -0
  68. package/src/client/service.ts +1 -1
  69. package/src/client/sidebar.module.css +81 -19
  70. package/src/client/ui-tweaks/archive.tsx +118 -140
  71. package/src/client/ui-tweaks/branding.tsx +117 -49
  72. package/src/client/ui-tweaks/cachehit.tsx +24 -14
  73. package/src/client/ui-tweaks/dom-text.ts +12 -0
  74. package/src/client/ui-tweaks/index.tsx +75 -103
  75. package/src/client/ui-tweaks/sidebar-header.ts +73 -0
  76. package/src/client/ui-tweaks/typography.ts +38 -0
  77. package/src/config.ts +22 -2
  78. package/src/context-types.ts +5 -15
  79. package/src/index.ts +28 -21
  80. package/src/login-page-script.ts +107 -0
  81. package/src/login-route.ts +7 -4
  82. package/src/plugin-market-api.ts +88 -0
  83. package/src/plugin-market-shared.ts +30 -0
  84. package/src/prefs-shared.ts +1 -1
  85. package/src/pty-deps.ts +2 -2
  86. package/src/ui-tweaks/config.ts +12 -12
  87. package/src/ui-tweaks/index.ts +7 -13
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'
11
11
  import { createPortal } from 'react-dom'
12
+ import type { SessionId } from '@deepseek-ai/dsh-session/types'
12
13
  import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
13
14
  import type { Context as ClientContext } from '../../context-types.ts'
14
15
  import type {} from '@deepseek-ai/dsh-client-locale/client'
@@ -36,6 +37,8 @@ import { WhaleIndicator, installWhaleStyles } from './whale.tsx'
36
37
  import { PreciseCacheHitEntry } from './cachehit.tsx'
37
38
  import { installTaskNotifier, previewAlerts, requestNotifyPermission } from './notifier.ts'
38
39
  import { HeroProjectLogo, installBranding, ProjectLogoIcon, SidebarProjectLogo, SidebarProjectName } from './branding.tsx'
40
+ import { buildFontCss } from './typography.ts'
41
+ import { uiTweaksArchiveJa } from '../locales-ja.ts'
39
42
 
40
43
  const NS = 'ui-tweaks'
41
44
  const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
@@ -43,12 +46,12 @@ const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
43
46
  /** Client context narrowed to the browser sessions face in this combined build. */
44
47
  type UITweaksClientContext = ClientContext & { sessions: ISessions }
45
48
 
46
- const DEFAULT_FONT_SIZE = 16
49
+ const DEFAULT_FONT_SIZE = 14
47
50
  const MIN_FONT_SIZE = 10
48
51
  const MAX_FONT_SIZE = 32
49
52
  /** Legacy: code font as a percentage of the message font size (81% = stock 13/16). */
50
53
  const DEFAULT_CODE_FONT_SCALE = 81
51
- /** Absolute code font size (px): 13 matches the host default at a 16px body. */
54
+ /** Default absolute code-block size, paired with 14px prose. */
52
55
  const DEFAULT_CODE_FONT_SIZE = 13
53
56
  const MIN_CODE_FONT_SIZE = 8
54
57
  const MAX_CODE_FONT_SIZE = 32
@@ -134,7 +137,7 @@ const en = {
134
137
  fontSize: 'Message font size',
135
138
  fontSizeHint: `Number between ${MIN_FONT_SIZE} and ${MAX_FONT_SIZE}; applies to message text, headings, tables and code.`,
136
139
  codeFontSize: 'Code font size',
137
- codeFontSizeHint: `Absolute code size in px (${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}); ${DEFAULT_CODE_FONT_SIZE}px is ChatCode CLI's default at a 16px body. Applies to code blocks; inline code follows proportionally.`,
140
+ codeFontSizeHint: `Absolute code size in px (${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}); ${DEFAULT_CODE_FONT_SIZE}px is ChatCode CLI's default at a 14px body. Applies to code blocks; inline code follows proportionally.`,
138
141
  lineHeight: 'Line spacing',
139
142
  lineHeightHint: `Base vertical spacing in px: gaps between message rows (Think ↔ tool cards) and blocks inside one reply, plus text line-height, paragraph and list margins, all scale from it; ${DEFAULT_LINE_HEIGHT} is ChatCode CLI's default.`,
140
143
  tableStyle: 'Table style',
@@ -245,8 +248,16 @@ const en = {
245
248
  archiveEmpty: 'No archived sessions.',
246
249
  archiveRestore: 'Restore',
247
250
  archiveRestoring: 'Working…',
251
+ archiveConfirmTitle: 'Permanently delete sessions?',
252
+ archiveConfirmDescription: 'Delete {count} session records including owned subagents? This cannot be undone. Independent forks, workspace files and Git data are retained.',
253
+ archiveCancel: 'Cancel',
248
254
  archiveDelete: 'Delete',
249
255
  archiveDeleteAll: 'Delete all',
256
+ archiveSelectAll: 'Select all',
257
+ archiveSelectedCount: '{count} sessions selected',
258
+ archiveClearSelection: 'Clear selection',
259
+ archiveDeleteSelected: 'Delete selected ({count})',
260
+ archiveDeleteFailed: '{title}: {error}',
250
261
  archiveRestoreAll: 'Restore all',
251
262
  archiveCount: 'sessions',
252
263
  archiveUnavailable: 'Archive unavailable.',
@@ -334,7 +345,7 @@ const zh: Record<LocaleKey, string> = {
334
345
  fontSize: '消息字体大小',
335
346
  fontSizeHint: `取值 ${MIN_FONT_SIZE}–${MAX_FONT_SIZE},作用于消息正文、标题、表格与代码。`,
336
347
  codeFontSize: '代码字号',
337
- codeFontSizeHint: `代码绝对字号,取值 ${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}px;${DEFAULT_CODE_FONT_SIZE}px 为 ChatCode CLI 默认(正文 16 时)。作用于代码块,行内代码按比例跟随。`,
348
+ codeFontSizeHint: `代码绝对字号,取值 ${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}px;${DEFAULT_CODE_FONT_SIZE}px 为 ChatCode CLI 默认(正文 14 时)。作用于代码块,行内代码按比例跟随。`,
338
349
  lineHeight: '行高',
339
350
  lineHeightHint: `回复区垂直间距的基准值:消息之间(如 Think ↔ 工具卡片)、回复内块之间、正文行高、段落与列表边距都按它缩放;取值 ${MIN_LINE_HEIGHT}–${MAX_LINE_HEIGHT}px,${DEFAULT_LINE_HEIGHT} 为 ChatCode CLI 默认。`,
340
351
  tableStyle: '表格样式',
@@ -346,7 +357,7 @@ const zh: Record<LocaleKey, string> = {
346
357
  gitBarOn: '开启',
347
358
  gitBarOff: '关闭',
348
359
  archiveManager: '归档管理',
349
- archiveManagerHint: '在设置中显示「归档」页面:恢复或彻底删除已归档会话。',
360
+ archiveManagerHint: '在设置中显示「归档」页面:恢复或永久删除已归档会话。',
350
361
  archiveManagerOn: '开启',
351
362
  archiveManagerOff: '关闭',
352
363
  mcpManager: 'MCP 管理',
@@ -445,13 +456,21 @@ const zh: Record<LocaleKey, string> = {
445
456
  archiveEmpty: '暂无归档会话。',
446
457
  archiveRestore: '恢复',
447
458
  archiveRestoring: '处理中…',
459
+ archiveConfirmTitle: '永久删除会话?',
460
+ archiveConfirmDescription: '将永久删除共 {count} 条会话记录(含所属子代理),无法撤销。独立分叉、工作区文件与 Git 数据保留。',
461
+ archiveCancel: '取消',
448
462
  archiveDelete: '删除',
449
463
  archiveDeleteAll: '全部删除',
464
+ archiveSelectAll: '全选',
465
+ archiveSelectedCount: '已选择 {count} 个会话',
466
+ archiveClearSelection: '取消选择',
467
+ archiveDeleteSelected: '删除所选({count})',
468
+ archiveDeleteFailed: '「{title}」:{error}',
450
469
  archiveRestoreAll: '全部恢复',
451
470
  archiveCount: '个会话',
452
471
  archiveUnavailable: '归档暂不可用。',
453
472
  archiveLiveError: '该会话正在运行,无法彻底删除,请先关闭该会话。',
454
- archiveDisabledHint: '归档管理尚未开启。在「界面调整」中开启“归档管理”后,可在此查看、恢复或彻底删除已归档会话。',
473
+ archiveDisabledHint: '归档管理尚未开启。在「界面调整」中开启“归档管理”后,可在此恢复或永久删除已归档会话。',
455
474
  archiveEnable: '开启归档管理',
456
475
  archiveRestored: '已恢复。',
457
476
  defaultAction: '默认',
@@ -533,11 +552,13 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
533
552
 
534
553
  function resolveValue(value: TweaksValue | undefined): ResolvedTweaks {
535
554
  const fontSize = typeof value?.fontSize === 'number' ? value.fontSize : DEFAULT_FONT_SIZE
536
- // Effective code size: the absolute px input wins; otherwise derive px from
537
- // the legacy percentage at the resolved body size; otherwise stock.
555
+ const codeFontScale = value?.codeFontScale ?? DEFAULT_CODE_FONT_SCALE
556
+ // Explicit code sizing wins; the stock preference keeps readable 13px code.
538
557
  const codeFontSize = typeof value?.codeFontSize === 'number'
539
558
  ? Math.min(MAX_CODE_FONT_SIZE, Math.max(MIN_CODE_FONT_SIZE, value.codeFontSize))
540
- : Math.max(8, Math.round(fontSize * (13 / 16) * ((value?.codeFontScale ?? DEFAULT_CODE_FONT_SCALE) / DEFAULT_CODE_FONT_SCALE)))
559
+ : codeFontScale === DEFAULT_CODE_FONT_SCALE
560
+ ? DEFAULT_CODE_FONT_SIZE
561
+ : Math.max(8, Math.round(fontSize * (13 / 16) * (codeFontScale / DEFAULT_CODE_FONT_SCALE)))
541
562
  return {
542
563
  fontSize,
543
564
  codeFontSize,
@@ -559,50 +580,6 @@ function resolveValue(value: TweaksValue | undefined): ResolvedTweaks {
559
580
  }
560
581
  }
561
582
 
562
- /** Scale one theme px value proportionally to the chosen base size. */
563
- function rel(base: number, fontSize: number): number {
564
- return Math.max(8, Math.round((base / DEFAULT_FONT_SIZE) * fontSize))
565
- }
566
-
567
- /** Rebuild the markdown font tokens for the chosen base size, keeping the theme faces. */
568
- function buildFontCss(fontSize: number, lineHeight: number, codeFontSize: number): string {
569
- const cs = getComputedStyle(document.body)
570
- const fam = (name: string, fallback: string): string => {
571
- const value = cs.getPropertyValue(name).trim()
572
- return value.length > 0 ? value : fallback
573
- }
574
- const base = fam('--dsw-font-markdown-base-font-family', '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')
575
- const code = fam('--dsw-font-markdown-code-font-family', '"SF Mono", Consolas, monospace')
576
- const codeBlock = fam('--dsw-font-markdown-code-block-font-family', '"SF Mono", Consolas, monospace')
577
-
578
- const parts: string[] = []
579
- // `baseLine` is the token's line-height at the 16px baseline; it scales with
580
- // both the chosen font size and the 行高 unit, so at the default (16) it
581
- // reproduces the stock rhythm exactly.
582
- const token = (shorthand: string, size: number, baseLine: number, family: string): void => {
583
- const line = Math.max(12, Math.round((baseLine / DEFAULT_FONT_SIZE) * fontSize * (lineHeight / DEFAULT_LINE_HEIGHT)))
584
- parts.push(`--${shorthand}:${size}px/${line}px ${family}`)
585
- parts.push(`--${shorthand}-font-size:${size}px`)
586
- parts.push(`--${shorthand}-line-height:${line}px`)
587
- }
588
- // Code fonts hang off the absolute code-block size (stock: 13px at a 16px
589
- // body), with inline code slightly larger and the small variant slightly
590
- // smaller, preserving DSH's hierarchy (14/13 and 12/13 of the block).
591
- const codePx = (blockRatio: number): number => Math.max(8, Math.round(codeFontSize * blockRatio))
592
- token('dsw-font-markdown-base', fontSize, 28, base)
593
- token('dsw-font-markdown-base-strong', fontSize, 28, base)
594
- token('dsw-font-markdown-base-italic', fontSize, 28, base)
595
- token('dsw-font-markdown-base-strong-italic', fontSize, 28, base)
596
- token('dsw-font-markdown-h1', rel(24, fontSize), 34, base)
597
- token('dsw-font-markdown-h2', rel(22, fontSize), 32, base)
598
- token('dsw-font-markdown-h3', rel(20, fontSize), 30, base)
599
- token('dsw-font-markdown-h4', fontSize, 28, base)
600
- token('dsw-font-markdown-code', codePx(14 / 13), 22, code)
601
- token('dsw-font-markdown-code-block', codePx(1), 22, codeBlock)
602
- token('dsw-font-markdown-code-block-small', codePx(12 / 13), 18, codeBlock)
603
- return `body{${parts.join(';')}}`
604
- }
605
-
606
583
  /**
607
584
  * Claude Desktop-ish markdown table look: light-gray rounded cell cards with
608
585
  * small gaps, no borders. Cells share the theme's inline-code background and
@@ -610,7 +587,7 @@ function buildFontCss(fontSize: number, lineHeight: number, codeFontSize: number
610
587
  * renderer, so headers and cells always match.
611
588
  */
612
589
  const CLAUDE_TABLE_CSS = `
613
- div[data-slot="conversation.chat.node"] table{
590
+ div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table{
614
591
  border-collapse:separate !important;
615
592
  border-spacing:3px !important;
616
593
  width:100% !important;
@@ -621,7 +598,7 @@ div[data-slot="conversation.chat.node"] table{
621
598
  border:none !important;
622
599
  font-size:var(--dsw-font-markdown-base-font-size) !important;
623
600
  }
624
- div[data-slot="conversation.chat.node"] table thead th{
601
+ div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table thead th{
625
602
  background:var(--dsw-alias-markdown-inline-code) !important;
626
603
  color:inherit !important;
627
604
  font-weight:400 !important;
@@ -630,7 +607,7 @@ div[data-slot="conversation.chat.node"] table thead th{
630
607
  border:none !important;
631
608
  border-radius:6px !important;
632
609
  }
633
- div[data-slot="conversation.chat.node"] table tbody td{
610
+ div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table tbody td{
634
611
  background:var(--dsw-alias-markdown-inline-code) !important;
635
612
  color:inherit !important;
636
613
  font-size:inherit !important;
@@ -639,8 +616,8 @@ div[data-slot="conversation.chat.node"] table tbody td{
639
616
  border:none !important;
640
617
  border-radius:6px !important;
641
618
  }
642
- div[data-slot="conversation.chat.node"] table code,
643
- div[data-slot="conversation.chat.node"] table pre{
619
+ div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table code,
620
+ div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table pre{
644
621
  background:transparent !important;
645
622
  border:none !important;
646
623
  box-shadow:none !important;
@@ -650,52 +627,32 @@ div[data-slot="conversation.chat.node"] table pre{
650
627
  function buildRuntimeCss(value: ResolvedTweaks): string {
651
628
  const rules: string[] = []
652
629
  rules.push(buildFontCss(value.fontSize, value.lineHeight, value.codeFontSize))
653
- // User-sent messages use their own fixed font-size (not the markdown tokens);
654
- // route them through the same base so they follow the fontSize setting too.
630
+ // Sent messages share the reply metrics, including explicit UI Tweaks sizes.
655
631
  // `steering` messages are sent while the agent is busy (busyEnter: steer);
656
632
  // `[data-pending-steering]` is their in-flight bubble before it becomes durable.
657
- rules.push(`[data-chat-flow-kind="user"] [class^="_text_"],[data-chat-flow-kind="steering"] [class^="_text_"],[data-pending-steering] [class^="_text_"]{font-size:var(--dsw-font-markdown-base-font-size) !important}`)
658
- // Composer input follows the same base size. The visible text is rendered by
659
- // the hidden-textarea + backdrop/mirror pattern: the textarea is transparent,
660
- // the `data-input-backdrop` paints the text you see, and `data-input-mirror`
661
- // drives auto-grow. All three (plus the placeholder) must share the size.
662
- // Only font-size is touched: line-height is part of the auto-grow/caret
663
- // metrics, so overriding it misplaces the caret.
664
- rules.push(`[data-composer-card="true"] textarea,[data-composer-card="true"] [data-input-backdrop],[data-composer-card="true"] [data-input-mirror]{font-size:var(--dsw-font-markdown-base-font-size) !important}`)
665
- rules.push(`[data-composer-card="true"] textarea::placeholder{font-size:var(--dsw-font-markdown-base-font-size) !important}`)
666
- // Markdown table cells are pinned by DSH (15px); let every table style follow
667
- // the fontSize setting as well.
668
- rules.push(`div[data-slot="conversation.chat.node"] table th,div[data-slot="conversation.chat.node"] table td{font-size:var(--dsw-font-markdown-base-font-size) !important}`)
669
- // Inline code is pinned by DSH to 0.875em of the surrounding text (it ignores
670
- // the code token); scale that em by how far the chosen code size sits from
671
- // the stock ratio (a 13px block at this body size).
672
- const stockCodeBlock = value.fontSize * (13 / 16)
633
+ rules.push(`[data-chat-flow-kind="user"] [class*="_bubble"],[data-chat-flow-kind="steering"] [class*="_bubble"],[data-pending-steering] [class*="_bubble"]{font-size:var(--dsw-font-markdown-base-font-size) !important;line-height:var(--dsw-font-markdown-base-line-height) !important}`)
634
+ // Current contenteditable composers and older textarea composers inherit
635
+ // one size/leading pair, including placeholders and measurement layers.
636
+ rules.push(`[data-composer-card]{font:var(--dsw-font-markdown-base) !important}`)
637
+ // Tables use the same body size and leading in both table styles.
638
+ rules.push(`div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table th,div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table td{font-size:var(--dsw-font-markdown-base-font-size) !important;line-height:var(--dsw-font-markdown-base-line-height) !important}`)
639
+ // Inline code normally uses 0.92em. Explicit code sizing follows the
640
+ // same ratio relative to the 14px body / 13px code baseline.
641
+ const stockCodeBlock = value.fontSize * (13 / 14)
673
642
  if (Math.abs(value.codeFontSize - stockCodeBlock) > 0.5) {
674
- const em = (0.875 * (value.codeFontSize / stockCodeBlock)).toFixed(3)
675
- rules.push(`div[data-slot="conversation.chat.node"] div[class*="_markdown_"] :not(pre)>code{font-size:${em}em !important}`)
643
+ const em = (0.92 * (value.codeFontSize / stockCodeBlock)).toFixed(3)
644
+ rules.push(`div[data-slot="conversation.chat.node"] div[class*="_markdown"]:not([data-markdown-variant="compact"]) :not(pre)>code{font-size:${em}em !important}`)
676
645
  }
677
- // 行高: the base vertical rhythm of the reply area. When it differs from
678
- // the stock 16px, every vertical spacing scales from it proportionally:
679
- // ① gaps between message rows (Think ↔ tool cards like pwsh, user ↔
680
- // assistant) — the chat flow column;
681
- // ② gaps between content blocks inside one assistant reply (Think ↔ text) —
682
- // the Assistant Markdown block container (`Sxvs8a_body`, CSS-module
683
- // hashed, stable within the pinned rc.8 conversation package);
684
- // ③ the markdown typography rhythm: paragraphs (`p` has a stock `margin:
685
- // 16px 0` that must be overridden on both axes, not just bottom, or it
686
- // can never tighten below 16), list margins, list-item gaps (stock 6px),
687
- // paragraphs inside list items (stock 8px), code blocks, headings and
688
- // rules — all scaled from the 行高 unit.
689
- // Text line-height itself scales in buildFontCss above.
646
+ // Custom spacing scales prose without expanding compact thinking.
690
647
  if (value.lineHeight !== DEFAULT_LINE_HEIGHT) {
691
648
  const n = value.lineHeight
692
- const md = `div[data-slot="conversation.chat.node"] div[class*="_markdown_"]`
693
- const liGap = Math.max(2, Math.round((6 * n) / DEFAULT_LINE_HEIGHT))
649
+ const md = `div[data-slot="conversation.chat.node"] div[class*="_markdown"]:not([data-markdown-variant="compact"])`
650
+ const liGap = Math.max(2, Math.round((4 * n) / DEFAULT_LINE_HEIGHT))
694
651
  const liPGap = Math.max(2, Math.round((8 * n) / DEFAULT_LINE_HEIGHT))
695
- rules.push(`div[data-slot="conversation.view"] .Md3f7G_column{gap:${n}px !important}`)
696
- rules.push(`div[data-slot="conversation.chat.node"] .Sxvs8a_body{gap:${n}px !important}`)
697
- rules.push(`${md} p{margin:${n}px 0 !important}`)
698
- rules.push(`${md} ul,${md} ol{margin:${n}px 0 !important}`)
652
+ rules.push(`div[data-slot="conversation.view"] [data-chat-flow]{gap:${n}px !important}`)
653
+ rules.push(`div[data-slot="conversation.chat.node"] [data-assistant-body]{--dsh-assistant-block-gap:${n}px}`)
654
+ rules.push(`${md} p{margin:${Math.round(0.75 * n)}px 0 !important}`)
655
+ rules.push(`${md} ul,${md} ol{margin:${Math.round(0.75 * n)}px 0 !important}`)
699
656
  rules.push(`${md} pre{margin:${n}px 0 !important}`)
700
657
  // Code blocks: the pre's inner vertical padding is stock 16px (shiki
701
658
  // default); scale it so the block's own height follows 行高 too. Only
@@ -711,13 +668,11 @@ function buildRuntimeCss(value: ResolvedTweaks): string {
711
668
  }
712
669
  rules.push(`${md} li:not(:first-child){margin-top:${liGap}px !important}`)
713
670
  rules.push(`${md} li>p{margin:${liPGap}px 0 !important}`)
714
- rules.push(`${md} h1,${md} h2,${md} h3{margin:${2 * n}px 0 ${n}px !important}`)
671
+ rules.push(`${md} h1,${md} h2,${md} h3{margin:${Math.round(1.5 * n)}px 0 ${Math.round(0.75 * n)}px !important}`)
715
672
  rules.push(`${md} h4,${md} h5,${md} h6{margin:${n}px 0 !important}`)
716
673
  rules.push(`${md} hr{margin:${2 * n}px 0 !important}`)
717
674
  rules.push(`${md} blockquote{margin:${n}px 0 0 !important}`)
718
- // Keep DSH's flush edges: the first/last block of a reply has zero outer
719
- // margin (stock `>*:first-child` / `>*:last-child`), so a message starts
720
- // and ends tight and the spacing to the next node stays the column gap.
675
+ // Preserve the first and last block's flush edges.
721
676
  rules.push(`${md} > :first-child{margin-top:0 !important}`)
722
677
  rules.push(`${md} > :last-child{margin-bottom:0 !important}`)
723
678
  }
@@ -1458,6 +1413,7 @@ export function apply(ctx: UITweaksClientContext): void {
1458
1413
  ctx.effect(installArchiveStyles, 'dsh-ui-tweaks: archive styles')
1459
1414
  ctx.effect(installMcpStyles, 'dsh-ui-tweaks: mcp styles')
1460
1415
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'dsh-ui-tweaks: locale')
1416
+ ctx.effect(() => ctx.locale.register(NS, 'ja', uiTweaksArchiveJa), 'dsh-ui-tweaks: archive Japanese locale')
1461
1417
  const t = ctx.locale.bind(NS)
1462
1418
 
1463
1419
  const controller = new SettingsClient()
@@ -1545,7 +1501,7 @@ export function apply(ctx: UITweaksClientContext): void {
1545
1501
  ctx.effect(() => installHeroChip(controller, t), 'dsh-ui-tweaks: hero branch chip')
1546
1502
 
1547
1503
  // Archive manager: a Settings section ("归档") that lists archived sessions
1548
- // and can restore or permanently delete them. Registered only while the
1504
+ // and uses the shared Host operations to restore or delete them. Registered only while the
1549
1505
  // archiveManagerEnabled toggle in the UI Tweaks section is on, so the nav
1550
1506
  // row appears / disappears live with the switch (the settings shell
1551
1507
  // projects its nav from the section ledger).
@@ -1555,7 +1511,23 @@ export function apply(ctx: UITweaksClientContext): void {
1555
1511
  order: 50,
1556
1512
  label: () => t('archiveNav'),
1557
1513
  locale: NS,
1558
- inject: () => ({ controller, t, sessionsService: ctx.sessions }),
1514
+ inject: () => ({ controller, t,
1515
+ restoreSession: async (id: string) => {
1516
+ const service = ctx.workspaces as typeof ctx.workspaces & { unarchiveSession?: (id: SessionId) => Promise<void> }
1517
+ if (service.unarchiveSession === undefined) throw new Error(t('archiveUnavailable'))
1518
+ await service.unarchiveSession(id as SessionId)
1519
+ },
1520
+ previewDeletion: async (id: string) => {
1521
+ const service = ctx.workspaces as typeof ctx.workspaces & { sessionDeletionScope?: (id: SessionId) => Promise<readonly SessionId[]> }
1522
+ if (service.sessionDeletionScope === undefined) throw new Error(t('archiveUnavailable'))
1523
+ return service.sessionDeletionScope(id as SessionId)
1524
+ },
1525
+ deleteSession: async (id: string, scope: readonly string[]) => {
1526
+ const service = ctx.workspaces as typeof ctx.workspaces & { deleteSession?: (id: SessionId, scope: readonly SessionId[]) => Promise<readonly SessionId[]> }
1527
+ if (service.deleteSession === undefined) throw new Error(t('archiveUnavailable'))
1528
+ await service.deleteSession(id as SessionId, scope as readonly SessionId[])
1529
+ },
1530
+ }),
1559
1531
  }, ArchiveSection))
1560
1532
 
1561
1533
  // MCP manager: a Settings section ("MCP 管理") that lists the configured MCP
@@ -0,0 +1,73 @@
1
+ /** Compact sidebar chrome; the host retains every button, shortcut and drag surface. */
2
+ export const SIDEBAR_HEADER_CSS = `
3
+ .dut-sidebar-header{height:44px !important;padding:0 4px !important;margin-bottom:8px !important;gap:8px !important}
4
+ .dut-sidebar-brand{min-width:0 !important;background:transparent !important;box-shadow:none !important}
5
+ .dut-sidebar-identity{height:24px !important;gap:8px !important}
6
+ .dut-sidebar-wordmark{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
7
+ .dut-sidebar-toggle{width:28px !important;height:28px !important;border-radius:8px !important;color:var(--dsw-alias-label-secondary) !important}
8
+ .dut-sidebar-toggle:hover{background:var(--dsw-alias-interactive-bg-hover) !important}
9
+ /* Reuse the original ChatCode primary-action red, scoped to this marked CTA. */
10
+ .dut-sidebar-new-session{height:40px !important;justify-content:flex-start !important;gap:8px !important;margin:0 0 10px !important;padding:8px 10px !important;border:1px solid #9B0B09 !important;border-radius:10px !important;background:linear-gradient(135deg,#9B0B09,#b71916) !important;color:#fff !important;font:var(--dsw-font-s-strong-14) !important;font-weight:600 !important;box-shadow:none !important;transform:none !important}
11
+ .dut-sidebar-new-session:hover{background:linear-gradient(135deg,#b71916,#cf302c) !important}
12
+ .dut-sidebar-new-session:active{background:#9B0B09 !important}
13
+ .dut-sidebar-new-session:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
14
+ .dut-sidebar-new-session > span:first-child{flex:1;min-width:0;overflow:hidden;mask-image:none !important}
15
+ .dut-sidebar-new-session > span:first-child > span{width:auto !important;justify-content:flex-start !important;gap:8px !important;min-width:0}
16
+ .dut-sidebar-new-session > span:first-child > span > svg{width:16px;height:16px;flex:none;color:inherit}
17
+ .dut-sidebar-new-session > span:first-child > span > span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
18
+ .dut-sidebar-new-session > span + span{opacity:1 !important;flex:none;color:color-mix(in srgb,currentColor 75%,transparent);font:var(--dsw-font-xxs-12)}
19
+ /* Temporary navigation-only hide. Remove this block to restore Plugins;
20
+ registrations, settings, installed plugins and other panel entries stay intact. */
21
+ nav:is([aria-label="全局面板"],[aria-label="Global panels"]) > button:is([aria-label="插件"],[aria-label="Plugins"]),
22
+ nav:is([aria-label="全局面板"],[aria-label="Global panels"]):has(> button:is([aria-label="插件"],[aria-label="Plugins"]):only-child){display:none !important}
23
+ `
24
+
25
+ const HEADER_CLASSES = [
26
+ 'dut-sidebar-header', 'dut-sidebar-brand', 'dut-sidebar-identity',
27
+ 'dut-sidebar-wordmark', 'dut-sidebar-toggle', 'dut-sidebar-new-session',
28
+ ] as const
29
+ type HeaderClass = typeof HEADER_CLASSES[number]
30
+
31
+ /** Mark only the expanded brand row and its adjacent native New Session button. */
32
+ export function syncSidebarHeader(): void {
33
+ const desired = new Map<HTMLElement, Set<HeaderClass>>()
34
+ const mark = (element: Element | null | undefined, className: HeaderClass): void => {
35
+ if (!(element instanceof HTMLElement)) return
36
+ const classes = desired.get(element) ?? new Set<HeaderClass>()
37
+ classes.add(className)
38
+ desired.set(element, classes)
39
+ }
40
+ for (const name of document.querySelectorAll<HTMLElement>('.dut-sidebar-brand-name,.dut-brand-title')) {
41
+ const row = name.closest<HTMLElement>('[data-window-drag]')
42
+ const logo = row?.querySelector('.dut-sidebar-logo,.dut-left-logo')
43
+ if (!row || !logo) continue
44
+ const brand = [...row.children].find(child => child.contains(name) && child.contains(logo))
45
+ if (!brand) continue
46
+ mark(row, 'dut-sidebar-header')
47
+ mark(brand, 'dut-sidebar-brand')
48
+ mark(logo.closest('[class*="brandIdentity"]'), 'dut-sidebar-identity')
49
+ mark(name, 'dut-sidebar-wordmark')
50
+ for (const button of row.querySelectorAll('button')) {
51
+ if (!brand.contains(button) && button !== brand) mark(button, 'dut-sidebar-toggle')
52
+ }
53
+ // The host renders this native action directly after the drag row. Do
54
+ // not infer a new action from arbitrary text in another panel or dialog.
55
+ const next = row.nextElementSibling
56
+ if (next instanceof HTMLButtonElement) mark(next, 'dut-sidebar-new-session')
57
+ }
58
+ // A collapsed rail no longer has a wordmark. Remove expanded-only styling
59
+ // without changing the host's rail geometry or its logo/expand interaction.
60
+ for (const className of HEADER_CLASSES) {
61
+ for (const element of document.querySelectorAll<HTMLElement>(`.${className}`)) {
62
+ if (!desired.get(element)?.has(className)) element.classList.remove(className)
63
+ }
64
+ }
65
+ for (const [element, classes] of desired) element.classList.add(...classes)
66
+ }
67
+
68
+ /** Restore native header styling when the branding effect is disposed. */
69
+ export function clearSidebarHeader(): void {
70
+ for (const className of HEADER_CLASSES) {
71
+ for (const element of document.querySelectorAll(`.${className}`)) element.classList.remove(className)
72
+ }
73
+ }
@@ -0,0 +1,38 @@
1
+ /** Font overrides for the conversation, preserving the live theme families. */
2
+
3
+ /**
4
+ * Apply the UI Tweaks size and spacing preferences to the host's prose tokens.
5
+ * @param fontSize - Selected body size in pixels.
6
+ * @param lineHeight - Vertical-spacing unit; 16 retains the normal rhythm.
7
+ * @param codeFontSize - Selected code-block size in pixels.
8
+ * @returns Theme-token overrides for a runtime stylesheet.
9
+ */
10
+ export function buildFontCss(fontSize: number, lineHeight: number, codeFontSize: number): string {
11
+ const parts: string[] = []
12
+ const base = 'var(--dsw-font-markdown-base-font-family, var(--dsw-font-family))'
13
+ const code = 'var(--dsw-font-markdown-code-block-font-family, var(--ds-font-family-code))'
14
+ const token = (name: string, size: number, leading: number, family: string, weight = 400, style = 'normal'): void => {
15
+ const line = Math.max(12, Math.round(leading * (lineHeight / 16)))
16
+ parts.push(`--${name}:${style} ${weight} ${size}px/${line}px ${family}`)
17
+ parts.push(`--${name}-font-size:${size}px`)
18
+ parts.push(`--${name}-line-height:${line}px`)
19
+ parts.push(`--${name}-font-weight:${weight}`)
20
+ parts.push(`--${name}-font-style:${style}`)
21
+ }
22
+ const bodyLine = fontSize + 10
23
+ token('dsw-font-markdown-base', fontSize, bodyLine, base)
24
+ token('dsw-font-markdown-base-strong', fontSize, bodyLine, base, 600)
25
+ token('dsw-font-markdown-base-italic', fontSize, bodyLine, base, 400, 'italic')
26
+ token('dsw-font-markdown-base-strong-italic', fontSize, bodyLine, base, 600, 'italic')
27
+ token('dsw-font-markdown-h1', fontSize + 4, bodyLine + 4, base, 600)
28
+ token('dsw-font-markdown-h2', fontSize + 2, bodyLine + 2, base, 600)
29
+ token('dsw-font-markdown-h3', fontSize + 1, bodyLine + 1, base, 600)
30
+ token('dsw-font-markdown-h4', fontSize, bodyLine, base, 600)
31
+ token('dsw-font-markdown-table', fontSize, bodyLine, base)
32
+ token('dsw-font-markdown-table-head', fontSize, bodyLine, base, 500)
33
+ token('dsw-font-markdown-code', codeFontSize, codeFontSize + 7,
34
+ 'var(--dsw-font-markdown-code-font-family, var(--ds-font-family-code))')
35
+ token('dsw-font-markdown-code-block', codeFontSize, codeFontSize + 7, code)
36
+ token('dsw-font-markdown-code-block-small', Math.max(8, codeFontSize - 2), codeFontSize + 3, code)
37
+ return `body{${parts.join(';')}}`
38
+ }
package/src/config.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import z from 'schemastery'
9
+ import { Config as UITweaksSchema, type UITweaksConfig } from './ui-tweaks/config.ts'
9
10
  import {
10
11
  SIDEBAR_PREFS_DEFAULTS,
11
12
  SIDEBAR_PREFS_NS,
@@ -37,7 +38,7 @@ export {
37
38
  } from './prefs-shared.ts'
38
39
 
39
40
  /** Tunable sidebar host limits (every field optional; defaults fill in). */
40
- export interface SidebarConfig {
41
+ export interface SidebarConfig extends Partial<SidebarPrefs>, UITweaksConfig {
41
42
  /** Read cap of one text file (bytes); larger files return truncated. */
42
43
  readLimit?: number
43
44
  /** Media route cap (bytes); larger binaries are refused. */
@@ -88,7 +89,7 @@ export interface CodingPlanConfig {
88
89
  }
89
90
 
90
91
  /** Schemastery schema for the plugin configuration. */
91
- export const Config: z<SidebarConfig> = z.object({
92
+ const HostConfig = z.object({
92
93
  readLimit: z.number().step(1).min(1).default(512 * 1024),
93
94
  mediaLimit: z.number().step(1).min(1).default(20 * 1024 * 1024),
94
95
  uploadLimit: z.number().step(1).min(1).default(128 * 1024 * 1024),
@@ -205,3 +206,22 @@ export const PrefsSchema: z<SidebarPrefs> = z.object({
205
206
  // keys as unknown schema fields.
206
207
  pluginSettings: z.dict(z.dict(z.any())).default({}),
207
208
  })
209
+
210
+ function live<T>(schema: z<T>): z<T> {
211
+ Reflect.set(schema.meta, 'volatile', true)
212
+ return schema
213
+ }
214
+
215
+ function liveFields(schema: z): Record<string, z> {
216
+ if (schema.type !== 'object' || schema.dict === undefined) {
217
+ throw new TypeError('Live settings schema must be an object')
218
+ }
219
+ return Object.fromEntries(Object.entries(schema.dict).map(([key, field]) => [key, live(field)]))
220
+ }
221
+
222
+ /** One entry schema: deployment fields stay fixed while sidebar and UI preferences are live-editable. */
223
+ export const Config = z.object({
224
+ ...HostConfig.dict,
225
+ ...liveFields(PrefsSchema),
226
+ ...liveFields(UITweaksSchema),
227
+ }) as z<SidebarConfig>
@@ -446,22 +446,10 @@ export interface SidebarInvariantsService {
446
446
  ): () => void
447
447
  }
448
448
 
449
- /** The settings service face (mirror of @deepseek-ai/dsh-settings' SettingsProvider). */
449
+ /** The settings service face (mirror of @deepseek-ai/dsh-settings' SettingsForms). */
450
450
  export interface SidebarSettingsService {
451
- /**
452
- * Register one namespace schema (the resolved value layers schema defaults,
453
- * then the composition base, then the user document).
454
- */
455
- register<T>(
456
- ns: string,
457
- schema: unknown,
458
- options?: { base?: Partial<T>; applies?: 'live' | 'restart' },
459
- ): {
460
- get(): T
461
- watch(callback: (next: T, prev: T) => void | Promise<void>): () => void
462
- update(patch: object): Promise<void>
463
- replace(section: object): Promise<void>
464
- }
451
+ /** Whether the active profile accepts form edits. */
452
+ readonly writable: boolean
465
453
  /** Redacted descriptors of every registered namespace (secrets stripped). */
466
454
  describe(options?: { redactSecrets?: boolean }): Array<{
467
455
  ns: string
@@ -473,6 +461,8 @@ export interface SidebarSettingsService {
473
461
  }>
474
462
  /** Service-level merge write with the revision guard (a stale writer is refused). */
475
463
  update(ns: string, patch: object, expectedRevision?: number): Promise<void>
464
+ /** Apply path edits without restating fields hidden from the caller. */
465
+ mutate(ns: string, ops: readonly ({ op: 'set'; path: readonly string[]; value: unknown } | { op: 'unset'; path: readonly string[] })[], expectedRevision?: number): Promise<void>
476
466
  }
477
467
 
478
468
  /**