Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.11.6 #45

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

1.11.6 #45

wants to merge 15 commits into from

Conversation

Scyye
Copy link
Collaborator

@Scyye Scyye commented Mar 2, 2025

Summary by CodeRabbit

  • Chores

    • Updated the package version to 1.11.6.
  • New Features

    • Introduced enhanced logging controls for fine-tuned developer tool settings.
    • Added a new checkbox control for improved settings interaction.
  • Improvements

    • Refined visual elements and behavior for badges, chat controls, and game activity toggles.
    • Enhanced image zoom and username display for a smoother and more consistent user experience.
    • Improved handling of pointer events and configuration options for checkbox components.
    • Updated text wrapping behavior in code blocks for better readability.
    • Introduced a function for retrieving maximum emoji slots per guild for better emoji management.

Copy link

coderabbitai bot commented Mar 2, 2025

Walkthrough

The pull request updates the package version in package.json and adjusts various plugin files. Several regex patterns and patch replacement logics are refined in multiple API modules. New patches and dispatch actions are added in the dynamic image modal and crash handler plugins. The console janitor now supports configurable logging levels with new interfaces and components, and the console shortcuts directly reference a cached store list. Additionally, types for React components are updated with a new utility function, a Checkbox component and its types are introduced, and a caching mechanism for Flux stores is implemented in the webpack module.

Changes

File(s) Change Summary
package.json Version bump for package "vencord" from 1.11.5 to 1.11.6.
src/plugins/_api/badges/index.tsx, src/plugins/_api/chatButtons.ts, src/plugins/gameActivityToggle/index.tsx, src/plugins/showMeYourName/index.tsx, src/plugins/imageZoom/index.tsx Modified regex patterns and patch replacement logic for attribute matching, element insertion, and rendering adjustments.
src/plugins/dynamicImageModalApi.ts Updated patch find pattern and added a new patch object for .dimensionlessImage, to inject a replacement "true".
src/plugins/consoleJanitor/index.tsx Introduced new interfaces (AllowLevels, AllowLevelSettingProps) and components for logging level management; updated settings and method signature of shouldLog.
src/plugins/consoleShortcuts/index.ts Replaced a dynamic getter for stores with a direct reference to Webpack.fluxStores.
src/plugins/crashHandler/index.ts Added a try-catch block in handlePreventCrash to dispatch a "DEV_TOOLS_SETTINGS_UPDATE" action with error handling.
src/utils/types.ts Updated component type definitions to use `ReactNode
src/webpack/common/components.ts, src/webpack/common/types/components.d.ts Added a new Checkbox component via waitForComponent along with new types (CheckboxAligns, CheckboxTypes, and the Checkbox type) for detailed configuration.
src/webpack/webpack.ts Introduced a fluxStores cache and modified the findStore function to first check the cache before iterating through all stores.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AllowLevelSettings
    participant Settings
    participant ConsoleJanitor

    User->>AllowLevelSettings: Toggle logging level checkbox
    AllowLevelSettings->>Settings: Update allowLevel setting
    Settings-->>AllowLevelSettings: Confirm update
    User->>ConsoleJanitor: Trigger log event with level
    ConsoleJanitor->>Settings: Retrieve current logging level
    Settings-->>ConsoleJanitor: Return logging state
Loading
sequenceDiagram
    participant Component
    participant findStore
    participant fluxStores
    participant FluxStoreAPI

    Component->>findStore: Request store by name
    findStore->>fluxStores: Check for store in cache
    alt Store exists
        fluxStores-->>findStore: Return cached store
    else
        findStore->>FluxStoreAPI: Retrieve all stores
        FluxStoreAPI-->>findStore: Return list of stores
        findStore->>fluxStores: Cache the found store
    end
    findStore-->>Component: Return store
Loading

Poem

Oh, how my code hops in the night,
Patches and regexes shining so bright!
I’ve added new checks and toggles with care,
Logging and caching all dancing in air.
With every commit, my heart fills with glee,
A bunny’s delight in fresh code set free! 🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 5eb4435 and 4391fcc.

📒 Files selected for processing (2)
  • src/plugins/accountPanelServerProfile/index.tsx (1 hunks)
  • src/plugins/emoteCloner/index.tsx (2 hunks)
🔇 Additional comments (4)
src/plugins/accountPanelServerProfile/index.tsx (1)

76-76: More robust regex pattern for injection point

The updated regex pattern makes the match more flexible by allowing up to 100 characters between .AVATAR_SIZE) and the semicolon, while ensuring the injection happens before a return statement. This change likely addresses a breaking change in Discord's codebase that made the previous pattern stop working.

src/plugins/emoteCloner/index.tsx (3)

28-28: Good addition of type import

Adding the Guild type import from "discord-types/general" provides proper typing for the new function parameter, improving type safety.


34-35: Excellent refactoring with webpack finder

This change extracts the emoji slots retrieval logic into a standalone function using findByCodeLazy, making the code more maintainable and resilient to Discord's internal changes. The proper type annotation ensures type safety.


131-131: Correctly implements the new function

The code now uses the newly defined getGuildMaxEmojiSlots(g) function instead of directly accessing the method on the guild object. This change improves consistency and makes the code more resilient to Discord's internal changes.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8882f80 and 0f38441.

📒 Files selected for processing (14)
  • package.json (1 hunks)
  • src/plugins/_api/badges/index.tsx (1 hunks)
  • src/plugins/_api/chatButtons.ts (1 hunks)
  • src/plugins/_api/dynamicImageModalApi.ts (1 hunks)
  • src/plugins/consoleJanitor/index.tsx (5 hunks)
  • src/plugins/consoleShortcuts/index.ts (1 hunks)
  • src/plugins/crashHandler/index.ts (1 hunks)
  • src/plugins/gameActivityToggle/index.tsx (1 hunks)
  • src/plugins/imageZoom/index.tsx (1 hunks)
  • src/plugins/showMeYourName/index.tsx (1 hunks)
  • src/utils/types.ts (3 hunks)
  • src/webpack/common/components.ts (1 hunks)
  • src/webpack/common/types/components.d.ts (2 hunks)
  • src/webpack/webpack.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (28)
src/plugins/_api/chatButtons.ts (1)

20-20: Improved regex pattern for bundler compatibility

The regex pattern has been updated to be more flexible by removing the specific condition \i\.isDM from the lookahead assertion. This broadens the matching criteria and helps address the bundler-related compatibility issue mentioned in the comment above.

src/plugins/showMeYourName/index.tsx (1)

53-54: More precise regex targeting

The updated regex pattern is more precise, specifically targeting the username formatting pattern (\i\?"@":""\)\+\i that follows after children:. This makes the patch more resilient to Discord code changes.

src/plugins/gameActivityToggle/index.tsx (1)

98-98:

❓ Verification inconclusive

Updated selector for button insertion

The regex pattern has been changed to target elements with className:\i\.buttons instead of this\.renderNameZone\(\), adapting to Discord's current component structure.

The pattern includes a .{0,50} limit before children:\[. Verify that this character limit is sufficient for all possible cases:


🏁 Script executed:

#!/bin/bash
# Find potential matches with varying distances between className and children properties
rg -U "className:.+?buttons.+?children:" --type=ts --type=tsx

Length of output: 91


Verify Regex Gap Limit in Selector

The regex update now targets elements with className:\i\.buttons (in line with Discord’s current component structure) instead of this.renderNameZone(). However, since our initial automated search using rg --type=tsx failed due to a file type recognition issue, please manually verify that the .{0,50} limit before children:\[ is sufficient for all cases. An adjusted search command has been provided below to include both TS and TSX files:

#!/bin/bash
# Search for relevant patterns in both .ts and .tsx files
rg -U "className:.+?buttons.+?children:" --glob "*.ts" --glob "*.tsx"

Make sure to review the output and confirm that no potential matches exceed the 50-character allowance.

src/webpack/common/components.ts (1)

41-41: Added Checkbox component export

Clean addition of the Checkbox component, following the established pattern for component exports. This makes Discord's internal Checkbox component available for use in Vencord plugins.

src/plugins/crashHandler/index.ts (1)

176-183: Excellent addition of DevTools cleanup to crash recovery

The new try-catch block is a solid addition to the crash recovery process, closing DevTools by dispatching a DEV_TOOLS_SETTINGS_UPDATE action. This follows the same pattern as other cleanup operations and properly handles errors.

src/plugins/_api/dynamicImageModalApi.ts (2)

17-17: Updated search pattern for better patch targeting

The modified find property now includes .contain before SCALE_DOWN:, improving the specificity of the pattern matching.


23-28: Good addition of a new patch for dimensionless images

Adding this new patch enhances the plugin's functionality to handle dimensionless images with the appropriate matching pattern and replacement.

src/plugins/_api/badges/index.tsx (3)

76-77: Enhanced badge attribute handling with improved regex pattern

The replacement approach using destructuring and template literals for badge properties is more robust and maintainable than the previous implementation.


81-81: Code cleanup: Removed unnecessary spaces in replacement string

This minor code cleanup makes the replacement string more concise without changing functionality.


86-86: Code cleanup: Streamlined conditional replacement syntax

Simplified the replacement string by removing unnecessary spaces, making the code more maintainable.

src/webpack/webpack.ts (2)

41-41: Added useful caching mechanism for Flux stores

The new fluxStores constant provides a cache for Flux stores, which will improve performance by avoiding redundant lookups.


434-450: Significantly improved findStore implementation with caching

This enhanced implementation of findStore follows a good pattern:

  1. First checks the cache for quick lookups
  2. If not found, searches through all stores and populates the cache
  3. Falls back to the original search method as a last resort

This change will improve performance, especially for frequently accessed stores.

src/webpack/common/types/components.d.ts (3)

19-19: Added PointerEvent to import statement.

This addition correctly imports the necessary PointerEvent type from React, which is needed for the new Checkbox component.


200-210: New type definitions for CheckboxAligns and CheckboxTypes.

Well-structured type definitions for checkbox alignment and type options that follow the component type pattern used throughout the codebase.


212-228: Added Checkbox component type with appropriate props and static properties.

The Checkbox component type is properly defined with:

  • Required props: value and onChange handler (correctly typed with PointerEvent)
  • Optional configuration props like align, size, shape, etc.
  • Static properties for shapes, alignments, and types that follow Discord's component styling pattern

This implementation will allow for proper type checking when using the Checkbox component elsewhere in the codebase.

src/plugins/imageZoom/index.tsx (2)

168-170: Improved ID attribute injection with better selector matching.

Changed the patch to target imageClassName: instead of the previous pattern, which should make the ID attribute injection more reliable.


173-190: Added new patches for dimensionless images to enhance zoom functionality.

The new patch group for .dimensionlessImage includes three key improvements:

  1. Adds the plugin's ID to media elements for consistent identification
  2. Adds an empty onClick handler for zoomed elements, preventing potential event bubbling issues
  3. Removes unnecessary wrapper class that may have been interfering with the zoom functionality

These changes should improve the stability and consistency of the image zoom feature.

src/utils/types.ts (3)

29-29: Changed import from JSX to ReactNode.

Updated import to use ReactNode instead of JSX, which aligns with the changes to component return types in this file.


205-207: Added utility function defineDefault for type-safe default values.

New utility function that makes it clearer when a value is intended to be used as a default. While simple in implementation, it improves code readability by making the intention explicit.


341-343: Enhanced component type to support async rendering and default values.

Two important improvements:

  1. Changed the return type from JSX.Element to ReactNode | Promise<ReactNode>, enabling async component rendering
  2. Added an optional default property to component definitions

These changes provide more flexibility for plugin developers, especially when components need to load data asynchronously.

src/plugins/consoleJanitor/index.tsx (8)

8-12: Imports look good, with all necessary dependencies.

The additions of ErrorBoundary, Flex, Margins, defineDefault, and UI components are appropriate for implementing the new logging level configuration feature.


30-37: Well-defined interface for log levels.

The AllowLevels interface clearly defines all the supported logging levels as boolean flags, making it easy to understand and extend if needed.


39-41: Clean props interface definition.

The AllowLevelSettingProps interface properly types the setting key parameter to ensure type safety.


43-56: Good implementation of the AllowLevelSetting component.

The component correctly retrieves and updates the settings state. The capitalization of the setting name in the UI is a nice touch for better readability.


58-70: Well-structured AllowLevelSettings component with error handling.

Using ErrorBoundary is a good practice to prevent the entire plugin from crashing if this component fails. The layout with FormSection, FormTitle, and descriptive text provides a clear UI for users.


94-105: Good implementation of the allowLevel setting.

The component-based setting with appropriate defaults is well implemented. Setting error to true by default is a sensible choice since error logs are usually important.


122-123: Updated shouldLog method with proper level checking.

The method now correctly checks if the logger is explicitly allowed or if the specified log level is enabled in settings. This provides flexible control over logging.


197-204: Patch implementation correctly uses the updated shouldLog method.

The replacement now passes both the logger name and log level to the shouldLog method, enabling the new level-based filtering functionality.

.filter(([name]) => name.length > 1)
)
}
Stores: Webpack.fluxStores
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplified Stores implementation by using cached fluxStores.

Good refactor that replaces a complex dynamic getter implementation with a direct reference to the cached Webpack.fluxStores. This change:

  • Improves performance by using pre-cached stores instead of dynamically constructing the object
  • Simplifies the code and reduces potential points of failure
  • Leverages existing functionality from the webpack module

Comment on lines +192 to 197
{
find: '="FOCUS_SENSITIVE",',
replacement: {
match: /(?<=\.hidden]:)\i/,
replace: "false"
}
Copy link

@coderabbitai coderabbitai bot Mar 2, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fixed media viewer options visibility when zoomed.

This patch ensures that media viewer options remain visible even when zoomed in with Discord's default feature by forcing the hidden class condition to return false.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whats the actual issue youre addressing here?

Copy link

Choose a reason for hiding this comment

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

@Scyye The issue being addressed is that normally when you zoom into an image using Discord's built-in zoom feature, the media viewer options (like the download button, fullscreen button, etc.) disappear because Discord hides them.

This patch forces those controls to remain visible even when zoomed in, giving users better access to those options while they're examining zoomed images. Without this fix, users would have to zoom out first just to access those controls, which creates a poor user experience.

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.

3 participants