Skip to content

Agent panel speed: backend reuse, batch tool, long-poll reads, Fast preset - #925

Merged
leeguooooo merged 17 commits into
mainfrom
feat/panel-speed
Dec 3, 2026
Merged

leeguooooo merged 17 commits into
mainfrom
feat/panel-speed

Conversation

@leeguooooo

Copy link
Copy Markdown
Owner

Speeds up the agent side panel, based on a study of Claude in Chrome 1.0.109 and 188 recorded panel turns (first text p50 14 s; ~3.5 s per model round trip; cold backend start on every message).

Changes

  • Backend reuse: Claude Code 2.1.335 and Codex 0.173.0 timeout fixtures captured and checked; both added to GENERATION_REUSE (every message was retiring with unlistedVersion). New scripts/verify-backend-reuse.sh.
  • chrome_use_batch: sequential steps in one MCP call, stop on first error, per-step lease/action id/approval/check, humanized pauses between inputs, under the MCP client timeout.
  • Assessment: owed only when the service recorded a state-changing action (reads/navigation/scroll/hover/screenshots are read-only; tabs, input, eval, downloads are not). Panel labels read-only turns.
  • Long-poll reads: conversationRead waitMs (≤8 s), no engine lock held, panel falls back for older services.
  • Panel: Fast/Thorough preset for new conversations, plan card (chrome_use_plan), approval keyboard keys, turn-finished sound, Alt+Shift+K command.
  • Caps: snapshot/read maxChars default 50,000.
  • Clippy 1.99 as_chunks fix in site_policy.rs.

Stealth: all changes are in the CLI, service and extension pages; nothing page-visible.

Verification

  • build: cargo test --all-targets ok; clippy --profile ci -D warnings ok; node tests 923 pass.
  • Panel acceptance on build (CfT 158, fixture backends): 1–3, 5–12, 14–23 pass; 4 and 13 fail identically on v1.5.297. New live checks 21 (batch), 22 (assessment reasons), 23 (26 s turn: 7 reads instead of 43, text 29–92 ms after emit).

Enter allows the active card once, Cmd/Ctrl+Enter takes its broadest
allow, Esc declines. Hints show on the buttons. Keys in text fields,
menus and focused controls are left alone; a card carrying page text
and lasting approvals of sensitive sites still need a click.
The command opens the side panel of the tab it was pressed in. On an
open panel it moves focus to the message box; pressed there, it closes
the panel. Alt+Shift+K is free in Chrome's defaults on every platform
(Ctrl/Cmd+E and the tab-search Cmd+Shift+A are taken).
…f sight

The side panel plays a short bundled sound when the conversation it
shows finishes a turn or starts waiting for approval while the panel is
hidden or its window is unfocused, next to the existing notification.
Options page: "Play a sound when a task finishes" (ab_turn_sound,
storage.sync, default on). The WAV is synthesized, no third-party audio.
…nversations

Most of the panel's time to first text is model thinking. A Fast/Thorough
button next to the model menu sets a new conversation's reasoning effort
(Fast: low for Codex and Claude Code) and, for Claude Code with no model
chosen, the Sonnet entry from the CLI's own model menu. Fast is the
default; the choice is remembered (ab_panel_speed). An explicit model or
effort still wins, and existing conversations keep their options.
… multi-site tasks

A panel-only MCP tool, chrome_use_plan {steps, sites}. Outside full
access its tool call already waits for the user's approval; the panel
renders that request (Claude can_use_tool, Codex MCP elicitation) as a
plan card with the sites and numbered steps, Approve (Enter) and Reject
(Esc) with an optional reason. A Claude rejection carries the reason:
the service accepts a bounded {deny: reason} decision for tool approvals.
Codex's decline has no text, so its reason is not sent. The tool
description tells the model to use it only when the conversation asks
before tools run.
- chrome_use_batch (--tools all): run up to 20 predictable steps in order.
  Each step goes through the same path as a standalone call (own lease,
  action id, recorded check, confirmation gate); the batch stops at the
  first failed or held step and lists the rest as not run. Allowlist of
  input/navigation/read tools, no nesting, whole batch validated before
  anything runs, 90 s budget checked per step against its timeout. Two
  input steps in a row are spaced by a seeded humanized pause
  (humanize::pause_between_actions), never a fixed sleep.
- Panel only: a second single input call in a row gets a one-line hint
  to use chrome_use_batch, at most once every 6 calls.
- chrome_use_snapshot passes --max-bytes (maxChars, default 50000) and
  --from, and notes a cut tree; chrome_use_read cuts page text at a line
  break (maxChars, default 50000) in response, stdout and text block.
- The final assessment is owed only when the turn's admitted leases
  include a state-changing action (input, eval, downloads, unknown
  tools); read-only turns (reads, snapshots, screenshots, navigation,
  tabs, scroll, hover) end with reason readOnly instead of notAssessed.
  PROMPT and chrome_use_task description updated; stealth sentence kept.
- Approval keys never answer a card whose view is hidden; Esc from a
  control outside the card is left to it.
- The chime treats the panel as out of sight when the document is hidden
  or its browser window is not focused (not when the page has focus).
- The keyboard command opens the window's panel when per-tab panels are
  not configured, as notifications do.
- The speed preset's model applies only where its chip is offered, and
  never to the default-model retry.
- chrome_use_plan's reply claims no approval (full access and Pi run it
  unasked); its limits (12 x 150 chars) keep the largest plan under the
  service's review budget. Service test: the plan stays reviewable and a
  rejection reaches Claude with the reason.
Capture the MCP client-timeout fixtures for the installed versions. Both
close a timed-out chrome_use call as a failed tool with the text
client_timed_out matches, before an ordinary completed terminal line, and
ignore the late reply; Codex 0.173.0 now also sends notifications/cancelled.
List both in GENERATION_REUSE.

Tests now check every listed version against its own fixture (handshake
version, timed-out call closed before the turn ends, clientTimeout
retirement), so an entry without a fixture fails.

scripts/verify-backend-reuse.sh captures, redacts and checks the fixtures
for whatever claude/codex is installed and prints the entry to add
(capture/check-timeout.mjs; redact.mjs now also strips run paths, home,
user and host names).
conversationRead takes an optional waitMs (capped at 8 s, inside the
service's 10 s, the native host's 12 s and the bridge's 15 s budgets) and
answers as soon as the conversation's journal moves past the cursor or its
state or queue changes, or empty at the deadline. The wait does not hold
the engine lock: the store bumps a watch counter on every journal append
and state save, and the read subscribes under the lock before it re-checks.
Writes to other conversations wake it but do not end it.

At most 4 reads wait at once, since each holds one of the 16 service
connection slots; past that a read answers at once with readWaited false.
serviceStop wakes waiting reads so they do not hold the exit. Replies carry
readWaitMaxMs so panels send waitMs only to services that accept it (older
services refuse unknown fields).
… 600 ms

Once a read reply carries readWaitMaxMs, the read loop sends waitMs while a
turn runs and reads again right after each waited reply, keeping a 150 ms
floor between reads so streamed text arrives in batches. Idle conversations
keep the 1800 ms cadence; services without readWaitMaxMs keep the 600 ms
busy cadence and are never sent waitMs. A failed waiting read stops waitMs
until the host reconnects, and failures back off exponentially (30 s cap).

Plain reads after an action or on selection run beside a waiting read
instead of being skipped, a reply whose cursor was overtaken is read again
from the new cursor, and switching conversations restarts the loop so the
new selection is not held behind the old waiting read.
…ments and long-polled reads

Check 21 runs two chrome_use_batch calls through the real MCP: each step gets
its own lease, action id and browserActionTarget, and a failing middle click
stops the batch (the click after it never reaches the site). Check 22 ends
read-only turns (single tools and a batch) without an assessment and expects
reason readOnly, and click turns notAssessed. Check 23 counts the side
panel's conversationRead requests at the service proxy while a slow turn
streams: waitMs reads, far fewer than one per 600 ms, text shown promptly.
@leeguooooo
leeguooooo merged commit 9eb47d9 into main Dec 3, 2026
12 of 16 checks passed
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@leeguooooo
leeguooooo deleted the feat/panel-speed branch December 3, 2026 08:41
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.

1 participant