Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

cody: add cody.enabled flag to site-config, simplify others#52919

Merged
eseliger merged 22 commits into
mainfrom
mrn/cody-enabled-flag
Jun 13, 2023
Merged

cody: add cody.enabled flag to site-config, simplify others#52919
eseliger merged 22 commits into
mainfrom
mrn/cody-enabled-flag

Conversation

@mrnugget

@mrnugget mrnugget commented Jun 5, 2023

Copy link
Copy Markdown
Contributor

Context: proposal in Cody feature flag in 5.1

Fixes a lot of things on this ticket: https://github.com/sourcegraph/sourcegraph/issues/52980

This adds

  • cody.enabled to site-config flag, default false
  • cody.restrictUsersFeatureFlag to site-config, default false

It changes

  • cody.IsEnabled() to check cody.enabled and whether completions exists, not completions.enabled anymore
  • client.GetCompletionsConfig to prefer cody.enabled over completions.Enabled but respect old value
  • feature flag used by cody.restrictUsersFeatureFlag from cody-experimental to cody
  • completions handler to check whether cody is enabled and only then check config
  • ping data to send value of conf.CodyEnabled() which checks that Cody is enabled through cody.enabled == true && completions != nil

It removes

  • experimentalFeatures.CodyRestrictUsersFeatureFlag in favor of cody.restrictUsersFeatureFlag

It deprecates

  • completions.enabled field, in favor of cody.enabled

Test plan

  • Manual testing

@sourcegraph-bot

sourcegraph-bot commented Jun 6, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@mrnugget mrnugget force-pushed the mrn/cody-enabled-flag branch from e1c58a4 to d3587f5 Compare June 6, 2023 10:56
Comment thread client/web/src/cody/useIsCodyEnabled.tsx Outdated
Comment thread schema/site.schema.json Outdated

@bobheadxi bobheadxi Jun 6, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of removing this entirely, can we infer cody.enabled = completions.enabled and mark this old configuration as deprecated? This way when we upgrade an instance, Cody won't be momentarily disabled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This way when we upgrade an instance, Cody won't be momentarily disabled

How many customers are affected by this? And with "momentarily" you mean the time between "upgraded" and "admin added cody.enabled", right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And with "momentarily" you mean the time between "upgraded" and "admin added cody.enabled", right?

Yep!

How many customers are affected by this?

This is pretty surprisingly high number for me but we have 32 Cloud customers with Cody enabled that may all be affected by this change:

$ mi2 instance list -expr 'Spec.Application.Cody?.Enabled == true' | jq length             
32

Comment thread schema/site.schema.json Outdated
Comment on lines 2323 to 2332

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be nested? e.g.

cody {
  enabled
  restrictUsersFeatureFlag
}

this could be convenient for grouping Cody-related config

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I personally think top-level fields are easier to manage than nested ones and I'm also copying relatively recent additions to site-config like these:

https://github.com/sourcegraph/sourcegraph/blob/d3587f514877cf957a5c0a36494bcfc8125b550f/schema/site.schema.json#L644-L715

Because the case I want to optimize for is

{
  "cody.enabled": true
}

That seems much nicer to me (I know: hard arguments here) than:

{
  "cody": {
    "enabled": true
  }
}

(If we had a webform instead of a JSON editor and people wouldn't have to edit this manually, that's fine)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair enough, we have precedence for both :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Potential downside I've seen is that sometimes customer's don't sort the keys alphabetically so in a large site config, at a glance it's easy to miss that some facet of a particular group of config is set/not set

@abeatrix abeatrix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested with the changes from the client PR and confirmed it works as expected:
When Cody is not enabled (site-config does not have cody.enabled):
image

When Cody is enabled (set cody.enabled to true in site-config):
image

mrnugget added 13 commits June 7, 2023 08:25
This adds

- `cody.enabled` to site-config flag, default false
- `cody.restrictUsersFeatureFlag` to site-config, default false

It changes

- `cody.IsEnabled` to check `cody.enabled` and *not* `completions.enabled` anymore
- feature flag used by `cody.restrictUsersFeatureFlag` from `cody-experimental` to `cody`
- completions handler to check whether cody is enabled and only then check config

It removes

- `experimentalFeatures.CodyRestrictUsersFeatureFlag` in favor of `cody.restrictUsersFeatureFlag`
- `completions.enabled` field, in favor of `cody.enabled`
@mrnugget mrnugget force-pushed the mrn/cody-enabled-flag branch from d3587f5 to d1a8981 Compare June 7, 2023 06:26
@eseliger eseliger merged commit d3db8c4 into main Jun 13, 2023
@eseliger eseliger deleted the mrn/cody-enabled-flag branch June 13, 2023 13:29
ErikaRS pushed a commit that referenced this pull request Jun 22, 2023
Context: proposal in [Cody feature flag in
5.1](https://docs.google.com/document/d/1syg64zhUapagA1c8YVO7v4_EUI_m583C39UeRNcCJ3k/edit#)

Fixes a lot of things on this ticket:
https://github.com/sourcegraph/sourcegraph/issues/52980

This adds
- `cody.enabled` to site-config flag, default false
- `cody.restrictUsersFeatureFlag` to site-config, default false

It changes

- `cody.IsEnabled()` to check `cody.enabled` and whether `completions`
exists, **not** `completions.enabled` anymore
- `client.GetCompletionsConfig` to prefer `cody.enabled` over
`completions.Enabled` but respect old value
- feature flag used by `cody.restrictUsersFeatureFlag` from
`cody-experimental` to `cody`
- completions handler to check whether cody is enabled and only then
check config
- ping data to send value of `conf.CodyEnabled()` which checks that Cody
is enabled through `cody.enabled == true && completions != nil`

It removes
- `experimentalFeatures.CodyRestrictUsersFeatureFlag` in favor of
`cody.restrictUsersFeatureFlag`

It deprecates
- `completions.enabled` field, in favor of `cody.enabled`

## Test plan

- Manual testing

---------

Co-authored-by: Erik Seliger <erikseliger@me.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants