[docs]: add docs for cookie handling#1748
Conversation
|
Greptile SummaryAdded comprehensive documentation for cookie handling functionality in the context API, including three new methods: The documentation is thorough and well-structured with:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 4ad34e1 |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant User as User Script
participant SH as Stagehand
participant Ctx as V3Context
participant BE as Browser Engine (Local/Remote)
participant Page as Browser Page
Note over User,BE: Context Initialization
User->>SH: init()
SH->>Ctx: Create Context
Ctx->>BE: Launch/Connect Browser Session
Ctx->>Page: Open initial page(s)
Note over User,BE: NEW: Cookie Management Flow
rect rgb(23, 37, 84)
Note right of User: Set Cookies
User->>Ctx: NEW: addCookies(cookies[])
Ctx->>Ctx: Validate (Must have URL OR Domain+Path)
alt Validation Failed
Ctx-->>User: Throw ValidationError
else Validation Passed
Ctx->>BE: Inject cookies into session
BE-->>Ctx: Success
Ctx-->>User: void
end
end
rect rgb(5, 46, 22)
Note right of User: Read Cookies
User->>Ctx: NEW: cookies(urls?)
Ctx->>BE: Get session cookies
BE-->>Ctx: Cookie[]
opt If urls provided
Ctx->>Ctx: Filter cookies by domain/path/secure
end
Ctx-->>User: Return Cookie[]
end
rect rgb(69, 26, 3)
Note right of User: Clear Cookies
User->>Ctx: NEW: clearCookies(options?)
Ctx->>BE: Remove cookies from session
Note over Ctx,BE: Matches by Name, Domain, or Path
BE-->>Ctx: Success
Ctx-->>User: void
end
Note over Page,BE: Page interactions automatically use Context cookies
User->>Page: goto(url)
Page->>BE: Request with Context Cookies
BE-->>Page: Response (Set-Cookie headers update Context)
why
context.addCookies()context.clearCookies()context.cookies()note:
Summary by cubic
Add V3 docs for cookie management in context: cookies(), addCookies(), and clearCookies, with examples and type definitions to help users manage auth and state. Connects to Linear STG-1409; merge after the release that includes these APIs.
Written for commit 4ad34e1. Summary will update on new commits. Review in cubic