Skip to content

UI stops updating (selection / preview / 2nd face) — root causes found, fixes tested and working #69

Description

@moomoolien-ops
Hi! First off — thanks for maintaining this add-in, it's a lifesaver for CNC work.

Full disclosure: I'm a game designer, not a programmer. I ran into several UI-update bugs while using the add-in, and debugged/fixed them through AI-assisted coding (Claude), verifying each fix in Fusion on a real model. Sharing the findings here in case they're useful — happy to open a PR if there's interest.

## Symptoms I hit (master, 2026-07)

1. **Face selection doesn't register on click** — I had to toggle a checkbox (detection/preview) before clicks started working.
2. **Preview randomly freezes** — sometimes it updates, sometimes only toggling the Preview checkbox brings it back.
3. **Selecting a 2nd face does nothing** — edge count doesn't increase, no preview for the added face.

## Root causes found

1. **Normal clicks are gated off by the ctrl-click mechanism.** With Preview enabled (the default), `onFaceSelect` blocks plain-click selection entirely (`previewActive and previewEnabled` gate in `DogboneUi.py`). That's why selection only "wakes up" after toggling checkboxes.

2. **Any keypress kills the preview.** `onKeyUp` sets `previewActive = False` for *every* non-Ctrl key release — so just typing a tool diameter freezes preview updates until the Preview checkbox is toggled (the only code path that resets the flag). This makes bug 2 look random, but it's deterministic: it happens right after you use the keyboard.

3. **All of this fails silently** because every event handler exception is swallowed by the blanket `try/except` in `lib/utils/decorators.py`, and the default log level is `Notset`. Once I made the handler log tracebacks, the remaining bug became obvious:

4. **The preview recompute invalidates cached `BRepFace` proxies, and nothing revalidates them.** After `onExecutePreview` builds the dogbone bodies, the model recomputes and the stored `BRepFace` references for already-selected faces go stale. Hovering/selecting a 2nd face then throws
   `RuntimeError: 2 : InternalValidationError : face` (257 times in a single session log!) in `onFaceSelect`, and a `KeyError` in `onInputChanged` — so the 2nd face never gets registered. Interestingly, `DbFace.revalidate()` already exists in the codebase but is never called from anywhere.

   (Bonus, unrelated: `commands/refreshMfgCommand/main.py` references an undefined `g._design`, so the Manufacturing "Dogbone Refresh" command crashes 100% — also invisible due to #3.)

## What I changed (all verified in Fusion)

- Removed the ctrl-click / `previewActive` key-tracking mechanism (plain click now selects; tooltips updated to match)
- Made `DbFace.face` a self-healing property: revalidates the proxy from the stored point when it goes stale (finally putting `revalidate()` to work)
- Hardened the FACE_SELECT add/remove logic in `onInputChanged` (None guard, directional set difference instead of symmetric difference)
- Fixed an attribute-order bug in `DbFace`/`DbEdge.__init__` (attributes referenced before assignment on the re-select path)
- Handler exceptions still don't propagate, but they now always log the full traceback

After these changes: click-to-select works immediately, preview survives keyboard input and slider drags, and adding a 2nd/3rd face detects edges and updates the preview as expected.

The fixes live here (7 commits, 3 files, +134/−54):
- Branch: https://github.com/moomoolien-ops/Dogbone/tree/fix/ui-update-bugs
- Full diff vs master: https://github.com/DVE2000/Dogbone/compare/master...moomoolien-ops:Dogbone:fix/ui-update-bugs

Again — vibe-coded fixes by a non-programmer, so please treat the diff with healthy suspicion. But every symptom above was reproducible before and gone after, verified on a real CAM model. Happy to open a PR or provide the session logs if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions