Skip to content

Conversation

sid597
Copy link
Collaborator

@sid597 sid597 commented Oct 1, 2025

https://www.loom.com/share/1ddd5b55abbe4313a0f5da18c86e06fd?sid=26ac4d77-0c72-4ec2-987b-b38d731e09b9

Pending todos for next pr (all relate to db function so want to do them together):

New issues that got created

All issues from #340 are addressed

Summary by CodeRabbit

  • New Features

    • Collapsible Discourse Suggestions panel with external open/close control.
    • Rich suggestions experience: Hyde search workflow, client-side caching, node-type filtering, quick-add by groups, counters, and per-node actions (open/create).
    • Group-based page management within suggestions.
  • Improvements

    • Panel manager supports per-panel open state and header.
    • Synchronized panel toggling with callbacks.
    • Settings auto-create Suggestive Mode and Page Groups when needed, with error toasts.
    • UI/accessibility polish and performance gains via caching.
  • Chores

    • Setup script reordered to run migrations before environment generation.

Copy link

linear bot commented Oct 1, 2025

ENG-917 Suggestions body

Copy link

supabase bot commented Oct 1, 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 1, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@sid597 sid597 changed the title suggestions body and util in one file ENG-917 Suggestions body and actions Oct 1, 2025
@sid597 sid597 marked this pull request as ready for review October 4, 2025 08:35
@sid597
Copy link
Collaborator Author

sid597 commented Oct 4, 2025

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

✅ Actions performed

Full review triggered.

Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

📝 Walkthrough

Walkthrough

Implements controlled open/close behavior for Discourse suggestions panels, introduces a new SuggestionsBody component, updates PanelManager to manage per-panel isOpen state and updates, revises hyde.ts APIs and parameters, adjusts suggestive mode settings initialization/creation logic, removes two JSX comments, and reorders a setup script in database/package.json.

Changes

Cohort / File(s) Summary
Panel control and state management
apps/roam/src/components/DiscourseSuggestionsPanel.tsx, apps/roam/src/components/PanelManager.tsx
DiscourseSuggestionsPanel becomes a controlled component with props isOpen and onToggle; internal state syncs via useEffect; renders SuggestionsBody. PanelManager adds isOpen to PanelState, initializes it on addPanel, renders panels with isOpen/onToggle, and exposes updatePanelState to mutate per-panel fields; panel selection order reversed for open panels.
Suggestions UI body (new)
apps/roam/src/components/SuggestionsBody.tsx
New component implementing Hyde-driven suggestion workflow, caching, fetching discourse context and refs, filtering/grouping UI, and actions. Exports SuggestionsBody (default) and DiscourseData type.
HyDE utilities API update
apps/roam/src/utils/hyde.ts
Adjusts public types and function signatures: ResultItemMin.uid becomes optional; adds exported ExistingResultGroup; makes some helpers private; updates PerformHydeSearchParams to use discourseNode, blockUid, pageTitle; refactors performHydeSearch accordingly.
Suggestive mode settings flow
apps/roam/src/components/settings/SuggestiveModeSettings.tsx
Switches to local state for settings/UIDs, creates Suggestive Mode and Page Groups blocks when missing, wraps embedding creation in try/catch with toast, refreshes settings; updates PageGroupsPanel props/key.
Settings UI comments removal
apps/roam/src/components/settings/PageGroupPanel.tsx
Removes two JSX comment blocks; no behavior change.
Database setup script order
packages/database/package.json
Reorders setup script to run migrate before genenv.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant PanelManager
  participant DiscourseSuggestionsPanel as SuggestionsPanel
  participant SuggestionsBody

  Note over PanelManager,SuggestionsPanel: Controlled panel open/close

  User->>PanelManager: Open panel for tag
  PanelManager->>PanelManager: addPanel(tag, { isOpen: true })
  PanelManager->>SuggestionsPanel: Render with isOpen=true, onToggle(...)
  SuggestionsPanel->>SuggestionsPanel: handleToggle(next)
  SuggestionsPanel-->>PanelManager: onToggle(next)
  PanelManager->>PanelManager: updatePanelState(tag, { isOpen: next })
  PanelManager->>SuggestionsPanel: Re-render with updated isOpen
  SuggestionsPanel->>SuggestionsBody: Render body when isOpen
Loading
sequenceDiagram
  autonumber
  participant UI as SuggestionsBody
  participant Hyde as performHydeSearch
  participant Roam as Roam/Backend APIs

  Note over UI,Hyde: Hyde params now use pageTitle, blockUid, discourseNode

  UI->>Hyde: performHydeSearch({ pageTitle, blockUid, discourseNode })
  Hyde->>Roam: Fetch context (parent/child, refs) as needed
  Roam-->>Hyde: Context data
  Hyde->>Hyde: Filter/score candidates (uid optional)
  Hyde-->>UI: Results (groups/nodes)
  UI->>UI: Update cache, filters, counters
  UI-->>User: Display suggestions and actions
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60–90 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “ENG-917 Suggestions body and actions” succinctly captures the addition of the new SuggestionsBody component and its associated action logic while preserving ticket traceability. It aligns directly with the primary changes introduced in this pull request.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/roam/src/components/settings/SuggestiveModeSettings.tsx (1)

14-102: Stateful settings now goes stale

Storing settings in component state means the values backing FlagPanel/PageGroupsPanel freeze after the first render. Subsequent edits (toggling a flag, editing page groups) happen in Roam, but this component never re‑fetches the config, so it keeps handing the old value/initialGroups back to the children. The UI drifts from the real config and reverts user changes on re-render. Please switch back to deriving settings from getFormattedConfigTree() each render or add a watcher that refreshes state whenever the underlying config changes.

apps/roam/src/utils/hyde.ts (1)

434-488: Boolean settings no longer honoured

getExtensionAPI().settings.get(...) gives strings like "false" for unchecked toggles. Casting with as boolean doesn’t coerce at runtime, so both settings read as truthy and the “grab parent/child” and “grab referenced pages” filters always run. This regresses users who turned them off. Please restore getBooleanSetting (or explicitly coerce with something like === true || value === "true") before branching on these flags.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 436430a and 43ea70b.

📒 Files selected for processing (7)
  • apps/roam/src/components/DiscourseSuggestionsPanel.tsx (4 hunks)
  • apps/roam/src/components/PanelManager.tsx (6 hunks)
  • apps/roam/src/components/SuggestionsBody.tsx (1 hunks)
  • apps/roam/src/components/settings/PageGroupPanel.tsx (0 hunks)
  • apps/roam/src/components/settings/SuggestiveModeSettings.tsx (3 hunks)
  • apps/roam/src/utils/hyde.ts (7 hunks)
  • packages/database/package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/roam/src/components/settings/PageGroupPanel.tsx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-22T10:40:52.752Z
Learnt from: sid597
PR: DiscourseGraphs/discourse-graph#232
File: apps/roam/src/utils/getAllDiscourseNodesSince.ts:18-31
Timestamp: 2025-06-22T10:40:52.752Z
Learning: In apps/roam/src/utils/getAllDiscourseNodesSince.ts, the user confirmed that querying for `?title` with `:node/title` and mapping it to the `text` field in the DiscourseGraphContent type is the correct implementation for retrieving discourse node content from Roam Research, despite it appearing to query page titles rather than block text content.

Applied to files:

  • apps/roam/src/utils/hyde.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check

@sid597 sid597 force-pushed the eng-917-suggestions-body branch from 43ea70b to 8e1c9fc Compare October 5, 2025 03:10
@sid597 sid597 force-pushed the eng-914-panel-manager branch from 436430a to ac171db Compare October 5, 2025 03:10
@sid597
Copy link
Collaborator Author

sid597 commented Oct 5, 2025

#340 (comment)

Most of our buttons use the same or similar padding, border-radius, etc. This button seems to have them backwards

image

vs
image
image

image

@sid597
Copy link
Collaborator Author

sid597 commented Oct 5, 2025

#340 (comment)

@maparent where are we at with the require vs import here?

@sid597 sid597 requested a review from mdroidian October 5, 2025 07:34
@mdroidian
Copy link
Contributor

mdroidian commented Oct 6, 2025

#340 (comment)

@maparent where are we at with the require vs import here?

@sid597 syncDgNodesToSupabase.ts is not in this PR. Has the require moved somewhere else?

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.

Unfortunately I couldn't fully test

Image But we can discuss that at our next meeting.

Until then, here are some suggestions:

Image

Remove the bottom border from this Navbar.
If you need the border, put it as a top border of the collapsed component, so it only shows up when unfolded.

Image

Remove the card border of <SuggestionsBody> ... too many lines

I only see that the comment has been moved to this PR, but not addressed: #473 (comment)
Do you plan on addressing it still in this PR or somewhere else?

sid597 added 5 commits October 9, 2025 15:49
… 3. fix panel manager scroll issue, add new panel to top 4. If no result from search show message 5. fix pading and view for filter button row 6. use formatted tree instead of extensionapi, fix when suggestions don't exist
@sid597 sid597 force-pushed the eng-914-panel-manager branch from ac171db to e6b1f75 Compare October 9, 2025 10:29
@sid597 sid597 force-pushed the eng-917-suggestions-body branch from 121a02e to 1ae2a38 Compare October 9, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants