Skip to content

Annotate LoggingStats, DebugMoveCamera, and KeyEvent#7068

Open
lL1l1 wants to merge 5 commits intoFAForever:developfrom
lL1l1:annotations/engine1
Open

Annotate LoggingStats, DebugMoveCamera, and KeyEvent#7068
lL1l1 wants to merge 5 commits intoFAForever:developfrom
lL1l1:annotations/engine1

Conversation

@lL1l1
Copy link
Copy Markdown
Contributor

@lL1l1 lL1l1 commented Mar 27, 2026

Description of the proposed changes

I looked in the engine to see what these do when I was looking at console commands:

  • LoggingStats
  • DebugMoveCamera

Was working on a UI mod that interacts with worldview to annotate KeyEvent.

Testing done on the proposed changes

  • Use the logging stats functions.
  • Log key events when clicking in world view.

Additional context

Checklist

Summary by CodeRabbit

  • New Features

    • Added a debug camera movement command that repositions the camera to specified coordinates over a set duration.
  • Documentation

    • Enhanced documentation for performance benchmarking tools with clearer parameter specifications and updated function contracts.
    • Refined input event type definitions with comprehensive event type enumeration for improved API clarity.

@lL1l1 lL1l1 added the area: documentation related to documentation to preserve knowledge and practices label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This pull request adds type annotations and documentation improvements across several files. The changes introduce a KeyEventType union for input events, update function signatures and docs for logging/benchmarking utilities, add a new debug camera movement function, and document these modifications in a changelog snippet.

Changes

Cohort / File(s) Summary
Type Annotations & Documentation
engine/Core.lua, engine/User/CMauiEdit.lua
Updated function signatures for BeginLoggingStats and EndLoggingStats with explicit parameter types; added KeyEventType union alias defining input event types (ButtonPress, ButtonDClick, ButtonRelease, MouseMotion, MouseEnter, MouseExit, WheelRotation); refined KeyEvent type to use the new union and documented KeyCode click mappings.
New Debug Utilities
lua/SimSync.lua
Added DebugMoveCamera function that creates a camera instance and moves it to a specified rectangle over 5 seconds, providing a debug console command for camera manipulation.
Changelog
changelog/snippets/other.7068.md
New changelog snippet documenting the annotations added to LoggingStats, DebugMoveCamera, and KeyEvent.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

type: intellisense

Suggested reviewers

  • Garanas
  • speed2CZ
  • Hdt80bro

Poem

🐰 Hops through types with joyful might,
KeyEvents now shine ever bright,
Camera debug bounds are set,
The finest annotations yet!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main changes: it identifies the three key entities being annotated (LoggingStats, DebugMoveCamera, and KeyEvent), which matches the changeset's focus on adding type annotations and documentation.
Description check ✅ Passed The description covers the main sections with appropriate detail: it explains the motivation (inspecting engine behavior and working on a UI mod), lists testing performed, and confirms all checklist items are marked complete, including the changelog snippet addition.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 and usage tips.

@lL1l1 lL1l1 marked this pull request as ready for review April 12, 2026 03:58
@lL1l1 lL1l1 requested a review from 4z0t April 12, 2026 03:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
engine/User/CMauiEdit.lua (1)

178-178: Scope the KeyCode mapping note to mouse events.
As written, it reads as universal. Clarifying “for mouse button events” avoids ambiguity.

Suggested doc tweak
----@field KeyCode number # 0 = nothing, 1 = left click, 2 = middle click, 3 = right click
+---@field KeyCode number # For mouse button events: 0 = none, 1 = left, 2 = middle, 3 = right
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/User/CMauiEdit.lua` at line 178, The KeyCode field's comment is
ambiguous; narrow it to mouse button events by updating the docstring for the
KeyCode field (the `@field` KeyCode number comment in CMauiEdit.lua) to read
something like "0 = nothing, 1 = left mouse button, 2 = middle mouse button, 3 =
right mouse button (for mouse button events)" so it clearly applies only to
mouse inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@engine/Core.lua`:
- Around line 69-72: The EndLoggingStats annotation incorrectly documents an
`@param exit boolean?` that doesn't match actual usage; locate the
EndLoggingStats function and either remove or correct the `@param exit`
annotation so it reflects that EndLoggingStats is called with no arguments (or,
if the parameter is intended, update EndLoggingStats' signature/uses to accept
and honor an `exit` boolean), and ensure the BeginLoggingStats and
EndLoggingStats annotations consistently describe their real parameters and
behavior.

---

Nitpick comments:
In `@engine/User/CMauiEdit.lua`:
- Line 178: The KeyCode field's comment is ambiguous; narrow it to mouse button
events by updating the docstring for the KeyCode field (the `@field` KeyCode
number comment in CMauiEdit.lua) to read something like "0 = nothing, 1 = left
mouse button, 2 = middle mouse button, 3 = right mouse button (for mouse button
events)" so it clearly applies only to mouse inputs.
🪄 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: ae6cb576-d201-4336-a9e9-0d2a5537feea

📥 Commits

Reviewing files that changed from the base of the PR and between 5bcb15a and cd903be.

📒 Files selected for processing (4)
  • changelog/snippets/other.7068.md
  • engine/Core.lua
  • engine/User/CMauiEdit.lua
  • lua/SimSync.lua

Comment on lines +69 to +72
--- Begins the SupComMark performance benchmark.
---@see EndLoggingStats # End the benchmark and save results to disk.
---@param filename string # The name (with extension) for the resulting timestamped benchmark filename.
function BeginLoggingStats(filename)
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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Locate all declarations/comments and call sites.
rg -n -C2 '\b(BeginLoggingStats|EndLoggingStats)\b' engine lua

# 2) Check for zero-argument BeginLoggingStats usage (would conflict with required filename annotation).
rg -nP '\bBeginLoggingStats\s*\(\s*\)' engine lua || true

# 3) Check how EndLoggingStats is typically invoked (true/false/nil).
rg -nP '\bEndLoggingStats\s*\(\s*(true|false)?\s*\)' engine lua || true

Repository: FAForever/fa

Length of output: 820


🏁 Script executed:

# Search for actual invocations of BeginLoggingStats and EndLoggingStats across the entire codebase
rg -n 'BeginLoggingStats|EndLoggingStats' --type lua -A 1 -B 1

# Also search broadly without type restriction in case calls are in non-.lua files
rg -n 'BeginLoggingStats|EndLoggingStats' -A 1 -B 1 | head -100

Repository: FAForever/fa

Length of output: 2351


🏁 Script executed:

# Count how many times each function is called
echo "=== BeginLoggingStats call count ==="
rg 'BeginLoggingStats\s*\(' --count-matches

echo "=== EndLoggingStats call count ==="
rg 'EndLoggingStats\s*\(' --count-matches

Repository: FAForever/fa

Length of output: 259


🏁 Script executed:

# Look for specific invocation patterns - find lines that call these functions
rg -n '(BeginLoggingStats|EndLoggingStats)\s*\(' --type lua -o -A 0 | head -50

Repository: FAForever/fa

Length of output: 265


Line 117 annotation for EndLoggingStats is inaccurate and misleading.

The documentation states @param exit boolean? # Exits the application iff false, suggesting the exit parameter controls application behavior. However, the only actual call site (testmaps/PerfTestOriginal/perftest_script.lua:139) invokes it as EndLoggingStats() with no arguments, making the annotated parameter semantics irrelevant or wrong.

In contrast, Line 71's filename annotation for BeginLoggingStats is accurate—the single callsite passes 'perftest.log' as required.

Clarify the EndLoggingStats annotation to match actual behavior: either remove/correct the exit parameter description, or update the code to reflect the intended signature.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/Core.lua` around lines 69 - 72, The EndLoggingStats annotation
incorrectly documents an `@param exit boolean?` that doesn't match actual usage;
locate the EndLoggingStats function and either remove or correct the `@param
exit` annotation so it reflects that EndLoggingStats is called with no arguments
(or, if the parameter is intended, update EndLoggingStats' signature/uses to
accept and honor an `exit` boolean), and ensure the BeginLoggingStats and
EndLoggingStats annotations consistently describe their real parameters and
behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: documentation related to documentation to preserve knowledge and practices

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants