Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

  • Create shared worker utility in src/shared/worker-utils.ts with common handler logic
  • Extract logWorkerMetrics function to shared utility
  • Extract HandlerResult interface to shared types
  • Create createUnifiedWorkerHandler factory function that accepts configuration
  • Update SW worker to use shared utility
  • Update LR worker to use shared utility
  • Update SR worker to use shared utility
  • Update LW worker to use shared utility (and add performance metrics)
  • Run tests to validate changes
  • Run linter to ensure code quality
  • Address code review feedback on type safety
  • Add comprehensive documentation
  • Run security scan (CodeQL - no vulnerabilities found)
  • Refactor into smaller, testable functions

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 13, 2026 20:58
- Created shared/worker-utils.ts with createUnifiedWorkerHandler factory
- Extracted logWorkerMetrics function to shared utility
- Extracted HandlerResult interface to shared utility
- Updated SR, SW, LR, and LW workers to use shared utility
- Reduced code duplication by ~500 lines
- Added performance metrics to LW worker (previously missing)

Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
- Remove HandlerResult | void union type from WorkerConfig
- All handlers now required to return HandlerResult
- Updated build handler to return HandlerResult with syncResponseMs
- Removed fragile type check for handlerResult (always defined now)
- Improved type consistency across all handlers

Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
- Added detailed JSDoc explaining the function's purpose
- Documented use cases (E2E latency, queue wait time, etc.)
- Added parameter documentation
- Improved code maintainability and discoverability

Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 13, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/143.0.7499.169/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on mockup logic for long-read short-write commands Refactor: Extract common worker logic to eliminate ~500 lines of duplication Jan 13, 2026
Copilot AI requested a review from llama90 January 13, 2026 21:04
@llama90
Copy link
Contributor

llama90 commented Jan 13, 2026

@copilot Please refactor this code into smaller functions that are easier to test.
Avoid over-abstraction and keep the refactor pragmatic.
Do not change external behavior or function signatures.
Preserve existing side effects and async boundaries.

Split createUnifiedWorkerHandler into focused, single-responsibility functions:
- parseWorkerMessage: Extracts message parsing logic
- createMessageLogger: Handles logger creation with correlation context
- getCommandHandler: Validates and retrieves command handlers
- calculatePerformanceMetrics: Computes timing metrics
- processRecord: Orchestrates single record processing

Benefits:
- Each function has a clear, testable purpose
- Easier to unit test individual components
- Maintains exact same behavior and async boundaries
- No changes to external function signatures
- More maintainable and easier to understand

Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot Please refactor this code into smaller functions that are easier to test.
Avoid over-abstraction and keep the refactor pragmatic.
Do not change external behavior or function signatures....

I've refactored the code into smaller, focused functions. The main handler is now broken down into:

New functions (all with single responsibilities):

  • parseWorkerMessage() - Message parsing
  • createMessageLogger() - Logger creation with correlation
  • getCommandHandler() - Handler lookup and validation
  • calculatePerformanceMetrics() - Performance calculation
  • processRecord() - Single record orchestration

Result:

  • Each function is easily testable in isolation
  • Same external behavior and async boundaries preserved
  • No changes to public API (createUnifiedWorkerHandler signature unchanged)
  • All 32 tests pass, linter clean

The refactor maintains pragmatism - each extracted function has a clear purpose without over-abstracting.

Commit: 32b6978

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