Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quick Connect #1150

Merged
merged 12 commits into from
Apr 11, 2023
Merged

Conversation

chrjorgensen
Copy link
Collaborator

@chrjorgensen chrjorgensen commented Mar 21, 2023

Changes

This PR will add a Quick Connect setting in the connection configuration to speed up connecting to the system:

billede

When selected, the following server settings are taken from the previous connection to the system:

  • bad data areas
  • all remote features
  • ASP info
  • CCSID
  • encoding values for #@$

These values are stored in connection storage on each connection to the system. So if no previous connection has been done, even though the Quick Connect is checked, all settings will be retrieved from the server and stored in the connection configuration to be used on the next connection.

This setting is active by default. The user can disable it permanently in the configuration, or the user can reload all settings from server into cache by right-clicking on the connection and select Connect and Reload Server Settings.

If the remote feature keys do not match the keys in the cache, the remote features will be checked on the server disregarding this setting.

For more information, see issue #1122.

Checklist

  • have tested my change
  • eslint is not complaining
  • for feature PRs: PR only includes one feature enhancement.

@chrjorgensen chrjorgensen added the enhancement New feature or request label Mar 21, 2023
@worksofliam worksofliam linked an issue Mar 23, 2023 that may be closed by this pull request
@worksofliam
Copy link
Contributor

@chrjorgensen This is awesome. I personally love that this is an opt in thing. Please fix up the conflicts and then I will retest again.

@chrjorgensen
Copy link
Collaborator Author

@worksofliam Conflicts fixed, please retest...

Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an awesome change and should indeed speed up connection times. Great job!

Maybe you can make a change to enhance the UX a bit more. Having to uncheck the property in the settings, connect and check again the property seems a bit cumbersome. How about having a Connect and reload settings command that could force the reloading of the settings even if quick connect is on? This could be a right click action in the connection browser.

@chrjorgensen
Copy link
Collaborator Author

@sebjulliand I now added a connection right-click option to connect and reload server settings:

billede

A new command ConnectToAndReload has been created, but is not available in the command palette, only on the right-click menu.

I had to add one parameter to the connect functions to specify that server settings should be reloaded, despite quick connect was set for the connection. Could I have done it better in another way?

src/api/Storage.ts Outdated Show resolved Hide resolved
src/api/Storage.ts Outdated Show resolved Hide resolved
src/api/Storage.ts Outdated Show resolved Hide resolved
src/api/Storage.ts Outdated Show resolved Hide resolved
sebjulliand
sebjulliand previously approved these changes Mar 25, 2023
Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all good to me; just a suggestion to consider.

@sebjulliand
Copy link
Collaborator

I had to add one parameter to the connect functions to specify that server settings should be reloaded, despite quick connect was set for the connection. Could I have done it better in another way?

No, that's perfect the way you did it @chrjorgensen !

@sebjulliand
Copy link
Collaborator

@chrjorgensen, @worksofliam : shouldn't Quick connect actually be turned on by default when creating a connection? I'd tend to think so. What do you guys think?

@worksofliam
Copy link
Contributor

@sebjulliand I am guessing this quick connect would only work after the initial connection so we have some system information.

I haven't tested this PR yet

@sebjulliand
Copy link
Collaborator

@sebjulliand I am guessing this quick connect would only work after the initial connection so we have some system information.

If it's on but nothing's been cached yet, it will perform a normal connection to gather and cache the values. That's why I think it doesn't hurt to have it turned on by default.

@chrjorgensen
Copy link
Collaborator Author

Yeah, Quick connect will not break if activated on a connection never used before. For each setting it will check if there's a value in the cache from a previous connection and only then use that value. Otherwise it will go to the server as usual.
So having this on by default will not break anything.

I'm undecided whether this setting is best suited as a connection setting or a global setting. Since it won't break anything and servers very, very rarely change settings, this could just as well be a global setting. What do you guys think?

@sebjulliand
Copy link
Collaborator

When you put it this way, I think it should even not be an option at all, but just the built-in behavior. I can't think of a scenario where you'd need to reload the cached settings every time. Since we have the command to reload them on demand, there may be no point to have it as an option at all.

@worksofliam
Copy link
Contributor

When you put it this way, I think it should even not be an option at all, but just the built-in behavior.

I somewhat agree with it. In fact, I was thinking an option like 'always do a full connect' (which means never use our cached settings) in the VS Code settings would work here. If it's false, it will: use the cached settings if they exist, otherwise do full connect and store them. If it's true.. always do a full connect

@worksofliam worksofliam removed their assignment Mar 25, 2023
@chrjorgensen chrjorgensen force-pushed the feature/quick-connect branch from a7f7a63 to b8fd440 Compare April 3, 2023 23:28
@chrjorgensen
Copy link
Collaborator Author

chrjorgensen commented Apr 3, 2023

@sebjulliand This PR was so far behind master that I had to rebase the changes onto master branch and force push.
I also added a check for remote features in the cache, since new features have been and will be added in the future, and then the cache is not valid.

Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small suggestion and conflicts to resolve; I can't wait to merge this PR, it's so convenient!

src/api/IBMi.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is fine, save for one detail; it's not directly related to your PR, but it's been highlighted by it 😉

In src/webviews/settings/index.ts, the target configuration doesn't get loaded and saved in all cases using the ConnectionConfiguration.load and ConnectionConfiguration.update method. Since ConnectionConfiguration.load isn't used to load the configuration, some default values are not applied for undefined settings, like Quick Connect. Consequently, when you edit the connection settings for a connection for which Quick Connect is undefined, the checkbox is unchecked. But when the settings will be loaded during the connection, it will actually be true. So the settings page is not the exact reflect of the actual settings in this case 😉

Using ConnectionConfiguration's load and update will also simplify the connection settings page code a little bit and remove some redundant code.

@chrjorgensen
Copy link
Collaborator Author

@sebjulliand I see the problem and is on it...

@chrjorgensen
Copy link
Collaborator Author

@sebjulliand The initialization problem in settings view is now fixed - please test thoroughly, since this is not a trivial code rewrite.

@chrjorgensen
Copy link
Collaborator Author

@worksofliam It would be nice to have your eyes on this as well.

@worksofliam
Copy link
Contributor

@chrjorgensen Expect a test tonight (my tonight!) 👍

@chrjorgensen
Copy link
Collaborator Author

@worksofliam During my own tests I noticed that the fields enableSQL, showDescInLibList and tempDir asks for a reload of the workspace. But the connection is not reloaded (anymore?), should it not reload? Instead VS Code is being reloaded.

I also noticed that showDescInLibList actually does not require a reload, just a refresh of the library list view (because I coded the library description feature! 😆). I will make a PR for this later, when this PR has been merged. But are there any more fields, that does not require reload?

@worksofliam
Copy link
Contributor

@chrjorgensen I had a quick review and I think the whole idea of restarting can be removed now - you're right. I would need to confirm this for enableSQL as we use that in a lot of places!

Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is good and it works fine.
There is just one thing that needs to be fixed in my opinion, and we'll be good to merge!

Co-authored-by: Sébastien Julliand <sebjulliand@gmail.com>
@chrjorgensen
Copy link
Collaborator Author

@sebjulliand Suggestion has been accepted! 😉

sebjulliand
sebjulliand previously approved these changes Apr 11, 2023
Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for it!
@worksofliam I'll let you make your round of tests and merge if you're OK with it.

@@ -119,7 +120,8 @@ export namespace ConnectionConfiguration {
debugIsSecure: (parameters.debugIsSecure === true),
debugUpdateProductionFiles: (parameters.debugUpdateProductionFiles === true),
debugEnableDebugTracing: (parameters.debugEnableDebugTracing === true),
readOnlyMode: (parameters.readOnlyMode === true)
readOnlyMode: (parameters.readOnlyMode === true),
quickConnect: (parameters.quickConnect === true || parameters.quickConnect === undefined)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it shows that Quick Connect will be on by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worksofliam Yeah, Quick Connect was changed to be the default behavior with the setting available for the user to opt-out - per our discussion two weeks ago. Hope this is okay?

Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, but the 'Connect and Reload' right click option doesn't work as expected. Seems like the UI isn't updating after the connection is made?

Video uploading here: https://youtu.be/wntqwrjuFdM

worksofliam

This comment was marked as duplicate.

@chrjorgensen
Copy link
Collaborator Author

Code looks good, but the 'Connect and Reload' right click option doesn't work as expected. Seems like the UI isn't updating after the connection is made?

Video uploading here: https://youtu.be/wntqwrjuFdM

@worksofliam I see that - looking into it...

@chrjorgensen
Copy link
Collaborator Author

@worksofliam I'm glad I asked you to have a look and do some testing! 😃 There were a problem with two optional parameters to connect, one of which were created in master branch after the other were created in my PR branch - and since they were both boolean and optional, no warning were issued during development!

It should have been fixed now, please retest...

@sebjulliand
Copy link
Collaborator

@worksofliam I'm glad I asked you to have a look and do some testing! 😃 There were a problem with two optional parameters to connect, one of which were created in master branch after the other were created in my PR branch - and since they were both boolean and optional, no warning were issued during development!

It should have been fixed now, please retest...

Oh that's right. That was the reconnect boolean I added a few weeks ago, after your PR was created, to enhance the re-connection process after the connection gets dropped.

It's good you pinpointed it! Now it makes me think that when we start having a few options like that, especially a succession of optional ones, we should gather them in an object to avoid this kind of issues and prevent "merge messes" 😅

//For example this...
async connect(connectionObject: ConnectionData, reconnecting?: boolean, reloadServerSettings: boolean = false) {
...
}

//...could become this
async connect(connectionObject: ConnectionData, options?:{reconnecting?: boolean, reloadServerSettings?: boolean}) {
...
}

Not for today but definitely something way may keep in mind 😉

Copy link
Collaborator

@sebjulliand sebjulliand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connect to reload cache works fine now.
Disconnecting and reconnecting manually with quick connect on works as expected.

Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks like it is working as expected now. I really like this feature - thanks for your hard work @chrjorgensen!

I will give you the pleasure of merging.

@chrjorgensen
Copy link
Collaborator Author

I will give you the pleasure of merging.

Thanks @worksofliam and @sebjulliand

@chrjorgensen chrjorgensen merged commit 8f25b60 into codefori:master Apr 11, 2023
@chrjorgensen chrjorgensen deleted the feature/quick-connect branch April 13, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace SQL usage of fetching system values with QSH sysval
3 participants