CI 修复(plugin-mount 的 ctx.sessions.get TypeError ×1003):
- 客户端 runtime 无事件日志面——badge/SessionLens 原在客户端直读
ctx.sessions.get(id).events / ctx.on('session/event'),全部不可达。
- 新增宿主路由 changes.ops:live 会话日志优先,冷会话回放
sessionPersistence.inspect;afterSeq 增量(缺省游标含 seq 0,
显式游标为 seq > afterSeq,同 sidechat.events 约定),窗口上限
4000 与客户端累加器一致。
- ChangesTab 轮询(mount 一拉 + visible 2.5s 增量)折入 ops,写
模块级 opCounts 缓存供 badge 同步读取;SessionLens 改纯展示。
diff 展开二级设置(changesDiffFloat,默认浮窗):
- prefs 四处接线 + git tab settings select(浮窗/面板,图标选项卡)
- 预览面板「展开为 diff tab」按设置落点:浮窗居中弹出或源 pane
下方 split;i18n 全 21 词典同步。
视觉迭代(真机挂载截图审查后调整):
- Session 视角:kind 徽章为左轨,大小+相对时间右对齐元列;失败
操作行红色内嵌条;文件组头降为三级标签并加组间距。
- Git 视角:untracked '?' 徽章与新增同绿色;stage 按钮改 plus 图标。
- diff 折叠行:可展开折叠带 › 箭头 + 次级对比度,静态 gap 不再
显示 pointer/hover;预览头路径改尾部截断(RTL 技巧,保文件名)。
验证:typecheck ✓ / vitest 1123 ✓ / pnpm test:mount(钉 alpha.2 CLI)
14/14 ✓;真机挂载截图(badge=5、双视角、浮窗展开)0 console error。
158 lines
6.4 KiB
TypeScript
158 lines
6.4 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),
|
|
agentOpenTools: 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),
|
|
changesDiffFloat: z.boolean().default(true),
|
|
workspaceFence: z.boolean().default(true),
|
|
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),
|
|
browserAllowedLoopback: z.string().default(''),
|
|
// 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({}),
|
|
})
|