You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm filing this issue to track the finalization of the contribShareMenu API proposal since I was not able to find a tracking issue, cc Alex Ross (@alexr00).
Current state
The contribShareMenu API proposal tracks the following menu points:
file/share
editor/context/share
This proposal has been in place for several months without changes, and was previously discussed in #146309 and #157722, but has not yet been finalized. This means it can't yet be used by most extensions, limiting its utility. An example of an extension that IMO would be a great fit for the Share submenus is Live Share (cc jram (@jramsay)):
Additional share submenus
As part of #175676 I'm looking at integrating link sharing more deeply into our product surface area, with the goal of making collaboration via links as seamless as possible. Therefore I'm proposing to expand this API proposal to also include
editor/title/context/share
explorer/context/share
(Note, there is also editor/lineNumber/context via #175945, but I have not added a share submenu for that context menu yet because we are introducing that context menu for the first time all up and it would be odd to only have one item in the menu which is itself a submenu.)
Joyce Er (@joyceerhl) One thing I just thought of: how do we support sharing documents from other views, such as the open editors view, or potentially even sharing from custom tree views, such as the Find All References view?
One option would be to create contribution points for each case. That would let extensions control where their menus show up, but would also require knowing about and adopting a lot of contribution points
Another option though would be to have a generic shareFile contribution point. This would let VS Code show these contributions in any places where we think a share menu makes sense. It would also let VS Code surface the share commands in other ways, such as a Share... command in the command palette
I believe we may have considered something similar last week. Were there any concerns about this approach?
The main issue that we discussed last week is that we don't want to show the same share actions everywhere, e.g. file/share has Export/Import Profile... which doesn't make sense in any of the other share submenus.
how do we support sharing documents from other views, such as the open editors view, or potentially even sharing from custom tree views, such as the Find All References view?
This is a really good point though. Having a single contribution point would allow us to avoid a continuous adoption cost across extensions anytime we introduce a new area in the product where sharing makes sense.
It would also let VS Code surface the share commands in other ways, such as a Share... command in the command palette
Brigit Murtaugh (@bamurtaugh) had a proposal to add a Share button next to the command center if that ever becomes default, and a single share contribution point would also support that scenario.
If we go with this approach, here is the work that I think should happen:
Introduce a shareResource contribution point (I think file might be a little too limiting, e.g. I have wanted to copy links to a specific folder or workspace as well). The contribution point would be responsible for creating share submenus in the following places and ensuring that the right context (both command args and when clauses via overlays) is passed to contributed actions:
editor/context
editor/title/context
editor/lineNumber/context
explorer/context
file/share
editor line number context in diff editors
open editors view
find all references view
SCM view resource state context
Keep file/share as a separate menu identifier for now, since at the moment that is the only menu where we want to show actions that wouldn't make sense in all the other cases that we are discussing)
Standardize what context gets passed to actions, should be one of:
{ uri: vscode.Uri }: indicates generating a link for just the resource but not including range/selection
{ uri: vscode.Uri, selections: vscode.Selection }: indicates generating a link for the resource and a specific selection
-if the start line and end line are the same or if the start and end line are off by 1 and the end column is 0, extensions should generate links for just one line
Peng Lyu (@rebornix) we had a related conversation around supporting links for notebooks, I think that maybe we want to support passing NotebookCell ranges as well?
undefined: command palette context
Adopt the share contribution in:
GitHub Repositories
GitHub Pull Requests
GitHub
Remove previous duplicated link code
Matt Bierner (@mjbvz) let me know if I missed anything or if you have other suggestions.
we need to perform the appropriate renderer <-> ext host type conversions for the arguments that we pass, e.g. an internal ISelection object needs to be properly transformed into a vscode.Selection object if it's being passed to the ext host
some of the views where we want to introduce share links in the context menu are actually controlled by extensions rather than core, in which case the context that gets passed is always the data model object of the corresponding extension and is not influenced by core:
references view
call hierarchy
scm view
timeline
the command/arg approach suffers from the problem that the extension never really knows what args it receives and there is no contract or explicit typing
In order to be able to provide a consistent context from both core and extension-controlled contexts--without layer breaking--to extensions which want to generate a shareable link, we may be better off with an explicit data provider api. Here is a sketch of how I think this would work:
extensions like builtin GitHub, GitHub Pull Requests, Remote Repositories, and Live Share would declare a share contribution in package.json
core would inline the contributed command into various menus where it makes sense
core and extensions would register SharableDataProviders for various sharable contexts
when an extension's share contribution is selected, core would first call a registered ShareableDataProvider capable of providing info about the sharable context
the context then gets passed to the extension to generate a link, start a collaboration session, etc
Currently we're most interested in sharing editor and view context, so here's a sketch of what that api could look like:
declare module 'vscode'{exportnamespacewindow{/** * * @param viewId The id of the view that the provider can share data about. * @param provider A provider that can generate {@link ShareableData} for the specified view. */exportfunctionregisterShareableTreeDataProvider(viewId: string,provider: ShareableTreeDataProvider): Disposable;/** * * @param document A selector for editors that the provider can share data about. * @param provider A provider that can generate {@link ShareableData} for the specified document. */exportfunctionregisterShareableDocumentDataProvider(document: DocumentSelector,provider: ShareableDocumentDataProvider): Disposable;}interfaceShareableTreeDataProvider{provideShareableData(context: TreeItem,token: CancellationToken): ProviderResult<ShareableData>;}interfaceShareableDocumentDataProvider{provideShareableData(context: DocumentSelector,token: CancellationToken): ProviderResult<ShareableData>;}interfaceShareableData{readonlyuri?: Uri;readonlyranges?: Range[];}}
Another option is to expand the existing TreeDataProvider to include a provideShareableData method:
/** * A data provider that provides tree data */exportinterfaceTreeDataProvider<T>{provideShareableData?(item: TreeItem,token: CancellationToken): ProviderResult<ShareableData>;}
Some additional limitations of the current implementation, which a central API would be able to address:
Each extension is responsible for writing share links to the clipboard, so they step on each other which prevents nice multiselect behavior
We have had to introduce multiple share submenus to each context menu that we want to surface Share actions in (to date: explorer/context, editor/context, editor/title/context, editor/lineNumber/context, file). We also want to add Share to more places, and since some of these places are extension-owned tree views and all places have different data object shapes, each extension which contributes a sharing link must deal with parsing different source data types, so the current approach doesn't scale:
References view
Search view
SCM view
Open editors view
We cannot support a top-level Share action since the actions are surfaced piecemeal by extensions to specific Share submenus
Basically what we need is API to support the ability to
Get a standard context object from extension-contributed tree views, whose tree item shapes are opaque to core (all other data objects can be handled by core)
Pass that context object to extensions which provide share actions
I spent some time looking at prior art (copy/paste and drag/drop controllers, which support performing actions relating to data transfer on both tree items and editor context). I learned that we use stringified URIs with line numbers in the fragment, which works well enough for text editors. Unfortunately we already support copying deeplinks to notebook cells, so this approach doesn't suffice for my scenario:
* To add a data transfer item that can be dragged into the editor, use the application specific mime type "text/uri-list".
* The data for "text/uri-list" should be a string with `toString()`ed Uris separated by newlines. To specify a cursor position in the file,
* set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
Here's my latest API proposal sketch:
/** * * An {@link TreeShareableResourceDataProvider} enables sharing tree items * which represent resources from extension-contributed tree views. */exportinterfaceTreeShareableResourceDataProvider<T>{/** * * @param source A tree item to provide shareable resource data for * @returns The underlying shareable resource data represented by the tree item */provideShareableResourceData(source: T,token: CancellationToken): ProviderResult<ShareableResourceData>;}exportinterfaceTreeViewOptions<T>{/** * * {@link TreeView}s can optionally specify a {@link TreeShareableResourceDataProvider} * to ensure that `Share` actions show up in the context menu for the {@link TreeView}. */shareableResourceDataProvider?: TreeShareableResourceDataProvider<T>;}/** * * To be implemented by: * 1. GHPRI * 2. RemoteHub * 3. Builtin GitHub extension * 4. MakeCode * 5. Live Share */exportinterfaceShareProvider{readonlyid: string;readonlylabel: string;/** * @param resourceData Data representing a shareable resource * @returns If applicable, a URI representing the shared resource, to be written to the clipboard */provideShareResource(resourceData: ShareableResourceData,token: CancellationToken): ProviderResult<Uri>;}/** * * Modeled after TabInputText__, TabInputNotebook__, etc. */exporttypeShareableResourceData=TextDocumentShareableData|NotebookDocumentShareableData;exportinterfaceTextDocumentShareableData{uri: Uri;selection: Range;}exportinterfaceNotebookDocumentShareableData{uri: Uri;selection: NotebookRange;}
Activity
joyceerhl commentedon Mar 7, 2023
Feedback from API sync:
file/shareincludes export/import profiles which wouldn't be relevant ineditor/context/shareeditor/title/context/shareorexplorer/context/share, waiting for more feedbackmjbvz commentedon Mar 14, 2023
Joyce Er (@joyceerhl) One thing I just thought of: how do we support sharing documents from other views, such as the open editors view, or potentially even sharing from custom tree views, such as the Find All References view?
One option would be to create contribution points for each case. That would let extensions control where their menus show up, but would also require knowing about and adopting a lot of contribution points
Another option though would be to have a generic
shareFilecontribution point. This would let VS Code show these contributions in any places where we think asharemenu makes sense. It would also let VS Code surface thesharecommands in other ways, such as aShare...command in the command paletteI believe we may have considered something similar last week. Were there any concerns about this approach?
joyceerhl commentedon Mar 14, 2023
The main issue that we discussed last week is that we don't want to show the same share actions everywhere, e.g.
file/sharehasExport/Import Profile...which doesn't make sense in any of the other share submenus.This is a really good point though. Having a single contribution point would allow us to avoid a continuous adoption cost across extensions anytime we introduce a new area in the product where sharing makes sense.
Brigit Murtaugh (@bamurtaugh) had a proposal to add a
Sharebutton next to the command center if that ever becomes default, and a single share contribution point would also support that scenario.If we go with this approach, here is the work that I think should happen:
shareResourcecontribution point (I thinkfilemight be a little too limiting, e.g. I have wanted to copy links to a specific folder or workspace as well). The contribution point would be responsible for creating share submenus in the following places and ensuring that the right context (both command args and when clauses via overlays) is passed to contributed actions:editor/contexteditor/title/contexteditor/lineNumber/contextexplorer/contextfile/sharefile/shareas a separate menu identifier for now, since at the moment that is the only menu where we want to show actions that wouldn't make sense in all the other cases that we are discussing){ uri: vscode.Uri }: indicates generating a link for just the resource but not including range/selection{ uri: vscode.Uri, selections: vscode.Selection }: indicates generating a link for the resource and a specific selection-if the start line and end line are the same or if the start and end line are off by 1 and the end column is 0, extensions should generate links for just one line
NotebookCellranges as well?undefined: command palette contextMatt Bierner (@mjbvz) let me know if I missed anything or if you have other suggestions.
joyceerhl commentedon Mar 16, 2023
Two more places that would be nice to have share menus in:
It should be possible to deeplink to a line in a file from the share actions for those views.
joyceerhl commentedon Mar 16, 2023
Johannes Rieken (@jrieken) and I discussed this and there are a few complications:
ISelectionobject needs to be properly transformed into avscode.Selectionobject if it's being passed to the ext hostIn order to be able to provide a consistent context from both core and extension-controlled contexts--without layer breaking--to extensions which want to generate a shareable link, we may be better off with an explicit data provider api. Here is a sketch of how I think this would work:
sharecontribution in package.jsonSharableDataProviders for various sharable contextssharecontribution is selected, core would first call a registeredShareableDataProvidercapable of providing info about the sharable contextCurrently we're most interested in sharing editor and view context, so here's a sketch of what that api could look like:
Another option is to expand the existing
TreeDataProviderto include aprovideShareableDatamethod:joyceerhl commentedon May 15, 2023
Some additional limitations of the current implementation, which a central API would be able to address:
sharesubmenus to each context menu that we want to surface Share actions in (to date: explorer/context, editor/context, editor/title/context, editor/lineNumber/context, file). We also want to add Share to more places, and since some of these places are extension-owned tree views and all places have different data object shapes, each extension which contributes a sharing link must deal with parsing different source data types, so the current approach doesn't scale:Basically what we need is API to support the ability to
I spent some time looking at prior art (copy/paste and drag/drop controllers, which support performing actions relating to data transfer on both tree items and editor context). I learned that we use stringified URIs with line numbers in the fragment, which works well enough for text editors. Unfortunately we already support copying deeplinks to notebook cells, so this approach doesn't suffice for my scenario:
vscode/src/vscode-dts/vscode.d.ts
Lines 10567 to 10569 in 06fc826
Here's my latest API proposal sketch:
14 remaining items
alexr00 commentedon Jun 27, 2023
Moving to July.