diff --git a/CHANGELOG.md b/CHANGELOG.md index a99e0824..e17e4dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ > 本文档收录 dsh-better-sidebar 的完整发布历史(最新版摘要见 [README](README_ZH.md);同步发布于 [GitHub Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases))。 +### Unreleased + +- **dsh-context 可选联动**:Context 侧栏入口可用时,在 Agent 详情、后台任务输出窗和会话标题栏提供诊断入口;后台任务仅查看明确的真实属主,不改变任务输出观察或停止命令的会话语义。跨会话先定位目标再打开 Context,复用其他分栏已有的标签;用户继续导航时取消,等待最多 10 秒。未安装、禁用或仅显示会话标签页时隐藏入口,不修改上下文、不恢复 Agent 执行,也不修改 dsh-context 偏好。全部入口共用 Cordis 作用域内的可选适配器,空闲时不新增轮询。 + ### v0.27.0 - 🌿 **Git 页面重做:VS Code Source Control 结构 + 只读提交图(同一页签)**([#941](https://github.com/omdsh-dev/DSH-better-sidebar/issues/941),贡献者 PR [#944](https://github.com/omdsh-dev/DSH-better-sidebar/pull/944) @hairyf + [#969](https://github.com/omdsh-dev/DSH-better-sidebar/pull/969) @vlln):「文件变动 > Git」的内容区改为 Source Control 结构——可折叠的 Changes(多行 Message + 仅填草稿的 Generate、Merge / Staged / Changes 三组各自独立折叠与计数、整行 hover)与 Graph 区、常驻底栏(可点击分支 + `*`/`+`/`!` 标记、upstream 的 `↓`/`↑` 与安全 Pull-then-Push);Push/Pull 与 worktree·子仓库选择移入 More Actions;提交只消费已暂存项,冲突 / 空消息 / 无暂存时禁止,草稿按会话·仓库·worktree 隔离。Graph 区由 **#969 的有界只读引擎**渲染(专用 `git.graph` 路由:子先于父的拓扑序、分支筛选、游标失效显式返回 `graph-stale`、每页 200 / 偏移 10000 / 分支 1000 / 进程 10 s / 输出 8 MiB 上限,超限报错不静默截断;泳道连线与引用徽章用主题状态色,hover 卡片与提交详情卡;**纯读取**——不 checkout / fetch / 改任何 ref)。底部预览面板改为固定三签 `提交详情 / 内容 / 差异`(有内容才有差异,读操作落在内容签)。**设计取舍与实施偏差见 [docs/plans/2026-10-16-git-page-vscode-scm-merge.md](docs/plans/2026-10-16-git-page-vscode-scm-merge.md)**(贡献者 PR [#939](https://github.com/omdsh-dev/DSH-better-sidebar/pull/939) @hairyf 的官方下划线 Tabs 镜片切换保留;第三个「提交图」镜头刻意未上线)。 diff --git a/README.md b/README.md index 086dc0b8..be305aeb 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ Switch to **Git Graph** at the top of the Git panel for commit nodes, forks and merge edges across local branches, remote-tracking branches and HEAD. The branch selector only filters history — it **never checks out or fetches**; each commit is one line (lane edges + ref pills + subject), hover shows the author and short hash, and selecting one opens its full message and diff in the bottom pane. History loads in pages; reference changes during pagination prompt a refresh; reads are bounded (200 commits per page, offset 10,000, 1,000 branches) and report an explicit error past a limit. This first version shows no tags and offers no history-changing actions. +### 🧭 dsh-context diagnostics (optional) + +With the `dsh-context` plugin installed, three places offer a one-click jump into that conversation's **Context** view: an agent node's detail card on the Tasks page, a background job's output window (the job's real owner session — never merely the session its row was watched under), and the session header. The entries **appear only** while dsh-context's `Context` page is actually registered: a deployment without it (or with that page hidden) shows no control at all, and while one jump is in flight every entry point is disabled. A failed jump is reported once, in a dismissible alert at the frame's bottom edge; nothing is polled while idle. + ## 🚀 Installation ```sh diff --git a/README_ZH.md b/README_ZH.md index 98224840..a40fe5b2 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -32,6 +32,10 @@ 在 Git 面板顶部切到 **Git Graph**:本地分支、远程跟踪分支与 HEAD 的提交节点、分叉与合并连线。分支下拉框只筛选历史,**不会 checkout 或 fetch**;提交行是单行(泳道连线 + 引用徽章 + 标题),hover 看作者与短 hash,选中后在底部面板看完整提交信息与 diff。历史按页加载,分页期间 refs 变化会提示刷新;读取有上限(每页 200 条、偏移 10,000、分支 1,000),超限明确报错。首版不显示 tag,也不提供任何改写历史的操作。 +### 🧭 dsh-context 诊断入口(可选) + +装上 `dsh-context` 插件后,三处各有一个直达该会话 **Context(上下文)** 视图的入口:任务管理页的代理节点详情卡、后台任务输出窗(按任务的**真实属主会话**寻址,而不是它被挂在哪个会话名下)、以及会话标题栏。入口**只在** dsh-context 的 `Context` 页面确实注册时才出现——没装、没启用或该页面被隐藏的部署不会显示任何控件;一次跳转进行中时,三个入口一并禁用。跳转失败只报一条可关闭的提示(浮在窗口底部),空闲时不新增任何轮询。 + ## 🚀 安装 ```sh diff --git a/docs/external-plugin-guide.md b/docs/external-plugin-guide.md index bf1fda6e..cf19c841 100644 --- a/docs/external-plugin-guide.md +++ b/docs/external-plugin-guide.md @@ -40,6 +40,7 @@ | 新建标签页列表 | 每个 tab 类型在原生 guide 里占一行:标题取 `title` + 图标取 `icon`(缺图标时宿主补一个方块占位),说明取可选的 `description`——**宿主只在 guide 列出的条目 ≤ 4 条时渲染说明**(上游 `MAX_DESCRIBED_ENTRIES = 4`),更长的列表整列丢掉所有说明;未声明 `description` 的条目渲染成单行「图标 + 标题」(rc.1 起 `description` 回到宿主契约,但**宿主与插件都没有兜底句**,所以插件恢复字段而不恢复旧的通用句);`hidden: true` 的类型不占行,**`bottomOnly: true` 的类型同样不占行**(#774:它只活在插件自己的底部 `+` 菜单里)。插件的 `editor` 类型不再单独占行(它认领的文件资源由 `files` 接管页承载同一视图)。**本插件默认贡献 4 个 guide 条目**(文件 / Git / 任务管理 / 侧边对话,恰好在上限内),**但宿主的终端条目也占一行**——装了宿主终端即是 5 条,说明整列不渲染;要让说明回来,需在插件设置页关掉足够多的 tab 类型把总数压到 ≤ 4 条 | | 新建面板的种子(alpha.2) | 在新会话打开原生新面板时,宿主从已注册的 guide 条目里播种:恰好 1 个条目 → 直接打开那一页;0 或 ≥2 个条目 → 打开指南。`revealIfOpened` 打开的「页面」在**同一 pane 内**强制去重(已在该 pane 就不再新建);由已有 tab 地址驱动的打开不受该去重影响 | | alpha.2 全局面板(不接入) | 插件**不采用** alpha.2 引入的全局主面板模型——根级 keyed `main` 槽(预留 key `conversation`,由 ui-conversation 注册为 `main.conversation`)、根级 `sidebar.panellist` 列表槽(`SidebarPanelMetadata` / `SidebarPanelIconOwnerProps`)、`ctx.layout.selectPanel(MainPanelId|null)` / `beginNavigation()` / `dispose()`、全局标准 prop `usePanelInfo`,以及改根级并新增会话级 `rightbar.session` 子槽的 `rightbar`——这些只作兼容保留,不向其迁移 | +| dsh-context 可选联动(开发线) | 通过 Cordis 子作用域等待宿主服务,并订阅原生类型及内容槽注册;仅当 Context 侧栏可用时显示 Agent 详情、后台任务真实属主与当前会话标题栏的诊断入口。跨会话先导航到目标再打开 Context,复用该会话其他分栏已有标签;发起导航即关闭来源详情/输出浮层,插件级请求不随浮层卸载取消;导航最多等待 10 秒,用户继续导航或依赖消失即结束。后台任务没有真实 `job.owner` 或可靠子代理地址时不提供诊断,不回退到观察会话。只借用 `ctx.layout.beginNavigation()` 的取消语义,不贡献全局主面板;不扩展 `ctx.betterSidebar` 公共 API,也不要求消费插件改代码或安装 dsh-context。 | | 已移除 | 插件自绘右侧面板(含宽度拖拽 / 新会话默认宽度)与**自由窗口**(`features` 里的 `'floatWindows'` 已删除,v0.18.x 及更早版本的消费者请勿再 gate 该能力);`openByDefault` / `defaultWidthPercent` / `changesDiffFloat` 三个设置项同步删除(旧文档里的键会被忽略);**插件自带的终端与浏览器 tab 类型**(宿主 0.1.6/0.1.7 自带两者)与**只读文件预览**(image / pdf / Office / 表格,宿主 0.1.7 的 `ui-sidebar-documentpreview` 接手)同样不再内置,详见 §4.4 与 §5.4 | --- @@ -1151,6 +1152,8 @@ interface SettingsDescriptor { - **z-index**:面板宿主层 25、按钮簇 45——低于 DSH ui-cordis 插件面板(30)与浮层栈(100/1000+),浮层天然盖住侧边栏。 - **更改行选中态**:Git 文件行和本轮操作行保持原有布局;选中只绘制 `--dsw-alias-interactive-bg-active` 背景,以及行内 inset 4px、宽 2px 的 `--dsw-alias-state-business-primary` 标记。选中规则与缩进参考线的绝对定位规则必须分开;`tests/theme.spec.ts` 解析实际 CSS 规则守护,挂载测试验证点击后文件行仍在原分组内。 +- **Context 诊断入口与提示**:图标沿用宿主 `Button` 与 `IconContextInjectionOutlineRegular`,标题栏为固定宽度按钮。跨会话错误通过 `shell.overlay` 展示一条可关闭提示,背景取 `--dsw-alias-bg-layer-3`、边框与图标取 `--dsw-alias-state-warn-primary`、正文取 label 令牌;宽度受视口约束,目标名与错误文案允许任意位置换行。能力中途消失时仍保留本次错误,不依赖来源弹层继续挂载。 + ### 12.2 注意事项 - 类名是 CSS Modules 哈希,**不是契约**;精确命中用 `[data-dsh-better-sidebar]` + 子串类名(`[class*='panel']`)或 DOM 结构。 diff --git a/scripts/e2e-context.sh b/scripts/e2e-context.sh new file mode 100755 index 00000000..0f634a56 --- /dev/null +++ b/scripts/e2e-context.sh @@ -0,0 +1,302 @@ +#!/usr/bin/env bash +# ============================================================================= +# dsh-better-sidebar 双插件 Context 诊断 e2e(真实 dsh-context + 本插件): +# +# 1. 全新 scratch profile(骨架复用 scripts/e2e-common.sh,不改该文件); +# 2. 真实安装:本仓库 tarball;dual / tab-only 变体再加 dsh-context@<钉版>; +# - dual 双插件齐全(三个入口都可用:当前会话 / 子代理详情 / 后台任务); +# - tab-only dsh-context 在,但用**它自己的公开设置** defaultPlacement=tab +# 只注册会话内视图、不注册右侧栏 tab 类型与 body —— 入口必须隐藏 +# (controller 的判据是 kind+body 都可用); +# - no-context 只装 tarball —— 入口必须隐藏; +# 3. 启动真实 `dsh web`(keyless,--port 0 取 OS 分配端口,绝不动 :3384); +# 4. 运行 tests/e2e/context-diagnostics.e2e.ts(Playwright Chromium,无头)。 +# +# 用法: +# bash scripts/e2e-context.sh [--variant dual|tab-only|no-context|all] [--grep ] +# +# 环境变量(均可省略): +# DSH_CMD 必须保留 DSH_HOME 的真实 CLI;缺省 npx 钉版(避开桌面 shim) +# TARBALL 插件 tarball;缺省仓库根 dsh-better-sidebar-*.tgz(须已 pack) +# PORT 固定端口(默认 0 = OS 分配,从日志解析 URL) +# DSH_HOME_BASE scratch 根目录(默认系统临时目录)。脚本只在其下新建本调用拥有的 +# 独立子目录,只写入/删除该子目录 +# KEEP_HOME 非空时保留 scratch(调试用) +# CONTEXT_PKG context 插件规格;缺省 dsh-context@0.72.0。**必须写精确版本号, +# 绝不写 dist-tag**(AGENTS.md §2:dist-tag 指向与候选版经常不一致) +# 每个变体都安装仅测试用 fixture,播种父子会话和后台 job;绝不发送模型请求。 +# +# 退出码 = 0 全部通过;非 0 失败。服务与 scratch 由 trap 兜底清理。 +# +# 清理安全性(本脚本的硬约束,见用户/父代理要求): +# - 只定向 kill 本脚本自己启动的 $SERVER_PID(e2e_cleanup),**没有 pkill/killall**; +# - 只删 e2e_make_scratch(mktemp -d)产出的 $SCRATCH 与本脚本 mktemp -d 的 $TMP_DIR, +# 两者都在挂 trap 之前由 assert_mktemp_product 校验过形状,未通过即 die(不清理)。 +# ============================================================================= +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +E2E_TAG=e2e-context +source "$SCRIPT_DIR/e2e-common.sh" + +# Desktop command shims may overwrite DSH_HOME. Default to the pinned real CLI. +DSH_CMD="${DSH_CMD:-npx -y --package ${DSH_NPX_SPEC} dsh}" +PORT="${PORT:-0}" +TARBALL="${TARBALL:-}" +CONTEXT_PKG="${CONTEXT_PKG:-dsh-context@0.72.0}" +VARIANT="all" +GREP_FILTER="" + +while [ $# -gt 0 ]; do + case "$1" in + --variant) VARIANT="${2:?--variant 需要参数}"; shift 2 ;; + --grep) GREP_FILTER="${2:?--grep 需要参数}"; shift 2 ;; + -h|--help) sed -n '2,46p' "${BASH_SOURCE[0]}"; exit 0 ;; + *) die "未知参数:$1(支持 --variant/--grep)" ;; + esac +done + +case "$VARIANT" in + dual|tab-only|no-context) VARIANTS="$VARIANT" ;; + all) VARIANTS="dual tab-only no-context" ;; + *) die "--variant 只支持 dual / tab-only / no-context / all(收到 $VARIANT)" ;; +esac + +e2e_require_cmd node "DSH 运行需要 Node.js >= 20" +e2e_require_cmd pnpm "dsh plugin 转发给 pnpm" +e2e_require_cmd npm "打包 fixture 插件需要" + +e2e_resolve_dsh_cmd + +e2e_resolve_tarball || die "找不到 tarball(TARBALL 或 \$ROOT/dsh-better-sidebar-*.tgz)——先运行 pnpm build && pnpm pack" +TARBALL="$(cd "$(dirname "$TARBALL")" && pwd)/$(basename "$TARBALL")" +say "tarball: $TARBALL" + +# ── 清理目标形状校验 ───────────────────────────────────────────────────────── +# e2e_cleanup 会 rm -rf $SCRATCH / $TMP_DIR,两者都必须是本次调用 mktemp -d 的产物。 +# 形状不符(例如被外部环境变量顶掉)时直接 die,绝不无审查清理。 +assert_mktemp_product() { + local dir="$1" base="$2" name="$3" + [ -n "$dir" ] || die "$name 为空,拒绝挂清理 trap" + [ -d "$dir" ] || die "$name 不是目录:$dir(拒绝清理)" + base="$(cd "$base" && pwd -P)" || die "$name 根目录无法解析" + dir="$(cd "$dir" && pwd -P)" || die "$name 目录无法解析" + case "$dir" in + "$base"/"$name".*) ;; + *) die "$name 不是本次 mktemp -d 产物:$dir(期望 $base/$name.XXXXXX,拒绝清理)" ;; + esac +} + +# ── 一个变体的完整流程(在子 shell 里跑:EXIT trap 只清这一个变体)────────── +run_variant() { + local variant="$1" + local fixture_dir="" + + e2e_make_scratch dsh-e2e-context + assert_mktemp_product "$SCRATCH" "${DSH_HOME_BASE:-/tmp}" "dsh-e2e-context" + + export DSH_HOME="$SCRATCH/home" + local workspace="$SCRATCH/workspace" + local web_log="$SCRATCH/web.log" + local profile="$DSH_HOME/profiles/web" + mkdir -p "$profile" "$workspace" + SERVER_PID="" + TMP_DIR="" + trap e2e_cleanup EXIT + say "[$variant] scratch:$SCRATCH" + + # 步骤 1:引导 scratch profile(三件套 heredoc 及 minimumReleaseAgeExclude 的 + # 理由见 e2e-common.sh 的 e2e_write_profile) + e2e_write_profile "$profile" + + # 步骤 2:官方 CLI 安装(真实挂载路径) + say "[$variant] 安装插件 tarball…" + $DSH_CMD plugin --profile web add "file:$TARBALL" + + if [ "$variant" = "dual" ] || [ "$variant" = "tab-only" ]; then + say "[$variant] 安装 ${CONTEXT_PKG}…" + install_plugin_spec "$CONTEXT_PKG" "$profile" + fi + + local fixture_tmp + fixture_tmp="$(mktemp -d "${TMPDIR:-/tmp}/dsh-e2e-context-fixture.XXXXXX")" + assert_mktemp_product "$fixture_tmp" "${TMPDIR:-/tmp}" "dsh-e2e-context-fixture" + TMP_DIR="$fixture_tmp" + fixture_dir="$(build_fixture_package "$TMP_DIR")" + say "[$variant] 安装仅测试用 fixture 宿主插件($fixture_dir)…" + $DSH_CMD plugin --profile web add "file:$fixture_dir" + + if [ "$variant" = "tab-only" ]; then + # The plugin's OWN public setting, applied as an id-targeted config override + # in the profile patch layer (the documented `PatchOptions` shape: bundles + # first, then cordis.patch.yml). `defaultPlacement: tab` keeps dsh-context's + # in-conversation Context view and does NOT register the right-sidebar tab + # type or its pane body — the "kind present, body absent / tab-only" state + # the entries must hide in. Written AFTER the installs so `dsh plugin add` + # cannot clobber it. + say "[$variant] 写入 dsh-context defaultPlacement=tab(profile patch 覆盖)…" + cat > "$profile/cordis.patch.yml" <<'EOF' +# e2e lane (scripts/e2e-context.sh, variant tab-only): an id-targeted config +# override of dsh-context's own public setting. It keeps the plugin's +# conversation-level Context view while leaving the native right column without +# a `dsh-context` tab type — the state the diagnostics entries must hide in. +- id: dsh-context + config: + defaultPlacement: tab +EOF + fi + + # 步骤 3:校验挂载生效(dsh.profile.bundles 含 dsh-better-sidebar;dual 另证 + # context 依赖真的进了 profile) + assert_profile_installed "$profile" "$variant" + + # 步骤 4:启动真实 dsh web(--port 0 = OS 分配;keyless 可起) + say "[$variant] 启动 dsh web(port=${PORT})…" + export DSH_E2E_CONTEXT_WORKSPACE="$workspace" + $DSH_CMD web --port "$PORT" --no-open >"$web_log" 2>&1 & + SERVER_PID=$! + + # 就绪行解析:带一次性 token 的鉴权 URL(理由见 e2e-mount.sh 的同名注释) + E2E_READY_RE='dsh web: http://127\.0\.0\.1:[0-9]+[^ ]*' + E2E_READY_PICK=head + local wait_rc=0 + e2e_wait_dsh_web_ready "$web_log" || wait_rc=$? + if [ "$wait_rc" -eq 2 ]; then + echo "=== [$variant] dsh web 提前退出,日志尾部 ===" >&2 + tail -30 "$web_log" >&2 || true + exit 1 + fi + if [ "$wait_rc" -ne 0 ]; then + echo "=== [$variant] 120s 内未等到 dsh web 就绪,日志尾部 ===" >&2 + tail -40 "$web_log" >&2 || true + exit 1 + fi + say "[$variant] dsh web 就绪:${URL}(pid ${SERVER_PID})" + + # 启动期前置校验(都读宿主日志,失败即停在测试之前,避免把「插件没加载」误读 + # 成 controller 失效): + # 1) 宿主兼容性预检会把 peer 范围不满足的整行静默 disabled(AGENTS.md §12); + if grep -q "disabling profile plugin .*dsh-context" "$web_log"; then + warn "宿主预检禁用了 dsh-context 行——真机前提不成立" + grep -n "disabling profile plugin" "$web_log" >&2 || true + exit 1 + fi + # 2) tab-only 变体的 id 定向 config 覆盖必须真的命中那行;未命中时 include 只 + # 告警并跳过(cordis-plugin-include 的 applyEntryPatches),右侧栏类型就会 + # 照旧注册——spec 会红,但这里更早给出原因。 + if [ "$variant" = "tab-only" ] && grep -qE "patch: entry .*dsh-context.* not found" "$web_log"; then + warn "defaultPlacement 覆盖未命中 dsh-context 行(profile patch 的 id 对不上)" + grep -nE "patch: entry .*dsh-context.* not found" "$web_log" >&2 || true + exit 1 + fi + + # 步骤 5:运行本 lane 的 spec(只这一个文件;--grep 可选) + say "[$variant] 运行 Playwright(tests/e2e/context-diagnostics.e2e.ts)…" + export DSH_E2E_URL="$URL" + export DSH_E2E_WORKSPACE="$workspace" + export DSH_E2E_CONTEXT_VARIANT="$variant" + if [ -n "$GREP_FILTER" ]; then + pnpm exec playwright test tests/e2e/context-diagnostics.e2e.ts --output "test-results/context-$variant" --grep "$GREP_FILTER" + else + pnpm exec playwright test tests/e2e/context-diagnostics.e2e.ts --output "test-results/context-$variant" + fi + + if ! grep -q '\[e2e-context-fixture\] seeding complete' "$web_log"; then + warn "fixture 未完成播种" + tail -20 "$web_log" >&2 || true + exit 1 + fi + + say "[$variant] 通过" +} + +# 官方 CLI 安装一条插件规格;失败时给 profile 写 .npmrc 走官方 registry 重试一次 +# (本机默认 registry 是 npmmirror,对新预发布/新版本可能滞后;AGENTS.md §2)。 +install_plugin_spec() { + local spec="$1" profile="$2" + if $DSH_CMD plugin --profile web add "$spec"; then return 0; fi + warn "安装 $spec 失败——改用官方 registry(写 $profile/.npmrc)重试一次" + printf 'registry=https://registry.npmjs.org/\n' > "$profile/.npmrc" + $DSH_CMD plugin --profile web add "$spec" +} + +# 把 tests/e2e/context-fixture-plugin.mjs 打成仅测试用的 npm 包(manifest 随本脚本 +# 生成,镜像 tests/fixtures/aggregate-better-sidebar 的形态),返回 tarball 绝对路径。 +build_fixture_package() { + local tmp="$1" + local dir="$tmp/fixture-context-seed" + mkdir -p "$dir/lib" + cp "$ROOT/tests/e2e/context-fixture-plugin.mjs" "$dir/lib/index.mjs" + cat > "$dir/package.json" <<'EOF' +{ + "name": "fixture-context-seed", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "lib/index.mjs", + "files": [ + "lib", + "cordis.patch.yml" + ], + "dsh": { + "bundle": { + "patch": "./cordis.patch.yml" + } + } +} +EOF + cat > "$dir/cordis.patch.yml" <<'EOF' +# e2e-only bundle patch: mount the context-diagnostics seeding fixture as its own +# row. It never ships (the package is built into the lane's scratch dir from +# tests/e2e/context-fixture-plugin.mjs). +- insert: + - id: e2e-context-fixture + name: 'fixture-context-seed' +EOF + ( cd "$dir" && npm pack --pack-destination "$tmp" >&2 ) || return $? + local tgz + tgz="$(ls "$tmp"/fixture-context-seed-*.tgz 2>/dev/null | head -1 || true)" + [ -n "$tgz" ] || die "fixture 插件打包失败($dir)" + printf '%s\n' "$tgz" +} + +# 校验挂载点:bundles 含 dsh-better-sidebar;dual 变体另证 context 插件确实进了 +# profile 的 dependencies(否则「入口消失」会被误读成 controller 失效)。 +assert_profile_installed() { + local profile="$1" variant="$2" + if ! node -e ' + const fs = require("fs"); + const p = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); + const bundles = p.dsh?.profile?.bundles ?? []; + process.exit(bundles.includes("dsh-better-sidebar") ? 0 : 1); + ' "$profile/package.json"; then + warn "dsh-better-sidebar 未出现在 dsh.profile.bundles 中——挂载未注册" + cat "$profile/package.json" + exit 1 + fi + if [ "$variant" = "dual" ] || [ "$variant" = "tab-only" ]; then + if ! node -e ' + const fs = require("fs"); + const p = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); + const dep = p.dependencies?.["dsh-context"] ?? ""; + process.exit(dep === "" ? 1 : 0); + ' "$profile/package.json"; then + warn "$variant 变体下 dsh-context 不在 profile dependencies 中——真机前提不成立" + cat "$profile/package.json" + exit 1 + fi + fi + say "[$variant] 挂载已注册:dsh.profile.bundles 含 dsh-better-sidebar" +} + +cd "$ROOT" +for one in $VARIANTS; do + say "==== 变体 $one ====" + # Keep this outside a conditional: Bash otherwise disables errexit inside + # run_variant and a failing Playwright run could be reported as successful. + ( run_variant "$one" ) +done + +say "通过:双插件 Context 诊断 lane(变体:$VARIANTS)" diff --git a/src/client/JobsDrawer.tsx b/src/client/JobsDrawer.tsx index b1483b42..f761675b 100644 --- a/src/client/JobsDrawer.tsx +++ b/src/client/JobsDrawer.tsx @@ -24,6 +24,8 @@ import { TerminalBlock, type TagTone, } from '@deepseek-ai/dsh-client-ui-primitives' import type { SidebarClientJobsService, SidebarJobView, SidebarObservedJob } from '../context-types.ts' +import type { ContextDiagnosticTarget } from './context-diagnostics.ts' +import { ContextDiagnosticsButton } from './context-diagnostics-ui.tsx' import { terminalBlockLabels } from './block-labels.ts' import { formatJobDuration, @@ -291,12 +293,20 @@ export function JobOutputWindow(props: { ownerSessionId: string /** The host's streamed observation of THIS job (undefined until it arrives). */ observed: SidebarObservedJob | undefined + /** + * The diagnostics target of the conversation that OWNS this job, resolved by + * the caller from the tree model (`undefined` = the owner is not in this + * tree, or the page has no such capability): the window never derives it + * from `ownerSessionId`, which names the session the roster was WATCHED + * under, not the session that owns the job. + */ + diagnostics?: ContextDiagnosticTarget | undefined /** The row's main button — where the window first appears. */ anchor?: HTMLElement | null /** Close the window (the close button, or Escape). */ onClose(): void }): ReactNode { - const { jobs, job, ownerSessionId, observed, anchor, onClose } = props + const { jobs, job, ownerSessionId, observed, diagnostics: diagnosticTarget, anchor, onClose } = props const [follow, setFollow] = useState(true) const [copied, setCopied] = useState(false) const [armed, setArmed] = useState(false) @@ -346,6 +356,12 @@ export function JobOutputWindow(props: { bodyRef={bodyRef} actions={( <> + {/* + The owning conversation's Context view, beside the copy action: it is + offered only when the caller resolved the job's OWNER into the tree + (see the `diagnostics` prop) and the deployment has the page at all. + */} +