Skip to content

Conversation

@bajrangCoder
Copy link
Member

Fixes: #1852

Adds option to copy file/folder relative paths based on project root.
Supports all URI types (file, content, sftp, ftp) with proper fallback.
@github-actions github-actions bot added enhancement New feature or request translations Anything related to Translations Whether a Issue or PR labels Feb 2, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bajrangCoder, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant quality-of-life improvement by adding a 'Copy Relative Path' option to the context menu for both files and directories. This feature streamlines workflows by enabling users to effortlessly obtain file paths relative to the project's root, enhancing navigation and referencing within the application. The implementation includes comprehensive logic for path calculation and full internationalization support.

Highlights

  • New Feature: Copy Relative Path: A new context menu option 'Copy Relative Path' has been added, allowing users to quickly copy the relative path of files and folders to the clipboard.
  • Relative Path Calculation Logic: Implemented robust logic within openFolder.js to calculate the relative path of a selected item based on its root URL, including a fallback mechanism for different URL structures.
  • Internationalization Support: Added the 'copy relative path' string to numerous language translation files (src/lang/*.json) to ensure the new feature is localized across all supported languages.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a 'Copy Relative Path' feature to the context menu for files and folders. The implementation adds the necessary UI strings and the core logic in openFolder.js. The changes are mostly good, but I have a few suggestions for improvement.

My review focuses on:

  • A potential bug in the relative path calculation logic.
  • Improving user feedback messages to be more specific and localized.
  • Providing missing translations for the new UI string.

Overall, this is a great addition to the application's functionality.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

This PR adds a new "Copy Relative Path" feature to the file explorer context menu, allowing users to copy the relative path of files and folders to the clipboard. The implementation includes:

  • New context menu option: Added COPY_RELATIVE_PATH menu item for both files and directories in the file explorer
  • Core implementation: New copyRelativePath() function in src/lib/openFolder.js that:
    • Calculates the relative path from the root folder to the selected item
    • Uses Url.pathname() to extract paths from protocol-based URLs, then Path.convertToRelative() to compute the relative path
    • Includes fallback logic using string manipulation when pathname extraction fails
    • Copies the result to clipboard via the Cordova clipboard plugin
    • Shows appropriate success/error messages
  • Localization: Added "copy relative path" translation string to all 31 language files (currently untranslated, showing "Copy Relative Path" in English across all locales)

The feature integrates cleanly with the existing context menu system and follows established patterns in the codebase for clipboard operations.

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations for edge case handling and translation consistency
  • The implementation follows existing patterns in the codebase and includes proper error handling, validation, and fallback logic. The feature is well-isolated and adds functionality without modifying existing behavior. Minor points of attention include the fallback path calculation logic and the fact that translations remain in English for all locales.
  • No files require special attention - the implementation is straightforward and follows established patterns

Important Files Changed

Filename Overview
src/lib/openFolder.js Added copyRelativePath function with proper validation and fallback logic for calculating relative paths between root and target URLs
src/lang/en-us.json Added "copy relative path" translation string for English locale
src/lang/de-de.json Added "copy relative path" translation string (untranslated, kept as English)

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextMenu as Context Menu
    participant execOperation
    participant copyRelativePath
    participant Url
    participant Path
    participant Clipboard as Cordova Clipboard

    User->>ContextMenu: Right-click file/folder
    ContextMenu->>execOperation: "copy-relative-path" action
    execOperation->>copyRelativePath: Call copyRelativePath()
    
    copyRelativePath->>copyRelativePath: Validate url and rootUrl
    
    alt Both URLs have pathnames
        copyRelativePath->>Url: pathname(rootUrl)
        Url-->>copyRelativePath: rootPath
        copyRelativePath->>Url: pathname(url)
        Url-->>copyRelativePath: targetPath
        copyRelativePath->>Path: convertToRelative(rootPath, targetPath)
        Path-->>copyRelativePath: relativePath
    else Fallback: pathname extraction fails
        copyRelativePath->>copyRelativePath: Clean trailing slashes
        alt Target starts with root
            copyRelativePath->>copyRelativePath: Slice root from target
        else Not a child path
            copyRelativePath->>Url: basename(url)
            Url-->>copyRelativePath: relativePath
        end
    end
    
    copyRelativePath->>Clipboard: copy(relativePath)
    copyRelativePath->>User: toast("Relative path copied")
Loading

@bajrangCoder bajrangCoder merged commit 3d0b714 into Acode-Foundation:main Feb 2, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the feature/copy-relative-path branch February 2, 2026 03:23
@Victozee26
Copy link

thanks 🙏

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

Labels

enhancement New feature or request translations Anything related to Translations Whether a Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add copy path related to current open file

2 participants