Skip to content

#fix: Ensure label list updates immediately after label creation + Added Black color as pre-selected color of labels.#1723

Closed
Anshumancanrock wants to merge 11 commits intoMail-0:stagingfrom
Anshumancanrock:staging
Closed

#fix: Ensure label list updates immediately after label creation + Added Black color as pre-selected color of labels.#1723
Anshumancanrock wants to merge 11 commits intoMail-0:stagingfrom
Anshumancanrock:staging

Conversation

@Anshumancanrock
Copy link

@Anshumancanrock Anshumancanrock commented Jul 13, 2025

What does this PR do?

Description

This PR addresses two improvements related to the label creation experience:

  1. Label creation delay fix:
    Previously, when a new label was created via the sidebar "+" button, it wouldn’t show up immediately in the labels list. Users had to refresh the page or create another label to see the first one. This has been resolved by ensuring the label creation (labels.create) completes before triggering a fresh fetch (labels.list). The result is a smoother and more intuitive experience.

  2. Default color selection:
    When opening the "Create Label" dialog, no color was selected by default, which could be confusing. The first color option (black) is now pre-selected automatically when the dialog opens, offering a more consistent and user-friendly interaction.


Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🎨 UI/UX improvement

Areas Affected

  • User Interface/Experience
  • API Endpoints

Testing Done

  • Manual testing performed

Manual Test Coverage:

  • Verified that newly created labels appear instantly in the sidebar list
  • Confirmed default color (black) is pre-selected in the create label dialog
  • Checked that color selection can still be changed by the user
  • Ensured existing label editing and creation flows are not broken

Security Considerations

  • No sensitive data is exposed
  • Authentication checks are in place
  • Input validation is implemented

Checklist


Additional Notes

Technical Details:

  • The label creation logic now awaits a successful creation response before triggering a refetch, improving the label list synchronization.
  • A 200ms delay was added to allow the backend to persist the label before fetching.
  • The default color logic has been updated in both the frontend dialog and server schema for consistency.
  • These changes affect only ~21 lines across 3 files, maintaining backward compatibility.

Files modified:

  • nav-main.tsx – Updated label creation logic to improve UI sync
  • label-dialog.tsx – Added logic for default color selection
  • label.ts – Updated default color value on the server side

Screenshots/Recordings:

Before fix:

Recording.2025-07-14.013556.mp4

After fix:

Recording.2025-07-14.003115.1.mp4

Summary by cubic

Newly created labels now appear instantly in the sidebar, and the "Create Label" dialog pre-selects black as the default color.

  • Bug Fixes

    • Fixed label list not updating immediately after creating a new label.
  • UI Improvements

    • Set black as the default selected color when opening the create label dialog.

Summary by CodeRabbit

  • New Features

    • Updated default label colors to a dark theme with improved contrast, using a dark background and white text for new labels.
  • User Experience

    • Success messages for label creation are now shown more consistently, with a brief delay before refreshing the label list.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 13, 2025

"""

Walkthrough

The changes update the default color scheme for label creation to a dark theme across both frontend and backend. Additionally, the label creation flow is modified so that after creating a new label, a success message is shown and the label list is refetched after a short delay, addressing label list update timing.

Changes

File(s) Change Summary
apps/mail/components/labels/label-dialog.tsx Centralized default label colors to dark theme values (#202020 background, #FFFFFF text).
apps/server/src/trpc/routes/label.ts Updated label creation input schema to require hex color strings with defaults set to dark theme.
apps/mail/components/ui/nav-main.tsx Changed label creation flow to use explicit async/await with success toast and delayed refetch.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NavMain (UI)
    participant Server (TRPC)
    participant Label List

    User->>NavMain (UI): Submit new label
    NavMain (UI)->>Server (TRPC): createLabel
    Server (TRPC)-->>NavMain (UI): Label created (with dark theme colors)
    NavMain (UI)->>NavMain (UI): Show success toast
    NavMain (UI)->>Label List: (after 200ms) Refetch labels
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Ensure latest label is fetched and displayed immediately after creation (#1687)
Call labels.create before labels.list, and refetch labels after creation (#1687)
Remove need for user to create another label to see the previous one (#1687)

Possibly related PRs

Suggested reviewers

  • MrgSub
  • ahmetskilinc

Poem

In the land of labels, dark and bright,
A bunny hopped and set things right.
With colors deep and text so white,
New labels now appear in sight!
Hop, hop, hooray—
The list updates without delay!
🐇✨
"""


📜 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 0225641 and 2b0981c.

📒 Files selected for processing (1)
  • apps/mail/components/ui/nav-main.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/mail/components/ui/nav-main.tsx
✨ 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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Enhanced label creation UX with improved synchronization and default color selection.

  • Fixed immediate label visibility in apps/mail/components/ui/nav-main.tsx by adding async/await and 200ms delay for proper list refresh
  • Set black (#202020) as default label background color with white text in apps/mail/components/labels/label-dialog.tsx
  • Updated server-side schema in apps/server/src/trpc/routes/label.ts to include default color values for consistent behavior

3 files reviewed, 4 comments
Edit PR Review Bot Settings | Greptile

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

🔭 Outside diff range comments (1)
apps/mail/components/labels/label-dialog.tsx (1)

66-66: Fix color inconsistency for editing labels without color.

The fallback color for editing labels still uses the old light theme colors, which is inconsistent with the new dark theme defaults used elsewhere in the component.

Apply this diff to maintain consistency:

-          color: editingLabel.color || { backgroundColor: '#E2E2E2', textColor: '#000000' },
+          color: editingLabel.color || { backgroundColor: '#202020', textColor: '#FFFFFF' },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 414a44d and b9dc8b8.

📒 Files selected for processing (3)
  • apps/mail/components/labels/label-dialog.tsx (3 hunks)
  • apps/mail/components/ui/nav-main.tsx (1 hunks)
  • apps/server/src/trpc/routes/label.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
apps/mail/components/labels/label-dialog.tsx (2)
Learnt from: snehendu098
PR: Mail-0/Zero#1323
File: apps/mail/lib/themes/theme-utils.ts:318-318
Timestamp: 2025-06-24T06:22:58.753Z
Learning: In the Mail-0/Zero theme system (apps/mail/lib/themes/theme-utils.ts), when color themes are being applied, all color values come in HSL format, so there's no need for additional format validation when converting colors with hslToHex().
Learnt from: danteissaias
PR: Mail-0/Zero#902
File: apps/mail/components/connection/add.tsx:77-77
Timestamp: 2025-05-07T16:55:46.513Z
Learning: For the "Upgrade" link in AddConnectionDialog, using a proper <button> element instead of a <span> with onClick is recognized as an accessibility improvement but was deferred as out of scope in PR #902 (CSS variables PR).
apps/mail/components/ui/nav-main.tsx (2)
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
Learnt from: retrogtx
PR: Mail-0/Zero#1468
File: apps/server/src/trpc/routes/mail.ts:331-331
Timestamp: 2025-06-28T03:56:09.376Z
Learning: In apps/server/src/trpc/routes/mail.ts, the user indicated they are not using ISO format for the scheduleAt parameter, despite the frontend code showing toISOString() usage in the ScheduleSendPicker component.
🧬 Code Graph Analysis (1)
apps/mail/components/ui/nav-main.tsx (3)
apps/server/src/lib/driver/google.ts (1)
  • createLabel (691-709)
apps/server/src/routes/chat.ts (2)
  • createLabel (141-146)
  • createLabel (700-711)
apps/server/src/lib/driver/microsoft.ts (1)
  • createLabel (864-889)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
apps/server/src/trpc/routes/label.ts (1)

44-47: LGTM! Server-side default colors align with dark theme.

The default color values are correctly implemented and consistent with dark theme patterns. This ensures that when no color is explicitly provided, labels will have a professional dark appearance.

apps/mail/components/labels/label-dialog.tsx (1)

53-54: LGTM! Default color values consistently updated to dark theme.

The default color values are properly updated to use the dark theme across form initialization and reset operations.

Also applies to: 71-71, 87-87

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 1 issue across 3 files. Review it in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@Anshumancanrock
Copy link
Author

@MrgSub Please review this PR sir and let me know if you want any changes. Thanks !

@Anshumancanrock
Copy link
Author

@cubic-dev-ai /review

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jul 14, 2025

@cubic-dev-ai /review

@Anshumancanrock I've started the AI code review. It'll take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 2 issues across 3 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 1 issue across 3 files. Review it in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic reviewed 3 files and found no issues. Review PR in cubic.dev.

try {
await createLabel(data);
toast.success('Label created successfully');
setTimeout(() => refetch(), 200);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we have a timeout here?

Copy link
Collaborator

@MrgSub MrgSub left a comment

Choose a reason for hiding this comment

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

changes

@Anshumancanrock Anshumancanrock requested a review from MrgSub July 14, 2025 17:00
@Anshumancanrock
Copy link
Author

@MrgSub Sir.. I initially changed this to try/catch with with setTimeout but you are right this is problematic. I have now reverted the changes back to toast.promise() with proper promise changing. Please let me know if you want any other changes . Appreciate your time sir !

@Anshumancanrock
Copy link
Author

@MrgSub Please review this PR sir and let me know if you want any changes. Thanks !

@Anshumancanrock
Copy link
Author

@MrgSub

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

This PR has merge conflicts and has been open for more than 3 days. It will be automatically closed. Please resolve the conflicts and reopen the PR if you'd like to continue working on it.

@github-actions github-actions bot closed this Aug 7, 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.

Latest label is not getting fetched after creating new label.

2 participants