Skip to content

Conversation

@Kan-A-Pesh
Copy link
Member

@Kan-A-Pesh Kan-A-Pesh commented Oct 16, 2025

Introduce waitForNavigation action type to correctly handle automatic redirects and preserve cookies.

This change fixes a bug where login cookies would disappear after a server-side redirect because the runner was performing a redundant page.goto() for automatic navigations, which would often clear the newly set cookies. The new waitForNavigation action type, recorded when a navigation occurs within 1 second of a user interaction, ensures the runner simply waits for the browser's natural navigation to complete, thus preserving session state.


Open in Cursor Open in Web

Summary by CodeRabbit

  • New Features
    • Added support for "wait for navigation" action type that intelligently detects and records navigation events triggered by user interactions, automatically distinguishing between manual navigation and automatic redirects.

Co-authored-by: michelm.gaming <michelm.gaming@gmail.com>
@cursor
Copy link

cursor bot commented Oct 16, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a new "waitForNavigation" action type to differentiate between user-initiated navigation and automatic redirects. The feature adds type definitions, event capture logic that tracks interaction timing, action execution handling, and CLI formatting support across three handlers.

Changes

Cohort / File(s) Summary
Type Definitions
src/core/types.ts
Adds new WaitForNavigationAction interface and extends Action union type to include it
Event Capture Logic
src/recorder/event-capture.ts
Adds lastInteractionTime field to track user interactions; differentiates navigation events—emits "waitForNavigation" if navigation occurs within 1 second of last interaction, otherwise emits "navigate"
Action Execution
src/runner/action-executor.ts
Adds case for "waitForNavigation" action type that waits for navigation using waitUntil: "networkidle2"
CLI Handlers
src/cli/callbacks/ci-mode/handler.ts, src/cli/callbacks/existing-story/handler.ts, src/cli/callbacks/run-multiple-stories/handler.ts
Each adds "waitForNavigation" case to formatAction switch, returning display string "wait for navigation"

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EventCapture
    participant EventQueue
    participant ActionExecutor
    participant Browser

    User->>EventCapture: Click/interact
    EventCapture->>EventCapture: Update lastInteractionTime
    
    Browser->>EventCapture: framenavigated event
    EventCapture->>EventCapture: Check: time since interaction < 1 sec?
    
    alt Within 1 second
        EventCapture->>EventQueue: Emit waitForNavigation
    else After 1 second (redirect)
        EventCapture->>EventQueue: Emit navigate
    end
    
    EventQueue->>ActionExecutor: Process action
    alt WaitForNavigation action
        ActionExecutor->>Browser: Wait (networkidle2, default timeout)
    else Navigate action
        ActionExecutor->>Browser: Navigate to URL
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

The changes follow established patterns with straightforward additions: a new type, a new timing-based logic branch in event capture, a new action executor case, and three identical formatter cases across handlers. The core logic is localized and easy to verify against the 1-second interaction threshold requirement.

✨ 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 cursor/investigate-and-plan-cookie-disappearance-bug-d0bb

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a5a6044 and 6d251a5.

📒 Files selected for processing (6)
  • src/cli/callbacks/ci-mode/handler.ts (1 hunks)
  • src/cli/callbacks/existing-story/handler.ts (1 hunks)
  • src/cli/callbacks/run-multiple-stories/handler.ts (1 hunks)
  • src/core/types.ts (2 hunks)
  • src/recorder/event-capture.ts (4 hunks)
  • src/runner/action-executor.ts (1 hunks)

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

@Kan-A-Pesh Kan-A-Pesh marked this pull request as ready for review October 16, 2025 16:35
@Kan-A-Pesh Kan-A-Pesh merged commit b783d86 into dev Oct 16, 2025
1 of 2 checks passed
@Kan-A-Pesh Kan-A-Pesh deleted the cursor/investigate-and-plan-cookie-disappearance-bug-d0bb branch October 16, 2025 16:36
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