Skip to content

Persist machine configuration in presets#514

Merged
kraemr merged 28 commits intomasterfrom
62-persist-config-values
Jul 22, 2025
Merged

Persist machine configuration in presets#514
kraemr merged 28 commits intomasterfrom
62-persist-config-values

Conversation

@Oshgnacknak
Copy link
Copy Markdown
Collaborator

#62

As discussed, the following features are not implemented yet but will become their own issue:

  • Checking the schema version of a preset and possibly running migrations of needed.
  • Being able to export presets into an USB stick.
  • Implementing presets for the Laser.

@Oshgnacknak Oshgnacknak requested a review from kraemr July 21, 2025 20:57
Comment thread .github/workflows/electron.yml
Comment thread electron/package.json
Comment thread tmux-dev.sh Outdated
import { PresetData, PresetSchema } from "@/lib/preset/preset";
import { renderUnitSymbol, renderUnitSyntax, Unit } from "@/control/units";

export const previewSeparator = undefined;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have a const value that is always undefined? Just use undefined

Copy link
Copy Markdown
Collaborator Author

@Oshgnacknak Oshgnacknak Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we might have to change this later, then we don't need to do this in multiple places - or at least, the compiler tells us where.

Currently undefined has all the information we need. It is possible that this might change in the future. Any unique value (string, symbols, null, undefined) works. undefined is just the most light weight.

Also on the other side, if you read undefined in the list. Would you be able to guess what effect this has? Using a name here makes it obvious what the desired behavior should be.

return (
<div className="grid grid-cols-[60%_10%_30%]">
{entries.map((entry, i) => {
if (entry === previewSeparator) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do === undefined here

Copy link
Copy Markdown
Collaborator Author

@Oshgnacknak Oshgnacknak Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on the above code


export const presetSchema = <S extends PresetSchema>(dataSchema: S) =>
z.object({
id: z.number().int().nonnegative().optional(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can a preset id be optional (undefined)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Presets that don't come directly from the Preset Store (imported by the user, or just an dummy value to give to pass around in the ui) might not have an id. The id only makes sense if a preset is directly handled the store.

If we force an id everywhere, sometimes it will have an incorrect dummy value, which I consider more confusing that declaring the field as optional.

Its true that one could also create a type Representing only the parts of a preset the user is directly interested in (name, date, data), that is used instead. Any opinion on this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright then that makes sense.We will keep it that way for now

Comment thread electron/src/lib/preset/presetStore.ts
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the TODO Comments and write what you want to do in a ticket instead

@Oshgnacknak Oshgnacknak force-pushed the 62-persist-config-values branch from cad5a56 to a4af569 Compare July 22, 2025 10:49
@Oshgnacknak Oshgnacknak force-pushed the 62-persist-config-values branch from a4af569 to f393abb Compare July 22, 2025 11:06
@Oshgnacknak Oshgnacknak force-pushed the 62-persist-config-values branch from f393abb to 5a19410 Compare July 22, 2025 11:12
@Oshgnacknak Oshgnacknak force-pushed the 62-persist-config-values branch from 5a19410 to c1c5185 Compare July 22, 2025 11:17
@Oshgnacknak Oshgnacknak force-pushed the 62-persist-config-values branch from c1c5185 to f89645a Compare July 22, 2025 11:19
@kraemr kraemr merged commit b6842a7 into master Jul 22, 2025
4 checks passed
@Oshgnacknak Oshgnacknak mentioned this pull request Jul 25, 2025
19 tasks
@1cedsoda 1cedsoda deleted the 62-persist-config-values branch August 11, 2025 14:49
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