Skip to content

Open rule inline in tab view#455

Merged
elie222 merged 1 commit intomainfrom
feat/rule-tab
May 26, 2025
Merged

Open rule inline in tab view#455
elie222 merged 1 commit intomainfrom
feat/rule-tab

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented May 26, 2025

Summary by CodeRabbit

  • New Features

    • Improved navigation across assistant-related pages with consistent URLs using query parameters for tabs and rule details.
  • Refactor

    • Standardized all rule detail links to use query parameter-based URLs instead of path-based URLs for easier navigation and better context preservation.
    • Updated form field labeling for clarity in rule creation and editing.
  • Chores

    • Incremented application version to v1.2.5.

@vercel
Copy link

vercel bot commented May 26, 2025

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

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview May 26, 2025 0:20am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 26, 2025

Walkthrough

This update standardizes URL generation for assistant-related pages by shifting from path-based to query-parameter-based URLs and introduces a new useAssistantNavigation hook. Multiple components are refactored to use this hook or the new URL structure, ensuring consistent navigation logic across rule, group, and history pages.

Changes

File(s) Change Summary
apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx,
apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx
Refactored to use useAssistantNavigation hook with createAssistantUrl for building assistant URLs.
apps/web/app/(app)/[emailAccountId]/assistant/ProcessResultDisplay.tsx,
apps/web/app/(app)/[emailAccountId]/assistant/ReportMistake.tsx,
apps/web/app/(app)/[emailAccountId]/assistant/group/Groups.tsx,
apps/web/app/(app)/[emailAccountId]/assistant/rule/[ruleId]/examples/page.tsx,
apps/web/components/GroupedTable.tsx
Updated links from /assistant/rule/{id} to /assistant?tab=rule&ruleId={id} (path → query params).
apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx Changed redirect and input label to use new URL/query structure and improved label consistency.
apps/web/hooks/useAssistantNavigation.ts Added new hook for centralized assistant URL creation with query parameter support.
version.txt Bumped version from v1.2.4 to v1.2.5.

Sequence Diagram(s)

sequenceDiagram
    participant Component
    participant useAssistantNavigation
    participant prefixPath
    participant NextRouter

    Component->>useAssistantNavigation: useAssistantNavigation(emailAccountId)
    useAssistantNavigation->>prefixPath: prefixPath(emailAccountId, "/assistant")
    Component->>useAssistantNavigation: createAssistantUrl({tab, ruleId, ...})
    useAssistantNavigation->>Component: returns constructed URL with query params
    Component->>NextRouter: router.replace(URL) or <Link href={URL}>
Loading

Possibly related PRs

  • elie222/inbox-zero#292: Introduced the useAssistantNavigation hook now used for centralized URL creation in this PR.
  • elie222/inbox-zero#295: Modified rule creation and processing logic, related to how rule URLs are now constructed and navigated.
  • elie222/inbox-zero#275: Enhanced rule creation with new parameters, related to the URL refactoring for rule-related pages.

Poem

🐰
URLs once tangled, now neat and spry,
With hooks and queries, they swiftly fly.
Assistant pages, rules in tow,
Navigation’s simpler—off we go!
Version hopped up, v1.2.5,
In the warren of code, we thrive!

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/ProcessResultDisplay.tsx

Oops! Something went wrong! :(

ESLint: 9.24.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/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx

Oops! Something went wrong! :(

ESLint: 9.24.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/app/(app)/[emailAccountId]/assistant/ReportMistake.tsx

Oops! Something went wrong! :(

ESLint: 9.24.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.

  • 6 others
✨ 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

🧹 Nitpick comments (6)
apps/web/hooks/useAssistantNavigation.ts (1)

24-28: Consider improving type safety for parameters.

The current parameter type allows any string key with [key: string]: string | undefined, which could lead to typos or inconsistencies.

Consider creating a more specific type interface:

-    (params: {
-      tab?: string;
-      ruleId?: string;
-      [key: string]: string | undefined;
-    }) => {
+    (params: {
+      tab?: string;
+      ruleId?: string;
+      chatId?: string;
+      mode?: string;
+      page?: string;
+      search?: string;
+      custom?: string;
+    }) => {
apps/web/components/GroupedTable.tsx (1)

437-437: Consider using the new useAssistantNavigation hook for consistency.

While the URL change is correct, this component manually constructs the assistant URL instead of using the new useAssistantNavigation hook. This could lead to inconsistencies if URL patterns change in the future.

Consider refactoring to use the hook:

+import { useAssistantNavigation } from "@/hooks/useAssistantNavigation";

// In the component:
+const { createAssistantUrl } = useAssistantNavigation(emailAccountId);

// Then replace the manual URL construction:
-                  href={prefixPath(
-                    emailAccountId,
-                    `/assistant?tab=rule&ruleId=${rule.id}`,
-                  )}
+                  href={createAssistantUrl({
+                    tab: "rule",
+                    ruleId: rule.id.toString(),
+                  })}
apps/web/app/(app)/[emailAccountId]/assistant/rule/[ruleId]/examples/page.tsx (1)

47-47: Consider using the new useAssistantNavigation hook for consistency.

The URL change correctly adopts the new query parameter pattern, but like other components, this could benefit from using the useAssistantNavigation hook for consistency and future maintainability.

Consider refactoring to use the hook:

+import { useAssistantNavigation } from "@/hooks/useAssistantNavigation";

// In the component:
+const { createAssistantUrl } = useAssistantNavigation(emailAccountId);

// Then replace the manual URL construction:
-                  `/assistant?tab=rule&ruleId=${params.ruleId}`,
+                  createAssistantUrl({
+                    tab: "rule",
+                    ruleId: params.ruleId,
+                  }).replace(prefixPath(emailAccountId, ""), ""),

Or better yet, update the hook to handle prefixPath internally, then:

-                href={prefixPath(
-                  emailAccountId,
-                  `/assistant?tab=rule&ruleId=${params.ruleId}`,
-                )}
+                href={createAssistantUrl({
+                  tab: "rule",
+                  ruleId: params.ruleId,
+                })}
apps/web/app/(app)/[emailAccountId]/assistant/ProcessResultDisplay.tsx (1)

89-93: Consider using the useAssistantNavigation hook for consistency.

The URL structure change is correct and aligns with the PR objectives. However, according to the AI summary, a new useAssistantNavigation hook was introduced to centralize URL construction. Consider using this hook instead of manually constructing the URL for better maintainability.

apps/web/app/(app)/[emailAccountId]/assistant/group/Groups.tsx (1)

99-106: URL structure update looks good.

The change correctly updates the URL from path-based to query-parameter format, maintaining consistency with other components. As with other files in this PR, consider using the useAssistantNavigation hook if available for centralized URL management.

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

1093-1114: Consistent URL update in EditRuleButton component.

The URL structure change is correct and consistent with the other files. Since EditRuleButton is used multiple times throughout this file, using the useAssistantNavigation hook here would be particularly beneficial for maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 999ace2 and d5656e9.

📒 Files selected for processing (10)
  • apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx (3 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/ProcessResultDisplay.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/ReportMistake.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (2 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx (4 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/group/Groups.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/rule/[ruleId]/examples/page.tsx (1 hunks)
  • apps/web/components/GroupedTable.tsx (1 hunks)
  • apps/web/hooks/useAssistantNavigation.ts (1 hunks)
  • version.txt (1 hunks)
🔇 Additional comments (7)
version.txt (1)

1-1: LGTM: Standard version increment.

The version bump from v1.2.4 to v1.2.5 appropriately reflects the URL structure changes and new navigation hook implementation.

apps/web/hooks/useAssistantNavigation.ts (3)

6-14: LGTM: Well-structured parameter serializer.

The serializer configuration correctly handles all assistant-related parameters using parseAsString. This provides a consistent foundation for URL parameter management.


16-22: LGTM: Proper hook setup with clear intent.

The hook correctly uses Next.js navigation hooks and includes a helpful comment explaining the pathname matching logic. The endsWith("/assistant") check ensures it only matches the main assistant page, not sub-pages.


23-44: LGTM: Smart URL generation logic with proper optimization.

The conditional logic intelligently preserves existing search parameters when already on the assistant page, which provides a good user experience. The useCallback optimization with correct dependencies prevents unnecessary re-renders.

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

21-21: LGTM! URL standardization properly implemented.

The introduction of useAssistantNavigation hook and the migration to query parameter-based URLs is correctly implemented. This change improves consistency across the assistant navigation.

Also applies to: 89-90, 116-119

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

289-290: Good improvements to form field naming.

The normalization of the name attribute to lowercase and the more descriptive label improve consistency and clarity.

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

61-61: Excellent implementation of the new URL pattern.

The useAssistantNavigation hook is properly integrated and consistently used for both rule editing and history URLs. The special handling for cold email blocker rules is correctly preserved.

Also applies to: 70-70, 201-204, 296-299

Comment on lines 210 to 217
router.replace(
prefixPath(emailAccountId, `/assistant/rule/${res.data.rule.id}`),
prefixPath(
emailAccountId,
`/assistant?tab=rule&ruleId=${res.data.rule.id}`,
),
);
router.push(prefixPath(emailAccountId, "/assistant?tab=rules"));
}
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 using useAssistantNavigation for consistency.

While the URL pattern correctly follows the new query parameter format, this component still uses prefixPath directly instead of the useAssistantNavigation hook that other components are using. Consider refactoring to use createAssistantUrl for consistency:

+  const { createAssistantUrl } = useAssistantNavigation(emailAccountId);
   // ...
   router.replace(
-    prefixPath(
-      emailAccountId,
-      `/assistant?tab=rule&ruleId=${res.data.rule.id}`,
-    ),
+    createAssistantUrl({
+      tab: "rule",
+      ruleId: res.data.rule.id,
+    }),
   );
📝 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
router.replace(
prefixPath(emailAccountId, `/assistant/rule/${res.data.rule.id}`),
prefixPath(
emailAccountId,
`/assistant?tab=rule&ruleId=${res.data.rule.id}`,
),
);
router.push(prefixPath(emailAccountId, "/assistant?tab=rules"));
}
// add the navigation helper
const { createAssistantUrl } = useAssistantNavigation(emailAccountId);
// ...
router.replace(
createAssistantUrl({
tab: "rule",
ruleId: res.data.rule.id,
}),
);
router.push(prefixPath(emailAccountId, "/assistant?tab=rules"));
}
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx around lines 210
to 217, the code directly uses prefixPath to generate URLs for router.replace
and router.push, which is inconsistent with other components that use the
useAssistantNavigation hook. Refactor these lines to use the createAssistantUrl
function from useAssistantNavigation for URL generation to ensure consistency
across the codebase.

@elie222 elie222 merged commit dd726db into main May 26, 2025
7 checks passed
@elie222 elie222 deleted the feat/rule-tab branch May 26, 2025 12:52
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

Comments