| .. | .. |
|---|
| 220 | 220 | // Delay sync slightly to let broker acknowledge our subscriptions first. |
|---|
| 221 | 221 | // Without this, the catch_up response arrives before pailot/control/out |
|---|
| 222 | 222 | // subscription is active, and the message is lost. |
|---|
| 223 | | - Future.delayed(const Duration(milliseconds: 500), () { |
|---|
| 223 | + Future.delayed(const Duration(milliseconds: 200), () { |
|---|
| 224 | 224 | if (!mounted) return; |
|---|
| 225 | 225 | final activeId = ref.read(activeSessionIdProvider); |
|---|
| 226 | 226 | _sendCommand('sync', activeId != null ? {'activeSessionId': activeId} : null); |
|---|
| .. | .. |
|---|
| 263 | 263 | // sent immediately if already connected. |
|---|
| 264 | 264 | _push = PushService(mqttService: _ws!); |
|---|
| 265 | 265 | _push!.onNotificationTap = (data) { |
|---|
| 266 | | - // Only switch if tapping a notification for a DIFFERENT session. |
|---|
| 267 | | - // If already on this session, the message is already displayed — |
|---|
| 268 | | - // calling switchSession would reload from disk and lose it. |
|---|
| 269 | 266 | final sessionId = data['sessionId'] as String?; |
|---|
| 270 | 267 | final activeId = ref.read(activeSessionIdProvider); |
|---|
| 268 | + // Immediately request catch_up — don't wait for the sync flow. |
|---|
| 269 | + // The message is already in the server queue. |
|---|
| 270 | + _sendCommand('catch_up', {'lastSeq': _lastSeq}); |
|---|
| 271 | 271 | if (sessionId != null && sessionId != activeId && mounted) { |
|---|
| 272 | 272 | _switchSession(sessionId); |
|---|
| 273 | 273 | } |
|---|