fix(cli): limit background process port scans#10796
Merged
catrielmuller merged 2 commits intoJun 1, 2026
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Both issues from the previous review have been addressed in the follow-up commit:
Files Reviewed (1 file changed)
Reviewed by claude-4.6-sonnet-20260217 · 268,559 tokens Review guidance: REVIEW.md from base branch |
johnnyeric
approved these changes
Jun 1, 2026
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.
Issue
No linked issue. Follow-up to an internal report that background-process port discovery could contribute to Bun memory growth.
Context
Background process support inferred listening ports by repeatedly scanning active process trees. VS Code and Agent Manager do not surface inferred ports, and even in the TUI the scan is only needed shortly after startup so users can see a detected dev-server port.
This limits the scan surface area and makes port discovery explicitly opt-in for clients that surface inferred ports.
Implementation
Port discovery now requires
KILO_BACKGROUND_PROCESS_PORTS=true, and only the TUI worker sets that environment variable. Regular background-process publish/output updates no longer trigger inferred port scans.For the TUI, inference starts shortly after launch, retries at a slower interval, and stops after startup, when a port is found, or when the process exits. The
ps/lsoffallback path also has an abort timeout so stuck scan commands cannot accumulate.Screenshots / Video
N/A - no visual changes.
How to Test
Manual/local verification
bun test test/kilocode/background-process.test.tsfrompackages/opencode/passed.bun run typecheckfrompackages/opencode/passed.bun run script/check-opencode-annotations.ts --base origin/mainpassed.git diff --checkpassed.bun turbo typecheckpassed after refreshing workspace links withbun install.Reviewer test steps
ready.portstill reports that ready port for VS Code clients.Blocked checks and substitute verification
Checklist
Get in Touch
Catriel Muller