Skip to content

fix(core): invalid model error handling#132

Merged
sudo-tee merged 1 commit intosudo-tee:mainfrom
cameronr:fix/invalid-model-new-session-error
Dec 5, 2025
Merged

fix(core): invalid model error handling#132
sudo-tee merged 1 commit intosudo-tee:mainfrom
cameronr:fix/invalid-model-new-session-error

Conversation

@cameronr
Copy link
Collaborator

@cameronr cameronr commented Dec 5, 2025

It looks like there was a change in opencode 1.0 that changed how invalid model errors are surfaced so this change fixes that.

Also add unit test coverage for send_message changing state.user_message_count (and fix a bug with it not being updated in the catch)

Hopefully fixes #131

Copilot AI review requested due to automatic review settings December 5, 2025 02:05
Copy link
Contributor

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

This pull request fixes error handling for invalid model responses from opencode 1.0 and adds comprehensive test coverage for the user_message_count state management in the send_message function.

Key Changes:

  • Refactored user_message_count tracking logic into a reusable helper function with proper bounds checking
  • Fixed bug where user_message_count was not decremented in error handling path
  • Added explicit validation and error notification for invalid API responses
  • Added two new unit tests verifying correct increment/decrement behavior in both success and error scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
lua/opencode/core.lua Refactored message count tracking into a helper function, added error handling for invalid responses, and fixed missing count decrement in catch block
tests/unit/core_spec.lua Added two comprehensive tests verifying user_message_count is correctly incremented/decremented in both successful and error cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

It looks like there was a change in opencode 1.0 that changed how
invalid model errors are surfaced so this change fixes that.

Also add unit test coverage for send_message changing
state.user_message_count (and fix a bug with it not being updated in the
catch)

Hopefully fixes sudo-tee#131
@cameronr cameronr force-pushed the fix/invalid-model-new-session-error branch from 743ce9d to 7f4b114 Compare December 5, 2025 04:18
@sudo-tee
Copy link
Owner

sudo-tee commented Dec 5, 2025

Thanks for looking into this

This looks good to me

@sudo-tee sudo-tee merged commit 0250785 into sudo-tee:main Dec 5, 2025
5 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.

Error creating new sessions

3 participants