@@ -27,6 +27,8 @@ struct RecordingViewState {
2727 active : bool ,
2828 starting : bool ,
2929 stopping : bool ,
30+ display_discovery_in_flight : bool ,
31+ audio_discovery_in_flight : bool ,
3032 paused : bool ,
3133 progress : crate :: recording:: RecordingProgress ,
3234}
@@ -43,6 +45,8 @@ impl gpui::Render for FlashShotApp {
4345 active : self . recording_control . is_some ( ) ,
4446 starting : self . recording_start_in_flight ,
4547 stopping : self . recording_stopping ,
48+ display_discovery_in_flight : self . recording_display_discovery_in_flight ,
49+ audio_discovery_in_flight : self . recording_audio_discovery_in_flight ,
4650 paused : self . recording_paused ,
4751 progress : self . recording_progress ,
4852 } ;
@@ -796,22 +800,34 @@ fn recording_settings(
796800 audio : & str ,
797801 app : gpui:: Entity < FlashShotApp > ,
798802) -> gpui:: Div {
803+ let source_discovery_busy = recording_source_discovery_busy ( state) ;
804+ let settings_idle =
805+ !state. active && !state. starting && !state. stopping && !source_discovery_busy;
806+ let recording_toggle_enabled = !state. starting && !state. stopping && !source_discovery_busy;
799807 settings_section ( "Recording" , colors)
800808 . child ( settings_row ( "Display" , colors) . child ( settings_button (
801809 "settings-recording-display" ,
802- display,
810+ if state. display_discovery_in_flight {
811+ "Discovering..."
812+ } else {
813+ display
814+ } ,
803815 colors,
804- !state . active && !state . starting && !state . stopping ,
816+ settings_idle ,
805817 {
806818 let app = app. clone ( ) ;
807819 move |_, _, cx| app. update ( cx, |this, cx| this. cycle_recording_display ( cx) )
808820 } ,
809821 ) ) )
810822 . child ( settings_row ( "Audio" , colors) . child ( settings_button (
811823 "settings-recording-audio" ,
812- audio,
824+ if state. audio_discovery_in_flight {
825+ "Discovering..."
826+ } else {
827+ audio
828+ } ,
813829 colors,
814- !state . active && !state . starting && !state . stopping ,
830+ settings_idle ,
815831 {
816832 let app = app. clone ( ) ;
817833 move |_, _, cx| app. update ( cx, |this, cx| this. cycle_recording_audio ( cx) )
@@ -827,25 +843,17 @@ fn recording_settings(
827843 "settings-check-recording-support" ,
828844 "Check support" ,
829845 colors,
830- !state . active && !state . starting && !state . stopping ,
846+ settings_idle ,
831847 {
832848 let app = app. clone ( ) ;
833849 move |_, _, cx| app. update ( cx, |this, cx| this. check_recording_support ( cx) )
834850 } ,
835851 ) )
836852 . child ( settings_button (
837853 "settings-record-display" ,
838- if state. starting {
839- "Preparing..."
840- } else if state. stopping {
841- "Stopping..."
842- } else if state. active {
843- "Stop recording"
844- } else {
845- "Record display"
846- } ,
854+ recording_toggle_label ( state) ,
847855 colors,
848- !state . starting && !state . stopping ,
856+ recording_toggle_enabled ,
849857 {
850858 let app = app. clone ( ) ;
851859 move |_, _, cx| app. update ( cx, |this, cx| this. toggle_display_recording ( cx) )
@@ -886,6 +894,26 @@ fn recording_status_visible(state: RecordingViewState) -> bool {
886894 state. starting || state. active || state. stopping
887895}
888896
897+ /// Reports whether display or audio discovery is still changing the next recording input.
898+ fn recording_source_discovery_busy ( state : RecordingViewState ) -> bool {
899+ state. display_discovery_in_flight || state. audio_discovery_in_flight
900+ }
901+
902+ /// Gives the record command a truthful label while source discovery temporarily owns the action.
903+ fn recording_toggle_label ( state : RecordingViewState ) -> & ' static str {
904+ if state. starting {
905+ "Preparing..."
906+ } else if state. stopping {
907+ "Stopping..."
908+ } else if recording_source_discovery_busy ( state) {
909+ "Discovering..."
910+ } else if state. active {
911+ "Stop recording"
912+ } else {
913+ "Record display"
914+ }
915+ }
916+
889917/// Summarizes recording lifecycle and FFmpeg progress in the settings page while a capture runs.
890918fn recording_progress_label (
891919 recording_active : bool ,
@@ -2088,9 +2116,10 @@ mod tests {
20882116 RecordingViewState , capture_command_label, capture_shortcut_summary,
20892117 history_clear_confirmation_label, history_entry_label, history_entry_matches,
20902118 history_result_summary, history_retention_label, history_visibility_label,
2091- recording_progress_label, recording_status_visible, relative_timestamp_label,
2092- settings_navigation_items, settings_page_copy, settings_page_intro, settings_path_label,
2093- status_indicator_color, uses_compact_settings_navigation, visible_history_entries,
2119+ recording_progress_label, recording_source_discovery_busy, recording_status_visible,
2120+ recording_toggle_label, relative_timestamp_label, settings_navigation_items,
2121+ settings_page_copy, settings_page_intro, settings_path_label, status_indicator_color,
2122+ uses_compact_settings_navigation, visible_history_entries,
20942123 } ;
20952124 use crate :: app:: { HistoryClearScope , HistoryFilter , SettingsSection } ;
20962125 use crate :: history:: { HistoryEntry , HistorySource } ;
@@ -2262,18 +2291,37 @@ mod tests {
22622291 active: false ,
22632292 starting: false ,
22642293 stopping: true ,
2294+ display_discovery_in_flight: false ,
2295+ audio_discovery_in_flight: false ,
22652296 paused: false ,
22662297 progress: RecordingProgress :: default ( ) ,
22672298 } ) ) ;
22682299 assert ! ( !recording_status_visible( RecordingViewState {
22692300 active: false ,
22702301 starting: false ,
22712302 stopping: false ,
2303+ display_discovery_in_flight: false ,
2304+ audio_discovery_in_flight: false ,
22722305 paused: false ,
22732306 progress: RecordingProgress :: default ( ) ,
22742307 } ) ) ;
22752308 }
22762309
2310+ #[ test]
2311+ fn recording_controls_explain_discovery_busy_state ( ) {
2312+ let state = RecordingViewState {
2313+ active : false ,
2314+ starting : false ,
2315+ stopping : false ,
2316+ display_discovery_in_flight : true ,
2317+ audio_discovery_in_flight : false ,
2318+ paused : false ,
2319+ progress : RecordingProgress :: default ( ) ,
2320+ } ;
2321+ assert ! ( recording_source_discovery_busy( state) ) ;
2322+ assert_eq ! ( recording_toggle_label( state) , "Discovering..." ) ;
2323+ }
2324+
22772325 #[ test]
22782326 fn settings_navigation_compacts_before_the_content_column_becomes_too_narrow ( ) {
22792327 assert ! ( uses_compact_settings_navigation( 639.0 ) ) ;
0 commit comments