fix(gui): skip empty content rendering in Discussion Hub; add token usage to comms history
This commit is contained in:
26
src/gui_2.py
26
src/gui_2.py
@@ -306,17 +306,22 @@ class App:
|
|||||||
if is_nerv: imgui.push_style_color(imgui.Col_.text, vec4(80, 255, 80))
|
if is_nerv: imgui.push_style_color(imgui.Col_.text, vec4(80, 255, 80))
|
||||||
|
|
||||||
if len(content) > COMMS_CLAMP_CHARS:
|
if len(content) > COMMS_CLAMP_CHARS:
|
||||||
imgui.begin_child(f"heavy_text_child_{label}_{id_suffix}", imgui.ImVec2(0, 80), True)
|
|
||||||
if is_md:
|
if is_md:
|
||||||
|
imgui.begin_child(f"heavy_text_child_{label}_{id_suffix}", imgui.ImVec2(0, 150), True)
|
||||||
markdown_helper.render(content, context_id=ctx_id)
|
markdown_helper.render(content, context_id=ctx_id)
|
||||||
else:
|
|
||||||
markdown_helper.render_code(content, context_id=ctx_id)
|
|
||||||
imgui.end_child()
|
imgui.end_child()
|
||||||
|
else:
|
||||||
|
imgui.input_text_multiline(f"##heavy_text_input_{label}_{id_suffix}", content, imgui.ImVec2(-1, 150), imgui.InputTextFlags_.read_only)
|
||||||
else:
|
else:
|
||||||
if is_md:
|
if is_md:
|
||||||
markdown_helper.render(content, context_id=ctx_id)
|
markdown_helper.render(content, context_id=ctx_id)
|
||||||
else:
|
else:
|
||||||
markdown_helper.render_code(content, context_id=ctx_id)
|
if self.ui_word_wrap:
|
||||||
|
imgui.push_text_wrap_pos(imgui.get_content_region_avail().x)
|
||||||
|
imgui.text(content)
|
||||||
|
imgui.pop_text_wrap_pos()
|
||||||
|
else:
|
||||||
|
imgui.text(content)
|
||||||
|
|
||||||
if is_nerv: imgui.pop_style_color()
|
if is_nerv: imgui.pop_style_color()
|
||||||
# ---------------------------------------------------------------- gui
|
# ---------------------------------------------------------------- gui
|
||||||
@@ -2282,6 +2287,7 @@ def hello():
|
|||||||
self._render_thinking_trace(thinking_segments, i)
|
self._render_thinking_trace(thinking_segments, i)
|
||||||
if read_mode:
|
if read_mode:
|
||||||
content = entry["content"]
|
content = entry["content"]
|
||||||
|
if content.strip():
|
||||||
pattern = re.compile(r"\[Definition: (.*?) from (.*?) \(line (\d+)\)\](\s+```[\s\S]*?```)?")
|
pattern = re.compile(r"\[Definition: (.*?) from (.*?) \(line (\d+)\)\](\s+```[\s\S]*?```)?")
|
||||||
matches = list(pattern.finditer(content))
|
matches = list(pattern.finditer(content))
|
||||||
is_nerv = theme.is_nerv_active()
|
is_nerv = theme.is_nerv_active()
|
||||||
@@ -2310,7 +2316,6 @@ def hello():
|
|||||||
self.text_viewer_content = res
|
self.text_viewer_content = res
|
||||||
self.show_text_viewer = True
|
self.show_text_viewer = True
|
||||||
if code_block:
|
if code_block:
|
||||||
# Render code block with highlighting
|
|
||||||
if is_nerv: imgui.push_style_color(imgui.Col_.text, vec4(80, 255, 80))
|
if is_nerv: imgui.push_style_color(imgui.Col_.text, vec4(80, 255, 80))
|
||||||
markdown_helper.render(code_block, context_id=f'disc_{i}_c_{m_idx}')
|
markdown_helper.render(code_block, context_id=f'disc_{i}_c_{m_idx}')
|
||||||
if is_nerv: imgui.pop_style_color()
|
if is_nerv: imgui.pop_style_color()
|
||||||
@@ -2914,7 +2919,16 @@ def hello():
|
|||||||
elif kind == "response":
|
elif kind == "response":
|
||||||
r = payload.get("round", 0)
|
r = payload.get("round", 0)
|
||||||
sr = payload.get("stop_reason", "STOP")
|
sr = payload.get("stop_reason", "STOP")
|
||||||
imgui.text_colored(C_LBL, f"round: {r} stop_reason: {sr}")
|
usage = payload.get("usage", {})
|
||||||
|
usage_str = ""
|
||||||
|
if usage:
|
||||||
|
inp = usage.get("input_tokens", 0)
|
||||||
|
out = usage.get("output_tokens", 0)
|
||||||
|
cache = usage.get("cache_read_input_tokens", 0)
|
||||||
|
usage_str = f" in:{inp} out:{out}"
|
||||||
|
if cache:
|
||||||
|
usage_str += f" cache:{cache}"
|
||||||
|
imgui.text_colored(C_LBL, f"round: {r} stop_reason: {sr}{usage_str}")
|
||||||
|
|
||||||
text_content = payload.get("text", "")
|
text_content = payload.get("text", "")
|
||||||
segments, parsed_response = thinking_parser.parse_thinking_trace(text_content)
|
segments, parsed_response = thinking_parser.parse_thinking_trace(text_content)
|
||||||
|
|||||||
Reference in New Issue
Block a user