File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ use warpui::{
3636 ViewHandle , WeakViewHandle ,
3737} ;
3838
39- use crate :: ai:: AIRequestUsageModel ;
39+ use crate :: ai:: request_usage_model :: { AIRequestUsageModel , AIRequestUsageModelEvent } ;
4040use crate :: appearance:: Appearance ;
4141use crate :: code:: buffer_location:: LocalOrRemotePath ;
4242use crate :: code:: editor:: comment_editor:: DEFAULT_COMMENT_MAX_WIDTH ;
@@ -233,6 +233,16 @@ impl CommentListView {
233233 Event :: ItemHovered => { }
234234 } ) ;
235235
236+ // Keep the stored button state in sync when AI availability changes.
237+ ctx. subscribe_to_model (
238+ & AIRequestUsageModel :: handle ( ctx) ,
239+ |me, _, event, ctx| {
240+ if let AIRequestUsageModelEvent :: RequestUsageUpdated = event {
241+ me. sync_send_button ( ctx) ;
242+ }
243+ } ,
244+ ) ;
245+
236246 Self {
237247 parent,
238248 comment_model : None ,
@@ -1188,7 +1198,9 @@ impl TypedActionView for CommentListView {
11881198 ctx. emit ( CommentListEvent :: Cancelled ) ;
11891199 }
11901200 CommentListAction :: Submit => {
1191- ctx. emit ( CommentListEvent :: Submitted ) ;
1201+ if self . can_send ( ctx) {
1202+ ctx. emit ( CommentListEvent :: Submitted ) ;
1203+ }
11921204 }
11931205 CommentListAction :: ShowOverflow { comment_id } => {
11941206 let current_overflow = self . active_overflow_comment_id . take ( ) ;
You can’t perform that action at this time.
0 commit comments