ocdevel / gnothi

Gnothi is an open-source AI journal and toolkit for self-discovery. If you're interested in getting involved, we'd love to hear from you.
https://gnothiai.com
GNU Affero General Public License v3.0
166 stars 18 forks source link

The "default value" field is broken and attempting to enter anything in it breaks the whole "Edit/Add Behaviour" window. #177

Closed Leeleevy closed 8 months ago

Leeleevy commented 10 months ago

When adding a behaviour or editing an existing one, and choosing "Manual default" in the advanced settings, attempting to enter any value into the "default value" field results in a red frame around the field with an error saying "Expected number, received string" appearing. It then prevents saving of the behaviour, even after you clear the field in case and/or select "Yesterday's Value" or "Average Value" from the drop-down menu. The only way to be able to successfully edit/add a behaviour again is clicking "Cancel" and opening a new "Edit/Add" window, thus having to re-enter all the behaviour data/changes from zero, obviously not touching the "default value" field. The issue persists both on mobile and desktop browsers. I'm open to reword the title of this issue into anything more convenient and informative for the developers if they'll tell me so.

lefnire commented 9 months ago

Thanks for reporting this. Good find, I'll refer to this once I'm building out some Playwright tests for building out behaviors in coming weeks.

lefnire commented 8 months ago

https://github.com/ocdevel/gnothi/pull/186

I need to go through the code soon and look for everything that used CoerceNumber (or worse, didn't use anything; thus using Zod's default resolver). They added z.coerce.number() helper which fixes this issue, which is especially prevalent with MUI components. Fixed for this one (deploying now), but I'll keep an eye on any other number fields in the app which need to be switched to z.coerce.number().