[VS Code] Introduce Chat state manager in the extension and use LS policies to check chat availability
Similarly to Code Suggestions state manager, we should implement Chat State manager that will control Duo chat's availability on the extension side relying on LS Chat state checks. All necessary checks are already implemented on the LS side.
Problem to Solve
In the current state, the LS/VSCode connection does have a state manager for Duo Chat. But, the number and detail of those states does not mimic what is being done for Code Suggestions. As a result, it is nearly impossible to provide detailed error messages to users for why Duo Chat may not be working; leading to bad user experience.
Things to Consider
Note that the product of this issue is a direct impact on the work being done here: [VS Code] Show the current Duo Chat status to t... (#1712 - closed).
There are two ideas proposed in that issue.
Idea 1 highlights the possibility of rendering different views for a user in the chat panel to indicate chat state. This is likely the ideal scenario, but is blocked at the moment due to ongoing migrations of the webview to be hosted by the Language Server. Once the Language Server hosts the Webview, I think this is the best approach and should be pursued.
In the meantime, I think Idea 2 is very attainable and a benefit for the VSCode extensions regardless of the future implementations of Idea 1.
In both cases, the work below is critical to unblocking the path forward.
Proposed Solution
There a few stages to a proper fix here. I think it is best if we separate these into separate issues.
Refactor Current Implementation
Currently, the LS does send state updates updates through the FeatureStateManager and the states for Duo Chat are received in VSCode via a subscription to FeatureStateWChangeNotificationType which is in langauge_server_policy, the code is not easy to find and needs to be removed as a separate implementation to mirror what is being done for the CodeSuggestionStateManager.
That is this issue covering this.
Include More States in the Duo Chat State Manager
While the LS does currently send states for Duo Chat and Code Suggestions, the number of states that are handled for Duo Chat is not the same. This presents an issue when wanting to tackle this task: [VS Code] DuoChat: Improve VS Code webview erro... (#1699 - closed) which allows for more descriptive error messages to users. This Improve Duo status menu by better addressing un... (gitlab-org/editor-extensions&83) also would benefit from having more states.
[VS Code] Include More States in the Duo Chat S... (#1754 - closed)