Introduce ViewRouter Component#337
Conversation
* Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection
| @ParameterizedTest | ||
| @MethodSource("provideStateSource") | ||
| void testActiveViewResolutionBasedOnPluginState(final LspState lspState, final AuthState authState, | ||
| final ViewId activeViewId) { |
There was a problem hiding this comment.
can this be renamed to "expectedActiveViewId"?
Is there a way to do an assertion on what is expected and what is the actual active view ?
There was a problem hiding this comment.
I'll update the name. Changing this to an assertion is possible using ArgumentCaptors like so. Should I transition to this approach. I've verified that verify calls on the mock fail if the ViewIds are not what is expected. The ViewRouter doesn't really expose any methods to retrieve the activeView, so assertions are a bit difficult.
| RxJavaPlugins.setComputationSchedulerHandler(scheduler -> Schedulers.trampoline()); | ||
|
|
||
| publishSubject = PublishSubject.create(); | ||
| authStateObservable = publishSubject.ofType(AuthState.class); |
There was a problem hiding this comment.
Do any of the observables need disposal?
There was a problem hiding this comment.
I don't believe so, but I'll verify this.
There was a problem hiding this comment.
Observables do not need to be disposed. But on a related note I did add functionality to track any subscriptions in the event broker and added a method that can be used to dispose off them.
There was a problem hiding this comment.
What would be a example of a use case where we would want to dispose off a subscription?
By disposing observable I was talking about the situation when we want to stop listening for a certain event. By disposing off a subscription I am unclear what exactly that does?
There was a problem hiding this comment.
Disposing off the subscription basically cancels it. So we stop listening to events. Observables are the stream of data, and those don't need to be disposed. For the ViewContainer component, before the check to see if the parent composite is disposed, if we didn't dispose the listener then it would try to call update child view when the parent composite was disposed and error out. Cases like these it would make sense to dispose of the listener.
| RxJavaPlugins.setComputationSchedulerHandler(scheduler -> Schedulers.trampoline()); | ||
|
|
||
| publishSubject = PublishSubject.create(); | ||
| authStateObservable = publishSubject.ofType(AuthState.class); |
There was a problem hiding this comment.
What would be a example of a use case where we would want to dispose off a subscription?
By disposing observable I was talking about the situation when we want to stop listening for a certain event. By disposing off a subscription I am unclear what exactly that does?
* improved handling of lsp failure state * add static mock to lsp connection test case * Integrate Event Broker in LspStatusManager * Add ViewRouter POC * Fix code formatting bug * Add method to retrieve observables * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add functionality for hot event streams that track latest event (#340) * Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection * Remove active view update request listener * Add ViewRouter tests * Remove public constructor * Remove public constructor and unused event in tests * Add comments * Add documentation for EventBroker * Remove ViewRouter initialization * Remove LspInitializingView from ID enum * Add documentation for ViewRouter * Refactor and enhance EventBroker tests * Refactor ViewRouter tests for clarity * Remove PluginState class into separate file * Add documentation to subscription management logic * Add support for notifying multiple late-subscribers over time of latest state (#342) * Remove CODE_REFERENCE_VIEW * Rename newActiveViewId to newActiveView * Rename ViewId class to AmazonQViewType * Revert "Integrate Event Broker in LspStatusManager" This reverts commit 374e549. * Revert "improved handling of lsp failure state" This reverts commit 13c55ac. * Refactor EventBroker and enhance tests (#343) --------- Co-authored-by: Nicolas Borges <nickdb@amazon.com>
* improved handling of lsp failure state * add static mock to lsp connection test case * Integrate Event Broker in LspStatusManager * Add ViewRouter POC * Fix code formatting bug * Add method to retrieve observables * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add functionality for hot event streams that track latest event (#340) * Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection * Remove active view update request listener * Add ViewRouter tests * Remove public constructor * Remove public constructor and unused event in tests * Add comments * Add documentation for EventBroker * Remove ViewRouter initialization * Remove LspInitializingView from ID enum * Add documentation for ViewRouter * Refactor and enhance EventBroker tests * Refactor ViewRouter tests for clarity * Remove PluginState class into separate file * Add documentation to subscription management logic * Add support for notifying multiple late-subscribers over time of latest state (#342) * Remove CODE_REFERENCE_VIEW * Rename newActiveViewId to newActiveView * Rename ViewId class to AmazonQViewType * Revert "Integrate Event Broker in LspStatusManager" This reverts commit 374e549. * Revert "improved handling of lsp failure state" This reverts commit 13c55ac. * Refactor EventBroker and enhance tests (#343) --------- Co-authored-by: Nicolas Borges <nickdb@amazon.com>
…382) * improved handling of lsp failure state (#309) * Introduce ViewRouter Component (#337) * improved handling of lsp failure state * add static mock to lsp connection test case * Integrate Event Broker in LspStatusManager * Add ViewRouter POC * Fix code formatting bug * Add method to retrieve observables * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add functionality for hot event streams that track latest event (#340) * Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection * Remove active view update request listener * Add ViewRouter tests * Remove public constructor * Remove public constructor and unused event in tests * Add comments * Add documentation for EventBroker * Remove ViewRouter initialization * Remove LspInitializingView from ID enum * Add documentation for ViewRouter * Refactor and enhance EventBroker tests * Refactor ViewRouter tests for clarity * Remove PluginState class into separate file * Add documentation to subscription management logic * Add support for notifying multiple late-subscribers over time of latest state (#342) * Remove CODE_REFERENCE_VIEW * Rename newActiveViewId to newActiveView * Rename ViewId class to AmazonQViewType * Revert "Integrate Event Broker in LspStatusManager" This reverts commit 374e549. * Revert "improved handling of lsp failure state" This reverts commit 13c55ac. * Refactor EventBroker and enhance tests (#343) --------- Co-authored-by: Nicolas Borges <nickdb@amazon.com> * Introduce View Container and base view components (#338) * Add Browser Provider component (#357) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Add Webview Asset Providers (#358) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Integrate browser based views in ViewContainer (#359) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter * Integrate browser based views in ViewContainer * Fix checkstyle issues * Fix AmazonQBrowserProvider tests * Fix bug due to display sync exec call * Add semaphore locking to container to prevent race conditions * Add browser focus handling * Add state checking methods to LspState * Clean up code * Remove unnecessary parent assignment from chat webview * Refactor ViewVisibilityManager to default to one view * Add accidentally removed telemetry emissions * Update plugin descriptor (#360) * Move semaphore locking/unlocking to try/finally block --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Separate Chat and Toolkit Login web view asset state event stream (#361) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter * Integrate browser based views in ViewContainer * Fix checkstyle issues * Fix AmazonQBrowserProvider tests * Fix bug due to display sync exec call * Add semaphore locking to container to prevent race conditions * Add browser focus handling * Separate Chat and Toolkit Login webview asset event stream * Separate Chat and Toolkit Login webview asset event stream * Add state checking methods to LspState * Clean up code * Remove unnecessary parent assignment from chat webview * Refactor ViewVisibilityManager to default to one view * Add accidentally removed telemetry emissions * Fix issue in a comment due to stash * Update AssetProviders to publish state everytime content is fetched * Update plugin descriptor (#360) * Remove business logic from asset provider constructors * Remove redundant methods to check state --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Refactor view actions and move setup code to base view (#370) * Refactor actions and move to base view * Improve disposal logic * Fix minor bugs * Fix minor bugs * Remove unnecessary BaseView class (#371) * Remove LspStatusManager (#365) * Remove LspStatusManager * Refactor browser provider (#366) * Move publishing browser status to Activator * Fix potential memory visibility bug (#367) * Fix thread visibility bug * Fix thread visibility bug * Remove chat asset provider (#368) * Fix thread visibility bug * Remove ChatAssetProvider * Fix bugs in ViewRefactor feature branch (#362) * Remove redundant state check method * Fix bugs in view refactor branch * Fix checkstyle issues * Make webview asset provider disposal more selective * Reset content on dispose * Redirect old views to point to the ViewContainer (#380) * Redirect old view IDs to point to ViewContainer * Redirect old view IDs to point to ViewContainer * Auto detection of proxy settings * Make keystore custom cert injection additive * Introduce ViewRouter Component (#337) * improved handling of lsp failure state * add static mock to lsp connection test case * Integrate Event Broker in LspStatusManager * Add ViewRouter POC * Fix code formatting bug * Add method to retrieve observables * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add functionality for hot event streams that track latest event (#340) * Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection * Remove active view update request listener * Add ViewRouter tests * Remove public constructor * Remove public constructor and unused event in tests * Add comments * Add documentation for EventBroker * Remove ViewRouter initialization * Remove LspInitializingView from ID enum * Add documentation for ViewRouter * Refactor and enhance EventBroker tests * Refactor ViewRouter tests for clarity * Remove PluginState class into separate file * Add documentation to subscription management logic * Add support for notifying multiple late-subscribers over time of latest state (#342) * Remove CODE_REFERENCE_VIEW * Rename newActiveViewId to newActiveView * Rename ViewId class to AmazonQViewType * Revert "Integrate Event Broker in LspStatusManager" This reverts commit 374e549. * Revert "improved handling of lsp failure state" This reverts commit 13c55ac. * Refactor EventBroker and enhance tests (#343) --------- Co-authored-by: Nicolas Borges <nickdb@amazon.com> * Add Browser Provider component (#357) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Add Webview Asset Providers (#358) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Integrate browser based views in ViewContainer (#359) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter * Integrate browser based views in ViewContainer * Fix checkstyle issues * Fix AmazonQBrowserProvider tests * Fix bug due to display sync exec call * Add semaphore locking to container to prevent race conditions * Add browser focus handling * Add state checking methods to LspState * Clean up code * Remove unnecessary parent assignment from chat webview * Refactor ViewVisibilityManager to default to one view * Add accidentally removed telemetry emissions * Update plugin descriptor (#360) * Move semaphore locking/unlocking to try/finally block --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Merge main into feature/viewRefactor * Refactor asset providers (#383) * Refactor asset provider to handle JS asset setup * Move progress listener for flicker bug out of asset providers * Pre-fetch assets to publish asset state on event broker * Consolidate events into their own package (#385) * Refactor asset provider to handle JS asset setup * Move events to their own package * Move progress listener for flicker bug out of asset providers * Clean up code * Refactor asset provider interface (#386) * Refactor asset provider interface * Update initialize method to only fire once * Trigger LSP configuration pull on preference update (#388) * Open Flare version constraint (#389) * Bump version to 1.0.4-SNAPSHOT * Add dropdown menu on top level Q toolbar icon * Add item for opening Q Chat * Introduce ViewRouter Component (#337) * improved handling of lsp failure state * add static mock to lsp connection test case * Integrate Event Broker in LspStatusManager * Add ViewRouter POC * Fix code formatting bug * Add method to retrieve observables * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add listeners for combined state streams and view update request * Add functionality for hot event streams that track latest event (#340) * Add functionality for hot subscribers that track latest event * Add test to ensure event stream isolation * Fix missing subscription disposal in test * Use autoConnect to implicitly manage stream connection * Remove active view update request listener * Add ViewRouter tests * Remove public constructor * Remove public constructor and unused event in tests * Add comments * Add documentation for EventBroker * Remove ViewRouter initialization * Remove LspInitializingView from ID enum * Add documentation for ViewRouter * Refactor and enhance EventBroker tests * Refactor ViewRouter tests for clarity * Remove PluginState class into separate file * Add documentation to subscription management logic * Add support for notifying multiple late-subscribers over time of latest state (#342) * Remove CODE_REFERENCE_VIEW * Rename newActiveViewId to newActiveView * Rename ViewId class to AmazonQViewType * Revert "Integrate Event Broker in LspStatusManager" This reverts commit 374e549. * Revert "improved handling of lsp failure state" This reverts commit 13c55ac. * Refactor EventBroker and enhance tests (#343) --------- Co-authored-by: Nicolas Borges <nickdb@amazon.com> * Add Browser Provider component (#357) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Add Webview Asset Providers (#358) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Integrate browser based views in ViewContainer (#359) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter * Integrate browser based views in ViewContainer * Fix checkstyle issues * Fix AmazonQBrowserProvider tests * Fix bug due to display sync exec call * Add semaphore locking to container to prevent race conditions * Add browser focus handling * Add state checking methods to LspState * Clean up code * Remove unnecessary parent assignment from chat webview * Refactor ViewVisibilityManager to default to one view * Add accidentally removed telemetry emissions * Update plugin descriptor (#360) * Move semaphore locking/unlocking to try/finally block --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Refactor view actions and move setup code to base view (#370) * Refactor actions and move to base view * Improve disposal logic * Fix minor bugs * Fix minor bugs * Auto detection of proxy settings * Integrate browser based views in ViewContainer (#359) * Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' * Rebase changes from Browser Provider PR * Fix ViewRouter * Integrate browser based views in ViewContainer * Fix checkstyle issues * Fix AmazonQBrowserProvider tests * Fix bug due to display sync exec call * Add semaphore locking to container to prevent race conditions * Add browser focus handling * Add state checking methods to LspState * Clean up code * Remove unnecessary parent assignment from chat webview * Refactor ViewVisibilityManager to default to one view * Add accidentally removed telemetry emissions * Update plugin descriptor (#360) * Move semaphore locking/unlocking to try/finally block --------- Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Nicolas <nborges.aws@gmail.com> * Refactor asset providers (#383) * Refactor asset provider to handle JS asset setup * Move progress listener for flicker bug out of asset providers * Pre-fetch assets to publish asset state on event broker * Integrate AmazonQCommonActions change * Integrate AmazonQCommonActions change * Remove duplicate events * Fix global drop-down visibility bug * Fix UdateUtil bug * Fix UdateUtil bug * Fix missing imports * Improve timing of early startup activity (#393) (#394) * Improve timing of early startup activity * Fix unit test Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: Ishan Taldekar <taldekar@amazon.com> * Remove unused imports * Fix Event Broker subscription disposal bug (#392) (#395) * Fix Event Broker subscription disposal bug * Add null check Co-authored-by: Ishan Taldekar <taldekar@amazon.com> * Remove dispose method * Remove redundant classes --------- Co-authored-by: Nicolas <nborges.aws@gmail.com> Co-authored-by: Nicolas Borges <nickdb@amazon.com> Co-authored-by: Jonathan Breedlove <breedloj@amazon.com> Co-authored-by: aws-toolkit-automation <43144436+aws-toolkit-automation@users.noreply.github.com>
Issue #335
Description of changes:
Introduced a ViewRouter component to determine which view to display based on an order of resolution logic.
Open Questions:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.