Skip to content

chore: Taskfile + ESLint + jsdom tests + DB isolation env var - #6

Merged
JeanBaptisteRenard merged 4 commits into
mainfrom
chore/taskfile-tooling
May 22, 2026
Merged

JeanBaptisteRenard merged 4 commits into
mainfrom
chore/taskfile-tooling

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

Standardises tooling and adds the missing static analysis that would have caught the two ReferenceError regressions we shipped earlier this session.

Pieces

  1. Taskfile.yaml — `task install / dev / build / test / lint / check / ci / clean / db:reset / db:reset:dev`. Follows the Skaleet workspace convention.
  2. ESLint flat config (eslint.config.js, v9) — `no-undef` enabled with renderer globals declared. 0 errors, 204 warnings (existing tech debt).
  3. jsdom renderer tests — 8 new tests for sidebar rendering: `processProjectSessions` shape, `buildSessionsList` orphan branch, etc. Catches the variable-scope bugs from this session.
  4. Husky pre-commit hook — runs `task check` (lint + tests) before commit. `SKIP_TESTS=1 git commit` escape hatch.
  5. `SWITCHBOARD_DATA_DIR` env var — db.js honours it; main.js defaults to `~/.switchboard-dev` in `!app.isPackaged` mode. Dev electron and installed AppImage no longer race on `session_cache`.

Verify

```
task check

tests 32 / pass 32 / fail 0

0 errors, 204 warnings

```

Wraps npm scripts under task(1) with named tasks (install, dev, build,
test, lint, check, ci, clean, db:reset, install:lint). Updates README
with a Tooling section documenting the preferred workflow.
Layer 1 — ESLint 9 flat config (eslint.config.js) with no-undef enforced
on renderer (public/*.js) and main-process files. Verified statically
catches the two recent sidebar.js regressions:
  - undeclared subagentIndex in renderProjects destructure
  - out-of-scope projectPath in buildSessionsList orphan branch
Wired via "lint" + "pretest" scripts; npm test now lints first.

Layer 2 — jsdom-backed renderer tests (test/dom-setup.js, test/dom-sidebar.test.js):
  - bootstraps a JSDOM window, evaluates utils.js / icons.js / sidebar.js
    in its VM context, stubs cross-file globals (window.api, sessionMap,
    activePtyIds, etc.)
  - sample fixture: 2 top-level sessions, 3 subagents (1 orphan),
    1 starred, 1 archived
  - 7 tests covering: structural completeness, starred/archived classes,
    subagent carets, orphan group, projectPath localStorage key, empty
    project, idempotent re-render

Both bug-class regressions are now caught at lint time AND runtime.
Existing 24+ tests still green (npm test → 32 pass).

Notes:
  - Pre-existing no-unused-vars / no-redeclare warnings (204) left as
    warnings, not errors; not in scope.
  - One stray no-undef (_shellProfiles in main.js) annotated with
    eslint-disable + TODO; appears to be dead code from a refactor.
Adds husky pre-commit hook that runs `task check` when task is on PATH,
falling back to `npm run lint && npm test` otherwise. Stops bad code
from reaching origin — the two ReferenceError regressions we just fixed
(subagentIndex undefined, project.projectPath out of scope) would have
been caught locally by `task lint` before commit.

Set SKIP_TESTS=1 to skip the heavier test suite in a pinch.
Two electron instances on the same ~/.switchboard/switchboard.db race on
session_cache and crash silently. This blocked any agent that wanted to
launch dev electron while the user's installed AppImage was running.

- db.js: honour SWITCHBOARD_DATA_DIR env var, fall back to ~/.switchboard.
  Skip the legacy ~/.claude/browser/ migration when a custom dir is set so a
  fresh dev DB doesn't steal the AppImage's old data.
- main.js: !app.isPackaged → default the env var to ~/.switchboard-dev before
  db.js is required. Explicit env var overrides (test sandbox / agent run).
- Taskfile.yaml: 'task dev' sets the env var for belt-and-suspenders; new
  'task db:reset:dev' wipes just the dev DB.

Result: dev electron and installed AppImage coexist safely.
@JeanBaptisteRenard
JeanBaptisteRenard merged commit 0001c83 into main May 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant