Skip to content

Commands "Add File to Cody", "Add Selection to Cody" and shallow folder #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 3, 2025

Conversation

Yandrik
Copy link
Contributor

@Yandrik Yandrik commented Oct 29, 2024

Just like the title sais, this is what the new features do.

Add File to Cody

Does the same thing as Add Folder to Cody, just for files
image

Add Selection to Cody

Select some files with ctrl+mouse1, right-click on the selection and run the command, and all files and folders that are selected will be added to Cody
image

Problems

Currently, when >1 file is selected, the "add selection" command always shows up in the right click menu. When run on a file that isn't in the selection, it adds only that file, nothing else. I haven't found a way to prevent it from showing up in that situation :/

@Yandrik
Copy link
Contributor Author

Yandrik commented Oct 29, 2024

Also contains adding shallow directory together with non-shallow directory now, so will close #2

@Yandrik Yandrik changed the title Commands "Add File to Cody" and "Add Selection to Cody" Commands "Add File to Cody", "Add Selection to Cody" and shallow folder Oct 29, 2024
@mnismt
Copy link
Owner

mnismt commented Jan 1, 2025

Thank for the PR @Yandrik. Will review it later

Copy link
Owner

@mnismt mnismt left a comment

Choose a reason for hiding this comment

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

Hi @Yandrik , happy new year!

Forgive me for the late review, I think overall this PR is good, thanks for your contribution 🚀

Just left some thoughts and modifications to make it more intuitive. Feel free to discuss!

package.json Outdated
Comment on lines 65 to 84
{
"command": "cody-plus-plus.addFile",
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addSelection",
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addShallowFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
}
Copy link
Owner

@mnismt mnismt Jan 2, 2025

Choose a reason for hiding this comment

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

I think when users select multiple folders and files, we should show (only) Add Multiple Files option. This is likely their expected behavior.

CleanShot 2025-01-02 at 23 05 15

Also, we should hide the “Add File…” command when the user right-clicks on the folder (because it should only be used for adding individual files). We can achieve this by adding !explorerResourceIsFolder to the condition property.

CleanShot 2025-01-02 at 23 29 46

Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
{
"command": "cody-plus-plus.addFile",
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addSelection",
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addShallowFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
}
{
"command": "cody-plus-plus.addFile",
"when": "!explorerResourceIsFolder && !listMultiSelection && explorerViewletFocus && resourceLangId && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addSelection",
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addFolder",
"when": "!listMultiSelection && explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addShallowFolder",
"when": "!listMultiSelection && explorerResourceIsFolder && cody.activated",
"group": "0_cody"
}

Copy link
Contributor Author

@Yandrik Yandrik Jan 2, 2025

Choose a reason for hiding this comment

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

The add file change is a really good idea! I totally overlooked that :)

I think keeping the addFolder and addShallowFolder options available even when a user has selected some files can be useful. I've run into the situation of wanting to select multiple files for adding, but also adding a shallow folder multiple times (e.g. in a SvelteKit project I select the homepage and contact +page files and also shallow folder of contact page to e.g. better integrate it into the homepage. This will cause some dual selections, but that's fine as Cody internally dedups this)

Do you think that's reasonable, or not a good idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This suggestion keeps both folder and file adds in place even when right-clicking a selection. Not sure if that's a good idea, but I think it'll make Cody++ more flexible for several usecases

Suggested change
{
"command": "cody-plus-plus.addFile",
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addSelection",
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addShallowFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
}
{
"command": "cody-plus-plus.addFile",
"when": "!explorerResourceIsFolder && explorerViewletFocus && resourceLangId && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addSelection",
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
},
{
"command": "cody-plus-plus.addShallowFolder",
"when": "explorerResourceIsFolder && cody.activated",
"group": "0_cody"
}

Copy link
Owner

Choose a reason for hiding this comment

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

Can you maybe provide an example? I do not really get your use cases since both commands actually do not make any difference in my test video

CleanShot.2025-01-02.at.23.44.44.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Problems

Currently, when >1 file is selected, the "add selection" command always shows up in the right click menu. When run on a file that isn't in the selection, it adds only that file, nothing else. I haven't found a way to prevent it from showing up in that situation :/

That's also the issue I ran into before, and I didn't find any way to fix this. That's why I abandoned the "Add Selected Files" being only visible when actually clicking on a list - if there's already a file selected, then VSCode will consider any right-clicked file or folder to be part of that list, no matter what unfortunately.

I've spent quite a few hours to work around this, but never managed

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks, @PriNova for the ideas. Option 2 seems great, and I will implement it for the next version. @Yandrik, thank you for your contribution. I can take over from here, so feel free to leave your code, I will improve it later 🚀.

Copy link
Contributor Author

@Yandrik Yandrik Jan 2, 2025

Choose a reason for hiding this comment

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

Will do! 😄
Happy new year!

Copy link
Owner

@mnismt mnismt Jan 2, 2025

Choose a reason for hiding this comment

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

@Yandrik Got that! Also, can you leave your X account here? I can give you a shout out when I release a new version to acknowledge your contribution (if you feel okay with that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't actually have an X account ^^
If you want to mention me, just the GitHub username is just fine 😄 Thanks!

@mnismt mnismt assigned Yandrik and unassigned Yandrik Jan 2, 2025
@mnismt mnismt added the feature New feature or request label Jan 2, 2025
@mnismt mnismt added this to the v0.2.0 milestone Jan 2, 2025
@mnismt mnismt linked an issue Jan 3, 2025 that may be closed by this pull request
@jdorfman
Copy link

jdorfman commented Jan 6, 2025

Great work @mnismt @Yandrik !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants