Skip to content

Conversation

Kesuaheli
Copy link

@Kesuaheli Kesuaheli commented Jul 25, 2025

Fixes the issue of chest names (and similar containers) weren't shown.

Still missing:

  • custom formatting is applied correctly (like colors, etc)

Summary by CodeRabbit

  • New Features
    • Improved inventory window titles with enhanced formatting and support for custom titles.

Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

The update imports the prismarine-nbt module and modifies the handling of inventory window titles in the windowOpen event. The openWindow function now accepts an optional title parameter, which is used directly instead of retrieving the title from the current window. The function signature and internal logic are adjusted accordingly.

Changes

File(s) Change Summary
src/inventoryWindows.ts Imported prismarine-nbt, updated openWindow function signature to accept optional title. Modified event handler and logic to use passed title parameter instead of accessing bot.currentWindow?.title.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A window opens, titles anew,
With NBT magic shining through.
A function changed, a signature grown,
Now titles are passed, not fetched alone.
Prismarine dreams in inventory view—
Hop, hop! The code feels fresh and true.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

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

✨ 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.

@zardoy zardoy marked this pull request as ready for review July 26, 2025 12:51
Copy link

@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: 0

🧹 Nitpick comments (1)
src/inventoryWindows.ts (1)

390-398: Consider enhancing error handling for title formatting.

While the try-catch block prevents crashes, the error is only reported via reportError?.(err) and falls back to undefined. Consider logging more specific information about title formatting failures for debugging purposes.

  } catch (err) {
-   reportError?.(err)
+   console.warn('Failed to format window title:', { title, error: err })
+   reportError?.(err)
    inv.canvasManager.children[0].customTitleText = undefined
  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b9c8ade and b130fc4.

📒 Files selected for processing (1)
  • src/inventoryWindows.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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.
src/inventoryWindows.ts (5)

Learnt from: zardoy
PR: #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.

Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-02T02:50:46.443Z
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).

Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-02T02:50:46.443Z
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).

Learnt from: CR
PR: zardoy/minecraft-web-client#0
File: .cursor/rules/vars-usage.mdc:0-0
Timestamp: 2025-07-02T02:50:46.443Z
Learning: Applies to renderer/**/*.ts : In renderer code (such as in WorldRendererThree), use the playerState property (e.g., worldRenderer.playerState.gameMode) to access player state. The implementation for playerState lives in src/mineflayer/playerState.ts.

Learnt from: zardoy
PR: #391
File: renderer/viewer/three/threeJsUtils.ts:56-56
Timestamp: 2025-07-10T16:03:10.838Z
Learning: The minecraft-web-client project uses core-js auto polyfill injection, which means newer JavaScript features like Promise.withResolvers() are automatically polyfilled for compatibility across different environments.

🔇 Additional comments (4)
src/inventoryWindows.ts (4)

12-12: LGTM: Import addition looks correct.

The prismarine-nbt import is appropriately added to handle NBT data simplification for window titles.


358-358: Function signature update is correctly implemented.

The openWindow function signature now properly accepts an optional title parameter with a default value of undefined. This maintains backward compatibility while enabling the new title functionality.


390-394: Title handling logic correctly uses the passed parameter.

The implementation properly uses the passed title parameter instead of retrieving from bot.currentWindow?.title. The conditional logic handles both string and object titles appropriately, with proper error handling via try-catch.


63-63: Verify NBT simplification in window titles

The use of nbt.simplify(win.title as any) here:

  • Loses compile-time guarantees by casting to any. Consider replacing with a more specific type (e.g. the Prismarine-style Tag or a custom ChatComponent interface).
  • May strip out nested chat component properties (color, bold, italics, hover events, etc.). Ensure that your window titles’ formatting fields survive the simplification step.
  • Add a quick smoke-test: open a GUI with a colored/styled title and confirm it renders correctly.

Locations to check:

  • src/inventoryWindows.ts:63
  • src/inventoryWindows.ts:65

@zardoy zardoy changed the title Window Title (e.g. Chest) fix: fix some window titles Jul 27, 2025
@zardoy zardoy merged commit 67855ae into zardoy:next Jul 27, 2025
3 checks passed
@zardoy zardoy deleted the pr/chest-title branch July 28, 2025 01:19
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