A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Make the desktop window frameless on Windows, with Mica on Windows 11
Fei24115b64348cecfb
diff --git a/NOTICE b/NOTICEindex 914a2eb4..afb29d66 100644--- a/NOTICE+++ b/NOTICE@@ -21,8 +21,12 @@ MIT License, Copyright (c) 2026 DeepSeekshutdown messages.- app/src/host-process.mjs follows apps/desktop/src/host-process.ts: theHost in Electron's Node mode and the shutdown escalation.- - app/src/main.mjs follows apps/desktop/src/main.ts for the dsh-app scheme- and the request routing.+ - app/src/main.mjs follows apps/desktop/src/main.ts for the dsh-app scheme,+ the request routing, and the Windows window options (the caption-button+ overlay, its colors and the native theme). app/src/preload.cjs adapts+ apps/desktop/src/preload-windows.ts, apps/desktop/src/preload-platform.ts+ and apps/desktop/src/preload-theme.ts: the caption-band marks, the+ fullscreen mark, the caption-color measure and the theme sync.- app/engine/cordis.patch.yml follows the bundle patch of@deepseek-ai/dsh-web-app (packages/bundle/web-app/cordis.patch.yml): thetransport and host-service rows and the agent-plane rows it turns off.diff --git a/app/README.md b/app/README.mdindex 1ef59322..4b8240a6 100644--- a/app/README.md+++ b/app/README.md@@ -107,7 +107,8 @@ The script serves a releases list with one release of that version that has this| File | What it does ||---|---|| `src/main.mjs` | Main process: one instance, the `dsh-app://app` scheme (DSH's Web front end, and everything else forwarded to the Host), the window and its boot data |-| `src/preload.cjs` | Hands the window the boot data that DSH's Web front end needs |+| `src/preload.cjs` | Hands the window the boot data that DSH's Web front end needs. On Windows it marks the page for the frameless window and sends the caption buttons the colors of the surface under them |+| `src/window-frame.mjs`, `src/mica.css` | The frameless Windows window: the caption band, when Mica is available (Windows 11 22H2 and later), and the stylesheet that lets Mica through the sidebar || `src/host-process.mjs` | Starts the Host in Electron's Node mode and owns its exit || `src/host.mjs` | The Host: boots the profile with `runProfile()` and reports the launch URL and the page injections; for the first-run check (`DS_BOT_CHECK`), the chats it cannot read || `src/profile.mjs` | The profiles: the app's own and the first-run check's, their bundles, and their creation and update |diff --git a/app/src/main.mjs b/app/src/main.mjsindex 755115b5..79daa83a 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -2,9 +2,10 @@// The dsh-app scheme, the request forwarding and the WebSocket header rewrite follow// DeepSeek Harness apps/desktop/src/main.ts (MIT); see NOTICE.import { app, BrowserWindow, dialog, ipcMain, Menu, nativeTheme, protocol, session, shell } from 'electron'-import { mkdirSync, readdirSync, writeFileSync } from 'node:fs'+import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'import { rm } from 'node:fs/promises'import { createRequire } from 'node:module'+import { release } from 'node:os'import { dirname, join } from 'node:path'import { setTimeout as sleep } from 'node:timers/promises'import { fileURLToPath } from 'node:url'@@ -16,10 +17,14 @@ import { copySessions, findTeam, importTeam } from './import.mjs'import { CHECK_PROFILE, PROFILE } from './profile.mjs'import { UPDATE_TEXT, watchReleases, watchUpdates } from './updates.mjs'import { APP_ORIGIN, authenticateWebHost, forwardWebRequest, serveWebDocument } from './web.mjs'+import { CAPTION_HEIGHT, cssColor, micaAvailable, nativeThemeSource } from './window-frame.mjs'// DSH writes dsh-app://app/ into workspace file URLs and Markdown file links, so the window keeps that scheme.const SCHEME = 'dsh-app'-const IPC = { boot: 'ds-bot:boot', bootFailed: 'ds-bot:boot-failed' }+const IPC = {+ boot: 'ds-bot:boot', bootFailed: 'ds-bot:boot-failed',+ caption: 'ds-bot:caption-colors', nativeTheme: 'ds-bot:native-theme', fullscreen: 'ds-bot:fullscreen',+}const STATIC_PATHS = new Set(['/', '/index.html', '/manifest.webmanifest'])const UPDATE_CHECK_WAIT_MS = 15_000const UPDATE_DOWNLOAD_WAIT_MS = 15 * 60_000@@ -28,6 +33,8 @@ const here = dirname(fileURLToPath(import.meta.url))const webDist = join(dirname(createRequire(import.meta.url).resolve('@deepseek-ai/dsh-web-frontend/package.json')), 'dist')// Drawn by scripts/icon.mjs. Windows takes the .ico for its several sizes.const iconFile = join(here, '..', 'assets', process.platform === 'win32' ? 'icon.ico' : 'icon.png')+// Windows 11 draws Mica behind the page; mica.css lets it through the sidebar.+const mica = micaAvailable(process.platform, release())if (process.env.DS_BOT_SHELL_DATA) app.setPath('userData', process.env.DS_BOT_SHELL_DATA)protocol.registerSchemesAsPrivileged([{@@ -138,6 +145,18 @@ async function start() {assertWindow(event)fail(new Error(String(message)))})+ if (process.platform === 'win32') {+ // Windows ignores the alpha of the caption buttons' color, so they take the opaque color+ // of the surface under them, which the page measures.+ ipcMain.on(IPC.caption, (event, color, symbolColor) => {+ if (fromWindow(event) && cssColor(color) && cssColor(symbolColor)) mainWindow.setTitleBarOverlay({ color, symbolColor })+ })+ // Mica and the caption buttons follow the app's theme, not only the system's.+ ipcMain.on(IPC.nativeTheme, (event, source) => {+ const value = nativeThemeSource(source)+ if (fromWindow(event) && value !== undefined) nativeTheme.themeSource = value+ })+ }// The stream connects to the Host directly; the Host accepts only its own origin and cookie.session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ['ws://127.0.0.1/*'] }, (details, callback) => {@@ -267,16 +286,40 @@ async function askDownload(version) {}function createWindow() {+ const dark = nativeTheme.shouldUseDarkColors+ const win32 = process.platform === 'win32'mainWindow = new BrowserWindow({width: 1320, height: 860, minWidth: 720, minHeight: 480,title: 'DeepSeek Bot', show: false, icon: iconFile,- backgroundColor: nativeTheme.shouldUseDarkColors ? '#1b1b1c' : '#ffffff',- webPreferences: { preload: join(here, 'preload.cjs'), contextIsolation: true, sandbox: true },+ backgroundColor: mica ? '#00000000' : dark ? '#1b1b1c' : '#ffffff',+ // Frameless as in DSH Desktop: the caption buttons overlay the page's band. They keep the+ // sidebar's colors until the page sends the colors of the surface under them.+ ...(win32 ? {+ titleBarStyle: 'hidden',+ titleBarOverlay: { height: CAPTION_HEIGHT, color: dark ? '#1b1b1c' : '#f9fafb', symbolColor: dark ? '#f9fafb' : '#0f1115' },+ ...(mica ? { backgroundMaterial: 'mica' } : {}),+ } : {}),+ webPreferences: {+ preload: join(here, 'preload.cjs'), contextIsolation: true, sandbox: true,+ additionalArguments: win32 ? [`--ds-bot-caption=${String(CAPTION_HEIGHT)}`, ...(mica ? ['--ds-bot-mica'] : [])] : [],+ },})mainWindow.once('ready-to-show', () => { mainWindow?.show() })mainWindow.on('page-title-updated', (event) => { event.preventDefault() })mainWindow.on('closed', () => { mainWindow = undefined })const contents = mainWindow.webContents+ if (win32) {+ // Fullscreen hides the caption buttons, and the page drops its band meanwhile. A reload+ // registers the page's listener again, so the state goes out after every load too.+ const sendFullscreen = () => { if (mainWindow !== undefined) contents.send(IPC.fullscreen, mainWindow.isFullScreen()) }+ mainWindow.on('enter-full-screen', sendFullscreen)+ mainWindow.on('leave-full-screen', sendFullscreen)+ contents.on('did-finish-load', sendFullscreen)+ }+ if (mica) {+ const css = readFileSync(join(here, 'mica.css'), 'utf8')+ contents.on('dom-ready', () => { void contents.insertCSS(css) })+ }contents.setWindowOpenHandler(({ url }) => { openOutside(url); return { action: 'deny' } })contents.on('will-navigate', (event, url) => {if (url.startsWith(`${APP_ORIGIN}/`)) return@@ -309,6 +352,10 @@ function assertWindow(event) {|| !event.senderFrame.url.startsWith(`${APP_ORIGIN}/`)) throw new Error('DeepSeek Bot: rejected IPC from an unknown page')}+function fromWindow(event) {+ try { assertWindow(event); return true } catch { return false }+}+function openOutside(url) {if (/^https?:\/\//iu.test(url)) void shell.openExternal(url)}diff --git a/app/src/mica.css b/app/src/mica.cssnew file mode 100644index 00000000..6da1d0f4--- /dev/null+++ b/app/src/mica.css@@ -0,0 +1,27 @@+/* Windows 11 with Mica: the sidebar shows the material for the full window height, and the+ conversation reaches the top edge. The caption buttons stand on the conversation, because+ Windows paints them opaque. Theme variables only. */++body,+div[class*="_frame"]:has(> div[class*="_sidebarCol"]) {+ background: transparent !important;+}+div[class*="_frame"]:has(> div[class*="_sidebarCol"]) {+ padding-top: 0 !important;+}+/* The band stays the drag area, but it no longer paints. */+div[class*="_frame"]:has(> div[class*="_sidebarCol"])::before {+ background: transparent !important;+}+div[class*="_sidebarCol"] {+ padding-top: var(--dsh-windows-titlebar-height) !important;+ background: color-mix(in srgb, var(--dsw-specific-sidebar-fill) 45%, transparent) !important;+}+/* The sidebar's own root paints the same fill again; only the column's coat stays. */+div[class*="_sidebarCol"] > div[class*="_root"],+div[class*="_sidebarCol"] > * > div[class*="_root"] {+ background: transparent !important;+}+div[class*="_centerCol"] {+ padding-top: var(--dsh-windows-titlebar-height) !important;+}diff --git a/app/src/preload.cjs b/app/src/preload.cjsindex acc18b39..efc7181b 100644--- a/app/src/preload.cjs+++ b/app/src/preload.cjs@@ -1,4 +1,8 @@-// Gives the DSH Web entry the boot handshake it uses inside an app window.+// Gives the DSH Web entry the boot handshake it uses inside an app window. On Windows it also+// marks the page for the frameless window the way DSH Desktop's preload does+// (apps/desktop/src/preload-windows.ts, preload-platform.ts and preload-theme.ts; see NOTICE),+// but without data-platform: that puts DSH's shortcuts on native menu input, which this+// window does not have.const { contextBridge, ipcRenderer } = require('electron')if (location.protocol === 'dsh-app:' && location.hostname === 'app') {@@ -6,4 +10,76 @@ if (location.protocol === 'dsh-app:' && location.hostname === 'app') {ready: () => ipcRenderer.invoke('ds-bot:boot'),failed: (message) => ipcRenderer.invoke('ds-bot:boot-failed', String(message)),})+ const caption = process.argv.find(value => value.startsWith('--ds-bot-caption='))+ if (caption !== undefined) {+ ipcRenderer.on('ds-bot:fullscreen', (_event, fullscreen) => {+ const root = document.documentElement+ if (root === null) return+ if (fullscreen) root.dataset.fullscreen = 'true'+ else delete root.dataset.fullscreen+ })+ const start = () => { frameless(caption.slice('--ds-bot-caption='.length), process.argv.includes('--ds-bot-mica')) }+ // A preload runs before the document root exists.+ if (document.readyState === 'loading') window.addEventListener('DOMContentLoaded', start, { once: true })+ else start()+ }+}++function frameless(height, mica) {+ const root = document.documentElement+ root.dataset.windowsTitlebar = ''+ root.style.setProperty('--dsh-windows-titlebar-height', `${height}px`)+ let theme+ const sendTheme = () => {+ const value = root.getAttribute('data-ds-theme-source')+ if (value === null || value === theme) return+ theme = value+ ipcRenderer.send('ds-bot:native-theme', value)+ }+ new MutationObserver(sendTheme).observe(root, { attributeFilter: ['data-ds-theme-source'] })+ sendTheme()+ captionColors(mica)+}++// The caption buttons stand on the conversation with Mica and on the sidebar-colored band+// without it. Theme variables can resolve apart from what is painted, so the color comes from+// the element itself: the first one up from it that is not transparent.+function captionColors(mica) {+ const canvas = document.createElement('canvas')+ canvas.width = canvas.height = 1+ const context = canvas.getContext('2d', { willReadFrequently: true })+ if (context === null) return+ const opaque = (color) => {+ context.clearRect(0, 0, 1, 1)+ context.fillStyle = color+ context.fillRect(0, 0, 1, 1)+ const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data+ return alpha === 0 ? undefined : `rgb(${red}, ${green}, ${blue})`+ }+ const surface = () => {+ for (let element = document.querySelector(mica ? 'div[class*="_centerCol"]' : 'div[class*="_sidebarCol"]'); element !== null; element = element.parentElement) {+ const color = opaque(getComputedStyle(element).backgroundColor)+ if (color !== undefined) return [color, opaque(getComputedStyle(element).color)]+ }+ return undefined+ }+ let sent = ''+ let tries = 0+ const send = () => {+ const colors = surface()+ // The frame appears once DSH has booted; until then the main process's colors hold.+ if (colors === undefined || colors[1] === undefined) {+ if (tries++ < 120) setTimeout(send, 250)+ return+ }+ const current = colors.join()+ if (current === sent) return+ sent = current+ ipcRenderer.send('ds-bot:caption-colors', ...colors)+ }+ const observer = new MutationObserver(send)+ observer.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme', 'style'] })+ observer.observe(document.head, { childList: true, subtree: true, characterData: true })+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-ds-theme-source', 'style'] })+ send()}diff --git a/app/src/window-frame.mjs b/app/src/window-frame.mjsnew file mode 100644index 00000000..0dc4c425--- /dev/null+++ b/app/src/window-frame.mjs@@ -0,0 +1,17 @@+// The frameless Windows window: the system caption buttons overlay a band at the top of the+// page, as in DeepSeek Harness apps/desktop (windows-layout.ts and main.ts; see NOTICE).++/** Height of the caption band in device-independent pixels. */+export const CAPTION_HEIGHT = 40++/** Electron's Mica backdrop needs the system backdrop of Windows 11 22H2 (build 22621). */+export function micaAvailable(platform, release) {+ return platform === 'win32' && Number(String(release).split('.')[2] ?? 0) >= 22621+}++const COLOR = /^(?:#[\da-f]{3,8}|rgba?\([\d.,%\s]+\))$/iu+/** Only plain CSS colors cross from the page to the caption buttons. */+export const cssColor = value => typeof value === 'string' && COLOR.test(value)++/** The theme sources that the native theme accepts; a theme id has no native counterpart. */+export const nativeThemeSource = value => (value === 'light' || value === 'dark' || value === 'system' ? value : undefined)diff --git a/app/test/window-frame.test.mjs b/app/test/window-frame.test.mjsnew file mode 100644index 00000000..1ca67c89--- /dev/null+++ b/app/test/window-frame.test.mjs@@ -0,0 +1,28 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { cssColor, micaAvailable, nativeThemeSource } from '../src/window-frame.mjs'++test('Mica only on Windows 11 22H2 and later', () => {+ assert.equal(micaAvailable('win32', '10.0.22621'), true)+ assert.equal(micaAvailable('win32', '10.0.26100'), true)+ assert.equal(micaAvailable('win32', '10.0.22000'), false)+ assert.equal(micaAvailable('win32', '10.0.19045'), false)+ assert.equal(micaAvailable('darwin', '25.0.0'), false)+ assert.equal(micaAvailable('linux', '6.8.0'), false)+})++test('only plain CSS colors reach the caption buttons', () => {+ assert.equal(cssColor('rgba(252, 252, 252, 1)'), true)+ assert.equal(cssColor('rgb(20, 20, 20)'), true)+ assert.equal(cssColor('#f9fafb'), true)+ assert.equal(cssColor('red'), false)+ assert.equal(cssColor('url(x)'), false)+ assert.equal(cssColor(7), false)+})++test('a theme id does not reach the native theme', () => {+ assert.equal(nativeThemeSource('dark'), 'dark')+ assert.equal(nativeThemeSource('system'), 'system')+ assert.equal(nativeThemeSource('moonlight'), undefined)+ assert.equal(nativeThemeSource(null), undefined)+})diff --git a/docs/dev/release-checklist.md b/docs/dev/release-checklist.mdindex a821849b..b0ced1e5 100644--- a/docs/dev/release-checklist.md+++ b/docs/dev/release-checklist.md@@ -139,15 +139,17 @@ CI 只跑单元测试和 Linux 上的测试台。窗口外框、输入法、高## 12. 桌面应用(Windows)-12.4 和 12.5 要在 Release 发布、工作流传完安装包之后做:Release 里要有安装包、它的 `.blockmap` 和 `latest.yml`。上一个发布版本没有安装包时,跳过这两项。+12.6 和 12.7 要在 Release 发布、工作流传完安装包之后做:Release 里要有安装包、它的 `.blockmap` 和 `latest.yml`。上一个发布版本没有安装包时,跳过这两项。| # | 步骤 | 期望 | 结果 ||---|---|---|---|| 12.1 | 运行安装包,选安装位置,安装 | 不要管理员权限;只装给当前用户;开始菜单里有 DeepSeek Bot | || 12.2 | 第一次打开:选数据位置和 Bot 工作文件夹;有 DSH 团队时选复制 | 团队、对话、模型设置都在;DSH 里原来的团队不变 | || 12.3 | 给一个 Bot 发消息;再打开设置 → 关于 DS Bot | 收到回复;DS Bot 一行写「随 DeepSeek Bot 应用一起更新。」 | |-| 12.4 | 装上一个发布版本的 App,打开它,等它提示新版本已经下载好,选「立即重启」 | App 关掉后自己装好新版并重新打开;关于页里是新版本号;团队都在 | |-| 12.5 | 再装一次上一个版本,等下载好的提示,选「稍后」,退出 App,等半分钟再打开 | 打开的是新版 | |+| 12.4 | 看窗口:拖标题栏,双击标题栏,点最小化、最大化、关闭;切换浅色和深色 | 没有系统边框;拖得动,双击会最大化,最大化后顶部没有缝;三个按钮都能用,底色和下面的界面一样;Windows 11 上侧栏透出 Mica,Windows 10 上标题栏和侧栏同色 | |+| 12.5 | 按 `Ctrl+Alt+B` | 侧栏收起,再按一次展开 | |+| 12.6 | 装上一个发布版本的 App,打开它,等它提示新版本已经下载好,选「立即重启」 | App 关掉后自己装好新版并重新打开;关于页里是新版本号;团队都在 | |+| 12.7 | 再装一次上一个版本,等下载好的提示,选「稍后」,退出 App,等半分钟再打开 | 打开的是新版 | |## 13. 桌面应用(macOS)diff --git a/docs/plans/2026-10-16-desktop-app.md b/docs/plans/2026-10-16-desktop-app.mdindex ed8e0bdc..091f1e67 100644--- a/docs/plans/2026-10-16-desktop-app.md+++ b/docs/plans/2026-10-16-desktop-app.md@@ -18,7 +18,7 @@| 部分 | 做什么 ||---|---|-| 壳 | Electron 主进程。只开一个实例;窗口用 `dsh-app://app` 加载 DSH 的网页前端,把请求转发给引擎;管引擎进程的启动和退出。窗口用系统标题栏 |+| 壳 | Electron 主进程。只开一个实例;窗口用 `dsh-app://app` 加载 DSH 的网页前端,把请求转发给引擎;管引擎进程的启动和退出。窗口见下面「窗口」一节 || 引擎 | 子进程,用 Electron 自带的 Node 运行。通过 `@deepseek-ai/dsh/profile-boot` 的 `runProfile()` 启动 profile `ds-bot`,只监听 `127.0.0.1` 上系统分配的端口。环境变量 `DS_BOT_APP=1` 告诉 ds-bot 它跑在桌面应用里 || 界面 | DSH 的网页前端加上 `ds-bot` 插件,和插件版一样 |@@ -26,6 +26,13 @@- 安装包和 `ds-bot` 用同一个版本号。- 引擎的 profile 由三个 bundle 叠成:DSH 的 `dsh-base`、DSH 的网页前端 `dsh-web-app`、`ds-bot`,用户装的插件排在后面。每次启动时,引擎把这三个 bundle 排回最前面。+### 窗口++- Windows:窗口无边框,和 DSH Desktop 一样。标题栏并进页面,系统的最小化、最大化、关闭按钮留在右上角,颜色和它下面的界面一致,跟着主题变。拖标题栏移动窗口,双击最大化。+- Windows 11(22H2 及以后):侧栏用 Mica 材质,一直通到窗口顶部;对话区也到顶,左上角是圆角,系统按钮在对话区上。Windows 10 上标题栏和侧栏同色、不透明。+- 页面仍是 DSH 网页前端的网页模式,快捷键和网页版一样。+- macOS:系统标题栏。+### 模型- 模型服务商和 key 在 DSH 自己的设置里配,存在桌面应用的数据位置里,和插件版一样。@@ -92,6 +99,7 @@- 还没有:在设置里改数据位置和 Bot 工作文件夹。- 第一次运行:Windows 会弹出 SmartScreen 警告,macOS 要在系统设置里手动放行。- macOS 上关掉窗口就退出应用(和 Windows 一样),Dock 里不留着。+- macOS 上窗口还有系统标题栏。无边框要让页面进入 DSH 的 macOS 桌面模式,那时快捷键改由原生菜单输入,应用要提供 DSH Desktop 那样的键盘桥。- 会话里记着工作文件夹的完整路径,不能改。所以导入和搬工作文件夹都要换段。- 安装的 `@deepseek-ai/dsh` 包带着 Office 套件和语音包,所以安装包里仍有这些文件,只是不加载。@@ -111,3 +119,4 @@- 2026-10-19:锁定的 DSH 升到 0.2.1-rc.2;锁定版跟上 DSH Desktop 提供的 rc 版本,PR #336。- 2026-10-19:复制团队前用锁定版把每段对话读一遍,有新版 DSH 写的对话时停下来,PR #340。- 2026-10-20:首次启动没走完就退出时什么都不记,下次从头再问;欢迎框加「退出」;复制停在安全的地方,不留半个团队,PR #360。+- 2026-10-20:Windows 上窗口无边框,Windows 11 上侧栏用 Mica;macOS 仍用系统标题栏,Issue #362。