Skip to content

[WEB-3978] chore: cmd k search result redirection improvements #7012

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

Merged

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented May 5, 2025

Description

This PR improves the redirection behavior from the Cmd+K search results. In addition to redirecting to the selected page, it now expands the corresponding project and highlights it in the app sidebar.

A new utility function, openProjectAndScrollToSidebar, has been added. It accepts a projectId, and can be reused wherever similar behavior is needed.

Type of Change

  • Improvement

Media

Before After
WEB-3978-Before WEB-3978-After

References

[WEB-3978]

Summary by CodeRabbit

  • New Features
    • Improved project navigation in the command palette: selecting a project now automatically opens and scrolls to the relevant sidebar item, highlighting it for better visibility.
  • Enhancements
    • Project list open/close state is now managed centrally, ensuring consistent behavior across the interface.
  • Style
    • Added a highlight animation for sidebar project items to visually emphasize them when accessed.

Copy link
Contributor

coderabbitai bot commented May 5, 2025

Walkthrough

A centralized state management system for the open/close state of project lists in the command palette sidebar was implemented using MobX. A helper function was introduced to open a project and scroll to its sidebar item with a highlight animation. Related UI components and global styles were updated to utilize these new mechanisms.

Changes

File(s) Change Summary
web/core/store/base-command-palette.store.ts Added observable projectListOpenMap, computed getIsProjectListOpen, and action toggleProjectListOpen to manage project list open state centrally via MobX.
web/core/components/command-palette/actions/helper.tsx Added openProjectAndScrollToSidebar helper to open project lists, scroll to sidebar items, and trigger highlight animation.
web/core/components/command-palette/actions/search-results.tsx Wrapped CommandPaletteSearchResults with observer, and invoked openProjectAndScrollToSidebar on item selection.
web/core/components/workspace/sidebar/projects-list-item.tsx Replaced local open state with centralized MobX state using useCommandPalette for project list open/close logic.
web/styles/globals.css Added new CSS keyframes animation highlight for visually emphasizing sidebar items.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CommandPaletteSearchResults
    participant openProjectAndScrollToSidebar
    participant CommandPaletteStore
    participant SidebarProjectsListItem
    participant DOM

    User->>CommandPaletteSearchResults: Selects a search result
    CommandPaletteSearchResults->>openProjectAndScrollToSidebar: Call with projectId
    openProjectAndScrollToSidebar->>CommandPaletteStore: toggleProjectListOpen(projectId, true)
    openProjectAndScrollToSidebar->>DOM: Scroll to sidebar item, trigger highlight animation
    CommandPaletteStore-->>SidebarProjectsListItem: projectListOpenMap updated
    SidebarProjectsListItem->>SidebarProjectsListItem: Rerender based on centralized open state
Loading

Poem

In the sidebar’s gentle light,
Projects now open just right.
With a highlight flash and MobX’s might,
Scrolling smooth, animations bright.
No more local state to fight—
Centralized, reactive, and out of sight!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 90c9b4a and 272b15b.

📒 Files selected for processing (2)
  • web/core/components/command-palette/actions/helper.tsx (1 hunks)
  • web/styles/globals.css (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/styles/globals.css
  • web/core/components/command-palette/actions/helper.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
✨ 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.
    • 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.

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

makeplane bot commented May 5, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

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 (5)
web/core/components/command-palette/actions/helper.tsx (1)

1-20: Well-structured helper function for sidebar navigation.

The openProjectAndScrollToSidebar function effectively manages both the state change (opening the project list) and the UI feedback (scrolling and highlighting), creating a cohesive user experience as described in the PR objectives.

Consider adding error handling for the DOM manipulation operations, and potentially extracting the element ID construction logic to make the function more reusable:

export const openProjectAndScrollToSidebar = (itemProjectId: string) => {
  if (!itemProjectId) return;
  // open the project list
  store.commandPalette.toggleProjectListOpen(itemProjectId, true);
  // scroll to the element
  const scrollElementId = `sidebar-${itemProjectId}-JOINED`;
  const scrollElement = document.getElementById(scrollElementId);
  // if the element exists, scroll to it
  if (scrollElement) {
    setTimeout(() => {
+     try {
        scrollElement.scrollIntoView({ behavior: "smooth", block: "start" });
        // Restart the highlight animation every time
        scrollElement.style.animation = "none";
        void scrollElement.offsetWidth;
        scrollElement.style.animation = "highlight 2s ease-in-out";
+     } catch (error) {
+       console.error("Error highlighting sidebar element:", error);
+     }
    });
  }
};
web/core/components/command-palette/actions/search-results.tsx (1)

4-4: Great enhancement to project navigation UX.

The integration of MobX observer and the new sidebar scrolling/highlighting functionality provides a better user experience when selecting search results, aligning perfectly with the PR objectives.

Consider using optional chaining for cleaner project ID extraction:

- const itemProjectId = item.project_id || (item.project_ids && item.project_ids[0]) || undefined;
+ const itemProjectId = item.project_id || item.project_ids?.[0] || undefined;

Also applies to: 12-13, 20-20, 44-45

web/core/store/base-command-palette.store.ts (1)

59-77: Consider using observable.map for dynamic keys

projectListOpenMap grows dynamically ([projectId] = …). With a plain object MobX must patch the object each time a new key appears which is slightly less efficient and can surprise when observe / reaction is used. A dedicated observable.map<string, boolean>() keeps intent explicit and avoids those edge cases.

web/core/components/workspace/sidebar/projects-list-item.tsx (1)

200-204: Side-effect runs only on match – consider symmetrical close

if (URLProjectId === project.id) setIsProjectListOpen(true);

When users navigate away from a project, its list stays expanded because there’s no complementary branch that sets it to false. Depending on UX expectations this could leave many projects open in long-running sessions.
If you want the sidebar to reflect the current route strictly, add an else setIsProjectListOpen(false).

web/core/components/workspace/sidebar/project-navigation.tsx (1)

143-158: isActive logic works but pathname.includes() can over-match

Using substring matching may flag an item active for unrelated nested paths (e.g. "/pages" inside "/pages-settings"). For stricter checks:

import { match } from "path-to-regexp"; // or use Next.js `router` helpers
...
const isPathnameActive = match(item.href, { end: false })(pathname);

Alternatively compare pathname.startsWith(item.href) which is cheap and avoids mid-string collisions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fbca9d9 and 9d9a59e.

📒 Files selected for processing (7)
  • web/core/components/command-palette/actions/helper.tsx (1 hunks)
  • web/core/components/command-palette/actions/search-results.tsx (3 hunks)
  • web/core/components/workspace/sidebar/project-navigation.tsx (5 hunks)
  • web/core/components/workspace/sidebar/projects-list-item.tsx (4 hunks)
  • web/core/store/base-command-palette.store.ts (6 hunks)
  • web/core/store/issue/issue-details/issue.store.ts (1 hunks)
  • web/styles/globals.css (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
web/core/components/workspace/sidebar/projects-list-item.tsx (2)
web/core/hooks/store/use-command-palette.ts (1)
  • useCommandPalette (7-11)
web/core/store/router.store.ts (1)
  • projectId (85-87)
web/core/store/base-command-palette.store.ts (1)
web/core/store/router.store.ts (1)
  • projectId (85-87)
🪛 Biome (1.9.4)
web/core/components/command-palette/actions/search-results.tsx

[error] 44-44: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/styles/globals.css (1)

945-955: Clean animation implementation for sidebar highlighting.

The new highlight keyframe animation provides a smooth visual effect to draw attention to elements in the sidebar. It transitions from a fully opaque background color to transparent, maintaining a consistent border radius.

web/core/store/issue/issue-details/issue.store.ts (1)

309-309: Good fix for issue identifier registration.

Adding the issue identifier to the store immediately after validation ensures it's available before any subsequent operations, preventing potential state inconsistencies between different parts of the application.

web/core/components/workspace/sidebar/projects-list-item.tsx (1)

67-85: Good move to centralised state, but mind the toggleProjectListOpen contract

The component now relies on the store-level toggleProjectListOpen. After fixing the contract bug in the store (see comment above) this usage will work as expected. Without the fix, setIsProjectListOpen(false) may reopen a list that was already closed.

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

🧹 Nitpick comments (1)
web/core/store/issue/issue.store.ts (1)

63-68: Consider adding null/undefined checks for projectIdentifier and workItemSequenceId

The code builds an issue identifier by combining the project identifier and sequence ID, but doesn't handle cases where these values might be undefined or null.

- // add issue identifier to the issuesIdentifierMap
- const projectIdentifier = rootStore.projectRoot.project.getProjectIdentifierById(issue?.project_id);
- const workItemSequenceId = issue?.sequence_id;
- const issueIdentifier = `${projectIdentifier}-${workItemSequenceId}`;
- set(this.issuesIdentifierMap, issueIdentifier, issue.id);
+ // add issue identifier to the issuesIdentifierMap
+ const projectIdentifier = rootStore.projectRoot.project.getProjectIdentifierById(issue?.project_id);
+ const workItemSequenceId = issue?.sequence_id;
+ if (projectIdentifier && workItemSequenceId) {
+   const issueIdentifier = `${projectIdentifier}-${workItemSequenceId}`;
+   set(this.issuesIdentifierMap, issueIdentifier, issue.id);
+ }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ea68b8d and a68a287.

📒 Files selected for processing (1)
  • web/core/store/issue/issue.store.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/store/issue/issue.store.ts (2)

10-10: LGTM: Import for accessing project identifier data

This import of rootStore is necessary to access project identifier information used in the enhanced issue identification system.


63-68: Good implementation supporting the Command+K search result navigation enhancement

This code elegantly implements the issue identification mapping needed for the enhanced Command+K search result navigation mentioned in the PR objectives. The mapping enables the application to find the right project and issue when a user selects a search result, supporting the new ability to expand the relevant project in the sidebar and highlight it.

@sriramveeraghanta sriramveeraghanta merged commit 079c3a3 into preview May 12, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-cmd-k-search-result-redirection-improvements branch May 12, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants