From ccf862eab4faeb99677e6e86d81f8f52c5ca5be5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 7 Nov 2026 11:03:56 +0530 Subject: [PATCH] Use an accurate title for the overlay showing startup errors Errors during startup that are not caused by invalid config lines, such as failing to listen on the remote control socket, were shown under the title "Errors parsing configuration" with the heading "In final effective configuration". The title now reflects whether the errors are config parse errors, startup errors or both. --- kitty/boss.py | 14 ++++++++++++-- kitty_tests/iterable_arguments.py | 21 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index e09cc1382..79b9a718f 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -3906,12 +3906,22 @@ class Boss: if file: a(f'In file {file}:') [a(format_bad_line(x)) for x in groups[file]] + # misc_errors are errors that happen during startup that are not + # caused by invalid lines in the config, such as failing to listen on + # the remote control socket if misc_errors := tuple(misc_errors): - a('In final effective configuration:') + if groups: + a('Other errors:') for line in misc_errors: a(line) msg = '\n'.join(ans).rstrip() - self.show_error(_('Errors parsing configuration'), msg) + if groups and misc_errors: + title = _('Errors parsing configuration and during startup') + elif misc_errors: + title = _('Errors during startup') + else: + title = _('Errors parsing configuration') + self.show_error(title, msg) @ac( 'misc', diff --git a/kitty_tests/iterable_arguments.py b/kitty_tests/iterable_arguments.py index 12ab7760c..1d98aef4e 100644 --- a/kitty_tests/iterable_arguments.py +++ b/kitty_tests/iterable_arguments.py @@ -48,12 +48,27 @@ class IterableArgumentsTest(BaseTest): def test_config_error_iterable(self): for container in (list, tuple, iter): - for values in ((), ('configuration error',)): + for values in ((), ('startup error',)): with self.subTest(container=container, values=values): boss = SimpleNamespace(show_error=Mock()) Boss.show_bad_config_lines(boss, (), container(values)) - message = boss.show_error.call_args.args[1] - self.ae(message, 'In final effective configuration:\nconfiguration error' if values else '') + title, message = boss.show_error.call_args.args[:2] + self.ae(message, 'startup error' if values else '') + self.ae(title, 'Errors during startup' if values else 'Errors parsing configuration') + + def test_config_error_titles(self): + from kitty.conf.utils import BadLine + + bad = BadLine(3, 'font_size x', ValueError('invalid'), '/some/kitty.conf') + boss = SimpleNamespace(show_error=Mock()) + Boss.show_bad_config_lines(boss, (bad,)) + title, message = boss.show_error.call_args.args[:2] + self.ae(title, 'Errors parsing configuration') + self.ae(message, 'In file /some/kitty.conf:\n3:invalid in line: font_size x') + Boss.show_bad_config_lines(boss, (bad,), ('startup error',)) + title, message = boss.show_error.call_args.args[:2] + self.ae(title, 'Errors parsing configuration and during startup') + self.ae(message, 'In file /some/kitty.conf:\n3:invalid in line: font_size x\n\nOther errors:\nstartup error') def test_watcher_iterable(self): for container in (list, tuple, iter):