Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/claw/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class << self
#
# @param bind [Binding] the binding whose variables to save
# @param dir [String] directory to write state files into
def save(bind, dir)
def save(bind, dir, baseline_vars: [])
FileUtils.mkdir_p(dir)
save_values(bind, dir)
save_values(bind, dir, baseline_vars: baseline_vars)
save_definitions(bind, dir)
end

Expand All @@ -35,14 +35,16 @@ def restore(bind, dir)

# --- Values ---

def save_values(bind, dir)
def save_values(bind, dir, baseline_vars: [])
values = {}
bind.local_variables.each do |name|
val = bind.local_variable_get(name)
next if name.to_s.start_with?("_")
name_s = name.to_s
next if name_s.start_with?("_")
next if baseline_vars.include?(name_s)

val = bind.local_variable_get(name)
encoded = encode_value(val)
values[name.to_s] = encoded if encoded
values[name_s] = encoded if encoded
end

path = File.join(dir, VALUES_FILE)
Expand Down
5 changes: 3 additions & 2 deletions lib/claw/tui/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "bubbletea"
require "bubbles"
require "io/console"
require "pp"

begin
require "bubblezone"
Expand Down Expand Up @@ -52,7 +53,7 @@ def initialize(caller_binding)
@view_height = 24
@zone = defined?(Bubblezone::Manager) ? Bubblezone::Manager.new : nil
@baseline_methods = begin
caller_binding.eval("methods").dup
caller_binding.eval("methods | private_methods").dup
rescue
[]
end
Expand Down Expand Up @@ -657,7 +658,7 @@ def write_trace(trace_data)
end

def save_state
Claw::Serializer.save(@caller_binding, File.join(Dir.pwd, ".ruby-claw")) if Claw.config.persist_session
Claw::Serializer.save(@caller_binding, File.join(Dir.pwd, ".ruby-claw"), baseline_vars: @baseline_vars) if Claw.config.persist_session
Claw.memory&.save_session
rescue
# ignore save failures
Expand Down
2 changes: 1 addition & 1 deletion lib/claw/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Claw
VERSION = "0.2.2"
BUILD = "20260407-015"
BUILD = "20260407-016"
end
Loading