Every side-card switch was dead: settings.update returned OK and cordis.patch.yml was written, yet the running plugin never saw the new value and nothing reported an error. Root cause: the plugin declared Config with the plain npm `schemastery` (3.18.0), which has no volatile support. The host resolves plugin config via `runtime.Config['~standard'].validate()` — i.e. the plugin's OWN schemastery — so `meta.volatile` nodes were never wrapped in cosmokit volatile references. `cordis-plugin-loader`'s `_commitVolatile()` bails out as soon as `volatileEntries(fiber.config)` is empty, so every volatile-only edit was silently dropped: no in-place update, no plugin restart. Fix: import z from '@deepseek-ai/schemastery' (peer provided by the host at mount; pinned 3.18.4 as a devDependency for the dev tree), matching the repo's existing pnpm-workspace convention for @deepseek-ai/* peers. Verified: probe reports tabsIsVolatile=true and revision climbing 0->6 across six writes, each read-back matching the written value (previously the value was frozen and revision stuck at 1). Also in this change: - apes tab ids lose their colon (apes:tasks -> apesTasks, ...): the host's settings projection dropped map keys containing a colon. - sidebar prefs ns follows the profile entry id (`better-sidebar`). - subagent rows degrade to summary rows when the root catalog never hydrates. - docs/feedback-0.2.0-rc2-contract-gaps.md: four host contract gaps, gap 4 documenting the silent volatile-write drop above. Gates: typecheck 0, lint 0, build 0, test 131 files / 1385 passed.
114 lines
6.0 KiB
TypeScript
114 lines
6.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import Loader from '@cordisjs/plugin-loader'
|
|
import * as sidebar from '../src/index.ts'
|
|
|
|
/**
|
|
* Run the real namespace export through `Loader.unwrapExports`; a stray
|
|
* default would discard `name`, `inject`, `Config`, and `apply`. Same guard
|
|
* the official plugin repos ship (dsh-external/turtle-ui,
|
|
* packages/ui/jsonrpc).
|
|
*/
|
|
describe('dsh-apes-sidebar plugin export shape', () => {
|
|
it('has the namespace-plugin export shape (no stray default) so the Loader keeps name/inject/Config/apply', () => {
|
|
expect('default' in sidebar).toBe(false)
|
|
expect(typeof sidebar.apply).toBe('function')
|
|
|
|
const loader = Object.create(Loader.prototype) as Loader
|
|
const unwrapped = loader.unwrapExports(sidebar) as Record<string, unknown>
|
|
expect(unwrapped).toBe(sidebar)
|
|
expect(unwrapped.name).toBe('dsh-apes-sidebar')
|
|
expect(unwrapped.inject).toEqual(['webServer', 'sessions', 'webRuntime', 'tools'])
|
|
expect(unwrapped.Config).toBeDefined()
|
|
expect(typeof unwrapped.apply).toBe('function')
|
|
})
|
|
|
|
it('exports the schemastery Config with the documented tunable fields', () => {
|
|
const schema = sidebar.Config
|
|
expect(schema).toBeDefined()
|
|
// The resolved defaults mirror the pre-config constants.
|
|
const resolved = (schema as unknown as {
|
|
(input: Record<string, unknown> | undefined): Record<string, unknown>
|
|
})(undefined)
|
|
expect(resolved.readLimit).toBe(512 * 1024)
|
|
expect(resolved.mediaLimit).toBe(20 * 1024 * 1024)
|
|
expect(resolved.listLimit).toBe(1000)
|
|
expect(resolved.terminalsPerSession).toBe(3)
|
|
expect(resolved.reconnectGraceMs).toBe(30_000)
|
|
// The terminal shell config defaults to auto-resolution (empty shell =
|
|
// the platform chain in defaultShell()).
|
|
expect(resolved.shell).toBe('')
|
|
// Shell args default to an empty list; non-empty values replace the
|
|
// automatic platform login flag.
|
|
expect(resolved.shellArgs).toEqual([])
|
|
const configured = (schema as unknown as {
|
|
(input: Record<string, unknown> | undefined): Record<string, unknown>
|
|
})({ shell: 'pwsh.exe' })
|
|
expect(configured.shell).toBe('pwsh.exe')
|
|
const configuredWithArgs = (schema as unknown as {
|
|
(input: Record<string, unknown> | undefined): Record<string, unknown>
|
|
})({ shell: '/bin/zsh', shellArgs: ['--noprofile', '--no-rc'] })
|
|
expect(configuredWithArgs.shell).toBe('/bin/zsh')
|
|
expect(configuredWithArgs.shellArgs).toEqual(['--noprofile', '--no-rc'])
|
|
})
|
|
|
|
it('registers the side card preferences schema with the documented defaults', async () => {
|
|
const { PrefsSchema, SIDEBAR_PREFS_NS, SIDEBAR_PREFS_DEFAULTS } = await import('../src/config.ts')
|
|
expect(SIDEBAR_PREFS_NS).toBe('better-sidebar')
|
|
const resolved = (PrefsSchema as unknown as {
|
|
(input: Record<string, unknown> | undefined): Record<string, unknown>
|
|
})(undefined)
|
|
expect(resolved.openByDefault).toBeUndefined()
|
|
expect(resolved.defaultWidthPercent).toBeUndefined()
|
|
expect(resolved.changesDiffFloat).toBeUndefined()
|
|
expect(resolved.autoOpenSubagent).toBe(true)
|
|
// A new background job auto-opens the Jobs page too.
|
|
expect(resolved.autoOpenJobs).toBe(true)
|
|
// The terminal tools default OFF (the feature is dormant until the user
|
|
// enables it in the side card settings).
|
|
expect(resolved.agentTerminalTools).toBe(false)
|
|
// The sidebar-open tool defaults OFF too (same dormant-until-enabled rule).
|
|
expect(resolved.agentOpenTools).toBe(false)
|
|
// The terminal font customizations default to the theme (empty family)
|
|
// and 13px.
|
|
expect(resolved.terminalFontFamily).toBe('')
|
|
expect(resolved.terminalFontSize).toBe(13)
|
|
// The position-compat scheme is declared WITHOUT a schema default so a
|
|
// stored document that predates it resolves without the field — the
|
|
// CLIENT parsePrefs then applies the conservative `auto` default (or
|
|
// migrates the legacy boolean), which is exactly what makes old
|
|
// documents migrate instead of silently flipping to a scheme. The
|
|
// legacy strip keeps its schema default of 40px.
|
|
expect(resolved.titleBarScheme).toBeUndefined()
|
|
expect(resolved.titleBarPresetId).toBeUndefined()
|
|
expect(resolved.customCss).toBeUndefined()
|
|
expect(resolved.titleBarCompat).toBe(false)
|
|
expect(resolved.titleBarStripPx).toBe(40)
|
|
// The enable-switch maps resolve to {} (everything on) for old documents.
|
|
expect(resolved.tabsEnabled).toEqual({})
|
|
expect(resolved.viewersEnabled).toEqual({})
|
|
// The separate file-window mode is the default (each file opens its own
|
|
// tab; the merged editor-explorer is opt-in).
|
|
expect(resolved.editorExplorer).toBe(false)
|
|
// The workspace fence (containment over the sidebar fs routes) defaults
|
|
// ON — the safe default never depends on the stored document.
|
|
expect(resolved.workspaceFence).toBe(true)
|
|
// A stored overridden value resolves through (the range contract is
|
|
// enforced by the settings service on write); the new pref keeps its
|
|
// default when the stored document predates it.
|
|
const overridden = (PrefsSchema as unknown as {
|
|
(input: Record<string, unknown> | undefined): Record<string, unknown>
|
|
})({ openByDefault: false, defaultWidthPercent: 45, changesDiffFloat: true })
|
|
// Schemastery's object schema is OPEN: a document written by an older
|
|
// plugin version still carrying the retired keys resolves them through
|
|
// verbatim. They are inert — the typed value the client consumes
|
|
// (parsePrefs) drops them (tests/prefs.spec.ts) — and the defaults no
|
|
// longer declare them.
|
|
// titleBarScheme / titleBarPresetId / customCss are declared WITHOUT a
|
|
// schema default (the client's parsePrefs supplies them), so they are
|
|
// absent from a resolved document that never stored them.
|
|
const { titleBarScheme, titleBarPresetId, customCss, ...schemaDefaults } = SIDEBAR_PREFS_DEFAULTS
|
|
void titleBarScheme; void titleBarPresetId; void customCss
|
|
expect(overridden).toEqual({ ...schemaDefaults, openByDefault: false, defaultWidthPercent: 45, changesDiffFloat: true })
|
|
})
|
|
})
|