feat: describe tab handling in agentic tool#46
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdded tab-management capabilities to the browsing agent: new commands to list, switch, create, and close tabs; snapshot can target a non-active tab; snapshot outputs and tool documentation were updated to include tabs/activeTargetId and formatted tab summaries. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AgentTool as Agent Tool
participant Browser as Browser Runtime
participant Formatter as Snapshot Formatter
Client->>AgentTool: send command (getTabs/createTab/switchTab/closeTab/snapshot{targetId})
AgentTool->>Browser: execute corresponding tab API call
Browser-->>AgentTool: return result / SnapshotResult (with tabs, activeTargetId)
AgentTool->>Formatter: formatSnapshot (include tabs summary if multiple tabs)
Formatter-->>Client: formatted snapshot / command response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning Review ran into problems🔥 ProblemsThese MCP integrations need to be re-authenticated in the Integrations settings: Linear Review rate limit: 3/5 reviews remaining, refill in 15 minutes and 21 seconds. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/tools/schemas.ts (1)
204-210: TightentargetIdvalidation to reject empty values early.At Line 204, Line 224, and Line 258,
z.string()allows"", which will pass schema validation and fail later at runtime. Enforcing non-empty strings improves error locality.Suggested schema hardening
targetId: z - .string() + .string() + .min(1, 'targetId cannot be empty') .optional()targetId: z - .string() + .string() + .min(1, 'targetId cannot be empty') .describe('The targetId of the tab to make active (from getTabs).'),- targetId: z.string().describe('The targetId of the tab to close.'), + targetId: z + .string() + .min(1, 'targetId cannot be empty') + .describe('The targetId of the tab to close.'),Also applies to: 224-226, 258-258
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tools/schemas.ts` around lines 204 - 210, Replace permissive z.string() for the targetId fields with a non-empty string validator so empty "" values fail validation early; e.g., change instances like z.string().optional().describe(...) to z.string().nonempty().optional().describe(...) (apply this to the targetId schemas in this file, including the other two occurrences that currently use z.string().optional()).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/tools/agent.ts`:
- Line 79: The deep-selector example in src/tools/agent.ts contains a duplicated
token: change the example `button button "Deny" deep-ref=< button#deny` to
remove the extra `button` so it reads `button "Deny" deep-ref=< button#deny`,
and ensure the associated selector example remains `"< button#deny"` to keep the
example consistent.
- Around line 134-137: The snapshot metadata (tabs and activeTargetId) is
documented but not included in agent output; update the snapshot renderer
(function formatSnapshot and its SnapshotResult handling) to include
snapshot.tabs and snapshot.activeTargetId in the returned formatted text (show
Active tab and a Tabs list with targetId, active flag, title and url) so agents
can choose tabs without calling getTabs every time, or alternatively change the
docs to require getTabs by removing the claims about snapshots always including
tabs—implement the former by adding checks for snapshot.tabs and
snapshot.activeTargetId inside formatSnapshot and appending the tab metadata
lines before rendering elements.
---
Nitpick comments:
In `@src/tools/schemas.ts`:
- Around line 204-210: Replace permissive z.string() for the targetId fields
with a non-empty string validator so empty "" values fail validation early;
e.g., change instances like z.string().optional().describe(...) to
z.string().nonempty().optional().describe(...) (apply this to the targetId
schemas in this file, including the other two occurrences that currently use
z.string().optional()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 17976a97-176f-4d8b-bb6a-9c6ca966ab53
📒 Files selected for processing (2)
src/tools/agent.tssrc/tools/schemas.ts
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Tab management capabilities now available: enumerate, switch, create, and close tabs. * Snapshots can now capture non-active tabs without changing the active tab. * **Documentation** * Updated tool documentation with Shadow DOM deep selector guidance. * Added specifications for tab behavior, error codes, and snapshot usage with tab targeting. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Documentation