Skip to content

Fix this-binding: use arrow functions in web LLM service - #9

Merged
danialsamiei merged 1 commit into
mainfrom
devin/1771276683-fix-this-binding
Feb 16, 2026
Merged

danialsamiei merged 1 commit into
mainfrom
devin/1771276683-fix-this-binding

Conversation

@danialsamiei

Copy link
Copy Markdown
Collaborator

Fix this-binding: use arrow functions in web LLM service

Summary

Converts 4 methods in LLMMessageServiceWeb from regular class methods to arrow function properties. RefreshModelService.startRefreshingModels extracts these methods into a standalone variable (const listFn = this.llmMessageService.openAICompatibleList) and calls them directly, which loses the this context. This caused a runtime crash:

TypeError: Cannot read properties of undefined (reading 'voidSettingsService')
    at openAICompatibleList (sendLLMMessageService.js:268:49)
    at RefreshModelService.startRefreshingModels (refreshModelService.js:66:13)

The fix is purely mechanical — method(args) {} → method = (args) => {} — for sendLLMMessage, abort, ollamaList, and openAICompatibleList.

Review & Testing Checklist for Human

  • Deploy and verify no voidSettingsService TypeError in browser console. Open https://ide.orcest.ai/, open DevTools console, and confirm the Cannot read properties of undefined error is gone.
  • Test that the Settings panel opens. Click the gear icon or "Void's Settings" link and confirm it renders without errors.

Notes

  • The caller pattern in refreshModelService.ts:164-167 is pre-existing and used in Electron mode too, but Electron's LLMMessageService methods use IPC channels that don't reference this, so the bug only manifests in the web stub.
  • Arrow function properties are per-instance rather than on the prototype, which is fine for a singleton service.

Link to Devin run: https://app.devin.ai/sessions/9a3910ef8208402b93e14fa38bb90f2b
Requested by: @danialsamiei

RefreshModelService extracts methods as standalone functions (e.g.
const listFn = this.llmMessageService.openAICompatibleList) which
loses the this context. Converting to arrow function properties
ensures this is always bound to the class instance.

Co-Authored-By: Danial Piterson <danial.samiei@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@danialsamiei
danialsamiei merged commit be97256 into main Feb 16, 2026
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.

1 participant