Fix overlay: Directionality widget + startListening state guard

- Wrap overlay Stack with Directionality (required above MaterialApp)
- Guard startListening() for IncomingData/StaleData states to prevent
  overlay dismissal when status reloads on app resume

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 23:09:36 +08:00
parent 4c6130aa04
commit bb0346a843
2 changed files with 15 additions and 4 deletions

View File

@@ -76,7 +76,15 @@ class ChatRequest extends _$ChatRequest {
ChatRequestData build() => const ChatRequestIdleData(); ChatRequestData build() => const ChatRequestIdleData();
Future<void> startListening() async { Future<void> startListening() async {
if (state is ChatRequestAcceptingData || state is ChatRequestAcceptedData) return; // Don't reset state if showing a request, stale message, or actively accepting
if (state is ChatRequestIncomingData ||
state is ChatRequestStaleData ||
state is ChatRequestAcceptingData ||
state is ChatRequestAcceptedData) {
// Still reconnect WebSocket if needed, but don't change state
if (_channel == null) await _connectWebSocket();
return;
}
_closeWebSocket(); _closeWebSocket();
state = const ChatRequestListeningData(); state = const ChatRequestListeningData();
await _connectWebSocket(); await _connectWebSocket();

View File

@@ -79,7 +79,9 @@ class _ChatRequestOverlayState extends ConsumerState<ChatRequestOverlay>
} }
}); });
return Stack( return Directionality(
textDirection: TextDirection.ltr,
child: Stack(
children: [ children: [
widget.child, widget.child,
if (_visible) ...[ if (_visible) ...[
@@ -108,6 +110,7 @@ class _ChatRequestOverlayState extends ConsumerState<ChatRequestOverlay>
), ),
], ],
], ],
),
); );
} }