Skip to content

Test contributing timeline providers with paging from extensions #91330

Closed

Description

@eamodio

Refs: #84297

Complexity: 4


Similar to #89385.

Extensions can now contribute timeline providers to show time-series information in a new Timeline view in the Explorer sidebar.

Develop an extension that can contribute a TimelineProvider to provide time-series information given a Uri. Here is an example provider.

Here is the current API declarations:

//#region eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
export class TimelineItem {
/**
* A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
*/
timestamp: number;
/**
* A human-readable string describing the timeline item.
*/
label: string;
/**
* Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
*
* If not provided, an id is generated using the timeline item's timestamp.
*/
id?: string;
/**
* The icon path or [ThemeIcon](#ThemeIcon) for the timeline item.
*/
iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
/**
* A human readable string describing less prominent details of the timeline item.
*/
description?: string;
/**
* The tooltip text when you hover over the timeline item.
*/
detail?: string;
/**
* The [command](#Command) that should be executed when the timeline item is selected.
*/
command?: Command;
/**
* Context value of the timeline item. This can be used to contribute specific actions to the item.
* For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context`
* using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`.
* ```
* "contributes": {
* "menus": {
* "timeline/item/context": [
* {
* "command": "extension.copyCommitId",
* "when": "timelineItem == commit"
* }
* ]
* }
* }
* ```
* This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`.
*/
contextValue?: string;
/**
* @param label A human-readable string describing the timeline item
* @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
*/
constructor(label: string, timestamp: number);
}
export interface TimelineChangeEvent {
/**
* The [uri](#Uri) of the resource for which the timeline changed.
* If the [uri](#Uri) is `undefined` that signals that the timeline source for all resources changed.
*/
uri?: Uri;
/**
* A flag which indicates whether the entire timeline should be reset.
*/
reset?: boolean;
}
export interface Timeline {
readonly paging?: {
/**
* A set of provider-defined cursors specifing the range of timeline items returned.
*/
readonly cursors: {
readonly before: string;
readonly after?: string
};
/**
* A flag which indicates whether there are more items that weren't returned.
*/
readonly more?: boolean;
}
/**
* An array of [timeline items](#TimelineItem).
*/
readonly items: readonly TimelineItem[];
}
export interface TimelineOptions {
/**
* A provider-defined cursor specifing the range of timeline items that should be returned.
*/
cursor?: string;
/**
* A flag to specify whether the timeline items being requested should be before or after (default) the provided cursor.
*/
before?: boolean;
/**
* The maximum number or the ending cursor of timeline items that should be returned.
*/
limit?: number | string;
}
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<Timeline>;
}
export namespace workspace {
/**
* Register a timeline provider.
*
* Multiple providers can be registered. In that case, providers are asked in
* parallel and the results are merged. A failing provider (rejected promise or exception) will
* not cause a failure of the whole operation.
*
* @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
* @param provider A timeline provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
}
//#endregion
)

  • For now, only test with 1 provider at a time because there are many known issues with multiple providers and paging. You can use the timeline.excludeSources setting to filter out the git-history source
  • Implement paging in the provider
  • Make sure there is a command contributed to each timeline item for the on click action.
  • Contribute a command to the timeline/item/context for specific timeline items
  • Try updating provider data after initial load (using onDidChange) and ensure the view is updated

Activity

  1. alexr00 commented on Feb 25, 2020

    @alexr00
    Member

    Blocked testing on #91400

  2. weinand commented on Feb 26, 2020

    @weinand
    Contributor

    Eric Amodio (@eamodio) same here, I cannot get my timeline items to show up. Please advise.

  3. eamodio commented on Feb 26, 2020

    @eamodio
    ContributorAuthor

    Andre Weinand (@weinand) Ensure you are returning a Timeline interface out of the provideTimeline method, since that seemed like it was the issue Alex was having.

  4. connor4312 commented on Feb 27, 2020

    @connor4312
    Member

    Started playing around with it, will finish my testing in the morning

  5. removed their assignment
    on Feb 27, 2020
  6. locked and limited conversation to collaborators on Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions