Files
RoboMovel/simulacao/robo-movel-godot/addons/claude_godot/ui/reasoning_card.gd
T
mguinhosandClaude Opus 5.5 393019705c Projeto: app demo, servidor/firmware em software/, simulacao Godot, planta do bloco D, chapas MDF da base, renders e slides
- app/: app demo (Kivy/buildozer) da API do robo
- software/: servidor RoboMovel (SLAM, profundidade, navegacao) e firmware da base movel (movido de firmware/)
- simulacao/: projeto Godot do robo e script de lancamento servidor + simulacao
- modelos/: planta do 5o andar do bloco D, cena Blender do corredor e modelo real do robo
- partes/mdf/: chapas identificadas e nesting da base do robo (DXF/SVG/FCStd)
- projeto/render, relatorio/imagens, slides: renders finais e apresentacoes de progresso
- ferramentas/scripts: encaixe de chapas, planta do bloco D e render do corredor no Blender
- .gitignore: ignora backups do Blender/FreeCAD e .godot/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:38:16 -03:00

77 lines
2.2 KiB
GDScript

## A collapsed panel for the model's pre-action commentary.
##
## Reasoning is worth showing — it explains the tool call that follows — but
## rendered inline it buries the conversation, since a model thinking through
## a task will produce far more of it than of answer. So it collapses to one
## line and opens on click, the same shape the tool cards use.
@tool
class_name ClaudeGodotReasoningCard
extends VBoxContainer
const COLOR_DIM := "#8a8a8a"
const MAX_BODY_LINES := 200
var _text := ""
var _expanded := false
var _header: Button
var _header_label: RichTextLabel
var _body: VBoxContainer
func setup(text: String) -> void:
_text = text
_header = Button.new()
_header.flat = true
_header.custom_minimum_size = Vector2(0, 22)
_header.pressed.connect(_toggle)
add_child(_header)
_header_label = RichTextLabel.new()
_header_label.bbcode_enabled = true
_header_label.scroll_active = false
_header_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
_header_label.set_anchors_preset(Control.PRESET_FULL_RECT)
_header.add_child(_header_label)
_body = VBoxContainer.new()
_body.visible = false
add_child(_body)
_refresh_header()
func to_plain_text() -> String:
return _text
func _toggle() -> void:
_expanded = not _expanded
_body.visible = _expanded
if _expanded and _body.get_child_count() == 0:
var rtl := RichTextLabel.new()
rtl.bbcode_enabled = true
rtl.fit_content = true
rtl.scroll_active = false
rtl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
rtl.append_text("[i][color=%s]%s[/color][/i]" % [COLOR_DIM, _capped(_text)])
_body.add_child(rtl)
_refresh_header()
func _refresh_header() -> void:
_header_label.clear()
_header_label.append_text("[color=%s]%s thought · %d words[/color]" % [
COLOR_DIM, "▾" if _expanded else "▸", _word_count(),
])
func _word_count() -> int:
var n := 0
for word in _text.split(" ", false):
if word.strip_edges() != "":
n += 1
return n
func _capped(text: String) -> String:
var escaped := text.replace("[", "[lb]")
var lines := escaped.split("\n")
if lines.size() <= MAX_BODY_LINES:
return escaped
return "\n".join(lines.slice(0, MAX_BODY_LINES)) + "\n… %d more lines" % (lines.size() - MAX_BODY_LINES)