MCPcopy Create free account
hub / github.com/altic-dev/FluidVoice / handleModeTransition

Method handleModeTransition

Sources/Fluid/ContentView.swift:910–950  ·  view source on GitHub ↗

Centralized handler for sidebar mode transitions to ensure proper cleanup and state management

(from oldValue: SidebarItem?, to newValue: SidebarItem?)

Source from the content-addressed store, hash-verified

908
909 /// Centralized handler for sidebar mode transitions to ensure proper cleanup and state management
910 private func handleModeTransition(from oldValue: SidebarItem?, to newValue: SidebarItem?) {
911 DebugLogger.shared.debug("Mode transition: \(String(describing: oldValue)) → \(String(describing: newValue))", source: "ContentView")
912
913 // Clean up state from the previous mode
914 if let old = oldValue {
915 switch old {
916 case .commandMode:
917 // Close expanded command output notch if visible
918 if NotchOverlayManager.shared.isCommandOutputExpanded {
919 DebugLogger.shared.debug("Closing expanded command notch on mode transition", source: "ContentView")
920 NotchOverlayManager.shared.hideExpandedCommandOutput()
921 }
922 // Note: We don't clear command history here - user may want to return to it
923
924 case .rewriteMode:
925 // Clear rewrite state when leaving
926 self.rewriteModeService.clearState()
927
928 default:
929 break
930 }
931 }
932
933 // Set up state for the new mode
934 if let new = newValue {
935 switch new {
936 case .commandMode:
937 self.menuBarManager.setOverlayMode(.command)
938
939 case .rewriteMode:
940 self.menuBarManager.setOverlayMode(.edit)
941
942 default:
943 // For all other views, set to dictation mode
944 self.menuBarManager.setOverlayMode(.dictation)
945 }
946 } else {
947 // If newValue is nil, default to dictation
948 self.menuBarManager.setOverlayMode(.dictation)
949 }
950 }
951
952 @MainActor
953 private func handleMenuBarNavigation(_ destination: MenuBarNavigationDestination?) {

Callers 1

ContentViewStruct · 0.95

Calls 4

debugMethod · 0.80
clearStateMethod · 0.80
setOverlayModeMethod · 0.80

Tested by

no test coverage detected