feat: complete TypeScript migration with cross-platform focus detection#12
Merged
feat: complete TypeScript migration with cross-platform focus detection#12
Conversation
Add tsconfig.json and tsconfig.build.json for project-references build. Update package.json with TypeScript devDependencies, build scripts, dist/ output paths, and bumped version to 1.3.3. Update .gitignore with dist/ and tsbuildinfo patterns.
Define typed interfaces for config, TTS engines, notifications, events, Linux platform support, OpenCode SDK, and test helpers. Add ambient declarations for msedge-tts and detect-terminal modules.
Migrate all util/ modules to src/util/ with full type annotations: config, tts, ai-messages, webhook, desktop-notify, focus-detect, linux, sound-theme, and per-project-sound.
Migrate index.js to src/index.ts with typed plugin hooks, session event handlers, and notification orchestration logic. Remove legacy index.js from project root.
Migrate test setup and all unit, integration, and e2e test files from .js to .ts with typed mocks, fixtures, and assertions. Update bunfig.toml preload path to tests/setup.ts.
Delete all original util/*.js modules now superseded by their typed equivalents in src/util/.
Add proper error handling for session.get() API failures so that network errors no longer accidentally let sub-session events through. Clear debounce entries when returning early for sub-sessions or API errors to keep the debounce map accurate. Introduce a 30-second TTL session cache (sessionCache Map) to reduce redundant API calls during repeated idle/error events. Cache is invalidated on session.created and expired entries are cleaned up periodically. Add debug logging across all decision branches for improved observability. Closes #11
Cover sub-session detection, API error fail-safe behavior, debounce cleanup on early returns, and session cache hit/miss/invalidation logic across both session.idle and session.error handlers (31 tests).
Add cross-platform focus detection using PowerShell with Win32 API interop on Windows and xdotool/xprop (X11) plus Sway/GNOME/KDE compositor queries on Wayland for Linux. Includes executeCommand abstraction for testable shell execution, platform-specific terminal name lists, and a comprehensive Linux-specific test suite.
Add visibility checks to cross-platform focus detection scripts: - macOS: check app visibility and filter out miniaturized windows - Windows: add IsIconic and IsWindowVisible DLL imports and checks Focus detection now returns empty when the foreground window is minimized or hidden, preventing false positive focus matches.
Replace early-return behavior on session lookup failure with a degraded notification flow that still alerts the user: - Add usedIdleSessionFallback and usedErrorSessionFallback flags - Send shorter desktop messages when session context is unavailable - Pass empty AI context in fallback mode to avoid stale data - Fix indentation inconsistency in idle/error notification blocks
… terminal lists - Change suppressWhenFocused default from true to false (opt-in) - Remove VS Code variants and JetBrains IDEs from KNOWN_TERMINALS_MACOS - Add comprehensive focus detection mock tests for Windows and macOS - Update sub-session filtering tests to match fail-safe skip behavior - Align platform support tests with current detection capabilities
- Document focus detection as cross-platform (Windows, macOS, Linux) - Update platform compatibility table with full support checkmarks - Add focus detection configuration details to example config - Update platform-specific notes for macOS focus detection
Update focus detection section to reflect cross-platform support status (Windows, macOS, and Linux). Fix Edge TTS description to document dual approach: Python CLI recommended with msedge-tts npm fallback.
…documentation Synchronize Edge TTS description with config.ts (Python CLI + npm fallback). Add missing enableContextAwareAI field. Add extensive inline comments covering desktop notifications, AI endpoints, sound themes, webhooks, permission batching, and per-project sound settings.
Add 45 tests covering config value preservation, comment updates without value loss, focus detection field defaults and persistence, deepMerge edge cases, findNewFields detection, and full roundtrip regeneration stability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete TypeScript migration of the entire codebase with full type safety, cross-platform focus detection (Windows, macOS, Linux), improved notification reliability, and comprehensive test coverage. All 9 utility modules, the main plugin entry point, and 22 test files have been converted from JavaScript to TypeScript.
Changes
TypeScript Migration
tsconfig.json,tsconfig.build.json) and build setupconfig,tts,ai-messages,webhook,desktop-notify,focus-detect,linux,sound-theme,per-project-sound) to TypeScript with full type annotationsindex.js→src/index.ts) with typed plugin hooks and session event handlersCross-Platform Focus Detection
GetForegroundWindow,GetWindowText,IsIconic,IsWindowVisible)xdotool/xprop) and Wayland compositors (Sway, GNOME, KDE)suppressWhenFocuseddefault tofalse(opt-in) for safer defaultsNotification Reliability
Documentation & Config
example.config.jsoncandconfig.tsenableContextAwareAIfield to example configFiles Changed
tsconfig.json,tsconfig.build.jsonpackage.json.gitignoresrc/types/*.ts(9 files)src/index.tsindex.js)src/util/*.ts(9 files)util/*.js)util/*.js(9 files)tests/**/*.test.ts(22 files)tests/setup.tstests/setup.js)tests/unit/linux-focus-detect.test.tstests/unit/sub-session-filtering.test.tstests/unit/config-update.test.tsexample.config.jsoncREADME.mdTesting
Reviewer Checklist
suppressWhenFocuseddefault change tofalseis a safe defaultRelated Issues