From da6124be07b7ef444f8910d4c6b428929f68100f Mon Sep 17 00:00:00 2001 From: OMSociety <85862362+OMSociety@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:44:27 +0800 Subject: [PATCH 1/2] feat: add dsh.settingsTab to hide the bili entry on the DSH settings page (#6436) --- docs/configuration.ja.md | 3 +- docs/configuration.md | 3 +- docs/configuration.zh-CN.md | 3 +- src/agent/dsh-native-client.ts | 27 +++++++++++++--- src/agent/dsh-native.ts | 20 +++++++----- src/config.ts | 23 ++++++++----- src/knobs.ts | 12 +++++++ src/web/client.ts | 12 +++++++ src/web/i18n.ts | 4 +++ tests/dsh-settings-ui.test.ts | 48 ++++++++++++++++++++++++++++ website/config-reference/server.yaml | 13 ++++++-- 11 files changed, 142 insertions(+), 26 deletions(-) diff --git a/docs/configuration.ja.md b/docs/configuration.ja.md index 215a6ffc3e..500d6cc925 100644 --- a/docs/configuration.ja.md +++ b/docs/configuration.ja.md @@ -122,10 +122,11 @@ | `compat.streamErrorShape` | "protocol" \| "completion" | protocol | BILI_STREAM_ERROR_SHAPE | 200 がコミットされた後、上流ストリーム失敗がどのように提示されるか:プロトコルネイティブのエラーフレーム(デフォルト)またはレガシーの合成完了形状。 | | `compat.noCacheControl` | boolean | false | BILI_NO_CACHE_CONTROL | Anthropic レーンの cache_control ブレークポイントを完全にスタンプしないようにします(独自のブレークポイントポリシーを持つ上流/リレー用のエスケープハッチ)。 | | `compat.keepResponseId` | boolean | false | ACP_KEEP_RESPONSE_ID | カーネル再構築された Responses リクエストで previous_response_id を保持します(デフォルトでは削除するため、再構築されたボディは上流が発行したことのない ID を参照しません)。 | -| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | セクションは認識されるが、従来のエスケープハッチは削除された(#3666、#2028 を代替):`allowDshCompaction` キーおよび `BILI_ALLOW_DSH_COMPACTION` 環境変数はもはや存在しない — dsh ネイティブコンパクションは、すべてのレーンにおいてワイヤガードによって無条件に拒否される。残存する `dsh.allowDshCompaction` の値は、一度限りの非推奨警告とともに無視される;代わりにホスト側の抑制を適用すること(#3354/#2474)。ライブキー — `dsh.authoredCompaction`、`dsh.contextTab`、`dsh.contextTabLabel` — は以下のエントリに文書化されている。 | +| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | セクションは認識されるが、従来のエスケープハッチは削除された(#3666、#2028 を代替):`allowDshCompaction` キーおよび `BILI_ALLOW_DSH_COMPACTION` 環境変数はもはや存在しない — dsh ネイティブコンパクションは、すべてのレーンにおいてワイヤガードによって無条件に拒否される。残存する `dsh.allowDshCompaction` の値は、一度限りの非推奨警告とともに無視される;代わりにホスト側の抑制を適用すること(#3354/#2474)。ライブキー — `dsh.authoredCompaction`、`dsh.contextTab`、`dsh.contextTabLabel`、`dsh.settingsTab` — は以下のエントリに文書化されている。 | | `dsh.authoredCompaction` | boolean | true (on, #3901 flip) | BILI_DSH_AUTHORED_COMPACTION | bili は dsh コンパクションの summarize 呼び出しを、拒否する代わりに折り畳みスナップショットでローカルに回答する(#3723/#3733)。0.1.203 のドッグフッド期間が維持されたため、デフォルトで ON。`false`(または環境変数 `BILI_DSH_AUTHORED_COMPACTION=0`)を設定すると、#1729 の拒否パスが復元される。 | | `dsh.contextTab` | boolean | true | BILI_DSH_CONTEXT_TAB | DSH トップバーの「上下文」/「Context」会話タブを登録する(#3862/#4237):`false` にすると、そのタブのみが削除される — コンプレッション、設定セクション、その他のすべてのサーフェスは引き続き動作する。非表示にしてもコンプレッションは無効にならない;台帳は設定セクション(会话 サブページ)、プラグインバンドル設定フェイス、Web UI、および `/acp` コマンド経由で引き続きアクセス可能。次のページ読み込み / dsh リスタート時に有効になる(スロット登録はページ読み込み時に発生);デフォルト `true` = 現在の動作は変更なし。 | | `dsh.contextTabLabel` | string | unset (built-in 「上下文」/「Context」) | — | DSH トップバーの Context タブのカスタム表示名(#4237)、例:別のプラグイン(dsh-context)が「上下文」の名前を所有している場合の "压缩账本"。トリムされた空でない文字列が組み込みラベルに優先される;空白または未設定の場合は組み込みにフォールバック。ファイル専用ティア(表示設定、#2030 に従い環境変数なし)。デフォルト未設定 = 組み込みラベルは変更なし。 | +| `dsh.settingsTab` | boolean | true | — | DSH 設定ページの bili セクションを登録する(#6436):`false` にすると、そのナビゲーションエントリのみが削除される — コンプレッション、Context タブ、プラグインバンドル設定フェイス、Web UI は引き続き動作し、パネルはプラグイン詳細ページと bili Web UI から引き続きアクセス可能。次のページ読み込み / dsh リスタート時に有効になる(スロット登録はページ読み込み時に発生)。ファイル専用ティア(表示設定、#2030 に従い環境変数なし)。デフォルト `true` = 現在の動作は変更なし。 | | `resign` | scheme → { enabled?, passthrough?, credentialRef? } | {} (armed; built-in scheme sdk-hmac-sha256) | BILI_RESIGN, BILI_RESIGN_PASSTHROUGH, BILI_CODEARTS_REF, BILI_RESIGN_BENEFIT | Authorization スキームでキーイングされた再署名アーム:署名済みモデルリクエストは、すべてのエグレスボディが再署名されてトンネリングされる;署名解除できないリクエストは、パススルーがそのスキームを逐語転送にオプトインしていない限り、ローカルで 403 として拒否される。 | | `promptCache.routing` | "auto" \| "enabled" \| "disabled" | disabled | ACP_PROMPT_CACHE_ROUTING | bili 自身の `prompt_cache_key` 出力の姿勢(両方のワイヤ);クライアントが供給したキーは常に逐語的に転送される。 | | `cacheKeepalive.enabled` | boolean | false | BILI_CACHE_KEEPALIVE | Anthropic ワイヤにおけるアイドル時のプロンプトキャッシュキープアライブのマスタースイッチ(#3376):セッションがアイドルになると、bili は TTL 由来の周期で `max_tokens=1` を伴う最後の転送ボディを再生し、アップストリームのプレフィックスキャッシュをウォームに保つ;ヒットは `usage.cache_read_input_tokens` 経由で検証される;ミス/429/エラー連続/期間上限で停止。プロバイダルートごとおよびモデルごとにも設定可能。 | diff --git a/docs/configuration.md b/docs/configuration.md index d2bddf9df9..d53f551d4e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -125,10 +125,11 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `compat.streamErrorShape` | "protocol" \| "completion" | protocol | BILI_STREAM_ERROR_SHAPE | How upstream stream failures are presented after the 200 is committed: protocol-native error frames (default) or the legacy synthesized-completion shape. | | `compat.noCacheControl` | boolean | false | BILI_NO_CACHE_CONTROL | Stop stamping Anthropic-lane cache_control breakpoints entirely (escape hatch for upstreams/relays with their own breakpoint policy). | | `compat.keepResponseId` | boolean | false | ACP_KEEP_RESPONSE_ID | Preserve previous_response_id on kernel-rebuilt Responses requests (default strips it so rebuilt bodies never reference ids the upstream never issued). | -| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The live keys — dsh.authoredCompaction, dsh.contextTab, dsh.contextTabLabel — are documented in the following entries. | +| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The live keys — dsh.authoredCompaction, dsh.contextTab, dsh.contextTabLabel, dsh.settingsTab — are documented in the following entries. | | `dsh.authoredCompaction` | boolean | true (on, #3901 flip) | BILI_DSH_AUTHORED_COMPACTION | bili answers dsh compaction summarize calls locally with the folded snapshot instead of refusing (#3723/#3733). ON by default since the 0.1.203 dogfood window held; false (or env BILI_DSH_AUTHORED_COMPACTION=0) restores the #1729 refusal path. | | `dsh.contextTab` | boolean | true | BILI_DSH_CONTEXT_TAB | Registers the DSH top-bar 「上下文」/「Context」 conversation tab at all (#3862/#4237): false removes ONLY that tab — compression, the settings section and every other surface keep working. Hiding never disables compression; the ledger stays reachable via the settings section (会话 subpage), the plugin bundle config face, the Web UI and the /acp command. Takes effect on the next page load / dsh restart (slot registration happens at page load); default true = today's behavior unchanged. | | `dsh.contextTabLabel` | string | unset (built-in 「上下文」/「Context」) | — | Custom display name for the DSH top-bar Context tab (#4237), e.g. "压缩账本" when another plugin (dsh-context) owns the name 「上下文」. Trimmed non-empty string wins over the built-in label; blank or absent falls back to the built-in. File-only tier (display preference, no env knob per #2030). Default unset = built-in label unchanged. | +| `dsh.settingsTab` | boolean | true | — | Registers the bili section on the DSH settings page (#6436): false removes ONLY that navigation entry — compression, the Context tab, the plugin bundle config face and the Web UI keep working, so the panel stays reachable from the plugin detail page and the bili Web UI. Takes effect on the next page load / dsh restart (slot registration happens at page load). File-only tier (display preference, no env knob per #2030). Default true = today's behavior unchanged. | | `resign` | scheme → { enabled?, passthrough?, credentialRef? } | {} (armed; built-in scheme sdk-hmac-sha256) | BILI_RESIGN, BILI_RESIGN_PASSTHROUGH, BILI_CODEARTS_REF, BILI_RESIGN_BENEFIT | Re-sign arm keyed by Authorization scheme: signed model requests tunnel with every egress body re-signed; unresignable requests are refused locally 403 unless passthrough opts that scheme into verbatim forwarding. | | `promptCache.routing` | "auto" \| "enabled" \| "disabled" | disabled | ACP_PROMPT_CACHE_ROUTING | Posture of bili's own `prompt_cache_key` emission (both wires); client-supplied keys always forward verbatim. | | `cacheKeepalive.enabled` | boolean | false | BILI_CACHE_KEEPALIVE | Master switch for idle prompt-cache keepalive on the Anthropic wire (#3376): while a session goes idle, bili replays the last forwarded body with max_tokens=1 on a TTL-derived cadence so the upstream prefix cache stays warm; hits are verified via usage.cache_read_input_tokens; stops on miss/429/error-streak/duration cap. Also settable per provider route and per model. | diff --git a/docs/configuration.zh-CN.md b/docs/configuration.zh-CN.md index 3ad7b20267..3cd336fcac 100644 --- a/docs/configuration.zh-CN.md +++ b/docs/configuration.zh-CN.md @@ -125,10 +125,11 @@ | `compat.streamErrorShape` | "protocol" \| "completion" | protocol | BILI_STREAM_ERROR_SHAPE | 200 已提交后上游流失败的呈现方式:协议原生错误帧(默认)或旧版合成完成形态。 | | `compat.noCacheControl` | boolean | false | BILI_NO_CACHE_CONTROL | 完全停止 Anthropic 通道的 cache_control 断点打标(面向拒收该字段或有自有断点策略的上游/中继的逃生门)。 | | `compat.keepResponseId` | boolean | false | ACP_KEEP_RESPONSE_ID | 在内核重建的 Responses 请求上保留 previous_response_id(默认剔除,使重建请求体永不引用上游从未签发过的响应 id)。 | -| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | 段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。存活的键——dsh.authoredCompaction、dsh.contextTab、dsh.contextTabLabel——见接下来的条目。 | +| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | 段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。存活的键——dsh.authoredCompaction、dsh.contextTab、dsh.contextTabLabel、dsh.settingsTab——见接下来的条目。 | | `dsh.authoredCompaction` | boolean | true (on, #3901 flip) | BILI_DSH_AUTHORED_COMPACTION | bili 用折叠快照本地应答 dsh 压缩摘要请求而非拒绝(#3723/#3733)。0.1.203 狗粮窗口守住后默认开启;false(或环境变量 BILI_DSH_AUTHORED_COMPACTION=0)恢复 #1729 拒绝路径。 | | `dsh.contextTab` | boolean | true | BILI_DSH_CONTEXT_TAB | 是否注册 DSH 顶栏「上下文」会话标签页(#3862/#4237):false 只移除该标签页——压缩、设置页一节及其余所有入口不受影响。隐藏绝不关闭压缩;账本仍可从设置页(会话子页)、插件 bundle 配置面、Web UI 与 /acp 命令查看。下次页面加载 / dsh 重启生效(槽位注册发生在页面加载时);默认 true = 现状不变。 | | `dsh.contextTabLabel` | string | unset (built-in 「上下文」/「Context」) | — | DSH 顶栏上下文标签页的自定义显示名(#4237),例如另一插件(dsh-context)已占用「上下文」时改为"压缩账本"。去空白后的非空字符串优先于内置名;留空或缺省回退内置名。仅文件层(显示偏好,按 #2030 不设 env 开关)。默认缺省 = 内置名不变。 | +| `dsh.settingsTab` | boolean | true | — | 是否在 DSH 设置页注册 bili 一节(#6436):false 只移除该导航入口——压缩、上下文标签页、插件 bundle 配置面与 Web UI 均不受影响,设置面板仍可从插件详情页与 bili Web UI 打开。下次页面加载 / dsh 重启生效(槽位注册发生在页面加载时)。仅文件层(显示偏好,按 #2030 不设 env 开关)。默认 true = 现状不变。 | | `resign` | scheme → { enabled?, passthrough?, credentialRef? } | {} (armed; built-in scheme sdk-hmac-sha256) | BILI_RESIGN, BILI_RESIGN_PASSTHROUGH, BILI_CODEARTS_REF, BILI_RESIGN_BENEFIT | 按 Authorization 方案键控的重签名臂:可重签名的模型请求全程重签转发;无法重签的请求本地 403 拒绝,除非该方案经 passthrough 选择原文透传。 | | `promptCache.routing` | "auto" \| "enabled" \| "disabled" | disabled | ACP_PROMPT_CACHE_ROUTING | bili 自注入 `prompt_cache_key` 的姿态(两条 wire 同时生效);客户端自带的 key 永远原样转发。 | | `cacheKeepalive.enabled` | boolean | false | BILI_CACHE_KEEPALIVE | Anthropic 线路空闲期提示缓存保活总开关(#3376):会话空闲时按 TTL 推导的节奏以 max_tokens=1 重放最后一次转发的请求体,维持上游前缀缓存温热;以 usage.cache_read_input_tokens 验证命中,miss/429/连续错误/时长上限即停;支持逐 provider 路由与逐模型覆盖。 | diff --git a/src/agent/dsh-native-client.ts b/src/agent/dsh-native-client.ts index f4a074173c..5208e0703a 100644 --- a/src/agent/dsh-native-client.ts +++ b/src/agent/dsh-native-client.ts @@ -589,6 +589,18 @@ function readCtxTabFace(): { hidden: boolean; label: string | undefined } { return { hidden, label }; } +/** #6436: settings-section face flag from the __BILI__ snapshot (host half, + * dsh.settingsTab). `hidden` skips the settings.section registration — only + * the DSH settings navigation entry goes away; the panel stays mounted at + * plugins.bundle.config and reachable through the Web UI. Fails open: an + * absent field (legacy host, pre-bootstrap page load) keeps today's + * registration byte-identical. */ +function readSettingsTabFace(): { hidden: boolean } { + const g = globalThis as { __BILI__?: { settingsTab?: unknown } }; + const snap = g.__BILI__; + return { hidden: snap !== undefined && snap.settingsTab === false }; +} + function openExternal(url: string): void { const w = globalThis as { open?: (url: string, target?: string, features?: string) => unknown }; if (typeof w.open === "function") w.open(url, "_blank", "noopener,noreferrer"); @@ -1141,10 +1153,17 @@ export function apply(ctx: ClientContext): void { }), ); }; - ctx.slots.inject( - "settings.section", - () => ctx.slots.register({ name: "settings.section", id: "bili", order: 100, label: () => t("nav"), locale: NS }, panel(true)), - ); + // #6436: dsh.settingsTab=false (config file / web settings) skips the + // settings.section registration — only the DSH settings navigation entry + // goes away; the ledger stays reachable through the plugin bundle config + // face and the Web UI. Fail-open on an absent flag. + const settingsGate = readSettingsTabFace(); + if (!settingsGate.hidden) { + ctx.slots.inject( + "settings.section", + () => ctx.slots.register({ name: "settings.section", id: "bili", order: 100, label: () => t("nav"), locale: NS }, panel(true)), + ); + } ctx.slots.inject( "plugins.bundle.config", () => ctx.slots.register({ name: "plugins.bundle.config", key: "billion-context", locale: NS }, panel(false)), diff --git a/src/agent/dsh-native.ts b/src/agent/dsh-native.ts index 8654a7b2b7..4806c82e47 100644 --- a/src/agent/dsh-native.ts +++ b/src/agent/dsh-native.ts @@ -60,7 +60,7 @@ import { VERSION } from "../version.js"; import { APIG_RESIGN_SCHEME, unresolvedRefusals } from "../apig-resign.js"; import { adminRelayEnabled, resolveResignSettings } from "../config.js"; import { decodeRequestBody } from "../content-encoding.js"; -import { dshContextTabEnabled, dshContextTabLabel, limitsDecodedBytes } from "../knobs.js"; +import { dshContextTabEnabled, dshContextTabLabel, dshSettingsTabEnabled, limitsDecodedBytes } from "../knobs.js"; import { MIN_ASSUMED_WINDOW_TOKENS } from "../util.js"; import { markNativeHost, nativeAttachOrigin, nativeBootstrapGate, nativeProxyScriptPath, proxyEnvOrigin, singleFlight } from "./native-bootstrap.js"; import { bodyOverWindowDetail as sharedBodyOverWindowDetail, getDeclaredModelEndpoints, installNativeFetchIntercept, liveStateSlotEffect, noteRoutedOrigin, observeRoutedOrigin, routedBiliModelUrl, setDeclaredModelEndpoints, type GateVerdict, type NativeInterceptState } from "./native-intercept.js"; @@ -2013,11 +2013,14 @@ export async function apply(ctx: PluginContext): Promise { // a stale link. // #4237: the payload also carries the Context-tab face flags (register // gate + optional custom label), read live on every call so a web-settings - // edit lands on the next page load without a proxy restart. - const withCtxTabFace = (base: Record): Record => { + // edit lands on the next page load without a proxy restart. #6436 adds the + // settings-section gate; it is emitted only when OFF so a default-config + // payload stays byte-identical and an older host half keeps failing open. + const withDshFace = (base: Record): Record => { base.contextTab = dshContextTabEnabled(); const label = dshContextTabLabel(); if (label !== undefined) base.contextTabLabel = label; + if (!dshSettingsTabEnabled()) base.settingsTab = false; return base; }; ctx.on?.("webserver/index-inject", (table: Array<{ kind: string; name?: string; value?: unknown }>) => { @@ -2027,11 +2030,12 @@ export async function apply(ctx: PluginContext): Promise { // must therefore ride the row even before the origin is bound (spawn mode // reads register.base only after bootstrap), or dsh.contextTab=false fails // open on desktop forever. A null origin is safe: readOrigin() treats a - // non-string origin as unresolved and keeps polling /bili/origin, and - // readCtxTabFace() only needs contextTab/contextTabLabel. Mirrors the + // non-string origin as unresolved and keeps polling /bili/origin, and the + // browser half reads only the face flags it knows (contextTab, + // contextTabLabel, settingsTab). Mirrors the // /bili/origin route expression below so snapshot ≡ route at any instant. const origin = currentOrigin(); - table.push({ kind: "global", name: "__BILI__", value: withCtxTabFace(origin !== undefined && adminRelayEnabled() ? { origin: null, relay: true } : { origin: origin ?? null }) }); + table.push({ kind: "global", name: "__BILI__", value: withDshFace(origin !== undefined && adminRelayEnabled() ? { origin: null, relay: true } : { origin: origin ?? null }) }); }); // #2604: follow the host session name (dsh-session-title service). Every @@ -2066,9 +2070,9 @@ export async function apply(ctx: PluginContext): Promise { const origin = currentOrigin(); // #3373: relay mode ⇒ the client derives its base from the probe // response URL itself; the loopback origin is useless (and leaky) - // to a remote browser. #4237: same Context-tab face flags as the + // to a remote browser. #4237/#6436: same DSH face flags as the // snapshot row. - const body = JSON.stringify(withCtxTabFace(origin !== undefined && adminRelayEnabled() ? { origin: null, relay: true } : { origin: origin ?? null })); + const body = JSON.stringify(withDshFace(origin !== undefined && adminRelayEnabled() ? { origin: null, relay: true } : { origin: origin ?? null })); res.writeHead(200, { "content-type": "application/json" }); res.end(body); }, diff --git a/src/config.ts b/src/config.ts index ef473e7a98..17e77a9645 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1142,11 +1142,11 @@ export type ProxyOptions = { * `allowDshCompaction` escape hatch was REMOVED (#3651) — dsh native * compaction is now refused unconditionally by the #1729 wire guard on every * lane, and a landed checkpoint durably shadows the raw history - * (irreversible), so no opt-in remains. The one live key is - * `authoredCompaction` (#3723/#3901). Leftover removed keys still sit in old - * files: the section stays RECOGNIZED so they don't trip the unknown-key - * warning, and each is ignored with a once-per-process deprecation note - * (warnRemovedDshAllowKey). */ + * (irreversible), so no opt-in remains. Live keys are `authoredCompaction` + * (#3723/#3901), `contextTab` / `contextTabLabel` (#4237) and `settingsTab`. + * Leftover removed keys still sit in old files: the section stays RECOGNIZED + * so they don't trip the unknown-key warning, and each is ignored with a + * once-per-process deprecation note (warnRemovedDshAllowKey). */ interface DshFileSettings { /** #3723/#3901: bili-authored compaction answers (ON by default since * the 0.1.203 dogfood window; `false` or env `BILI_DSH_AUTHORED_COMPACTION=0` @@ -1167,6 +1167,13 @@ interface DshFileSettings { * rename exists for machines where another plugin occupies the same name * (dsh-context ships its own "上下文"). */ contextTabLabel?: string; + /** #6436: show the bili section on the DSH settings page (settings.section + * slot). ON by default; `false` removes only that navigation entry — the + * panel stays reachable through the plugin bundle config face and the + * Web UI. Resolved per page load by the host half and shipped to the + * browser half through the __BILI__ snapshot / /bili/origin route. + * File-only (display preference, no env tier per #2030). */ + settingsTab?: boolean; } /** The routing fields a provider entry can carry — exactly what @@ -2715,9 +2722,9 @@ function warnRemovedDshAllowKey(obj: Record): void { const d = obj.dsh; if (d !== null && typeof d === "object" && !Array.isArray(d)) { // authoredCompaction (#3723/#3901), contextTab + contextTabLabel - // (#4237) are the LIVE keys in the section — everything else found - // here is removed/unknown and gets named. - const live = new Set(["authoredCompaction", "contextTab", "contextTabLabel"]); + // (#4237), settingsTab (#6436) are the LIVE keys in the section — + // everything else found here is removed/unknown and gets named. + const live = new Set(["authoredCompaction", "contextTab", "contextTabLabel", "settingsTab"]); for (const key of Object.keys(d as Record)) if (!live.has(key)) hits.push(`dsh.${key}`); } hits.sort(); diff --git a/src/knobs.ts b/src/knobs.ts index 9fe5ee2e2c..256b3f151e 100644 --- a/src/knobs.ts +++ b/src/knobs.ts @@ -707,6 +707,18 @@ export function dshContextTabLabel(): string | undefined { return s.length > 0 ? s : undefined; } +/** dsh.settingsTab (#6436): whether the DSH settings page shows the bili + * section (settings.section slot). Default ON = today's behavior; false + * removes only that navigation entry — compression, the Context tab, the + * plugin bundle config face and the Web UI keep working. File-only on + * purpose (#2030 env-var discipline: a display preference, not a secret / + * spawn channel / host posture). Resolved by the host half at page-load + * time and shipped to the browser half via the __BILI__ snapshot / + * /bili/origin route. */ +export function dshSettingsTabEnabled(): boolean { + return loadConfigFile().dsh?.settingsTab !== false; +} + type PluginBypassOverride = "auto" | "on" | "off"; /** BILI_PLUGIN_BYPASS — operator override of the x-bili-plugin-bypass diff --git a/src/web/client.ts b/src/web/client.ts index 5ca025d133..35e7abf4ba 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -4657,6 +4657,7 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + mitmInp.value = (m && Array.isArray(m.domains)) ? m.domains.filter((x) => typeof x === "string").join(", ") : ""; const ds = (draft.dsh && typeof draft.dsh === "object" && !Array.isArray(draft.dsh)) ? draft.dsh : null; dshCtxRow.inp.checked = ds ? ds.contextTab !== false : true; + dshSetRow.inp.checked = ds ? ds.settingsTab !== false : true; dshLblInp.value = (ds && typeof ds.contextTabLabel === "string") ? ds.contextTabLabel : ""; } function commit(mutate) { @@ -4730,6 +4731,17 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + dshCtxHint.className = "dim small"; dshCtxHint.textContent = t("cfg.q_dsh_ctxtab_hint"); dshCtxRow.ctl.appendChild(dshCtxHint); + const dshSetRow = row("quick-dsh-settingstab", t("cfg.q_dsh_settingstab")); + qCtrls.push(dshSetRow.inp); + dshSetRow.inp.addEventListener("change", () => commit((d) => { + const ds = (d.dsh && typeof d.dsh === "object" && !Array.isArray(d.dsh)) ? d.dsh : {}; + if (dshSetRow.inp.checked) delete ds.settingsTab; else ds.settingsTab = false; + if (Object.keys(ds).length === 0) delete d.dsh; else d.dsh = ds; + })); + const dshSetHint = document.createElement("span"); + dshSetHint.className = "dim small"; + dshSetHint.textContent = t("cfg.q_dsh_settingstab_hint"); + dshSetRow.ctl.appendChild(dshSetHint); const dshLblInp = textRow("quick-dsh-ctxtab-label", t("cfg.q_dsh_ctxtab_label")); qCtrls.push(dshLblInp); dshLblInp.addEventListener("change", () => commit((d) => { diff --git a/src/web/i18n.ts b/src/web/i18n.ts index 45d66a429b..a6d29b775f 100644 --- a/src/web/i18n.ts +++ b/src/web/i18n.ts @@ -630,6 +630,8 @@ export const MESSAGES: Record> = { "cfg.q_dsh_ctxtab": "DSH 顶栏「上下文」标签页(dsh.contextTab)——关闭只摘掉 DSH 会话区顶部那个标签页,压缩不受影响;账本仍可在 bili 设置页、插件详情页和本 Web UI 查看(默认开)", "cfg.q_dsh_ctxtab_hint": "下次页面加载 / 重启 dsh 后生效;也可用环境变量 BILI_DSH_CONTEXT_TAB=0 强制隐藏", "cfg.q_dsh_ctxtab_label": "DSH「上下文」标签页名称(dsh.contextTabLabel)——留空用内置名「上下文」,可改名避免与其他插件重名", + "cfg.q_dsh_settingstab": "DSH 设置页「bili设置」入口(dsh.settingsTab)——关闭只摘掉 DSH 设置页侧栏的 bili 入口,压缩与账本不受影响;设置面板仍可从插件详情页和本 Web UI 打开(默认开)", + "cfg.q_dsh_settingstab_hint": "下次页面加载 / 重启 dsh 后生效;也可在配置文件里写 dsh.settingsTab: false", "cfg.q_absorb": "工具结果即时蒸馏(absorb)——大工具结果到达时由模型即时蒸馏,原文隐藏到下一轮折叠前(默认关)", "cfg.q_absorb_hint": "默认只吸含图结果(#3422);mediaOnly: false 可恢复吸全文。子项(minToolTokens、contextThresholdPct、excludeTools)请在下方 JSON 编辑框写", "cfg.q_require_nudge": "禁止未提示压缩(compress.requireNudge)——只在 nudge 信用存活时(最近一次真正注入的提醒起 20 个模型轮内,新提醒刷新、未提示轮衰减、成功折叠不消耗)允许模型调用 compress,其余拒绝并回错误回执(默认关)", @@ -1430,6 +1432,8 @@ export const MESSAGES: Record> = { "cfg.q_dsh_ctxtab": "DSH top-bar Context tab (dsh.contextTab) — off removes only that tab from the DSH conversation area; compression is untouched and the ledger stays visible in the bili settings section, the plugin detail page and this Web UI (default on)", "cfg.q_dsh_ctxtab_hint": "takes effect on the next page load / dsh restart; env BILI_DSH_CONTEXT_TAB=0 also forces it hidden", "cfg.q_dsh_ctxtab_label": "Label of the DSH Context tab (dsh.contextTabLabel) — empty keeps the built-in name \"Context\"; rename to avoid clashing with another plugin's tab", + "cfg.q_dsh_settingstab": "bili entry on the DSH settings page (dsh.settingsTab) — off removes only the bili navigation item from the DSH settings sidebar; compression and the ledger are untouched, and the panel stays reachable from the plugin detail page and this Web UI (default on)", + "cfg.q_dsh_settingstab_hint": "takes effect on the next page load / dsh restart; dsh.settingsTab: false in the config file works too", "cfg.q_absorb": "Instant tool-result absorption (absorb) — large tool results are distilled by the model on arrival; originals hidden until the next fold round (default off)", "cfg.q_absorb_hint": "by default only image-bearing results are absorbed (#3422); set mediaOnly: false to absorb full text. Sub-fields (minToolTokens, contextThresholdPct, excludeTools) go in the JSON editor below", "cfg.q_require_nudge": "Forbid unprompted compression (compress.requireNudge) — compress may only be called while a nudge credit is live (within 20 model rounds of the last actually-injected nudge: refreshed by new nudges, decayed per un-nudged round, NOT consumed by successful folds); anything else is refused with an error receipt (default off)", diff --git a/tests/dsh-settings-ui.test.ts b/tests/dsh-settings-ui.test.ts index 6c8ac47268..82d985ccee 100644 --- a/tests/dsh-settings-ui.test.ts +++ b/tests/dsh-settings-ui.test.ts @@ -143,6 +143,32 @@ test("#4846: index-inject carries contextTab=false even before the origin is bou } }); +// #6436: dsh.settingsTab=false must reach the page through BOTH carriers, and +// the default-config payload must stay byte-identical to #4237 (no new key). +test("#6436: dsh.settingsTab=false rides the boot snapshot and /bili/origin; default omits it", async () => { + const home = fs.mkdtempSync(path.join(os.tmpdir(), "bili-dsh-ui-")); + try { + const cfgFile = path.join(home, "bili-config.json"); + fs.writeFileSync(cfgFile, JSON.stringify({ dsh: { settingsTab: false } })); + await withEnv({ DSH_HOME: home, BILLION_CONTEXT_PROXY: undefined, BILI_CONFIG_FILE: cfgFile }, async () => { + _resetRegisterForTest(undefined); + const listeners: InjectListener[] = []; + apply(uiCtx(listeners) as Parameters[0]); + const table: InjectRow[] = []; + listeners[0](table); + assert.deepEqual(table, [{ kind: "global", name: "__BILI__", value: { origin: null, contextTab: true, settingsTab: false } }]); + // The live route agrees with the boot snapshot (last known origin wins). + const routes: RouteRow[] = []; + apply(routeCtx(routes, []) as Parameters[0]); + const res = new FakeRes(); + await routes.find((r) => r.path === "/bili/origin")!.handler({}, res); + assert.deepEqual(JSON.parse(res.body), { origin: null, contextTab: true, settingsTab: false }); + }); + } finally { + rmrf(home); + } +}); + type RouteRow = { kind: string; path: string; handler: (req: unknown, res: FakeRes) => void | Promise }; class FakeRes { @@ -2028,6 +2054,28 @@ test("#4237: contextTab=false hides the Context tab; absent field fails open to shown.runCleanups(); }); +// #6436: dsh.settingsTab=false drops ONLY the settings.section registration — +// the plugin bundle config face (the remaining in-DSH entry point), the +// Context tab and the availability pill stay registered. +test("#6436: settingsTab=false hides the DSH settings entry; absent field fails open", async () => { + const baseExtra = (): Record => ({ + open: (_url: string) => {}, + fetch: async () => ({ ok: true, json: async () => ({ origin: "http://127.0.0.1:8787" }) }), + setTimeout, + clearTimeout, + }); + const hidden = await mountClient({ ...baseExtra(), __BILI__: { origin: "http://127.0.0.1:8787", settingsTab: false } }, "plugins.bundle.config"); + assert.deepEqual(hidden.slotsOrder, ["plugins.bundle.config", "conversation.view", "shell.overlay"]); + assert.ok(!hidden.optionsBySlot.has("settings.section"), "hidden settings entry registers nothing"); + assert.ok(hidden.optionsBySlot.has("plugins.bundle.config"), "the plugin detail page stays the in-DSH entry point"); + hidden.runCleanups(); + // Explicit on keeps it; (absent-field fail-open is pinned by the + // #1590/#2125 test above, which mounts without the field). + const shown = await mountClient({ ...baseExtra(), __BILI__: { origin: "http://127.0.0.1:8787", settingsTab: true } }); + assert.ok(shown.optionsBySlot.has("settings.section"), "explicit on keeps the entry"); + shown.runCleanups(); +}); + test("#4237: contextTabLabel overrides the built-in tab name; blank or non-string falls back", async () => { const baseExtra = (): Record => ({ open: (_url: string) => {}, diff --git a/website/config-reference/server.yaml b/website/config-reference/server.yaml index d05c9e7e50..0615800c13 100644 --- a/website/config-reference/server.yaml +++ b/website/config-reference/server.yaml @@ -428,9 +428,9 @@ entries: default: "{}" env: BILI_ALLOW_DSH_COMPACTION group: behavior - desc_en: "Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The live keys — dsh.authoredCompaction, dsh.contextTab, dsh.contextTabLabel — are documented in the following entries." - desc_zh: "段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。存活的键——dsh.authoredCompaction、dsh.contextTab、dsh.contextTabLabel——见接下来的条目。" - desc_ja: "セクションは認識されるが、従来のエスケープハッチは削除された(#3666、#2028 を代替):`allowDshCompaction` キーおよび `BILI_ALLOW_DSH_COMPACTION` 環境変数はもはや存在しない — dsh ネイティブコンパクションは、すべてのレーンにおいてワイヤガードによって無条件に拒否される。残存する `dsh.allowDshCompaction` の値は、一度限りの非推奨警告とともに無視される;代わりにホスト側の抑制を適用すること(#3354/#2474)。ライブキー — `dsh.authoredCompaction`、`dsh.contextTab`、`dsh.contextTabLabel` — は以下のエントリに文書化されている。" + desc_en: "Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The live keys — dsh.authoredCompaction, dsh.contextTab, dsh.contextTabLabel, dsh.settingsTab — are documented in the following entries." + desc_zh: "段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。存活的键——dsh.authoredCompaction、dsh.contextTab、dsh.contextTabLabel、dsh.settingsTab——见接下来的条目。" + desc_ja: "セクションは認識されるが、従来のエスケープハッチは削除された(#3666、#2028 を代替):`allowDshCompaction` キーおよび `BILI_ALLOW_DSH_COMPACTION` 環境変数はもはや存在しない — dsh ネイティブコンパクションは、すべてのレーンにおいてワイヤガードによって無条件に拒否される。残存する `dsh.allowDshCompaction` の値は、一度限りの非推奨警告とともに無視される;代わりにホスト側の抑制を適用すること(#3354/#2474)。ライブキー — `dsh.authoredCompaction`、`dsh.contextTab`、`dsh.contextTabLabel`、`dsh.settingsTab` — は以下のエントリに文書化されている。" - key: dsh.authoredCompaction type: boolean default: "true (on, #3901 flip)" @@ -454,6 +454,13 @@ entries: desc_en: "Custom display name for the DSH top-bar Context tab (#4237), e.g. \"压缩账本\" when another plugin (dsh-context) owns the name 「上下文」. Trimmed non-empty string wins over the built-in label; blank or absent falls back to the built-in. File-only tier (display preference, no env knob per #2030). Default unset = built-in label unchanged." desc_zh: "DSH 顶栏上下文标签页的自定义显示名(#4237),例如另一插件(dsh-context)已占用「上下文」时改为\"压缩账本\"。去空白后的非空字符串优先于内置名;留空或缺省回退内置名。仅文件层(显示偏好,按 #2030 不设 env 开关)。默认缺省 = 内置名不变。" desc_ja: "DSH トップバーの Context タブのカスタム表示名(#4237)、例:別のプラグイン(dsh-context)が「上下文」の名前を所有している場合の \"压缩账本\"。トリムされた空でない文字列が組み込みラベルに優先される;空白または未設定の場合は組み込みにフォールバック。ファイル専用ティア(表示設定、#2030 に従い環境変数なし)。デフォルト未設定 = 組み込みラベルは変更なし。" + - key: dsh.settingsTab + type: boolean + default: "true" + group: behavior + desc_en: "Registers the bili section on the DSH settings page (#6436): false removes ONLY that navigation entry — compression, the Context tab, the plugin bundle config face and the Web UI keep working, so the panel stays reachable from the plugin detail page and the bili Web UI. Takes effect on the next page load / dsh restart (slot registration happens at page load). File-only tier (display preference, no env knob per #2030). Default true = today's behavior unchanged." + desc_zh: "是否在 DSH 设置页注册 bili 一节(#6436):false 只移除该导航入口——压缩、上下文标签页、插件 bundle 配置面与 Web UI 均不受影响,设置面板仍可从插件详情页与 bili Web UI 打开。下次页面加载 / dsh 重启生效(槽位注册发生在页面加载时)。仅文件层(显示偏好,按 #2030 不设 env 开关)。默认 true = 现状不变。" + desc_ja: "DSH 設定ページの bili セクションを登録する(#6436):`false` にすると、そのナビゲーションエントリのみが削除される — コンプレッション、Context タブ、プラグインバンドル設定フェイス、Web UI は引き続き動作し、パネルはプラグイン詳細ページと bili Web UI から引き続きアクセス可能。次のページ読み込み / dsh リスタート時に有効になる(スロット登録はページ読み込み時に発生)。ファイル専用ティア(表示設定、#2030 に従い環境変数なし)。デフォルト `true` = 現在の動作は変更なし。" - key: resign type: "scheme → { enabled?, passthrough?, credentialRef? }" default: "{} (armed; built-in scheme sdk-hmac-sha256)" From 3f9b8904e921af432bd85e916e0181454f924098 Mon Sep 17 00:00:00 2001 From: ci-check Date: Thu, 12 Nov 2026 23:37:39 +0800 Subject: [PATCH 2/2] test: pin the default-config __BILI__ payload for dsh.settingsTab (#6436) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #6436 host-half test title claimed 'default omits it' but only asserted the settingsTab=false case. Add the missing default-config assertion: an empty config must produce { origin: null, contextTab: true } with NO settingsTab key on both the boot snapshot and /bili/origin — the byte-identical-to-#4237 regression guarantee, and the 'does not trigger' half of the gate (#3617). --- tests/dsh-settings-ui.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/dsh-settings-ui.test.ts b/tests/dsh-settings-ui.test.ts index 82d985ccee..ed36096613 100644 --- a/tests/dsh-settings-ui.test.ts +++ b/tests/dsh-settings-ui.test.ts @@ -169,6 +169,33 @@ test("#6436: dsh.settingsTab=false rides the boot snapshot and /bili/origin; def } }); +// #6436: the default-config payload must stay byte-identical to #4237 — no +// settingsTab key at all (the host half only emits the field when OFF, so an +// older host half that predates settingsTab keeps failing open on the absent +// field). Pins the "default omits it" half of the gate (#3617 both directions). +test("#6436: default config omits settingsTab from the __BILI__ payload (byte-identical to #4237)", async () => { + const home = fs.mkdtempSync(path.join(os.tmpdir(), "bili-dsh-ui-")); + try { + const cfgFile = path.join(home, "bili-config.json"); + fs.writeFileSync(cfgFile, JSON.stringify({})); + await withEnv({ DSH_HOME: home, BILLION_CONTEXT_PROXY: undefined, BILI_CONFIG_FILE: cfgFile }, async () => { + _resetRegisterForTest(undefined); + const listeners: InjectListener[] = []; + apply(uiCtx(listeners) as Parameters[0]); + const table: InjectRow[] = []; + listeners[0](table); + assert.deepEqual(table, [{ kind: "global", name: "__BILI__", value: { origin: null, contextTab: true } }]); + const routes: RouteRow[] = []; + apply(routeCtx(routes, []) as Parameters[0]); + const res = new FakeRes(); + await routes.find((r) => r.path === "/bili/origin")!.handler({}, res); + assert.deepEqual(JSON.parse(res.body), { origin: null, contextTab: true }); + }); + } finally { + rmrf(home); + } +}); + type RouteRow = { kind: string; path: string; handler: (req: unknown, res: FakeRes) => void | Promise }; class FakeRes {