Skip to content

Conversation

@shivammittal274
Copy link
Contributor

No description provided.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

This PR adds browser_update_bookmark tool to enable editing bookmark titles and URLs. The implementation follows established patterns from other bookmark actions and includes comprehensive test coverage.

Key changes:

  • New UpdateBookmarkAction that validates at least one field is provided and delegates to BookmarkAdapter.updateBookmark
  • Registered in BrowserOSController and exported in tool registry (updated count: 36→37 tools)
  • Enhanced agent prompt documentation with clearer workflow examples for organizing bookmarks into folders
  • Full test suite covering success cases (title-only, URL-only, both) and error handling (missing ID, invalid ID)

Bookmarks section improvements:

  • Split "Bookmarks & History" into separate sections for better clarity
  • Added detailed descriptions emphasizing folder workflows (parentId from browser_get_bookmarks or browser_create_bookmark_folder)
  • Included practical multi-step example showing folder creation → bookmark creation → moving existing bookmarks

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation following existing patterns, comprehensive test coverage, and proper validation. The only style comment is minor (excessive documentation per CLAUDE.md) and doesn't impact functionality. No bugs, security issues, or architectural concerns identified.
  • No files require special attention

Important Files Changed

Filename Overview
apps/controller-ext/src/actions/bookmark/UpdateBookmarkAction.ts New action handler for updating bookmark title/URL with proper validation and error handling
apps/server/src/agent/prompt.ts Enhanced bookmark documentation with clear usage examples and organizational workflow guidance
apps/server/src/tools/controller-based/tools/bookmarks.ts Added updateBookmark tool with improved descriptions for folder organization workflows
apps/server/tests/tools/controller-based/bookmarks.test.ts Comprehensive test coverage for update bookmark functionality including success and error cases

Sequence Diagram

sequenceDiagram
    participant Client as AI Agent/MCP Client
    participant Server as HTTP Server (Hono)
    participant Tool as browser_update_bookmark Tool
    participant Bridge as ControllerBridge (WebSocket)
    participant Controller as BrowserOSController
    participant Action as UpdateBookmarkAction
    participant Adapter as BookmarkAdapter
    participant Chrome as Chrome Bookmarks API

    Client->>Server: Call browser_update_bookmark(bookmarkId, title?, url?)
    Server->>Tool: Handler invoked with params
    Tool->>Bridge: executeAction('updateBookmark', {id, title, url})
    Bridge->>Controller: Send action request via WebSocket
    Controller->>Action: Execute UpdateBookmarkAction
    Action->>Action: Validate at least one field provided
    Action->>Adapter: updateBookmark(id, changes)
    Adapter->>Chrome: chrome.bookmarks.update(id, changes)
    Chrome-->>Adapter: Updated bookmark node
    Adapter-->>Action: Return updated bookmark
    Action-->>Controller: Return {id, title, url}
    Controller-->>Bridge: Action result
    Bridge-->>Tool: Execution result
    Tool->>Tool: Format response text
    Tool-->>Server: Response with updated bookmark details
    Server-->>Client: MCP response
Loading

@claude
Copy link

claude bot commented Jan 27, 2026

Code Review

Found 1 issue that needs attention:

Schema Validation Mismatch in browser_update_bookmark

Location: apps/server/src/tools/controller-based/tools/bookmarks.ts line 135

The server-side schema accepts any string for the url parameter:

title: z.string().optional().describe('New title for the bookmark'),
url: z.string().optional().describe('New URL for the bookmark'),
windowId: z.number().optional().describe('Window ID for routing'),

However, the extension-side schema requires a valid URL format using Zod's .url() validator:

title: z.string().optional().describe('New bookmark title'),
url: z.string().url().optional().describe('New bookmark URL'),
})

Impact: A user could call browser_update_bookmark with an invalid URL string (e.g., "not-a-valid-url"), which would:

  1. Pass server-side validation
  2. Be sent to the extension via WebSocket
  3. Fail at the extension level with a Zod validation error

This creates a poor user experience because validation errors occur in the wrong layer and with less helpful error messages.

Suggested fix: Update line 135 in apps/server/src/tools/controller-based/tools/bookmarks.ts to:

url: z.string().url().optional().describe('New URL for the bookmark'),

This ensures validation happens as early as possible in the request pipeline and provides clearer error messages to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants