Skip to content

fix(app): use optional chaining for model.current() in ProviderIcon#18927

Merged
adamdotdevin merged 1 commit intoanomalyco:devfrom
BYK:byk/fix-provider-icon
Mar 24, 2026
Merged

fix(app): use optional chaining for model.current() in ProviderIcon#18927
adamdotdevin merged 1 commit intoanomalyco:devfrom
BYK:byk/fix-provider-icon

Conversation

@BYK
Copy link
Copy Markdown
Contributor

@BYK BYK commented Mar 24, 2026

Issue for this PR

Closes #18923

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

prompt-input.tsx uses local.model.current()!.provider.id with a non-null assertion inside a <Show> guard. SolidJS compiles id={expr} into a get id() getter. During a reactive batch, the getter can fire before <Show> disposes its children, causing a TypeError when model.current() becomes undefined (e.g. provider refresh, model not found).

Replaces the ! assertion with optional chaining (?.) and an empty string fallback at both occurrences (lines 1500 and 1532). The <Show> guard still prevents rendering when the model is undefined; the fallback only fires during the reactive race window.

How did you verify your code works?

  • bun test passes for packages/app (291/291)
  • The TypeError can't access property 'provider', r.model.current() is undefined no longer occurs

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Replace non-null assertion (!) with optional chaining (?.) and empty
string fallback for the ProviderIcon id prop. The SolidJS compiler
turns the prop into a getter that can fire during a reactive batch
before the <Show> guard disposes children, causing a TypeError when
model.current() becomes undefined.
@BYK BYK requested a review from adamdotdevin as a code owner March 24, 2026 10:57
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@BYK BYK changed the title fix(app): use optional chaining for model.current() in ProviderIcon prop fix(app): use optional chaining for model.current() in ProviderIcon Mar 24, 2026
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@adamdotdevin adamdotdevin merged commit 3f1a4ab into anomalyco:dev Mar 24, 2026
13 checks passed
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.

TypeError: can't access property 'provider', model.current() is undefined in ProviderIcon

2 participants