Skip to content

Refactor intel.ts: Extract hotkey-based features into modular components#19

Draft
Copilot wants to merge 7 commits into
mainfrom
copilot/fix-80f07096-5b1d-445a-be84-6c509083a29c
Draft

Refactor intel.ts: Extract hotkey-based features into modular components#19
Copilot wants to merge 7 commits into
mainfrom
copilot/fix-80f07096-5b1d-445a-be84-6c509083a29c

Conversation

Copilot AI commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

This PR begins the process of breaking down the massive 6,461-line intel.ts file into smaller, focused modules organized around user-facing features. Each feature is identified by its defineHotkey call and extracted into its own module.

Problem

The intel.ts file has grown to over 6,400 lines containing many different features mixed together, making it difficult to:

  • Navigate and understand the codebase
  • Add new features without conflicts
  • Maintain and debug individual components
  • Enable selective feature loading

Solution

This PR extracts 5 distinct feature groups into separate modules while maintaining all existing functionality:

Extracted Modules

  1. ui-controls.ts - Core UI interaction functions

    • showUI() (backtick hotkey) - Opens NPA UI
    • showOptions() (ctrl+backtick) - Opens options dialog
    • configureColours() (ctrl+a) - Opens color configuration
  2. help.ts - Help and documentation functions

    • npaHelp() (? hotkey) - Displays help screen with all hotkeys
    • npaControls() (~ hotkey) - Generates control reference
  3. fleet-routing.ts - Fleet management functionality

    • routeEnemy() (x hotkey) - Creates fake enemy fleets for strategic planning
  4. screenshot.ts - Screenshot upload functionality

    • screenshot() (# hotkey) - Uploads map screenshots to imgbb
  5. combat-controls.ts - Combat calculation adjustments

    • incCombatHandicap() (. hotkey) - Increases enemy weapon advantage
    • decCombatHandicap() (, hotkey) - Decreases enemy weapon advantage

Implementation Details

  • Each module exports its functions and a registration function for hotkeys
  • Dependencies are properly managed through imports/exports
  • All existing functionality is preserved
  • No breaking changes to the public API
  • All tests continue to pass

Results

  • 180 lines removed from intel.ts (6,461 → 6,281 lines, 2.8% reduction)
  • 5 new focused modules created
  • 9 functions extracted across different feature areas
  • 0 test failures - all functionality preserved

Future Work

This establishes the pattern for continuing the modularization. The remaining 53 hotkey-based features can be extracted using the same approach, eventually reducing intel.ts to primarily initialization and coordination logic.

The modular structure will enable:

  • Feature-specific testing and development
  • Conditional feature loading based on user preferences
  • Easier onboarding for new contributors
  • Better separation of concerns

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits August 20, 2025 04:48
Co-authored-by: anicolao <1145048+anicolao@users.noreply.github.com>
Co-authored-by: anicolao <1145048+anicolao@users.noreply.github.com>
Co-authored-by: anicolao <1145048+anicolao@users.noreply.github.com>
Co-authored-by: anicolao <1145048+anicolao@users.noreply.github.com>
Copilot AI changed the title [WIP] intel.ts contains a lot of code. each user-facing piece of functionality is hooked up to a hotkey via a defineHotkey call. Use that to split intel.ts into many files, one for each user facing feature, and do this one feature at a time in separate com... Refactor intel.ts: Extract hotkey-based features into modular components Aug 20, 2025
Copilot AI requested a review from anicolao August 20, 2025 05:03
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.

2 participants