Skip to content

fix: don't fail activation on chat models without a family - #1137

Open
dividedmind wants to merge 1 commit into
masterfrom
fix/chat-model-sort-missing-family
Open

dividedmind wants to merge 1 commit into
masterfrom
fix/chat-model-sort-missing-family

Conversation

@dividedmind

Copy link
Copy Markdown
Contributor

ChatCompletion.refreshModels() sorted models with b.family.localeCompare(a.family). Language model providers other than Copilot can return models with no family (despite the typings), which threw a TypeError from inside activate() and left most of the extension unregistered. Whether it threw depended on the order the provider listed the models in.

Treat a missing family as '' and a missing maxInputTokens as 0, and use || so the family only breaks ties on token count. Also catch and report ChatCompletion.initialize failures in activate(), so a broken provider can't take the rest of the extension down with it.

Fixes #1133

Assisted-by: Claude:claude-opus-5-5

@dividedmind
dividedmind requested review from kgilpin and a balanced review from Copilot November 11, 2026 22:18
@dividedmind dividedmind self-assigned this Nov 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new tests short-circuit before the family comparison because token counts differ, leaving the equal-token missing-family crash untested in either input order.

1 open issue
What changed in this PR

This PR addresses #1133 by making chat-model sorting tolerate missing provider metadata and preventing chat initialization failures from blocking the rest of the AppMap extension.

Changes:

  • Default missing token counts and families to safe values, using family only to break token-count ties.
  • Catch and report chat initialization failures during activation.
  • Add regression tests for incomplete model metadata across different provider orders.
File Description
test/​unit/​services/​chatCompletion.test.ts Adds sorting tests for models missing metadata.
src/​services/​chatCompletion.ts Makes model sorting null-safe and corrects tie-breaking.
src/​extension.ts Logs and reports chat initialization failures while allowing activation to continue.

Review effort: Balanced

ChatCompletion.refreshModels() sorted models with
b.family.localeCompare(a.family). Language model providers other than
Copilot can return models with no family (despite the typings), which
threw a TypeError from inside activate() and left most of the extension
unregistered. Whether it threw depended on the order the provider
listed the models in.

Treat a missing family as '' and a missing maxInputTokens as 0, and use
|| so the family only breaks ties on token count. Also catch and report
ChatCompletion.initialize failures in activate(), so a broken provider
can't take the rest of the extension down with it.

Fixes #1133

Assisted-by: Claude:claude-opus-5-5
@dividedmind
dividedmind force-pushed the fix/chat-model-sort-missing-family branch from 42c0159 to c5dd365 Compare November 11, 2026 23:00
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.

Activation fails with 'Cannot read properties of undefined (reading localeCompare)' when a chat model has no family

2 participants