Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ jobs:
cache: npm
- run: npm install -g npm@11 --no-fund --no-audit
- run: npm ci --no-fund
- run: npm run lint
- run: npm run check:styles && npm run check:themes && npm run check:structure
- run: npm run check:i18n && npm run check:rawtext
- run: npm run check:static
- run: npm test

# Both platforms the app ships on. Windows is here because the release build
Expand Down Expand Up @@ -65,12 +63,36 @@ jobs:
- name: Guard against unexpected install warnings
shell: bash
run: node scripts/check-install-warnings.mjs npm-ci.log
- run: npm run check # ESLint + Vitest
- run: npm run build # ensure it bundles
- name: The whole gate
if: runner.os != 'Windows'
run: npm run check
# Every test and guard, without coverage instrumentation: coverage is a
# measurement, not a test, and its floors are enforced on ubuntu above.
- name: Guards and lint
if: runner.os == 'Windows'
run: npm run check:static
- name: Unit tests, without coverage
if: runner.os == 'Windows'
run: npm test
- name: Build
if: runner.os == 'Windows'
run: npm run build

# Packages the real exe and launches it, in parallel with check rather than after it.
packaged:
runs-on: windows-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- run: npm install -g npm@11 --no-fund --no-audit
- run: npm ci --no-fund
- run: npm run build
# Claude Desktop launches `Diff Bro.exe mcp` with piped stdio; whether a
# GUI-subsystem exe keeps those pipes can only be proven on Windows.
- name: Claude connection answers over stdio (packaged exe)
if: runner.os == 'Windows'
shell: bash
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
Expand All @@ -80,7 +102,6 @@ jobs:
# The GUI launch of the same package: e2e runs build/ from the repo, so a file
# the package leaves out or a Windows-only startup step is invisible to it.
- name: Packaged app starts clean
if: runner.os == 'Windows'
run: node scripts/packaged-smoke.mjs dist

# One bundle for every shard: building in each shard was most of its fixed cost.
Expand Down Expand Up @@ -153,7 +174,7 @@ jobs:
# which starts a single display and owns DISPLAY itself.
- name: Start a virtual display per worker
run: bash scripts/e2e-displays.sh
- uses: actions/download-artifact@v6
- uses: actions/download-artifact@v8
with:
name: e2e-build
path: build/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
# and nsis) on every single run. Keyed on the lockfile, so an Electron bump
# misses and refetches rather than packaging a stale runtime.
- name: Cache the Electron + electron-builder downloads
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-ebuilder-${{ hashFiles('package-lock.json') }}
Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Mint a token for the version-sync App
uses: actions/create-github-app-token@v2
uses: actions/create-github-app-token@v3
id: app-token
with:
app-id: '4412629'
Expand Down
5 changes: 4 additions & 1 deletion docs/standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,10 @@ system-ui, sans-serif`, at `--font-md` 13px, `--font-sm` 12px and
works everywhere over one guarded by `process.platform`: spawn `process.execPath`
against a package's own `bin`, compare generated text line-ending agnostically.
E2E stays Linux-only (it needs Xvfb), so a Windows INTERACTION bug still has to
be found by hand.
be found by hand. Windows runs every guard and test (`check:static`, `npm test`,
the build) without coverage instrumentation: coverage is a measurement, not a
test, and its floors are enforced on ubuntu. A separate `packaged` job builds
the real exe and runs both smokes in parallel.

- **macOS-only E2E runs on the Mac, not in Docker.** Some window-lifecycle bugs
cannot exist on Linux — closing the last window quits the app there
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"check:styles": "node scripts/check-style-tokens.mjs",
"check:themes": "node scripts/check-theme-depth.mjs",
"format": "prettier --write \"src/**/*.{js,vue,css}\" \"tests/**/*.js\" \"*.mjs\"",
"check": "npm run lint && npm run check:styles && npm run check:themes && npm run check:structure && npm run check:i18n && npm run check:rawtext && npm run test:coverage && npm run build",
"check": "npm run check:static && npm run test:coverage && npm run build",
"check:static": "npm run lint && npm run check:styles && npm run check:themes && npm run check:structure && npm run check:i18n && npm run check:rawtext",
"postinstall": "electron-builder install-app-deps",
"build:win": "npm run build && electron-builder --win --publish never",
"build:mac": "npm run build && electron-builder --mac --publish never",
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/releaseVerified.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const OURS = /^(quick|check|e2e)\b/
const REQUIRED = ['check (ubuntu', 'check (windows', 'e2e (']
const OURS = /^(quick|check|packaged|e2e)\b/
const REQUIRED = ['check (ubuntu', 'check (windows', 'packaged', 'e2e (']

// Judges CI on the tagged commit itself, so nothing is assumed about how it was merged.
export function releaseVerdict(checkRuns) {
Expand Down
23 changes: 9 additions & 14 deletions src/main/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { readFileSync } from 'fs'
import { join } from 'path'
import { DEV_URL } from './env'
import appIcon from '../../resources/icon.png?asset'
import { createStateSaver } from './windowStateSaver'

// --- Window state persistence (size/position across launches) ---

Expand All @@ -27,20 +28,14 @@ function loadWindowState() {
}

function trackWindowState(win) {
let timer = null
const save = () => {
const bounds = win.getNormalBounds()
writeFile(windowStatePath(), JSON.stringify({ ...bounds, maximized: win.isMaximized() })).catch(
() => {}
)
}
const debounced = () => {
clearTimeout(timer)
timer = setTimeout(save, 500)
}
win.on('resize', debounced)
win.on('move', debounced)
win.on('close', save)
const saver = createStateSaver({
snapshot: () => ({ ...win.getNormalBounds(), maximized: win.isMaximized() }),
write: (state) => writeFile(windowStatePath(), JSON.stringify(state)).catch(() => {}),
isGone: () => win.isDestroyed()
})
win.on('resize', saver.soon)
win.on('move', saver.soon)
win.on('close', saver.now)
}

// The TOOLBAR sets the width floor, not the panes — below it the whole document
Expand Down
18 changes: 18 additions & 0 deletions src/main/windowStateSaver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Closing cancels a save still pending from the last move, which would otherwise fire on a destroyed window.
export function createStateSaver({ snapshot, write, isGone, delayMs = 500 }) {
let timer = null
const save = () => {
if (!isGone()) write(snapshot())
}
return {
soon() {
clearTimeout(timer)
timer = setTimeout(save, delayMs)
},
now() {
clearTimeout(timer)
timer = null
save()
}
}
}
35 changes: 35 additions & 0 deletions tests/main/windowStateSaver.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createStateSaver } from '../../src/main/windowStateSaver'

beforeEach(() => vi.useFakeTimers())
afterEach(() => vi.useRealTimers())

function setUp() {
const win = { gone: false }
const snapshot = vi.fn(() => {
if (win.gone) throw new Error('Object has been destroyed')
return { width: 800 }
})
const write = vi.fn()
const saver = createStateSaver({ snapshot, write, isGone: () => win.gone })
return { win, snapshot, write, saver }
}

describe('saving window bounds', () => {
it('saves once, after the last of a burst of moves', () => {
const { saver, write } = setUp()
saver.soon()
saver.soon()
vi.advanceTimersByTime(500)
expect(write).toHaveBeenCalledTimes(1)
})

it('never reaches a window closed while a save was pending', () => {
const { win, saver, write } = setUp()
saver.soon()
saver.now()
win.gone = true
expect(() => vi.advanceTimersByTime(500)).not.toThrow()
expect(write).toHaveBeenCalledTimes(1)
})
})
5 changes: 5 additions & 0 deletions tests/scripts/releaseVerified.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const FULL = green(
'quick',
'check (ubuntu-latest)',
'check (windows-latest)',
'packaged',
'e2e-build',
'e2e (1)',
'e2e (2)'
Expand All @@ -30,6 +31,10 @@ describe('releaseVerdict', () => {
)
})

it('retests when the packaged-app job is missing, so a broken package is never reused', () => {
expect(releaseVerdict(FULL.filter((r) => r.name !== 'packaged')).verified).toBe(false)
})

it('ignores check runs from other workflows', () => {
expect(releaseVerdict([...FULL, { name: 'CodeQL', conclusion: 'neutral' }]).verified).toBe(true)
})
Expand Down
1 change: 1 addition & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default defineConfig({
'src/main/sealingTtl.js',
'src/main/launchGuard.js',
'src/main/startSteps.js',
'src/main/windowStateSaver.js',
'src/main/lan/acks.js',
'src/main/lan/itemReceiver.js',
'src/main/lan/peerName.js',
Expand Down
Loading