feat: implement engine kind detection for default context in context ls#823
Open
ilopezluna wants to merge 3 commits intomainfrom
Open
feat: implement engine kind detection for default context in context ls#823ilopezluna wants to merge 3 commits intomainfrom
ilopezluna wants to merge 3 commits intomainfrom
Conversation
Contributor
ilopezluna
commented
Apr 2, 2026
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements dynamic engine kind detection for the "default" Docker context to provide more accurate host and description information in the CLI. However, the current implementation hardcodes connection schemes and ports, failing to account for TLS configurations. Additionally, the detection logic is inefficiently called within loops, potentially causing significant delays, and it lacks handling for specific WSL2 edge cases where Moby-based runners are used.
- Handle WSL2 edge case in DetectEngineKind where a Moby controller container may be running alongside Docker Desktop - Respect MODEL_RUNNER_TLS env var in resolveDefaultContext to show correct scheme (https) and TLS ports (12444/12445) when TLS is enabled - Resolve default context info lazily once in inspect command to avoid repeated network probes when 'default' appears multiple times in args
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
resolveDefaultContext, consider adding adefaultbranch in theswitch kindto ensurehostis always initialized sensibly if newModelRunnerEngineKindvalues are introduced in the future. - The host/port construction logic in
resolveDefaultContextduplicates logic from the runtime detection path; it might be worth centralizing this mapping (kind + TLS → URL) in a shared helper to avoid future drift between what is displayed and what is actually used.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `resolveDefaultContext`, consider adding a `default` branch in the `switch kind` to ensure `host` is always initialized sensibly if new `ModelRunnerEngineKind` values are introduced in the future.
- The host/port construction logic in `resolveDefaultContext` duplicates logic from the runtime detection path; it might be worth centralizing this mapping (kind + TLS → URL) in a shared helper to avoid future drift between what is displayed and what is actually used.
## Individual Comments
### Comment 1
<location path="cmd/cli/commands/context.go" line_range="94-101" />
<code_context>
+ detectCtx, cancel := context.WithTimeout(ctx, defaultContextDetectTimeout)
+ defer cancel()
+
+ kind := desktop.DetectEngineKind(detectCtx, dockerCLI)
+ description = "Model Runner on " + kind.String()
+
+ // Check whether TLS is enabled so the displayed scheme and port match
+ // what DetectContext would actually use at runtime.
+ useTLS := os.Getenv("MODEL_RUNNER_TLS") == "true"
+
+ switch kind {
+ case types.ModelRunnerEngineKindDesktop:
+ host = kind.String()
</code_context>
<issue_to_address>
**issue:** Handle unexpected/unknown engine kinds to avoid returning an empty host string
If `DetectEngineKind` ever returns a new/unknown `ModelRunnerEngineKind` (e.g., after future enum extensions), this `switch` will leave `host` empty while still setting a non-empty `description`. Consider adding a `default` case that falls back to the generic `(auto-detect)` host (and possibly description) to keep the output consistent and user-friendly for unhandled kinds.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
doringeman
reviewed
Apr 2, 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.