Module: Clacky::UIInterface

Overview

UIInterface defines the standard interface between Agent/CLI and UI implementations. All UI controllers (UIController, JsonUIController) must implement these methods.

Defined Under Namespace

Classes: LegacyProgressHandleAdapter

Instance Method Summary collapse

Instance Method Details

#append_output(content) ⇒ Object



23
# File 'lib/clacky/ui_interface.rb', line 23

def append_output(content); end

#clear_inputObject

Input control (CLI layer) ===



118
# File 'lib/clacky/ui_interface.rb', line 118

def clear_input; end

#log(message, level: :info) ⇒ Object



30
# File 'lib/clacky/ui_interface.rb', line 30

def log(message, level: :info); end

#request_confirmation(message, default: true) ⇒ Object

Blocking interaction ===



115
# File 'lib/clacky/ui_interface.rb', line 115

def request_confirmation(message, default: true); end

#set_idle_statusObject



112
# File 'lib/clacky/ui_interface.rb', line 112

def set_idle_status; end

#set_input_tips(message, type: :info) ⇒ Object



119
# File 'lib/clacky/ui_interface.rb', line 119

def set_input_tips(message, type: :info); end

#set_working_statusObject



111
# File 'lib/clacky/ui_interface.rb', line 111

def set_working_status; end

#show_assistant_message(content, files:) ⇒ Object

Output display ===

Parameters:

  • content (String)

    text portion of the assistant reply (file:// links stripped)

  • files (Array<Hash>)

    extracted file refs: [{ name:, path:, inline: }]



10
# File 'lib/clacky/ui_interface.rb', line 10

def show_assistant_message(content, files:); end

#show_complete(iterations:, cost:, duration: nil, cache_stats: nil, awaiting_user_feedback: false) ⇒ Object



22
# File 'lib/clacky/ui_interface.rb', line 22

def show_complete(iterations:, cost:, duration: nil, cache_stats: nil, awaiting_user_feedback: false); end

#show_diff(old_content, new_content, max_lines: 50) ⇒ Object



20
# File 'lib/clacky/ui_interface.rb', line 20

def show_diff(old_content, new_content, max_lines: 50); end

#show_error(message) ⇒ Object



28
# File 'lib/clacky/ui_interface.rb', line 28

def show_error(message); end

#show_file_edit_preview(path) ⇒ Object



17
# File 'lib/clacky/ui_interface.rb', line 17

def show_file_edit_preview(path); end

#show_file_error(error_message) ⇒ Object



18
# File 'lib/clacky/ui_interface.rb', line 18

def show_file_error(error_message); end

#show_file_write_preview(path, is_new_file:) ⇒ Object



16
# File 'lib/clacky/ui_interface.rb', line 16

def show_file_write_preview(path, is_new_file:); end

#show_info(message, prefix_newline: true) ⇒ Object

Status messages ===



26
# File 'lib/clacky/ui_interface.rb', line 26

def show_info(message, prefix_newline: true); end

#show_progress(message = nil, prefix_newline: true, progress_type: "thinking", phase: "active", metadata: {}) ⇒ Object

Progress ===

Unified progress indicator with type-based display customization. progress_type: “thinking” | “retrying” | “idle_compress” | custom phase: “active” | “done” metadata: extensible hash (e.g., 3, total: 10 for retries)



37
# File 'lib/clacky/ui_interface.rb', line 37

def show_progress(message = nil, prefix_newline: true, progress_type: "thinking", phase: "active", metadata: {}); end

#show_shell_preview(command) ⇒ Object



19
# File 'lib/clacky/ui_interface.rb', line 19

def show_shell_preview(command); end

#show_success(message) ⇒ Object



29
# File 'lib/clacky/ui_interface.rb', line 29

def show_success(message); end

#show_token_usage(token_data) ⇒ Object



21
# File 'lib/clacky/ui_interface.rb', line 21

def show_token_usage(token_data); end

#show_tool_args(formatted_args) ⇒ Object



15
# File 'lib/clacky/ui_interface.rb', line 15

def show_tool_args(formatted_args); end

#show_tool_call(name, args) ⇒ Object



11
# File 'lib/clacky/ui_interface.rb', line 11

def show_tool_call(name, args); end

#show_tool_error(error) ⇒ Object



14
# File 'lib/clacky/ui_interface.rb', line 14

def show_tool_error(error); end

#show_tool_result(result) ⇒ Object



12
# File 'lib/clacky/ui_interface.rb', line 12

def show_tool_result(result); end

#show_tool_stdout(lines) ⇒ Object



13
# File 'lib/clacky/ui_interface.rb', line 13

def show_tool_stdout(lines); end

#show_warning(message) ⇒ Object



27
# File 'lib/clacky/ui_interface.rb', line 27

def show_warning(message); end

#start_progress(message: nil, style: :primary, quiet_on_fast_finish: false) ⇒ #update, ...

Progress (v2: owned handles) ===

Start a new progress indicator and return an owned handle. The caller is responsible for finishing it — use with_progress (below) whenever possible to get ensure-based auto-close.

Default implementation degrades gracefully to the old show_progress API so UI implementations that haven’t migrated still behave correctly.

Parameters:

  • message (String, nil) (defaults to: nil)

    Initial progress message (nil picks a random thinking verb).

  • style (Symbol) (defaults to: :primary)

    :primary (foreground, yellow, bumps sessionbar) or :quiet (background, gray, no sessionbar change).

  • quiet_on_fast_finish (Boolean) (defaults to: false)

    When true, a finish under FAST_FINISH_THRESHOLD_SECONDS removes the progress line entirely (preferred for per-tool wrappers so fast tools don’t leave a permanent “Executing foo… (0s)” log line). The default implementation ignores this flag — it only affects the native UI2::UIController + ProgressHandle path.

Returns:

  • (#update, #finish, #cancel)

    a ProgressHandle-like object.



58
59
60
61
62
63
# File 'lib/clacky/ui_interface.rb', line 58

def start_progress(message: nil, style: :primary, quiet_on_fast_finish: false)
  _ = quiet_on_fast_finish # default impl doesn't honor fast-collapse
  progress_type = style == :primary ? "thinking" : "idle_compress"
  show_progress(message, progress_type: progress_type, phase: "active")
  LegacyProgressHandleAdapter.new(self, progress_type: progress_type)
end

#stopObject

Path redaction (for encrypted brand skill tmpdirs) ===

Lifecycle ===



123
# File 'lib/clacky/ui_interface.rb', line 123

def stop; end

#update_sessionbar(tasks: nil, cost: nil, cost_source: nil, status: nil) ⇒ Object

State updates ===



109
# File 'lib/clacky/ui_interface.rb', line 109

def update_sessionbar(tasks: nil, cost: nil, cost_source: nil, status: nil); end

#update_todos(todos) ⇒ Object



110
# File 'lib/clacky/ui_interface.rb', line 110

def update_todos(todos); end

#with_progress(message: nil, style: :primary, quiet_on_fast_finish: false) {|handle| ... } ⇒ Object

Run the given block with a progress indicator active. The handle is always finished in an ensure block — exceptions (including AgentInterrupted) cannot leave the ticker or entry orphaned.

Yield Parameters:

  • handle

    the progress handle



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/clacky/ui_interface.rb', line 70

def with_progress(message: nil, style: :primary, quiet_on_fast_finish: false)
  handle = start_progress(
    message: message,
    style: style,
    quiet_on_fast_finish: quiet_on_fast_finish
  )
  begin
    yield handle
  ensure
    handle.finish
  end
end