Skip to content
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

[Cody Ignore] Hook BaseCommandAction/doAction to consult Cody Ignore #1252

Closed
2 of 3 tasks
Tracked by #1242 ...
dominiccooney opened this issue Apr 1, 2024 · 1 comment
Closed
2 of 3 tasks
Tracked by #1242 ...
Assignees

Comments

@dominiccooney
Copy link
Contributor

dominiccooney commented Apr 1, 2024

src/main/kotlin/com/sourcegraph/cody/chat/actions/BaseCommandAction.kt needs to consult Cody Ignore rules (in sourcegraph/cody#3641) and display an error message when commands are disabled due to Cody Ignore.

@toolmantim 's input on the RFC:

Running a command on an ignored file

  • Ideal change: notification error message on command execution saying the repo is disabled for Cody

We should add BaseCommandAction fields/methods so we can name the action that has been disabled.

Per the P2 PRD requirement for commands, inform people that their Sourcegraph admin can set the Cody Ignore policy (in sourcegraph/docs#222)

Tasks

dominiccooney added a commit that referenced this issue Apr 24, 2024
…ting (#1340)

This adds some plumbing for Cody Ignore, and a way to interactively test
that locally in IntelliJ without admin access to a Sourcegraph instance.

- Adds Agent protocol stubs for Cody Ignore protocol. These depend on
Agent-side changes in sourcegraph/cody#3858
- Adds an "internals" menu to the status bar, hidden behind a feature
flag, for doing ad-hoc manual ignore policy settings

Part of #1252

## Test plan

- Run agent with sourcegraph/cody#3858
- Run the plugin with
`CODY_JETBRAINS_FEATURES=cody.feature.internals-menu=true` and open a
clone of the sourcegraph/sourcegraph repo
- On the status bar, Internals, Testing: Cody Ignore
- Check *Override policy for testing*
- Enter URI regex `\.go$` . Any repo regex is fine; that setting is
currently unused on the extension side. Click OK.
- Verify that console output includes `handling ignore rules changing
not yet implemented`. This indicates the testing override generated a
notification that the rules have changed, through to the stub in the
extension.
- Start a chat
- In the Enhanced Context Selector, ensure *Chat Context* is checked.
Uncheck any specific repos.
- Open a Go file, for example `cmd/batcheshelper/main.go` and highlight
some code
- In chat, ask Cody "what does this do?" There should be *no local
context* and Cody should make something up unrelated to the highlighted
code.
- On the status bar, Internals, Testing: Cody Ignore. Uncheck *Override
policy for testing*. OK. Again verify console output.
- In chat, hit up and resubmit the same chat message. There should be
local context from the open Go file and Cody should comment related to
that code.
- Run the plugin again *without*
`CODY_JETBRAINS_FEATURES=cody.feature.internals-menu=true` and verify
that the Internals menu does not appear on the status bar.
dominiccooney added a commit that referenced this issue Apr 25, 2024
…th ignored status (#1379)

This change is integrated through Agent, but the extension side is not
integrated with server-set policy yet. Instead, this change uses a
testing hook which pushes an ad-hoc policy to the extension—see the test
plan.

As a result, this does not cause any user visible change for Enterprise
users yet. For self-serve users of the experimental file-based Cody
Ignore feature, this UX may trigger until extension-side integration is
complete. However we have determined that to be very few users.

Exact UX is still being designed. These labels and icons are
placeholders.

Part of #1252, #1253.

## Test plan

Tested manually:

1. Run the extension with
`CODY_JETBRAINS_FEATURES=cody.feature.internals-menu=true` and open some
files, say `Foo.java` and `Bar.go`
2. Status bar, Internals, Testing: Cody Ignore
3. Check "Override policy for testing", set URI regex to `\.java$`. OK.
4. Verify that a banner appears in `Foo.java` but not `Bar.go`.
5. Run a command like Explain Code with the right click context menu and
verify that a notification appears
6. Run a command like Explain Code with a keyboard shortcut like
ctrl-shift-E and verify that a notification appears
7. Verify when focus switches from `Foo.java` to `Bar.go`, a slashed
Cody icon appears in the status bar when an ignored file is focused.
dominiccooney added a commit that referenced this issue Apr 26, 2024
…ide syntax (#1396)

Fixes #1393

Part of #1252 #1253

Depends on sourcegraph/cody#3946

## Test plan

Tested manually:

1. Run the extension with
`CODY_JETBRAINS_FEATURES=cody.feature.internals-menu=true` and open the
sourcegraph/sourcegraph repo.
2. Status bar, Internals, Testing: Cody Ignore
3. Check "Override policy for testing". OK.
4. Verify that no banners appear
5. Change the policy from excluding `...sourcegraph/cody` to
`...sourcegraph/sourcegraph`
6. Verify that banners appear on open editors
7. Run a command like Explain Code with the right click context menu and
verify that a notification appears
8. Run a command like Explain Code with a keyboard shortcut like
ctrl-shift-E and verify that a notification appears
9. Verify when focus switches from a file within sourcegraph/sourcegraph
to a file outside it, a slashed Cody icon appears in the status bar when
an ignored file is focused.
10. Disable the policy override, verify that the banners/blocked
commands/etc. revert.
dominiccooney added a commit that referenced this issue May 2, 2024
…d button sidebar UX and sundry (#1432)

- Intercepts the manual autocomplete trigger and displays a notification
- Disables the buttons in the sidebar command tab when in an ignored
file
- Displays a banner in the sidebar command tab when in an ignored file
- No longer displays banners on individual editors
- Notification text, tooltip text has been updated to match latest UX
proposal

https://www.loom.com/share/3a417616ef4f4701ac0e02bcc0c61e64

Part of #1252, #1256

Closes #1253

## Test plan

Manually tested:

- Run plugin with environment
`CODY_JETBRAINS_FEATURES=cody.feature.internals-menu=true`
- Use status bar, Internals, Testing: Cody Ignore and change the policy
to match your repo, turn the policy override on.
- Check that autocomplete does not happen
- Check that the manual autocomplete trigger displays a notification
- Check that right click menu actions for Explain, Smell and "Test V1"
display a notification; same for their keyboard shortcuts
- Check that the buttons in the sidebar command tab are disabled and a
banner is displayed
- Check that the status bar Cody icon displays a slash and tooltip when
in an ignored file
- Check that all the above and UX affordances respond when the policy
changes (override off, different repo name, etc.)
@dominiccooney
Copy link
Contributor Author

Lacks Telemetry, but I will file a follow-up issue for all Cody Ignore Telemetry.

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

No branches or pull requests

3 participants