fix(gui): Properly add thinking trace without breaking _render_selectable_label
This commit is contained in:
16
src/gui_2.py
16
src/gui_2.py
@@ -317,7 +317,7 @@ class App:
|
|||||||
markdown_helper.render_code(content, context_id=ctx_id)
|
markdown_helper.render_code(content, context_id=ctx_id)
|
||||||
|
|
||||||
if is_nerv: imgui.pop_style_color()
|
if is_nerv: imgui.pop_style_color()
|
||||||
if is_nerv: imgui.pop_style_color()
|
# ---------------------------------------------------------------- gui
|
||||||
|
|
||||||
def _render_thinking_trace(self, segments: list[dict], entry_index: int) -> None:
|
def _render_thinking_trace(self, segments: list[dict], entry_index: int) -> None:
|
||||||
if not segments:
|
if not segments:
|
||||||
@@ -340,15 +340,19 @@ class App:
|
|||||||
imgui.end_child()
|
imgui.end_child()
|
||||||
imgui.unindent()
|
imgui.unindent()
|
||||||
imgui.pop_style_color(2)
|
imgui.pop_style_color(2)
|
||||||
|
|
||||||
|
|
||||||
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:
|
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
|
pops = 4
|
||||||
imgui.push_style_color(imgui.Col_.frame_bg, vec4(0, 0, 0, 0))
|
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))
|
imgui.push_style_color(imgui.Col_.frame_bg_hovered, vec4(0, 0, 0, 0))
|
||||||
imgui.push_style_color(imgui.Col_.frame_bg_active, vec4(0, 0, 0, 0))
|
imgui.push_style_color(imgui.Col_.frame_bg_active, vec4(0, 0, 0, 0))
|
||||||
imgui.push_style_color(imgui.Col_.border, vec4(0, 0, 0, 0))
|
imgui.push_style_color(imgui.Col_.border, vec4(0, 0, 0, 0))
|
||||||
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:
|
if color:
|
||||||
imgui.push_id(label)
|
imgui.push_style_color(imgui.Col_.text, color)
|
||||||
pops = 4
|
pops += 1
|
||||||
|
imgui.push_style_var(imgui.StyleVar_.frame_border_size, 0.0)
|
||||||
imgui.push_style_var(imgui.StyleVar_.frame_padding, imgui.ImVec2(0, 0))
|
imgui.push_style_var(imgui.StyleVar_.frame_padding, imgui.ImVec2(0, 0))
|
||||||
if multiline:
|
if multiline:
|
||||||
imgui.input_text_multiline("##" + label, value, imgui.ImVec2(width, height), imgui.InputTextFlags_.read_only)
|
imgui.input_text_multiline("##" + label, value, imgui.ImVec2(width, height), imgui.InputTextFlags_.read_only)
|
||||||
@@ -2315,11 +2319,13 @@ def hello():
|
|||||||
imgui.end_child()
|
imgui.end_child()
|
||||||
else:
|
else:
|
||||||
ch, entry["content"] = imgui.input_text_multiline("##content", entry["content"], imgui.ImVec2(-1, 150))
|
ch, entry["content"] = imgui.input_text_multiline("##content", entry["content"], imgui.ImVec2(-1, 150))
|
||||||
|
imgui.separator()
|
||||||
thinking_segments = entry.get("thinking_segments", [])
|
thinking_segments = entry.get("thinking_segments", [])
|
||||||
if thinking_segments:
|
if thinking_segments:
|
||||||
self._render_thinking_trace(thinking_segments, i)
|
self._render_thinking_trace(thinking_segments, i)
|
||||||
imgui.separator()
|
|
||||||
imgui.pop_id()
|
imgui.pop_id()
|
||||||
|
if self._scroll_disc_to_bottom:
|
||||||
|
imgui.set_scroll_here_y(1.0)
|
||||||
self._scroll_disc_to_bottom = False
|
self._scroll_disc_to_bottom = False
|
||||||
imgui.end_child()
|
imgui.end_child()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user