Skip to content

Revert "Increase context for choosing rule"#374

Merged
elie222 merged 1 commit intomainfrom
revert-373-increased-rule-context
Mar 20, 2025
Merged

Revert "Increase context for choosing rule"#374
elie222 merged 1 commit intomainfrom
revert-373-increased-rule-context

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Mar 20, 2025

Reverts #373

Summary by CodeRabbit

These updates streamline how email data is processed throughout the system. Email information is now handled as a single, structured object rather than a collection, which enhances clarity and consistency in reply handling and rule evaluation. Automated tests have been updated accordingly, and obsolete features for previous email aggregation and external dataset interactions have been removed, helping reduce overall complexity.

  • Refactor
    • Simplified email processing by switching from array-based to single-object handling.
  • Tests
    • Updated test cases to reflect the new message structure.
  • Chores
    • Removed deprecated email aggregation and external integration features.

@vercel
Copy link

vercel bot commented Mar 20, 2025

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

Name Status Preview Updated (UTC)
inbox-zero 🔄 Building (Inspect) Visit Preview Mar 20, 2025 3:59pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request refactors multiple parts of the codebase to switch from processing arrays of messages to handling single message/email objects. Parameter names and function signatures across test files, API endpoints, AI-related modules, and utility functions have been updated to accept a single message (or email) instance. Additionally, functions related to email formatting and thread handling have been modified or removed. The overall control flow remains intact while the input structure becomes simplified and more consistent.

Changes

File(s) Change Summary
apps/web/__tests__/ai-choose-rule.test.ts, apps/web/utils/ai/choose-rule/match-rules.test.ts Updated test cases to pass a single email/message object instead of an array.
apps/web/app/api/google/webhook/process-history-item.ts Modified message retrieval to use getMessage and parseMessage (renaming variables to gmailMessage), and updated the argument passed to runRulesOnMessage accordingly.
apps/web/utils/ai/choose-rule/ai-choose-rule.ts, apps/web/utils/actions/ai-rule.ts Refactored functions by updating the GetAiResponseOptions type and replacing array parameters (messages) with a single email or message object in function calls and prompt generation.
apps/web/utils/ai/choose-rule/match-rules.ts, apps/web/utils/ai/choose-rule/run-rules.ts Changed function signatures to process a single message instead of an array, simplifying the logic for matching and running rules.
apps/web/utils/ai/clean/ai-clean.ts, apps/web/utils/gmail/thread.ts, apps/web/utils/reply-tracker/*, apps/web/utils/stringify-email.ts Adjusted utility functions: removed or re-implemented email formatting functions, restored and slightly modified thread message handling, and updated reply processing to use only the latest or a single message.

Sequence Diagram(s)

sequenceDiagram
    participant Gmail as Gmail API
    participant API as Webhook/API Handler
    participant Parser as Message Parser
    participant Rules as Rule Engine
    participant AI as AI Service

    Gmail->>API: getMessage(messageId, "full")
    API->>Parser: parseMessage(gmailMessage)
    Parser-->>API: Parsed message
    API->>Rules: processHistoryItem(parsedMessage)
    Rules->>AI: getAiResponse({ email: parsedMessage })
    AI-->>Rules: AI response result
    Rules-->>API: Processed rule outcome
Loading

Possibly related PRs

Poem

I'm a happy rabbit, leaping through the code,
Single emails now lead the hopping mode,
No more cluttered arrays in my burrow so neat,
One message at a time makes my day complete,
Hopping through functions with joyful delight—
Cheers to clear code and a future so bright! 🐇✨

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/__tests__/ai-choose-rule.test.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in 'apps/web/.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /apps/web/.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
apps/web/app/api/google/webhook/process-history-item.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in 'apps/web/.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /apps/web/.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
apps/web/utils/ai/choose-rule/ai-choose-rule.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in 'apps/web/.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /apps/web/.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
  • 8 others

📜 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 6b91ebf and 687a8ff.

📒 Files selected for processing (12)
  • apps/web/__tests__/ai-choose-rule.test.ts (15 hunks)
  • apps/web/app/api/google/webhook/process-history-item.ts (4 hunks)
  • apps/web/utils/actions/ai-rule.ts (3 hunks)
  • apps/web/utils/ai/choose-rule/ai-choose-rule.ts (3 hunks)
  • apps/web/utils/ai/choose-rule/match-rules.test.ts (14 hunks)
  • apps/web/utils/ai/choose-rule/match-rules.ts (3 hunks)
  • apps/web/utils/ai/choose-rule/run-rules.ts (2 hunks)
  • apps/web/utils/ai/clean/ai-clean.ts (4 hunks)
  • apps/web/utils/gmail/thread.ts (1 hunks)
  • apps/web/utils/reply-tracker/check-previous-emails.ts (1 hunks)
  • apps/web/utils/reply-tracker/inbound.ts (2 hunks)
  • apps/web/utils/stringify-email.ts (0 hunks)
✨ 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.

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

@elie222 elie222 merged commit 88963a0 into main Mar 20, 2025
0 of 3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 7, 2025
@elie222 elie222 deleted the revert-373-increased-rule-context branch December 18, 2025 23:08
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