Repository navigation
Closed
Labels
Description
Testing #93820
export interface Timeline {
readonly paging?: {
/**
* A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
* Use `undefined` to signal that there are no more items to be returned.
*/
readonly cursor: string | undefined;
}
/**
* An array of [timeline items](#TimelineItem).
*/
readonly items: readonly TimelineItem[];
}It seems to me the paging API is not obvious and standard. AFIK following is common pattern for paging
- client asks the server to give me collection of data in pages and gives the pageSize and the index or some identity from which it wants the data
- Server returns the result from the requested index or identity and of requested size.
This API is other way around. Extension(server) defined the pageSize and returns to VS Code (client) the cursor/index/identity. VS Code keeps asking the extension using this cursor. How can extension knows the good number pageSize?
Any reasoning behind flipping this?
Recommendation:
export interface TimelineOptions {
/**
* Return all timeline items newer (exclusive) than the given id
* If `undefined` return starting from latest
*/
from?: string;
/**
* An optional maximum number timeline items to be returned
* If `undefined` all timeline items should be returned.
*/
pageSize?: number;
}
export interface TimelineProvider {
/**
* An optional event to signal that the timeline for a source has changed.
* To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`.
*/
onDidChange?: Event<TimelineChangeEvent>;
/**
* An identifier of the source of the timeline items. This can be used to filter sources.
*/
readonly id: string;
/**
* A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources.
*/
readonly label: string;
/**
* Provide [timeline items](#TimelineItem) for a [Uri](#Uri).
*
* @param uri The [uri](#Uri) of the file to provide the timeline for.
* @param options A set of options to determine how results should be returned.
* @param token A cancellation token.
* @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result
* can be signaled by returning `undefined`, `null`, or an empty array.
*/
provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<TimelineItem>;
}Also make id property of the timeline item mandatory
Activity
eamodio commentedon Apr 7, 2020
Sandeep Somavarapu (@sandy081) I don't see how this is flipped. The extension is the "server" and VS Code is the "client". VS Code asks the extension via
provideTimeline(options). TheTimelineOptions.cursoris the starting point to get from (orundefinedto start at the most recent), while theTimelineOptions.limitis the page size, and then the extension returns the items and if paging is supported apagingobject which contains the cursor to the next set of items.So in your suggestion:
fromis equivalent tocursor, except thatcursoris provider-independent, to make it more flexible in case a provider can't query by specific "ids"pageSizeis equivalent tolimit, except thatlimitadditionally allows querying up to a specific id or timestamp -- which is required for a timeline source like our Git provider because the timeline itself is mutablesandy081 commentedon Apr 7, 2020
Because it is not clear that limit is the page size. I could implement to return a page of elements whose size is less than limit and give my cursor. It would be clear if limit is called pageSize so that I return exactly that number of elements and client can assume that if returned elements are less than pageSize ignore the from (cursor/index).
Yes. I would like to simply follow the general paging semantics ie., pageSize & from. It is up to us to define the semantics of
from. To be simple, I would callfromas from last returned timeline item's id. Make timeline item id mandatory and it is up to the provider to use either timestamp or commit id or other unique value as id.I would not marry query parameters and pageSize into single property. Keeping them separate makes it easier to understand and also to implement.
github-actions commentedon Apr 14, 2020
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!