Skip to content

Conversation

@mdroidian
Copy link
Collaborator

@mdroidian mdroidian commented Aug 3, 2025

We can now rm node_modules and rm package-lock.json then npm i without --legacy-peer-deps.

NOTE: Only the Blueprint Components used in roamjs-components were patched.

npm ls react

roamjs-components@0.86.0-alpha.2 C:\Users\Michael\Desktop\Areas\RoamJS\RoamJS Repos\roamjs-components
+-- @blueprintjs/core@3.50.4 overridden
| +-- react-popper@1.3.11
| | +-- @hypnosphi/create-react-context@0.3.1
| | | `-- react@18.2.0 deduped
| | `-- react@18.2.0 deduped
| +-- react-transition-group@2.9.0
| | `-- react@18.2.0 deduped
| `-- react@18.2.0 deduped
+-- @blueprintjs/datetime@3.23.14 overridden
| +-- react-day-picker@7.4.9
| | `-- react@18.2.0 deduped
| `-- react@18.2.0 deduped
+-- @blueprintjs/select@3.18.6 overridden
| `-- react@18.2.0 deduped
+-- @samepage/scripts@0.74.2
| `-- @samepage/testing@0.74.2
|   `-- @testing-library/react@14.0.0
|     `-- react@18.2.0 deduped
+-- marked-react@1.1.2
| `-- react@18.2.0 deduped
+-- react-dom@18.2.0 overridden
| `-- react@18.2.0 deduped
+-- react@18.2.0
`-- use-sync-external-store@1.2.0
  `-- react@18.2.0 deduped

Summary by CodeRabbit

  • New Features

    • Introduced a new "TimePanel" component, accessible via the command palette, that displays and interacts with time-related data.
  • Bug Fixes

    • Improved MenuItemSelect to prevent displaying "create new item" as the selected label.
  • Refactor

    • Enhanced type safety by updating component prop types to explicitly accept children where appropriate.
    • Upgraded React and BlueprintJS dependencies to ensure compatibility and improved typing support.
  • Chores

    • Updated package dependencies, removed unused packages, and adjusted development tools for better maintainability.

- Upgrade React and React DOM to version 18.2.0 in package.json and package-lock.json.
- Fix minor type errors
- Add patches for @blueprintjs/core and @blueprintjs/select to support children prop in TypeScript definitions.
@coderabbitai
Copy link

coderabbitai bot commented Aug 3, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update includes a package version bump, dependency upgrades (notably React 17 to 18), and dependency removals/additions in package.json. Several BlueprintJS TypeScript declaration patches add explicit children properties to component prop interfaces. The codebase adopts these changes by updating internal component prop types to accept children, introducing a new TimePanel component, and refining type annotations and UI logic in various React components.

Changes

Cohort / File(s) Change Summary
Dependency & Version Management
package.json
Upgraded project version to 0.86.0-alpha.2, updated React/React DOM to 18.2.0, removed aws-sdk-plus, added dotenv to devDependencies, and adjusted dependency overrides for BlueprintJS and React.
BlueprintJS TypeScript Patches
patches/@blueprintjs+core+3.50.4.patch, patches/@blueprintjs+select+3.18.6.patch
Added optional children?: React.ReactNode to multiple BlueprintJS core and select component prop interfaces to improve typing for React 18 compatibility.
Component Prop Typing for Children
src/components/BlockErrorBoundary.tsx, src/components/ComponentContainer.tsx
Updated component prop types to explicitly accept children (as required for BlockErrorBoundary and optional for ComponentContainer).
New Feature: TimePanel Component
src/components.tsx
Added a new "TimePanel" component, including async block creation and registration with the command palette and global developer components.
Type Annotation Improvements
src/components/ConfigPanels/OauthPanel.tsx, src/components/CursorMenu.tsx
Added explicit TypeScript type annotations to event and callback parameters for improved type safety.
Menu Item Rendering Logic
src/components/MenuItemSelect.tsx
Improved logic to prevent "create new item" placeholder from displaying as button text by using the isCreateNewItem utility from BlueprintJS.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TimePanelComponent
    participant RoamAPI

    User->>TimePanelComponent: Render via command palette
    TimePanelComponent->>RoamAPI: Get current page UID
    RoamAPI-->>TimePanelComponent: Return UID or fallback
    TimePanelComponent->>RoamAPI: Create block with "time-field" under page UID
    RoamAPI-->>TimePanelComponent: Return block UID
    TimePanelComponent->>User: Display TimePanel UI with selected time
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

A bunny hopped through fields of code,
Upgrading React, lightening the load.
With children props now crystal clear,
And TimePanel’s debut drawing near.
Menu tweaks and types refined—
This patch leaves no bug behind!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch upgrade-to-react-18-2-0

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.

@mdroidian mdroidian marked this pull request as draft August 3, 2025 02:44
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: 3

🧹 Nitpick comments (2)
src/components/ConfigPanels/OauthPanel.tsx (1)

30-31: Good type safety improvement, but remove redundant cast.

The explicit event typing is excellent for type safety. However, the cast (e.target as HTMLInputElement) on line 31 is now redundant since the parameter is already correctly typed.

Consider this simplification:

-    (e: React.ChangeEvent<HTMLInputElement>) => {
-      const checked = (e.target as HTMLInputElement).checked;
+    (e: React.ChangeEvent<HTMLInputElement>) => {
+      const checked = e.target.checked;
src/components.tsx (1)

231-231: Remove console.log statement.

Debug logging should be removed from production code.

-            console.log(currentPageUid);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36fa528 and 742b44a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • package.json (5 hunks)
  • patches/@blueprintjs+core+3.50.4.patch (1 hunks)
  • patches/@blueprintjs+select+3.18.6.patch (1 hunks)
  • src/components.tsx (3 hunks)
  • src/components/BlockErrorBoundary.tsx (1 hunks)
  • src/components/ComponentContainer.tsx (1 hunks)
  • src/components/ConfigPanels/OauthPanel.tsx (1 hunks)
  • src/components/CursorMenu.tsx (1 hunks)
  • src/components/MenuItemSelect.tsx (2 hunks)
🔇 Additional comments (12)
src/components/CursorMenu.tsx (1)

150-150: LGTM! Excellent type safety improvement.

The explicit typing of the item parameter enhances type safety and is consistent with the component's generic design and Props<T> interface.

src/components/BlockErrorBoundary.tsx (1)

4-8: LGTM! Proper children prop typing.

Making the children prop explicit in the interface is excellent for type safety and aligns with React 18 best practices. The component was already using this.props.children, so this change makes the interface accurately reflect the actual usage.

patches/@blueprintjs+select+3.18.6.patch (1)

9-9: LGTM! Necessary React 18 compatibility patch.

Adding the optional children prop to the BlueprintJS Select interface is essential for React 18 compatibility and follows standard React component patterns. The optional nature ensures backward compatibility.

src/components/MenuItemSelect.tsx (2)

2-7: LGTM! Good import addition for improved UX.

Adding the isCreateNewItem import supports the logic improvement below for better user experience.


46-46: LGTM! Excellent UX improvement.

The additional !isCreateNewItem(activeItem) check prevents displaying the "create new item" placeholder text as the button text, which would be confusing to users. This ensures the button shows either the actual selected item or the appropriate placeholder text.

src/components/ComponentContainer.tsx (1)

11-12: LGTM! Clean implementation of explicit children typing.

The addition of optional children?: React.ReactNode prop and its proper usage in the component aligns perfectly with React 18 best practices and improves type safety.

Also applies to: 40-40

package.json (3)

4-4: Version bump follows proper semver for React upgrade.

The alpha version increment is appropriate for this major React upgrade.


81-92: BlueprintJS overrides ensure React 18 compatibility.

The overrides section properly forces BlueprintJS packages to use React 18.2.0, preventing version conflicts.


71-71: dotenv Dependency Usage Confirmed

dotenv is only imported and invoked in build scripts (e.g. scripts/publishToRoamDepot.ts) to load environment variables for tooling. Runtime code merely references process.env and relies on the bundler or host environment—so keeping dotenv as a devDependency is correct.

• scripts/publishToRoamDepot.ts – imports and calls dotenv.config()
• All other references to process.env occur in source files (env.ts, runExtension.ts, components) and tests

No changes required.

patches/@blueprintjs+core+3.50.4.patch (1)

1-49: Essential patch for React 18 compatibility.

This patch correctly adds explicit children?: React.ReactNode properties to BlueprintJS deprecated interfaces, which is necessary since React 18 removed implicit children from React.FC. The patch ensures backward compatibility while maintaining type safety.

src/components.tsx (2)

15-15: TimePanel component properly imported and exported.

The import and export of TimePanel component maintains consistency with the existing pattern.

Also applies to: 274-274


218-258: TimePanel component demo implementation looks solid.

The overall structure and React patterns are correct. The component properly handles async operations, loading states, and component composition.

Comment on lines +29 to +30
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

React and TypeScript definitions upgraded consistently.

The upgrade to React 18.2.0 with matching TypeScript definitions is properly coordinated.

Also applies to: 43-44


🌐 Web query:

Is React 18.2.0 the latest stable version of React, and are there any known security vulnerabilities?

💡 Result:

As of August 3, 2025, the latest stable version of React is 19.1.0, released on March 28, 2025. (github.com) React 18.2.0, released on June 14, 2022, is not the latest stable version.

Regarding security vulnerabilities, Snyk reports that the latest version, 19.1.1, has no known vulnerabilities. (security.snyk.io) However, earlier versions, such as 0.0.1 to 0.13.0, have been identified with cross-site scripting (XSS) vulnerabilities. It's important to note that these vulnerabilities are present in older versions and have been addressed in subsequent releases.

Therefore, to ensure your application remains secure, it's recommended to use the latest stable version of React, which currently is 19.1.0.

Citations:


Upgrade React and TypeScript definitions to latest stable (19.1.0)

React 18.2.0 is no longer the latest stable release. As of August 2025, React 19.1.0 is the current stable version with no known security vulnerabilities. Please update both React and its TypeScript definitions to keep dependencies secure and up-to-date.

Areas to update in package.json:

  • Lines 29–30 ("@types/react", "@types/react-dom")
  • Lines 43–44 ("react", "react-dom")

Suggested diff:

-    "react": "18.2.0",
-    "react-dom": "18.2.0",
+    "react": "19.1.0",
+    "react-dom": "19.1.0",
 
-    "@types/react": "18.2.0",
-    "@types/react-dom": "18.2.0",
+    "@types/react": "19.1.0",
+    "@types/react-dom": "19.1.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
// … other dependencies …
"react": "19.1.0",
"react-dom": "19.1.0",
// … other devDependencies …
"@types/react": "19.1.0",
"@types/react-dom": "19.1.0",
// …
🤖 Prompt for AI Agents
In package.json around lines 29 to 30 and 43 to 44, update the versions of
"@types/react" and "@types/react-dom" from "18.2.0" to "19.1.0", and also update
"react" and "react-dom" dependencies to version "19.1.0". This ensures both
React and its TypeScript definitions are upgraded to the latest stable release.

Comment on lines +224 to +239
React.useEffect(() => {
const createUid = async () => {
const currentPageUid =
(await window.roamAlphaAPI.ui.mainWindow.getOpenPageOrBlockUid()) ||
window.roamAlphaAPI.util.dateToPageUid(new Date());

if (!currentPageUid) throw new Error("No current page uid");
console.log(currentPageUid);
const newUid = await createBlock({
parentUid: currentPageUid,
node: { text: "time-field" },
});
setUid(newUid);
};
createUid();
}, []);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for block creation.

The async block creation should handle potential failures gracefully.

        React.useEffect(() => {
          const createUid = async () => {
+           try {
              const currentPageUid =
                (await window.roamAlphaAPI.ui.mainWindow.getOpenPageOrBlockUid()) ||
                window.roamAlphaAPI.util.dateToPageUid(new Date());

              if (!currentPageUid) throw new Error("No current page uid");
              const newUid = await createBlock({
                parentUid: currentPageUid,
                node: { text: "time-field" },
              });
              setUid(newUid);
+           } catch (error) {
+             console.error("Failed to create block:", error);
+             // Consider setting an error state or fallback behavior
+           }
          };
          createUid();
        }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
React.useEffect(() => {
const createUid = async () => {
const currentPageUid =
(await window.roamAlphaAPI.ui.mainWindow.getOpenPageOrBlockUid()) ||
window.roamAlphaAPI.util.dateToPageUid(new Date());
if (!currentPageUid) throw new Error("No current page uid");
console.log(currentPageUid);
const newUid = await createBlock({
parentUid: currentPageUid,
node: { text: "time-field" },
});
setUid(newUid);
};
createUid();
}, []);
React.useEffect(() => {
const createUid = async () => {
try {
const currentPageUid =
(await window.roamAlphaAPI.ui.mainWindow.getOpenPageOrBlockUid()) ||
window.roamAlphaAPI.util.dateToPageUid(new Date());
if (!currentPageUid) throw new Error("No current page uid");
console.log(currentPageUid);
const newUid = await createBlock({
parentUid: currentPageUid,
node: { text: "time-field" },
});
setUid(newUid);
} catch (error) {
console.error("Failed to create block:", error);
// Consider setting an error state or fallback behavior
}
};
createUid();
}, []);
🤖 Prompt for AI Agents
In src/components.tsx around lines 224 to 239, the async function createUid does
not handle errors from the createBlock call, which may cause unhandled promise
rejections. Wrap the createBlock call and subsequent setUid in a try-catch block
to catch any errors, and handle them appropriately, such as logging the error or
showing a user-friendly message, to ensure graceful failure.

<TimePanel
title="time-field"
uid={uid}
parentUid="test-parent-uid"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace hardcoded test value with dynamic or configurable value.

The hardcoded "test-parent-uid" appears to be a placeholder and should be replaced with a proper dynamic value or made configurable.

-              parentUid="test-parent-uid"
+              parentUid={currentPageUid}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parentUid="test-parent-uid"
parentUid={currentPageUid}
🤖 Prompt for AI Agents
In src/components.tsx at line 249, replace the hardcoded string
"test-parent-uid" with a dynamic value passed as a prop or derived from
component state or context. Alternatively, make it configurable via component
props or environment variables to avoid using a fixed placeholder.

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