Skip to content

Conversation

@shige
Copy link
Member

@shige shige commented Dec 26, 2025

User description

Summary

Close the task overlay when the route changes to prevent UI overlap


PR Type

Bug fix


Description

  • Close task overlay when route changes to prevent UI overlap

  • Add pathname tracking with useEffect hook

  • Retrieve hideOverlay method from task overlay store

  • Compare previous and current pathname to trigger overlay closure


Diagram Walkthrough

flowchart LR
  A["Route Change Detected"] -- "pathname updated" --> B["useEffect triggered"]
  B -- "compare previous pathname" --> C["Pathname changed?"]
  C -- "yes" --> D["Call hideOverlay"]
  D --> E["Task Overlay Closed"]
  C -- "no" --> F["No action"]
Loading

File Walkthrough

Relevant files
Bug fix
task-overlay.tsx
Add pathname tracking to close overlay on navigation         

apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx

  • Import usePathname hook from next/navigation for route tracking
  • Import useEffect and useRef hooks for pathname comparison logic
  • Add hideOverlay method to store selector
  • Implement useEffect hook that detects pathname changes and closes
    overlay
  • Store previous pathname in ref to compare against current pathname
+23/-7   

Summary by CodeRabbit

✏️ Tip: You can customize this high-level summary in your review settings.

@shige shige self-assigned this Dec 26, 2025
Copilot AI review requested due to automatic review settings December 26, 2025 14:27
@changeset-bot
Copy link

changeset-bot bot commented Dec 26, 2025

⚠️ No Changeset found

Latest commit: 70e2a2b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "giselles-ai" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
giselle Ready Ready Preview, Comment Dec 26, 2025 2:31pm
ui Ready Ready Preview, Comment Dec 26, 2025 2:31pm

@giselles-ai
Copy link

giselles-ai bot commented Dec 26, 2025

Finished running flow.

Step 1
🟢
On Pull Request OpenedStatus: Success Updated: Dec 26, 2025 2:28pm
Step 2
🟢
Manual QAStatus: Success Updated: Dec 26, 2025 2:30pm
🟢
Prompt for AI AgentsStatus: Success Updated: Dec 26, 2025 2:30pm
Step 3
🟢
Create a Comment for PRStatus: Success Updated: Dec 26, 2025 2:32pm
Step 4
🟢
Create Pull Request CommentStatus: Success Updated: Dec 26, 2025 2:32pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

The TaskOverlay component now tracks route changes using Next.js pathname hook and automatically hides the overlay when navigation occurs. It reads hideOverlay state from the task overlay store and establishes a pathname change detection mechanism via a ref-based previous pathname comparison.

Changes

Cohort / File(s) Summary
Task Overlay Navigation Sync
apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
Added usePathname hook integration with previousPathnameRef to detect route changes. Introduced useEffect that triggers hideOverlay() when pathname changes. TaskOverlay now reads hideOverlay from task overlay store and includes it in selected state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ Through winding paths the overlay hops,
When routes change, the curtain drops,
A synchronized dance, so clean and tight,
Navigation whispers, "Hide from sight!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main fix: closing the task overlay when the route changes to prevent lingering UI issues.
Description check ✅ Passed The description includes all required template sections: Summary, PR Type, comprehensive Description with implementation details, a diagram walkthrough, and file walkthrough documentation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/task-overlay

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3031a8d and 70e2a2b.

📒 Files selected for processing (1)
  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Favor clear, descriptive names and type annotations over clever tricks
If you need a multi-paragraph comment, refactor until intent is obvious

**/*.{ts,tsx,js,jsx}: Use async/await and proper error handling
Variables and functions should use camelCase naming
Booleans and functions should use is, has, can, should prefixes
Function names should clearly indicate purpose

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development-guide.mdc)

**/*.{ts,tsx}: MUST run pnpm biome check --write [filename] after EVERY code modification
All code changes must be formatted using Biome before being committed
Use Biome for formatting with tab indentation and double quotes
Follow organized imports pattern (enabled in biome.json)
Use TypeScript for type safety; avoid any types
Use Next.js patterns for web applications
Use async/await for asynchronous code rather than promises
Error handling: use try/catch blocks and propagate errors appropriately
Use kebab-case for all filenames
Use PascalCase for React components and classes
Use camelCase for variables, functions, and methods
Use prefixes like is, has, can, should for boolean variables (e.g., isEnabled, hasPermission)
Use prefixes like is, has, can, should for boolean functions (e.g., isTriggerRequiringCallsign(), hasActiveSubscription()) instead of imperative verbs
Use verbs or verb phrases for function naming that clearly indicate purpose (e.g., calculateTotalPrice(), not process())

Use PascalCase for React component and class names

Use TypeScript and avoid any

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/development-guide.mdc)

Use functional components with React hooks

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.{js,ts,tsx,jsx,py,java,cs,cpp,c,go,rb,php,swift,kt,scala,rs,dart}

📄 CodeRabbit inference engine (.cursor/rules/language-support.mdc)

Write all code comments in English

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*

📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)

Use kebab-case for file names (e.g., user-profile.ts, api-client.tsx)

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)

**/*.{js,ts,jsx,tsx}: Use camelCase for variable names, functions, and methods
Use verbs or verb phrases for function names to clearly indicate what the function does (e.g., calculateTotalPrice(), validateUserInput())
Use nouns or noun phrases for variable names to describe what the variable represents
Use boolean prefixes (is, has, can, should) for boolean variables and functions returning boolean values (e.g., isEnabled, hasPermission, isTriggerRequiringCallsign())

**/*.{js,ts,jsx,tsx}: Run pnpm biome check --write [filename] after every code change
All code must be formatted with Biome before commit

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.{ts,tsx,js,jsx,css}

📄 CodeRabbit inference engine (AGENTS.md)

Files should use kebab-case naming

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

Components should use PascalCase naming

Files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: .cursor/rules/edit-workspace-tour.mdc:0-0
Timestamp: 2025-06-23T12:31:58.286Z
Learning: The tour uses React portals to render above other UI elements, ensuring overlays and highlights are not obstructed by the main application UI.
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T03:06:27.023Z
Learning: Applies to **/{components,pages}/**/*.{tsx,ts} : Components should use React hooks and Next.js patterns
📚 Learning: 2025-11-25T03:05:31.051Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: .cursor/rules/edit-workspace-tour.mdc:0-0
Timestamp: 2025-11-25T03:05:31.051Z
Learning: Applies to internal-packages/workflow-designer-ui/src/editor/workspace-tour/workspace-tour.tsx : Update the `TourGlobalStyles` component in `workspace-tour.tsx` for animation changes

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-12-03T05:18:36.138Z
Learnt from: shige
Repo: giselles-ai/giselle PR: 2344
File: apps/studio.giselles.ai/app/stage/ui/navigation-rail/navigation-rail-expanded.tsx:14-20
Timestamp: 2025-12-03T05:18:36.138Z
Learning: In apps/studio.giselles.ai/app/stage/ui/navigation-rail/navigation-rail-expanded.tsx, "nav-action-history" is intentionally included in stageOnlyItemIds to hide it when the stage flag is disabled because the link destination is not yet implemented, even though it appears in the "Studio - Build Apps" section of navigation-items.ts.

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-11-25T03:07:07.498Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/AGENTS.md:0-0
Timestamp: 2025-11-25T03:07:07.498Z
Learning: Applies to internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/**/*.tsx : Wrap all state updates in `startTransition` for consistent UI behavior during configuration and reconfiguration flows.

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-11-25T03:07:19.740Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: internal-packages/workflow-designer-ui/src/new-editor/AGENTS.md:0-0
Timestamp: 2025-11-25T03:07:19.740Z
Learning: Applies to internal-packages/workflow-designer-ui/src/new-editor/**/*.{ts,tsx} : Replace context-wide reads from `src/editor/v2` with fine-grained selectors against the Zustand store

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-11-25T03:07:19.740Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: internal-packages/workflow-designer-ui/src/new-editor/AGENTS.md:0-0
Timestamp: 2025-11-25T03:07:19.740Z
Learning: Applies to internal-packages/workflow-designer-ui/src/new-editor/**/*.{ts,tsx} : Lift actions into the store (e.g., `updateNode`) and call them from components needing mutations instead of passing mutation callbacks as props

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-11-25T03:07:07.498Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/AGENTS.md:0-0
Timestamp: 2025-11-25T03:07:07.498Z
Learning: Applies to internal-packages/workflow-designer-ui/src/editor/properties-panel/trigger-node-properties-panel/providers/github-trigger/components/{callsign,labels}*.tsx : Hide the 'Back' button in `input-callsign` and `input-labels` steps during reconfiguration mode to simplify UX.

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-11-25T03:05:31.051Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: .cursor/rules/edit-workspace-tour.mdc:0-0
Timestamp: 2025-11-25T03:05:31.051Z
Learning: Applies to internal-packages/workflow-designer-ui/src/editor/workspace-tour/workspace-tour.tsx : Import new images at the top of `workspace-tour.tsx` and update the `imageSrc` prop in the appropriate step component to use the new image

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-06-23T12:31:58.286Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: .cursor/rules/edit-workspace-tour.mdc:0-0
Timestamp: 2025-06-23T12:31:58.286Z
Learning: The tour uses React portals to render above other UI elements, ensuring overlays and highlights are not obstructed by the main application UI.

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
📚 Learning: 2025-06-23T12:31:58.286Z
Learnt from: CR
Repo: giselles-ai/giselle PR: 0
File: .cursor/rules/edit-workspace-tour.mdc:0-0
Timestamp: 2025-06-23T12:31:58.286Z
Learning: The workspace tour feature in `internal-packages/workflow-designer-ui/src/editor/workspace-tour/` is implemented using React and relies on a `TourStep` interface that defines each step's target (CSS selector), title, content, and placement.

Applied to files:

  • apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx
🧬 Code graph analysis (1)
apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx (1)
apps/studio.giselles.ai/app/(main)/stores/task-overlay-store.ts (1)
  • useTaskOverlayStore (33-42)
⏰ 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). (2)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: check
🔇 Additional comments (4)
apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx (4)

4-5: LGTM! Standard Next.js and React hooks for navigation tracking.

The imports correctly bring in usePathname for route detection and React hooks for managing side effects and refs.


12-20: LGTM! Correct use of store selector with useShallow.

The extended selection properly includes hideOverlay while maintaining optimized re-renders through useShallow.


21-22: LGTM! Clean setup for pathname change detection.

Using usePathname for route tracking and a ref for storing the previous pathname is the correct pattern for detecting navigation changes without causing extra renders.


24-32: LGTM! Correct route change detection and cleanup logic.

The effect properly:

  • Detects pathname changes using ref-based comparison
  • Prevents firing on initial render with the null check
  • Cleans up the overlay on navigation
  • Includes correct dependencies (pathname and hideOverlay)

The implementation aligns well with the PR objective of preventing UI overlap when routes change.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the task overlay UI component would persist when users navigate to different routes, causing unwanted UI overlap. The solution implements automatic overlay dismissal by monitoring route changes using Next.js navigation hooks.

  • Adds route change detection using usePathname hook
  • Implements automatic overlay hiding when the route changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hideOverlay();
}
previousPathnameRef.current = pathname;
}, [pathname, hideOverlay]);
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

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

The hideOverlay function is included in the dependency array but may not be stable across renders. If hideOverlay is recreated on each render, this could cause unnecessary effect re-runs. Consider wrapping hideOverlay in useCallback within the store, or remove it from the dependency array if it's guaranteed to be stable.

Suggested change
}, [pathname, hideOverlay]);
}, [pathname]);

Copilot uses AI. Check for mistakes.
@qodo-free-for-open-source-projects

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Only hide the overlay if visible

Optimize the useEffect hook by adding a check for isVisible before calling
hideOverlay to prevent unnecessary state updates on route changes.

apps/studio.giselles.ai/app/(main)/ui/task-overlay.tsx [24-32]

 	useEffect(() => {
 		if (
+			isVisible &&
 			previousPathnameRef.current !== null &&
 			previousPathnameRef.current !== pathname
 		) {
 			hideOverlay();
 		}
 		previousPathnameRef.current = pathname;
-	}, [pathname, hideOverlay]);
+	}, [pathname, hideOverlay, isVisible]);
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies an inefficiency where hideOverlay is called even when the overlay is not visible, proposing a valid optimization by checking the isVisible state first.

Low
  • More

@giselles-ai
Copy link

giselles-ai bot commented Dec 26, 2025

🔍 QA Testing Assistant by Giselle

📋 Manual QA Checklist

Based on the changes in this PR, here are the key areas to test manually:

  • Task Overlay Visibility: Open the task overlay, navigate to a different page using an internal link, and verify that the overlay is completely closed and not visible.
  • Task Overlay State after Browser Back/Forward: Open the task overlay, navigate to a new page (overlay closes), then use the browser's back button to return to the original page. Verify the overlay does not reappear. Then use the forward button to go to the new page again and verify the overlay remains closed.
  • Task Overlay Persistence on Non-Route Changes: Open the task overlay and perform actions within the application that do not change the URL (e.g., interacting with elements outside the overlay). Verify the task overlay remains open and functional.

✨ Prompt for AI Agents

Use the following prompts with Cursor or Claude Code to automate E2E testing:

📝 E2E Test Generation Prompt
Hello! You are an expert QA engineer. Your task is to write a new E2E test suite using Playwright and TypeScript based on the provided context. The goal is to validate the fix introduced in a recent Pull Request.

Please follow these instructions carefully to generate a robust, maintainable, and CI-ready test file.

---

### **1. Context Summary**

*   **PR Description:** The pull request fixes a UI bug where a "Task Overlay" component would remain visible ("linger") on the screen even after the user navigated to a different page/route within the application. This caused a UI overlap issue.
*   **The Fix:** The change was made in the `task-overlay.tsx` component. It now uses the `usePathname` and `useEffect` hooks from Next.js/React to detect when the URL path changes. If a change is detected while the overlay is open, it automatically calls the `hideOverlay()` function from the `zustand` store to close itself.
*   **Key User Flow Affected:**
    1.  User opens the Task Overlay on any page.
    2.  User clicks a navigation link (e.g., in a sidebar or header) to go to a new page.
    3.  **Expected Behavior (After Fix):** The Task Overlay should disappear.
    4.  **Old Behavior (Before Fix):** The Task Overlay would stay open on top of the new page's content.
*   **Critical Path to Test:** The primary critical path is verifying that a route change correctly triggers the closing of the task overlay.

### **2. Test Scenarios**

Create a test suite that covers the following scenarios:

1.  **Happy Path (Core Fix Verification):**
    *   **Title:** `should close the task overlay on route change`
    *   **Steps:**
        1.  Navigate to a page where the task overlay can be opened (e.g., a main project page).
        2.  Perform the action that opens the task overlay.
        3.  **Assert** that the task overlay is visible.
        4.  Click on a primary navigation link to go to a different page (e.g., 'Settings' or 'Dashboard').
        5.  **Assert** that the URL has changed to the new page.
        6.  **Assert** that the task overlay is now hidden.

2.  **Regression Test (Manual Close):**
    *   **Title:** `should not be affected by navigation after being manually closed`
    *   **Steps:**
        1.  Navigate to the initial page.
        2.  Open the task overlay.
        3.  **Assert** it's visible.
        4.  Manually close the overlay (e.g., by clicking a close 'X' button or pressing the `Escape` key).
        5.  **Assert** it's hidden.
        6.  Click a navigation link to go to a new page.
        7.  **Assert** that the app remains stable and the overlay does not reappear.

3.  **Regression Test (No Route Change):**
    *   **Title:** `should remain open when interacting within the overlay`
    *   **Steps:**
        1.  Navigate to the initial page.
        2.  Open the task overlay.
        3.  **Assert** it's visible.
        4.  Perform an action *inside* the overlay that does **not** trigger a route change (e.g., clicking a tab or typing in an input field within the overlay).
        5.  **Assert** that the task overlay remains visible.

### **3. Playwright Implementation Instructions**

*   **Test File:** Create a new test file named `task-overlay.spec.ts` inside the `tests/e2e/` directory.
*   **Test Structure:** Use `test.describe('Task Overlay', () => { ... });` to group all related tests.

*   **Selectors (Use these as a guide; adapt if necessary):**
    *   **Trigger for opening the overlay:** Assume there is a button or link to open a task. A good generic selector would be `page.getByTestId('open-task-button')` or `page.getByRole('button', { name: /open task/i })`.
    *   **The Task Overlay itself:** The component is named `TaskOverlay`. It likely has a `role="dialog"` or a unique test ID. Target it with `page.getByTestId('task-overlay')` or `page.getByRole('dialog')`.
    *   **Content within the overlay:** To confirm it's open, you can assert on content from its children, like `TaskHeader`. For example: `page.getByRole('heading', { name: /task details/i })`.
    *   **Navigation Link:** Target a reliable navigation link that changes the route. For example: `page.getByRole('link', { name: 'Dashboard' })`.
    *   **Manual Close Button:** Find the close button within the overlay. A good selector would be `page.getByRole('dialog').getByLabel('Close')` or `page.getByTestId('close-task-overlay-button')`.

*   **User Interactions & Assertions:**
    *   Use `await page.goto('/some-initial-page');` to start.
    *   Use `await expect(locator).toBeVisible();` to check if the overlay is present.
    *   Use `await expect(locator).toBeHidden();` or `await expect(locator).not.toBeVisible();` to check if the overlay is gone. Use `toBeHidden` as it's generally more robust.
    *   Wait for navigation to complete using `await page.waitForURL('**/new-page-path');` or by asserting the URL `await expect(page).toHaveURL('/new-page-path');`. The latter is preferred.
    *   When testing the manual close, you can use `await page.keyboard.press('Escape');`.

*   **Code Example for the Main Test Scenario:**

```typescript
// tests/e2e/task-overlay.spec.ts
import { test, expect } from '@playwright/test';

test.describe('Task Overlay', () => {
  test.beforeEach(async ({ page }) => {
    // Navigate to a page where the task overlay can be opened
    await page.goto('/project/cl123456');
  });

  test('should close the task overlay on route change', async ({ page }) => {
    // 1. Find and click the button that opens the task overlay
    const openTaskButton = page.getByTestId('some-task-in-list'); // Placeholder, adjust selector as needed
    await openTaskButton.click();

    // 2. Assert that the task overlay is now visible
    const taskOverlay = page.getByTestId('task-overlay'); // Placeholder, adjust selector as needed
    await expect(taskOverlay).toBeVisible();
    await expect(page.getByRole('heading', { name: /task details/i })).toBeVisible(); // Placeholder, adjust selector as needed

    // 3. Find and click a navigation link
    const dashboardLink = page.getByRole('link', { name: 'Dashboard' }); // Placeholder, adjust selector as needed
    await dashboardLink.click();

    // 4. Assert the URL has changed and the overlay is hidden
    await expect(page).toHaveURL(/.*\/dashboard/); // Placeholder, adjust URL as needed
    await expect(taskOverlay).toBeHidden();
  });

  // ... implement other test scenarios here ...
});

4. MCP Integration Guidelines

  • Execution Command: These tests can be invoked via Playwright MCP using a descriptive command.
    # Example command to run a single generated test
    mcp test "Verify that the task overlay closes when navigating to the dashboard"
    
    # Or to run the whole file
    mcp test "Run all tests for the Task Overlay functionality" --file tests/e2e/task-overlay.spec.ts
  • Environment Configuration: The test should assume a BASE_URL is configured in the playwright.config.ts or a .env file, which MCP will use. No special environment variables seem necessary for this specific test.

5. CI-Ready Code Requirements

  • Organization: Place the new file task-overlay.spec.ts in the appropriate test directory as specified above.
  • Naming Conventions:
    • File: feature-name.spec.ts (e.g., task-overlay.spec.ts).
    • Test Describe Block: test.describe('Feature Name', ...) (e.g., Task Overlay).
    • Test Case: test('should do X when Y', ...) (e.g., should close on route change).
  • Error Handling: Rely on Playwright's built-in web-first assertions (expect) and auto-waits. They handle retries and timeouts gracefully, making the tests less flaky.
  • Parallelization: The tests should be atomic and self-contained. They start by navigating to a clean page state (page.goto) and do not depend on the state from other tests. This makes them fully compatible with parallel execution in CI. Please ensure no state is shared between test() blocks.

<!--

LLM Instructions:

- Create a prompt that describes E2E test scenarios based on PR changes

- Include specific user flows, selectors, and assertions

- Reference Playwright MCP for test execution

- Structure the prompt to be directly usable in Cursor/Claude Code

- Include:

1. Test scenario descriptions

2. Step-by-step actions

3. Expected results/assertions

4. Any necessary test data or setup

-->


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants