Skip to content

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

Say on the start page where the data goes, with a way to change it

AdamPlatin123db13116f652d
diff --git a/README.md b/README.md
index a568902c..cc611d84 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ The desktop app brings its own DSH, so you don't need to install DSH first. Down
- macOS: `DeepSeek-Bot-<version>-mac-arm64.zip` for an Apple chip, `DeepSeek-Bot-<version>-mac-x64.zip` for Intel. Safari unzips it by itself; drag **DeepSeek Bot** into **Applications** and open it. When macOS says it cannot check the app, open **System Settings** → **Privacy & Security** and select **Open Anyway**.
- Linux (x64): `DeepSeek-Bot-<version>-linux-x86_64.AppImage` runs on every distribution — make it executable and open it. It mounts through FUSE 2, which you may need to install first (`sudo apt install libfuse2t64` on Ubuntu 24.04+, `sudo dnf install fuse-libs` on Fedora, `sudo pacman -S fuse2` on Arch). On Ubuntu 24.04 and later an AppImage can refuse to start (Ubuntu restricts the sandbox it needs); the `DeepSeek-Bot-<version>-linux-amd64.deb` on Debian/Ubuntu does not have this problem and adds a menu entry.
-At the first start the app asks where to keep its data and the Bots' files, and offers to copy a Bot team from your DSH (it only reads your DSH). Set up a model in its settings. The Windows app and the Linux AppImage update themselves; the macOS app and the Linux deb tell you when a new version is ready to download.
+At the first start the app keeps its data and the Bots' files in your home folder; the start window says where and lets you change it in one click. It offers to copy a Bot team from your DSH (it only reads your DSH). Set up a model in its settings. The Windows app and the Linux AppImage update themselves; the macOS app and the Linux deb tell you when a new version is ready to download.
If the app does not download, install or start, [report an install problem](https://github.com/Fei2411/DS-Bot/issues/new?template=install.yml); it needs no diagnostics.
diff --git a/README.zh.md b/README.zh.md
index 9b220e59..d7465835 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -52,7 +52,7 @@ DS Bot 是一个基于 [DeepSeek Harness](https://github.com/deepseek-ai/deepsee
- macOS:Apple 芯片下载 `DeepSeek-Bot-<版本>-mac-arm64.zip`,Intel 下载 `DeepSeek-Bot-<版本>-mac-x64.zip`。Safari 会自动解压;把 **DeepSeek Bot** 拖进 **应用程序**,再打开。如果提示无法检查这个 App,打开 **系统设置** → **隐私与安全性**,点 **仍要打开**。
- Linux(x64):`DeepSeek-Bot-<版本>-linux-x86_64.AppImage` 通用于所有发行版——加上可执行权限后打开即可。它通过 FUSE 2 挂载,可能需要先安装(Ubuntu 24.04+ 用 `sudo apt install libfuse2t64`,Fedora 用 `sudo dnf install fuse-libs`,Arch 用 `sudo pacman -S fuse2`)。Ubuntu 24.04 及以后版本会限制 AppImage 需要的沙箱,AppImage 可能因此拒绝启动;Debian/Ubuntu 上的 `DeepSeek-Bot-<版本>-linux-amd64.deb` 没有这个问题,还会加菜单项。
-第一次打开时,App 会问数据和 Bot 的文件放在哪里,并可以从你的 dsh 复制 Bot 团队(只读取你的 dsh,不改它)。在 App 的设置里配好模型就能用。Windows 版和 Linux 的 AppImage 会自动更新;macOS 版和 Linux 的 deb 有新版本时会提示你下载。
+第一次打开时,App 把数据和 Bot 的文件放在你的用户文件夹里,启动窗口上写着放在哪,点一下就能换;并可以从你的 dsh 复制 Bot 团队(只读取你的 dsh,不改它)。在 App 的设置里配好模型就能用。Windows 版和 Linux 的 AppImage 会自动更新;macOS 版和 Linux 的 deb 有新版本时会提示你下载。
下载不了、装不上或打不开时,[报告安装问题](https://github.com/Fei2411/DS-Bot/issues/new?template=install.yml),不需要诊断信息。
diff --git a/app/README.md b/app/README.md
index 34f9d30a..36e201aa 100644
--- a/app/README.md
+++ b/app/README.md
@@ -25,7 +25,7 @@ On macOS, Electron's default `userData` directory for `productName` "DeepSeek Bo
## First start and import
-At its first start the app asks, in system dialogs, for the data location (`~/.ds-bot` by default) and the team workspace (`~/DeepSeek Bot`), and keeps the answer in `locations.json` in its own data. Neither folder may be inside the other or inside the user's DSH data.
+At its first start the app uses the default data location (`~/.ds-bot`) and team workspace (`~/DeepSeek Bot`) without asking, and keeps them in `locations.json` in its own data. The start window says where the data goes and how much room the drive has, with 「换个位置…」: the system folder picker opens only on that click, and the one folder picked gives the root (`src/place.mjs`, the rule of the Windows onboarding note): the folder itself when it is new or empty, otherwise `DeepSeek Bot` inside it, as inside a drive; the data goes to `<root>/data` and the Bots' files to `<root>/workspace`. A root the app added is confirmed on a card; a place without write access, inside OneDrive, inside the user's DSH data or inside the program folder is refused with the reason. The start then begins again in the new folder, and the folders this start made at the default place go away. Once a team has been copied in, the line goes, and the data moves through Settings. The offer to copy a team is still a dialog. Neither folder may be inside the other or inside the user's DSH data.
Both change later in DS Bot's Settings > General > Locations. The plugin moves the team workspace and tells the app, which writes it into `locations.json`. The app names the user's DSH data to the plugin (`DS_BOT_USER_DSH_HOME`), so that neither the team workspace nor a Bot's folder can be set there. The data location moves through the app (`src/move-data.mjs`): the new folder must be empty or new and apart from the old data, the team workspace, the user's DSH data and the program folder. The app stops the Host, copies the data (without the team's lock) into a staging folder beside the new one, renames it to the new folder once it is whole, writes `locations.json` and starts again. A failed or interrupted copy leaves the old location in use and removes the staging folder; the old folder always stays. A run on throwaway folders (`DS_BOT_HOME`) keeps its data location.
@@ -122,7 +122,8 @@ The script serves a releases list with one release of that version that has this
| `src/profile.mjs` | The profiles: the app's own and the first-run check's, their bundles, and their creation and update |
| `src/app-patch.mjs` | The app's own profile overlay (`profiles/app-onboarding.patch.yml`, passed through `patchFiles`): it turns off DSH Web's automatic credential step (`credentialOnboarding: false`), since models are set up in DS Bot's Models page and the Main Bot's key card |
| `src/session-check.mjs` | Which chats the pinned DSH refuses because a newer DSH wrote them |
-| `src/first-run.mjs` | The first start's dialogs (the two folders and the offer to import) and the texts of the data move |
+| `src/first-run.mjs` | The first start's places (the defaults, the saved ones, the folder picker of 「换个位置…」), its offer to import, and the texts of the data move |
+| `src/place.mjs` | The place line of the start page (drive, free space) and the root rule of a picked folder |
| `src/import.mjs` | The import of a Bot team from the user's DSH |
| `src/move-data.mjs` | The move of the data location: which folders can take it, and the copy through a staging folder |
| `src/updates.mjs` | The self-updates (Windows installer, Linux AppImage) and the release-page checks (macOS, Linux deb) |
diff --git a/app/src/first-run.mjs b/app/src/first-run.mjs
index 00fa8cc6..4f589cd5 100644
--- a/app/src/first-run.mjs
+++ b/app/src/first-run.mjs
@@ -1,20 +1,16 @@
-// The first start: where the app keeps its data and the Bots' files, and whether it copies the
-// Bot team of the user's own DSH. The answers are kept in the app's own data.
+// The first start: where the app keeps its data and the Bots' files (the default places, or the
+// one folder picked from the start page), and whether it copies the Bot team of the user's own
+// DSH. The answers are kept in the app's own data.
import { app, dialog } from 'electron'
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
import { homedir } from 'node:os'
import { dirname, join } from 'node:path'
-import { findTeam, newerSessions, teamInUse, userDshHome, within } from './import.mjs'
+import { findTeam, newerSessions, teamInUse, userDshHome } from './import.mjs'
import { installFolder } from './move-data.mjs'
const TEXT = {
en: {
- welcome: 'Welcome to DeepSeek Bot',
- places: (data, workspace) => `Data: ${data}\nTeam workspace: ${workspace}`,
- start: 'Start', change: 'Change…',
- pickData: 'Folder for DeepSeek Bot data', pickWorkspace: 'Folder for the team workspace',
- dataInWorkspace: 'The data folder cannot be inside the team workspace.',
- workspaceInData: 'The team workspace cannot be inside the data folder.',
+ pickRoot: 'Where DeepSeek Bot keeps its data',
inDsh: home => `Choose a folder outside the DeepSeek Harness data (${home}).`,
inProgram: 'Choose a folder outside the program folder: uninstalling removes it.',
pickMove: 'New folder for DeepSeek Bot data',
@@ -37,12 +33,7 @@ const TEXT = {
failed: message => `The team could not be copied: ${message}\n\nDeepSeek Bot starts with a new team. The team in DeepSeek Harness is unchanged.`,
},
zh: {
- welcome: '欢迎使用 DeepSeek Bot',
- places: (data, workspace) => `数据:${data}\n总工作区:${workspace}`,
- start: '开始使用', change: '更改位置…',
- pickData: '选择 DeepSeek Bot 的数据文件夹', pickWorkspace: '选择总工作区的文件夹',
- dataInWorkspace: '数据文件夹不能放在总工作区里面。',
- workspaceInData: '总工作区不能放在数据文件夹里面。',
+ pickRoot: '选择 DeepSeek Bot 放数据的位置',
inDsh: home => `请选择 DeepSeek Harness 数据(${home})以外的文件夹。`,
inProgram: '请选择程序文件夹以外的位置:卸载时会删掉程序文件夹。',
pickMove: '选择 DeepSeek Bot 数据的新文件夹',
@@ -84,25 +75,27 @@ async function ask(options, signal, ui) {
return response
}
-async function pick(title, current, signal, ui) {
- const { canceled, filePaths } = await ui.asking(dialog.showOpenDialog(ui.owner(), { title, defaultPath: existsSync(current) ? current : dirname(current), properties: ['openDirectory', 'createDirectory', 'promptToCreate'] }))
+async function pick(title, from, signal, ui) {
+ const { canceled, filePaths } = await ui.asking(dialog.showOpenDialog(ui.owner(), { title, defaultPath: existsSync(from) ? from : dirname(from), properties: ['openDirectory', 'createDirectory', 'promptToCreate'] }))
await new Promise(resolve => setImmediate(resolve))
if (signal.aborted) throw new Quit()
- return canceled ? current : filePaths[0]
+ return canceled ? undefined : filePaths[0]
}
export const programFolder = () => installFolder(app.getPath('exe'))
-function placeProblem(t, dataDir, workspace) {
- const dsh = userDshHome()
- const program = programFolder()
- if (within(dataDir, workspace)) return t.dataInWorkspace
- if (within(workspace, dataDir)) return t.workspaceInData
- for (const path of [dataDir, workspace]) {
- if (within(path, dsh) || within(dsh, path)) return t.inDsh(dsh)
- if (app.isPackaged && within(path, program)) return t.inProgram
+/**
+ * The system picker of 「换个位置…」 on the start page: one folder, from which the root rule
+ * (place.mjs) makes the places. Undefined when the box was cancelled or the app is quitting.
+ * @param {string} from the folder the picker opens in
+ */
+export async function pickRoot(from, signal, ui) {
+ try {
+ return await pick(text().pickRoot, from, signal, ui)
+ } catch (error) {
+ if (error instanceof Quit) return undefined
+ throw error
}
- return undefined
}
/** The places a first start offers. */
@@ -161,9 +154,11 @@ export function saveLocations({ dataDir, workspace }) {
}
/**
- * Where the app keeps its data and the Bots' files, asked at the first start in dialogs that
- * belong to `ui.owner()`. A run on throwaway folders (DS_BOT_HOME, for development and tests)
- * asks nothing and copies nothing. `offered` says whether the first run offered to copy a team.
+ * Where the app keeps its data and the Bots' files: the saved places, or at the first start the
+ * default ones without a question (the start page says where the data goes and offers
+ * 「换个位置…」; windows-onboarding §3). The offer to copy a team is still a dialog that belongs
+ * to `ui.owner()`. A run on throwaway folders (DS_BOT_HOME, for development and tests) asks
+ * nothing and copies nothing. `offered` says whether the first run offered to copy a team.
* @param {AbortSignal} signal
* @param {{ owner: () => import('electron').BrowserWindow | undefined, asking: <T>(answer: Promise<T>) => Promise<T> }} ui
* @returns {Promise<{ dataDir: string, workspace?: string, import?: { from: string, profile?: string }, offered?: boolean, quit?: true }>}
@@ -175,23 +170,10 @@ export async function chooseLocations(signal, ui) {
const saved = JSON.parse(readFileSync(file, 'utf8'))
return { dataDir: saved.dataDir, workspace: saved.workspace }
}
- const t = text()
- let { dataDir, workspace } = defaultPlaces()
+ const { dataDir, workspace } = defaultPlaces()
let offered
try {
- for (;;) {
- const choice = await ask({ type: 'info', message: t.welcome, detail: t.places(dataDir, workspace), buttons: [t.start, t.change, t.quit], defaultId: 0, cancelId: 2 }, signal, ui)
- if (choice === 2) return { quit: true }
- if (choice === 1) {
- dataDir = await pick(t.pickData, dataDir, signal, ui)
- workspace = await pick(t.pickWorkspace, workspace, signal, ui)
- continue
- }
- const problem = placeProblem(t, dataDir, workspace)
- if (problem === undefined) break
- await ask({ type: 'warning', message: problem, buttons: ['OK'] }, signal, ui)
- }
- const offer = await offerImport(t, dataDir, signal, ui)
+ const offer = await offerImport(text(), dataDir, signal, ui)
if (offer.quit) return { quit: true }
if (offer.import !== undefined) return { dataDir, workspace, import: offer.import, offered: true }
offered = offer.offered
diff --git a/app/src/host-process.mjs b/app/src/host-process.mjs
index d2f64cb1..d000e356 100644
--- a/app/src/host-process.mjs
+++ b/app/src/host-process.mjs
@@ -72,13 +72,20 @@ export class HostProcess {
this.#child.send(message)
}
- /** Ask the Host to shut down, then end it if it does not exit in time. */
- async stop() {
+ /**
+ * Ask the Host to shut down, then end it if it does not exit in time. With `now`, it is ended
+ * at once instead: a start that goes on in another folder has no use for this Host's boot or
+ * for an orderly shutdown of its data, which goes away with it.
+ */
+ async stop({ now = false } = {}) {
const child = this.#child
if (child === undefined) return
this.#stopping = true
- if (child.connected) child.send({ type: 'shutdown' }, (error) => { if (error) console.error(error) })
- if (!await settlesWithin(this.#exit, 10_000)) child.kill()
+ if (now) child.kill()
+ else {
+ if (child.connected) child.send({ type: 'shutdown' }, (error) => { if (error) console.error(error) })
+ if (!await settlesWithin(this.#exit, 10_000)) child.kill()
+ }
if (!await settlesWithin(this.#exit, 5_000)) child.kill('SIGKILL')
this.#child = undefined
}
diff --git a/app/src/main.mjs b/app/src/main.mjs
index a63505f8..0c5c2899 100644
--- a/app/src/main.mjs
+++ b/app/src/main.mjs
@@ -14,6 +14,7 @@ import { fileURLToPath } from 'node:url'
import { canonicalExecPath } from './canonical-path.mjs'
import { hostPort } from './host-port.mjs'
import { captureStdio, LogFile } from './logs.mjs'
+import { currentRootOf, driveOf, formatBytes, freeSpace, isEmptyTree, pickFrom, placeOf, rootOf } from './place.mjs'
import { readStartFrame, writeStartFrame } from './start-frame.mjs'
import { explainOf, StartWindow } from './start-window.mjs'
import { CAPTION_HEIGHT, cssColor, micaAvailable, nativeThemeSource } from './window-frame.mjs'
@@ -40,6 +41,8 @@ const IMPORT_FILE_MAX = 32 * 1024 * 1024
const MOVE_PROBLEMS = { drive: 'moveDrive', nested: 'moveNested', workspace: 'moveWorkspace', program: 'inProgram', notEmpty: 'moveNotEmpty' }
const UPDATE_CHECK_WAIT_MS = 15_000
const UPDATE_DOWNLOAD_WAIT_MS = 15 * 60_000
+// Under this, the start page notes the drive's free space for the first 10 s (onboarding §3).
+const SHORT_DRIVE_BYTES = 5e9
const here = dirname(fileURLToPath(import.meta.url))
// Drawn by scripts/icon.mjs. Windows takes the .ico for its several sizes.
@@ -51,7 +54,7 @@ const frameFile = join(app.getPath('userData'), 'start-frame.json')
// Loaded once the start window is up (loadModules).
let BotBrowserGuests, partitionOf, BotViews, isBotId, importFromBrowser, listSources, applyCookies, CookieImports, parseCookieFile
-let downloadSaver, chooseLocations, localeText, programFolder, saveLocations, teamIn, teamsAt, text, HostProcess
+let downloadSaver, chooseLocations, defaultPlaces, localeText, pickRoot, programFolder, saveLocations, teamIn, teamsAt, text, HostProcess
let copySessions, findTeam, importTeam, teamInUse, userDshHome, copyData, moveProblem, CHECK_PROFILE, PROFILE
let UPDATE_TEXT, watchReleases, watchUpdates, getDshRuntimeVersion, electronUpdater
@@ -73,6 +76,13 @@ let stopping = false
let stopped = false
let failed = false
let places
+// Which of the places this start made, so that 「换个位置…」 can take them away again.
+let made = { dataDir: false, workspace: false, root: false }
+// The folder picker of 「换个位置…」 is open, and the root it proposed on the 「会放在…」 card.
+let picking = false
+let proposed
+// A retry or a start over is stopping the old engine: no second one starts meanwhile.
+let restarting = false
// The first run's answer to the import; only the first boot copies.
let pendingImport
// Each boot of the engine; a retry starts a new one, and what an old one still reports is dropped.
@@ -112,6 +122,8 @@ if (canonical !== undefined) {
onReload: () => { mainWindow?.webContents.reload() },
// Closing the start window before the hand-off quits, as closing the team window does.
onClose: () => { app.quit() },
+ onPick: () => { changePlace().catch(fail) },
+ onAnswer: (value) => { placeAnswer(value).catch(fail) },
})
app.on('second-instance', focusWindow)
app.on('window-all-closed', () => { app.quit() })
@@ -183,7 +195,7 @@ async function loadModules() {
;({ applyCookies, CookieImports } = cookies)
;({ parseCookieFile } = cookieFiles)
;({ downloadSaver } = downloads)
- ;({ chooseLocations, localeText, programFolder, saveLocations, teamIn, teamsAt, text } = firstRun)
+ ;({ chooseLocations, defaultPlaces, localeText, pickRoot, programFolder, saveLocations, teamIn, teamsAt, text } = firstRun)
;({ HostProcess } = hostProcess)
;({ copySessions, findTeam, importTeam, teamInUse, userDshHome } = imports)
;({ copyData, moveProblem } = moves)
@@ -208,28 +220,48 @@ function run() {
// The engine starts again after a failure or the 180 s question; the places stay. A first run's
// copy goes on to its end first: an engine started beside it would run on a half-copied team.
async function retry() {
- attempt += 1
+ const mine = (attempt += 1)
failed = false
- await copying?.catch(() => {})
- if (copyAbort.signal.aborted || stopping) return
+ proposed = undefined
+ restarting = true
+ try {
+ await copying?.catch(() => {})
+ if (copyAbort.signal.aborted || stopping || mine !== attempt) return
+ await stopOld()
+ if (stopping || mine !== attempt) return
+ await prepare()
+ } finally {
+ restarting = false
+ }
+ if (!stopping && mine === attempt) run()
+}
+
+// The Host stays known while it stops, so that a quit meanwhile waits for it.
+async function stopOld(options) {
const old = host
- host = undefined
- await old?.stop().catch((error) => { console.error(error) })
- await prepare()
- run()
+ if (old === undefined) return
+ await old.stop(options).catch((error) => { console.error(error) })
+ if (host === old) host = undefined
}
-// The data folder (with the first run's questions on a first start), the engine, then the team
+// The dialogs of the first run belong to the start window and stop its clock.
+const ui = () => ({ owner: () => startWindow.owner(), asking: answer => startWindow.asking(answer) })
+
+// The data folder (with the first run's question on a first start), the engine, then the team
// view in the hidden team window.
async function boot(mine) {
if (places === undefined) {
const first = startWindow.kind === 'first'
- if (first) startWindow.explain(explainOf(teamsAt()))
+ if (first) {
+ const teams = teamsAt()
+ startWindow.explain(explainOf(teams))
+ // A reinstall goes on with its data where it is; a new or copied team can still move.
+ if (teams.team === undefined) tellPlace(defaultPlaces().dataDir)
+ }
choosing = new AbortController()
- const ui = { owner: () => startWindow.owner(), asking: answer => startWindow.asking(answer) }
- const where = await chooseLocations(choosing.signal, ui).finally(() => { choosing = undefined })
+ const where = await chooseLocations(choosing.signal, ui()).finally(() => { choosing = undefined })
if (where.quit) { app.exit(0); return }
- places = { dataDir: where.dataDir, workspace: where.workspace }
+ setPlaces({ dataDir: where.dataDir, workspace: where.workspace })
pendingImport = where.import
if (first) startWindow.explain(explainOf({ offered: where.offered === true, team: teamIn(where.dataDir) }))
}
@@ -246,6 +278,110 @@ async function boot(mine) {
void mainWindow.loadURL(engine.url).catch(() => {})
}
+function setPlaces(next) {
+ places = next
+ const root = currentRootOf(places.dataDir, places.workspace)
+ made = { dataDir: !existsSync(places.dataDir), workspace: places.workspace !== undefined && !existsSync(places.workspace), root: root !== undefined && !existsSync(root) }
+}
+
+// The line on the start page that says where the data goes and how much room is there, and the
+// short drive's note for the first 10 s (start-window §2, §4).
+function tellPlace(dataDir) {
+ const free = freeSpace(dataDir)
+ startWindow.place(placeOf(dataDir, { free }))
+ const drive = driveOf(dataDir)
+ startWindow.hint(drive !== undefined && free !== undefined && free < SHORT_DRIVE_BYTES ? { drive, free: formatBytes(free) } : undefined)
+}
+
+// 「换个位置…」 on the start page and 〔重新选〕 on its cards: the system picker, then the root rule
+// (windows-onboarding §3, 一个位置). The root is used at once when it is the folder picked; a
+// layer the app added is confirmed on the 「会放在…」 card; a place that cannot be used says why.
+// A cancelled picker leaves things as they were: the line, or the card it came from. Not during
+// the first run's copy, whose team would be left behind.
+async function changePlace() {
+ if (startWindow.kind !== 'first' || places === undefined || choosing !== undefined || copying !== undefined || picking || restarting || stopping || failed) return
+ picking = true
+ try {
+ // One wait for the picker and what follows it: a team view that becomes ready meanwhile
+ // hands over only once the start knows where it goes on.
+ await startWindow.asking(pickAndPlace())
+ } finally {
+ picking = false
+ }
+}
+
+// A cancelled picker, or the place the data is in now, is no change: the line stays, and a card
+// that led here goes, since the start goes on where it was.
+async function pickAndPlace() {
+ const picked = await pickRoot(pickFrom(places.dataDir), copyAbort.signal, ui())
+ if (stopping || startWindow.owner() === undefined) return
+ const root = picked === undefined ? { same: true } : rootOf(picked, { dshHome: userDshHome(), program: app.isPackaged ? programFolder() : undefined, current: places })
+ if (root.same) {
+ proposed = undefined
+ startWindow.card(undefined)
+ return
+ }
+ if (root.reason !== undefined) {
+ console.log(`DeepSeek Bot: the place ${root.at} cannot be used (${root.reason})`)
+ proposed = undefined
+ startWindow.card({ kind: 'rejected', reason: root.reason, path: root.at })
+ return
+ }
+ if (root.added) {
+ proposed = root
+ startWindow.card({ kind: 'picked', path: root.root })
+ return
+ }
+ await startOver(root)
+}
+
+async function placeAnswer(value) {
+ if (value !== 'use' || proposed === undefined || picking || restarting) return
+ const root = proposed
+ proposed = undefined
+ await startOver(root)
+}
+
+// The start begins again in the root R (start-window §7): the whale sinks at once, the engine
+// that may be up on the default folder stops, what this start made there goes, and the boot runs
+// again. The places are saved at once: the import question has been answered by now.
+async function startOver(root) {
+ const mine = (attempt += 1)
+ failed = false
+ proposed = undefined
+ restarting = true
+ try {
+ // restart() also takes the card away, without letting a held hand-off of the old engine go;
+ // the line names the new place from here on. The Host on the old folder is ended at once:
+ // neither its boot nor an orderly shutdown of a folder about to go is of any use, and either
+ // would keep the whale under water for up to 10 s.
+ startWindow.restart()
+ tellPlace(root.dataDir)
+ await stopOld({ now: true })
+ if (stopping || mine !== attempt) return
+ await removeMade()
+ if (stopping || mine !== attempt) return
+ setPlaces({ dataDir: root.dataDir, workspace: root.workspace })
+ saveLocations(places)
+ console.log(`DeepSeek Bot: the data goes to ${places.dataDir}`)
+ } finally {
+ restarting = false
+ }
+ run()
+}
+
+// What this start made at the place it leaves: the data folder it created (the engine may have
+// put a blank team there), the team workspace while nothing has been written into it, and the
+// root above them once it is empty.
+async function removeMade() {
+ const gone = []
+ if (made.dataDir && existsSync(places.dataDir)) gone.push(places.dataDir)
+ if (made.workspace && existsSync(places.workspace) && isEmptyTree(places.workspace)) gone.push(places.workspace)
+ for (const folder of gone) await rm(folder, { recursive: true, force: true, maxRetries: 5 }).catch((error) => { console.error(error) })
+ const root = currentRootOf(places.dataDir, places.workspace)
+ if (made.root && root !== undefined && existsSync(root) && isEmptyTree(root)) await rm(root, { recursive: true, force: true, maxRetries: 5 }).catch((error) => { console.error(error) })
+}
+
const profileDir = () => join(places.dataDir, 'profiles', PROFILE)
const pnpmEntry = () => join(app.getAppPath(), 'node_modules', 'pnpm', 'bin', 'pnpm.mjs')
const hostOutput = (stream, chunk) => {
@@ -281,6 +417,8 @@ async function startEngine(mine) {
if (pendingImport !== undefined) {
const where = { ...places, import: pendingImport }
pendingImport = undefined
+ // The team is about to live here; moving it is Settings' job (the data move).
+ startWindow.place(undefined)
// The copy's time is not the engine's: the start's clock stands still, and the 180 s
// question with it.
copying = startWindow.asking(copyTeam(where, copyAbort.signal))
diff --git a/app/src/place.mjs b/app/src/place.mjs
new file mode 100644
index 00000000..cd87b9a9
--- /dev/null
+++ b/app/src/place.mjs
@@ -0,0 +1,183 @@
+// Where a first start puts the data: the line on the start page that says so, and the root rule
+// of 「换个位置…」 (windows-onboarding §3, 一个位置; start-window §6). No Electron here, so the
+// tests run without it.
+import { existsSync, mkdirSync, readdirSync, rmdirSync, rmSync, statfsSync, statSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { basename, dirname, join, parse, resolve, sep } from 'node:path'
+import { real, within } from './copy-tree.mjs'
+
+export const DATA_DIR = 'data'
+export const WORKSPACE_DIR = 'workspace'
+// The layer the app adds inside a drive or a folder that is someone else's.
+export const LAYER = 'DeepSeek Bot'
+
+/** Free bytes on the volume that holds `path`, measured at its nearest existing ancestor. */
+export function freeSpace(path) {
+ let at = resolve(path)
+ for (;;) {
+ if (existsSync(at)) {
+ try {
+ const stats = statfsSync(at)
+ return Number(stats.bavail) * Number(stats.bsize)
+ } catch {
+ return undefined
+ }
+ }
+ const up = dirname(at)
+ if (up === at) return undefined
+ at = up
+ }
+}
+
+/** Bytes as the page shows them, in Explorer's units of 1024: whole GB from 10 up, else one decimal. */
+export function formatBytes(bytes) {
+ if (typeof bytes !== 'number' || !Number.isFinite(bytes) || bytes < 0) return undefined
+ const gb = bytes / 2 ** 30
+ if (gb >= 10) return `${String(Math.floor(gb))} GB`
+ if (gb >= 1) return `${(Math.floor(gb * 10) / 10).toFixed(1)} GB`
+ return `${String(Math.floor(bytes / 2 ** 20))} MB`
+}
+
+/** The drive letter of a Windows path ('C'), or undefined. */
+export function driveOf(path) {
+ const match = /^([A-Za-z]):[\\/]/u.exec(resolve(path))
+ return match ? match[1].toUpperCase() : undefined
+}
+
+/** A path with the home folder written as ~, for the page. */
+export function shortPath(path, home = homedir()) {
+ const full = resolve(path)
+ const base = resolve(home)
+ if (full === base) return '~'
+ return within(full, base) ? `~${sep}${full.slice(base.length).replace(/^[\\/]+/u, '')}` : full
+}
+
+/**
+ * What the start page says about the place of the data: the drive and its free space on
+ * Windows, the folder elsewhere.
+ * @param {{ home?: string, free?: number }} what `free` from freeSpace(); none leaves it out
+ * @returns {{ drive?: string, path?: string, free?: string }}
+ */
+export function placeOf(dataDir, { home = homedir(), free } = {}) {
+ const drive = driveOf(dataDir)
+ const place = drive === undefined ? { path: shortPath(dataDir, home) } : { drive }
+ const text = formatBytes(free)
+ return text === undefined ? place : { ...place, free: text }
+}
+
+/** The root R of places made by the root rule (R\data beside R\workspace); the default places have none. */
+export function currentRootOf(dataDir, workspace) {
+ if (typeof dataDir !== 'string' || typeof workspace !== 'string') return undefined
+ const root = dirname(resolve(dataDir))
+ if (basename(resolve(dataDir)) !== DATA_DIR || basename(resolve(workspace)) !== WORKSPACE_DIR || dirname(resolve(workspace)) !== root) return undefined
+ return root
+}
+
+/** The picker starts from the current data folder's parent (windows-onboarding §3). */
+export const pickFrom = dataDir => dirname(resolve(dataDir))
+
+/** A folder with nothing but empty folders in it. */
+export function isEmptyTree(folder) {
+ try {
+ if (!statSync(folder).isDirectory()) return false
+ return readdirSync(folder).every(name => isEmptyTree(join(folder, name)))
+ } catch {
+ return false
+ }
+}
+
+// A folder that holds nothing but what the app itself puts into an empty root (the two
+// folders of a start that never got further).
+const ownEmpty = folder => readdirSync(folder).every(name => [DATA_DIR, WORKSPACE_DIR].includes(name) && isEmptyTree(join(folder, name)))
+
+// OneDrive's folders: the roots it names in the environment, a folder called OneDrive or
+// 「OneDrive - <organisation>」, and macOS's Library/CloudStorage/OneDrive-<name>. A folder that
+// only has OneDrive in its name (OneDrive-old) is not the cloud.
+function inOneDrive(path, env) {
+ const roots = ['OneDrive', 'OneDriveConsumer', 'OneDriveCommercial'].map(name => env[name]).filter(value => typeof value === 'string' && value !== '')
+ if (roots.some(root => within(path, root))) return true
+ const parts = path.split(/[\\/]/u)
+ return parts.some((part, k) => part === 'OneDrive' || part.startsWith('OneDrive - ') || (parts[k - 1] === 'CloudStorage' && part.startsWith('OneDrive-')))
+}
+
+const sameFolder = (a, b) => within(a, b) && within(b, a)
+
+/**
+ * The root R that a picked folder gives (windows-onboarding §3, 一个位置): the folder itself
+ * when it is new, empty, or an empty root of the app's own; otherwise `DeepSeek Bot` inside it,
+ * as inside a drive. The data goes to R\data and the Bots' files to R\workspace.
+ * @param {string} picked
+ * @param {{ dshHome?: string, program?: string, env?: NodeJS.ProcessEnv, probe?: boolean, current?: { dataDir: string, workspace?: string } }} where
+ * `probe` writes a file into R\data to see that the place can be written (default true);
+ * `current` names the places the data is in now
+ * @returns {{ same: true } | { root: string, dataDir: string, workspace: string, added: boolean, reason?: 'permission' | 'onedrive' | 'foreign' | 'nested' | 'dsh' | 'program', at?: string }}
+ * `same`: the place the data is in now was picked, which is no change; `reason` says why R
+ * cannot be used, with the path `at` that the card names
+ */
+export function rootOf(picked, { dshHome, program, env = process.env, probe = true, current } = {}) {
+ const chosen = resolve(picked)
+ const places = root => ({ root, dataDir: join(root, DATA_DIR), workspace: join(root, WORKSPACE_DIR) })
+ try {
+ // The places the data is in now: the data folder, and the team workspace once something
+ // is in it (an empty one, just made, can become the new root, as a pick of the home folder
+ // proposes with the default places).
+ const data = typeof current?.dataDir === 'string' ? real(current.dataDir) : undefined
+ const workspace = typeof current?.workspace === 'string' && existsSync(current.workspace) && !isEmptyTree(current.workspace) ? real(current.workspace) : undefined
+ const now = [data, workspace].filter(path => path !== undefined)
+ const nowRoot = currentRootOf(current?.dataDir, current?.workspace)
+ const physicalChosen = real(chosen)
+ if ([data, nowRoot === undefined ? undefined : real(nowRoot)].some(path => path !== undefined && sameFolder(physicalChosen, path))) return { same: true }
+ if (now.some(path => within(physicalChosen, path))) return { ...places(chosen), added: false, reason: 'nested', at: chosen }
+ const isDrive = parse(chosen).root === chosen
+ let root = chosen
+ let added = false
+ if (isDrive) {
+ root = join(chosen, LAYER)
+ added = true
+ } else if (existsSync(chosen)) {
+ if (!statSync(chosen).isDirectory()) return { ...places(root), added, reason: 'foreign', at: chosen }
+ if (readdirSync(chosen).length > 0 && !ownEmpty(chosen)) {
+ root = join(chosen, LAYER)
+ added = true
+ }
+ }
+ const result = { ...places(root), added }
+ const reject = (reason, at = root) => ({ ...result, reason, at })
+ // An added layer that is already someone else's folder cannot be used either.
+ if (added && existsSync(root) && (!statSync(root).isDirectory() || (readdirSync(root).length > 0 && !ownEmpty(root)))) return reject('foreign')
+ // The checks look through links and junctions at the folder as the file system has it.
+ const physical = real(root)
+ if (now.some(path => within(physical, path) || within(path, physical))) return reject('nested', chosen)
+ if (inOneDrive(physical, env)) return reject('onedrive', chosen)
+ if (dshHome !== undefined && existsSync(dshHome)) {
+ const dsh = real(dshHome)
+ if (within(physical, dsh) || within(dsh, physical)) return reject('dsh', chosen)
+ }
+ if (program !== undefined && within(physical, real(program))) return reject('program', chosen)
+ if (probe && !canWrite(result.dataDir)) return reject('permission', chosen)
+ return result
+ } catch {
+ // A folder that cannot be read (another user's, the system's) cannot be written either.
+ return { ...places(chosen), added: false, reason: 'permission', at: chosen }
+ }
+}
+
+// Makes only the missing layers, writes and removes a file, and removes what it made.
+function canWrite(folder) {
+ const made = []
+ try {
+ for (let at = resolve(folder); !existsSync(at); at = dirname(at)) {
+ made.unshift(at)
+ if (dirname(at) === at) break
+ }
+ mkdirSync(folder, { recursive: true })
+ const file = join(folder, '.ds-bot-write-check')
+ writeFileSync(file, '')
+ rmSync(file)
+ return true
+ } catch {
+ return false
+ } finally {
+ for (const at of [...made].reverse()) { try { rmdirSync(at) } catch { /* not empty: left as it is */ } }
+ }
+}
diff --git a/app/src/start-window.mjs b/app/src/start-window.mjs
index 655a4a05..0abebecd 100644
--- a/app/src/start-window.mjs
+++ b/app/src/start-window.mjs
@@ -37,6 +37,10 @@ const ACT_VIEWS = {
retry: ['failed', 'watchdog'],
wait: ['watchdog'],
reloadView: ['viewFailed'],
+ // 「换个位置…」 on the page (also under the 180 s question), and the cards it leads to
+ // (「会放在…」, a place that cannot be used).
+ pick: ['boot', 'card', 'watchdog'],
+ answer: ['card'],
openLogs: null,
copyDetails: null,
}
@@ -208,6 +212,8 @@ export function startSnapshot(state, now) {
celebrate: state.celebrate,
}
if (state.hint !== undefined) snapshot.hint = { ...state.hint }
+ if (state.place !== undefined) snapshot.place = { ...state.place }
+ if (state.card !== undefined) snapshot.card = { ...state.card }
if (state.failure !== undefined) snapshot.failure = { reason: state.failure.reason, log: [...state.failure.log] }
return snapshot
}
@@ -215,6 +221,8 @@ export function startSnapshot(state, now) {
export const detailsText = ({ version, platform, arch, reason, lines }) => [`DeepSeek Bot ${version} (${platform} ${arch})`, `reason: ${reason}`, '', ...lines].join('\n')
const note = message => { console.log(`DeepSeek Bot: start window: ${message}`) }
+// The page sends a button's detail as { value }; anything else counts as none.
+const valueOf = payload => (payload !== null && typeof payload === 'object' && typeof payload.value === 'string' ? payload.value.slice(0, 40) : undefined)
export class StartWindow {
#o
@@ -235,6 +243,11 @@ export class StartWindow {
// Whether the engine of this attempt is up; the stages done say where the whale is, which a
// retry never moves back.
#engineUp = false
+ // What a dialog of the window (the folder picker) or a card keeps waiting: the hand-off, which
+ // would take the window and the dialog's owner away, and the 20 s check's verdict.
+ #readyHeld = false
+ #heldAt = 0
+ #viewLate = false
#teamShown
#showTeam
@@ -246,8 +259,11 @@ export class StartWindow {
* log: { dir: string, tail: (count: number) => string[] },
* mainWindow: () => any,
* onRetry: () => void, onReload: () => void, onClose: () => void,
+ * onPick?: (value?: string) => void, onAnswer?: (value?: string) => void,
* }} options `lang` is asked at each open; `program` names the folders of the app's own files;
- * `onClose` runs when the user closes the start window before the hand-off.
+ * `onClose` runs when the user closes the start window before the hand-off; `onPick` when
+ * the page asks for the folder picker ('changePlace' from its place line, nothing from a
+ * card's 〔重新选〕), `onAnswer` with a card's answer ('use' for 〔继续〕 on 「会放在…」).
*/
constructor(options) {
this.#o = options
@@ -354,7 +370,53 @@ export class StartWindow {
if (this.#open()) this.#update({ explain: this.#explain })
}
- /** The clock stands still while the user answers a dialog: thinking time is not the engine's. */
+ /**
+ * The line that says where the data goes, with 「换个位置…」 (start-window §2): the drive and its
+ * free space, or the folder. Undefined takes the line away.
+ * @param {{ drive?: string, path?: string, free?: string } | undefined} place
+ */
+ place(place) {
+ if (this.#open()) this.#update({ place: place === undefined ? undefined : { ...place } })
+ }
+
+ /** A short drive's one-line note for the first 10 s (§4), or none. */
+ hint(hint) {
+ if (this.#open()) this.#update({ hint: hint === undefined ? undefined : { ...hint } })
+ }
+
+ /**
+ * A card on the sheet while the start boots (the clock stands still), or none: back to the
+ * boot. Only the cards of a place: 「会放在…」 and a place that cannot be used.
+ * @param {{ kind: 'picked' | 'rejected', path: string, reason?: string } | undefined} card
+ */
+ card(card) {
+ if (!this.#open() || !['boot', 'card', 'watchdog'].includes(this.#state.view)) return
+ if (card === undefined && this.#state.view !== 'card') return
+ // Back in the boot, a 180 s question that the card replaced comes straight back.
+ this.#update(card === undefined ? { view: 'boot', card: undefined } : { view: 'card', card: { ...card } })
+ if (card === undefined) this.#resume()
+ }
+
+ /**
+ * The start begins again in another folder (§7): the stages go back to the start, the whale
+ * sinks and surfaces at the first stop, and the clock starts from 0. The first success after
+ * it celebrates, as after a retry.
+ */
+ restart() {
+ if (!this.#open()) return
+ note('starting over in another folder')
+ this.#engineUp = false
+ this.#holdsOff()
+ this.#watchAt = WATCHDOG_MS
+ this.#phaseAt = Date.now()
+ this.#clear('teamView')
+ this.#update({ view: 'boot', done: [], card: undefined, failure: undefined, celebrate: true, clock: { base: 0, from: Date.now(), running: true } })
+ }
+
+ /**
+ * The clock stands still while the user answers a dialog: thinking time is not the engine's.
+ * The hand-off and the 20 s check wait for the answer too (see ready()).
+ */
async asking(promise) {
this.#asks += 1
this.#refresh()
@@ -363,9 +425,29 @@ export class StartWindow {
} finally {
this.#asks -= 1
this.#refresh()
+ this.#resume()
+ }
+ }
+
+ // What waited for the dialogs to close and the card to go.
+ #resume() {
+ if (this.#asks > 0 || !this.#open() || this.#state.view !== 'boot') return
+ if (this.#readyHeld) {
+ this.#readyHeld = false
+ note(`the hand-off waited ${String(Date.now() - this.#heldAt)} ms for the answer`)
+ this.ready()
+ } else if (this.#viewLate) {
+ this.#viewLate = false
+ this.#teamViewLate()
}
}
+ #holdsOff() {
+ if (this.#readyHeld) note(`the held hand-off is dropped after ${String(Date.now() - this.#heldAt)} ms: the start goes on elsewhere`)
+ this.#readyHeld = false
+ this.#viewLate = false
+ }
+
/** The data folder or the engine is ready; the engine also again after a retry. */
done(phase) {
if (!this.#open() || !['data', 'engine'].includes(phase)) return
@@ -381,17 +463,34 @@ export class StartWindow {
/** The engine's page started loading in the hidden team window: it has 20 s to call ready(). */
teamLoading() {
if (!this.#open()) return
- this.#later('teamView', TEAM_VIEW_MS, () => {
- if (this.#state.view !== 'boot') return
- note(`the team view did not call ready() within ${String(TEAM_VIEW_MS / 1000)} s`)
- this.#update({ view: 'viewFailed', failure: { reason: 'other', log: this.#o.log.tail(FAILURE_LINES) } })
- })
+ this.#later('teamView', TEAM_VIEW_MS, () => { this.#teamViewLate() })
+ }
+
+ #teamViewLate() {
+ if (!['boot', 'card'].includes(this.#state.view)) return
+ // A dialog or a card is up: the verdict waits for the answer (#resume).
+ if (this.#asks > 0 || this.#state.view === 'card') { this.#viewLate = true; return }
+ note(`the team view did not call ready() within ${String(TEAM_VIEW_MS / 1000)} s`)
+ this.#update({ view: 'viewFailed', failure: { reason: 'other', log: this.#o.log.tail(FAILURE_LINES) } })
}
- /** dsBotApp.ready() from the team view: the hand-off starts. */
+ /**
+ * dsBotApp.ready() from the team view: the hand-off starts. While a dialog of the window or
+ * a card is up (the folder picker, 「会放在…」), it waits: the hand-off would take the window,
+ * and with it the dialog's owner, away while the user is still choosing where the data goes.
+ */
ready() {
- if (!this.#open() || !['boot', 'viewFailed'].includes(this.#state.view) || !this.#engineUp) return
+ if (!this.#open() || !['boot', 'card', 'viewFailed'].includes(this.#state.view) || !this.#engineUp) return
this.#clear('teamView')
+ if (this.#asks > 0 || this.#state.view === 'card') {
+ if (!this.#readyHeld) {
+ note('the team view is ready; the hand-off waits for the answer')
+ this.#heldAt = Date.now()
+ }
+ this.#readyHeld = true
+ return
+ }
+ this.#readyHeld = false
const now = Date.now()
note(`team took ${String(now - this.#phaseAt)} ms`)
this.#readyAt = now
@@ -420,6 +519,7 @@ export class StartWindow {
}
if (!this.#open()) this.open(showing || this.#state === undefined ? kind : this.#state.start)
this.#cancelHandoff()
+ this.#holdsOff()
this.#clear('teamView')
this.#clear('fallback')
this.#update({ view: 'failed', failure: { reason: failureReason(error, { program: this.#o.program }), log: this.#o.log.tail(FAILURE_LINES) } })
@@ -454,6 +554,7 @@ export class StartWindow {
this.#handing = false
this.#revealed = false
this.#engineUp = false
+ this.#holdsOff()
this.#watchAt = WATCHDOG_MS
const now = Date.now()
this.#phaseAt = now
@@ -462,7 +563,7 @@ export class StartWindow {
view: start === 'moving' ? 'moving' : 'boot',
done: [], explain: this.#explain, celebrate: start === 'first',
clock: { base: 0, from: now, running: true },
- hint: undefined, failure: undefined,
+ hint: undefined, place: undefined, card: undefined, failure: undefined,
}
this.#refresh()
}
@@ -512,6 +613,8 @@ export class StartWindow {
else if (name === 'reloadView') this.#reload()
else if (name === 'openLogs') this.#openLogs()
else if (name === 'copyDetails') this.#copyDetails()
+ else if (name === 'pick') this.#o.onPick?.(valueOf(payload))
+ else if (name === 'answer') this.#o.onAnswer?.(valueOf(payload))
return true
}
@@ -521,6 +624,7 @@ export class StartWindow {
#retry() {
note(`retry from ${this.#state.view}`)
this.#engineUp = false
+ this.#holdsOff()
this.#watchAt = WATCHDOG_MS
this.#phaseAt = Date.now()
this.#update({ view: 'boot', failure: undefined, celebrate: true, done: this.#state.done.filter(phase => phase !== 'team'), clock: { base: 0, from: Date.now(), running: true } })
diff --git a/app/src/start/start.css b/app/src/start/start.css
index 159f6dc6..526e1a79 100644
--- a/app/src/start/start.css
+++ b/app/src/start/start.css
@@ -181,8 +181,14 @@ html[data-shimmer] .voice[data-on]>span{color:transparent;background:linear-grad
.disclose svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;transition:rotate var(--spring-tap-ms) var(--spring-tap)}
.disclose[aria-expanded=true] svg{rotate:180deg}
-.note{position:absolute;left:calc(50% - 312px);top:calc(100% - 36px);font-size:13px;line-height:18px;color:var(--bt-ink-2)}
-html:is([data-start=later],[data-start=moving]) .note{display:none}
+/* The footer row: the note at the left, and where the data goes with 「换个位置…」 at the right
+ (first starts with a place). The note never gives way; the place's text is cut with an
+ ellipsis where the two would meet (English, a long folder). */
+.footrow{position:absolute;left:calc(50% - 312px);right:calc(50% - 312px);top:calc(100% - 36px);display:flex;justify-content:space-between;align-items:baseline;gap:16px;font-size:13px;line-height:18px;color:var(--bt-ink-2)}
+.note{flex:none;white-space:nowrap}
+.place{flex:0 1 auto;min-width:0;margin:0;display:flex;align-items:baseline;gap:6px;white-space:nowrap}
+.place-text{min-width:0;overflow:hidden;text-overflow:ellipsis}
+html:is([data-start=later],[data-start=moving]) .footrow{display:none}
/* A work area under 588 px gets a 500 px window: the stage rises 8 px and the sheet still ends
above the footer. */
@media (max-height:520px){.stage{top:-8px}html[data-frame=system] .stage{top:-32px}.sheet{height:calc(100% - 296px)}.elapsed{top:46px}html[data-frame=system] .elapsed{top:22px}}
@@ -201,7 +207,7 @@ html[data-start=first]:not([data-resume],[data-entered],[data-tier=quiet]) #tail
html[data-start=first]:not([data-resume],[data-settled],[data-tier=quiet]) .ripple{animation:bt-ripple-scale var(--spring-shape-ms) var(--spring-shape) .12s backwards,bt-ripple-fade .56s linear .12s}
html[data-start=first]:not([data-resume],[data-settled]) .voice{animation:bt-veil .22s ease-out .16s backwards}
html[data-start=first]:not([data-resume],[data-settled]) .water{animation:bt-veil .22s ease-out .22s backwards}
-html[data-start=first]:not([data-resume],[data-settled]) .note{animation:bt-veil .22s ease-out .42s backwards}
+html[data-start=first]:not([data-resume],[data-settled]) :is(.note,.place){animation:bt-veil .22s ease-out .42s backwards}
html:is([data-start=later],[data-start=moving]):not([data-resume],[data-entered]) .whale-move{animation:bt-enter-later var(--spring-tap-ms) var(--spring-tap) backwards}
html:is([data-start=later],[data-start=moving]):not([data-resume],[data-settled]) .voice{animation:bt-veil .22s ease-out .06s backwards}
@@ -226,7 +232,7 @@ html[data-tail=dash]:not([data-tier=quiet]) #tail{animation:bt-tail-dash .55s ea
@keyframes bt-tail-dash{from{transform:rotate(-8deg)}to{transform:rotate(8deg)}}
/* hand-off: window-level content fades */
-html[data-exit~=caption] :is(.elapsed,.caption),html[data-exit~=all] :is(.voice,.water,.fx .trace,.sheet,.note){opacity:0;transition:opacity .16s}
+html[data-exit~=caption] :is(.elapsed,.caption),html[data-exit~=all] :is(.voice,.water,.fx .trace,.sheet,.note,.place){opacity:0;transition:opacity .16s}
html[data-hidden] *{animation-play-state:paused!important}
/* reduced motion (ui-standard 9.6, styles.js:106): static whale, fades only */
@@ -236,7 +242,7 @@ html[data-hidden] *{animation-play-state:paused!important}
:root[data-eyes=happy] .bt-eye-happy{opacity:1}
@media (prefers-reduced-motion:reduce){
:root :is(.whale-x,.whale-gaze,.whale,.whale-move,.whale-loop,#tail,#gaze,#eye-pair,.bt-eye,.bt-eye-happy,.ripple,.trace,.stage){animation:none!important;transition:none!important}
-:root :is(.voice,.water,.note){animation:none!important}
+:root :is(.voice,.water,.note,.place){animation:none!important}
:root .voice>span{animation:none!important;background:none!important;color:var(--bt-ink)!important}
:root :is(.voice,.caption>*,.elapsed,.card,.miss,.banner,.log,.confirm,.models,[data-u]){filter:none!important;scale:none!important;transition-property:opacity!important;transition-duration:.12s!important;transition-delay:0s!important}
:root .btn:active{scale:none}
diff --git a/app/src/start/start.html b/app/src/start/start.html
index 7cb241fd..bbc84752 100644
--- a/app/src/start/start.html
+++ b/app/src/start/start.html
@@ -46,7 +46,7 @@
</div>
</section>
</main>
-<footer class="note" data-t="footer"></footer>
+<footer class="footrow"><span class="note" data-t="footer"></span><p class="place" hidden><span class="place-text"></span><span aria-hidden="true">·</span><button class="btn" data-look="link" data-act="pick" data-detail="changePlace" data-t="place.change"></button></p></footer>
<p class="sr live" aria-live="polite"></p>
</body>
</html>
diff --git a/app/src/start/start.js b/app/src/start/start.js
index 994951f9..5f8db662 100644
--- a/app/src/start/start.js
+++ b/app/src/start/start.js
@@ -21,6 +21,7 @@ const $ = selector => document.querySelector(selector)
const sheet = $('.sheet'), edge = $('.sheet-edge'), fill = $('.sheet-fill'), stage = $('.stage'), live = $('.live')
const voiceEl = $('.voice'), voiceText = $('.voice>span')
const captionText = $('.caption-text'), logs = $('.caption .btn'), elapsed = $('.elapsed')
+const placeEl = $('.place'), placeText = $('.place-text')
const CODE = new Set(['path', 'dataDir', 'workspace'])
let lang = 'zh'
let s = null
@@ -42,10 +43,21 @@ function render(el, vars = {}) {
}
function renderStatic() {
root.lang = lang === 'zh' ? 'zh-CN' : 'en'
- for (const el of document.querySelectorAll('.track [data-t], .note[data-t], .caption [data-t]')) render(el)
+ for (const el of document.querySelectorAll('.track [data-t], .footrow [data-t], .caption [data-t]')) render(el)
$('.track').setAttribute('aria-label', say('track.label'))
for (const st of document.querySelectorAll('.station')) st.querySelector('.sr').textContent = say(`state.${st.dataset.state}`)
- if (s) { fillBlock(shown); timeUI() }
+ if (s) { fillBlock(shown); placeUI(s.place); timeUI() }
+}
+// Where the data goes, at the footer's right end with 「换个位置…」 (first starts; the main
+// process sends no place on a reinstall or once a copied team lives there). The drive and its
+// free space on Windows, the folder elsewhere.
+function placeUI(place) {
+ // The failure page has its own buttons; the 180 s question still lets the place change.
+ const on = first && place !== null && typeof place === 'object' && !['failed', 'viewFailed'].includes(s?.view)
+ placeEl.hidden = !on
+ if (!on) return
+ const key = place.drive ? (place.free ? 'place.drive' : 'place.driveOnly') : place.free ? 'place.path' : 'place.pathOnly'
+ placeText.textContent = say(key, place)
}
function varsOf(snap) {
const card = snap.card ?? {}
@@ -86,7 +98,8 @@ function voiceWant() {
if (!first) return [`title.${START}`, true]
if (view === 'handoff') return ['voice.ready', false]
const st = director.stage()
- if (st.sinking) return ['', false]
+ // The whale is sinking to start over: the line goes with it, without the usual hold.
+ if (st.sinking) return ['', true]
if (st.ready) return ['voice.ready', false]
if (st.at >= 2 || (st.at === 1 && st.legging)) return ['voice.team', false]
const ms = bootMs()
@@ -507,6 +520,7 @@ function apply(next) {
else delete root.dataset.frame
root.dataset.view = next.view
shimmer()
+ placeUI(next.place)
const name = blockFor(next)
if (name !== shown) showBlock(name, jump)
else { fillBlock(name); resize() }
diff --git a/app/src/start/text.mjs b/app/src/start/text.mjs
index 730eb6e7..fd9f0193 100644
--- a/app/src/start/text.mjs
+++ b/app/src/start/text.mjs
@@ -60,6 +60,14 @@ export const TEXT = {
'card.rejected.permission': 'DeepSeek Bot 没有权限在 {path} 里写文件。',
'card.rejected.onedrive': '{path} 在 OneDrive 里,同步会打断正在写入的聊天记录。',
'card.rejected.foreign': '{path} 里已经有别的文件。',
+ 'card.rejected.dsh': '{path} 是 DeepSeek Harness 的数据。',
+ 'card.rejected.program': '{path} 在程序文件夹里,卸载时会删掉。',
+ 'card.rejected.nested': '{path} 和现在放数据的位置重叠。',
+ 'place.drive': '数据放在 {drive} 盘(剩 {free})',
+ 'place.driveOnly': '数据放在 {drive} 盘',
+ 'place.path': '数据放在 {path}(剩 {free})',
+ 'place.pathOnly': '数据放在 {path}',
+ 'place.change': '换个位置…',
'card.missing': '找不到数据文件夹 {path}。可能是移动硬盘没插上,或者文件夹被移走、删除了。旧数据不会被改动。',
'card.missing.relocate': '重新找到它…',
'card.missing.retryMissed': '还是找不到这个文件夹。',
@@ -172,6 +180,14 @@ export const TEXT = {
'card.rejected.permission': 'DeepSeek Bot can’t write files in {path}.',
'card.rejected.onedrive': '{path} is in OneDrive; syncing interrupts chats while they are being written.',
'card.rejected.foreign': '{path} already has other files in it.',
+ 'card.rejected.dsh': '{path} is DeepSeek Harness’s data.',
+ 'card.rejected.program': '{path} is in the program folder, which uninstalling removes.',
+ 'card.rejected.nested': '{path} overlaps where the data is now.',
+ 'place.drive': 'Drive {drive}, {free} free',
+ 'place.driveOnly': 'Drive {drive}',
+ 'place.path': '{path}, {free} free',
+ 'place.pathOnly': '{path}',
+ 'place.change': 'Change…',
'card.missing': 'Can’t find the data folder {path}. The external drive may be unplugged, or the folder was moved or deleted. The old data won’t be changed.',
'card.missing.relocate': 'Find it again…',
'card.missing.retryMissed': 'Still can’t find this folder.',
diff --git a/app/src/start/whale.js b/app/src/start/whale.js
index e0975aff..b68871b7 100644
--- a/app/src/start/whale.js
+++ b/app/src/start/whale.js
@@ -820,7 +820,7 @@ export function createDirector({ start, resume, act, label, announce, onCheck, o
await entered
if (want.view === 'handoff') return handoff()
if (D.pose === 'enter') { D.pose = 'loop'; place(); armActive() }
- if (want.station < D.checks) await resetRun()
+ if (D.over || want.station < D.checks) { D.over = false; await resetRun() }
if (!failure() && ['down', 'lift', 'redo'].includes(D.pose)) await shakeOff()
await runLegs(false)
if (want.view === 'handoff') return handoff()
@@ -859,6 +859,9 @@ export function createDirector({ start, resume, act, label, announce, onCheck, o
let station = 0
if (first && done.includes('data')) station = done.includes('engine') ? 2 : 1
const next = { station, view: s.view, phase: s.phase, done, card: s.card?.kind ?? '', missed: Boolean(s.card?.missedRetry), celebrate: Boolean(s.celebrate), update: s.update?.state ?? '' }
+ // Stages taken back mean a start in another folder: the whale starts over even when the
+ // next snapshot, a moment later, has the first stage done again.
+ if (D.started && station < want.station) D.over = true
const changed = !D.started || ['station', 'view', 'phase', 'card', 'missed', 'update'].some(key => next[key] !== want[key])
want = next
D.started = true
diff --git a/app/test/place.test.mjs b/app/test/place.test.mjs
new file mode 100644
index 00000000..dbe310fc
--- /dev/null
+++ b/app/test/place.test.mjs
@@ -0,0 +1,196 @@
+import assert from 'node:assert/strict'
+import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join, parse, resolve, sep } from 'node:path'
+import { test } from 'node:test'
+import { currentRootOf, DATA_DIR, driveOf, formatBytes, freeSpace, isEmptyTree, LAYER, pickFrom, placeOf, rootOf, shortPath, WORKSPACE_DIR } from '../src/place.mjs'
+
+const win32 = process.platform === 'win32'
+const temp = (t) => {
+ const dir = mkdtempSync(join(tmpdir(), 'ds-bot-place-'))
+ t.after(() => { rmSync(dir, { recursive: true, force: true }) })
+ return dir
+}
+
+test('free space is read at the nearest existing ancestor of a folder that is not there yet', (t) => {
+ const dir = temp(t)
+ const free = freeSpace(join(dir, 'not', 'yet'))
+ assert.equal(typeof free, 'number')
+ assert.ok(free > 0)
+ assert.equal(freeSpace(join(dir, 'not', 'yet')), freeSpace(dir))
+})
+
+// Explorer's units: GB and MB of 1024, so the line agrees with what the user sees there.
+test('sizes read as Explorer shows them', () => {
+ assert.equal(formatBytes(412.7 * 2 ** 30), '412 GB')
+ assert.equal(formatBytes(10 * 2 ** 30), '10 GB')
+ assert.equal(formatBytes(1.26 * 2 ** 30), '1.2 GB')
+ assert.equal(formatBytes(900 * 2 ** 20), '900 MB')
+ assert.equal(formatBytes(undefined), undefined)
+ assert.equal(formatBytes(-1), undefined)
+})
+
+test('the drive letter is read from a Windows path only', () => {
+ if (win32) {
+ assert.equal(driveOf('C:\\Users\\me\\.ds-bot'), 'C')
+ assert.equal(driveOf('d:/DeepSeek Bot'), 'D')
+ } else {
+ assert.equal(driveOf('/home/me/.ds-bot'), undefined)
+ }
+})
+
+test('a path under the home folder is written with ~', () => {
+ const home = resolve('/home/me')
+ assert.equal(shortPath(join(home, '.ds-bot'), home), `~${sep}.ds-bot`)
+ assert.equal(shortPath(home, home), '~')
+ assert.equal(shortPath(resolve('/srv/data'), home), resolve('/srv/data'))
+})
+
+test('the place line names the drive and its free space, or the folder', () => {
+ if (win32) {
+ assert.deepEqual(placeOf('C:\\Users\\me\\.ds-bot', { free: 412 * 2 ** 30 }), { drive: 'C', free: '412 GB' })
+ assert.deepEqual(placeOf('C:\\Users\\me\\.ds-bot', { free: undefined }), { drive: 'C' })
+ } else {
+ assert.deepEqual(placeOf('/home/me/.ds-bot', { home: '/home/me', free: 1.5 * 2 ** 30 }), { path: `~${sep}.ds-bot`, free: '1.5 GB' })
+ }
+})
+
+test('the picker opens in the data folder\'s parent', (t) => {
+ const dir = temp(t)
+ assert.equal(pickFrom(join(dir, 'DeepSeek Bot', 'data')), join(dir, 'DeepSeek Bot'))
+})
+
+test('the current root is the parent of a data and a workspace folder that are siblings', (t) => {
+ const dir = temp(t)
+ assert.equal(currentRootOf(join(dir, 'R', DATA_DIR), join(dir, 'R', WORKSPACE_DIR)), join(dir, 'R'))
+ // The default places are not under one root.
+ assert.equal(currentRootOf(join(dir, '.ds-bot'), join(dir, 'DeepSeek Bot')), undefined)
+ assert.equal(currentRootOf(join(dir, 'R', DATA_DIR), undefined), undefined)
+})
+
+test('an empty tree holds nothing but empty folders', (t) => {
+ const dir = temp(t)
+ mkdirSync(join(dir, 'a', 'b'), { recursive: true })
+ assert.equal(isEmptyTree(dir), true)
+ writeFileSync(join(dir, 'a', 'b', 'file'), '')
+ assert.equal(isEmptyTree(dir), false)
+ assert.equal(isEmptyTree(join(dir, 'missing')), false)
+})
+
+// The root rule of windows-onboarding §3 (一个位置), without the write probe.
+const noProbe = { env: {}, probe: false }
+
+test('a new or empty folder is the root itself', (t) => {
+ const dir = temp(t)
+ const fresh = join(dir, 'new')
+ assert.deepEqual(rootOf(fresh, noProbe), { root: fresh, dataDir: join(fresh, DATA_DIR), workspace: join(fresh, WORKSPACE_DIR), added: false })
+ const empty = join(dir, 'empty')
+ mkdirSync(empty)
+ assert.deepEqual(rootOf(empty, noProbe), { root: empty, dataDir: join(empty, DATA_DIR), workspace: join(empty, WORKSPACE_DIR), added: false })
+})
+
+test('a drive or a folder with other things in it gets a DeepSeek Bot layer', (t) => {
+ const dir = temp(t)
+ writeFileSync(join(dir, 'notes.txt'), '')
+ const layered = rootOf(dir, noProbe)
+ assert.equal(layered.root, join(dir, LAYER))
+ assert.equal(layered.added, true)
+ assert.equal(layered.reason, undefined)
+ const drive = parse(dir).root
+ const atDrive = rootOf(drive, noProbe)
+ assert.equal(atDrive.root, join(drive, LAYER))
+ assert.equal(atDrive.added, true)
+})
+
+test('an empty root of the app\'s own is used again; someone else\'s layer is refused', (t) => {
+ const dir = temp(t)
+ mkdirSync(join(dir, DATA_DIR, 'profiles'), { recursive: true })
+ mkdirSync(join(dir, WORKSPACE_DIR))
+ assert.equal(rootOf(dir, noProbe).added, false)
+ const busy = temp(t)
+ writeFileSync(join(busy, 'notes.txt'), '')
+ mkdirSync(join(busy, LAYER))
+ writeFileSync(join(busy, LAYER, 'theirs.txt'), '')
+ const refused = rootOf(busy, noProbe)
+ assert.equal(refused.reason, 'foreign')
+ assert.equal(refused.at, join(busy, LAYER))
+ const file = join(dir, 'a-file')
+ writeFileSync(file, '')
+ assert.equal(rootOf(file, noProbe).reason, 'foreign')
+})
+
+test('the place the data is in now is no change, and a place inside it is refused', (t) => {
+ const dir = temp(t)
+ const current = { dataDir: join(dir, 'R', DATA_DIR), workspace: join(dir, 'R', WORKSPACE_DIR) }
+ mkdirSync(join(current.dataDir, 'profiles'), { recursive: true })
+ mkdirSync(current.workspace)
+ for (const same of [join(dir, 'R'), current.dataDir, `${join(dir, 'R')}${sep}`]) assert.deepEqual(rootOf(same, { ...noProbe, current }), { same: true })
+ const inside = rootOf(join(current.dataDir, 'old'), { ...noProbe, current })
+ assert.equal(inside.reason, 'nested')
+ assert.equal(inside.at, join(current.dataDir, 'old'))
+ // The team workspace with something in it is a place too; an empty one, just made, is free.
+ writeFileSync(join(current.workspace, 'notes.md'), '')
+ assert.equal(rootOf(join(current.workspace, 'sub'), { ...noProbe, current }).reason, 'nested')
+ // The default places: picking the home puts the root on the workspace the start made.
+ const home = join(dir, 'home')
+ mkdirSync(join(home, 'DeepSeek Bot'), { recursive: true })
+ writeFileSync(join(home, 'other.txt'), '')
+ const defaults = { dataDir: join(home, '.ds-bot'), workspace: join(home, 'DeepSeek Bot') }
+ const atHome = rootOf(home, { ...noProbe, current: defaults })
+ assert.equal(atHome.reason, undefined)
+ assert.equal(atHome.root, join(home, 'DeepSeek Bot'))
+ assert.equal(atHome.added, true)
+ assert.equal(rootOf(join(home, 'DeepSeek Bot'), { ...noProbe, current: defaults }).added, false)
+ // Once the workspace holds files, the layer the home pick would add is a used folder.
+ writeFileSync(join(home, 'DeepSeek Bot', 'theirs.txt'), '')
+ assert.equal(rootOf(home, { ...noProbe, current: defaults }).reason, 'foreign')
+ assert.equal(rootOf(join(home, 'DeepSeek Bot', 'sub'), { ...noProbe, current: defaults }).reason, 'nested')
+ assert.equal(rootOf(join(home, 'elsewhere'), { ...noProbe, current: defaults }).reason, undefined)
+})
+
+test('a folder that cannot be read counts as one without permission', { skip: !win32 || !existsSync('C:\\System Volume Information') }, () => {
+ const refused = rootOf('C:\\System Volume Information', noProbe)
+ assert.equal(refused.reason, 'permission')
+ assert.equal(refused.at, 'C:\\System Volume Information')
+})
+
+test('OneDrive, the DSH home and the program folder are refused, through links too', (t) => {
+ const dir = temp(t)
+ const cloud = join(dir, 'OneDrive', 'Docs')
+ assert.equal(rootOf(cloud, noProbe).reason, 'onedrive')
+ assert.equal(rootOf(cloud, noProbe).at, cloud)
+ assert.equal(rootOf(join(dir, 'OneDrive - Contoso', 'Docs'), noProbe).reason, 'onedrive')
+ assert.equal(rootOf(join(dir, 'Library', 'CloudStorage', 'OneDrive-Personal', 'Docs'), noProbe).reason, 'onedrive')
+ // A folder that only has OneDrive in its name is not the cloud.
+ assert.equal(rootOf(join(dir, 'OneDrive-old', 'Docs'), noProbe).reason, undefined)
+ const synced = join(dir, 'Synced')
+ assert.equal(rootOf(synced, { ...noProbe, env: { OneDrive: join(dir, 'Synced') } }).reason, 'onedrive')
+ const dsh = join(dir, '.dsh')
+ mkdirSync(dsh)
+ const inDsh = rootOf(join(dsh, 'bots'), { ...noProbe, dshHome: dsh })
+ assert.equal(inDsh.reason, 'dsh')
+ assert.equal(inDsh.at, join(dsh, 'bots'))
+ assert.equal(rootOf(dir, { ...noProbe, dshHome: join(dir, 'missing-dsh') }).reason, undefined)
+ assert.equal(rootOf(join(dir, 'app', 'data'), { ...noProbe, program: join(dir, 'app') }).reason, 'program')
+ // A link into the DSH home leads there.
+ const link = join(dir, 'link')
+ try {
+ symlinkSync(dsh, link, 'junction')
+ } catch {
+ return
+ }
+ assert.equal(rootOf(join(link, 'bots'), { ...noProbe, dshHome: dsh }).reason, 'dsh')
+})
+
+test('the write probe makes only the missing layers and takes them away again', (t) => {
+ const dir = temp(t)
+ const fresh = join(dir, 'deep', 'er')
+ const root = rootOf(fresh, { env: {} })
+ assert.equal(root.reason, undefined)
+ assert.equal(existsSync(join(dir, 'deep')), false)
+ const kept = join(dir, 'kept')
+ mkdirSync(kept)
+ rootOf(kept, { env: {} })
+ assert.equal(existsSync(kept), true)
+ assert.equal(existsSync(join(kept, DATA_DIR)), false)
+})
diff --git a/app/test/start-page.test.mjs b/app/test/start-page.test.mjs
index de8e7542..06606be9 100644
--- a/app/test/start-page.test.mjs
+++ b/app/test/start-page.test.mjs
@@ -92,7 +92,7 @@ test('every text key that the page uses exists', () => {
const keys = Object.keys(TEXT.zh)
const matching = pattern => keys.filter(key => new RegExp(`^${pattern.replaceAll('.', '\\.').replace(/\{\w+\}/gu, '\\w+')}$`, 'u').test(key))
for (const [, key] of html.matchAll(/data-t(?:-label)?="([^"]+)"/gu)) assert.ok(matching(key).length > 0, `start.html: unknown text key ${key}`)
- const literal = /^(?:voice|hint|title|say|card|import|copying|eta|sr|state|phase|slow|update|failed|newer|importFailed|track)\.[\w.]+$/u
+ const literal = /^(?:voice|hint|title|say|card|import|copying|eta|sr|state|phase|slow|update|failed|newer|importFailed|track|place)\.[\w.]+$/u
for (const name of ['start.js', 'whale.js']) {
const text = uncommented(code[name])
const used = [
diff --git a/app/test/start-window.test.mjs b/app/test/start-window.test.mjs
index 404207ca..788657cc 100644
--- a/app/test/start-window.test.mjs
+++ b/app/test/start-window.test.mjs
@@ -116,8 +116,16 @@ test('only a missing file of the app\'s own says that the install is incomplete'
})
test('the main process takes only its own acts, each in its own views', () => {
- assert.deepEqual([...START_ACTS].sort(), ['copyDetails', 'handoffDone', 'handoffShow', 'openLogs', 'reloadView', 'retry', 'wait'])
+ assert.deepEqual([...START_ACTS].sort(), ['answer', 'copyDetails', 'handoffDone', 'handoffShow', 'openLogs', 'pick', 'reloadView', 'retry', 'wait'])
assert.equal(acceptsAct('handoffShow', 'handoff'), true)
+ // 「换个位置…」 while the start boots and 〔重新选〕 on its cards; a card's answer only on a card.
+ assert.equal(acceptsAct('pick', 'boot'), true)
+ assert.equal(acceptsAct('pick', 'card'), true)
+ assert.equal(acceptsAct('pick', 'watchdog'), true)
+ assert.equal(acceptsAct('pick', 'failed'), false)
+ assert.equal(acceptsAct('pick', 'viewFailed'), false)
+ assert.equal(acceptsAct('answer', 'card'), true)
+ assert.equal(acceptsAct('answer', 'boot'), false)
assert.equal(acceptsAct('handoffShow', 'boot'), false)
assert.equal(acceptsAct('handoffDone', 'handoff'), true)
assert.equal(acceptsAct('retry', 'failed'), true)
@@ -133,7 +141,7 @@ test('the main process takes only its own acts, each in its own views', () => {
assert.equal(acceptsAct('copyDetails', view), true)
}
// The cards of later pull requests, and names that are not acts at all.
- for (const name of ['reload', 'toggleDetails', 'answer', 'pick', 'freshStart', 'installUpdate', 'manualDownload', 'stopCopy', 'keepCopying', 'importModel', 'importOption', '__proto__', 'constructor', 'toString', '']) {
+ for (const name of ['reload', 'toggleDetails', 'freshStart', 'installUpdate', 'manualDownload', 'stopCopy', 'keepCopying', 'importModel', 'importOption', '__proto__', 'constructor', 'toString', '']) {
assert.equal(acceptsAct(name, 'failed'), false, name)
}
assert.equal(acceptsAct(undefined, 'failed'), false)
@@ -179,6 +187,9 @@ test('the snapshot carries the phase, the stages done and the clock', () => {
assert.equal('card' in failed, false)
assert.equal('hint' in failed, false)
assert.deepEqual(startSnapshot(state({ hint: { drive: 'C', free: '1.2 GB' } }), now).hint, { drive: 'C', free: '1.2 GB' })
+ assert.equal('place' in startSnapshot(state(), now), false)
+ assert.deepEqual(startSnapshot(state({ place: { drive: 'C', free: '412 GB' } }), now).place, { drive: 'C', free: '412 GB' })
+ assert.deepEqual(startSnapshot(state({ view: 'card', card: { kind: 'picked', path: 'D:\\DeepSeek Bot' } }), now).card, { kind: 'picked', path: 'D:\\DeepSeek Bot' })
// The page gets copies: it cannot change the main process's state.
const source = state({ failure: { reason: 'other', log: ['x'] } })
const sent = startSnapshot(source, now)
@@ -300,12 +311,13 @@ function startWindow(t) {
t.mock.method(console, 'log', () => {})
const fake = fakeElectron()
const main = new fake.electron.BrowserWindow({ show: false })
- const calls = { retry: 0, reload: 0, close: 0 }
+ const calls = { retry: 0, reload: 0, close: 0, pick: [], answer: [] }
const start = new StartWindow({
electron: fake.electron, page: join(tmpdir(), 'start', 'start.html'), preload: 'preload.cjs', icon: 'icon.ico', mica: false, devTools: false,
lang: () => 'en', motion: 'normal', version: '0.0.0', program: [], log: { dir: 'logs', tail: () => ['a log line'] },
mainWindow: () => main,
onRetry: () => { calls.retry += 1 }, onReload: () => { calls.reload += 1 }, onClose: () => { calls.close += 1 },
+ onPick: (value) => { calls.pick.push(value) }, onAnswer: (value) => { calls.answer.push(value) },
})
const win = () => fake.windows.at(-1)
const page = () => ({ sender: win().webContents, senderFrame: win().webContents.mainFrame })
@@ -529,3 +541,125 @@ test('a failure after the hand-off opens a fresh start window over the hidden te
assert.equal(s.start.owner(), s.win())
assert.equal(s.calls.close, 0)
})
+
+test('the place line, its picker and its cards, and a start over in another folder', (t) => {
+ const s = startWindow(t)
+ s.start.open('first')
+ s.start.done('data')
+ assert.equal('place' in s.state(), false)
+ s.start.place({ drive: 'C', free: '412 GB' })
+ assert.deepEqual(s.state().place, { drive: 'C', free: '412 GB' })
+ // 「换个位置…」 from the line, with its detail; the picker's own wait is the main process's.
+ assert.equal(s.act('pick', { value: 'changePlace' }), true)
+ assert.deepEqual(s.calls.pick, ['changePlace'])
+ assert.equal(s.act('answer', { value: 'use' }), false)
+ // A layer the app added: the 「会放在…」 card waits for the answer, and the clock with it.
+ s.start.card({ kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ assert.equal(s.state().view, 'card')
+ assert.deepEqual(s.state().card, { kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ assert.equal(s.state().clock.running, false)
+ assert.equal(s.act('pick', undefined), true)
+ assert.deepEqual(s.calls.pick, ['changePlace', undefined])
+ assert.equal(s.act('answer', { value: 'use' }), true)
+ assert.equal(s.act('answer', 'use'), true)
+ assert.deepEqual(s.calls.answer, ['use', undefined])
+ s.start.card(undefined)
+ assert.equal(s.state().view, 'boot')
+ assert.equal('card' in s.state(), false)
+ assert.equal(s.state().clock.running, true)
+ // A rejected place names the reason and the path.
+ s.start.card({ kind: 'rejected', reason: 'onedrive', path: 'C:\\Users\\me\\OneDrive' })
+ assert.equal(s.state().card.reason, 'onedrive')
+ s.start.card(undefined)
+ // Under the 180 s question the place can still change; the question comes back after a card.
+ s.tick(180_000)
+ assert.equal(s.state().view, 'watchdog')
+ assert.equal(s.act('pick', { value: 'changePlace' }), true)
+ s.start.card({ kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ assert.equal(s.state().view, 'card')
+ s.start.card(undefined)
+ s.tick(1)
+ assert.equal(s.state().view, 'watchdog')
+ // Starting over: the stages go back, the clock starts from 0, the engine is guarded again,
+ // and the place line stays for the new folder.
+ s.start.done('engine')
+ s.tick(30_000)
+ s.start.restart()
+ s.start.place({ drive: 'D', free: '412 GB' })
+ assert.equal(s.state().view, 'boot')
+ assert.deepEqual(s.state().done, [])
+ assert.equal(s.state().clock.ms, 0)
+ assert.equal(s.state().celebrate, true)
+ assert.deepEqual(s.state().place, { drive: 'D', free: '412 GB' })
+ s.start.done('data')
+ s.tick(180_000)
+ assert.equal(s.state().view, 'watchdog')
+ s.start.done('engine')
+ assert.equal(s.state().view, 'boot')
+ assert.deepEqual(s.state().done, ['data', 'engine'])
+ // No card after a failure: the failure page has its own buttons.
+ s.start.fail(new Error('The DSH Host stopped (exit 1)'))
+ s.start.card({ kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ assert.equal(s.state().view, 'failed')
+ assert.equal(s.act('pick', { value: 'changePlace' }), false)
+})
+
+// The picker is open when the team view becomes ready: the window, the picker's owner, stays.
+test('the hand-off waits while the picker is open', async (t) => {
+ const s = startWindow(t)
+ s.start.open('first')
+ s.start.done('data')
+ s.start.done('engine')
+ s.start.teamLoading()
+ let answer
+ const asked = s.start.asking(new Promise((resolve) => { answer = resolve }))
+ s.start.ready()
+ assert.equal(s.state().view, 'boot')
+ s.tick(2500)
+ assert.equal(s.main.visible, false)
+ answer()
+ await asked
+ assert.equal(s.state().view, 'handoff')
+})
+
+test('a card holds the hand-off the same way, and the ready is not lost when the card goes', (t) => {
+ const c = startWindow(t)
+ c.start.open('first')
+ c.start.done('data')
+ c.start.done('engine')
+ c.start.card({ kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ c.start.ready()
+ assert.equal(c.state().view, 'card')
+ c.start.card(undefined)
+ assert.equal(c.state().view, 'handoff')
+})
+
+test('a start over in another folder drops the old engine\'s held ready', (t) => {
+ const o = startWindow(t)
+ o.start.open('first')
+ o.start.done('data')
+ o.start.done('engine')
+ o.start.card({ kind: 'picked', path: 'D:\\DeepSeek Bot' })
+ o.start.ready()
+ o.start.restart()
+ assert.equal(o.state().view, 'boot')
+ o.tick(3000)
+ assert.equal(o.state().view, 'boot')
+ o.start.done('data')
+ o.start.done('engine')
+ o.start.ready()
+ assert.equal(o.state().view, 'handoff')
+})
+
+test('the 20 s check\'s verdict waits for a card\'s answer instead of being lost', (t) => {
+ const v = startWindow(t)
+ v.start.open('first')
+ v.start.done('data')
+ v.start.done('engine')
+ v.start.teamLoading()
+ v.start.card({ kind: 'rejected', reason: 'onedrive', path: 'C:\\OneDrive' })
+ v.tick(20_000)
+ assert.equal(v.state().view, 'card')
+ v.start.card(undefined)
+ assert.equal(v.state().view, 'viewFailed')
+})
diff --git a/docs/plans/2026-10-26-start-window.md b/docs/plans/2026-10-26-start-window.md
index bb55400e..f0554fc8 100644
--- a/docs/plans/2026-10-26-start-window.md
+++ b/docs/plans/2026-10-26-start-window.md
@@ -55,9 +55,10 @@
| 提示行 | y 300–328,居中 | y 220–248,隐藏 | 13/18,`--bt-ink-2`;最多约 22 个字,或者只有〔打开日志文件夹〕;没有要提前知道的事时空着 |
| 纸面 | 空 | x 48–672,y 260–496 | 只放卡片 |
| 底注 | x 48,y 504–522 | 同左 | 「社区开源项目,不是 DeepSeek 官方产品」,13/18 |
+| 位置行 | 右对齐 x 672,y 504–522,和底注同一行,挤不下时位置行的字省略 | 同左 | 「数据放在 C 盘(剩 412 GB)· 换个位置…」,13/18,`--bt-ink-2`;「换个位置…」是链接(第 6 节)。只在新团队和要导入的首次启动有,重装没有;导入一开始复制就收起;失败页和「团队界面没有加载出来」时隐藏,180 秒的问题开着时还能点。剩余空间按资源管理器的算法(1024 进制)。Windows 以外写文件夹(`~/.ds-bot`)代替盘;查不到剩余空间时不写括号 |
- 三站是鲸鱼停的三处:x 168 / 360 / 552,依次对应「准备数据文件夹」「启动本机引擎」「打开团队」三个阶段。站上不画标记、名字和连线:鲸鱼停在哪一站,进度就到了哪里。
-- 没有卡片时,水道、水线、圈、鲸鱼的话和提示行整组比有卡片时低 80 px,鲸鱼落在窗口的视觉中心。要出卡片时,整组用 `SPRING_SHAPE` 上移 80 px,卡片出现在下面的纸面里;卡片收回后,整组再回到低处。已用秒数和底注不动。页面不能滚动(第 11 节)。
+- 没有卡片时,水道、水线、圈、鲸鱼的话和提示行整组比有卡片时低 80 px,鲸鱼落在窗口的视觉中心。要出卡片时,整组用 `SPRING_SHAPE` 上移 80 px,卡片出现在下面的纸面里;卡片收回后,整组再回到低处。已用秒数、底注和位置行不动。页面不能滚动(第 11 节)。
- 鲸鱼的话和提示行直接写在 Mica 上。
- 卡片是不透明的 `--bt-card`:1 px `--bt-line` 边,圆角 12,内边距 16 × 20。卡片正文比纸面高时,正文在卡片里滚动,按钮行固定在卡片底部。
- 以后的启动:
@@ -78,7 +79,7 @@
- 每段一次性动作带序号,新状态到了就丢掉旧的。等动画结束的地方都配一个计时器兜底,因为最小化的窗口不走动画。
- 弹簧只用 `motion.js` 的常量。头像动作的关键帧沿用插件的写法(`styles.js` 的 `bt-hop`、`bt-bob` 等),换算成像素。
- 鲸鱼说话:
- - 鲸鱼一次只说一句短话,写在水线下面那一行(第 2 节),用 Main Bot 自己的口吻。窗口里没有大段的文字:旁边只有已用秒数、一行提示、卡片和底注。
+ - 鲸鱼一次只说一句短话,写在水线下面那一行(第 2 节),用 Main Bot 自己的口吻。窗口里没有大段的文字:旁边只有已用秒数、一行提示、卡片、底注和位置行(第 2 节)。
- 问候里的名字是 Main Bot 的名字(待定):新团队用界面语言的默认名字(中文「总管」,英文 Chief,见 [上手流程](2026-10-26-windows-onboarding.md)「待定」);重装时用团队里 Main Bot 自己的名字,主进程和第 2 站提示里的 Bot、群聊数一起读出来;要导入、或者读不出名字时不带名字:「嗨,我来了」。导入卡答完之前,进门后的 Main Bot 是哪一个还没定:答〔先不复制〕就是新的空白团队。
- 那一行跟着鲸鱼走:它停在哪一站、那一站的阶段是不是进行中、它是不是正在游、是不是已经就绪。只看主进程的快照不够,所以话从不跑到鲸鱼前面。
- 每句话停够了才换:一般 0.9 秒,问候 1.5 秒,「找到了」0.7 秒;除了失败和 180 秒的问题,一句话至少能读满 300 ms 才被换掉。这期间被跳过的话不补说。失败和 180 秒的问题不等,立刻换上。「进去吧」等上一句能读满 400 ms 就出来。
@@ -131,7 +132,7 @@
- 160 ms,鲸鱼的话「嗨,我是总管」淡入(重装和导入时的名字见第 3 节)。
- 220 ms,水线淡入。
- 360 ms,睁眼。
- - 420 ms,底注淡入。
+ - 420 ms,底注和位置行淡入。
- 560 ms,到位。
入场全是 CSS,不等脚本。入场时来的卡片和就绪,等它到位再处理。问候至少停 1.5 秒,之后有新消息才换;入场时就来的卡片也等它读满(第 6 节)。
2. 到 560 ms「准备数据文件夹」还没完成、并且已经等了 250 ms,第 1 站才进入进行中,鲸鱼搜索;问候停够以后,鲸鱼说「先找个地方放东西」。已经完成的话,直接游到第 2 站。离开第 1 站时,只有真的说过「先找个地方放东西」,才接一句「找到了」(停 0.7 秒)。一般的首次启动里,数据阶段在问候读完以前就结束了,所以这两句只在这个阶段慢、出过卡片或者换了新文件夹之后才出现。
@@ -148,6 +149,7 @@
9. `dsBotApp.ready()`:鲸鱼说「进去吧」,见第 8 节。
- 卡片等用户回答时,已用秒数暂停并隐藏,回答后接着走。10 秒、45 秒和 180 秒都按这个时钟算:用户自己想了多久,不算在引擎头上。
+- 位置行(第 2 节)从入场起就在:新团队和要导入时写「数据放在 C 盘(剩 412 GB)· 换个位置…」,什么都不点就按它走,不问。点「换个位置…」才开系统选择框(第 6 节),选择框开着时时钟也停。交接时随整组淡出(第 8 节)。
### 5. 以后的启动
@@ -185,6 +187,7 @@
- 「其他位置…」打开系统选择框,卡片留在后面。定出的根就是用户选的文件夹时(上手流程第 3 节的规则),卡片直接收回,照常启动,不确认。应用在里面加了一层 `DeepSeek Bot` 时,同一张卡变形成「会放在 `D:\DeepSeek Bot`」〔继续〕(主按钮)〔重新选〕。选的位置不能用,同一张卡写一句原因(「DeepSeek Bot 没有权限在 `D:\Data` 里写文件。」「`C:\Users\<用户名>\OneDrive\文档` 在 OneDrive 里,同步会打断正在写入的聊天记录。」「`D:\Projects\DeepSeek Bot` 里已经有别的文件。」),〔重新选〕(主按钮),来时那张卡的〔放到 D 盘〕〔仍然放在 C 盘〕照旧留着;选择框被取消就回到来时的卡。「会放在…」和被拒绝的卡也有脚注。
- 脚注都是「以后可以在 设置 → 通用 → 位置 里改。」
- 没有更好的盘时不出卡片:前 10 秒提示行写「C 盘只剩 1.2 GB」,之后换成这一站的提示(第 4 节)。
+ - 位置行的「换个位置…」(第 2 节)不等推荐盘的卡:新团队和要导入的首次启动期间随时能点,引擎正在起也可以,走和「其他位置…」同一条路。选完先定根(上手流程第 3 节「一个位置」):根就是选的文件夹时不出卡,直接重新开始;加了一层 `DeepSeek Bot` 时出「会放在 `D:\DeepSeek Bot`」〔继续〕(主按钮)〔重新选〕;不能用时出「这里放不了」加一句原因(上面三句,再加「`D:\Data` 是 DeepSeek Harness 的数据。」「`C:\Program Files\DeepSeek Bot\data` 在程序文件夹里,卸载时会删掉。」),〔重新选〕(主按钮);这两张卡都是用户自己引出的,不跳。选择框被取消就回到位置行:这一路没有来时的卡,「会放在…」和「这里放不了」也一起收回,仍按默认位置走。选了现在的根或数据文件夹就当没选;选在现在的数据文件夹里面、或者定出的根和它重叠,出「这里放不了」加「`C:\Users\<用户名>\.ds-bot\旧` 和现在放数据的位置重叠。」,总工作区里已经有东西时也一样,还空着的(这次启动刚建的)可以成为新的根:默认位置下选用户文件夹,就是「会放在 `C:\Users\<用户名>\DeepSeek Bot`」;读不了的文件夹按没有权限处理;检查都穿过链接和联接看真正的路径,DSH 的家那句写用户选的文件夹。选择框或这两张卡开着时团队就绪了,交接和 20 秒的界面检查都等答完再走:交接会把启动窗口连同挂在它上面的选择框一起收掉。定好以后按第 7 节〔换个位置…〕的路重新开始:鲸鱼立刻沉下去,位置行立刻写新的盘;旧引擎直接结束,不等它起完、也不等它有序退出(两者都要 3 到 10 秒,鲸鱼会一直在水下;那个文件夹马上就删,没有要保全的东西),默认位置上这一次建的文件夹删掉(数据文件夹整个删,总工作区只在还是空的时候删),位置这时就记下,鲸鱼在第 1 站重新浮上来;沉下去时这一行立刻空着,不等上一句停够。导入复制进行中不接这一下,复制完以后这一行收起:搬一个复制好的团队是 设置 → 通用 → 位置 的事。
- 重装(`C:\Users\<用户名>\.ds-bot` 里有团队、没有保存的位置)不出卡片,盘不够也不出:鲸鱼到了第 2 站,提示行写「上次的 6 个 Bot 和 2 个群聊都在」,不写路径,也没有接模型的提示。
- 180 秒:鲸鱼立刻问「等太久了,要不要重试?」,卡片里只有〔继续等待〕(主按钮)〔重试〕〔打开日志文件夹〕,读屏读的是这句问话。
- 〔继续等待〕:卡片收回,180 秒后再问。
@@ -223,7 +226,7 @@
- 鲸鱼抬一次头,看向更新条,然后又静止。
- 恢复卡上的选择:
- 〔重试〕:已完成的阶段保持完成,留下的圈不动;失败的那个阶段回到进行中,鲸鱼抖一抖,回到工作,鲸鱼的话回到这一站的那句。
- - 〔换个位置…〕和〔用新的空白团队开始…〕:先选文件夹(定根和首次启动同一条规则);然后鲸鱼的话和提示行空着,鲸鱼沉到水线下,留下的圈一起淡出(.16 s),三个阶段回到未开始,鲸鱼在第 1 站重新浮上来,说「先找个地方放东西」。
+ - 〔换个位置…〕和〔用新的空白团队开始…〕:先选文件夹(定根和首次启动同一条规则);然后鲸鱼的话和提示行空着,鲸鱼沉到水线下,留下的圈一起淡出(.16 s),三个阶段回到未开始,鲸鱼在第 1 站重新浮上来,说「先找个地方放东西」。位置行的「换个位置…」(第 6 节)走同一条路;阶段被收回时,就算下一个快照里第 1 站马上又完成了,鲸鱼也先沉下去。
- 重试或重新开始后第一次成功时庆祝一次:首次启动照第 8 节的表,先说「进去吧」;以后的启动不说「进去吧」,字照旧,压扁回弹 920 ms 后潜下去(第 8 节)。
- 团队界面 20 秒没加载出来:
- 主窗口始终不显示。
@@ -339,7 +342,8 @@
| 同上 3.1 字族 | 启动窗口加 `"Microsoft YaHei UI"`,记进第 14 节 |
| 同上 12 可访问性 | 新出现的卡片和恢复页,焦点移到主按钮 |
| [Windows 上手流程](2026-10-26-windows-onboarding.md) 第 3 节「标题「正在准备你的 Bot 团队…」,下面三个真实阶段,各带进度勾」;本文首稿第 2 节的标题行和三站(16 px 标记的四种样子、阶段名、站间的细线、进行中的流光) | 没有标题行,阶段不画出来:鲸鱼停在哪一站就是进度,离开的站留下一个圈,水线上不画别的;三个阶段只留在看不见的列表「启动进度」里,朗读照旧;已用秒数移到右上角;没有卡片时整组低 80 px(第 2、3 节) |
-| 同上 首次启动的说明(产品介绍、「下一步:接上一个模型…」、「聊天和设置保存在这台电脑上…」、写位置的小字、「接下来会先显示 DeepSeek Harness 的「预览版说明」…」);本文首稿第 4 节第 3 拍逐段出现的说明 | 不再有说明。鲸鱼一次说一句短话(第 3、4 节);提示行只写接下来要知道的一件事:「待会儿要接一个模型:DeepSeek 账号或 API Key」「里面先有一页说明,点「继续」就行」;首次启动不写路径,位置只在卡片和 设置 → 通用 → 位置 里出现 |
+| 同上 首次启动的说明(产品介绍、「下一步:接上一个模型…」、「聊天和设置保存在这台电脑上…」、写位置的小字、「接下来会先显示 DeepSeek Harness 的「预览版说明」…」);本文首稿第 4 节第 3 拍逐段出现的说明 | 不再有说明。鲸鱼一次说一句短话(第 3、4 节);提示行只写接下来要知道的一件事:「待会儿要接一个模型:DeepSeek 账号或 API Key」「里面先有一页说明,点「继续」就行」;首次启动不写完整路径,底注右边的位置行只写盘和剩余空间(2026-10-28 第二次补),路径只在卡片和 设置 → 通用 → 位置 里出现 |
+| 本文 2026-10-28 首稿:首次启动没有自己选位置的入口,只有推荐盘的卡上才有「其他位置…」 | 位置行「数据放在 C 盘(剩 412 GB)· 换个位置…」随时能点(第 2、4、6 节)。维护者 2026-10-28:「给出建议,同时提供自行选择的接口,避免小弹窗」 |
| 同上 超过 10 秒、45 秒的提示「第一次启动会慢一些,Windows 可能在检查刚装好的文件。」「比平时慢,可能是杀毒软件在检查新文件,请再等一会儿。」 | 首次启动由鲸鱼说「第一次会慢一点」「有点久,可能是杀毒软件在查新文件」,45 秒时提示行只有〔打开日志文件夹〕;以后的启动不变 |
| 同上 启动超过 180 秒:「启动比平常慢很多。可以再等一会儿,或者重试。」 | 鲸鱼问「等太久了,要不要重试?」,卡片里只有〔继续等待〕〔重试〕〔打开日志文件夹〕 |
| 同上 重装时说明的小字「接着用上次的数据:6 个 Bot、2 个群聊(`C:\Users\<用户名>\.ds-bot`)。可以在 设置 → 通用 → 位置 里改。」(本文第 6 节照写) | 提示行写「上次的 6 个 Bot 和 2 个群聊都在」,不写路径 |
@@ -357,6 +361,7 @@
- 2026-10-27:导入卡加一行小字写明复制后多占多少、原件不动;换位置的页面改叫「正在搬 DeepSeek Bot 的数据…」(上手流程 §8 的〔移到…〕改成真正的搬)。评审后补正:导入卡开着时引擎起来只打勾、不加载页面(§1、§4 第 8 拍);占用卡和下载卡有〔先不复制〕;被拒绝的卡留着来时的按钮和脚注;空间例子改成 1.7 / 1.5 / 0.2 GB。
- 2026-10-27:第 1 节加登录窗口(上手流程第 5 节):主窗口的子窗口,只在交接之后、用户点了某个登录入口时出现,启动窗口阶段没有它。
- 2026-10-28:按维护者 2026-10-27 的反馈改写:小窗口显示的是实现的结构(一条带三个点和阶段名的线、几段说明),不是用户感受到的东西,最后一步跳进团队窗口也太突然。三部分一起定:(1)「鲸鱼即进度」的启动窗口:鲸鱼停在哪一站就是进度,离开的站留下一个圈,窗口里的字都是鲸鱼一次一句的短话,卡片的第一行也是它说的;去掉标题行、三站的标记和阶段名、说明和写位置的小字,180 秒的卡只留按钮,重装只写一句提示,复制中的标题改成「正在搬过来」;鲸鱼更有反应(探身、呼吸、眨眼、回到窗口时看你、眼睛跟着键盘焦点、按下预备、活泼档越跳越稀、潜得更深),呼吸和眨眼只在卡片等用户时有;交接时启动窗口长成主窗口的矩形,主窗口在同一个矩形上露面(就绪后约 1.6 秒,兜底 2.5 秒),鲸鱼在侧栏的磁贴上浮上来。(2)交接后的目标卡改成多选加〔确定〕。(3)AI-native 的后半段:开场白不调模型,目标卡、建议卡和第一件事由插件画,上手期间最多 3 次模型请求,模型关着也走得通。后两部分写在上手流程第 5、6 节,本文只写到交接为止。依据:原型和它的检查(82 个状态、22 个场景、交接和团队窗口的联合检查)、Electron 44 上长大窗口的探针。评审后补正:磁贴上的鲸鱼怎么浮上来写进第 8 节(数值照原型,由主进程经 `dsBotApp` 的露面事件开始,待定),不再指向上手流程第 5 节;问候里的名字跟着团队(重装用团队里的名字,导入和读不出时「嗨,我来了」);入场时就来的卡等问候读满 1.5 秒;300 ms 的最短停留和「卡片在时这一行空着」写明失败和 180 秒的例外;以后的启动重试或重新开始后第一次成功不说「进去吧」,压扁回弹 920 ms 后潜下去,兜底和首次启动一样 2.5 秒;启动窗口在主窗口露面时才离开任务栏;减少动态效果时「^ ^」眼再停 300 ms;卡片在时已用秒数隐藏;45 KB 的预算写进第 11 节,建议和上手流程一致;「淡圈」统一叫「圈」,和上手流程的用词一样;空 Mica 帧的退路、「不做什么」里的推迟和「不要用户做什么」按新的交接和会说话的鲸鱼改写;首稿里「等用户回答时静止」等规则记进「改动的已定设计」;文件头的「一起改」补全。
+- 2026-10-28 位置行:落地第一批(启动窗口、交接、失败页、日志)时维护者看到首次启动仍弹「欢迎使用 DeepSeek Bot」的系统对话框,要求「给出建议,同时提供自行选择的接口,避免小弹窗」。首次启动不再弹这个对话框,底注右边一行「数据放在 C 盘(剩 412 GB)· 换个位置…」(第 2、4 节),点了才开系统选择框,定根、「会放在…」和「这里放不了」按第 6 节,被拒绝的原因加上 DSH 的家和程序文件夹两句,定好后按第 7 节沉下去重新开始,默认位置上这一次建的文件夹删掉;导入复制完以后收起。依据:桌面应用里的实现和它的检查(`place.test.mjs`、`start-window.test.mjs`、未打包的应用上的实测)。
## 待定
diff --git a/docs/plans/2026-10-26-windows-onboarding.md b/docs/plans/2026-10-26-windows-onboarding.md
index 34562df2..30613def 100644
--- a/docs/plans/2026-10-26-windows-onboarding.md
+++ b/docs/plans/2026-10-26-windows-onboarding.md
@@ -101,14 +101,14 @@ Windows 是桌面应用的主要平台:0.2.0 到 0.2.2 三个版本的安装
| 有卡片时 | 空着,由卡片自己的第一句说(15/20、600,在已定的文字上面):推荐盘「C 盘有点挤」(盘不够)或「这里不让我放东西」(没有写入权限),「会放在…」那张「我多加了一层文件夹」,被拒绝的「这里放不了」,找不到数据文件夹「数据不在原来的地方了」;导入的几张见第 4 节;失败的卡没有 | 隐藏 |
- 话跟着鲸鱼走(停在哪一站、正在游哪一段、就绪),从不抢在它前面。每句至少能读 300 ms 才被换掉,一般停 0.9 秒(招呼 1.5 秒,「找到了」0.7 秒);中间跳过的话以后不补说。失败和 180 秒的问题马上说。「进去吧」等上一句能读满 400 ms 才上,上屏 300 ms 后开始庆祝。鲸鱼沉下去、换个新文件夹重新开始时,话和提示都空着。失败时不画叉,鲸鱼失败的姿势和那句话就是失败。一般的首次启动,用户读到的是「嗨,我是总管」→「热身中,等我一下」→「开门去了」→「进去吧」:数据文件夹这一步通常在招呼读完之前就做完了。
-- **一般情况下什么都不问**,用默认位置。先看是不是重装(下一条),再看要不要出位置卡片。选位置的卡片只有推荐盘这一张,它上面的按钮都已经试写通过,不会点了再被拒绝;每张卡都说明以后在哪里改:
+- **一般情况下什么都不问**,用默认位置,但页面上写着放在哪、能换:底注右边一行「数据放在 C 盘(剩 412 GB)· 换个位置…」([启动窗口](2026-10-26-start-window.md) 第 2、4、6 节),什么都不点就按它走;点「换个位置…」才开系统选择框,定根和下面「一个位置」一样,定好后引擎在新文件夹重新起、鲸鱼沉下去重新开始(启动窗口第 7 节),默认位置上这一次建的文件夹删掉。重装没有这一行,导入复制完以后收起。先看是不是重装(下一条),再看要不要出位置卡片。选位置的卡片只有推荐盘这一张,它上面的按钮都已经试写通过,不会点了再被拒绝;每张卡都说明以后在哪里改:
- 数据所在的盘不到 5 GB(有团队要导入时,不到「5 GB + 导入卡上要多占的数」),而且有更好的盘:「C 盘只剩 1.2 GB。放到 D 盘(剩 412 GB)?」〔放到 D 盘〕〔仍然放在 C 盘〕,按钮行末尾一个小链接「其他位置…」。按 Enter 就是放到 D 盘。没有更好的盘就不出卡片,只在提示行写一句「C 盘只剩 1.2 GB」,照常启动。
- 默认位置不能用(没有写入权限):第一句换成原因「DeepSeek Bot 没有权限在 `C:\Users\<用户名>` 里写文件。」,第二句一样;按钮只有〔放到 D 盘〕和小链接「其他位置…」,没有〔仍然放在 C 盘〕。没有可推荐的盘时只有〔选择其他位置…〕。
- 保存过的数据文件夹找不到了(多见于以后的启动):「找不到数据文件夹 `D:\DeepSeek Bot\data`。可能是移动硬盘没插上,或者文件夹被移走、删除了。旧数据不会被改动。」〔重试〕〔重新找到它…〕〔用新的空白团队开始…〕。〔重新找到它…〕不走定根的规则:选中的文件夹本身或它下面的 `data` 里有 `.deepseek-bot` 标记和 `bot/state.json`(所以 `~/.dsh` 永远不算),又通过位置规则(不在 DSH 的家里、不在程序目录里),就把它写成数据文件夹;旁边有 `workspace` 时总工作区一起改过去,没有就不动。否则卡上写「这里没有 DeepSeek Bot 的数据。」,〔重新找到它…〕留着。
- **重装不问。** 没有保存的位置、而 `C:\Users\<用户名>\.ds-bot` 里有团队时(重装过,或者 `%APPDATA%` 被清过),直接接着用:不出推荐盘的卡片,盘不够只在提示行写一句「C 盘只剩 1.2 GB」,要搬去 设置 → 通用 → 位置 →〔移到…〕;写不进去直接是恢复页。第 2 站的提示行写「上次的 6 个 Bot 和 2 个群聊都在」,不写路径,接模型的那句提示也不显示。旧团队登记的总工作区启动页不知道:插件启动后经 `teamWorkspaceChanged` 报告一次,应用据此写 `locations.json` 的 `workspace`。想要空白团队的人去 设置 → 通用 → 位置 →「用新的空白团队开始…」。只认默认位置:放在别处、又没有保存位置的旧数据找不到,和今天一样。
- **推荐的盘**怎么来:只在数据所在的盘不到门槛(5 GB,有团队要导入时加上要多占的数:对话 1.2 GB 加默认要复制的工作文件 3.4 GB,就是不到 9.6 GB)、或默认位置不能用时查一次(重装接着用时不查),正常启动不查。这一步在引擎预热之前,所以迁移用户先看到推荐盘的卡,再看到导入卡。用完整路径的 `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive`(`windowsHide`,5 秒超时)读 `Win32_LogicalDisk` 和 `Get-Partition | Get-Disk`:只要固定盘(`DriveType` 3)、`FreeSpace` 不为空、总线不是 USB、SD、MMC 或虚拟盘的,再用 `fs.statfs` 确认一次。盘不够时排除数据现在所在的盘;默认位置不能用时可以推荐同一个盘上的 `X:\DeepSeek Bot`。取剩余空间最大、而且不少于 20 GB 的一个。`X:\DeepSeek Bot` 已经存在时按下面定根的规则判断,不能用就不推荐这个盘。试写只建缺的那几层,写完删掉自己建的。PowerShell 失败、超时或被策略禁掉,都当作没有更好的盘。macOS 和 Linux 不推荐盘,空间不够只在提示行写一句。
- **一个位置。** 用户换位置时只选一个文件夹,由它定出根 `R`:选的是磁盘根目录,`R` 是它下面的 `DeepSeek Bot`;选的文件夹不存在或是空的,`R` 就是它;选的文件夹是 DeepSeek Bot 以前的根(`data` 里有 `.deepseek-bot` 标记,没有团队或者只有一个没说过话的空白团队),`R` 也是它;其余非空的文件夹,`R` 是它下面的 `DeepSeek Bot`。`R` 已经存在、非空、又不是以前的根时,不能用。数据放在 `R\data`,Bot 的文件放在 `R\workspace`(子文件夹的名字待定);两者是兄弟,互不包含,和默认的 `~\.ds-bot`、`~\DeepSeek Bot` 一样是同一个父文件夹下的兄弟,所有规则不变。〔放到 D 盘〕就是 `D:\DeepSeek Bot\data` 加 `D:\DeepSeek Bot\workspace`。默认安装的路径不改(待定)。设置里也是一处:「位置」一行显示两个路径,一个〔移到…〕一起搬(第 8 节);要分开放的在「高级」里。
-- 只有点了「其他位置…」才打开系统选择框,挂在窗口上,从推荐的盘开始,没有推荐的盘就从现在的数据文件夹的上一级开始。选完先定根,`R\data` 和 `R\workspace` 都对照现在的数据文件夹和总工作区过一遍位置规则,再试写。都通过了:`R` 就是用户选的文件夹时直接用,不再确认;应用加了一层 `DeepSeek Bot` 时,同一张卡片变成「会放在 `D:\DeepSeek Bot`」〔继续〕〔重新选〕,只在应用改了用户选的路径时才确认。没通过(没有写入权限、在 OneDrive 里、`R` 是别人的非空文件夹),卡片写一句原因,〔重新选〕作主按钮,来时那张卡的〔放到 D 盘〕〔仍然放在 C 盘〕照旧留着;选择框被取消就回到来时的卡。DSH 数据的规则只在那个文件夹真的存在时才检查。
+- 只有点了「其他位置…」才打开系统选择框,挂在窗口上,从推荐的盘开始,没有推荐的盘就从现在的数据文件夹的上一级开始。选完先定根,`R\data` 和 `R\workspace` 都对照现在的数据文件夹和总工作区过一遍位置规则,再试写。都通过了:`R` 就是用户选的文件夹时直接用,不再确认;应用加了一层 `DeepSeek Bot` 时,同一张卡片变成「会放在 `D:\DeepSeek Bot`」〔继续〕〔重新选〕,只在应用改了用户选的路径时才确认。没通过(没有写入权限、在 OneDrive 里、`R` 是别人的非空文件夹、在 DSH 的家里、在程序文件夹里),卡片写一句原因,〔重新选〕作主按钮,来时那张卡的〔放到 D 盘〕〔仍然放在 C 盘〕照旧留着;选择框被取消就回到来时的卡。DSH 数据的规则只在那个文件夹真的存在时才检查。位置行的「换个位置…」走同一条路,没有来时的卡:取消就回到位置行,已经出的「会放在…」「这里放不了」也收回。选了现在的根或数据文件夹就当没选;选在现在的数据文件夹里面不行,总工作区还空着时可以成为新的根。
- 首次启动的位置检查和「移到…」用同一套规则检查定出的根:不能是整个磁盘、不能是别人的非空文件夹,外加一次试写。
- `locations.json` 只在引擎第一次成功启动(`ready`)、导入问题也答完之后才写。同时写一份 UTF-16LE 的 `locations.ini` 给卸载程序读。应用自己新建的数据文件夹里放一个不含任何机密的 `.deepseek-bot` 标记,这个标记在建文件夹时就写、不等 `ready`:首次启动没走完就退出时,留下的文件夹下次才认得出是自己建的(定根规则里的「以前的根」),不会被当成别人的非空文件夹。「首次启动没走完就退出时什么都不记」的规则不变:记的只是 `locations.json`。每次启动先删掉上次留下的暂存(路径记在 `%APPDATA%` 里,加上数据文件夹里所有的 `.import-*` 和 `.import-check-*`)。
- 然后加载引擎的页面:DSH 的「预览版说明」→「继续」。DSH 自己的「开始使用」和「添加一个 API Key」不再自动出现:应用在自己的 profile 补丁(和 `search-patch.mjs` 一样经 `runProfile` 的 `patchFiles` 传入)里设 `ui-settings-models` 的 `credentialOnboarding: false`,这是 DSH 有文档的配置。补丁会替换这一行的整个 `config`,所以每次升级锁定的 DSH 都对照新版本重写这一行。应用的补丁里只有这一行。
@@ -308,6 +308,7 @@ Windows 是桌面应用的主要平台:0.2.0 到 0.2.2 三个版本的安装
| [桌面应用](2026-10-16-desktop-app.md)「首次启动分别选数据位置和总工作区……用的是系统对话框」 | 窗口先出来,显示应用自己的启动页;默认位置直接用,只在需要时出卡片;换位置只选一个文件夹,按第 3 节定根 `R`,数据和总工作区一起放在 `R\data` 和 `R\workspace`;盘不够或默认位置不能用时先推荐一个固定盘,系统选择框只在「其他位置…」之后,只在应用改了所选路径时才确认 |
| 同上「两个位置不能一个在另一个里面」 | 保留;一个位置的两个子文件夹是兄弟,不互相包含 |
| 本文首稿 §3「找到以前的 DS Bot 数据……〔接着用(推荐)〕〔用新的空白团队开始…〕」 | 不问,直接接着用;空白团队在设置里 |
+| 本文 2026-10-28 首稿 §3:首次启动不写路径,自己选位置只在推荐盘的卡上有「其他位置…」 | 启动页底注右边写「数据放在 C 盘(剩 412 GB)· 换个位置…」,随时能换;维护者 2026-10-28:「给出建议,同时提供自行选择的接口,避免小弹窗」 |
| 本文首稿「不做什么」:不扫描 D: 到 Z: 去推荐数据位置 | 只在盘不够或默认位置不能用时枚举一次固定盘,可移动盘、网络盘和光驱仍然一概不碰 |
| 本文首稿 §3「OneDrive 里的总工作区只提醒,不拒绝」 | 一个位置之下总工作区和数据是兄弟,位置在 OneDrive 里就整个不能用,首次启动不再有这张提醒卡 |
| 同上 换数据位置「选一个空文件夹或新文件夹……也不能选整个磁盘」 | 选磁盘根目录或别人的非空文件夹时,应用在里面加一层 `DeepSeek Bot`(第 3 节定根的规则),只在加了这一层时确认 |
@@ -383,7 +384,7 @@ Windows 是桌面应用的主要平台:0.2.0 到 0.2.2 三个版本的安装
- 打包后的 Windows CI,用名为「测试 用户」、没有「下载」文件夹、没有 `~/.dsh` 的一次性用户:进程启动后 2 秒内窗口可见(目标 1 秒,CI 留余量);引擎的页面之前不出现任何卡片;能进到引擎的页面。
- 启动页(同一个 CI,中英文各一遍):首次启动没有标题、三站的标记和说明段落;鲸鱼的话按第 3 节的顺序出现,每句至少能读 300 ms 才被换掉,跳过的不补;提示行只在第 2、3 站有字(例外是盘不够时前 10 秒的「C 盘只剩 1.2 GB」和 45 秒的〔打开日志文件夹〕);「已用 N 秒」5 秒起出现;在 720 × 540 和 720 × 500 下没有一行字折行或被省略号截断,页面不能滚动;读屏的「启动进度」列表和朗读区照旧报阶段。
- 交接:首次启动 `handoffShow` 在鲸鱼停到第 3 站后 1.3 秒内(原型实测 1.09 到 1.17 秒);启动窗口在约 300 ms 里至少经过一个中间尺寸,长到主窗口的矩形;主窗口在鲸鱼停到第 3 站后 2 秒内可见,矩形和启动窗口长成的一样(`ready()` 到达时鲸鱼还在游的,这两个时间最多各晚 600 ms);页面不发 `handoffShow` 时,主进程在 `ready()` 后 2.5 秒自己显示主窗口(以后的启动 0.8 秒,重试或重新开始后庆祝的那次也是 2.5 秒);减少动态效果时窗口不长大,`handoffShow` 时主窗口直接出现。
-- 首次启动期间没有一个 `dialog.show*` 不挂在主窗口上(单元测试扫描调用处),窗口出来之前没有系统对话框。
+- 首次启动期间没有一个 `dialog.show*` 不挂在主窗口上(单元测试扫描调用处),窗口出来之前没有系统对话框;位置和总工作区不问(没有「欢迎」对话框),系统选择框只在点了位置行的「换个位置…」以后出现,取消它什么都不变。
- 数据所在的盘不够 5 GB(CI 用替身的空间查询):只有一张卡片、一个主按钮,按 Enter 就过,不出现系统选择框。枚举盘的 PowerShell 只在盘不够或默认位置不能用时运行一次,正常启动和重装的日志里没有它;没有剩余 20 GB 以上的其他固定盘时不出卡片,提示行写剩余空间。〔放到 D 盘〕之后 `D:\DeepSeek Bot\data` 和 `D:\DeepSeek Bot\workspace` 都存在,`locations.json` 指向它们;〔仍然放在 C 盘〕之后 D 盘上没有留下试写建的文件夹。
- 有 `~/.ds-bot` 团队、没有 `locations.json` 的一次性用户:没有卡片,C 盘不到 5 GB 时也没有,第 2 站的提示行写「上次的 N 个 Bot 和 N 个群聊都在」(数字是那个团队的),进去就是原来的团队。
- 导入:点〔复制过来〕后,对话复制完团队就打开,`bot/work-files.json` 记着工作文件没复制完;工作文件在后台到齐后记成已完成;复制一半退出再启动会接着复制,已有的文件一个不覆盖;〔先不复制〕不重启引擎,暂存已删。
@@ -489,3 +490,4 @@ Windows 是桌面应用的主要平台:0.2.0 到 0.2.2 三个版本的安装
- 2026-10-27:维护者要求空间不能占两份:§4 加「空间只占一份」(对话只复制一次、附件改名进位、第一段和第二段各有空间下限、卡片写明多占多少、设置里显示原团队的位置和大小);§8 的〔移到…〕改成真正的搬(同一个卷改名,不同的卷复制完删旧的),恢复页的〔换个位置…〕同样。评审后补正:暂存前先查锁,占用卡和「正在下载」卡有〔先不复制〕;标记在建文件夹时就写,每次启动先删上次的暂存;〔移到…〕只搬应用自己建的文件夹、按「搬到一半」记录退回、逐个搬工作文件、搬前查空间;复制团队和空白团队不删现在的团队,设置里列出「以前的团队」;〔重新找到它…〕的规则;被拒绝的位置卡留着来时的按钮;Bot 知道工作文件还没到齐,`workDir` 在 `~/.dsh` 里的改到新总工作区;空间例子改成 1.7 / 1.5 / 0.2 GB;推荐盘的门槛加上导入要多占的数;Key 余额为零的卡加〔换一种方式〕;允许名单补 DSH Desktop、DSH Web、提供商名和用户起的名字。
- 2026-10-27:接模型的三条改进写进 §5 和 M2:桌面应用里登录页在应用自己的登录窗口里打开,不离开应用,打不开时才退回系统浏览器;现成的 Key(DeepSeek Harness 的凭据、设置卡期间的剪贴板)一键用,照样先检查再保存;聊天里整段是 Key 的草稿拦下来,问保存还是发送。`dsBotApp` 加 `signIn` 和 `foundKeys()` / `takeKey()`;「需要 DSH 提供的」加第 13、14 条;剪贴板是否保留、〔去充值 ↗〕在哪里打开列入待定。评审后补正:DSH 开的空白弹窗改不了 partition,登录窗口由应用另建、两者同生同灭;允许名单只管主框架,授权页来源从第一次导航取;回调不看状态码,`onClosed` 带原因,回调发出后关窗不算取消;代理提示不提引擎的开关;环境变量的 Key 是「来源 env」不是「不可写」;mock 加三把 DeepSeek 格式的 Key;现成 Key 一行一个主按钮、两处合并、`takeKey` 核对前八位;聊天卡按状态选文案,加〔清掉〕和「改一下」,和模型锁合算一个 block,发送走输入框自己的 `submit()`;草稿存在 localStorage、充值页要再登录记进已知限制。第二轮补正:登录窗口的 session 只放行主框架的回调,不照抄 Bot 浏览器拦引擎的规则;新窗口等旧 partition 清完再开;`onClosed` 带代理,打不开的卡有〔取消〕;登录中点鲸鱼菜单或修复卡只打开 DSH 的登录框;窗口里新开的链接一律去系统浏览器;被拒的现成 Key 不再推荐;聊天卡写明检查没通过时的按钮、余额为零的〔知道了〕和 `request_secret` 卡的按钮;「放过」在 DSH 清空草稿时仍在。
- 2026-10-28:维护者 2026-10-27 的反馈写进 §3 到 §6、§8 和 M2、M4,分三部分。一是「鲸鱼即进度」的启动页:小窗口显示的是实现的结构(一条带三个点的线和几段说明),不是用户感受到的东西;现在鲸鱼停在哪一站就是到了哪一步,一次一句鲸鱼的话,提示行只说接下来要准备什么,5 秒起显示已用秒数,卡片的第一句也由鲸鱼说,重装的小字改成提示,180 秒改成鲸鱼的问题,交接时启动窗口长成主窗口。二是目标卡可以多选,按〔确定〕提交,几个目标按卡上的顺序合并成一份建议。三是上手后半段的 AI-native 方案:开场白改成固定文字、不调用模型,然后是目标卡、建议卡和第一件事卡,只在用户写了字或要换一组时调用模型,整个上手最多 3 次请求,深度限制写成机制(步骤表在代码里、工具受限、每一步一次请求和时限、模型关着也能走通的卡、mock 模型的 CI);「试试:」的三个固定任务留作〔跳过〕的路和补位。依据:启动窗口和团队窗口的原型及其检查(`handoffShow` 在就绪后 1.09 到 1.17 秒,窗口 300 ms 长大,目标卡和合并的用例)和 2026-10-27 给维护者的 AI-native 评估。合并的上限、第一件事的分法、单个目标的摘要、水线和启动页的大小列入「待定」。评审后补正:第一件事一发出就解除工具限制,它是不受上手限制的正常回合,灰字仍在它回复以后;建议卡建的 Bot 的招呼也是固定文字,整个上手确实最多 3 次请求;JSON 调用只有一组时限(8 秒第一个字、12 秒回完),整轮 20 秒只管上手期间 Main Bot 会话里的回合,兜底最坏 12 秒;schema 带 `goal` 和任务的草案序号,合并按 `goal` 走,模型的摘要只在用户的话太长时用;〔换一组建议〕由模型换一组不重复的;目标卡输入框里整段是 Key 时不发给模型;上手结束从会话里读(灰字或用户自己的消息),中途重开从目标卡重新开始,「取舍」写明这一点;一个会话的 block 按模型锁、上手锁、Key 排,上手锁有自己的占位,开场白不再说「直接说就行」;接上模型前发出的消息算 Main Bot 的第一个正常回合,不再出目标卡;修复卡的「重新留着」只管模型写的招呼;合并的上限和分法按已定的写,「待定」改成要不要改;「一轮多少钱」改用第一件事的回合实测;第 5 节写明侧栏磁贴上的鲸鱼,开场白和目标卡的时间从设置卡收起时算;以后的启动照 [启动窗口](2026-10-26-start-window.md) 第 5 节写,记进「改动的已定设计」;交接的验收从鲸鱼停到第 3 站算;`askSteward` 只是形态相同,上限是这次调用自己的;「水圈」统一叫「圈」,「三站」改成「三站的标记」;导入的检查行去掉破折号;45 KB 那条待定照启动窗口稿写;M4 加八种动作和磁贴上的鲸鱼,估计改成 10 人日。复核后补正:问候里的名字、`dsBotApp` 的露面事件(待定)和以后的启动庆祝那次的 2.5 秒兜底与启动窗口稿对齐;交接验收的 1.2 秒放宽到 1.3 秒,给 CI 留余量。
+- 2026-10-28(第二次):落地 M4 第一批时维护者看到首次启动仍弹「欢迎使用 DeepSeek Bot」的系统对话框(「我主要不喜欢这个」),要求「给出建议,同时提供自行选择的接口,避免小弹窗」:§3 的「什么都不问」补上启动页底注右边的位置行「数据放在 C 盘(剩 412 GB)· 换个位置…」,点了才开系统选择框,定根和「一个位置」一样,被拒绝的原因加上 DSH 的家和程序文件夹,定好后引擎在新文件夹重新起(启动窗口稿第 2、4、6、7 节);验收加一条。导入问题在 M5 的导入卡落地前仍是挂在启动窗口上的对话框。