Files
openwork/packages/server/src
Jason Kneen 997a8ed3e9 refactor: codebase quality improvements — types, tests, error handling (#592)
* fix(desktop): suppress unused variable warnings in manager modules

Prefix unused `child` bindings with underscore in engine and openwork_server
managers to silence Rust compiler warnings.

* refactor(app): remove `as any` casts with typed SDK helpers

Create lib/opencode-session.ts that wraps OpenCode SDK session operations
(abort, revert, unrevert, shell, command listing) with proper types.

Replace all `(c.session as any).abort/revert/unrevert` and
`(c.command as any).list` calls in app.tsx with the typed helpers.

The SDK v2 already exposes these methods with full type definitions —
the casts were unnecessary and bypassed type safety on critical API paths.

* refactor(app): extract OpenWork server connection store

Create context/openwork-server.ts that encapsulates all OpenWork server
connection state: 15 signals, 6 polling effects, derived memos for
baseUrl/auth/client, and the health check helper.

This is a standalone module ready to replace the corresponding state in
app.tsx. It follows the same factory pattern as createSessionStore and
createExtensionsStore.

* feat(app): add safe execution utilities for error handling

Create lib/safe-run.ts with safeAsync, safeSync, and fireAndForget
helpers that replace bare `catch {}` blocks. Errors are logged in
development mode and silently swallowed in production.

This provides a migration path for the ~50 silent catch blocks.

* test(server): add unit tests for validators, utils, and token service

Add 41 new tests across 3 test files:

- validators.test.ts: sanitizeCommandName, validateCommandName,
  validateMcpName, validateSkillName, validateMcpConfig (22 tests)
- utils.test.ts: hashToken, shortId, parseList, ensureDir/exists (10 tests)
- tokens.test.ts: TokenService CRUD, scope resolution, revocation (9 tests)

Total server test count: 48 (from 7 previously).

---------

Co-authored-by: Benjamin Shafii <benjamin.shafii@gmail.com>
2026-02-17 10:53:11 -08:00
..
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00
2026-01-26 23:00:47 -08:00