Skip to content

Auto Advance Email on Archive #369

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
merged 58 commits into from
Mar 14, 2025
Merged

Auto Advance Email on Archive #369

merged 58 commits into from
Mar 14, 2025

Conversation

gshiva53
Copy link
Contributor

@gshiva53 gshiva53 commented Mar 5, 2025

Hi,

I am a first time contributor and I worked on the issue #345 Auto advance mail. The functionality works for archive for now but can work with other actions if needed.

Related to #345.

Demo Video: https://www.loom.com/share/a2b58b50466b49169d3d6fa83e6bbbd2?sid=2e0e800b-71cb-42b0-8601-63134f6cbd3d

Summary by CodeRabbit

  • New Features

    • Archiving an email now automatically shifts focus to the next or previous email thread for smoother continuity.
  • Bug Fixes

    • Adjusted the behavior after archiving so that the email panel remains open, enhancing user control throughout the process.
  • Changes

    • Removed the rejectPlan function from the EmailListItem component's props, altering its interaction with parent components.

Copy link

vercel bot commented Mar 5, 2025

Someone is attempting to deploy a commit to the Inbox Zero Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ gshiva53
✅ elie222
❌ Shiva Gupta


Shiva Gupta seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

Walkthrough

This pull request introduces a new function advanceToAdjacentThread in the EmailList component to manage email thread navigation by updating the openThreadId based on the current thread's index. The EmailPanel component is updated to include a new prop, advanceToAdjacentThread, which modifies the control flow during the archiving process by allowing the panel to invoke this function instead of closing immediately. Additionally, the rejectPlan prop is removed from the EmailListItem component.

Changes

File(s) Change Summary
apps/web/components/email-list/EmailList.tsx Added new function advanceToAdjacentThread to manage the openThreadId based on the current thread; updated EmailPanel to use advanceToAdjacentThread.
apps/web/components/email-list/EmailPanel.tsx Introduced advanceToAdjacentThread prop to handle post-archive actions; modified control flow to call advanceToAdjacentThread() instead of immediate close().
apps/web/components/email-list/EmailListItem.tsx Removed rejectPlan prop from the EmailListItem component.

Poem

In the code forest, I hop with delight,
Finding the next thread with nimble insight.
My memoized path leads me through the maze,
With no quick panel close to end my days.
Archive adventures sung in every byte—
A rabbit's code journey, so merry and 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/components/email-list/EmailList.tsx

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[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)

📜 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 25887f6 and 163610e.

📒 Files selected for processing (1)
  • apps/web/components/email-list/EmailList.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/components/email-list/EmailList.tsx

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

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 ad5a91b and c968e1d.

📒 Files selected for processing (2)
  • apps/web/components/email-list/EmailList.tsx (3 hunks)
  • apps/web/components/email-list/EmailPanel.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/components/email-list/EmailPanel.tsx
🔇 Additional comments (2)
apps/web/components/email-list/EmailList.tsx (2)

229-233: Auto-advance feature is correctly implemented.

The implementation for automatically advancing to the next email after archiving works as intended. This matches the PR objective of adding this functionality for the archive action.

🧰 Tools
🪛 Biome (1.9.4)

[error] 229-229: This hook does not specify all of its dependencies: setOpenThreadId

This dependency is not specified in the hook dependency list.

(lint/correctness/useExhaustiveDependencies)


255-255: The dependency array is properly updated.

The prevOrNextRowId has been correctly added to the dependency array, ensuring the callback uses the latest calculated value when an email is archived.

@gshiva53 gshiva53 mentioned this pull request Mar 5, 2025
Copy link
Owner

@elie222 elie222 left a comment

Choose a reason for hiding this comment

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

thanks! left 2 comments!

@elie222
Copy link
Owner

elie222 commented Mar 6, 2025

Great that you added a video too! Super helpful. Also see the cla task that's pending

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)
apps/web/components/email-list/EmailPanel.tsx (1)

14-14: Naming convention inconsistency: prop should use camelCase.

The new prop OpenEmailOnArchive uses PascalCase naming, which is inconsistent with React/TypeScript conventions and the rest of the codebase where props and function names use camelCase (like onArchive, close, etc.).

Consider renaming to openEmailOnArchive for consistency:

- OpenEmailOnArchive,
+ openEmailOnArchive,
- OpenEmailOnArchive: () => void;
+ openEmailOnArchive: () => void;

Also applies to: 25-25

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8f64321 and a36295c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • apps/web/components/email-list/EmailList.tsx (2 hunks)
  • apps/web/components/email-list/EmailListItem.tsx (0 hunks)
  • apps/web/components/email-list/EmailPanel.tsx (3 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/components/email-list/EmailListItem.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/components/email-list/EmailList.tsx
🔇 Additional comments (1)
apps/web/components/email-list/EmailPanel.tsx (1)

59-62: Implementation looks good.

The implementation correctly calls the new function after archiving. This achieves the PR objective of adding functionality to automatically advance to the next email after archiving the current one.

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)
apps/web/components/email-list/EmailList.tsx (1)

273-288: Good implementation of auto-advancing to the next email on archive.

The new setPrevOrNextRow function properly handles edge cases:

  • When the thread is not found in the list
  • When there are no threads available
  • When there's only one thread available

In all these cases, it correctly calls closePanel() to close the email panel.

However, I suggest improving the function name to better reflect its purpose:

-function setPrevOrNextRow() {
+function advanceToAdjacentThread() {

The new name more clearly describes that this function advances to the next thread (or previous if at the end).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a36295c and 73779b6.

📒 Files selected for processing (1)
  • apps/web/components/email-list/EmailList.tsx (2 hunks)
🔇 Additional comments (1)
apps/web/components/email-list/EmailList.tsx (1)

511-511: Successfully implemented auto-advance on archive.

The OpenEmailOnArchive prop now uses the setPrevOrNextRow function to navigate to the next email after archiving, which fulfills the PR objective.

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 e071574 and 25887f6.

📒 Files selected for processing (2)
  • apps/web/components/email-list/EmailList.tsx (2 hunks)
  • apps/web/components/email-list/EmailPanel.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/components/email-list/EmailPanel.tsx
🔇 Additional comments (1)
apps/web/components/email-list/EmailList.tsx (1)

511-511: Proper prop addition for the auto-advance feature.

The advanceToAdjacentThread function is correctly passed to the EmailPanel component, enabling the "advance to next email after archive" feature.

@@ -57,7 +58,7 @@ export function EmailPanel({
onPlanAiAction={() => onPlanAiAction(row)}
onArchive={() => {
onArchive(row);
close();
advanceToAdjacentThread();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the logic outside of onArchive() and where close() was before as per comments.

@@ -270,6 +270,23 @@ export function EmailList({
}, 100);
}

function advanceToAdjacentThread() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the logic into a function which will only be called onArchive() instead of every render (possibly) as per comments.

(thread) => thread.id === openThreadId,
);

if (openedRowIndex === -1 || threads.length === 0 || threads.length === 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Close the email panel when there is only one thread because that thread would have been archived.

@gshiva53 gshiva53 requested a review from elie222 March 7, 2025 03:35
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@gshiva53
Copy link
Contributor Author

gshiva53 commented Mar 7, 2025

Signed the CLA.

@elie222 elie222 merged commit 4b228b6 into elie222:main Mar 14, 2025
1 of 3 checks passed
@elie222
Copy link
Owner

elie222 commented Mar 14, 2025

Thanks!

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