Skip to content

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Oct 24, 2025

image

Summary by CodeRabbit

  • New Features

    • Settings reorganized into a tabbed interface separating Page Groups and Sync Config for improved navigation.
  • Improvements

    • Enhanced error handling for node embeddings upload with user notifications.
    • Related toggles now dynamically adjust based on parent setting selection for better UX.

@linear
Copy link

linear bot commented Oct 24, 2025

@supabase
Copy link

supabase bot commented Oct 24, 2025

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Collaborator Author

sid597 commented Oct 24, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sid597 sid597 changed the title move sync settings to a new tab, make other setting disabled if page one is enabled ENG-993 Move sync settings to tabs Oct 24, 2025
@sid597 sid597 marked this pull request as ready for review October 24, 2025 11:29
@sid597
Copy link
Collaborator Author

sid597 commented Oct 24, 2025

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

📝 Walkthrough

Walkthrough

The SuggestiveModeSettings component was refactored from a single-column layout to a tabbed UI with "Page Groups" and "Sync Config" tabs. New internal state manages tab selection and page relation settings. The embedding generation action was moved to the Sync Config tab with error handling, and the Include Parent And Child Blocks behavior was made conditional on page relations settings.

Changes

Cohort / File(s) Summary
SuggestiveModeSettings Refactoring
apps/roam/src/components/settings/SuggestiveModeSettings.tsx
Converted single-column layout to tabbed UI with "Page Groups" and "Sync Config" tabs. Added state for tab selection and page relation inclusion. Moved Generate & Upload All Node Embeddings action to Sync Config tab with try/catch error handling. Reorganized component controls into appropriate tabs and made Include Parent And Child Blocks conditionally disabled when page relations are included.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SuggestiveModeSettings
    participant PageGroupsPanel
    participant SyncConfigPanel

    User->>SuggestiveModeSettings: Select Tab (Page Groups/Sync Config)
    SuggestiveModeSettings->>SuggestiveModeSettings: Update selectedTabId state
    
    alt Page Groups Tab
        SuggestiveModeSettings->>PageGroupsPanel: Render with pageGroupsUid key
        Note over PageGroupsPanel: Keyed refresh on UID change
    else Sync Config Tab
        SuggestiveModeSettings->>SyncConfigPanel: Render sync controls
        Note over SyncConfigPanel: FlagPanel for page relations<br/>FlagPanel for parent/child blocks
        User->>SyncConfigPanel: Toggle Include Page Relations
        SyncConfigPanel->>SuggestiveModeSettings: Update includePageRelations
        SuggestiveModeSettings->>SyncConfigPanel: Disable Parent/Child Blocks
        User->>SyncConfigPanel: Trigger Generate & Upload
        rect rgb(200, 240, 200)
        SyncConfigPanel->>SyncConfigPanel: try - Execute embedding generation
        end
        rect rgb(240, 200, 200)
        SyncConfigPanel->>SuggestiveModeSettings: catch - Show failure toast
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The change involves reorganizing a single component's UI structure and state management across multiple concerns (tab navigation, state coordination, conditional rendering, error handling). While contained to one file, the interaction between new state properties, conditional logic, and component lifecycle requires careful review to verify correct state synchronization and no unintended side effects.

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "ENG-993 Move sync settings to tabs" directly and clearly summarizes the main change in the changeset. The primary modification is restructuring the settings UI in SuggestiveModeSettings.tsx by replacing the single-column layout with a tabbed interface containing "Page Groups" and "Sync Config" tabs. The title is specific, concise, and uses clear language without vague terms or noise. A developer scanning the history would immediately understand that this PR refactors the settings presentation into a tabbed structure.

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.

Copy link
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 (4)
apps/roam/src/components/settings/SuggestiveModeSettings.tsx (4)

81-97: Effective vs. persisted setting for Parent/Child Blocks

You force value to true and disable the control when includePageRelations is true. If downstream logic reads only the persisted includeParentAndChildren value, behavior may diverge from UI. Either:

  • compute an effectiveIncludeParentAndChildren = includePageRelations || persisted, and ensure consumers use it; or
  • cascade-write includeParentAndChildren=true when includePageRelations turns on, and restore prior value on turn-off.

100-128: Guard against double‑clicks and show loading state

Prevent concurrent submissions, disable the button while running, and surface errors consistently.

@@
-  const [selectedTabId, setSelectedTabId] = useState<TabId>("page-groups");
+  const [selectedTabId, setSelectedTabId] = useState<TabId>("page-groups");
+  const [isEmbedding, setIsEmbedding] = useState(false);
@@
-                <Button
+                <Button
                   icon="cloud-upload"
                   text={"Generate & Upload All Node Embeddings"}
-                  onClick={() =>
-                    void (async () => {
+                  disabled={isEmbedding}
+                  onClick={() =>
+                    void (async () => {
+                      if (isEmbedding) return;
+                      setIsEmbedding(true);
                       renderToast({
@@
-                      try {
+                      try {
                         await createOrUpdateDiscourseEmbedding();
                       } catch (e) {
                         console.error("Failed to generate embeddings", e);
                         renderToast({
@@
-                        });
+                        });
+                      } finally {
+                        setIsEmbedding(false);
                       }
                     })()
                   }
                   intent={Intent.PRIMARY}
                   className={"mt-2"}
                 />

54-57: Do you need key={pageGroupsUid}?

Keying PageGroupsPanel to a constant UID forces a remount even when not necessary and can drop local state. If remounting isn’t required for correctness, remove the key to preserve state.


25-34: Add error handling to create the “Suggestive Mode” container

If createBlock fails, the UI silently continues without a parent UID. Add try/catch and a toast to aid diagnostics.

   useEffect(() => {
     if (suggestiveModeUid) return;
     void (async () => {
-      const smUid = await createBlock({
-        parentUid: getPageUidByPageTitle(DISCOURSE_CONFIG_PAGE_TITLE),
-        node: { text: "Suggestive Mode" },
-      });
-      setSuggestiveModeUid(smUid);
+      try {
+        const smUid = await createBlock({
+          parentUid: getPageUidByPageTitle(DISCOURSE_CONFIG_PAGE_TITLE),
+          node: { text: "Suggestive Mode" },
+        });
+        setSuggestiveModeUid(smUid);
+      } catch (e) {
+        console.error("Failed to create Suggestive Mode container", e);
+        renderToast({
+          id: "discourse-suggestive-mode-error",
+          content: "Could not initialize Suggestive Mode settings block.",
+          intent: Intent.DANGER,
+          timeout: 5000,
+        });
+      }
     })();
   }, [suggestiveModeUid]);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b964097 and a4059bc.

📒 Files selected for processing (1)
  • apps/roam/src/components/settings/SuggestiveModeSettings.tsx (3 hunks)
🔇 Additional comments (1)
apps/roam/src/components/settings/SuggestiveModeSettings.tsx (1)

67-79: Verify FlagPanel onChange prop placement with roamjs-components maintainer or package docs

The concern in the review comment is valid but unresolved: both FlagPanel usages at lines 67 and 81 pass options={{ onChange: ... }}, but the actual FlagPanel API from roamjs-components cannot be verified through available search results. If the package expects onChange at the top level rather than nested in options, the state setter setIncludePageRelations will never be called, breaking the dependent UI logic at line 81 (conditional description and value).

Check the roamjs-components package (GitHub: dvargas92495/roamjs-components) or npm documentation to confirm whether FlagPanel expects:

  • onChange as a direct prop, or
  • options={{ onChange: ... }} as a nested prop

@sid597 sid597 requested a review from mdroidian October 24, 2025 11:43
Copy link
Contributor

@mdroidian mdroidian left a comment

Choose a reason for hiding this comment

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

👍

@sid597 sid597 force-pushed the eng-993-move-sync-settings-to-tabs branch from a4059bc to c6463c8 Compare October 26, 2025 20:06
@sid597 sid597 merged commit 6cfc41b into main Oct 26, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this to Done in General Oct 26, 2025
@sid597 sid597 deleted the eng-993-move-sync-settings-to-tabs branch October 26, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants