Skip to content

Enable all axis controls simultaneously#686

Merged
lawsie merged 9 commits into
flipcomputing:mainfrom
lawsie:axis-control-bugfixes
Jun 23, 2026
Merged

Enable all axis controls simultaneously#686
lawsie merged 9 commits into
flipcomputing:mainfrom
lawsie:axis-control-bugfixes

Conversation

@lawsie

@lawsie lawsie commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

All axis control methods - keyboard, drag and HUD - should be usable interchangeably on all platforms.

image
  • Show HUD on desktop
  • HUD display reflects active keyboard key or drag handle, i.e. if you're dragging the X axis, the HUD displays X
  • Free mode for keyboard controls is the default. If a HUD button is pressed while a keyboard axis lock is active, the axis lock clears. If a different gizmo is selected while a keyboard axis lock is active, the Flock message in the top left is cleared to avoid confusion.
  • Don't trigger axis locks (x/y/z) when a modifier is held, i.e. Ctrl + Z should not trigger an axis lock
  • Retain the previously selected axis if you switch to a different mesh

AI usage

Claude Sonnet 4.6 used interactively, plans and alterations by a human.

Summary by CodeRabbit

  • New Features

    • Enhanced keyboard axis selection to persist across interaction mode changes and coordinate with gizmo drag interactions.
    • Added initial axis configuration option for keyboard and UI controls.
  • Bug Fixes

    • Improved keyboard input tracking and debug output display for better diagnostics.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Axis selection state is now persisted and restored across keyboard/HUD transitions for move, rotate, and scale gizmos. createAxisKeyboardHandler and createGizmoMobileHud gain initialAxis/onAxisChange APIs and getAxis/setAxis accessors. createAdaptiveInput is rewritten as an axis-coordination bridge. All three gizmo handlers carry savedHudAxis across transitions, and drag interactions set axis state via a new observeDragAxis helper. keyboardDispatcher debug output and quote style are also updated.

Changes

Axis Persistence Across Keyboard/HUD Gizmo Transitions

Layer / File(s) Summary
createAxisKeyboardHandler API extension
ui/axis-keyboard.js
Adds onAxisChange callback and initialAxis parameter; all axis-toggle and arrow/PageUp cases call onAxisChange; Ctrl/Meta/Alt combos are ignored; stop.getAxis/stop.setAxis are attached to the returned function.
createGizmoMobileHud initialAxis and refreshAxisVisuals
ui/gizmo-mobile-hud.js
Adds initialAxis parameter; replaces hardcoded 'x' with AXIS_DEFS-based initialization; renames updateAxisButtons to refreshAxisVisuals; update flow calls onAxisChange; returned stop gains stop.setAxis(newAxis); removes translate import.
createAdaptiveInput axis-coordination bridge
ui/gizmos.js
Rewritten to accept initialKeyboardAxis/initialHudAxis and onHudHide, wire bidirectional onKbAxisChange/onHudAxisChange, and expose stop.setAxis/stop.getAxis; previous AXIS_SWITCH_KEYS touch-vs-keyboard switching removed.
Move/rotate/scale keyboard handler axis persistence
ui/gizmos.js
startMoveKeyboardHandler, startRotateKeyboardHandler, and startScaleKeyboardHandler each gain savedHudAxis/onHudAxisSaved parameters, capture current keyboard axis before reset, and pass initialKeyboardAxis/initialHudAxis through to createAdaptiveInput.
observeDragAxis and per-gizmo savedHudAxis wiring
ui/gizmos.js
handleScaleGizmo stops keyboard axis during uniform-handle drags; handleScaleGizmo, handleRotationGizmo, and handlePositionGizmo introduce savedHudAxis and pass it into their respective keyboard handler start calls; drag observers are cleaned up on exit.

Keyboard Dispatcher Debug and Quote Cleanup

Layer / File(s) Summary
Keyboard dispatcher debug output and quote normalization
main/keyboardDispatcher.js
String literals normalized to single quotes throughout; _debugShow is now called after handler lookup for every dispatched keypress, labeling output as context:combo when a handler exists or 'external' when none is found.

Sequence Diagram(s)

sequenceDiagram
  participant GizmoHandler
  participant createAdaptiveInput
  participant createAxisKeyboardHandler
  participant createGizmoMobileHud

  GizmoHandler->>createAdaptiveInput: start with initialKeyboardAxis and initialHudAxis
  createAdaptiveInput->>createAxisKeyboardHandler: initialAxis and onAxisChange callback
  createAdaptiveInput->>createGizmoMobileHud: initialAxis and onAxisChange callback

  Note over createAxisKeyboardHandler,createGizmoMobileHud: User selects axis via keyboard or HUD button
  createAxisKeyboardHandler-->>createAdaptiveInput: onKbAxisChange(axis)
  createAdaptiveInput-->>GizmoHandler: onAxisChange calls onHudAxisSaved(axis)

  createGizmoMobileHud-->>createAdaptiveInput: onHudAxisChange(axis)
  createAdaptiveInput-->>GizmoHandler: onAxisChange calls onHudAxisSaved(axis)

  Note over GizmoHandler: Drag on gizmo handle begins via observeDragAxis
  GizmoHandler->>createAdaptiveInput: stop.setAxis(dragAxis)
  createAdaptiveInput->>createAxisKeyboardHandler: setAxis(dragAxis)
  createAdaptiveInput->>createGizmoMobileHud: setAxis(dragAxis)

  Note over GizmoHandler: Gizmo handler restarts on mesh reattach
  GizmoHandler->>createAdaptiveInput: start with savedHudAxis as initialKeyboardAxis and initialHudAxis
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • flipcomputing/flock#668: Modifies ui/gizmo-mobile-hud.js and its integration in ui/gizmos.js to coordinate axis selection via the mobile HUD, directly overlapping with this PR's createGizmoMobileHud API and stop.setAxis additions.
  • flipcomputing/flock#670: Introduces adaptive touch/keyboard axis switching and HUD axis-update plumbing in ui/gizmos.js and ui/gizmo-mobile-hud.js—the same files and patterns this PR extends with onAxisChange, initialAxis, and axis persistence.
  • flipcomputing/flock#609: Modifies ui/axis-keyboard.js and ui/gizmos.js to use InputManager/context-driven modes, directly related to this PR's extensions of the axis-keyboard handler and adaptive input wiring.

Poem

🐇 Hoppity-hop, my axis stays true,
No more lost X when the HUD breaks through!
savedHudAxis remembers the way,
Through drag and drop and keyboard play.
onAxisChange rings like a bell—
The gizmos align, all is well! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Enable all axis controls simultaneously' directly aligns with the main objective of the PR, which is to enable all axis control methods (keyboard, mouse dragging, HUD buttons) to work simultaneously and interchangeably.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main/keyboardDispatcher.js`:
- Line 59: The comment on line 59 in the keyboardDispatcher.js file incorrectly
states that debug info is printed for all key presses, but the _dispatch
function contains early returns for certain key types like TYPING and OVERLAY
that prevent debug logging for those cases. Revise the comment to accurately
describe the actual behavior, clarifying that debug info is printed only for key
presses that reach the debug logging statement, accounting for the early return
conditions in the _dispatch function's control flow.

In `@ui/gizmos.js`:
- Around line 84-90: The lastReportedAxis variable is only updated in the
onKbAxisChange function, but axis changes can also originate from HUD
interactions and the stop handler, leaving lastReportedAxis out of sync with
actual axis state. This stale state causes the deduplication check to suppress
valid onAxisChange notifications. Update lastReportedAxis whenever the axis
changes in the HUD axis change handler (around lines 94-99) by setting
lastReportedAxis to match the new axis value, and similarly update
lastReportedAxis in the stop.setAxis handler (around lines 112-115) to ensure
the dedupe state always reflects the current axis regardless of the change
origin.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa4551ff-e651-4fe7-878f-ea0215126e62

📥 Commits

Reviewing files that changed from the base of the PR and between 890007f and efefbce.

📒 Files selected for processing (4)
  • main/keyboardDispatcher.js
  • ui/axis-keyboard.js
  • ui/gizmo-mobile-hud.js
  • ui/gizmos.js

Comment thread main/keyboardDispatcher.js
Comment thread ui/gizmos.js
@lawsie lawsie merged commit 6a05692 into flipcomputing:main Jun 23, 2026
3 checks passed
@lawsie lawsie deleted the axis-control-bugfixes branch June 23, 2026 11:06
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.

1 participant