feat(cdp): support custom CDP ports via .env for multi-instance setups (#93) - #234
Draft
dgomez407 wants to merge 10 commits into
Draft
feat(cdp): support custom CDP ports via .env for multi-instance setups (#93)#234dgomez407 wants to merge 10 commits into
dgomez407 wants to merge 10 commits into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dgomez407
force-pushed
the
feat/custom-cdp-port-via-env
branch
2 times, most recently
from
August 8, 2026 21:08
255f3dd to
835a868
Compare
…d i18n (tokyoweb3#147) ### Audit Summary Matrix: Issue tokyoweb3#147 | # | Item Description | Initial Audit | Resolution Status | Technical Action Taken | |---|---|:---:|:---:|---| | 1 | Type Safety in interactionCreateHandler.ts | Still Present | Fixed & Verified | Removed (interaction as any).channelId and (interaction as any).channel?.threads casts; refactored targetChannel checks to use typed sendableChannel in src/events/interactionCreateHandler.ts. | | 2 | Dependency Injection (ArtifactService) | Still Present | Fixed & Verified | Replaced new ArtifactService() inline instantiation with deps.artifactService || new ArtifactService() in src/events/interactionCreateHandler.ts. | | 3 | API Consistency (artifactRenderMode?) | Resolved | Confirmed | Verified UserPreferenceRecord.artifactRenderMode is optional (?) in src/database/userPreferenceRepository.ts. | | 4 | Encoding Robustness (encodeSelectValue) | Still Present | Fixed & Verified | Replaced numeric filename hash with an 8-character hex SHA-256 hash segment of conversationId + filename in src/services/artifactService.ts. | | 5 | i18n Integration (artifactsUi.ts) | Still Present | Fixed & Verified | Replaced unlocalized strings with t() i18n helper function across UI elements in src/ui/artifactsUi.ts. | ### Technical Details - Type Safety: Cleaned up interactionCreateHandler.ts by using typed channel property guards and interaction.channelId directly. - Dependency Injection: Injected artifactService into interactionCreateHandler for testability and architectural consistency. - Encoding Robustness: Updated ArtifactService.encodeSelectValue to compute sha256(conversationId + ':' + filename).slice(0, 8). - Internationalization: Wrapped artifactsUi.ts strings with t() helper function. - Tests: Added TDD unit assertions in artifactService.test.ts and interactionCreateHandler.test.ts. Rebased against doc/docstring-cleanup. Full test suite passing (115 test suites, 1549 tests).
…and platform adapters
…yphens, and artifact hash assertions
…r precedence, and negative test assertions
### Audit Summary Matrix: Final Review Resolution
| # | Item Description | Initial Audit | Resolution Status | Technical Action Taken |
|---|---|:---:|:---:|---|
| 1 | Type Safety in interactionCreateHandler.ts | Still Present | Fixed & Verified | Created SendableChannel type guard in src/utils/discordChannelUtils.ts; removed inline `{ send: Function }` and `(interaction.channel as any).send` casts across all fallback send paths. |
| 2 | Process Log Buffer Consolidation | Still Present | Fixed & Verified | Exported createDefaultProcessLogBuffer() factory in src/utils/processLogBuffer.ts to centralize log buffer configuration across Discord and Telegram message handlers. |
| 3 | Title Parsing & Separator Precedence | Still Present | Fixed & Verified | Refined parseProjectNameFromTitle in src/services/cdpService.ts with a 3-tier separator hierarchy (Product Suffix > Em/En Dash > Hyphen). |
| 4 | Negative Test Coverage (decodeSelectValue) | Still Present | Fixed & Verified | Added explicit test case for same 8-char short prefix collision rejection in tests/services/artifactService.test.ts. |
| 5 | Regression Test (sendableChannel) | Still Present | Fixed & Verified | Added unit test asserting SendableChannel target channel dispatching in tests/events/interactionCreateHandler.test.ts. |
### Technical Details
- Type Safety: Isolated Discord sendable channel narrowing into src/utils/discordChannelUtils.ts with isSendableChannel predicate.
- Process Log Buffering: Standardized maxChars, maxEntries, and maxEntryLength tuning via createDefaultProcessLogBuffer().
- Title Parsing: Prioritized em-dash (—) and en-dash (–) over plain hyphens (-) when extracting project names from titles.
- Test Coverage: Added SendableChannel dispatching test in interactionCreateHandler.test.ts and prefix collision test in artifactService.test.ts.
Full test suite passing (115 test suites, 1559 tests).
…ack routing and robust DOM selectors
tokyoweb3#93) Add support for resolving custom CDP debugging ports from environment variables (CDP_PORT and ANTIGRAVITY_ACCOUNTS) alongside default candidates. Key changes: - Implement getCdpCandidatePorts() in src/utils/cdpPorts.ts with strict integer parsing (1..65535) and set-based deduplication. - Wire dynamic port candidate scanning into CdpService.resolveAccountPorts(), AntigravityLauncher, and CLI commands (doctor, open, setup). - Update .env.example and README.md with configuration usage examples. - Add unit and live HTTP integration tests for custom port resolution. Closes tokyoweb3#93
dgomez407
force-pushed
the
feat/custom-cdp-port-via-env
branch
from
August 10, 2026 11:59
835a868 to
f908585
Compare
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
Closes #93
While PR #114 introduced account config parsing utilities, low-level CDP candidate port scanning across
CdpService,AntigravityLauncher, and CLI commands (doctor,open,setup) still defaulted to the staticDEFAULT_CDP_PORTSarray.This PR enables dynamic candidate port resolution prioritizing custom environment overrides (
CDP_PORTandANTIGRAVITY_ACCOUNTS) while gracefully falling back to standard default ports.Key Changes
Dynamic Candidate Port Resolution (
src/utils/cdpPorts.ts)getCdpCandidatePorts(accountsEnv?, singlePortEnv?)helper with integer boundary validation (1..65535) andSet<number>deduplication.getConfiguredCdpPorts()to delegate directly togetCdpCandidatePorts().Core Service & Process Launcher Wiring
CdpService.resolveAccountPorts()to callgetCdpCandidatePorts().AntigravityLauncher(startAntigravity,stopAntigravity,ensureAntigravityRunning) to iterate over dynamic candidate ports.CLI Commands & Diagnostics
doctor.ts,open.ts, andsetup.tsto scan configured candidate ports.Documentation & Environment Template
CDP_PORTandANTIGRAVITY_ACCOUNTSexample entries to.env.example.README.mdconfiguration guide and candidate port scanning tip.Tests & Verification
tests/utils/cdpPorts.test.tscovering custom single ports, multi-account mappings, defaults, and malformed input handling.tests/services/customPortLive.test.ts.Verification
npm run build— 0 TypeScript compilation errorsnpx jest tests/utils/cdpPorts.test.ts— 7/7 tests passednpx jest tests/services/customPortLive.test.ts— 1/1 test passed