From bcbc93a6b9ccb5eb96e7de4739af369243f78629 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 21 Aug 2026 08:02:26 -0700 Subject: [PATCH] terminal/kitty: preserve image limits across full reset RIS previously cleared configured storage limits and allowed mediums. We now retain this properly. --- src/terminal/Screen.zig | 8 +++++++- src/terminal/Terminal.zig | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index a0333ee2f..9c89b02b1 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -417,8 +417,14 @@ pub fn reset(self: *Screen) void { if (comptime build_options.kitty_graphics) { // Reset kitty graphics storage + const image_limits = self.kitty_images.image_limits; + const total_limit = self.kitty_images.total_limit; self.kitty_images.deinit(self.alloc, self); - self.kitty_images = .{ .dirty = true }; + self.kitty_images = .{ + .dirty = true, + .image_limits = image_limits, + .total_limit = total_limit, + }; } // Reset our basic state diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index ef8c2586c..5c20cbed8 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -15406,6 +15406,32 @@ test "Terminal: fullReset status display" { try testing.expect(t.status_display == .main); } +test "Terminal: fullReset preserves kitty graphics limits" { + const alloc = testing.allocator; + const temp_dir = "/tmp/ghostty-kitty-images"; + + var t = try init(testing.io, alloc, .{ .cols = 10, .rows = 10 }); + defer t.deinit(alloc); + + t.setKittyGraphicsLoadingLimits(.allWithTempDir(temp_dir)); + for ([_]usize{ 1234, 0 }) |total_limit| { + t.setKittyGraphicsSizeLimit(alloc, total_limit); + t.fullReset(); + + const storage = &t.screens.active.kitty_images; + try testing.expectEqual(total_limit, storage.total_limit); + try testing.expect(storage.image_limits.file); + try testing.expect(storage.image_limits.shared_memory); + switch (storage.image_limits.temporary_file) { + .enabled => |value| try testing.expectEqualStrings( + temp_dir, + value.directory, + ), + .disabled => return error.TestUnexpectedResult, + } + } +} + // https://github.com/mitchellh/ghostty/issues/1607 test "Terminal: fullReset clears alt screen kitty keyboard state" { var t = try init(testing.io, testing.allocator, .{ .cols = 10, .rows = 10 });