Skip to content

Commit

Permalink
progress: display notifications coming from Sapling
Browse files Browse the repository at this point in the history
Summary: With some recent changes in the Sapling side, showing warnings on ISL coming from Sapling should be possible. This should be particularly useful to tell users why some of their operations (like `goto`) can be slow.

Reviewed By: evangrayk

Differential Revision: D66730579

fbshipit-source-id: 72b049fd6ed675076ad7a055b525f639762fb505
  • Loading branch information
sggutier authored and facebook-github-bot committed Dec 5, 2024
1 parent 9461d02 commit b38e498
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
3 changes: 3 additions & 0 deletions addons/isl-server/src/OperationQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export class OperationQueue {
case 'inlineProgress':
onProgress({id: operation.id, kind: 'inlineProgress', hash: args[1], message: args[2]});
break;
case 'warning':
onProgress({id: operation.id, kind: 'warning', warning: args[1]});
break;
case 'stderr':
onProgress({id: operation.id, kind: 'stderr', message: args[1]});
break;
Expand Down
32 changes: 17 additions & 15 deletions addons/isl-server/src/Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,23 +677,25 @@ export class Repository {
try {
// eslint-disable-next-line no-await-in-loop
const message = await child.getOneMessage();
if (
message === null ||
typeof message !== 'object' ||
!('progress_bar_update' in message)
) {
if (message === null || typeof message !== 'object') {
break;
}
const bars = message.progress_bar_update as IpcProgressBar[];
const blen = bars.length;
if (blen > 0) {
const msg = bars[blen - 1];
onProgress('progress', {
message: msg.topic,
progress: msg.position,
progressTotal: msg.total,
unit: msg.unit,
});
if ('progress_bar_update' in message) {
const bars = message.progress_bar_update as IpcProgressBar[];
const blen = bars.length;
if (blen > 0) {
const msg = bars[blen - 1];
onProgress('progress', {
message: msg.topic,
progress: msg.position,
progressTotal: msg.total,
unit: msg.unit,
});
}
} else if ('warning' in message) {
onProgress('warning', message.warning as string);
} else {
break;
}
} catch (err) {
break;
Expand Down
8 changes: 8 additions & 0 deletions addons/isl/src/CommandHistoryAndProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ export function CommandHistoryAndProgress() {
<div className="progress-container-row">
{icon}
{label}
{progress.warnings?.map(warning => (
<Banner
icon={<Icon icon="warning" color="yellow" />}
alwaysShowButtons
kind={BannerKind.warning}>
<T replace={{$provider: warning}}>$provider</T>
</Banner>
))}
</div>
{showLastLineOfOutput ? (
<div className="progress-container-row">
Expand Down
17 changes: 17 additions & 0 deletions addons/isl/src/operationsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type OperationInfo = {
hasCompletedUncommittedChangesOptimisticState?: boolean;
/** if true, the operation process has exited AND there's no more optimistic changes to merge conflicts to show */
hasCompletedMergeConflictsOptimisticState?: boolean;
warnings?: Array<string>;
} & EnsureAssignedTogether<{
endTime: Date;
exitCode: number;
Expand Down Expand Up @@ -193,6 +194,22 @@ registerDisposable(
};
});
break;
case 'warning':
writeAtom(operationList, current => {
const currentOperation = current.currentOperation;
if (currentOperation == null) {
return current;
}
const warnings = [...(currentOperation?.warnings ?? []), progress.warning];
return {
...current,
currentOperation: {
...currentOperation,
warnings,
},
};
});
break;
case 'exit':
case 'forgot':
writeAtom(operationList, current => {
Expand Down
2 changes: 2 additions & 0 deletions addons/isl/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ export type OperationProgress =
| {id: string; kind: 'inlineProgress'; hash?: string; message?: string}
| {id: string; kind: 'exit'; exitCode: number; timestamp: number}
| {id: string; kind: 'error'; error: string}
| {id: string; kind: 'warning'; warning: string}
// used by requestMissedOperationProgress, client thinks this operation is running but server no longer knows about it.
| {id: string; kind: 'forgot'};

Expand All @@ -598,6 +599,7 @@ export type OperationCommandProgressReporter = (
// null message -> clear inline progress for this hash. Null hash -> apply to all affected hashes (set message or clear)
| [type: 'inlineProgress', hash?: string, message?: string]
| ['progress', ProgressStep]
| ['warning', string]
| ['exit', number]
) => void;

Expand Down

0 comments on commit b38e498

Please sign in to comment.