Skip to content

Tool - open rule as dialog#530

Merged
elie222 merged 1 commit intomainfrom
feat/rule-model-chat
Jun 27, 2025
Merged

Tool - open rule as dialog#530
elie222 merged 1 commit intomainfrom
feat/rule-model-chat

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jun 27, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a modal dialog for viewing rule details, replacing previous URL-based navigation for rule actions.
  • Improvements

    • Dialog headers in rule creation and editing are now consistently rendered, with dynamic titles and improved accessibility.
    • Expanded the scope of context providers in chat UI for more consistent state management.
  • Chores

    • Updated version to v1.7.15.

@vercel
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview Jun 27, 2025 2:20pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

Walkthrough

This update refactors dialog and modal handling for rule management in the assistant UI. The dialog header logic in RuleDialog is unified, the SWRProvider context is expanded in the chat UI, and rule actions now use a modal dialog instead of URL query parameters for viewing details. Minor code cleanups and a version bump are also included.

Changes

File(s) Change Summary
apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx Simplified and unified dialog header rendering; title now adapts dynamically and uses "sr-only" for edit mode.
apps/web/components/assistant-chat/chat.tsx Expanded SWRProvider context to wrap both control bar and message list.
apps/web/components/assistant-chat/tools.tsx Switched from URL query state navigation to modal dialog (RuleDialog) for rule actions; updated imports and logic.
apps/web/hooks/useAssistantNavigation.ts Removed commented-out index signature and explanatory comment; no logic changes.
version.txt Updated version from v1.7.14 to v1.7.15.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RuleActions
    participant RuleDialog

    User->>RuleActions: Clicks "View" button on a rule
    RuleActions->>RuleDialog: Opens modal with ruleId
    RuleDialog-->>User: Displays rule details in modal
    User->>RuleDialog: Closes modal
    RuleDialog-->>RuleActions: Triggers onClose
Loading

Possibly related PRs

Poem

A dialog’s header, once tangled in code,
Now smoothly adapts to whatever’s bestowed.
No more query strings to open a view—
A modal appears, fresh and new!
The rabbit hops on, version fifteen,
Tidier UI, and code more serene.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/components/assistant-chat/chat.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/components/assistant-chat/tools.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

✨ 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
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 76010f4 and d1f3be4.

📒 Files selected for processing (5)
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx (1 hunks)
  • apps/web/components/assistant-chat/chat.tsx (1 hunks)
  • apps/web/components/assistant-chat/tools.tsx (3 hunks)
  • apps/web/hooks/useAssistantNavigation.ts (0 hunks)
  • version.txt (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/hooks/useAssistantNavigation.ts
🧰 Additional context used
📓 Path-based instructions (8)
`apps/web/**/app/**`: Follow NextJS app router structure by organizing code within the app directory.

apps/web/**/app/**: Follow NextJS app router structure by organizing code within the app directory.

📄 Source: CodeRabbit Inference Engine (apps/web/CLAUDE.md)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
`apps/web/**/*.{ts,tsx}`: Use TypeScript with strict null checks enabled. Use pa...

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks enabled.
Use path aliases with @/ for imports from the project root.
Use proper error handling with try/catch blocks.
Use the LoadingContent component for async data loading states.
Prefix client-side environment variables with NEXT_PUBLIC_.

📄 Source: CodeRabbit Inference Engine (apps/web/CLAUDE.md)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
`apps/web/**/*.{ts,tsx,js,jsx}`: Format code with Prettier and follow tailwindcss patterns using prettier-plugin-tailwindcss.

apps/web/**/*.{ts,tsx,js,jsx}: Format code with Prettier and follow tailwindcss patterns using prettier-plugin-tailwindcss.

📄 Source: CodeRabbit Inference Engine (apps/web/CLAUDE.md)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
`apps/web/**`: Install packages only within the 'apps/web' directory, not at the repository root.

apps/web/**: Install packages only within the 'apps/web' directory, not at the repository root.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/installing-packages.mdc)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
`apps/web/app/(app)/**/*.{js,jsx,ts,tsx}`: If you need to use onClick in a component, that component is a client component and file must start with 'use client'.

apps/web/app/(app)/**/*.{js,jsx,ts,tsx}: If you need to use onClick in a component, that component is a client component and file must start with 'use client'.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
`**/*.{js,jsx,ts,tsx}`: Use Shadcn UI and Tailwind for components and styling. I...

**/*.{js,jsx,ts,tsx}: Use Shadcn UI and Tailwind for components and styling.
Implement responsive design with Tailwind CSS using a mobile-first approach.
Use the next/image package for images.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/ui-components.mdc)

List of files the instruction was applied to:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
`apps/web/**/components/**/*.{ts,tsx}`: Use PascalCase naming convention for com...

apps/web/**/components/**/*.{ts,tsx}: Use PascalCase naming convention for component files.
Prefer functional components with hooks.
Use shadcn/ui components when available.
Ensure responsive design with a mobile-first approach.

📄 Source: CodeRabbit Inference Engine (apps/web/CLAUDE.md)

List of files the instruction was applied to:

  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
`apps/web/components/**/*`: All other components are in components/.

apps/web/components/**/*: All other components are in components/.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

List of files the instruction was applied to:

  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/components/assistant-chat/tools.tsx
🧠 Learnings (3)
apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx (7)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:59.468Z
Learning: For components with onClick handlers in Next.js App Router, ensure they are client components by including the 'use client' directive at the top of the file.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: Custom React hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-06-23T12:25:52.998Z
Learning: Prefer functional React components with hooks over class components for better composability and modern React patterns.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-06-23T12:26:07.018Z
Learning: When handling form submissions in React, provide user feedback for both success and error cases, such as using toast notifications.
Learnt from: aryanprince
PR: elie222/inbox-zero#210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning: `MoreDropdown` is a React component and `useUnsubscribeButton` is a custom React hook, and they should not be imported using `import type`.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-06-23T12:27:33.499Z
Learning: For form text inputs in React using Shadcn UI, use the `Input` component with `registerProps` from a form library (such as react-hook-form) and pass any validation errors to the `error` prop.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: For data fetching in custom React hooks, prefer using the useSWR hook. The custom hook should typically wrap useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially the mutate function from SWR.
apps/web/components/assistant-chat/chat.tsx (5)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:47.630Z
Learning: In deeply nested React components within the Next.js app directory, use the SWR library to fetch data via API instead of loading data directly in the component.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:59.468Z
Learning: Use SWR for data fetching in deeply nested components in Next.js App Router projects to enable efficient client-side data fetching and caching.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-06-23T12:26:00.208Z
Learning: In React applications using SWR for data fetching, prefer the 'swr' package for API GET requests in client components, as it simplifies data refetching and caching.
Learnt from: elie222
PR: elie222/inbox-zero#485
File: apps/web/app/(landing)/login/page.tsx:41-43
Timestamp: 2025-06-05T09:49:12.168Z
Learning: In Next.js App Router, components that use the `useSearchParams` hook require a Suspense boundary to handle the asynchronous nature of search parameter access. The Suspense wrapper is necessary and should not be removed when a component uses useSearchParams.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: For data fetching in custom React hooks, prefer using the useSWR hook. The custom hook should typically wrap useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially the mutate function from SWR.
apps/web/components/assistant-chat/tools.tsx (8)
Learnt from: elie222
PR: elie222/inbox-zero#485
File: apps/web/app/(landing)/login/page.tsx:41-43
Timestamp: 2025-06-05T09:49:12.168Z
Learning: In Next.js App Router, components that use the `useSearchParams` hook require a Suspense boundary to handle the asynchronous nature of search parameter access. The Suspense wrapper is necessary and should not be removed when a component uses useSearchParams.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: Custom React hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: For data fetching in custom React hooks, prefer using the useSWR hook. The custom hook should typically wrap useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially the mutate function from SWR.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:47.630Z
Learning: In deeply nested React components within the Next.js app directory, use the SWR library to fetch data via API instead of loading data directly in the component.
Learnt from: aryanprince
PR: elie222/inbox-zero#210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning: `MoreDropdown` is a React component and `useUnsubscribeButton` is a custom React hook, and they should not be imported using `import type`.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: In this project, Prisma should be imported using 'import prisma from "@/utils/prisma";' in TypeScript files.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-06-23T12:26:07.018Z
Learning: In React projects, use React Hook Form together with Zod for form validation to ensure type safety and robust validation logic.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-06-23T12:25:52.998Z
Learning: Prefer functional React components with hooks over class components for better composability and modern React patterns.
🧬 Code Graph Analysis (2)
apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx (1)
apps/web/components/ui/dialog.tsx (2)
  • DialogHeader (118-118)
  • DialogTitle (120-120)
apps/web/components/assistant-chat/tools.tsx (3)
apps/web/hooks/useDialogState.ts (1)
  • useDialogState (8-32)
apps/web/utils/actions/rule.ts (1)
  • deleteRuleAction (365-423)
apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx (1)
  • RuleDialog (23-78)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
version.txt (1)

1-1: LGTM! Standard version bump.

The version increment from v1.7.14 to v1.7.15 appropriately reflects the UI and state management improvements described in this PR.

apps/web/components/assistant-chat/chat.tsx (1)

185-211: Good architectural improvement for SWR context coverage.

Expanding the SWRProvider scope to cover both the control bar and Messages component enhances data fetching context availability for nested components. This aligns well with the retrieved learnings about using SWR for data fetching in deeply nested React components.

apps/web/components/assistant-chat/tools.tsx (3)

3-3: Clean import optimization.

Good removal of unused parseAsString and useQueryStates imports as the component no longer uses URL query state management.


22-23: Proper imports for modal dialog approach.

The addition of RuleDialog and useDialogState imports supports the new modal-based rule viewing functionality.


424-472: Well-implemented modal dialog refactor.

The transition from URL query parameters to modal dialog state using useDialogState is well-executed. The implementation correctly:

  • Uses the useDialogState hook with typed data
  • Passes appropriate props to RuleDialog
  • Maintains the same user actions (view/delete)

Note that this changes the UX from URL-addressable rule viewing to modal-only, which improves the chat flow but removes direct linking capability.

Comment on lines +41 to +45
<DialogHeader>
<DialogTitle className={ruleId ? "sr-only" : ""}>
{ruleId ? "Edit Rule" : "Create Rule"}
</DialogTitle>
</DialogHeader>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider the accessibility implications of hiding the edit title.

Using sr-only class for the "Edit Rule" title creates an inconsistency between visual and screen reader experiences. Screen reader users will hear "Edit Rule" while sighted users see no title when editing. Consider either:

  1. Always showing the title visually for both create and edit modes
  2. Using a different approach to handle the title display

This ensures a consistent experience for all users.

-        <DialogHeader>
-          <DialogTitle className={ruleId ? "sr-only" : ""}>
-            {ruleId ? "Edit Rule" : "Create Rule"}
-          </DialogTitle>
-        </DialogHeader>
+        <DialogHeader>
+          <DialogTitle>
+            {ruleId ? "Edit Rule" : "Create Rule"}
+          </DialogTitle>
+        </DialogHeader>
📝 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
<DialogHeader>
<DialogTitle className={ruleId ? "sr-only" : ""}>
{ruleId ? "Edit Rule" : "Create Rule"}
</DialogTitle>
</DialogHeader>
<DialogHeader>
<DialogTitle>
{ruleId ? "Edit Rule" : "Create Rule"}
</DialogTitle>
</DialogHeader>
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/assistant/RuleDialog.tsx around lines 41
to 45, the "Edit Rule" title is visually hidden using the sr-only class, causing
inconsistency between visual and screen reader users. To fix this, remove the
conditional sr-only class so that the title is always visible regardless of
create or edit mode, ensuring a consistent experience for all users.

@elie222 elie222 merged commit 787ab0e into main Jun 27, 2025
10 checks passed
@elie222 elie222 deleted the feat/rule-model-chat branch June 27, 2025 14:35
This was referenced Nov 20, 2025
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.

1 participant