Skip to content

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

Keep the data out of the whole macOS app bundle

Fei24115b85c7d50f62
diff --git a/app/src/first-run.mjs b/app/src/first-run.mjs
index f4e820cb..cc8c60f0 100644
--- a/app/src/first-run.mjs
+++ b/app/src/first-run.mjs
@@ -5,6 +5,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from '
import { homedir } from 'node:os'
import { dirname, join } from 'node:path'
import { findTeam, newerSessions, teamInUse, userDshHome, within } from './import.mjs'
+import { installFolder } from './move-data.mjs'
const TEXT = {
en: {
@@ -92,9 +93,11 @@ async function pick(title, current, signal) {
return canceled ? current : filePaths[0]
}
+export const programFolder = () => installFolder(app.getPath('exe'))
+
function placeProblem(t, dataDir, workspace) {
const dsh = userDshHome()
- const program = dirname(app.getPath('exe'))
+ const program = programFolder()
if (within(dataDir, workspace)) return t.dataInWorkspace
if (within(workspace, dataDir)) return t.workspaceInData
for (const path of [dataDir, workspace]) {
diff --git a/app/src/main.mjs b/app/src/main.mjs
index 30a1d05e..f2c30147 100644
--- a/app/src/main.mjs
+++ b/app/src/main.mjs
@@ -11,7 +11,7 @@ import { setTimeout as sleep } from 'node:timers/promises'
import { fileURLToPath } from 'node:url'
import { getDshRuntimeVersion } from '@deepseek-ai/dsh-app-boot'
import electronUpdater from 'electron-updater'
-import { chooseLocations, localeText, saveLocations, text } from './first-run.mjs'
+import { chooseLocations, localeText, programFolder, saveLocations, text } from './first-run.mjs'
import { HostProcess } from './host-process.mjs'
import { copySessions, findTeam, importTeam, teamInUse, userDshHome } from './import.mjs'
import { copyData, moveProblem } from './move-data.mjs'
@@ -283,7 +283,7 @@ async function moveData(workspace) {
if (canceled || filePaths[0] === undefined) return false
const to = resolve(filePaths[0])
const dshHome = userDshHome()
- const problem = moveProblem({ from: places.dataDir, to, workspace, dshHome, program: app.isPackaged ? dirname(app.getPath('exe')) : undefined })
+ const problem = moveProblem({ from: places.dataDir, to, workspace, dshHome, program: app.isPackaged ? programFolder() : undefined })
if (problem !== undefined) {
await dialog.showMessageBox(owner, { type: 'warning', title: 'DeepSeek Bot', message: problem === 'dsh' ? t.inDsh(dshHome) : t[MOVE_PROBLEMS[problem]], buttons: ['OK'] })
return false
diff --git a/app/src/move-data.mjs b/app/src/move-data.mjs
index 9d666499..d166fd78 100644
--- a/app/src/move-data.mjs
+++ b/app/src/move-data.mjs
@@ -26,6 +26,14 @@ function real(path) {
return join(realpathSync.native(at), ...rest)
}
+/** The folder that an update or uninstall replaces: on macOS the whole .app bundle. */
+export function installFolder(exe, platform = process.platform) {
+ if (platform === 'darwin') {
+ for (let at = dirname(exe); dirname(at) !== at; at = dirname(at)) if (at.endsWith('.app')) return at
+ }
+ return dirname(exe)
+}
+
/**
* What keeps `to` from being the new data location, or undefined.
* @param {{ from: string, to: string, workspace?: string, dshHome: string, program?: string }} places
diff --git a/app/test/move-data.test.mjs b/app/test/move-data.test.mjs
index 4f4dda5b..95d91097 100644
--- a/app/test/move-data.test.mjs
+++ b/app/test/move-data.test.mjs
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlink
import { tmpdir } from 'node:os'
import { dirname, join, parse } from 'node:path'
import { test } from 'node:test'
-import { copyData, moveProblem } from '../src/move-data.mjs'
+import { copyData, installFolder, moveProblem } from '../src/move-data.mjs'
const write = (path, text) => {
mkdirSync(dirname(path), { recursive: true })
@@ -58,6 +58,11 @@ test('the new data location is an empty or new folder apart from the data, the t
assert.equal(problem(join(root, 'full', 'note.txt')), 'notEmpty')
})
+test('the program folder is the whole app bundle on macOS', () => {
+ assert.equal(installFolder('/Applications/DeepSeek Bot.app/Contents/MacOS/DeepSeek Bot', 'darwin'), '/Applications/DeepSeek Bot.app')
+ assert.equal(installFolder(join('C:', 'Programs', 'DeepSeek Bot', 'DeepSeek Bot.exe'), 'win32'), join('C:', 'Programs', 'DeepSeek Bot'))
+})
+
test('the data is copied whole, without the lock and the temporary folders, and the old folder stays', async (t) => {
const { root, from } = setup(t)
const before = files(from)