Change:
Testing I'm not sure why I have two entries for edit sessions and wonder if it came from another machine/sessions. It would be great to see some metadata about where the source is coming from, similar to the "Synced Data" view for Settings Sync. <img width="394" alt="CleanShot 2022-07-26 at 10 58 31 src="https://user-"<img width="373" alt="CleanShot 2022-07-26 at 11 00 07 src="https://user-"

Discussion:
import { isWeb } from 'vs/base/common/platform'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { Codicon } from 'vs/base/common/codicons'; <ins> import { IUserDataSyncMachinesService, UserDataSyncMachinesService } from 'vs/platform/userDataSync/common/userDataSyncMachines'; </ins> type ExistingSession = IQuickPickItem & { session: AuthenticationSession & { providerId: string } }; type AuthenticationProviderOption = IQuickPickItem & { provider: IAuthenticationProvider };

_serviceBrand = undefined; private serverConfiguration = this.productService['editSessions.store']; <del> private storeClient: UserDataSyncStoreClient | undefined; </del> <ins> private storeClient: EditSessionsStoreClient | undefined; private machineClient: IUserDataSyncMachinesService | undefined; </ins> #authenticationInfo: { sessionId: string; token: string; providerId: string } | undefined; private static CACHED_SESSION_STORAGE_KEY = 'editSessionAccountPreference';

throw new Error('Please sign in to store your edit session.'); } <ins> if (editSession.machine === undefined) { editSession.machine = await this.getOrCreateCurrentMachineId(); } </ins> return this.storeClient!.writeResource('editSessions', JSON.stringify(editSession), null, undefined, createSyncHeaders(generateUuid())); }

} if (!this.storeClient) { <del> this.storeClient = new UserDataSyncStoreClient(URI.parse(this.serverConfiguration.url), this.productService, this.requestService, this.logService, this.environmentService, this.fileService, this.storageService); </del> <ins> this.storeClient = new EditSessionsStoreClient(URI.parse(this.serverConfiguration.url), this.productService, this.requestService, this.logService, this.environmentService, this.fileService, this.storageService); </ins> this._register(this.storeClient.onTokenFailed(() => { this.logService.info('Clearing edit sessions authentication preference because of successive token failures.'); this.clearAuthenticationPreference(); })); } <ins> if (this.machineClient === undefined) { this.machineClient = new UserDataSyncMachinesService(this.environmentService, this.fileService, this.storageService, this.storeClient!, this.logService, this.productService); } </ins> // If we already have an existing auth session in memory, use that if (this.#authenticationInfo !== undefined) { return true;

return authenticationSession !== undefined; } <ins> private cachedMachines: Map<string, string> | undefined; async getMachineById(machineId: string) { await this.initialize(false); if (!this.cachedMachines) { const machines = await this.machineClient!.getMachines(); this.cachedMachines = machines.reduce((map, machine) => map.set(machine.id, machine.name), new Map<string, string>()); } return this.cachedMachines.get(machineId); } private async getOrCreateCurrentMachineId(): Promise<string> { const currentMachineId = await this.machineClient!.getMachines().then((machines) => machines.find((m) => m.isCurrent)?.id); if (currentMachineId === undefined) { await this.machineClient!.addCurrentMachine(); return await this.machineClient!.getMachines().then((machines) => machines.find((m) => m.isCurrent)!.id); } return currentMachineId; } </ins> private async getAuthenticationSession(fromContinueOn: boolean) { // If the user signed in previously and the session is still available, reuse that without prompting the user again if (this.existingSessionId) {

})); } } <ins> class EditSessionsStoreClient extends UserDataSyncStoreClient { _serviceBrand: any; } </ins>

private async getAllEditSessions(): Promise<ITreeItem[]> { const allEditSessions = await this.editSessionsStorageService.list(); this.editSessionsCount.set(allEditSessions.length); <del> return allEditSessions.map((session) => { </del> <ins> const editSessions = []; for (const session of allEditSessions) { </ins> const resource = URI.from({ scheme: EDIT_SESSIONS_SCHEME, authority: 'remote-session-content', path: `/${session.ref}` }); <del> return { </del> <ins> const sessionData = await this.editSessionsStorageService.read(session.ref); const label = sessionData?.editSession.folders.map((folder) => folder.name).join(', ') ?? session.ref; const machineId = sessionData?.editSession.machine; const description = machineId === undefined ? fromNow(session.created, true) : `${fromNow(session.created, true)}u00a0u00a0u2022u00a0u00a0${await this.editSessionsStorageService.getMachineById(machineId)}`; editSessions.push({ </ins> handle: resource.toString(), collapsibleState: TreeItemCollapsibleState.Collapsed, <del> label: { label: fromNow(session.created, true) }, description: session.ref, </del> <ins> label: { label }, description: description, </ins> themeIcon: Codicon.repo, contextValue: `edit-session` <del> }; }); </del> <ins> }); } return editSessions; </ins> } private async getEditSession(ref: string): Promise<ITreeItem[]> {

return []; } <ins> if (data.editSession.folders.length === 1) { const folder = data.editSession.folders[0]; return this.getEditSessionFolderContents(ref, folder.name); } </ins> return data.editSession.folders.map((folder) => { const resource = URI.from({ scheme: EDIT_SESSIONS_SCHEME, authority: 'remote-session-content', path: `/${data.ref}/${folder.name}` }); return {

write(editSession: EditSession): Promise<string>; delete(ref: string | null): Promise<void>; list(): Promise<IResourceRefHandle[]>; <ins> getMachineById(machineId: string): Promise<string | undefined>; </ins> } export const IEditSessionsLogService = createDecorator<IEditSessionsLogService>('IEditSessionsLogService');

export interface EditSession { version: number; <ins> machine?: string; </ins> folders: Folder[]; }