Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Restore the app's own search selection when auto is turned off

Fei24119d5b973005d7
diff --git a/app/src/host.mjs b/app/src/host.mjs
index ce2c8e58..d8608060 100644
--- a/app/src/host.mjs
+++ b/app/src/host.mjs
@@ -7,6 +7,7 @@ import { inspect } from 'node:util'
import { loadLayeredEnv, reportSkippedBundles } from '@deepseek-ai/dsh-app-boot'
import { runProfile } from '@deepseek-ai/dsh/profile-boot'
import { CHECK_PROFILE, INSTALL_ANCHOR, loadAppProfile, loadCheckProfile, PROFILE } from './profile.mjs'
+import { reconcileSearchSelector } from './search-patch.mjs'
import { unreadableSessions } from './session-check.mjs'
const MAX_FATAL_DIAGNOSTIC_CHARS = 64 * 1024
@@ -25,7 +26,7 @@ async function main() {
environment: loadLayeredEnv('dsh'),
profile: check === undefined ? PROFILE : CHECK_PROFILE,
resolvedProfile: { profile, installAnchor: INSTALL_ANCHOR },
- patchFiles: [],
+ patchFiles: check === undefined ? reconcileSearchSelector(profile) : [],
args: ['--no-open', '--port', process.env.DS_BOT_PORT || '0'],
...(pnpm === undefined ? {} : {
packageManager: { command: process.execPath, args: ['--expose-internals', pnpm], env: { ELECTRON_RUN_AS_NODE: '1' } },
diff --git a/app/src/search-patch.mjs b/app/src/search-patch.mjs
new file mode 100644
index 00000000..b6f0fe97
--- /dev/null
+++ b/app/src/search-patch.mjs
@@ -0,0 +1,51 @@
+// Reconcile #128: turning off `web-search-auto` does not undo the `web` row's
+// `searchProvider: auto`, which DS Bot's own patch selects for the profile — every
+// search then fails with WEB_PROVIDER_CONFIGURED_MISSING. When the app's own bundles
+// configured the selector before ds-bot arrived, restore that selection through a
+// `--patch` overlay the app writes into its own data area next to the profiles
+// (`<DSH_HOME>/profiles/search-selector.patch.yml`): DSH reads it only through
+// `patchFiles` and nothing scans this location, so it cannot rewrite the profile or
+// outlive the fix. The plugins page's toggle takes effect at once; this
+// reconciliation runs on the next launch.
+import { dirname, join } from 'node:path'
+import { rmSync, writeFileSync } from 'node:fs'
+import { composeEntries } from '@deepseek-ai/dsh-app-boot'
+import { stringify } from 'yaml'
+
+export const SEARCH_PATCH_NAME = 'search-selector.patch.yml'
+
+/**
+ * The overlay rows that put the `web` row back on the app's own bundles'
+ * selection, or `undefined` when none is needed.
+ * @param {import('@deepseek-ai/dsh-app-boot').Profile} profile
+ * @returns {import('@deepseek-ai/cordis-plugin-include').PatchOptions[] | undefined}
+ */
+export function searchSelectorPatch(profile) {
+ const layers = profile.layers
+ const entries = composeEntries([...layers.map(layer => layer.patches), profile.patches])
+ if (entries.find(entry => entry.id === 'web-search-auto')?.disabled !== true) return undefined
+ const web = entries.find(entry => entry.id === 'web')
+ if (web?.config?.searchProvider !== 'auto') return undefined
+ // The web row as it composes from the bundles alone, before ds-bot's selection.
+ const base = layers.filter(({ packageName }) => packageName !== 'ds-bot')
+ const original = composeEntries(base.map(layer => layer.patches)).find(entry => entry.id === 'web')
+ if (original?.config?.searchProvider === undefined || original.config.searchProvider === 'auto') return undefined
+ return [{ id: 'web', name: original.name, config: original.config }]
+}
+
+/**
+ * Write the reconciliation overlay next to the profiles and report it for
+ * `patchFiles`; when none is needed, drop a stale one from an earlier launch.
+ * @param {import('@deepseek-ai/dsh-app-boot').Profile} profile
+ * @returns {string[]} the `patchFiles` argument for this launch
+ */
+export function reconcileSearchSelector(profile) {
+ const file = join(dirname(profile.dir), SEARCH_PATCH_NAME)
+ const rows = searchSelectorPatch(profile)
+ if (rows === undefined) {
+ rmSync(file, { force: true })
+ return []
+ }
+ writeFileSync(file, stringify(rows), 'utf8')
+ return [file]
+}
diff --git a/app/test/search-patch.test.mjs b/app/test/search-patch.test.mjs
new file mode 100644
index 00000000..09a60111
--- /dev/null
+++ b/app/test/search-patch.test.mjs
@@ -0,0 +1,80 @@
+import assert from 'node:assert/strict'
+import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { after, before, describe, test } from 'node:test'
+import { reconcileSearchSelector, SEARCH_PATCH_NAME, searchSelectorPatch } from '../src/search-patch.mjs'
+
+const DSH_WEB = '@deepseek-ai/dsh-web'
+
+// A stand-in profile: dsh-base supplies the web row, ds-bot adds the auto
+// provider and points the selector at it, and `user` rows model the profile's
+// own cordis.patch.yml.
+function profile(user = [], { auto = true } = {}) {
+ const dir = mkdtempSync(join(tmpdir(), 'ds-bot-search-patch-'))
+ return {
+ name: 'ds-bot', dir, patchPath: join(dir, 'cordis.patch.yml'), skippedBundles: [],
+ layers: [
+ { packageName: '@deepseek-ai/dsh-base', packageDir: '', patchPaths: [], patches: [{ insert: [{ id: 'web', name: DSH_WEB, config: { searchProvider: 'deepseek-official', fetchProvider: 'http' } }] }] },
+ { packageName: 'ds-bot', packageDir: '', patchPaths: [], patches: [
+ ...(auto ? [{ insert: [{ id: 'web-search-auto', name: 'ds-bot/web-search' }] }] : []),
+ { id: 'web', config: { searchProvider: 'auto', fetchProvider: 'http' } },
+ ] },
+ ],
+ patches: user,
+ }
+}
+const disabledAuto = { id: 'web-search-auto', name: 'ds-bot/web-search', disabled: true }
+
+describe('searchSelectorPatch', () => {
+ const made = []
+ const track = (...args) => { const p = profile(...args); made.push(p.dir); return p }
+ after(() => { for (const dir of made) rmSync(dir, { recursive: true, force: true }) })
+
+ test('restores the app bundles\' web selection when auto is disabled and still selected', () => {
+ assert.deepEqual(searchSelectorPatch(track([disabledAuto])), [
+ { id: 'web', name: DSH_WEB, config: { searchProvider: 'deepseek-official', fetchProvider: 'http' } },
+ ])
+ })
+
+ test('does nothing while the auto provider is enabled', () => {
+ assert.equal(searchSelectorPatch(track()), undefined)
+ })
+
+ test('does nothing when the profile already names another provider', () => {
+ assert.equal(searchSelectorPatch(track([disabledAuto, { id: 'web', config: { searchProvider: 'custom-one', fetchProvider: 'http' } }])), undefined)
+ })
+})
+
+describe('reconcileSearchSelector', () => {
+ let dir
+ before(() => { dir = mkdtempSync(join(tmpdir(), 'ds-bot-search-reconcile-')) })
+ after(() => { rmSync(dir, { recursive: true, force: true }) })
+
+ test('writes the overlay where DSH only reads it through patchFiles, and drops it when satisfied', () => {
+ const p = profile([disabledAuto])
+ try {
+ const [file] = reconcileSearchSelector(p)
+ // Outside the profile directory itself, so DSH only reads it through patchFiles.
+ assert.equal(file, join(p.dir, '..', SEARCH_PATCH_NAME))
+ assert.notEqual(file, p.patchPath)
+ } finally {
+ rmSync(p.dir, { recursive: true, force: true })
+ }
+ })
+
+ test('removes a stale overlay when the auto provider is on again', () => {
+ const p = profile([disabledAuto])
+ try {
+ const [file] = reconcileSearchSelector(p)
+ assert.ok(existsSync(file))
+ assert.match(readFileSync(file, 'utf8'), /searchProvider: deepseek-official/)
+ // The user re-enables web-search-auto: no profile patch rows, nothing to do.
+ p.patches = []
+ assert.deepEqual(reconcileSearchSelector(p), [])
+ assert.equal(existsSync(file), false)
+ } finally {
+ rmSync(p.dir, { recursive: true, force: true })
+ }
+ })
+})