feat(gui): Add _render_thinking_trace helper and integrate into Discussion Hub

This commit is contained in:
2026-03-13 22:07:13 -04:00
parent 084f9429af
commit 1ad146b38e
3 changed files with 35 additions and 9 deletions

View File

@@ -317,11 +317,28 @@ class App:
markdown_helper.render_code(content, context_id=ctx_id)
if is_nerv: imgui.pop_style_color()
# ---------------------------------------------------------------- gui
if is_nerv: imgui.pop_style_color()
def _render_thinking_trace(self, segments: list[dict], entry_index: int) -> None:
if not segments:
return
imgui.indent()
header_id = f"thinking_header_{entry_index}"
if imgui.collapsing_header(f"Thinking ({len(segments)} traces)", header_id):
imgui.begin_child(f"thinking_content_{entry_index}", imgui.ImVec2(0, 80), True)
for idx, seg in enumerate(segments):
content = seg.get("content", "")
marker = seg.get("marker", "thinking")
imgui.push_id(f"think_{entry_index}_{idx}")
imgui.text_colored(vec4(180, 180, 100), f"[{marker}]")
imgui.same_line()
imgui.textWrapped(content)
imgui.pop_id()
imgui.separator()
imgui.end_child()
imgui.unindent()
def _render_selectable_label(self, label: str, value: str, width: float = 0.0, multiline: bool = False, height: float = 0.0, color: Optional[imgui.ImVec4] = None) -> None:
imgui.push_id(label + str(hash(value)))
pops = 4
imgui.push_style_color(imgui.Col_.frame_bg, vec4(0, 0, 0, 0))
imgui.push_style_color(imgui.Col_.frame_bg_hovered, vec4(0, 0, 0, 0))
@@ -2297,10 +2314,11 @@ def hello():
imgui.end_child()
else:
ch, entry["content"] = imgui.input_text_multiline("##content", entry["content"], imgui.ImVec2(-1, 150))
thinking_segments = entry.get("thinking_segments", [])
if thinking_segments:
self._render_thinking_trace(thinking_segments, i)
imgui.separator()
imgui.pop_id()
if self._scroll_disc_to_bottom:
imgui.set_scroll_here_y(1.0)
self._scroll_disc_to_bottom = False
imgui.end_child()