From b706c130842affaf0d815e31b5bd609fefc86feb Mon Sep 17 00:00:00 2001 From: twokidsCarl Date: Tue, 7 Apr 2026 22:36:56 -0700 Subject: [PATCH] Filter pre-existing binding variables from status panel Record baseline local variables at TUI init and exclude them from the Binding section in the status panel. Only user-defined variables (created during the session) are shown. Co-Authored-By: Claude Opus 4.6 --- lib/claw/tui/model.rb | 7 ++++++- lib/claw/tui/status_panel.rb | 18 ++++++++++-------- lib/claw/version.rb | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/claw/tui/model.rb b/lib/claw/tui/model.rb index d9cf3ca..b148334 100644 --- a/lib/claw/tui/model.rb +++ b/lib/claw/tui/model.rb @@ -33,7 +33,7 @@ module TUI # Implements Bubbletea's init/update/view protocol. class Model attr_reader :runtime, :chat_history, :mode, :chat_viewport, :executor, :textarea, - :baseline_methods, :input_history, :zone + :baseline_methods, :baseline_vars, :input_history, :zone attr_accessor :chat_ratio, :dragging_divider def initialize(caller_binding) @@ -56,6 +56,11 @@ def initialize(caller_binding) rescue [] end + @baseline_vars = begin + caller_binding.local_variables.map(&:to_s) + rescue + [] + end # Bubbles components @chat_viewport = Bubbles::Viewport.new(width: 80, height: 20) diff --git a/lib/claw/tui/status_panel.rb b/lib/claw/tui/status_panel.rb index 291dadb..8d76f64 100644 --- a/lib/claw/tui/status_panel.rb +++ b/lib/claw/tui/status_panel.rb @@ -7,11 +7,11 @@ module StatusPanel def self.render(model, width, height) sections = [] - sections << render_binding(model, width - 4) - sections << render_snapshots(model, width - 4) - sections << render_memory(model, width - 4) - sections << render_tokens(model, width - 4) - sections << render_status(model, width - 4) + sections << render_binding(model, width - 2) + sections << render_snapshots(model, width - 2) + sections << render_memory(model, width - 2) + sections << render_tokens(model, width - 2) + sections << render_status(model, width - 2) # Truncate content to fit within available height all_lines = sections.join("\n").split("\n") @@ -27,7 +27,9 @@ def self.render_binding(model, width) return "#{header}\n (not tracked)" unless binding_res lines = [header] - binding_res.tracked.each do |name, blob| + baseline = model.baseline_vars || [] + user_vars = binding_res.tracked.reject { |name, _| baseline.include?(name) } + user_vars.each do |name, blob| val = begin v = MarshalMd.load(blob) "#{v.class} (#{summary_value(v)})" @@ -37,7 +39,7 @@ def self.render_binding(model, width) line = " #{name}: #{val}" lines << truncate(line, width) end - lines << " (empty)" if binding_res.tracked.empty? + lines << " (empty)" if user_vars.empty? # Show user-defined methods (only those added during session) begin @@ -81,7 +83,7 @@ def self.render_memory(model, width) count = memory.long_term.size lines = [header, " #{count} facts"] memory.long_term.last(3).each do |m| - lines << " · #{truncate(m[:content].to_s, width - 4)}" + lines << " · #{truncate(m[:content].to_s, width - 2)}" end lines.join("\n") end diff --git a/lib/claw/version.rb b/lib/claw/version.rb index 63a820a..2ef8b00 100644 --- a/lib/claw/version.rb +++ b/lib/claw/version.rb @@ -2,5 +2,5 @@ module Claw VERSION = "0.2.2" - BUILD = "20260407-014" + BUILD = "20260407-015" end