Skip to content

Conversation

Kesuaheli
Copy link

@Kesuaheli Kesuaheli commented Jul 31, 2025

Enable proxy logging by passing ?proxyLogging=true as url query parameter.

Any important message will be send to the proxy for logging.1
Currently implemented "important messages" include:

  • when the client started and finished loading
  • disconnect messages (with reason)
  • message from the error handler

Summary by CodeRabbit

  • New Features

    • Added support for a new query parameter to enable proxy logging.
    • Introduced enhanced logging for key connection events and errors when proxy logging is enabled.
  • Bug Fixes

    • No bug fixes included in this release.

Footnotes

  1. Logging needs to be enabled on the proxy too. Also https://github.com/zardoy/prismarinejs-net-browserify/pull/1 is required.

Copy link

coderabbitai bot commented Jul 31, 2025

Walkthrough

A new optional query string parameter, proxyLogging, has been added to the application's parameter type definition. The bot client's type now includes a logProxy method for logging proxy-related events. The main application logic has been updated to conditionally assign and invoke this logging method during key connection lifecycle events, based on the presence of the proxyLogging parameter.

Changes

Cohort / File(s) Change Summary
App Query Parameter Extension
src/appParams.ts
Added optional proxyLogging string property to AppQsParams type.
Bot Client Type Update
src/globals.d.ts
Added logProxy: (msg: string) => void method to _client property of bot declaration.
Proxy Logging Implementation
src/index.ts
Assigned logProxy method based on proxyLogging param; invoked it to log key connection events.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Bot
    participant Net

    User->>App: Loads app with query params (may include proxyLogging)
    App->>App: Checks appQueryParams.proxyLogging
    alt proxyLogging enabled
        App->>Bot: Assigns _client.logProxy = Net.logProxy
    else proxyLogging not enabled
        App->>Bot: Assigns _client.logProxy = noop
    end
    App->>Bot: Initiates connection
    Bot->>Bot: On connection events (error, connect, kick, disconnect, chunks loaded)
    Bot->>Bot: Calls _client.logProxy with event info
    Bot->>Console: Optionally logs to console
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A query string hops in, so sly and new,
Now proxy logs sparkle in all that we do!
With logProxy in tow, and events to report,
Our bot tells its tale—succinct, never short.
From connect to a kick, every hop leaves a trace,
The rabbit devs smile at this logging embrace.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67855ae and e757e1a.

📒 Files selected for processing (3)
  • src/appParams.ts (1 hunks)
  • src/globals.d.ts (1 hunks)
  • src/index.ts (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/vars-usage.mdc)

src/**/*.ts: You may use the global variable bot directly in any file under the src/ directory (e.g., src/mineflayer/playerState.ts).
In src/ code, you may use the global variable appViewer from src/appViewer.ts directly. Do not import appViewer or use window.appViewer; use the global appViewer variable as-is.

Files:

  • src/appParams.ts
  • src/index.ts
  • src/globals.d.ts
🧠 Learnings (5)
📚 Learning: applies to src/**/*.ts : you may use the global variable `bot` directly in any file under the `src/`...
Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-27T13:24:58.174Z
Learning: Applies to src/**/*.ts : You may use the global variable `bot` directly in any file under the `src/` directory (e.g., `src/mineflayer/playerState.ts`).

Applied to files:

  • src/index.ts
  • src/globals.d.ts
📚 Learning: applies to renderer/**/*.ts : in renderer code, all bot/player state and events must be accessed via...
Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-27T13:24:58.174Z
Learning: Applies to renderer/**/*.ts : In renderer code, all bot/player state and events must be accessed via explicit interfaces, state managers, or passed-in objects, never by referencing `bot` directly.

Applied to files:

  • src/index.ts
  • src/globals.d.ts
📚 Learning: applies to renderer/**/*.ts : do not use the global variable `bot` directly in any file under the `r...
Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-27T13:24:58.174Z
Learning: Applies to renderer/**/*.ts : Do not use the global variable `bot` directly in any file under the `renderer/` directory or its subfolders (e.g., `renderer/viewer/three/worldrendererThree.ts`).

Applied to files:

  • src/index.ts
📚 Learning: applies to src/**/*.ts : in `src/` code, you may use the global variable `appviewer` from `src/appvi...
Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-27T13:24:58.174Z
Learning: Applies to src/**/*.ts : In `src/` code, you may use the global variable `appViewer` from `src/appViewer.ts` directly. Do not import `appViewer` or use `window.appViewer`; use the global `appViewer` variable as-is.

Applied to files:

  • src/index.ts
📚 Learning: in the minecraft-web-client project, files under renderer/ directory must not access the global `bot...
Learnt from: zardoy
PR: zardoy/minecraft-web-client#373
File: renderer/viewer/three/entities.ts:1120-1120
Timestamp: 2025-06-23T13:33:14.776Z
Learning: In the minecraft-web-client project, files under renderer/ directory must not access the global `bot` variable directly according to .cursor/rules/vars-usage.mdc. The updateNameTagVisibility method in renderer/viewer/three/entities.ts currently violates this rule by accessing bot.teamMap and bot.username. Team information should be passed through entity update events from the world data emitter instead.

Applied to files:

  • src/globals.d.ts
🔇 Additional comments (8)
src/appParams.ts (1)

12-12: LGTM! Proper type definition for the new query parameter.

The proxyLogging parameter follows the established pattern of optional string properties in the AppQsParams interface.

src/globals.d.ts (1)

11-11: LGTM! Proper type declaration for the logging method.

The logProxy method signature is correctly typed and aligns with its usage in the implementation.

src/index.ts (6)

582-582: LGTM! Proper conditional assignment of logging method.

The logProxy method is correctly assigned based on the proxyLogging query parameter, with a no-op fallback when logging is disabled.


268-268: LGTM! Appropriate error logging with JSON serialization.

The error logging correctly serializes the error object to JSON for structured logging, providing useful debugging information to the proxy.


620-620: LGTM! Simple connection success logging.

Clear and concise logging message for successful proxy WebSocket connection establishment.


667-667: LGTM! Proper kick reason logging with JSON serialization.

The kick reason is correctly serialized to JSON, preserving the structured data for proxy logging analysis.


692-692: LGTM! Appropriate disconnect reason logging.

The disconnect reason is properly logged with JSON serialization for structured proxy logging.


759-759: LGTM! Useful performance logging for chunk loading.

The chunk loading time logging provides valuable performance metrics for proxy analysis, formatted as a clear duration message.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Kesuaheli Kesuaheli changed the title feat: added important log message to send to the proxy Add server-side logging Jul 31, 2025
@zardoy zardoy closed this Aug 7, 2025
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