Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions src/vs/sessions/contrib/changes/browser/changesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { ActionRunner, IAction, Separator, SubmenuAction, toAction } from '../..
import { Codicon } from '../../../../base/common/codicons.js';
import { Disposable, DisposableStore, IDisposable } from '../../../../base/common/lifecycle.js';
import { Event } from '../../../../base/common/event.js';
import { autorun, derived, derivedObservableWithCache, derivedOpts, IObservable, observableFromEvent, observableValue } from '../../../../base/common/observable.js';
import { autorun, derived, derivedObservableWithCache, derivedOpts, IObservable, observableFromEvent, observableFromEventOpts, observableValue } from '../../../../base/common/observable.js';
import { CountBadge } from '../../../../base/browser/ui/countBadge/countBadge.js';
import { ProgressBar } from '../../../../base/browser/ui/progressbar/progressbar.js';
import { basename, isEqual } from '../../../../base/common/resources.js';
import { URI } from '../../../../base/common/uri.js';
import { localize, localize2 } from '../../../../nls.js';
import { MenuWorkbenchButtonBar, WorkbenchButtonBar } from '../../../../platform/actions/browser/buttonbar.js';
import { getActionBarActions } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
import { getActionBarActions, PrimaryAndSecondaryActions } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
import { MenuWorkbenchToolBar } from '../../../../platform/actions/browser/toolbar.js';
import { ActionWidgetDropdownActionViewItem } from '../../../../platform/actions/browser/actionWidgetDropdownActionViewItem.js';
import { MenuId, Action2, MenuItemAction, registerAction2, IMenuService } from '../../../../platform/actions/common/actions.js';
Expand Down Expand Up @@ -74,7 +74,7 @@ import { ActiveSessionContextKeys, CHANGES_VIEW_CONTAINER_ID, CHANGES_VIEW_ID, C
import { buildTreeChildren, ChangesTreeElement, ChangesTreeRenderer, IChangesFileItem, IChangesTreeRootInfo, isChangesFileItem, toIChangesFileItem } from './changesViewRenderer.js';
import { ChangesViewModel } from './changesViewModel.js';
import { ResourceTree } from '../../../../base/common/resourceTree.js';
import { structuralEquals } from '../../../../base/common/equals.js';
import { arrayEqualsC, structuralEquals } from '../../../../base/common/equals.js';
import { compareFileNames, comparePaths } from '../../../../base/common/comparers.js';
import { IViewsService } from '../../../../workbench/services/views/common/viewsService.js';
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
Expand Down Expand Up @@ -247,9 +247,24 @@ class ChangesWorkbenchButtonBarWidget extends Disposable {
}
));

const menuActionsObs = observableFromEvent(menu.onDidChange, () => {
return getActionBarActions(menu.getActions({ shouldForwardArgs: true }));
});
const menuActionsEquals = (a: PrimaryAndSecondaryActions, b: PrimaryAndSecondaryActions) => {
const actionEquals = (a: IAction, b: IAction) => {
return a.id === b.id &&
a.label === b.label &&
a.tooltip === b.tooltip &&
a.class === b.class &&
a.enabled === b.enabled &&
a.checked === b.checked;
};

return arrayEqualsC(actionEquals)(a.primary, b.primary) &&
arrayEqualsC(actionEquals)(a.secondary, b.secondary);
};

const menuActionsObs = observableFromEventOpts({ equalsFn: menuActionsEquals },
menu.onDidChange, () => {
return getActionBarActions(menu.getActions({ shouldForwardArgs: true }));
});

const operationActionGroupsObs = derived<IAction[][]>(reader => {
const changeset = viewModel.activeSessionChangesetObs.read(reader);
Expand Down Expand Up @@ -309,6 +324,11 @@ class ChangesWorkbenchButtonBarWidget extends Disposable {
});

this._register(autorun(reader => {
const isLoading = viewModel.activeSessionIsLoadingObs.read(reader);
if (isLoading) {
return;
}

Comment on lines 326 to +331
const operationActionGroups = operationActionGroupsObs.read(reader);
const menuActions = menuActionsObs.read(reader);

Expand Down
6 changes: 5 additions & 1 deletion src/vs/sessions/contrib/changes/browser/changesViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export class ChangesViewModel extends Disposable {
private _getActiveSessionState(): { isLoading: IObservable<boolean>; state: IObservable<ActiveSessionState | undefined> } {
const isLoadingObs = derived(reader => {
const changeset = this.activeSessionChangesetObs.read(reader);
return changeset?.isLoadingChanges.read(reader) ?? false;
if (changeset === undefined) {
return true;
}

return changeset.isLoadingChanges.read(reader);
});
Comment on lines 156 to 163

const activeSessionStateObs = derivedObservableWithCache<ActiveSessionState | undefined>(this, (reader, lastValue) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@

/* Actions container outside the card - new layout experiment */
.changes-view-body .chat-editing-session-actions.outside-card {
height: 26px;
margin-bottom: 8px;
justify-content: flex-end;
}
Expand Down
Loading