← Back to Kontasks
Mobile-Optimized SSE Reconnection
Implemented unlimited retries with exponential backoff for mobile browsers
Output
✅ Mobile-Optimized SSE Reconnection
The Problem
Android Firefox (and iOS Safari) freeze connections when you switch to another app. The previous code treated this as exceptional - giving up after 5 retries. But on mobile, disconnects are normal, not exceptional. You shouldn't be stuck in one app for an entire turn.
The Fix
| Before | After |
|---|---|
| Hard 5-retry limit | Unlimited retries |
| Retries accumulated across app switches | Reset on visibility change |
| Gave up after ~5 app switches | Never gives up - konsole keeps session alive |
| "RECONNECTING (5/5)..." scary countdown | "Reconnecting..." then "(attempt N)" after 3 |
How It Works Now
- Exponential backoff: 1s → 1.5s → 2.25s → ... → 30s max
- Visibility change resets everything: When you return from another app, backoff resets to 1s and attempt counter resets
- Smart status display: Shows "Reconnecting..." for first 3 attempts, then "(attempt N)" for transparency
- Only retries while running: Won't keep reconnecting if the turn completed while you were away
Files Changed
konui/src/console-streaming.ts- New backoff strategy,resetReconnectState()konui/src/console-events.ts- Reset on visibility change
Commit
9276f4ca pushed to main
Test It
Konui restarted - try switching apps while a turn is running. When you return, it should immediately reconnect without the scary countdown.
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
consolemobilessereconnection
Created
7 Jan 2026, 7:34 pm
Updated
7 Jan 2026, 7:34 pm
Created By
claude
Raw Data
{
"id": "735db6d0-06b8-48ce-84d6-0750bde613ab",
"type": "general",
"status": "completed",
"title": "Mobile-Optimized SSE Reconnection",
"description": "Implemented unlimited retries with exponential backoff for mobile browsers",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:sans-serif;\">\n<h2 style=\"color:#22c55e;margin:0 0 16px 0;\">✅ Mobile-Optimized SSE Reconnection</h2>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">The Problem</h3>\n<p style=\"margin:0;line-height:1.6;\">Android Firefox (and iOS Safari) freeze connections when you switch to another app. The previous code treated this as exceptional - giving up after 5 retries. But on mobile, <strong>disconnects are normal</strong>, not exceptional. You shouldn't be stuck in one app for an entire turn.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">The Fix</h3>\n<table style=\"width:100%;border-collapse:collapse;\">\n<tr style=\"border-bottom:1px solid #444;\">\n<th style=\"text-align:left;padding:8px;color:#9ca3af;\">Before</th>\n<th style=\"text-align:left;padding:8px;color:#9ca3af;\">After</th>\n</tr>\n<tr style=\"border-bottom:1px solid #444;\">\n<td style=\"padding:8px;\">Hard 5-retry limit</td>\n<td style=\"padding:8px;color:#22c55e;\">Unlimited retries</td>\n</tr>\n<tr style=\"border-bottom:1px solid #444;\">\n<td style=\"padding:8px;\">Retries accumulated across app switches</td>\n<td style=\"padding:8px;color:#22c55e;\">Reset on visibility change</td>\n</tr>\n<tr style=\"border-bottom:1px solid #444;\">\n<td style=\"padding:8px;\">Gave up after ~5 app switches</td>\n<td style=\"padding:8px;color:#22c55e;\">Never gives up - konsole keeps session alive</td>\n</tr>\n<tr>\n<td style=\"padding:8px;\">\"RECONNECTING (5/5)...\" scary countdown</td>\n<td style=\"padding:8px;color:#22c55e;\">\"Reconnecting...\" then \"(attempt N)\" after 3</td>\n</tr>\n</table>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">How It Works Now</h3>\n<ul style=\"margin:0;padding-left:20px;line-height:1.8;\">\n<li><strong>Exponential backoff:</strong> 1s → 1.5s → 2.25s → ... → 30s max</li>\n<li><strong>Visibility change resets everything:</strong> When you return from another app, backoff resets to 1s and attempt counter resets</li>\n<li><strong>Smart status display:</strong> Shows \"Reconnecting...\" for first 3 attempts, then \"(attempt N)\" for transparency</li>\n<li><strong>Only retries while running:</strong> Won't keep reconnecting if the turn completed while you were away</li>\n</ul>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">Files Changed</h3>\n<ul style=\"margin:0;padding-left:20px;line-height:1.8;\">\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;\">konui/src/console-streaming.ts</code> - New backoff strategy, <code>resetReconnectState()</code></li>\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;\">konui/src/console-events.ts</code> - Reset on visibility change</li>\n</ul>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">Commit</h3>\n<p style=\"margin:0;\"><code style=\"background:#22c55e;color:#fff;padding:4px 8px;border-radius:4px;\">9276f4ca</code> pushed to main</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-top:16px;\">\n<h4 style=\"margin:0 0 8px 0;color:#fff;\">Test It</h4>\n<p style=\"color:#9ca3af;margin:0;\">Konui restarted - try switching apps while a turn is running. When you return, it should immediately reconnect without the scary countdown.</p>\n</div>\n</div>",
"requestedAt": "2026-01-07T18:32:00Z",
"requestId": "82576f01-ae8a-4452-8211-22ec8c1fdb92",
"choices": [
{
"label": "Test now",
"value": "I'll test the reconnection fix by switching apps during this turn",
"primary": true
},
{
"label": "View backlog",
"value": "Show me the current backlog priorities"
},
{
"label": "Run tests",
"value": "Run the konui test suite"
}
]
},
"createdBy": "claude",
"createdAt": "2026-01-07T09:34:45.788Z",
"updatedAt": "2026-01-07T09:34:46.023Z",
"requestId": "82576f01-ae8a-4452-8211-22ec8c1fdb92",
"scope": "vibetools",
"tags": [
"console",
"mobile",
"sse",
"reconnection"
],
"targetUser": "claude"
}