* feat(sidebar): 桌面兼容三方案——自动检测(WCO 标准几何)/壳预设/自定义 CSS 核心只保留 Web 标准机制,壳专属适配全部下沉到用户空间(KISS): - prefs 新增 titleBarScheme(默认 auto)/titleBarPresetId/customCss,旧 titleBarCompat 布尔自动迁移(true→custom 保留 stripPx,false/缺失→auto) - wco.ts:navigator.windowControlsOverlay 反应式几何(geometrychange 实时更新; visible=false 的幽灵 API 视为缺失),实现 #257 - titlebar-strip.ts 唯一 strip 取值链:WCO → dsh-desktop-titlebar-inset 契约参数 → 预设 stripFor → 手动 px → 0;desktop-env.ts 移除 win32 32px 硬编码 - shell-presets.ts 数据驱动预设(准入:issue/PR 提及 + 100+ star;v1 仅 anywhere-labs DSH Desktop:darwin 20px / win32 无 WCO 时 32px),opt-in 手动 - 预设/自定义 CSS 注入(data-dsh-preset-css / data-dsh-custom-css 标签), chrome 补稳定寻址面 data-dsh-toggle-cluster / data-dsh-panel - 交互 chrome 统一 -webkit-app-region: no-drag(吸收 #111/#153) - layout.css 底栏推挤复合锚点([data-pane] 与 :has(> [data-slot]) 双保险, rc.8 实测前者失效、后者命中,吸收 #226 思路) - 设置 UI:位置兼容模式齿轮弹窗改三方案(自动检测/壳兼容方案/自定义方案) - 测试:wco/titlebar-strip/shell-presets 单测 + prefs 迁移 + e2e 5 场景 (保守 auto/WCO 反应式/预设/自定义 CSS/复合锚点),挂载门禁 12/12 全绿 核心 grep 无壳专属类名;为某壳做的兼容在另一壳会再坏——预设与自定义 CSS 是唯一出路(AGENTS.md §8 契约已更新)。 * refine(sidebar): 位置兼容模式改主行下拉四选项——自动检测/DSH官方Web/壳预设/自定义 按用户反馈定稿 UI: - 主行下拉:自动检测(默认)/ DSH官方Web(显式零适配,连 WCO 也强制 0)/ 各壳预设(命中环境带「已检测」后缀,仅提示)/ 自定义方案(保留齿轮弹窗: 下移距离 + 自定义 CSS) - 旧文档迁移:titleBarCompat=true 或 titleBarStripPx 非默认值(此前已有配置) → 默认落到 custom 方案保留用户数值;干净文档 → auto - prefs 新增 'web' 方案;strip 取值链最优先处理 web→0 - 测试:prefs 迁移(stripPx 48→custom / 40→auto)、web 强制 0、下拉渲染断言 - 单测 693 通过,挂载 e2e 12/12 全绿 * refine(sidebar): 方案下拉复用 SelectMenu 组件,不用原生 <select> - 抽出可复用 SelectMenu(primitives Menu:锚点按钮 + 下拉选项卡,支持 icon/desc/多选),SelectRow 改为其薄壳 - 位置兼容模式方案下拉改用 SelectMenu;选项带描述(自动检测/DSH官方Web/ 各壳预设(命中带「已检测」后缀)/自定义方案) - 移除原生 select 样式;单测 693 通过,挂载 e2e 12/12 全绿
154 lines
6.2 KiB
TypeScript
154 lines
6.2 KiB
TypeScript
/**
|
|
* Serializable configuration and defaults for the sidebar host half. Loader
|
|
* schema validation normally fills defaults; {@link resolveSidebarConfig}
|
|
* applies the same defaults for direct callers that bypass the Loader.
|
|
* @module dsh-better-sidebar/config
|
|
*/
|
|
|
|
import z from 'schemastery'
|
|
import {
|
|
SIDEBAR_PREFS_DEFAULTS,
|
|
SIDEBAR_PREFS_NS,
|
|
TERMINAL_FONT_SIZE_DEFAULT,
|
|
TERMINAL_FONT_SIZE_MAX,
|
|
TERMINAL_FONT_SIZE_MIN,
|
|
TITLE_BAR_STRIP_DEFAULT,
|
|
TITLE_BAR_STRIP_MAX,
|
|
TITLE_BAR_STRIP_MIN,
|
|
WIDTH_PERCENT_DEFAULT,
|
|
WIDTH_PERCENT_MAX,
|
|
WIDTH_PERCENT_MIN,
|
|
type SidebarPrefs,
|
|
} from './prefs-shared.ts'
|
|
|
|
export {
|
|
SIDEBAR_PREFS_DEFAULTS,
|
|
SIDEBAR_PREFS_NS,
|
|
TERMINAL_FONT_SIZE_DEFAULT,
|
|
TERMINAL_FONT_SIZE_MAX,
|
|
TERMINAL_FONT_SIZE_MIN,
|
|
TITLE_BAR_STRIP_DEFAULT,
|
|
TITLE_BAR_STRIP_MAX,
|
|
TITLE_BAR_STRIP_MIN,
|
|
WIDTH_PERCENT_DEFAULT,
|
|
WIDTH_PERCENT_MAX,
|
|
WIDTH_PERCENT_MIN,
|
|
type SidebarPrefs,
|
|
} from './prefs-shared.ts'
|
|
|
|
/** Tunable sidebar host limits (every field optional; defaults fill in). */
|
|
export interface SidebarConfig {
|
|
/** Read cap of one text file (bytes); larger files return truncated. */
|
|
readLimit?: number
|
|
/** Media route cap (bytes); larger binaries are refused. */
|
|
mediaLimit?: number
|
|
/** Upload route cap (bytes); larger files are refused without touching disk. */
|
|
uploadLimit?: number
|
|
/** Explorer row bound of one level. */
|
|
listLimit?: number
|
|
/** Terminals per session. */
|
|
terminalsPerSession?: number
|
|
/** How long a disconnected terminal process survives awaiting a reconnect. */
|
|
reconnectGraceMs?: number
|
|
/**
|
|
* Terminal shell (absolute path or bare executable name) for BOTH the UI
|
|
* terminal tabs and the model-facing `terminal_*` tools. Empty = auto:
|
|
* POSIX follows `$SHELL` then the account login shell; Windows follows
|
|
* `DSH_SIDEBAR_SHELL`, then probes for `pwsh.exe`, then falls back to the
|
|
* inbox `powershell.exe` (5.1). Set it from `cordis.patch.yml` / profile
|
|
* plugin config, e.g. `config: { shell: /bin/zsh }`.
|
|
*/
|
|
shell?: string
|
|
/**
|
|
* Optional arguments passed to the shell executable. When non-empty these
|
|
* REPLACE the automatic platform defaults (POSIX `-l` / Windows none), so
|
|
* the deployment has full control over how the shell starts. When omitted
|
|
* the existing default behavior is kept.
|
|
*/
|
|
shellArgs?: string[]
|
|
}
|
|
|
|
/** Schemastery schema for the plugin configuration. */
|
|
export const Config: z<SidebarConfig> = z.object({
|
|
readLimit: z.number().step(1).min(1).default(512 * 1024),
|
|
mediaLimit: z.number().step(1).min(1).default(20 * 1024 * 1024),
|
|
uploadLimit: z.number().step(1).min(1).default(128 * 1024 * 1024),
|
|
listLimit: z.number().step(1).min(1).default(1000),
|
|
terminalsPerSession: z.number().step(1).min(1).default(3),
|
|
reconnectGraceMs: z.number().step(1).min(0).default(30_000),
|
|
shell: z.string().default(''),
|
|
shellArgs: z.array(z.string()).default([]),
|
|
})
|
|
|
|
/** Fully defaulted sidebar host settings. */
|
|
export interface ResolvedSidebarConfig {
|
|
readLimit: number
|
|
mediaLimit: number
|
|
uploadLimit: number
|
|
listLimit: number
|
|
terminalsPerSession: number
|
|
reconnectGraceMs: number
|
|
/** The configured terminal shell; empty means the host auto-resolves it. */
|
|
shell: string
|
|
/** Explicit shell arguments; empty means use the platform defaults. */
|
|
shellArgs: string[]
|
|
}
|
|
|
|
/**
|
|
* Apply direct-call defaults after Loader schema validation has normally run.
|
|
*
|
|
* @param config - Deployment-provided sidebar host settings.
|
|
* @returns Complete settings consumed by the host half.
|
|
*/
|
|
export function resolveSidebarConfig(config: SidebarConfig | undefined): ResolvedSidebarConfig {
|
|
return {
|
|
readLimit: config?.readLimit ?? 512 * 1024,
|
|
mediaLimit: config?.mediaLimit ?? 20 * 1024 * 1024,
|
|
uploadLimit: config?.uploadLimit ?? 128 * 1024 * 1024,
|
|
listLimit: config?.listLimit ?? 1000,
|
|
terminalsPerSession: config?.terminalsPerSession ?? 3,
|
|
reconnectGraceMs: config?.reconnectGraceMs ?? 30_000,
|
|
shell: config?.shell?.trim() ?? '',
|
|
shellArgs: config?.shellArgs ?? [],
|
|
}
|
|
}
|
|
|
|
// ── User-facing "Side card" preferences ─────────────────────────────────────
|
|
|
|
/** Schemastery schema for the user-facing preferences (validated by the settings service). */
|
|
export const PrefsSchema: z<SidebarPrefs> = z.object({
|
|
openByDefault: z.boolean().default(false),
|
|
defaultWidthPercent: z.number().step(1).min(WIDTH_PERCENT_MIN).max(WIDTH_PERCENT_MAX).default(WIDTH_PERCENT_DEFAULT),
|
|
autoOpenSubagent: z.boolean().default(true),
|
|
autoOpenJobs: z.boolean().default(true),
|
|
agentTerminalTools: z.boolean().default(false),
|
|
bottomPanelAutoTerminal: z.boolean().default(true),
|
|
terminalFontFamily: z.string().default(''),
|
|
terminalFontSize: z.number().step(1).min(TERMINAL_FONT_SIZE_MIN).max(TERMINAL_FONT_SIZE_MAX).default(TERMINAL_FONT_SIZE_DEFAULT),
|
|
interceptOpenPath: z.boolean().default(true),
|
|
editorExplorer: z.boolean().default(false),
|
|
terminalShell: z.string().default(''),
|
|
terminalShellArgs: z.string().default(''),
|
|
titleBarScheme: z.union([z.const('auto'), z.const('web'), z.const('preset'), z.const('custom')]),
|
|
titleBarPresetId: z.string(),
|
|
customCss: z.string(),
|
|
titleBarCompat: z.boolean().default(false),
|
|
titleBarStripPx: z.number().step(1).min(TITLE_BAR_STRIP_MIN).max(TITLE_BAR_STRIP_MAX).default(TITLE_BAR_STRIP_DEFAULT),
|
|
htmlViewerNoSandbox: z.boolean().default(false),
|
|
htmlViewerDefaultUnsafe: z.boolean().default(false),
|
|
browserNoSandbox: z.boolean().default(false),
|
|
browserInterceptLinks: z.boolean().default(true),
|
|
browserInterceptHttp: z.boolean().default(true),
|
|
browserInterceptHttps: z.boolean().default(false),
|
|
// Per-feature enable switches are OPEN maps (any tab/viewer id, built-in or
|
|
// external): an absent key means enabled, so old documents resolve to {}
|
|
// (everything on) with no migration. Non-boolean values fail validation.
|
|
tabsEnabled: z.dict(z.boolean()).default({}),
|
|
viewersEnabled: z.dict(z.boolean()).default({}),
|
|
// Plugin-owned settings blobs (v0.12.0+) are an OPEN nested map: any
|
|
// descriptor id may carry any JSON-serializable values. This is the
|
|
// "settings seam" opening — without it the seam would drop third-party
|
|
// keys as unknown schema fields.
|
|
pluginSettings: z.dict(z.dict(z.any())).default({}),
|
|
})
|