[VSCode] Refactor Duo Quick Chat using a state machine POC
Problem to solve
Duo Quick Chat is getting complicated with multiple components relying on the side effects.
There are multiple listeners and we check different things across to determine whether we want to update the Quick Chat like gutter icon and keyboard bindings.
Proposal
Improved State Management: Refactor Duo Quick Chat to simplify the logics based on the suggestion from below.
Further details
Suggestion comment from @viktomas
-
@viktomas started a discussion: (non-blocking) This is a more complex suggestion and it is related to this whole file, not just the feature in this MR. So it's not blocking.
I think we got into a state where we should consider using a state machine here. Something like
stateDiagram-v2 [*] --> NoQuickChat: Initial State NoQuickChat --> QuickChatCurrentDoc: Open quick chat QuickChatCurrentDoc --> NoQuickChat: Close quick chat QuickChatCurrentDoc --> QuickChatDifferentDoc: Switch documents QuickChatDifferentDoc --> QuickChatCurrentDoc: Return to original document QuickChatCurrentDoc --> QuickChatCollapsed: Collapse chat QuickChatDifferentDoc --> QuickChatCollapsed: Collapse chat QuickChatCollapsed --> QuickChatCurrentDoc: Expand in current doc QuickChatCollapsed --> NoQuickChat: Close collapsed chatThen we would have a single "state changed event" and all the components like this context value, the gutter icon and so on could react to the state changes.