-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Add new exp TAS assignments endpoint (/api/v1/assignments) alongside legacy TAS #329653
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ import type { IExperimentationService as ITASExperimentationService } from 'vsco | |
| import { equals } from '../../../util/vs/base/common/arrays'; | ||
| import { IntervalTimer } from '../../../util/vs/base/common/async'; | ||
| import { Emitter } from '../../../util/vs/base/common/event'; | ||
| import { Disposable } from '../../../util/vs/base/common/lifecycle'; | ||
| import { Disposable, MutableDisposable, toDisposable } from '../../../util/vs/base/common/lifecycle'; | ||
| import { ICopilotTokenStore } from '../../authentication/common/copilotTokenStore'; | ||
| import { IConfigurationService } from '../../configuration/common/configurationService'; | ||
| import { IVSCodeExtensionContext } from '../../extContext/common/extensionContext'; | ||
|
|
@@ -124,9 +124,15 @@ export class BaseExperimentationService extends Disposable implements IExperimen | |
| private readonly _refreshTimer = this._register(new IntervalTimer()); | ||
| private readonly _previouslyReadTreatments = new Map<string, boolean | string | number | undefined>(); | ||
|
|
||
| protected readonly _delegate: ITASExperimentationService; | ||
| protected _delegate: ITASExperimentationService; | ||
| protected readonly _userInfoStore: UserInfoStore; | ||
|
|
||
| /** Disposes the current delegate (stopping its polling); auto-disposes the previous one on replacement. */ | ||
| private readonly _delegateDisposable = this._register(new MutableDisposable()); | ||
|
|
||
| private readonly _delegateFn: TASClientDelegateFn; | ||
| private readonly _globalState: vscode.Memento; | ||
|
|
||
| protected _onDidTreatmentsChange = this._register(new Emitter<TreatmentsChangeEvent>()); | ||
| readonly onDidTreatmentsChange = this._onDidTreatmentsChange.event; | ||
|
|
||
|
|
@@ -155,10 +161,26 @@ export class BaseExperimentationService extends Disposable implements IExperimen | |
| this._signalTreatmentsChangeEvent(); | ||
| }, 60 * 60 * 1000); | ||
|
|
||
| this._delegate = delegateFn(context.globalState, this._userInfoStore); | ||
| this._delegate.initialFetch.then(() => { | ||
| this._delegateFn = delegateFn; | ||
| this._globalState = context.globalState; | ||
| this._delegate = this._createDelegate(); | ||
| } | ||
|
|
||
| private _createDelegate(): ITASExperimentationService { | ||
| const delegate = this._delegateFn(this._globalState, this._userInfoStore); | ||
| this._delegateDisposable.value = toDisposable(() => (delegate as unknown as { dispose?(): void }).dispose?.()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI Review: |
||
| delegate.initialFetch.then(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI Review: When an endpoint change recreates the delegate, completion of the replacement's |
||
| this._logService.trace(`[BaseExperimentationService] Initial fetch completed`); | ||
| }); | ||
| return delegate; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a fresh delegate, disposing the previous one (stopping its polling). Used | ||
| * when inputs captured at delegate-creation time (e.g. the assignments endpoint) change. | ||
| */ | ||
| protected recreateDelegate(): void { | ||
| this._delegate = this._createDelegate(); | ||
| } | ||
|
|
||
| private _signalTreatmentsChangeEvent = () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,8 @@ class MockTASExperimentationService implements ITASExperimentationService { | |
| this.refreshCallCount = 0; | ||
| this.treatmentRequests = []; | ||
| } | ||
|
|
||
| dispose(): void { } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI Review: The production change adds endpoint-driven delegate replacement, disposal, and asynchronous initial-fetch behavior, but the only test update is this no-op method. Please add focused tests for late endpoint arrival/change, disposal of the old delegate, ignoring superseded fetch completion, and notifying treatment changes after the replacement fetch. |
||
| } | ||
|
|
||
| describe('ExP Service Tests', () => { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.