A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Exit when a first-run quit cannot answer
klarkxy1cd048aa72d4
diff --git a/app/src/main.mjs b/app/src/main.mjsindex ffeb108e..60a7b5d7 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -48,6 +48,7 @@ const IPC = {// A cookie export larger than this is not a cookie export.const IMPORT_FILE_MAX = 32 * 1024 * 1024const MOVE_PROBLEMS = { drive: 'moveDrive', nested: 'moveNested', workspace: 'moveWorkspace', program: 'inProgram', notEmpty: 'moveNotEmpty' }+const CHOOSING_QUIT_WAIT_MS = 1_000const UPDATE_CHECK_WAIT_MS = 15_000const UPDATE_DOWNLOAD_WAIT_MS = 15 * 60_000@@ -142,7 +143,11 @@ if (canonical !== undefined) {// A first-run dialog is open: the quit waits for it, and the app goes on meanwhile.event.preventDefault()shell.cancelQuit()+ const stuck = choosingchoosing.abort()+ // A first run whose dialog never answers would hold every later quit the same+ // way; the app still leaves when it stays silent.+ setTimeout(() => { if (choosing === stuck) app.exit(0) }, CHOOSING_QUIT_WAIT_MS).unref()return}if (copying !== undefined) {diff --git a/app/test/helpers/app-harness.mjs b/app/test/helpers/app-harness.mjsindex 2a40999c..f0ef7d5b 100644--- a/app/test/helpers/app-harness.mjs+++ b/app/test/helpers/app-harness.mjs@@ -20,14 +20,15 @@ export const waitFor = async (check, what, timeout = 10_000) => {/*** Start the app on throwaway folders: the places are chosen already and the one-time notice* is answered, so that the app asks nothing. The Host answers when the test lets it.- * @param {{ packaged?: boolean }} options whether the app is a packaged one, with an updater+ * @param {{ packaged?: boolean, firstRun?: boolean }} options whether the app is a packaged+ * one, with an updater; a first run keeps its places unchosen, so that it asks*/-export const startApp = async ({ packaged = true } = {}) => {+export const startApp = async ({ packaged = true, firstRun = false } = {}) => {const home = mkdtempSync(join(tmpdir(), 'ds-bot-main-home-'))const workspace = join(home, 'workspace')mkdirSync(workspace, { recursive: true })mkdirSync(paths.userData, { recursive: true })- writeFileSync(join(paths.userData, 'locations.json'), JSON.stringify({ dataDir: home, workspace }))+ if (!firstRun) writeFileSync(join(paths.userData, 'locations.json'), JSON.stringify({ dataDir: home, workspace }))writeFileSync(join(paths.userData, 'tray-close-acknowledged'), '')hold()await import('../../src/main.mjs')diff --git a/app/test/main-first-run.test.mjs b/app/test/main-first-run.test.mjsnew file mode 100644index 00000000..af108cea--- /dev/null+++ b/app/test/main-first-run.test.mjs@@ -0,0 +1,31 @@+// The first run asks where the app keeps its data. A quit while it asks ends the app+// even when the dialog never answers it (#401), and the places stay unwritten.+import assert from 'node:assert/strict'+import { existsSync } from 'node:fs'+import { join } from 'node:path'+import { after, before, test } from 'node:test'+import { app, paths, state } from './helpers/fake-electron.mjs'+import { startApp, waitFor } from './helpers/app-harness.mjs'+import { installHooks } from './helpers/register.mjs'++await installHooks()++before(async () => {+ // The first-run dialog never answers.+ state.dialogAnswer = () => new Promise(() => {})+ await startApp({ firstRun: true })+})++after(() => { app.emit('will-quit') })++test('a quit while the first run is asking ends the app even when the dialog never answers', async () => {+ await waitFor(() => state.dialogs.length > 0, 'ask for the places')+ app.quit()+ assert.equal(state.quitPrevented, true, 'the quit waits for the first run')+ await waitFor(() => state.exits.length > 0, 'leave anyway')+ assert.equal(state.exits[0], 0)+})++test('the first run that is quit wrote nothing', () => {+ assert.equal(existsSync(join(paths.userData, 'locations.json')), false)+})