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

batches: surface batch change rollout window in JSContext#50471

Merged
BolajiOlajide merged 4 commits into
mainfrom
bo/surface-rollout-window-config-js-context
Apr 12, 2023
Merged

batches: surface batch change rollout window in JSContext#50471
BolajiOlajide merged 4 commits into
mainfrom
bo/surface-rollout-window-config-js-context

Conversation

@BolajiOlajide

Copy link
Copy Markdown
Contributor

#48217 and #48963 require the batchChangesRolloutWindows configuration to be available in the frontend.
This PR surfaces the value via the jscontext object preloaded when the UI starts.

Test plan

  • Start up a Sourcegraph instance with sg start batches

  • If the rollout window is configured in the Site Config, then logging window.context should include the configured values in the batchChangesRolloutWindows field.
    CleanShot 2023-04-07 at 12 50 12@2x

  • If not, the value of batchChangesRolloutWindows will be null.
    CleanShot 2023-04-07 at 12 49 46@2x

@BolajiOlajide BolajiOlajide requested a review from a team April 7, 2023 11:53
@BolajiOlajide BolajiOlajide self-assigned this Apr 7, 2023
@cla-bot cla-bot Bot added the cla-signed label Apr 7, 2023
@BolajiOlajide BolajiOlajide force-pushed the bo/surface-rollout-window-config-js-context branch from f3185f4 to 7615738 Compare April 7, 2023 11:55
@sourcegraph-bot

sourcegraph-bot commented Apr 7, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 185c154...d6a939b.

No notifications.

@eseliger

eseliger commented Apr 7, 2023

Copy link
Copy Markdown
Member

The global jscontext is already super bloated, does it have to be in there or could we request it dynamically if the user visits a page that requires it?

@BolajiOlajide

Copy link
Copy Markdown
Contributor Author

The global jscontext is already super bloated, does it have to be in there or could we request it dynamically if the user visits a page that requires it?

I agree and I initially thought of requesting it via the GraphQL endpoint but I wasn't sure the tradeoff made sense.

We'll basically be making the Site query to get one field that'll be used in the User settings page and in the Batch Change details page.

@BolajiOlajide BolajiOlajide force-pushed the bo/surface-rollout-window-config-js-context branch from bb3fe6e to b64230c Compare April 12, 2023 09:19
@BolajiOlajide BolajiOlajide merged commit 3b1c5fc into main Apr 12, 2023
@BolajiOlajide BolajiOlajide deleted the bo/surface-rollout-window-config-js-context branch April 12, 2023 10:10
almeidapaulooliveira pushed a commit that referenced this pull request Apr 13, 2023
#48217 and #48963 require the `batchChangesRolloutWindows` configuration
to be available in the frontend.
This PR surfaces the value via the `jscontext` object preloaded when the
UI starts.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
* Start up a Sourcegraph instance with `sg start batches`
* If the rollout window is configured in the Site Config, then logging
`window.context` should include the configured values in the
`batchChangesRolloutWindows` field.
![CleanShot 2023-04-07 at 12 50
12@2x](https://user-images.githubusercontent.com/25608335/230604199-adecb401-29fe-4cd5-b94f-f4f5d7da157d.png)

* If not, the value of `batchChangesRolloutWindows` will be null.
![CleanShot 2023-04-07 at 12 49
46@2x](https://user-images.githubusercontent.com/25608335/230604227-c1013cf0-19a5-462f-81f9-20c5883e1f48.png)
cesrjimenez pushed a commit that referenced this pull request Apr 14, 2023
#48217 and #48963 require the `batchChangesRolloutWindows` configuration
to be available in the frontend.
This PR surfaces the value via the `jscontext` object preloaded when the
UI starts.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
* Start up a Sourcegraph instance with `sg start batches`
* If the rollout window is configured in the Site Config, then logging
`window.context` should include the configured values in the
`batchChangesRolloutWindows` field.
![CleanShot 2023-04-07 at 12 50
12@2x](https://user-images.githubusercontent.com/25608335/230604199-adecb401-29fe-4cd5-b94f-f4f5d7da157d.png)

* If not, the value of `batchChangesRolloutWindows` will be null.
![CleanShot 2023-04-07 at 12 49
46@2x](https://user-images.githubusercontent.com/25608335/230604227-c1013cf0-19a5-462f-81f9-20c5883e1f48.png)
@courier-new

Copy link
Copy Markdown
Contributor

Super delayed feedback here, but just wanted to share, I think I'd also prefer this sort of thing to come from the GraphQL API rather than the JSContext object. I don't believe we've explicitly stated guidance on this sort of thing anywhere, and this definitely isn't true for everything that's in there today, but generally I consider the things we put in JSContext to be:

  • critical to the frontend web client rendering properly on initial load
  • almost always able to be treated as a constant over the lifetime of the user visit

The fields like batchChangesEnabled, experimentalFeatures, and licenseInfo really exemplify this to me. batchChangesRolloutWindows may be safely treated as a constant, but I wouldn't consider it essential information to the frontend; it's possible a user who visits Sourcegraph never once visits a page where we even need to know that information. The main benefit to putting stuff here seems to be avoiding the network requests waterfall. Historically it probably also had the benefit of preventing redundant queries for something that was unchanging, but today we have the Apollo cache to mitigate that instead. This field on the site config could be safely requested in parallel, and I wouldn't expect it to require any dependent follow-up queries, so the anti-waterfalls benefit isn't really relevant. I'd also argue batchChangesDisableWebhooksWarning and batchChangesWebhookLogsEnabled don't belong here anymore, but I suspect they were added at a time when we didn't have good caching practices established. The GraphQL API provides better organization and predictability about this field, compared to the flat grab bag of keys in the JSContext, and it would allow us to defer requesting it until we're sure we even need it.

It's not a big deal to leave it here, just wanted to share my two cents since I realize this isn't a topic that's well documented (and I'll make a note to raise this as a topic in need of clearer guidance/explanation at frontend crew!!), but maybe it's worth filing an issue to refactor to a GraphQL query for a rainy day. Bonus points if we can update batchChangesDisableWebhooksWarning and batchChangesWebhookLogsEnabled, too. :)

@eseliger

Copy link
Copy Markdown
Member

Agree with Kelli here on the reasoning :)

@BolajiOlajide

Copy link
Copy Markdown
Contributor Author

Super delayed feedback here, but just wanted to share, I think I'd also prefer this sort of thing to come from the GraphQL API rather than the JSContext object. I don't believe we've explicitly stated guidance on this sort of thing anywhere, and this definitely isn't true for everything that's in there today, but generally I consider the things we put in JSContext to be:

  • critical to the frontend web client rendering properly on initial load
  • almost always able to be treated as a constant over the lifetime of the user visit

The fields like batchChangesEnabled, experimentalFeatures, and licenseInfo really exemplify this to me. batchChangesRolloutWindows may be safely treated as a constant, but I wouldn't consider it essential information to the frontend; it's possible a user who visits Sourcegraph never once visits a page where we even need to know that information. The main benefit to putting stuff here seems to be avoiding the network requests waterfall. Historically it probably also had the benefit of preventing redundant queries for something that was unchanging, but today we have the Apollo cache to mitigate that instead. This field on the site config could be safely requested in parallel, and I wouldn't expect it to require any dependent follow-up queries, so the anti-waterfalls benefit isn't really relevant. I'd also argue batchChangesDisableWebhooksWarning and batchChangesWebhookLogsEnabled don't belong here anymore, but I suspect they were added at a time when we didn't have good caching practices established. The GraphQL API provides better organization and predictability about this field, compared to the flat grab bag of keys in the JSContext, and it would allow us to defer requesting it until we're sure we even need it.

It's not a big deal to leave it here, just wanted to share my two cents since I realize this isn't a topic that's well documented (and I'll make a note to raise this as a topic in need of clearer guidance/explanation at frontend crew!!), but maybe it's worth filing an issue to refactor to a GraphQL query for a rainy day. Bonus points if we can update batchChangesDisableWebhooksWarning and batchChangesWebhookLogsEnabled, too. :)

As discussed, #51752 takes care of this and removes the rollout window configuration from JSContext.
Thank you all.

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.

5 participants