Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 15
runs-on: ubuntu-24.04
timeout-minutes: 20

steps:
- name: 'Checkout code'
Expand All @@ -22,8 +22,8 @@ jobs:
- name: 'Install npm dependencies'
run: npm ci

- name: 'Install Playwright Electron dependencies'
run: npx playwright install --with-deps
- name: 'Install Electron system dependencies'
run: npx playwright install-deps chromium

- name: 'Build Electron app'
run: npx electron-vite build
Expand Down
18 changes: 18 additions & 0 deletions src/main/__tests__/activityTracker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import type { WindowChangeHandler, WindowInfo } from '../activity/backend'
const mocks = vi.hoisted(() => ({
insertValues: vi.fn().mockResolvedValue(undefined),
backendStart: vi.fn(),
captureAppIcon: vi.fn(),
}))

vi.mock('electron', () => ({
ipcMain: { handle: vi.fn() },
powerMonitor: { on: vi.fn() },
}))
vi.mock('../appIcons', () => ({
captureAppIcon: mocks.captureAppIcon,
}))
vi.mock('../db/client', () => ({
db: { insert: () => ({ values: mocks.insertValues }) },
}))
Expand Down Expand Up @@ -58,6 +62,7 @@ beforeEach(() => {
vi.useFakeTimers({ toFake: ['Date'] })
mocks.insertValues.mockClear()
mocks.backendStart.mockClear()
mocks.captureAppIcon.mockClear()
})

afterEach(async () => {
Expand Down Expand Up @@ -90,3 +95,16 @@ describe('handleWindowChange overlay guard', () => {
expect(saved.durationSeconds).toBe(10)
})
})

describe('handleWindowChange icon capture', () => {
it('captures the icon of each newly focused app', async () => {
vi.setSystemTime(new Date('2026-09-01T10:00:00Z'))
await initializeActivityTracker()
const onChange: WindowChangeHandler = mocks.backendStart.mock.calls[0][0]

onChange(makeWindow(1, 'Doc'))
await flush()

expect(mocks.captureAppIcon).toHaveBeenCalledWith('App')
})
})
6 changes: 6 additions & 0 deletions src/main/activityTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
type ActivityBackend,
type WindowInfo,
} from './activity/backend'
import { captureAppIcon } from './appIcons'

let activityTrackingEnabled = false
let backend: ActivityBackend | null = null
Expand Down Expand Up @@ -249,6 +250,11 @@ async function handleWindowChange(windowInfo: WindowInfo): Promise<void> {
return
}

// Grab the icon while the app is running so history views can show it later
if (activityTrackingEnabled) {
captureAppIcon(windowInfo.info.name || windowInfo.info.execName)
}

// Remember focus changes while paused without starting the clock.
if (trackingPaused) {
lastWindowInfo = windowInfo
Expand Down
Loading
Loading