Skip to content

fix(ui): model/eval picker shows no list when CLI model discovery fails#78

Merged
digitarald merged 4 commits intomainfrom
copilot/fix-model-eval-selection-bug
Mar 22, 2026
Merged

fix(ui): model/eval picker shows no list when CLI model discovery fails#78
digitarald merged 4 commits intomainfrom
copilot/fix-model-eval-selection-bug

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

When listCopilotModels() returns [] or throws (CLI not found, changed --help format, or help written to stderr), availableModels stayed empty and the model picker rendered nothing — leaving users stuck in model-pick state with a blank screen.

Changes

  • tui.tsx — always populate availableModels
    Fall back to PREFERRED_MODELS in both the empty-result and error cases, so the list always renders when entering model-pick state (affects both M eval-model and J judge-model pickers).

  • copilot.ts — handle stderr and non-zero exits in listCopilotModels
    Some CLI builds write --help to stderr and/or exit non-zero. Now captures both streams, tries stdout first, falls back to stderr (including from thrown ExecFileException).

  • extractModelChoices exported + unit tested
    Added 6 tests covering single-line, multi-line, missing choices:, empty string, and stderr-sourced help text.

// Before: error case silently left models empty, picker rendered nothing
.catch(() => {
  setAvailableModels([]);  // ← gated list never shows
});

// After: always have a usable list
.catch(() => {
  setAvailableModels(PREFERRED_MODELS);
});
Original prompt

Selection in TUI for model and eval is broken, there is no list shown

The user has attached the following file paths as relevant context:

  • AGENTS.md

Created from VS Code.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Fix broken selection for model and eval in TUI fix(ui): model/eval picker shows no list when CLI model discovery fails Mar 22, 2026
Copilot AI requested a review from digitarald March 22, 2026 21:25
@digitarald digitarald marked this pull request as ready for review March 22, 2026 23:21
Copilot AI review requested due to automatic review settings March 22, 2026 23:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the TUI model/eval picker getting stuck with an empty (non-rendering) model list when Copilot CLI model discovery returns an empty list or fails, by adding safer fallbacks and improving Copilot CLI --help parsing.

Changes:

  • Ensure the TUI always has a non-empty availableModels list by falling back to PREFERRED_MODELS on empty discovery results and on errors.
  • Make listCopilotModels() resilient to CLIs that write help text to stderr and/or exit non-zero for --help.
  • Export extractModelChoices() and add unit tests for multiple help-output formats and edge cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ui/tui.tsx Adds fallback to PREFERRED_MODELS so the model picker always renders a list.
packages/core/src/services/copilot.ts Captures/parses both stdout and stderr for --help, exports the parser helper.
src/services/tests/copilot.test.ts Adds unit coverage for extractModelChoices() across common formats/edge cases.

Comment on lines +63 to +74
try {
const result = await execFileAsync(cmd, args, { timeout: 5000 });
stdout = result.stdout;
stderr = result.stderr;
} catch (err) {
// Some CLIs exit with a non-zero code for --help; try to extract from stderr
const e = err as { stderr?: string; stdout?: string };
stdout = e.stdout ?? "";
stderr = e.stderr ?? "";
}
const fromStdout = extractModelChoices(stdout);
return fromStdout.length > 0 ? fromStdout : extractModelChoices(stderr);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In listCopilotModels(), the catch currently swallows all execFileAsync failures and then returns [] if parsing yields no choices. That changes behavior for real execution failures (timeout, EACCES, broken binary, etc.): callers like eval --list-models will now report “No models detected” instead of surfacing the underlying error.

Consider only falling back to parsing stdout/stderr for expected non-zero --help exits, and if no models can be extracted, rethrow the original error (or throw a new error that includes the original failure) so genuine failures aren’t silently converted into an empty list.

Suggested change
try {
const result = await execFileAsync(cmd, args, { timeout: 5000 });
stdout = result.stdout;
stderr = result.stderr;
} catch (err) {
// Some CLIs exit with a non-zero code for --help; try to extract from stderr
const e = err as { stderr?: string; stdout?: string };
stdout = e.stdout ?? "";
stderr = e.stderr ?? "";
}
const fromStdout = extractModelChoices(stdout);
return fromStdout.length > 0 ? fromStdout : extractModelChoices(stderr);
let execError: unknown = null;
try {
const result = await execFileAsync(cmd, args, { timeout: 5000 });
stdout = result.stdout;
stderr = result.stderr;
} catch (err) {
// Some CLIs exit with a non-zero code for --help; try to extract from stderr
execError = err;
const e = err as { stderr?: string; stdout?: string };
stdout = e.stdout ?? "";
stderr = e.stderr ?? "";
}
const fromStdout = extractModelChoices(stdout);
if (fromStdout.length > 0) return fromStdout;
const fromStderr = extractModelChoices(stderr);
if (fromStderr.length > 0) return fromStderr;
if (execError) {
const e = execError as Error & { stderr?: string; stdout?: string };
const details = e.stderr || e.stdout;
const detailMsg = details ? `\nCopilot CLI output:\n${details}` : "";
throw new Error(`Failed to list Copilot models: ${e.message}${detailMsg}`);
}
return [];

Copilot uses AI. Check for mistakes.
Harald Kirschner added 2 commits March 22, 2026 16:26
Address review feedback: only fall back to parsing stdout/stderr for
expected non-zero --help exits. If no models can be extracted and
an exec error occurred, rethrow with details instead of silently
returning an empty list.
@digitarald digitarald merged commit c0a65e0 into main Mar 22, 2026
11 checks passed
@digitarald digitarald deleted the copilot/fix-model-eval-selection-bug branch March 22, 2026 23:32
github-actions bot pushed a commit that referenced this pull request Mar 22, 2026
- Add model/eval picker blank screen fix to CHANGELOG [Unreleased] (from #78)
- Update agentrc init description in docs/commands.md to clarify
  agentrc.config.json is always created (not just for monorepos)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Mar 23, 2026
Add missing changelog entries and documentation for:
- Config status in TUI with [C] keybinding (PR #74)
- Workspace Status tree view in VS Code extension (PR #74)
- TUI model/eval picker blank screen fix (PR #78)
- TUI terminal resize artifacts fix (PR #76)
- @github/copilot-sdk 0.1.32 -> 0.2.0 bump (PR #73)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants