Skip to content

feat: Local clipboard tool to copy text, image and filepaths#1453

Merged
angrybayblade merged 3 commits intoComposioHQ:developmentfrom
ExplorerAadi:feat/clipboard-tool-issue-455
Mar 25, 2025
Merged

feat: Local clipboard tool to copy text, image and filepaths#1453
angrybayblade merged 3 commits intoComposioHQ:developmentfrom
ExplorerAadi:feat/clipboard-tool-issue-455

Conversation

@ExplorerAadi
Copy link

@ExplorerAadi ExplorerAadi commented Mar 18, 2025

Add Clipboardtool for in-memory clipboard management

A new Clipboardtool as requested in #455 , offering in-memory clipboard capabilities for text, images, and file paths. The tool is fully self-contained and maintains clipboard state in memory, making it useful for automated workflows and cross-platform compatibility.

Features

  • Text operations: Copy and paste text strings
  • Image operations: Copy and paste images using PIL
  • File path operations: Copy and paste file paths with validation

Implementation details

  • Follows the standard Composio tool structure (took reference mostly from filetool)
  • Maintains clipboard state in session metadata, avoiding OS clipboard dependencies
  • Full test coverage for all operations
  • Example script demonstrating usage

Dependencies

  • Added Pillow (>=10.2.0,<11) for image operations

This tool enhances automation capabilities by allowing agents to maintain their own clipboard state separate from the OS clipboard, making it especially useful for multi-step workflows that need to preserve data between operations.

Let me know about any changes or feedback.

Example ss:
image

Test ss:
image


Important

Introduces Clipboardtool for in-memory clipboard management of text, images, and file paths, with full test coverage and example usage.

  • Behavior:
    • Adds Clipboardtool for in-memory clipboard management of text, images, and file paths.
    • Supports copy and paste operations for text, images (using PIL), and file paths with validation.
    • Maintains clipboard state in session metadata, independent of OS clipboard.
  • Implementation:
    • New classes CopyText, PasteText, CopyImage, PasteImage, CopyFilePaths, PasteFilePaths in actions directory.
    • get_clipboard_state() function in base_action.py to manage clipboard state.
    • Example script clipboard_example.py demonstrating usage.
  • Dependencies:
    • Adds Pillow (>=10.2.0,<11) for image operations in setup.py.
  • Testing:
    • Full test coverage in test_clipboardtool.py for all clipboard operations.

This description was created by Ellipsis for 3a73ef2. It will automatically update as commits are pushed.

@vercel
Copy link

vercel bot commented Mar 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 20, 2025 9:02am

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 3a73ef2 in 2 minutes and 43 seconds

More details
  • Looked at 857 lines of code in 10 files
  • Skipped 1 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. python/composio/tools/local/clipboardtool/__init__.py:5
  • Draft comment:
    Missing newline at end of file.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. python/composio/tools/local/clipboardtool/actions/image.py:59
  • Draft comment:
    Avoid using print statements for debugging; consider using a logging framework.
  • Reason this comment was not posted:
    Marked as duplicate.
3. python/examples/miscellaneous/clipboard_example.py:90
  • Draft comment:
    Hard-coded image path may break cross-platform compatibility.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    This is an example file demonstrating clipboard functionality. The hardcoded path is clearly just for demonstration purposes. The file is in an "examples" directory and contains multiple example usages. The path doesn't need to work everywhere since it's just sample code. The important part is demonstrating the API usage pattern.
    The code could be more useful as an example if it used a more generic path that works everywhere. Someone copy-pasting this example would need to modify the path.
    While the suggestion would make the code more portable, example code often uses simplified hardcoded values to focus on demonstrating the core functionality. The path is clearly marked as example code.
    This comment should be deleted since it's nitpicking an example file where the specific path used isn't critical to demonstrating the clipboard functionality.
4. python/composio/tools/local/clipboardtool/actions/image.py:106
  • Draft comment:
    Ensure that 'request.save_path' includes a valid directory path; if it lacks one, os.path.dirname returns an empty string, which may cause os.makedirs to fail.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The comment raises a theoretical issue but os.makedirs() with exist_ok=True will handle empty strings gracefully - it will create in current directory. This is actually a reasonable fallback behavior. The comment is asking for validation without clear benefit. It's more of a "verify that..." style comment that doesn't point to a clear problem.
    Perhaps there could be security implications of allowing arbitrary paths? Maybe the current directory fallback isn't desirable in all cases?
    The code is already handling path creation safely with exist_ok=True. If path validation is needed, it should be done at a higher architectural level, not in this utility function.
    Delete the comment as it's asking for verification without demonstrating a clear problem, and the current code handles the case safely.
5. python/tests/test_tools/test_local/test_clipboardtool.py:29
  • Draft comment:
    Using a module-scoped shared 'clipboard_state' fixture could lead to test interference; consider using a function-scoped fixture to ensure isolation between tests.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The clipboard_state fixture holds mutable state that is modified by each test through copy/paste operations. While the tests currently pass, they are dependent on running in a specific order and cleaning up after themselves. A function-scoped fixture would provide better isolation. However, looking at the test implementation, each test performs a complete copy-paste cycle and verifies the results, so the shared state doesn't actually cause problems.
    The tests are working as designed - each test does a full copy-paste cycle and verifies its own results. The module-scoped fixture may actually be intentional to test persistence across operations.
    While function-scoping would provide better isolation, the current implementation is valid and may be intentionally testing clipboard state persistence. The tests handle their own setup/verification.
    The comment raises a valid testing best practice but the current implementation is working as intended and may be deliberately testing state persistence. The suggestion is not clearly necessary.
6. python/composio/tools/local/clipboardtool/__init__.py:5
  • Draft comment:
    Trailing whitespace found at the end of the import statement. Please remove the extra space after 'Clipboardtool' to ensure cleaner code.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    While trailing whitespace is generally undesirable, this is an extremely minor style issue that would typically be handled by automatic formatters or linters. It doesn't affect functionality and is not a significant code quality issue. Most IDEs automatically strip trailing whitespace on save.
    Perhaps trailing whitespace could cause issues in some edge cases or with certain tools? Maybe it's part of a consistent style guide that needs to be followed?
    Even if there are style guidelines about trailing whitespace, this is too minor to warrant a PR comment. This should be handled by automated tools, not manual review.
    Delete this comment as it points out an extremely minor style issue that should be handled by automated tools rather than PR comments.
7. python/composio/tools/local/clipboardtool/__init__.py:5
  • Draft comment:
    The file is missing a newline at the end. Please add a newline at the end of the file to adhere to standard formatting best practices.
  • Reason this comment was not posted:
    Marked as duplicate.
8. python/setup.py:2
  • Draft comment:
    Typographical error: In the file header docstring (line 2), 'compsio core' appears to be a typo. Consider correcting it to 'composio core' to maintain consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_RUHPf0XYunnCH799


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ExplorerAadi
Copy link
Author

New test with a dummy image instead of the one from my system:
image

Comment on lines +49 to +50
# Register actions in Action enum when the module is imported
register_clipboard_actions()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The register_clipboard_actions() function is now called at module import time, but it's also still being called when actions() is accessed. This could lead to duplicate action registration.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# Register actions in Action enum when the module is imported
register_clipboard_actions()
# Register clipboard actions at module import time
register_clipboard_actions()

Comment on lines +89 to +93
# Create a test image instead of using a hard-coded path
test_image_path = os.path.join(temp_dir, "test_image.png")
# Create a simple test image
test_image = Image.new('RGB', (100, 100), color='red')
test_image.save(test_image_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code imports Image from PIL but the import statement is missing. Add from PIL import Image to fix the error.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# Create a test image instead of using a hard-coded path
test_image_path = os.path.join(temp_dir, "test_image.png")
# Create a simple test image
test_image = Image.new('RGB', (100, 100), color='red')
test_image.save(test_image_path)
from PIL import Image

@angrybayblade angrybayblade changed the base branch from master to development March 25, 2025 05:45
@angrybayblade angrybayblade merged commit c1f279d into ComposioHQ:development Mar 25, 2025
2 checks passed
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