legion-tty 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -5
- data/lib/legion/tty/components/message_stream.rb +25 -2
- data/lib/legion/tty/screens/chat.rb +2 -4
- data/lib/legion/tty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdea3050f87e6b47ea8d03d9d3575acdecb2a3968c120cf3f9302068d21a88d9
|
|
4
|
+
data.tar.gz: d90acad8892d80dfab3ba292cb024a969037a4ddbde376535c26418d17cfb5a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9bc985a693932f6cd1ec9682306dc55eb282c3d7bc6e430305afdeb05962c2bd2c64d70ad6efba4177bf895519a3636ef659508c8182ead8b63410d5bd8bf78
|
|
7
|
+
data.tar.gz: cecd20a8b7842d4c41671458853a030a45e4276b00be917de6578c8c982024ef8c1b6a333ca43ffbbd7f48850c72416e78f47b4217420570dccf721d0ed8d691
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.5.
|
|
3
|
+
## [0.5.3] - 2026-04-20
|
|
4
4
|
|
|
5
5
|
### Fixed
|
|
6
|
-
- **
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **`normalize_key` paste passthrough** — Hash events (paste) pass through without KEY_MAP lookup (closes #22)
|
|
6
|
+
- **Scroll performance** — `MessageStream` now caches rendered lines per message keyed on `(object_id, content_hash, role, width, reactions, annotations, tags, pinned)`; cache invalidates automatically on content change (streaming), display option change, or width change — markdown re-parsing only runs for new/changed messages (closes #23)
|
|
7
|
+
- **Input coalescing** — `App#run_loop` drains all queued keys before the next `render_frame`, so rapid typing no longer triggers O(total-messages) renders per keystroke (closes #23)
|
|
8
|
+
- **PgUp/PgDn scroll step** — now scrolls by half-viewport (`(height-3)/2`) instead of a fixed 10 lines, matching Ctrl+B/Ctrl+F behavior (closes #23)
|
|
10
9
|
|
|
11
10
|
## [0.5.1] - 2026-04-18
|
|
12
11
|
|
|
@@ -28,10 +28,13 @@ module Legion
|
|
|
28
28
|
@show_numbers = false
|
|
29
29
|
@colorize = true
|
|
30
30
|
@show_timestamps = true
|
|
31
|
+
@line_cache = {}
|
|
32
|
+
@cache_options_hash = nil
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def add_message(role:, content:)
|
|
34
36
|
@messages << { role: role, content: content, tool_panels: [], timestamp: Time.now }
|
|
37
|
+
compact_cache if @line_cache.size > @messages.size * 2
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def append_streaming(text)
|
|
@@ -87,15 +90,35 @@ module Legion
|
|
|
87
90
|
|
|
88
91
|
private
|
|
89
92
|
|
|
90
|
-
def build_all_lines(width)
|
|
93
|
+
def build_all_lines(width) # rubocop:disable Metrics/AbcSize
|
|
94
|
+
current_opts = options_hash
|
|
95
|
+
if current_opts != @cache_options_hash
|
|
96
|
+
@line_cache.clear
|
|
97
|
+
@cache_options_hash = current_opts
|
|
98
|
+
end
|
|
99
|
+
|
|
91
100
|
filtered_messages.each_with_index.flat_map do |msg, idx|
|
|
92
101
|
next [] if @mute_system && msg[:role] == :system
|
|
93
102
|
next [] if @silent_mode && msg[:role] == :assistant
|
|
94
103
|
|
|
95
|
-
|
|
104
|
+
cache_key = message_cache_key(msg, width)
|
|
105
|
+
@line_cache[cache_key] ||= render_message(msg, width, @show_numbers ? idx + 1 : nil)
|
|
96
106
|
end
|
|
97
107
|
end
|
|
98
108
|
|
|
109
|
+
def options_hash
|
|
110
|
+
[@wrap_width, @show_numbers, @colorize, @show_timestamps, @highlights, @truncate_limit].hash
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def message_cache_key(msg, width)
|
|
114
|
+
[msg.object_id, msg[:content], msg[:role], width,
|
|
115
|
+
msg[:reactions], msg[:annotations], msg[:tags], msg[:pinned]].hash
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def compact_cache
|
|
119
|
+
@line_cache.clear
|
|
120
|
+
end
|
|
121
|
+
|
|
99
122
|
def filtered_messages
|
|
100
123
|
return @messages if @filter.nil?
|
|
101
124
|
|
|
@@ -208,12 +208,10 @@ module Legion
|
|
|
208
208
|
|
|
209
209
|
def handle_scroll_key(key)
|
|
210
210
|
case key
|
|
211
|
-
when :page_up
|
|
212
|
-
when :page_down
|
|
211
|
+
when :page_up, :ctrl_b then @message_stream.scroll_up(half_page_lines)
|
|
212
|
+
when :page_down, :ctrl_f then @message_stream.scroll_down(half_page_lines)
|
|
213
213
|
when :scroll_up then @message_stream.scroll_up(3)
|
|
214
214
|
when :scroll_down then @message_stream.scroll_down(3)
|
|
215
|
-
when :ctrl_b then @message_stream.scroll_up(half_page_lines)
|
|
216
|
-
when :ctrl_f then @message_stream.scroll_down(half_page_lines)
|
|
217
215
|
when :home then @message_stream.scroll_up(@message_stream.messages.size * 5)
|
|
218
216
|
when :end then @message_stream.scroll_down(@message_stream.scroll_offset)
|
|
219
217
|
else return nil
|
data/lib/legion/tty/version.rb
CHANGED