Skip to content

feat: Add the result type returned by a value feedback's callback to the value feedback's schema - #258

Open
jswalden wants to merge 1 commit into
bitfocus:mainfrom
jswalden:value-result-type
Open

feat: Add the result type returned by a value feedback's callback to the value feedback's schema#258
jswalden wants to merge 1 commit into
bitfocus:mainfrom
jswalden:value-result-type

Conversation

@jswalden

@jswalden jswalden commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Anyone defining a value feedback schema is going to be compelled by this change to add some appropriate result: T to all their value feedback schemas, when they upgrade from ~2.1.0 to ~2.2.0. Seems like this should be equally as fine as the change in 2.1.0 to require optionsToMonitorForSubscribe on actions, right?

I didn't actually attempt to test this, only relied on my intrinsic TypeScript/etc. understandings.

Summary by CodeRabbit

  • Enhancements
    • Improved feedback schema definitions with clearer support for boolean, value-based, and advanced feedback types.
    • Value-based feedback now supports custom JSON-compatible result types, including asynchronous callback results.
    • Feedback result types are now consistently preserved across callbacks and schema mappings.
    • Added more precise type validation for feedback integrations, improving editor guidance and compile-time reliability.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jswalden, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e20bb26e-1a73-45d5-8922-55781e355c3d

📥 Commits

Reviewing files that changed from the base of the PR and between d2645b5 and b9c1685.

📒 Files selected for processing (1)
  • packages/base/src/module-api/__tests__/feedback.spec.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de1fa16b-1ac6-478a-9041-7f9d33d93f75

📥 Commits

Reviewing files that changed from the base of the PR and between c4c98a8 and d2645b5.

📒 Files selected for processing (1)
  • packages/base/src/module-api/feedback.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/base/src/module-api/feedback.ts

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The feedback API now uses discriminated schema interfaces. Value feedback definitions accept a generic JSON-compatible result type. CompanionFeedbackDefinition propagates that type through callbacks, schema mappings, and fallback alternatives.

Changes

Feedback typing

Layer / File(s) Summary
Discriminated feedback schemas
packages/base/src/module-api/feedback.ts
The broad feedback schema interface is replaced by boolean, value, and advanced schema interfaces. The union preserves the value result type.
Value result type propagation
packages/base/src/module-api/feedback.ts
Value callbacks return the schema-specific result type. CompanionFeedbackDefinition propagates the option and result types through definitions and fallback alternatives.

Poem

Schemas split by kind,
Results keep their typed shape,
Callbacks follow through.
Boolean, value, advanced—
Clear paths through the API.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: linking a value feedback callback's result type to its schema.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Julusian

Copy link
Copy Markdown
Member

Yeah im fine with a slightly breaking types change like this.

But it doesnt appear to work currently:
image

@jswalden

Copy link
Copy Markdown
Contributor Author

Are you sure? This callback works correctly for me with this schema. This is with me running yarn link --all ../../module-base/ && yarn install && yarn build locally to link against my local companion-module-base checkout.

And if I change the callback to return string | number, the compilation error I expect to get does in fact show up.

Screenshot From 2026-08-15 17-11-18

That said, in further testing (further down in that demonstration, even) I've noticed one semi-debatable "lapse" here: if you want to implement a value feedback to delegate to a variable:

				// Delegate to the MSB/LSB-specified level variable.
				return `$(${instance.label}:level_${MSB}.${LSB})`

then of course TypeScript will only understand this as your feedback returning a string, even if the variable you're delegating to will not be a string. (In this case it's '-inf' | number, but as the feedback exists only to generate a variable for interpolation into string, the precise type doesn't really matter.) I'm inclined to say this is sufficiently recondite that the concern is entirely ignorable -- or at least ignorable for now.

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.

2 participants