Skip to content

Refactor existing views to use a view router and a single view part#382

Merged
taldekar merged 55 commits intomainfrom
feature/viewRefactor
Mar 12, 2025
Merged

Refactor existing views to use a view router and a single view part#382
taldekar merged 55 commits intomainfrom
feature/viewRefactor

Conversation

@taldekar
Copy link
Copy Markdown
Contributor

Issue #314

Description of changes:

  • Introduce ViewRouter.
  • Move views to be hosted by a single ViewContainer view.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

nborges-aws and others added 24 commits February 4, 2025 16:24
* 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>
* 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>
* 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>
* 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>
* 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 actions and move to base view

* Improve disposal logic

* Fix minor bugs

* Fix minor bugs
* 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
* Remove redundant state check method

* Fix bugs in view refactor branch

* Fix checkstyle issues

* Make webview asset provider disposal more selective
* Redirect old view IDs to point to ViewContainer

* Redirect old view IDs to point to ViewContainer
* 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>
* 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>
* 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>
* 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 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
* Refactor asset provider to handle JS asset setup

* Move events to their own package

* Move progress listener for flicker bug out of asset providers
Comment on lines +64 to +70
public Optional<String> getContent() {
Optional<String> content = resolveContent();
Activator.getEventBroker().post(ToolkitLoginWebViewAssetState.class,
content.isPresent() ? ToolkitLoginWebViewAssetState.RESOLVED
: ToolkitLoginWebViewAssetState.DEPENDENCY_MISSING);
return content;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love this coupling since this is also called in the webview constructor, presumably to hydrate the event bus. Doing this lazily would make sense otherwise, but since we won't know the asset state till we actually resolve the content I think this can be done in an initialize method that is called after construction - also symmetric to dispose. Then this method goes away and any consumer simply passes their browser instance in to hydrate it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, makes sense. Do we want to keep the method still? Because it is able to handle resolution errors after the first call too. I am not sure how likely a scenario where resolution fails on subsequent calls is, but I was erring on the side of being cautious.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't it only be called once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With the recent update, it is!

breedloj and others added 15 commits March 7, 2025 13:53
* 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>
* 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>
* 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>
* 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 actions and move to base view

* Improve disposal logic

* Fix minor bugs

* Fix minor bugs
* 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 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
taldekar and others added 10 commits March 10, 2025 19:27
* 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>
* Fix Event Broker subscription disposal bug

* Add null check

Co-authored-by: Ishan Taldekar <taldekar@amazon.com>
@taldekar taldekar merged commit 3fbb3a9 into main Mar 12, 2025
@taldekar taldekar deleted the feature/viewRefactor branch March 12, 2025 17:20
nborges-aws added a commit that referenced this pull request Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants