Reconnect on desktop after a dropped connection

After a timeout or a server shutdown the session counts down and connects
again, back to the channel it was in, waiting 5, 10, 20, 40 and then 60 s
between attempts. A kick, a ban, leaving, or connecting elsewhere ends it, as
does a retry refused with a ban. The status bar shows the countdown with a
Cancel link. Off by default in core, so Android keeps its own NetworkFollower.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 01:30:14 +00:00
co-authored by Claude Opus 5.5
parent b7a5828c43
commit 13c1e8a659
6 changed files with 230 additions and 5 deletions
@@ -181,6 +181,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
if (selected != null) selected.session().stopRecording();
}, () -> {
if (selected != null) selected.showOfflineMessages();
}, () -> {
if (selected != null) selected.session().cancelReconnect();
});
statusBar.setVisible(settings.showStatusBar);
add(statusBar, BorderLayout.SOUTH);
@@ -1171,6 +1173,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
private void updateStatusLabel() {
statusBar.setStatus(selected == null ? "Not connected" : selected.session().status());
statusBar.showReconnecting(selected != null && selected.session().isReconnecting());
}
private void updateConnectionStatus() {
@@ -74,6 +74,7 @@ final class ServerTab {
ServerTabConnectionEvents events = new ServerTabConnectionEvents(host, this, settings);
this.session = new ServerSession(settings, identities, audio, sounds, contacts, events);
this.conn = session.connection();
session.setAutoReconnect(true);
this.conn.setMyTeamSpeakLogin(host.myTeamSpeakLogin());
this.groupIcons = new GroupIcons(conn.getIcons());
this.chatPanel = new ChatPanel(host.chatZoom(), settings, pictures, conn::serverUniqueId);
@@ -3,10 +3,13 @@ package eu.lixko.ts3j.client.ui;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -14,7 +17,8 @@ import java.awt.event.MouseEvent;
/**
* The strip at the bottom of the window: connection status on the left, codec info on the
* right, and while the server on screen is being recorded, a label that stops it. An envelope
* shows while that server holds unread offline messages for us, and opens them.
* shows while that server holds unread offline messages for us, and opens them. While that
* server's connection is being re-established, a link beside the status cancels it.
*/
final class StatusBar extends JPanel {
@@ -22,8 +26,9 @@ final class StatusBar extends JPanel {
private final JLabel codecLabel = new JLabel();
private final JLabel recordingLabel = new JLabel("Recording", Icons.of("RECORDING_STOP"), JLabel.LEADING);
private final JLabel unreadLabel = new JLabel(Icons.of("OFFLINE_MESSAGES"));
private final JLabel cancelReconnectLabel = new JLabel("Cancel");
StatusBar(Runnable onStopRecording, Runnable onOpenOfflineMessages) {
StatusBar(Runnable onStopRecording, Runnable onOpenOfflineMessages, Runnable onCancelReconnect) {
super(new BorderLayout());
setBackground(Theme.statusBg());
setBorder(new ScaledEmptyBorder(3, 8, 3, 8));
@@ -48,13 +53,31 @@ final class StatusBar extends JPanel {
onOpenOfflineMessages.run();
}
});
cancelReconnectLabel.setFont(Theme.uiFont());
cancelReconnectLabel.setForeground(Theme.link());
cancelReconnectLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
cancelReconnectLabel.setVisible(false);
cancelReconnectLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
onCancelReconnect.run();
}
});
JPanel east = new JPanel(new FlowLayout(FlowLayout.TRAILING, UIScale.scale(12), 0));
east.setOpaque(false);
east.add(unreadLabel);
east.add(recordingLabel);
east.add(codecLabel);
// In the centre, a long status is cut short rather than drawn over the labels beside it.
add(statusLabel, BorderLayout.CENTER);
// A long status is cut short rather than drawn over the labels beside it.
statusLabel.setMinimumSize(new Dimension(0, 0));
JPanel west = new JPanel();
west.setLayout(new BoxLayout(west, BoxLayout.LINE_AXIS));
west.setOpaque(false);
west.add(statusLabel);
west.add(Box.createHorizontalStrut(UIScale.scale(8)));
west.add(cancelReconnectLabel);
west.add(Box.createHorizontalGlue());
add(west, BorderLayout.CENTER);
add(east, BorderLayout.EAST);
}
@@ -72,6 +95,10 @@ final class StatusBar extends JPanel {
statusLabel.setText(text);
}
void showReconnecting(boolean reconnecting) {
cancelReconnectLabel.setVisible(reconnecting);
}
void setCodec(String text) {
codecLabel.setText(text);
}