fix: only show disable language assistance popup is user manually closes IT (#5034)

This commit is contained in:
ggurdin 2026-01-02 14:43:54 -05:00 committed by GitHub
parent 354e3a14d1
commit 2a1daca3ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 10 deletions

View file

@ -519,7 +519,7 @@ class ChatController extends State<ChatPageWithRoom>
void _pangeaInit() {
choreographer = Choreographer(inputFocus);
choreographer.timesClosedIT.addListener(_onCloseIT);
choreographer.timesDismissedIT.addListener(_onCloseIT);
final updater = Matrix.of(context).analyticsDataService.updateDispatcher;
_levelSubscription = updater.levelUpdateStream.stream.listen(_onLevelUp);
@ -791,7 +791,7 @@ class ChatController extends State<ChatPageWithRoom>
_botAudioSubscription?.cancel();
_constructsSubscription?.cancel();
_router.routeInformationProvider.removeListener(_onRouteChanged);
choreographer.timesClosedIT.removeListener(_onCloseIT);
choreographer.timesDismissedIT.removeListener(_onCloseIT);
scrollController.dispose();
inputFocus.dispose();
depressMessageButton.dispose();
@ -2265,7 +2265,7 @@ class ChatController extends State<ChatPageWithRoom>
}
void _onCloseIT() {
if (choreographer.timesClosedIT.value >= 3) {
if (choreographer.timesDismissedIT.value >= 3) {
showDisableLanguageToolsPopup();
}
}

View file

@ -38,7 +38,7 @@ class Choreographer extends ChangeNotifier {
ChoreoRecordModel? _choreoRecord;
final ValueNotifier<bool> _isFetching = ValueNotifier(false);
final ValueNotifier<int> _timesClosedIT = ValueNotifier(0);
final ValueNotifier<int> _timesDismissedIT = ValueNotifier(0);
int _timesClicked = 0;
Timer? _debounceTimer;
@ -58,7 +58,7 @@ class Choreographer extends ChangeNotifier {
int get timesClicked => _timesClicked;
ValueNotifier<bool> get isFetching => _isFetching;
ValueNotifier<int> get timesClosedIT => _timesClosedIT;
ValueNotifier<int> get timesDismissedIT => _timesDismissedIT;
ChoreoModeEnum get choreoMode => _choreoMode;
String get currentText => textController.text;
@ -111,6 +111,7 @@ class Choreographer extends ChangeNotifier {
_choreoRecord = null;
itController.closeIT();
itController.clearSourceText();
itController.clearDissmissed();
igcController.clear();
_resetDebounceTimer();
_setChoreoMode(ChoreoModeEnum.igc);
@ -134,7 +135,7 @@ class Choreographer extends ChangeNotifier {
errorService.dispose();
textController.dispose();
_isFetching.dispose();
_timesClosedIT.dispose();
_timesDismissedIT.dispose();
TtsController.stop();
super.dispose();
@ -149,7 +150,7 @@ class Choreographer extends ChangeNotifier {
// if user is doing IT, call closeIT here to
// ensure source text is replaced when needed
if (itController.open.value && _timesClicked > 1) {
itController.closeIT();
itController.closeIT(dismiss: true);
}
}
}
@ -340,7 +341,10 @@ class Choreographer extends ChangeNotifier {
);
}
_timesClosedIT.value = _timesClosedIT.value + 1;
debugPrint("DISMISSED: ${itController.dismissed}");
if (itController.dismissed) {
_timesDismissedIT.value = _timesDismissedIT.value + 1;
}
_setChoreoMode(ChoreoModeEnum.igc);
errorService.resetError();
}

View file

@ -195,7 +195,8 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
spacing: 12.0,
children: [
_ITBarHeader(
onClose: widget.choreographer.itController.closeIT,
onClose: () =>
widget.choreographer.itController.closeIT(dismiss: true),
setEditing:
widget.choreographer.itController.setEditingSourceText,
editing: widget.choreographer.itController.editing,

View file

@ -35,6 +35,7 @@ class ITController {
StreamController.broadcast();
bool _continuing = false;
bool dismissed = false;
ITRequestModel _request(String textInput) {
assert(_sourceText.value != null);
@ -61,6 +62,10 @@ class ITController {
_sourceText.value = null;
}
void clearDissmissed() {
dismissed = false;
}
void dispose() {
acceptedContinuanceStream.close();
_open.dispose();
@ -75,10 +80,14 @@ class ITController {
_continueIT();
}
void closeIT() {
void closeIT({bool dismiss = false}) {
MatrixState.pAnyState.closeOverlay("it_feedback_card");
setEditingSourceText(false);
if (dismiss) {
dismissed = true;
}
_open.value = false;
_queue.clear();
_currentITStep.value = null;