Skip to content

fix: keyboard shortcut added for #3#5

Open
TrentuQuiyum wants to merge 2 commits into
matta174:mainfrom
TrentuQuiyum:Issue-3
Open

fix: keyboard shortcut added for #3#5
TrentuQuiyum wants to merge 2 commits into
matta174:mainfrom
TrentuQuiyum:Issue-3

Conversation

@TrentuQuiyum
Copy link
Copy Markdown

Adds Ctrl+Enter / Cmd+Enter as a keyboard shortcut for the Generate Mold action.

Hooks the global keydown listener in App.tsx
Triggers the same handleGenerate() path used by the Generate button
Works when focus is in sliders, buttons, or the 3D viewport
Does not fire when focus is inside text/number inputs or content-editable fields
No-op when no model is loaded or when the current mold is already up to date
This keeps the change focused on the keyboard shortcut only, with no visible UI hint added.

@matta174
Copy link
Copy Markdown
Owner

Thanks for picking this up — the overall approach is solid, and a couple
of things you handled that weren't spelled out in the issue (range-slider
focus passing through, distinguishing text inputs from other form
controls) are good calls.

Two things I'd like fixed before merging:

  1. The package-lock.json changes need to revert. 524 lines removed are
    mostly @esbuild platform-specific binary entries (aix-ppc64, android-arm,
    etc.) that main has but your branch dropped. This almost certainly
    happened because npm install on your OS didn't install the optional
    cross-platform binaries. Merging this would likely break CI on at
    least one of our three build platforms.

    Fix:
    git checkout main -- package-lock.json
    git commit --amend --no-edit
    git push -f origin Issue-3

  2. The paramsChanged check inside the new useEffect (around line 528)
    is missing sprueOverrideChanged. The existing paramsChanged at
    App.tsx:614 — which drives the showPartingPlaneIndicator UI — includes
    that branch. Without it, if the user only changes the sprue override
    position, the parting plane indicator correctly shows "stale" but
    Cmd+Enter does nothing. Two ways to fix:

    • Best: hoist the existing paramsChanged into a useMemo and use the
      same memoized value in both the useEffect and the JSX, so the
      two can't drift.
    • Minimal: copy the sprueOverrideChanged branch into your version.

Minor nit — title has a typo, "shortcute" → "shortcut". Worth fixing in
the squash commit message.

Looks good overall, let me know when those are done and I'll merge.

@matta174 matta174 self-assigned this Apr 23, 2026
@TrentuQuiyum TrentuQuiyum changed the title fix: keyboard shortcute added for #3 fix: keyboard shortcut added for #3 Apr 24, 2026
@TrentuQuiyum
Copy link
Copy Markdown
Author

All requested fixes are done: package-lock.json reverted, paramsChanged now includes sprueOverrideChanged via useMemo, and commit message typo fixed. Ready for merge. Please check and let me know thanks.

@TrentuQuiyum
Copy link
Copy Markdown
Author

resolved the conflicts, please check

Copy link
Copy Markdown
Owner

Thanks for the conflict resolution — unfortunately the rebase against main introduced a few new issues that need to be cleaned up before this can land. The good news is the fixes are small and localized.

Three blockers, in order of importance:

  1. Duplicate paramsChanged declaration — won't compile. The new useMemo at App.tsx:518 declares const { paramsChanged } = useMemo(...), but the original inline const paramsChanged = ... at App.tsx:614 is still there. Two consts with the same name in the same block → SyntaxError: Identifier 'paramsChanged' has already been declared. The whole point of hoisting it into useMemo was to be the single source of truth, so the inline block should go away entirely and showPartingPlaneIndicator at App.tsx:633 should read from the memoized value.

  2. Stale field names — clearanceRatio doesn't exist anymore. Main renamed clearanceRatioclearanceMm and added sprueDiameterMm (roadmap #13) before you opened this PR. Your useMemo still references state.generatedParams.clearanceRatio !== state.clearanceRatio, neither of which is a real field anymore. TypeScript will fail on both. The inline paramsChanged at App.tsx:614 has the right field names — copy that branch in.

  3. sprueDiameterMm missing from the useMemo's staleness check. Even after Mold robustness: empty-CSG guard, axis=y rotation, camera auto-orient #2 is fixed, the hoisted version is missing the sprueDiameterMm comparison the inline one has. Without it, changing only the sprue diameter leaves the keyboard shortcut disabled while the parting-plane indicator correctly shows stale — exactly the "two checks drift apart" bug my first review asked to fix.

Minor cleanups while you're in there:

  • The effect dep array at App.tsx:597 now lists both paramsChanged and every state field that feeds into it (axis, planeOffset, cutAngle, etc). Once the above is fixed, you can drop the individual fields — paramsChanged already changes when any of them change.
  • The comment at App.tsx:570 ("Don't interfere with browser/OS chords — Cmd-R reload, Ctrl-F find, etc.") is now misleading since Cmd+Enter is an intentional exception handled above. Worth a one-line tweak.
  • Not blocking, but if you're up for it, a smoke test in the style of src/renderer/mold/*.test.ts firing userEvent.keyboard('{Meta>}{Enter}{/Meta}') and asserting the generate handler ran would have caught both Fix sprue/vent wall breakouts on cylinder + roundedRect molds #1 and Mold robustness: empty-CSG guard, axis=y rotation, camera auto-orient #2 immediately.

The keyboard-handling logic itself (text-input vs slider distinction, the no-op-when-up-to-date check) is good and exactly what I wanted. It's just the rebase that needs another pass. Let me know when those three are sorted and I'll get this merged.


Generated by Claude Code

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