Skip to content

feat(clipper): ask the Lens assistant from the extension's side panel - #322

Merged
adeelahmad merged 4 commits into
mainfrom
claude/project-thread-mr9hx9
Oct 10, 2026
Merged

adeelahmad merged 4 commits into
mainfrom
claude/project-thread-mr9hx9

Conversation

@adeelahmad

@adeelahmad adeelahmad commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the web clipper could only clip pages into Lens. To ask the assistant you had to open Lens's web app.

After: the extension has the Lens assistant in a side panel (Firefox's sidebar in Firefox). Open it with Ask Lens in the popup, Ask Lens… on the right-click menu, or a shortcut you assign. Signing in takes one click: the address comes from the clipper's Lens, and Lens's own consent page lets the extension in (OAuth with PKCE through identity.launchWebAuthFlow, nothing to copy). Conversations are the same ones the web app shows. Answers are cited and linked to the moment they came from, the steps taken are listed, and approvals wait for Approve or Decline. Enter sends, Esc stops, New starts a new conversation and Open in Lens continues it in the web app.

This is the second of three PRs; #311 added the server side. The next PR lets the assistant use the browser from this panel.

How:

  • src/core/account.js signs in: it discovers the server (RFC 8414), registers once (RFC 7591), uses PKCE S256 and checks state. Tokens renew themselves, with a single renewal in flight, and sign-out revokes them (RFC 7009). Safari has no launchWebAuthFlow, so it falls back to an API token.
  • src/core/assistant.js is the chat API client. It reads SSE with eventsource-parser and renders answers with marked, then DOMPurify (no scripts, images or forms; only http and https links).
  • src/ui/sidepanel.* is the panel. The manifest adds side_panel and the sidePanel and identity permissions, neither of which shows an install warning, plus an open-assistant command with no suggested key, since Chrome allows four and the clipper uses them. Safari has no side panel, so its target opens the panel in a tab. Firefox (feat(clipper): build the web clipper for Firefox #282) maps it to sidebar_action, not opened at install, without the sidePanel permission; web-ext lint on dist/firefox has 0 errors.
  • The Edge smoke test now signs the panel in through a stand-in consent page, asks a question, checks the cited answer and approves. It passes locally in Chromium 141.
  • The threat model gains the side panel as an entry point.

Motivation and Context

Adeel asked to chat with the assistant from the browser extension and let it do tasks in the browser ("check my email and import important attachments").

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project.
  • I added or updated tests: test/account.test.js and test/assistant.test.js (34 extension tests pass), plus the Edge smoke test.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/browser-assistant.md, docs/web-clipper.md); mkdocs build --strict is clean.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: this is the second of three PRs. It merges on green, and the goal is met when browser control lands next.
  • Agents: the panel uses only the public API (/chats, /approvals), so agents already have all of it.
  • Zero setup: app sign-in is on by default. No .env change or manual step is needed.
  • Fewest clicks: the address is prefilled and one click signs in; nothing to copy. The first empty field has focus, and Enter sends or signs in.
  • Configurable: n/a, no new setting. It uses the existing Let apps and AI assistants sign in setting.
  • Light: no server change. Three small MIT/Apache libraries in the extension (marked, DOMPurify, eventsource-parser).
  • Private and secure: tokens stay on the device, renew themselves and are revoked on sign-out. Answers are sanitized. The threat model gains the side panel entry point.
  • Cost: no model calls beyond the questions asked, through the existing chat ledger.
  • User decides: approvals stay with the person, and existing defaults are unchanged.
  • Upgrades: no stored data changes. The new permissions need no new consent.
  • Honest: the docs say what's built and label browser control in progress.
  • Tests and docs updated. No generated files are touched.
  • Open standards: OAuth 2.1 (RFC 8414, 7591, 7636, 7009) and SSE. The dependencies are MIT and Apache-2.0 (DOMPurify).
  • Refine later items are in docs/browser-assistant.md and DEVLOG.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PhTrpdr3XSgcD91oFxAiMQ


Generated by Claude Code

The web clipper gets a side panel with the Lens assistant: Ask Lens in the popup, on the right-click menu or by a
shortcut. It signs in through Lens's own consent page (OAuth with PKCE and launchWebAuthFlow, nothing to copy), or
with an API token where the browser can't show that page (Safari, which opens it in a tab). Conversations are the
same ones the web app shows: cited answers rendered as Markdown through DOMPurify, the steps taken, approvals to
approve or decline, Stop, and Open in Lens.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PhTrpdr3XSgcD91oFxAiMQ
Firefox has no side_panel; its target maps the panel to sidebar_action (not
opened at install) and drops the sidePanel permission.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PhTrpdr3XSgcD91oFxAiMQ
@adeelahmad
adeelahmad merged commit 673c907 into main Oct 10, 2026
13 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-mr9hx9 branch October 10, 2026 22:23
adeelahmad added a commit that referenced this pull request Oct 10, 2026
…s as built (#332)

#322, #330, #297 and #309 merged, so the README lists them as built and keeps
only open PRs under "In progress".


Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS

Co-authored-by: Adeel Ahmad <noreply@anthropic.com>
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.

2 participants