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

remove Cody "upsells"—and all Cody links if Cody is disabled #63430

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

sqs
Copy link
Member

@sqs sqs commented Jun 22, 2024

At a high level, we don't want to show annoying ads/upsells for Cody that are not useful. And if Cody is disabled, we don't want to show any links to Cody.

Detailed desired behavior

  • Dotcom
    • Navbar
      • Unauthed: "Cody" single link to /cody (marketing page)
      • Authed: "Cody" dropdown with "Dashboard" (/cody/manage) and "Chat" (/cody/chat)
    • Routes
      • /cody: always the marketing page
      • /cody/manage: requires sign-in, shows Cody PLG subscription status for the user (Free plan is auto-opted-into by default)
      • /cody/chat: requires sign-in
  • Enterprise with Cody enabled on instance
    • Navbar
      • Cody NOT enabled for current user: "Cody" single link to /cody/dashboard
      • Cody enabled for current user: "Cody" dropdown with "Dashboard" (/cody/manage) and "Chat" (/cody/chat)
    • Routes
      • /cody: this link should not be present anywhere, but redirect to /cody/dashboard
      • /cody/manage: informational page, with editor/web links for Cody-enabled users and a "contact admin to get access" message for Cody-disabled users
      • /cody/chat: chat for Cody-enabled users, redirect to /cody/manage for Cody-disabled users
  • Enterprise with Cody NOT enabled on instance ("cody.enabled": false in site config)
    • Navbar: no Cody link or dropdown
    • Routes: all Cody routes 404
  • All
    • Do not show a Cody upsell on the /search page

This is an example of what we will KEEP for users on instances with Cody enabled but who do not themselves yet have access to Cody. This is useful because it informs users how to get access to Cody, and presumably their site admin wants people to request it who want to use it.

image

Fixes https://linear.app/sourcegraph/issue/SRCH-529/hide-cody-ai-tab-and-cody-upsell-if-cody-is-not-enabled

Unexpected code changes needed

This ended up being a much bigger change than I expected because I found error-prone code that needed cleaning up:

  • Improve how we determine if Cody is enabled in the frontend code. Previously, we checked the license features in some places, cody.enabled site config in others, and the user's current RBAC permissions for Cody in yet others. The most error-prone was checking the license features, since a license may entitle the instance to Cody but the site admin may still choose to disable it. There were no places in the frontend code where checking the license's entitlements was actually correct, so I changed everything to checking either window.context.codyEnabledOnInstance or window.context.codyEnabledForCurrentUser.
  • Did the same for window.context.codeSearchEnabledOnInstance for symmetry.
  • Removed "helper" functions that just checked 1 or 2 boolean values on window.context related to this, in favor of accessing window.context directly. Globals aren't great, and we should use React context or something similar, but now that the JSContext has the right fields (i.e., enabled instead of licensed), it's simpler and there is no need for helper functions.
  • Removed prop drilling of the licenseFeatures that was unnecessary since these values are available in globals and were being set from globals at some arbitrary point in the React component hierarchy anyway.
  • Updated the GlobalNavbar test snapshots.

Test plan

Run in 3 modes: (1) dotcom mode, (2) "cody.enabled": false in site config, (3) normal sg start.

Changelog

  • When Cody is disabled in site config (with "cody.enabled": false), all links and UI elements about Cody are hidden from all users. Previously, when Cody was disabled, users would see some links informing them about Cody.

@cla-bot cla-bot bot added the cla-signed label Jun 22, 2024
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 4 times, most recently from e376594 to 8d5e64e Compare June 23, 2024 20:49
@sqs sqs changed the base branch from main to sqs/single-program-dev June 24, 2024 04:40
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 2 times, most recently from 616db65 to cd03c32 Compare June 24, 2024 05:50
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 2 times, most recently from 75e44f2 to 5774fc0 Compare June 24, 2024 17:12
@sqs sqs force-pushed the sqs/single-program-dev branch 3 times, most recently from 8290bf0 to e263029 Compare June 24, 2024 21:08
Base automatically changed from sqs/single-program-dev to main June 24, 2024 21:12
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 2 times, most recently from 639a1b6 to 76406c3 Compare June 25, 2024 22:04
@sqs sqs changed the title remove Cody empty state "upsells" if Cody is disabled remove Cody "upsells"—and all Cody links if Cody is disabled Jun 26, 2024
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 3 times, most recently from 38822ce to 7e2c6e6 Compare June 26, 2024 00:51
@sqs sqs marked this pull request as ready for review June 26, 2024 00:51
@sqs sqs requested a review from a team June 26, 2024 00:52
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 3 times, most recently from 3266452 to a4e7dd7 Compare June 26, 2024 04:48
client/web/src/cody/CodyPage.tsx Outdated Show resolved Hide resolved
@sqs sqs force-pushed the sqs/rm-cody-upsell branch 6 times, most recently from a93139d to 9af69c0 Compare June 27, 2024 05:08
@sqs sqs enabled auto-merge (squash) June 27, 2024 05:16
At a high level, we don't want to show annoying ads/upsells for Cody that are not useful. And if Cody is disabled, we don't want to show *any* links to Cody.

- Dotcom
  - Navbar
    - Unauthed: "Cody" single link to /cody (marketing page)
    - Authed: "Cody" dropdown with "Dashboard" (/cody/manage) and "Chat" (/cody/chat)
  - Routes
    - /cody: always the marketing page
    - /cody/manage: requires sign-in, shows Cody PLG subscription status for the user (Free plan is auto-opted-into by default)
    - /cody/chat: requires sign-in
- Enterprise with Cody enabled on instance
  - Navbar
    - Cody NOT enabled for current user: "Cody" single link to /cody/dashboard
	- Cody enabled for current user: "Cody" dropdown with "Dashboard" (/cody/manage) and "Chat" (/cody/chat)
  - Routes
    - /cody: this link should not be present anywhere, but redirect to /cody/dashboard
	- /cody/manage: informational page, with editor/web links for Cody-enabled users and a "contact admin to get access" message for Cody-disabled users
	- /cody/chat: chat for Cody-enabled users, redirect to /cody/manage for Cody-disabled users
- Enterprise with Cody NOT enabled on instance (`"cody.enabled": false` in site config)
  - Navbar: no Cody link or dropdown
  - Routes: all Cody routes 404

This is an example of what we will KEEP for users on instances with Cody enabled but who do not themselves yet have access to Cody. This is useful because it informs users how to get access to Cody, and presumably their site admin wants people to request it who want to use it.

![image](https://github.com/sourcegraph/sourcegraph/assets/1976/c2adb086-44ec-4240-ad44-95981763fb72)

Fixes https://linear.app/sourcegraph/issue/SRCH-529/hide-cody-ai-tab-and-cody-upsell-if-cody-is-not-enabled

This ended up being a much bigger change than I expected because I found error-prone code that needed cleaning up:

- Improve how we determine if Cody is enabled in the frontend code. Previously, we checked the license features in some places, `cody.enabled` site config in others, and the user's current RBAC permissions for Cody in yet others. The most error-prone was checking the license features, since a license may entitle the instance to Cody but the site admin may still choose to disable it. There were no places in the frontend code where checking the license's entitlements was actually correct, so I changed everything to checking either `window.context.codyEnabledOnInstance` or `window.context.codyEnabledForCurrentUser`.
- Did the same for `window.context.codeSearchEnabledOnInstance` for symmetry.
- Removed "helper" functions that just checked 1 or 2 boolean values on `window.context` related to this, in favor of accessing `window.context` directly. Globals aren't great, and we should use React context or something similar, but now that the JSContext has the right fields (i.e., enabled instead of licensed), it's simpler and there is no need for helper functions.
- Removed prop drilling of the `licenseFeatures` that was unnecessary since these values are available in globals and were being set from globals at some arbitrary point in the React component hierarchy anyway.
- Updated the GlobalNavbar test snapshots.

Run in 3 modes: (1) dotcom mode, (2) `"cody.enabled": false` in site config, (3) normal `sg start`.

- When Cody is disabled in site config (with `"cody.enabled": false`), all links and UI elements about Cody are hidden from all users. Previously, when Cody was disabled, users would see some links informing them about Cody.
@sqs sqs merged commit 0021f95 into main Jun 27, 2024
15 checks passed
@sqs sqs deleted the sqs/rm-cody-upsell branch June 27, 2024 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants