Skip to content

Conversation

@mdroidian
Copy link
Collaborator

@mdroidian mdroidian commented Jul 7, 2025

Add the ability to hide columns in the results view, with settings persisted as blocks.

Summary by CodeRabbit

  • New Features

    • Introduced the ability to hide and show columns in the results view, with a dedicated "Hide Columns" menu option and an editing panel for toggling column visibility.
    • Column visibility settings are saved and persist across sessions.
  • Improvements

    • All table, chart, timeline, and kanban views now respect hidden columns, ensuring only visible columns are shown in filters, exports, and view selectors.
    • The menu icon now indicates when columns are hidden.

@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

Walkthrough

The changes introduce dynamic column hiding functionality to the ResultsView component, allowing users to control which columns are visible. This includes new UI controls, state management, and persistence for hidden columns. Supporting logic is added to parse and use hidden column settings from result node data.

Changes

File(s) Change Summary
src/components/ResultsView.tsx Added dynamic column hiding: new state, UI controls, menu integration, persistence, and logic updates.
src/utils/parseResultSettings.ts Extended to parse and return a hiddenColumns array from result node children in settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ResultsView
    participant SettingsStore

    User->>ResultsView: Clicks "Hide Columns" menu item
    ResultsView->>User: Shows column visibility panel
    User->>ResultsView: Toggles column visibility switches
    ResultsView->>ResultsView: Updates hiddenColumns state
    ResultsView->>SettingsStore: Persists hiddenColumns changes
    ResultsView->>User: Updates visible columns in UI
Loading

Poem

🐇
Hop, hop! A column’s gone,
Hidden now from dusk till dawn.
With a flick and a switch,
The table’s anew—how rich!
Rabbits love a tidy view,
Now you can hide a column or two!
🥕

✨ Finishing Touches
  • 📝 Generate Docstrings

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a3d2c4b and 4eb9d11.

📒 Files selected for processing (2)
  • src/components/ResultsView.tsx (17 hunks)
  • src/utils/parseResultSettings.ts (2 hunks)
🔇 Additional comments (6)
src/utils/parseResultSettings.ts (1)

117-120: Clean implementation of hidden columns parsing

The implementation correctly follows the existing pattern for parsing settings from the result node. The extraction of hidden columns is straightforward and properly integrated into the returned settings object.

Also applies to: 168-168

src/components/ResultsView.tsx (5)

317-323: Well-implemented state management for column visibility

Good use of useMemo to compute visible columns efficiently. The dependency array correctly includes both columns and hiddenColumns to ensure proper recomputation when either changes.


415-430: Correct implementation of hidden columns persistence

The function properly handles state updates and persistence, following the established pattern used elsewhere in the component for saving settings to Roam blocks.


484-484: Thorough update of column references to use visible columns

Excellent job systematically replacing columns with visibleColumns throughout the component. All the changes are appropriate for their contexts - export, UI selections, and layout rendering.

Also applies to: 603-603, 682-684, 691-691, 717-717, 853-853, 1191-1191, 1213-1213, 1219-1219, 1228-1228


912-912: View settings for hidden columns are preserved

The filtering ensures that view settings are only displayed for visible columns, which is correct. Note that view settings for hidden columns are preserved in state and will reappear when columns are unhidden.


381-382: Well-integrated menu item with appropriate visual indicators

Good implementation details:

  • The dirty indicator on both the main menu icon and the "Hide Columns" menu item helps users understand when columns are hidden
  • The eye-off icon is an intuitive choice for this feature

Also applies to: 1028-1035

Comment on lines +970 to +994
) : isEditHiddenColumns ? (
<div className="relative p-4" style={{ minWidth: "320px" }}>
<MenuHeading
onClear={() => setIsEditHiddenColumns(false)}
text="Hide Columns"
/>
<div className="flex flex-col gap-2 py-2">
{columns.map(({ key }) => (
<div key={key} className="flex items-center justify-between">
<span className="text-sm">{key}</span>
<Switch
checked={!hiddenColumns.includes(key)}
onChange={(e) => {
const isVisible = (e.target as HTMLInputElement).checked;
if (isVisible) {
onHiddenColumnsChange(hiddenColumns.filter(col => col !== key));
} else {
onHiddenColumnsChange([...hiddenColumns, key]);
}
}}
/>
</div>
))}
</div>
</div>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider preventing users from hiding all columns

The implementation looks good, but there's an edge case where users could potentially hide all columns, leaving the results view empty. Consider adding validation to ensure at least one column remains visible.

 onChange={(e) => {
   const isVisible = (e.target as HTMLInputElement).checked;
   if (isVisible) {
     onHiddenColumnsChange(hiddenColumns.filter(col => col !== key));
   } else {
+    // Prevent hiding the last visible column
+    if (hiddenColumns.length >= columns.length - 1) {
+      renderToast({
+        id: "hide-columns-error",
+        content: "At least one column must remain visible",
+        intent: Intent.WARNING,
+      });
+      return;
+    }
     onHiddenColumnsChange([...hiddenColumns, key]);
   }
 }}
📝 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
) : isEditHiddenColumns ? (
<div className="relative p-4" style={{ minWidth: "320px" }}>
<MenuHeading
onClear={() => setIsEditHiddenColumns(false)}
text="Hide Columns"
/>
<div className="flex flex-col gap-2 py-2">
{columns.map(({ key }) => (
<div key={key} className="flex items-center justify-between">
<span className="text-sm">{key}</span>
<Switch
checked={!hiddenColumns.includes(key)}
onChange={(e) => {
const isVisible = (e.target as HTMLInputElement).checked;
if (isVisible) {
onHiddenColumnsChange(hiddenColumns.filter(col => col !== key));
} else {
onHiddenColumnsChange([...hiddenColumns, key]);
}
}}
/>
</div>
))}
</div>
</div>
) : isEditHiddenColumns ? (
<div className="relative p-4" style={{ minWidth: "320px" }}>
<MenuHeading
onClear={() => setIsEditHiddenColumns(false)}
text="Hide Columns"
/>
<div className="flex flex-col gap-2 py-2">
{columns.map(({ key }) => (
<div key={key} className="flex items-center justify-between">
<span className="text-sm">{key}</span>
<Switch
checked={!hiddenColumns.includes(key)}
onChange={(e) => {
const isVisible = (e.target as HTMLInputElement).checked;
if (isVisible) {
onHiddenColumnsChange(hiddenColumns.filter(col => col !== key));
} else {
// Prevent hiding the last visible column
if (hiddenColumns.length >= columns.length - 1) {
renderToast({
id: "hide-columns-error",
content: "At least one column must remain visible",
intent: Intent.WARNING,
});
return;
}
onHiddenColumnsChange([...hiddenColumns, key]);
}
}}
/>
</div>
))}
</div>
</div>
🤖 Prompt for AI Agents
In src/components/ResultsView.tsx around lines 970 to 994, the current code
allows users to hide all columns, which can result in an empty results view. To
fix this, add validation in the onChange handler of the Switch component to
prevent hiding the last visible column. Specifically, check if hiding the
current column would leave no visible columns, and if so, do not update
hiddenColumns state to ensure at least one column remains visible.

@mdroidian mdroidian closed this Jul 21, 2025
@mdroidian mdroidian deleted the cursor/add-column-hiding-functionality-3b3e branch July 21, 2025 03:54
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