Skip to content

Add rotation support to ability widgets and improve error reporting#50

Merged
SunkenInTime merged 2 commits intomainfrom
ability-rotation-change
Mar 17, 2026
Merged

Add rotation support to ability widgets and improve error reporting#50
SunkenInTime merged 2 commits intomainfrom
ability-rotation-change

Conversation

@SunkenInTime
Copy link
Owner

  • Updated ResizableSquareAbility and related widgets to include rotation as a parameter, allowing for dynamic rotation of ability visuals.
  • Enhanced error handling in PlacedImageProvider by integrating AppErrorReporter to log deletion errors for better debugging.
  • Refactored widget structures in CenterSquareWidget and CustomSquareWidget to apply rotation transformations consistently.
  • Cleaned up test cases for PlacedAbility to ensure proper initialization of position and rotation values.

- Updated ResizableSquareAbility and related widgets to include rotation as a parameter, allowing for dynamic rotation of ability visuals.
- Enhanced error handling in PlacedImageProvider by integrating AppErrorReporter to log deletion errors for better debugging.
- Refactored widget structures in CenterSquareWidget and CustomSquareWidget to apply rotation transformations consistently.
- Cleaned up test cases for PlacedAbility to ensure proper initialization of position and rotation values.
Copilot AI review requested due to automatic review settings March 17, 2026 19:08
@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
icarus Ready Ready Preview, Comment Mar 17, 2026 7:32pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 17, 2026

Greptile Summary

This PR adds counter-rotation support to ability icon widgets (CenterSquareWidget, CustomSquareWidget, ResizableSquareWidget) so the icon stays visually upright when the parent ability shape is rotated, and fixes two related bugs where rotation was silently dropped. It also improves error reporting in PlacedImageProvider by replacing an empty catch block with AppErrorReporter logging.

Key changes:

  • All three square ability widgets now wrap AbilityWidget in a Transform.rotate(angle: -(rotation ?? 0)) to counter-rotate the icon.
  • ResizableSquareAbility.createWidget now correctly forwards rotation to ResizableSquareWidget (was silently dropped before).
  • page_transition_overlay.dart now passes rotation ?? w.rotation for the CenterSquareAbility case (was missing before).
  • Error handling in PlacedImageProvider.deleteUnusedImages is improved from a silent empty catch to an AppErrorReporter.reportError call.
  • New widget test file square_icon_counter_rotation_test.dart verifies the counter-rotation angle on all three widget types.

Issues found:

  • In image_provider.dart, StackTrace.current is used inside the catch (e) block instead of capturing the actual exception's stack trace via catch (e, stackTrace). This means the real call-stack from entity.delete() is lost and only the reporter call-site frames are recorded.
  • The error message embeds $e in the string AND passes error: e separately, causing the exception text to appear twice in log output.

Confidence Score: 4/5

  • PR is safe to merge; the rotation logic and bug fixes are correct, with only minor issues in the new error-reporting code.
  • The core feature (counter-rotation of ability icons) is implemented consistently across all three widgets, backed by new widget tests. Both pre-existing rotation-drop bugs are fixed. The only concerns are in the new error-reporting code: losing the original exception stack trace by using StackTrace.current instead of the caught trace, and duplicating the exception in the log message. These don't affect correctness of the primary feature and are easily fixed.
  • lib/providers/image_provider.dart — stack trace capture and message duplication issues in the new catch block.

Important Files Changed

Filename Overview
lib/providers/image_provider.dart Replaces a silent empty catch with AppErrorReporter logging, but uses StackTrace.current instead of the caught stack trace — losing the real exception origin — and duplicates the error in both the message string and the error parameter.
lib/const/abilities.dart Bug fix: forwards the rotation parameter from ResizableSquareAbility.createWidget to ResizableSquareWidget, which previously silently dropped it.
lib/widgets/draggable_widgets/ability/resizable_square_widget.dart Adds optional rotation field and applies the same counter-rotation pattern; consistent with the other square widgets.
lib/widgets/page_transition_overlay.dart Bug fix: the CenterSquareAbility case now correctly forwards rotation ?? w.rotation, matching the existing SquareAbility pattern it was missing before.
test/square_icon_counter_rotation_test.dart New widget tests verifying counter-rotation behavior for all three square widget types; test helper correctly extracts the rotation angle from the Transform matrix.

Sequence Diagram

sequenceDiagram
    participant OV as PageTransitionOverlay
    participant CA as CenterSquareAbility
    participant SA as SquareAbility / ResizableSquareAbility
    participant CSW as CenterSquareWidget
    participant CUSW as CustomSquareWidget
    participant RSW as ResizableSquareWidget
    participant TR as Transform.rotate(angle: -rotation)
    participant AW as AbilityWidget

    OV->>CA: createWidget(rotation: rotation ?? w.rotation)
    CA->>CSW: CenterSquareWidget(rotation: rotation)
    CSW->>TR: angle = -(rotation ?? 0)
    TR->>AW: render (icon stays upright)

    OV->>SA: createWidget(rotation: rotation ?? w.rotation)
    SA->>CUSW: CustomSquareWidget(rotation: rotation)
    CUSW->>TR: angle = -(rotation ?? 0)
    TR->>AW: render (icon stays upright)

    OV->>SA: createWidget(rotation: rotation ?? w.rotation)
    SA->>RSW: ResizableSquareWidget(rotation: rotation)
    RSW->>TR: angle = -(rotation ?? 0)
    TR->>AW: render (icon stays upright)
Loading

Last reviewed commit: 6f7ad53

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds rotation-aware rendering for square-based ability widgets by counter-rotating the embedded AbilityWidget icon, and improves diagnostics when image cleanup fails.

Changes:

  • Counter-rotate ability icons inside CustomSquareWidget, CenterSquareWidget, and ResizableSquareWidget to keep icons upright when the parent widget is rotated.
  • Plumb rotation overrides through PlacedWidgetPreview (notably for CenterSquareAbility) and ResizableSquareAbilityResizableSquareWidget.
  • Add widget tests covering icon counter-rotation behavior; minor test cleanups elsewhere.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/square_icon_counter_rotation_test.dart New widget tests verifying square ability icon counter-rotation.
test/resizable_square_ability_test.dart Minor cleanup: use const for initial positions.
test/placed_agent_node_serialization_test.dart Remove unused import; format test description.
lib/widgets/page_transition_overlay.dart Allow preview rotation override to flow into Square/CenterSquare ability widget creation.
lib/widgets/draggable_widgets/ability/resizable_square_widget.dart Add optional rotation and counter-rotate the AbilityWidget icon.
lib/widgets/draggable_widgets/ability/custom_square_widget.dart Counter-rotate the AbilityWidget icon using the widget’s rotation.
lib/widgets/draggable_widgets/ability/center_square_widget.dart Counter-rotate the AbilityWidget icon using the widget’s rotation.
lib/providers/image_provider.dart Report failures when deleting unused images via AppErrorReporter.
lib/const/abilities.dart Pass rotation through ResizableSquareAbility.createWidget into ResizableSquareWidget.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 92 to +98
await entity.delete();
} catch (e) {}
} catch (e) {
AppErrorReporter.reportError(
'Failed to delete unused image: $e',
error: e,
stackTrace: StackTrace.current,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Lost exception stack trace with StackTrace.current

catch (e) does not capture the original exception's stack trace, so StackTrace.current only records the call site inside the catch handler — not where entity.delete() actually threw. The real exception stack frames are permanently lost, making the logged trace far less useful for debugging.

The fix is to use the two-argument catch form:

Suggested change
await entity.delete();
} catch (e) {}
} catch (e) {
AppErrorReporter.reportError(
'Failed to delete unused image: $e',
error: e,
stackTrace: StackTrace.current,
);
} catch (e, stackTrace) {
AppErrorReporter.reportError(
'Failed to delete unused image',
error: e,
stackTrace: stackTrace,
);

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@SunkenInTime SunkenInTime merged commit 9f2bdd9 into main Mar 17, 2026
1 of 3 checks passed
@SunkenInTime SunkenInTime deleted the ability-rotation-change branch March 17, 2026 19:13
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