Repository navigation
Commit 997a8ed
refactor: codebase quality improvements — types, tests, error handling (anomalyco#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 <[email protected]>1 parent b9d5a4d commit 997a8ed
9 files changed
Lines changed: 898 additions & 43 deletions
File tree
- packages
- app/src/app
- context
- lib
- desktop/src-tauri/src
- engine
- openwork_server
- server/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
855 | 863 | | |
856 | 864 | | |
857 | 865 | | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
| 866 | + | |
875 | 867 | | |
876 | 868 | | |
877 | 869 | | |
| |||
931 | 923 | | |
932 | 924 | | |
933 | 925 | | |
934 | | - | |
| 926 | + | |
935 | 927 | | |
936 | 928 | | |
937 | 929 | | |
| |||
996 | 988 | | |
997 | 989 | | |
998 | 990 | | |
999 | | - | |
| 991 | + | |
1000 | 992 | | |
1001 | 993 | | |
1002 | 994 | | |
| |||
1019 | 1011 | | |
1020 | 1012 | | |
1021 | 1013 | | |
1022 | | - | |
1023 | | - | |
| 1014 | + | |
| 1015 | + | |
1024 | 1016 | | |
1025 | 1017 | | |
1026 | 1018 | | |
| |||
1029 | 1021 | | |
1030 | 1022 | | |
1031 | 1023 | | |
1032 | | - | |
| 1024 | + | |
1033 | 1025 | | |
1034 | 1026 | | |
1035 | 1027 | | |
| |||
1045 | 1037 | | |
1046 | 1038 | | |
1047 | 1039 | | |
1048 | | - | |
1049 | | - | |
| 1040 | + | |
| 1041 | + | |
1050 | 1042 | | |
1051 | 1043 | | |
1052 | 1044 | | |
1053 | 1045 | | |
1054 | 1046 | | |
1055 | 1047 | | |
1056 | 1048 | | |
1057 | | - | |
1058 | | - | |
| 1049 | + | |
| 1050 | + | |
1059 | 1051 | | |
1060 | 1052 | | |
1061 | 1053 | | |
| |||
1150 | 1142 | | |
1151 | 1143 | | |
1152 | 1144 | | |
1153 | | - | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
| 1145 | + | |
1168 | 1146 | | |
1169 | 1147 | | |
1170 | 1148 | | |
| |||
0 commit comments