Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,6 @@ export class RemoteNotebookKernelSourceSelector implements IRemoteNotebookKernel
lazyQuickPick.busy = true;
}
const ret = await this.selectRemoteServerFromRemoteKernelFinder(selectedSource, state, token);
if (lazyQuickPick) {
lazyQuickPick.busy = false;
}
return ret;
} catch (ex) {
if (ex === InputFlowAction.back && !defaultSelection) {
Expand All @@ -479,6 +476,9 @@ export class RemoteNotebookKernelSourceSelector implements IRemoteNotebookKernel
throw ex;
}
} finally {
if (lazyQuickPick) {
lazyQuickPick.busy = false;
}
taskNb.dispose();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { assert } from 'chai';

suite('Remote Notebook Kernel Source Selector - UI State Management', () => {
test('should demonstrate busy state pattern expectations', () => {
// This test documents the expected behavior for UI busy state management
// The fix ensures that lazyQuickPick.busy is reset in finally block

let busyState = false;
const mockQuickPick = {
set busy(value: boolean) {
busyState = value;
},
get busy() {
return busyState;
}
};

// Simulate the fixed pattern: busy state reset in finally block
const simulateOperation = async (shouldThrow: boolean) => {
try {
mockQuickPick.busy = true;
if (shouldThrow) {
throw new Error('Simulated error');
}
return 'success';
} finally {
mockQuickPick.busy = false;
}
};

// Test successful case
return simulateOperation(false)
.then(() => {
assert.isFalse(mockQuickPick.busy, 'Busy state should be reset after success');
})
.then(() => {
// Test error case
return simulateOperation(true).catch(() => {
assert.isFalse(mockQuickPick.busy, 'Busy state should be reset even after errors');
});
});
});
});