- P2-1 onOpen 收到真正落地的 tab:url 新建场景从 landed 态按 id 反查
(补丁后对象),回调不再拿到未打 url 的 tab
- P2-2 插件设置行显式取值源:FeatureSettingsRows 新增 valueSource prop,
插件行读自己的 pluginSettings blob——插件键与宿主 pref 同名时不再
静默读宿主值(原投影合并有读宿主写插件的读写不对称);prop 命名避开
Object.prototype.valueOf 冲突
- P2-3 consumer 类型检查接入工程:package.json 新增 check:consumer-types
脚本 + CI 在 build 后执行;脚本补 lib/types 存在性前置检查(防假绿)
- P3-1 url seed 只在新建时应用:dedupe 聚焦的 tab 不再被覆写 path
- P3-2 closeTab/activateTab 未知 id 严格 no-op:store.reduce 对同引用
结果短路(不 notify、不重写 localStorage),根因修复 + 回归测试
- P3-3 closeTab/activateTab 增加可选 scope(cwd 随回调传递),Sidebar
双树激活/关闭路径传入 { sessionId, cwd }
- P3-4 定向打开不再自动展开不可见 session 的面板
- P3-5 Sidebar 终端 pty 释放查找覆盖双树(底部面板终端不再漏掉 HTTP
兜底)
- P3-6/P3-7 与 Nits:AGENTS.md/指南文档化(dedupeKey 纯函数、meta 用
null 清除、回调 scope 的 cwd 语义);consumer fixture 补常量导出覆盖
测试 +6(url 落地保真 / url 不覆写聚焦 / 未知 id 无 notify / 定向打开
不展开 / scope 随回调 / valueSource 键隔离),464 全绿;typecheck、
build、consumer 校验全部通过。
102 lines
4.6 KiB
Bash
Executable File
102 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Consumer-facing type surface check: build a tiny standalone consumer that
|
|
# imports `dsh-better-sidebar/client/service` WITHOUT @types/node and with
|
|
# skipLibCheck: false, then type-check it with the repo's tsc.
|
|
#
|
|
# This is the exact scenario the v0.12.0 API work cares about: the shipped
|
|
# declaration graph (service.d.ts -> context-types.d.ts -> state/api) must
|
|
# resolve and type-check for a browser-only plugin author. Run AFTER
|
|
# `pnpm build` (the check reads lib/types).
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# The check reads the BUILT declaration surface (lib/types) — fail loudly
|
|
# instead of silently passing when the build output is missing.
|
|
if [ ! -f lib/types/client/service.d.ts ]; then
|
|
echo "[check-consumer-types] FAIL: lib/types/client/service.d.ts not found — run 'pnpm build' first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
mkdir -p "$WORK/node_modules"
|
|
ln -s "$(pwd)" "$WORK/node_modules/dsh-better-sidebar"
|
|
|
|
cat > "$WORK/check.ts" <<'EOF'
|
|
import { SIDEBAR_FEATURES, SIDEBAR_SERVICE_VERSION } from 'dsh-better-sidebar/client/service'
|
|
import type {} from 'dsh-better-sidebar/client/service'
|
|
import type {
|
|
BetterSidebarService, FileViewerDescriptor, OpenTabSeed, SidebarSettingsRenderProps,
|
|
TabComponentProps, TabDescriptor,
|
|
} from 'dsh-better-sidebar/client/service'
|
|
import type { SessionScope, SidebarSnapshot, SidebarState, SidebarStore, SidebarTab } from 'dsh-better-sidebar/client/service'
|
|
import type { SidebarPrefs } from 'dsh-better-sidebar/client/service'
|
|
|
|
declare const ctx: { betterSidebar: BetterSidebarService }
|
|
const tab: TabDescriptor = {
|
|
id: 'x:tab',
|
|
title: 'X',
|
|
single: true,
|
|
badge: (_ctx, _scope, state: SidebarState) => state.expanded.length,
|
|
onOpen: (_tab: SidebarTab, _scope: SessionScope) => {},
|
|
onClose: (_tab: SidebarTab, _scope: SessionScope) => {},
|
|
createTab: (state: SidebarState) => ({ tab: { id: 'x:1', type: 'x:tab', title: 'X', meta: {} } }),
|
|
settings: {
|
|
toggles: [{ key: 'autoOpenSubagent', title: 'A' }],
|
|
pluginToggles: [{ key: 'k', title: 'K', type: 'number', min: 0, max: 9 }],
|
|
render: (props: SidebarSettingsRenderProps) => { props.updatePluginSetting('a', 1); return null },
|
|
},
|
|
component: (props: TabComponentProps) => null,
|
|
}
|
|
ctx.betterSidebar.registerTab(tab)
|
|
const viewer: FileViewerDescriptor = {
|
|
id: 'x:csv', exts: ['csv'], fetchStrategy: 'custom',
|
|
load: (_path, _scope, signal?: AbortSignal) => { void signal; return Promise.resolve([]) },
|
|
component: () => null,
|
|
}
|
|
ctx.betterSidebar.registerFileViewer(viewer)
|
|
const seed: OpenTabSeed = { type: 'x:tab', title: 'X', meta: { a: 1 } }
|
|
ctx.betterSidebar.openTab(seed, { sessionId: 's1' })
|
|
ctx.betterSidebar.openFile({ sessionId: 's1' }, '/p/a.csv')
|
|
ctx.betterSidebar.updateTab('t', { meta: { b: 2 } })
|
|
const snap: SidebarSnapshot = ctx.betterSidebar.getSnapshot()
|
|
const prefs: SidebarPrefs = snap.prefs
|
|
const store: SidebarStore = null as unknown as SidebarStore
|
|
void prefs; void store; void ctx.betterSidebar.version; void ctx.betterSidebar.features
|
|
void SIDEBAR_SERVICE_VERSION; void SIDEBAR_FEATURES
|
|
EOF
|
|
|
|
cat > "$WORK/tsconfig.json" <<'EOF'
|
|
{
|
|
"compilerOptions": {
|
|
"target": "ES2023", "module": "esnext", "moduleResolution": "bundler",
|
|
"strict": true, "noEmit": true, "skipLibCheck": false, "types": [],
|
|
"jsx": "react-jsx", "lib": ["ES2023", "DOM"]
|
|
},
|
|
"include": ["check.ts"]
|
|
}
|
|
EOF
|
|
|
|
echo "[check-consumer-types] type-checking a browser-only consumer (no @types/node)..."
|
|
echo "[check-consumer-types] pass 1: skipLibCheck: true (the realistic consumer experience) — must be fully clean"
|
|
./node_modules/.bin/tsc -p "$WORK/tsconfig.json" --skipLibCheck true
|
|
echo "[check-consumer-types] pass 2: skipLibCheck: false — OUR declaration surface (lib/types/**) must be clean"
|
|
echo "[check-consumer-types] (upstream cordis/cosmokit declaration noise is filtered out; it predates this plugin)"
|
|
set +e
|
|
./node_modules/.bin/tsc -p "$WORK/tsconfig.json" --skipLibCheck false > "$WORK/strict.log" 2>&1
|
|
STATUS=$?
|
|
set -e
|
|
# Fail only on errors that mention OUR package / declarations / the fixture.
|
|
if grep -E "dsh-better-sidebar|lib/types|check\.ts" "$WORK/strict.log" | grep -v "node_modules/cordis\|node_modules/cosmokit"; then
|
|
echo "[check-consumer-types] FAIL: errors in the dsh-better-sidebar declaration surface:" >&2
|
|
grep -E "dsh-better-sidebar|lib/types|check\.ts" "$WORK/strict.log" >&2
|
|
exit 1
|
|
fi
|
|
if [ "$STATUS" -ne 0 ]; then
|
|
echo "[check-consumer-types] pass 2 note: strict mode only reports upstream declaration noise:"
|
|
grep -v "dsh-better-sidebar\|lib/types\|check\.ts" "$WORK/strict.log" | head -5
|
|
fi
|
|
echo "[check-consumer-types] OK: the client/service declaration surface is node-free and self-contained."
|
|
|