Private
Public Access
0
0

markdown fix but introduces a regresssion...

This commit is contained in:
2026-06-03 15:50:19 -04:00
parent af0bbe9793
commit 170983b98e
2 changed files with 74 additions and 45 deletions
+37 -43
View File
@@ -3320,40 +3320,37 @@ def render_context_presets(app: App) -> None:
app.ui_active_context_preset = ""
def render_snapshot_tab(app: App) -> None:
if imgui.begin_tab_bar("snapshot_tabs"):
if imgui.begin_tab_item("Aggregate MD")[0]:
display_md = app.last_aggregate_markdown
if app.ui_focus_agent:
tier_usage = app.mma_tier_usage.get(app.ui_focus_agent)
if tier_usage:
persona_name = tier_usage.get("persona")
if persona_name:
persona = app.controller.personas.get(persona_name)
if persona and persona.context_preset:
cp_name = persona.context_preset
if cp_name in app._focus_md_cache:
display_md = app._focus_md_cache[cp_name]
else:
flat = src.project_manager.flat_config(app.controller.project, app.active_discussion)
cp = app.controller.project.get('context_presets', {}).get(cp_name)
if cp:
flat["files"]["paths"] = cp.get("files", [])
flat["screenshots"]["paths"] = cp.get("screenshots", [])
full_md, _, _ = src.aggregate.run(flat)
app._focus_md_cache[cp_name] = full_md
display_md = full_md
if imgui.button("Copy"): imgui.set_clipboard_text(display_md)
imgui.begin_child("last_agg_md", imgui.ImVec2(0, 0), True)
markdown_helper.render(display_md, context_id="snapshot_agg")
imgui.end_child()
imgui.end_tab_item()
if imgui.begin_tab_item("System Prompt")[0]:
if imgui.button("Copy"): imgui.set_clipboard_text(app.last_resolved_system_prompt)
imgui.begin_child("last_sys_prompt", imgui.ImVec2(0, 0), True)
markdown_helper.render(app.last_resolved_system_prompt, context_id="snapshot_sys")
imgui.end_child()
imgui.end_tab_item()
imgui.end_tab_bar()
with imscope.tab_bar("snapshot_tabs"):
with imscope.tab_item("Aggregate MD") as (exp, _):
if exp:
display_md = app.last_aggregate_markdown
if app.ui_focus_agent:
tier_usage = app.mma_tier_usage.get(app.ui_focus_agent)
if tier_usage:
persona_name = tier_usage.get("persona")
if persona_name:
persona = app.controller.personas.get(persona_name)
if persona and persona.context_preset:
cp_name = persona.context_preset
if cp_name in app._focus_md_cache:
display_md = app._focus_md_cache[cp_name]
else:
flat = src.project_manager.flat_config(app.controller.project, app.active_discussion)
cp = app.controller.project.get('context_presets', {}).get(cp_name)
if cp:
flat["files"]["paths"] = cp.get("files", [])
flat["screenshots"]["paths"] = cp.get("screenshots", [])
full_md, _, _ = src.aggregate.run(flat)
app._focus_md_cache[cp_name] = full_md
display_md = full_md
if imgui.button("Copy"): imgui.set_clipboard_text(display_md)
with imscope.child("last_agg_md", 0, 0, True):
markdown_helper.render(display_md, context_id="snapshot_agg")
with imscope.tab_item("System Prompt") as (exp, _):
if exp:
if imgui.button("Copy"): imgui.set_clipboard_text(app.last_resolved_system_prompt)
with imscope.child("last_sys_prompt", 0, 0, True):
markdown_helper.render(app.last_resolved_system_prompt, context_id="snapshot_sys")
#endregion: Context Management
@@ -3375,9 +3372,8 @@ def render_discussion_hub(app: App) -> None:
if exp:
if imgui.button("Copy to Clipboard"):
imgui.set_clipboard_text(app.context_preview_text)
imgui.begin_child("ctx_preview_scroll_tab", imgui.ImVec2(0, 0), True)
markdown_helper.render(app.context_preview_text, context_id="ctx_preview_tab")
imgui.end_child()
with imscope.child("ctx_preview_scroll_tab", 0, 0, True):
markdown_helper.render(app.context_preview_text, context_id="ctx_preview_tab")
with imscope.tab_item("Snapshot") as (exp, opened):
if exp: render_snapshot_tab(app)
with imscope.tab_item("Takes") as (exp, opened):
@@ -4461,9 +4457,8 @@ def render_approve_script_modal(app: App) -> None:
avail_y = imgui.get_content_region_avail().y - 40 # reserve space for buttons
if app.ui_approve_modal_preview:
imgui.begin_child("preview_child", imgui.ImVec2(-1, avail_y), True)
markdown_helper.render(f"```powershell\n{dlg._script}\n```", context_id="approve_script_preview")
imgui.end_child()
with imscope.child("preview_child", -1, avail_y, True):
markdown_helper.render(f"```powershell\n{dlg._script}\n```", context_id="approve_script_preview")
else:
ch, dlg._script = imgui.input_text_multiline("##confirm_script", dlg._script, imgui.ImVec2(-1, avail_y))
imgui.separator()
@@ -5482,7 +5477,6 @@ def render_context_preview_window(app: App) -> None:
imgui.same_line()
if imgui.button("Copy to Clipboard"):
imgui.set_clipboard_text(app.context_preview_text)
imgui.begin_child("ctx_preview_scroll", imgui.ImVec2(0, 0), True)
markdown_helper.render(app.context_preview_text, context_id="ctx_preview")
imgui.end_child()
with imscope.child("ctx_preview_scroll", 0, 0, True):
markdown_helper.render(app.context_preview_text, context_id="ctx_preview")
+37 -2
View File
@@ -134,9 +134,9 @@ class MarkdownRenderer:
if md_buf:
chunk = "".join(md_buf)
if chunk.strip():
imgui_md.render(chunk)
imgui.spacing()
self._render_md_no_bullet_overlap(chunk)
md_buf.clear()
def flush_code() -> None:
nonlocal block_idx
if code_buf:
@@ -182,6 +182,41 @@ class MarkdownRenderer:
flush_md()
flush_code()
def _render_md_no_bullet_overlap(self, chunk: str) -> None:
"""Render markdown, but split out bulleted-list sections and render them
as plain text via imgui.text to avoid imgui_md's known bullet-overlap bug.
"""
import re
list_pattern = re.compile(r"^(?P<indent>[ \t]*)(?:[-*+])\s+", re.MULTILINE)
current_pos = 0
for m in list_pattern.finditer(chunk):
if m.start() > current_pos:
pre = chunk[current_pos:m.start()]
if pre.strip(): imgui_md.render(pre)
list_start = m.start()
indent_len = len(m.group("indent"))
i = list_start
while i < len(chunk):
line_end = chunk.find("\n", i)
if line_end == -1: line_end = len(chunk)
line = chunk[i:line_end]
stripped = line.lstrip(" \t")
leading_ws = len(line) - len(stripped)
if leading_ws == indent_len and (stripped.startswith(("- ", "* ", "+ ")) or stripped == ""):
i = line_end + 1
continue
if leading_ws < indent_len:
break
i = line_end + 1
list_block = chunk[list_start:i]
for line in list_block.splitlines():
imgui.text(line) if line.strip() else imgui.spacing()
current_pos = i
if current_pos < len(chunk):
tail = chunk[current_pos:]
if tail.strip(): imgui_md.render(tail)
def render_unindented(self, text: str) -> None:
"""Render Markdown text with automatic unindentation."""
imgui_md.render_unindented(text)