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();
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();
state = const ChatRequestListeningData();
await _connectWebSocket();

View File

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