Skip to content

fix: restore embedded Grok conversations and cookie consent - #88

Merged
Manho merged 2 commits into
mainfrom
fix/grok-embedded-cookies
Oct 16, 2026
Merged

Manho merged 2 commits into
mainfrom
fix/grok-embedded-cookies

Conversation

@Manho

@Manho Manho commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Closes #85.

Grok loads in Panelize but cannot start a conversation because Chromium omits its SameSite session cookies from embedded WebSocket handshakes. Restore authenticated connections and preserve the user's cookie consent choice across panel refreshes.

Changes

  • Append the existing Grok cookies Chromium omits through a session-scoped declarativeNetRequest rule restricted to Grok WebSockets initiated by Grok in Multi-Panel tabs. Preserve cookies Chromium already sends and leave standalone Grok tabs outside the rule.
  • Synchronize the rule before loading or switching to Grok and on cookie, provider, startup, and tab lifecycle changes.
  • Preserve existing OneTrust consent cookie values while making them accessible to the embedded panel with SameSite=None; Secure. Apply the same attributes to future writes of those two cookies in embedded Grok frames, so the user's choice survives refreshes.
  • Add the cookies and wss://grok.com/* permissions and document both uses of cookie access in the privacy policy.
  • Add unit coverage and a local browser regression for authentication, session rotation, and standalone-tab isolation.

Validation

  • Reproduced the failure in an embedded panel while standalone Grok worked in the same profile; confirmed missing session cookies in the WebSocket handshake.
  • Verified live Grok responses after the fix (session.created and response.done). The user also confirmed that sending messages and retaining cookie consent now work.
  • Verified consent persistence with existing Lax consent cookies and after accepting inside the panel, refreshing the panel, and reloading Multi-Panel.
  • npx vitest run --maxWorkers=1 --silent: 414 tests passed across 45 files. The initial parallel run had one ChatGPT idle-status test failure; its focused rerun and the serial full suite passed.
  • npx playwright test tests/e2e/grok-websocket.e2e.test.js: passed during targeted validation.
  • npm run test:e2e: 36/37 passed, including the Grok WebSocket regression. Qwen's test stopped during extension-copy setup with an ENOENT for Chromium's generated _metadata directory; npx playwright test tests/e2e/qwen-auth.e2e.test.js then passed on its own.
  • web-ext lint: 8 errors, all reproduced on origin/main; no new errors. Existing errors concern Firefox manifest compatibility and parsing Node scripts as extension code.

The branch starts at 8786521 on main, which already includes the Qwen fix from #87, and contains only the Grok fix commit.

Manho added 2 commits October 16, 2026 22:06
Address review findings on the embedded Grok cookie forwarding:

- Only accept sync requests from the top frame of the extension's own
  Multi-Panel page, derive tabs from runtime.getContexts (frameId 0) and
  add a topDomains condition when supported, so a website framing the
  web-accessible Multi-Panel page no longer receives Grok session cookies.
- Drop a tab from the rule as soon as it starts navigating and only
  re-admit it after a new sync request, avoiding duplicate cookies (401)
  after the tab leaves the Multi-Panel page.
- Route every reconcile through one coalescing service worker scheduler
  instead of reconciling from the page, and propagate failures.
- Upgrade consent cookies only on an explicit Multi-Panel sync request.
- Reconcile on tab removal and cookie changes only when relevant.
- Sync before the panel limit check in addPanel so concurrent adds cannot
  exceed MAX_PANELS.
- Patch the prototype that owns document.cookie and run the consent
  script only inside extension pages.

Claude-Session: https://claude.ai/code/session_01W5d9xkwrKRHCwLGjgnvYQn
@Manho
Manho merged commit 7974e37 into main Oct 16, 2026
2 checks passed
@Manho Manho mentioned this pull request Oct 16, 2026
@Manho
Manho deleted the fix/grok-embedded-cookies branch October 22, 2026 15:56
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.

Grok WebSocket connection fails inside Panelize on Chrome

1 participant