Skip to content

refactor(browser): split BrowserCookieStore into cookie_store.py (S6)#543

Merged
jaylfc merged 1 commit into
devfrom
refactor/cookie-store-split
Jun 3, 2026
Merged

refactor(browser): split BrowserCookieStore into cookie_store.py (S6)#543
jaylfc merged 1 commit into
devfrom
refactor/cookie-store-split

Conversation

@jaylfc
Copy link
Copy Markdown
Owner

@jaylfc jaylfc commented Jun 3, 2026

Modularity plan S6. Moves the self-contained BrowserCookieStore (SQLCipher-encrypted cookie store, ~193 lines) out of the 1397-line routes/desktop_browser/store.py into its own cookie_store.py. The class shares no code with BrowserStore (it deliberately bypasses BaseStore to use the sync sqlcipher3 driver).

To keep the many existing from ...desktop_browser.store import BrowserCookieStore importers working unchanged, store.py re-exports the class. Verified the two import paths resolve to the same class object. No behavioral change.

store.py 1397 → 1204 lines. +20 dedicated cookie tests pass; full desktop_browser suite (560 tests) passes. Preps the B4 store.py mixin split.

Summary by CodeRabbit

New Features

  • Implemented secure, encrypted cookie persistence with SQLCipher-backed database storage for maintaining credentials across user sessions.
  • Added comprehensive cookie management with subdomain pattern matching, automatic expiration filtering, and support for HTTP-only, Secure, and SameSite security flags.
  • Enables independent cookie storage and retrieval for multiple user profiles with 256-bit encrypted key management.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 42ac9c26-4bfc-4bfe-9afc-e55a5f48174a

📥 Commits

Reviewing files that changed from the base of the PR and between c137e66 and fdf348a.

📒 Files selected for processing (2)
  • tinyagentos/routes/desktop_browser/cookie_store.py
  • tinyagentos/routes/desktop_browser/store.py

📝 Walkthrough

Walkthrough

This PR extracts BrowserCookieStore, an async SQLCipher-backed cookie persistence layer, from store.py into a dedicated cookie_store.py module. The class is then re-exported from store.py for backward compatibility, reducing module coupling and improving organization.

Changes

Cookie Store Module Extraction

Layer / File(s) Summary
Cookie store class definition and lifecycle
tinyagentos/routes/desktop_browser/cookie_store.py
Constructor validates the SQLCipher 256-bit hex key, initializes instance state, and implements init() to create the DB directory and configure SQLCipher with schema and encryption key. close() resets initialization state, and _connect() helper opens new SQLCipher connections with PRAGMA key on each call.
Cookie CRUD operations
tinyagentos/routes/desktop_browser/cookie_store.py
set_cookie() asynchronously upserts cookies with value, expiration, and boolean flags stored as integers. get_cookies() queries cookies for a user/profile/host with subdomain matching and expiration filtering. delete_cookie() removes a single cookie by full key, and delete_profile_cookies() deletes all cookies for a user/profile pair and returns the row count.
Module re-export and cleanup
tinyagentos/routes/desktop_browser/store.py
Re-exports BrowserCookieStore from cookie_store.py for backward compatibility; removes the original 195-line in-file implementation from store.py.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • jaylfc/tinyagentos#300: Earlier PR implementing the SQLCipher-backed BrowserCookieStore with 256-bit key management and cookie CRUD logic that this PR refactors into a separate module.

Poem

🐰 A cookie store hops to its own file,
Encrypted keys, each one worthwhile,
SQLCipher keeps secrets locked tight,
Clean refactoring—modular delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactor: extracting BrowserCookieStore into a dedicated cookie_store.py module, which is the primary change reflected in the summary.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/cookie-store-split

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.

@jaylfc jaylfc merged commit b0a9b31 into dev Jun 3, 2026
7 checks passed
@jaylfc jaylfc deleted the refactor/cookie-store-split branch June 3, 2026 17:05
@github-project-automation github-project-automation Bot moved this from Todo to Done in TinyAgentOS Roadmap Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant