Skip to content

225 버그 몇 가지 수정하기 #227

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

ferrariRoma
Copy link
Contributor

@ferrariRoma ferrariRoma commented May 24, 2025

가랏, 코드래빗~ 🐰

Summary by CodeRabbit

  • New Features

    • Added a close button to the "Remaining TODO" section, allowing users to close the section directly from the header.
  • Improvements

    • Enhanced responsiveness by optimistically updating the extreme mode toggle for faster feedback.
    • Improved login check timing for a smoother user experience.
    • Refined internal logic for category input handling in todo components for more concise error management.
    • Updated layout and padding in the todo list for improved visual consistency.
  • Bug Fixes

    • Improved reliability of extreme mode toggle tests by ensuring proper state initialization before assertions.

@ferrariRoma ferrariRoma requested a review from imhjnoh May 24, 2025 10:18
@ferrariRoma ferrariRoma self-assigned this May 24, 2025
@ferrariRoma ferrariRoma added the BugFix bug fix label May 24, 2025
@ferrariRoma ferrariRoma linked an issue May 24, 2025 that may be closed by this pull request
4 tasks
Copy link

coderabbitai bot commented May 24, 2025

Walkthrough

This update introduces several refactorings and enhancements across the codebase. Key changes include optimistically updating the extremeMode flag in settings, refactoring card state management in the main todo component, and improving test reliability. UI adjustments add a close button to the todo list and streamline category error handling. Some hooks and interceptors now use synchronous or awaited behaviors for improved timing and consistency.

Changes

Files / Areas Change Summary
src/hooks/useExtremeMode.tsx, src/test/hooks/useExtremeMode.test.tsx Added optimistic update for extremeMode; improved test reliability by awaiting state readiness.
src/components/MainTodo/index.tsx, src/components/TodoList/index.tsx Refactored card state management; introduced changeCard and handleClose; added close button to todo list.
src/components/AddTodo.tsx, src/components/TodoCard/index.tsx Simplified conditional logic for clearing category errors.
src/hooks/LoginContext.tsx Switched from useEffect to useLayoutEffect for login checks.
src/shared/apis.ts Made axios interceptors asynchronous and awaited query cancellations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TodoList
    participant MainTodo

    User->>TodoList: Clicks Close Button
    TodoList->>MainTodo: Calls handleClose()
    MainTodo->>MainTodo: Updates card state via changeCard()
Loading
sequenceDiagram
    participant User
    participant useExtremeMode
    participant QueryClient
    participant settingsApi

    User->>useExtremeMode: Toggle Extreme Mode
    useExtremeMode->>QueryClient: Optimistically update extremeMode in cache
    useExtremeMode->>settingsApi: Send mutation
    alt Mutation fails
        useExtremeMode->>QueryClient: Rollback to previous cache
    else Mutation succeeds
        useExtremeMode->>QueryClient: Invalidate settings query
    end
Loading

Poem

🐇
Cards now flip with nimble grace,
Close buttons join the todo race.
Extreme mode toggles, quick and keen,
Optimistic updates keep things clean.
Errors cleared with logic neat,
Async hooks make flows complete—
This bunny’s code is hard to beat!

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.

npm warn config production Use --omit=dev instead.
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-24T10_19_39_384Z-debug-0.log

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

✨ 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

@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

🔭 Outside diff range comments (1)
src/components/MainTodo/index.tsx (1)

78-89: ⚠️ Potential issue

Update dependency array for handleClickSideButton.

The handleClickSideButton callback references changeCard on line 85 but doesn't include it in the dependency array. This could lead to stale closure issues.

  const handleClickSideButton = useCallback(
    (type: ModalType) => {
      if (!isLogin) {
        if (window.confirm('로그인을 하시겠습니까?')) {
          return usersApi.login();
        }
      } else {
        changeCard(currentCard, type);
      }
    },
-    [isLogin],
+    [isLogin, currentCard, changeCard],
  );
🧹 Nitpick comments (1)
src/hooks/useExtremeMode.tsx (1)

84-91: Consider adding type safety for the context parameter.

The error handler correctly uses the context for rollback, but the context parameter lacks type safety which could lead to runtime errors.

Apply this diff to improve type safety:

-      onError(error: AxiosError, _, context) {
+      onError(error: AxiosError, _, context: any) {

Or better yet, define a proper type for the context:

+interface MutationContext {
+  data: {
+    extremeMode: boolean;
+    [key: string]: any;
+  };
+  [key: string]: any;
+}

-      onError(error: AxiosError, _, context) {
+      onError(error: AxiosError, _, context: MutationContext) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8aca66b and 4e78f23.

📒 Files selected for processing (8)
  • src/__test__/hooks/useExtremeMode.test.tsx (1 hunks)
  • src/components/AddTodo.tsx (1 hunks)
  • src/components/MainTodo/index.tsx (2 hunks)
  • src/components/TodoCard/index.tsx (1 hunks)
  • src/components/TodoList/index.tsx (5 hunks)
  • src/hooks/LoginContext.tsx (2 hunks)
  • src/hooks/useExtremeMode.tsx (1 hunks)
  • src/shared/apis.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/shared/apis.ts (1)
src/App.tsx (1)
  • queryClient (19-21)
src/__test__/hooks/useExtremeMode.test.tsx (1)
src/shared/apis.ts (1)
  • settingsApi (193-201)
src/hooks/useExtremeMode.tsx (1)
src/App.tsx (1)
  • queryClient (19-21)
🔇 Additional comments (14)
src/hooks/useExtremeMode.tsx (1)

63-76: Excellent optimistic update implementation!

The optimistic update pattern is correctly implemented following React Query best practices. The logic properly cancels ongoing queries, backs up previous data, and updates the cache optimistically.

src/hooks/LoginContext.tsx (2)

1-7: Good timing improvement for login state initialization.

Changing from useEffect to useLayoutEffect ensures the login state is determined before the browser paints, preventing potential layout shifts during initial render.


46-48: LGTM - Synchronous login check prevents render flicker.

Since checkLogin only reads from localStorage (which is synchronous), using useLayoutEffect is appropriate and won't cause performance issues while ensuring login state is available before the first paint.

src/components/AddTodo.tsx (1)

118-120: Nice code simplification with short-circuit evaluation.

The refactor from an explicit if block to a short-circuit logical AND expression is more concise while maintaining the same functionality. The setCategoryError(undefined) will only be called when categoryError !== undefined is true.

src/shared/apis.ts (3)

1-1: Good cleanup removing unused import.

Removing the unused Cancel import keeps the codebase clean.


33-41: Excellent async query cancellation in request interceptor.

Making the request interceptor async and awaiting queryClient.cancelQueries() ensures that query cancellations complete before proceeding. This prevents race conditions and aligns with the optimistic update patterns implemented elsewhere in the codebase.


62-75: Proper async handling in response interceptor error handling.

The async error handler with awaited query cancellation ensures proper cleanup when handling 401 errors. This consistent pattern across interceptors improves the reliability of query state management.

src/__test__/hooks/useExtremeMode.test.tsx (1)

152-162: Excellent test reliability improvement!

The refactoring separates concerns by explicitly waiting for the pomodoro state initialization before firing the event, then waiting for the API call. This makes the test more deterministic and less prone to race conditions.

src/components/TodoCard/index.tsx (1)

322-324: Clean conditional logic simplification!

The refactored code uses short-circuit evaluation to handle both empty input validation and error state clearing in a single, more readable expression. This maintains the same functionality while reducing complexity.

src/components/MainTodo/index.tsx (1)

91-102: Excellent refactoring for better separation of concerns!

The extraction of changeCard logic into a reusable memoized function improves code organization and maintainability. The proper dependency arrays ensure optimal re-rendering behavior.

src/components/TodoList/index.tsx (4)

5-5: Good addition of IconAtom import and handleClose prop.

The import and interface update properly support the new close button functionality.

Also applies to: 72-72


158-162: Excellent UI enhancement with consistent header layout.

The addition of the close button with proper accessibility attributes (ariaLabel, tabIndex) and the consistent header structure for both TODO sections improves the user experience. The flex layout for .header__todo provides appropriate space-between alignment.

Also applies to: 189-201


156-156: Verify padding reduction impact on layout.

The padding was reduced from "2rem 1.5rem" to "1rem 1.5rem". Ensure this change doesn't negatively impact the visual spacing or component layout across different screen sizes.


314-318: Clean CSS implementation for header layout.

The .header__todo styles provide proper flex layout for the header sections with space-between alignment and fixed height.

Copy link
Member

@imhjnoh imhjnoh left a comment

Choose a reason for hiding this comment

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

의견 없습니당 고생하셨습니다~

const accessToken = localStorage.getItem(EXTREME_TOKEN_STORAGE);
const email = localStorage.getItem(EXTREME_EMAIL_STORAGE);
if (
config.url !== '/api/users/callback/google/start' &&
!email &&
!accessToken
) {
queryClient.cancelQueries();
await queryClient.cancelQueries();
Copy link
Member

Choose a reason for hiding this comment

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

await 가 없을 때 뭔가 에러가 있었나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugFix bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

버그 몇 가지 수정하기
2 participants