refactor: improve code quality with stricter TypeScript and memory leak prevention

- Add stricter TypeScript compiler flags (noUnusedLocals, noUnusedParameters,
  noImplicitReturns, noImplicitOverride, noFallthroughCasesInSwitch,
  allowUnreachableCode, allowUnusedLabels)
- Remove unused variables caught by stricter flags:
  - Remove unused `renameSession` destructuring in App.tsx
  - Remove unused `BG_GRAY` constant in DirectAttach.ts
  - Remove unused `INPUT_BATCH_INTERVAL` constant in useSessionManager.ts
- Add proper EventEmitter cleanup to RalphLoop:
  - Store bound event handlers for cleanup
  - Add cleanupEventHandlers() method
  - Add destroy() method for complete cleanup
  - Add destroyRalphLoop() singleton cleanup function
- Update ralph-loop tests to use destroy() instead of stop() to prevent
  MaxListenersExceededWarning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-21 14:01:47 +01:00
co-authored by Claude Opus 4.5
parent 8b04734538
commit c33d6e0987
6 changed files with 60 additions and 14 deletions
+2 -1
View File
@@ -124,7 +124,8 @@ describe('RalphLoop', () => {
});
afterEach(() => {
loop.stop();
// Use destroy() instead of stop() to clean up event listeners
loop.destroy();
vi.useRealTimers();
});