Drop the line count from the Server Log window

The label under the log now only appears while loading, on a failure or
for an empty log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-04 13:23:31 +00:00
co-authored by Claude Opus 5.5
parent 8255d986ac
commit 93e0b36083
@@ -90,7 +90,8 @@ final class ServerLogDialog extends JDialog {
private final Map<Level, JCheckBox> levelBoxes = new EnumMap<>(Level.class);
private final JComboBox<String> timeZone = new JComboBox<>(new String[]{"UTC time", "Local time"});
private final JButton olderButton = new JButton("Show Older");
private final JLabel status = new JLabel(" ");
/** Loading, failures and an empty log; hidden otherwise. */
private final JLabel status = new JLabel();
/** Everything read so far, oldest first. */
private final List<ServerLogEntry> entries = new ArrayList<>();
@@ -215,7 +216,7 @@ final class ServerLogDialog extends JDialog {
bottom.setOpaque(false);
bottom.add(status, BorderLayout.NORTH);
bottom.add(row, BorderLayout.SOUTH);
status.setForeground(Theme.chatEvent());
status.setVisible(false);
return bottom;
}
@@ -261,8 +262,7 @@ final class ServerLogDialog extends JDialog {
if (loading) return;
loading = true;
olderButton.setEnabled(false);
status.setForeground(Theme.chatEvent());
status.setText("Loading…");
showStatus("Loading…", Theme.chatEvent());
conn.requestServerLog(from, (page, error) -> SwingUtilities.invokeLater(() -> {
loading = false;
if (!isDisplayable()) return;
@@ -285,10 +285,10 @@ final class ServerLogDialog extends JDialog {
}
private void failed(String error) {
status.setForeground(Theme.isDark() ? new Color(0xFF6B6B) : new Color(0xC00000));
status.setText(error.toLowerCase(Locale.ROOT).contains("insufficient")
showStatus(error.toLowerCase(Locale.ROOT).contains("insufficient")
? "Insufficient permissions to view Server Log"
: "Error requesting server log: " + error);
: "Error requesting server log: " + error,
Theme.isDark() ? new Color(0xFF6B6B) : new Color(0xC00000));
}
private void settingsChanged() {
@@ -304,7 +304,6 @@ final class ServerLogDialog extends JDialog {
for (ServerLogEntry e : entries) channelWidth = Math.max(channelWidth, e.channel().length());
int scrollY = log.getVisibleRect().y;
int shown = 0;
try {
doc.remove(0, doc.getLength());
for (ServerLogEntry e : entries) {
@@ -312,16 +311,12 @@ final class ServerLogDialog extends JDialog {
if (!view.shows(e.level(), line)) continue;
if (onlyMatching != null && !onlyMatching.matches(line)) continue;
doc.insertString(doc.getLength(), line + "\n", style(view.highlightFor(line)));
shown++;
}
} catch (BadLocationException ignored) {
// appending at the end never fails
}
status.setForeground(Theme.chatEvent());
if (entries.isEmpty()) status.setText("No log entries available");
else if (shown == entries.size()) status.setText(lines(shown));
else status.setText(shown + " of " + lines(entries.size()));
showStatus(entries.isEmpty() ? "No log entries available" : null, Theme.chatEvent());
if (toEnd) {
log.setCaretPosition(doc.getLength());
@@ -331,8 +326,11 @@ final class ServerLogDialog extends JDialog {
}
}
private static String lines(int n) {
return n == 1 ? "1 line" : n + " lines";
/** Shows {@code text} under the log, or hides the label for {@code null}. */
private void showStatus(String text, Color color) {
status.setText(text);
status.setForeground(color);
status.setVisible(text != null);
}
private String format(ServerLogEntry e, int channelWidth) {